Skip to content

Show wallet-specific estimated APR on GMX asset card fedev-4006#2608

Open
timgmxio wants to merge 2 commits into
releasefrom
wallet-specific-estimated-apr-gmx-card-fedev-4006
Open

Show wallet-specific estimated APR on GMX asset card fedev-4006#2608
timgmxio wants to merge 2 commits into
releasefrom
wallet-specific-estimated-apr-gmx-card-fedev-4006

Conversation

@timgmxio

@timgmxio timgmxio commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploying gmx-interface-home with  Cloudflare Pages  Cloudflare Pages

Latest commit: a26e03f
Status: ✅  Deploy successful!
Preview URL: https://73424099.gmx-interface-home.pages.dev
Branch Preview URL: https://wallet-specific-estimated-ap.gmx-interface-home.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploying gmx-interface with  Cloudflare Pages  Cloudflare Pages

Latest commit: a26e03f
Status: ✅  Deploy successful!
Preview URL: https://b76c147a.gmx-interface.pages.dev
Branch Preview URL: https://wallet-specific-estimated-ap.gmx-interface.pages.dev

View logs

@divhead

divhead commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Review pass — wallet-specific Est. APR

⚠️ Cross-chain APR basis mismatch on non-Arbitrum chains
The Est. APR numerator and denominator come from different chains. useBuybackWeeklyStats() is hardcoded to Arbitrum — useGmxSdk(ARBITRUM) and SWR key ["buybackWeeklyStats", ARBITRUM] (useBuybackWeeklyStats.ts:11,14), so the weekly buyback pace is always arbitrum.gmxapi.io. But the staking-power share and staked amount come from the active chain — useStakingPowerData(chainId) (GmxAssetCard.tsx:51). The Est. APR row renders on the active chain with no chain gate (GmxAssetCard.tsx:280), and Avalanche has real GMX/esGMX staking. So on Avalanche the row computes Est. APR = (Arbitrum weekly buyback × 52 × Avalanche share) / Avalanche staked — an internally incoherent number (numerator from one chain, share/denominator from another).
Fix: gate the Est. APR row to chainId === ARBITRUM, or fetch the buyback pace for the active chain instead of hardcoding ARBITRUM.
(Caveat: if avalanche.gmxapi.io staking-power returns empty today, the row degrades to "—" and no wrong number shows — but the coupling should be gated in code, not left to backend behavior.)

@divhead

divhead commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Two low-severity follow-ups on the Est. APR card:

💡 Two share sources on the same card can disagree
The "Staking Power Share" row renders the server field stakingPowerData.userSharePercent (GmxAssetCard.tsx:496), while getUserEstimatedApr derives its own share from cumulativePower / totalNetworkPower (passed as userStakingPower / totalNetworkStakingPower, GmxAssetCard.tsx:140-141getUserEstimatedApr, stakingPowerUtils.ts:59-60). If the backend's userSharePercent isn't exactly cumulativePower / totalNetworkPower × 100, the displayed Share and the APR-implied share diverge on the same card. Worth confirming the two definitions agree, or deriving both from one source.

💡 Est. APR shows a loading skeleton for disconnected wallets (cosmetic)
isUserEstimatedAprLoading = isStakingPowerLoading || isBuybackStatsLoading (GmxAssetCard.tsx:152), and isBuybackStatsLoading (useBuybackWeeklyStats) loads regardless of wallet connection. So while disconnected, the sibling "Accumulated rewards" row shows "—" immediately (GmxAssetCard.tsx:238) but "Est. APR" shows a skeleton (:271) until the Arbitrum buyback query resolves, then also "—". Optionally gate the APR skeleton on account as well. Purely cosmetic.

…-4006

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@timgmxio

timgmxio commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

💡 Two share sources on the same card can disagree
The "Staking Power Share" row renders the server field stakingPowerData.userSharePercent (GmxAssetCard.tsx:496), while getUserEstimatedApr derives its own share from cumulativePower / totalNetworkPower (passed as userStakingPower / totalNetworkStakingPower, GmxAssetCard.tsx:140-141getUserEstimatedApr, stakingPowerUtils.ts:59-60). If the backend's userSharePercent isn't exactly cumulativePower / totalNetworkPower × 100, the displayed Share and the APR-implied share diverge on the same card. Worth confirming the two definitions agree, or deriving both from one source.

Two share sources — verified, no change needed. gmx-api computes userSharePercent from the exact same cumulativePower / totalNetworkPower of the same response snapshot (stakingService.ts), just truncated to basis points for display. Max divergence is 0.01pp — invisible at toFixed(2) (live check: derived 0.14237% vs server 0.14%). The APR keeps the unrounded ratio, as FEDEV-4006 explicitly requires unrounded source values.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Playwright Component Test Report

All tests passed.

View Report

Commit a26e03f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants