fix: stabilize token details headline price#30940
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 82234da. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
No E2E tags are warranted for this isolated UI rendering fix. Performance Test Selection: |

Description
When switching between time ranges (1H, 1D, 1W, 1M, 1Y) on the token details advanced chart, the headline price visibly jumps through 3-4 intermediate values before settling (~$3+ range on ETH). This creates a jarring flicker experience.
Root cause: Three data sources provide slightly different "current price" values, and during a time-range switch the headline cycles through all of them in sequence:
lastBarClosefrom the previous time range'sohlcvData(still in memory before the new API call returns)lastBarClosefrom the fresh/v3/ohlcv-chartresponse (bucketed candle close — lags behind real price by minutes/hours depending on interval granularity)/v3/ohlcv/latestpoll result (fresher candle snapshot)When the user switches time ranges, the WS unsubscribes and
realtimeClosebecomesundefined, causing the headline to fall back to stale candle data. The coarser the candle interval, the more pronounced the stale price (daily candles on 1Y can be hours old).Fix
Hold the last known WS/realtime price in a ref during time-range transitions. The headline stays stable until fresh realtime data arrives from
/latestor WS (~500ms after switch).Changelog
CHANGELOG entry: stabilize headline price in token details.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3314
Manual testing steps
Screenshots/Recordings
Before
Screen.Recording.2026-06-02.at.16.11.55.mov
After
Screen.Recording.2026-06-02.at.16.10.37.mov
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Localized display logic in Price.advanced.tsx with no auth, persistence, or API contract changes.
Overview
Fixes headline price flicker on the token details advanced chart when users switch time ranges (1H–1Y). During a range change, WebSocket updates pause and the UI was falling through to stale or bucketed OHLCV candle closes, so the displayed price jumped across several values.
Price.advanced.tsxnow keeps the last known realtime close in a ref and usesstablePrice(realtimeClose ?? lastRealtimeRef) fordisplayPriceanddisplayDiff, so the headline stays on the previous live price until fresh realtime data returns—aligned with the existing stable compare price pattern used while series data reloads.Reviewed by Cursor Bugbot for commit 82234da. Bugbot is set up for automated code reviews on this repo. Configure here.