-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: NWNT-681: Add useTronStakeApy hook #23743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…chain to avoid inaccurate values if chain is switched
| const fetchConsensysWitness = useCallback(async () => { | ||
| try { | ||
| setIsLoading(true); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also clear the error on a new fetch? with setErrorMessage(null);
Just in case there's any.
I can add this after its merged.
zone-live
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment. Looks great 💪🏼
9c728cd to
04573a4
Compare
04573a4 to
1d8376e
Compare
nickewansmith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved to unblock, with comment
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThe PR introduces TRON staking support by:
The changes are primarily additive (new TRON staking functionality) rather than modifying existing code paths. The stake-sdk upgrade follows semver with a minor version bump, suggesting backward compatibility. However, since this upgrades a core staking SDK dependency and touches the staking infrastructure, running staking-related tests is appropriate. The existing stake E2E test ( Unit tests have been added for the new hook and utility function, which increases confidence in the implementation. |
|



Description
Added new
useTronStakeApyhook.Changes:
useTronStakeApyhook which fetches all witness data and returns the APY for the Consensys witness and exposes the following properties:trueif actively fetching witness data.annualizedRatein decimal formannualizedRatein percentage form^3.4.0.truncateNumberutil. This is used to format the Tron staking APY without rounding.Note:
useTronStakeApycallsgetWitnessesfrom the stake-sdk which fetches all witnesses data. Meaning if additional data besides the APR is desired this function can be reused elsewhere.Changelog
CHANGELOG entry: added useTronStakeApy hook
Related issues
Fixes: NWNT-681: Add tron staking apy to client
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Adds
useTronStakeApyhook to fetch Consensys TRON witness APY, introducestruncateNumber, exposestronStakingApiService, and bumps@metamask/stake-sdkto^3.4.0with tests.useTronStakeApyto fetch witnesses viatronStakingApiService.getWitnesses(defaultTRON_MAINNET), computeapyDecimal/apyPercent, handle loading/error, and supportrefetch/chainIdoptions.truncateNumberinapp/components/UI/Earn/utils/number.tsfor 2-decimal truncation without rounding.tronStakingApiServicefromearnApiService.tronStakinginapp/components/UI/Stake/sdk/stakeSdkProvider.tsx.@metamask/stake-sdkto^3.4.0.useTronStakeApyandtruncateNumber.Written by Cursor Bugbot for commit a42d1d4. This will update automatically on new commits. Configure here.