fix(staking): stop showing $0 in StarGate/Juicy/BetterSwap cards#618
Conversation
…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]>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Size Change: +3.66 kB (+0.04%) Total Size: 8.48 MB
ℹ️ View Unchanged
|
Summary
$0even when the user had open positions. Refreshing sometimes resolved it, sometimes didn't.valueUsdwas computed inside each hook's React QueryqueryFn, while token prices come from a separate query that wasn't in the staking query key. When the staking call resolved before prices loaded,$0got baked into the cached result and stuck for the full 60sstaleTime.queryFnnow returns only raw on-chain data (amounts, decimals, delegation, etc.).valueUsd/valueInCurrencyare derived in auseMemofrom liveprices/exchangeRates/currentCurrency, so a late-arriving price query repopulates values without re-running the on-chain calls. This matches the patternuseNavigatorPositionwas already using.Files:
useStargatePositions.ts,useJuicyPosition.ts,useBetterSwapLpPositions.ts.Test plan
yarn kit:typecheckandyarn lintpass.🤖 Generated with Claude Code