Skip to content

fix(staking): stop showing $0 in StarGate/Juicy/BetterSwap cards#618

Merged
Agilulfo1820 merged 1 commit into
mainfrom
fix/staking-zero-usd-race
May 15, 2026
Merged

fix(staking): stop showing $0 in StarGate/Juicy/BetterSwap cards#618
Agilulfo1820 merged 1 commit into
mainfrom
fix/staking-zero-usd-race

Conversation

@Agilulfo1820

Copy link
Copy Markdown
Member

Summary

  • StarGate, Juicy Finance, and BetterSwap LP cards in the Assets → Staking tab intermittently rendered $0 even when the user had open positions. Refreshing sometimes resolved it, sometimes didn't.
  • Root cause: valueUsd was computed inside each hook's React Query queryFn, while token prices come from a separate query that wasn't in the staking query key. When the staking call resolved before prices loaded, $0 got baked into the cached result and stuck for the full 60s staleTime.
  • Fix: queryFn now returns only raw on-chain data (amounts, decimals, delegation, etc.). valueUsd / valueInCurrency are derived in a useMemo from live prices / exchangeRates / currentCurrency, so a late-arriving price query repopulates values without re-running the on-chain calls. This matches the pattern useNavigatorPosition was already using.

Files: useStargatePositions.ts, useJuicyPosition.ts, useBetterSwapLpPositions.ts.

Test plan

  • Open Account modal → Assets → Staking tab with a fresh page load (cold price cache). StarGate, Juicy Finance, and BetterSwap LP cards should show non-zero USD values once prices load, without needing a refresh.
  • Switch currency (USD → EUR/GBP). Values update without re-fetching on-chain data.
  • Verify Navigators card still works (unchanged code path).
  • yarn kit:typecheck and yarn lint pass.

🤖 Generated with Claude Code

…d into cache

StarGate, Juicy Finance and BetterSwap LP cards intermittently showed $0
because valueUsd was computed inside the React Query queryFn. Token prices
come from a separate query that wasn't part of the staking query key, so
when the staking call resolved before prices loaded, $0 was baked into the
cached result and persisted for the 60s staleTime.

queryFn now returns only raw on-chain data; valueUsd/valueInCurrency are
derived in a useMemo from live prices/exchangeRates/currentCurrency, so a
late-arriving price query repopulates values without re-running chain calls.
Matches the pattern useNavigatorPosition already used.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Agilulfo1820 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3de6cbf-26bf-47cd-aa54-1fb730a59c81

📥 Commits

Reviewing files that changed from the base of the PR and between 3dafef5 and 5091783.

📒 Files selected for processing (3)
  • packages/vechain-kit/src/hooks/api/staking/useBetterSwapLpPositions.ts
  • packages/vechain-kit/src/hooks/api/staking/useJuicyPosition.ts
  • packages/vechain-kit/src/hooks/api/staking/useStargatePositions.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/staking-zero-usd-race

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Size Change: +3.66 kB (+0.04%)

Total Size: 8.48 MB

Filename Size Change
packages/vechain-kit/dist/index-BIFBD2Gz.d.mts 0 B -170 kB (removed) 🏆
packages/vechain-kit/dist/index-BIFBD2Gz.d.mts.map 0 B -46.8 kB (removed) 🏆
packages/vechain-kit/dist/index-C8Uj8ple.d.cts 0 B -5.63 kB (removed) 🏆
packages/vechain-kit/dist/index-C8Uj8ple.d.cts.map 0 B -2.99 kB (removed) 🏆
packages/vechain-kit/dist/index-DrDs3YBR.d.cts 0 B -170 kB (removed) 🏆
packages/vechain-kit/dist/index-DrDs3YBR.d.cts.map 0 B -46.8 kB (removed) 🏆
packages/vechain-kit/dist/index.cjs.map 2.7 MB +1.58 kB (+0.06%)
packages/vechain-kit/dist/index.mjs.map 2.64 MB +1.55 kB (+0.06%)
packages/vechain-kit/dist/index-3dQQ7yMU.d.cts 170 kB +170 kB (new file) 🆕
packages/vechain-kit/dist/index-3dQQ7yMU.d.cts.map 46.8 kB +46.8 kB (new file) 🆕
packages/vechain-kit/dist/index-CS2f2zH9.d.mts 170 kB +170 kB (new file) 🆕
packages/vechain-kit/dist/index-CS2f2zH9.d.mts.map 46.8 kB +46.8 kB (new file) 🆕
packages/vechain-kit/dist/index-DeHUdOFZ.d.cts 5.63 kB +5.63 kB (new file) 🆕
packages/vechain-kit/dist/index-DeHUdOFZ.d.cts.map 2.99 kB +2.99 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
packages/vechain-kit/dist/assets 4.1 kB 0 B
packages/vechain-kit/dist/assets-BL24r-Yp.mjs 51.3 kB 0 B
packages/vechain-kit/dist/assets-BL24r-Yp.mjs.map 74.1 kB 0 B
packages/vechain-kit/dist/assets-DNJsQD7_.cjs 58.5 kB 0 B
packages/vechain-kit/dist/assets-DNJsQD7_.cjs.map 75.5 kB 0 B
packages/vechain-kit/dist/assets/index.cjs 716 B 0 B
packages/vechain-kit/dist/assets/index.d.cts 973 B 0 B
packages/vechain-kit/dist/assets/index.d.mts 973 B 0 B
packages/vechain-kit/dist/assets/index.mjs 718 B 0 B
packages/vechain-kit/dist/index-B7W1mM8I.d.mts 5.63 kB 0 B
packages/vechain-kit/dist/index-B7W1mM8I.d.mts.map 2.99 kB 0 B
packages/vechain-kit/dist/index.cjs 1.11 MB +283 B (+0.03%)
packages/vechain-kit/dist/index.d.cts 22.8 kB 0 B
packages/vechain-kit/dist/index.d.mts 22.8 kB 0 B
packages/vechain-kit/dist/index.mjs 1.07 MB +244 B (+0.02%)
packages/vechain-kit/dist/utils 4.1 kB 0 B
packages/vechain-kit/dist/utils-DJKLAzLP.cjs 27.2 kB 0 B
packages/vechain-kit/dist/utils-DJKLAzLP.cjs.map 67.2 kB 0 B
packages/vechain-kit/dist/utils-KYzX9d5n.mjs 22.1 kB 0 B
packages/vechain-kit/dist/utils-KYzX9d5n.mjs.map 66.5 kB 0 B
packages/vechain-kit/dist/utils/index.cjs 1.98 kB 0 B
packages/vechain-kit/dist/utils/index.d.cts 3.04 kB 0 B
packages/vechain-kit/dist/utils/index.d.mts 3.04 kB 0 B
packages/vechain-kit/dist/utils/index.mjs 2 kB 0 B

compressed-size-action

@Agilulfo1820 Agilulfo1820 merged commit fd209e6 into main May 15, 2026
7 checks passed
@Agilulfo1820 Agilulfo1820 deleted the fix/staking-zero-usd-race branch May 15, 2026 07:39
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.

1 participant