fix: FX fallback price broken for peggedREAL (BRTH shows mcap 0)#856
fix: FX fallback price broken for peggedREAL (BRTH shows mcap 0)#8560xshubhs wants to merge 1 commit into
Conversation
…nd chains responses
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ 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 |
Fixes #743.
Root cause
BRTH (id 352,
peggedREAL, Polygon) has no market price: it isn't on CoinGecko andcoins.llama.fireturns{"coins":{}}for it. That part is upstream. But the repo already has an FX-rate fallback for fiat-pegged assets without a market price, and it's broken for BRL pegs in two ways:storeCharts.tsandgetChainDominance.tsderive the FX ticker withpegType.slice(-3). ForpeggedREALthat yields"EAL", but the FX feed (rates/full) keys by ISO code (BRL), so the lookup always misses and the fallback price becomes 0. Every 3-letter pegType (EUR, GBP, JPY, ...) happens to work by accident;peggedREALis the only 4-letter one and there are 5 such assets.getStableCoins.tsandgetStablecoinChains.tsdon't use the FX fallback at all — they hardcodepegType === "peggedUSD" ? 1 : 0, so any non-USD asset without a market price gets mcap 0 in the/stablecoinsand/stablecoinchainsresponses even when the chart code path would have priced it.(BRZ and cREAL never surfaced this because they have CoinGecko prices.)
Change
src/utils/fxRates.ts: addpegTypeFxTicker()(strips thepeggedprefix, with an explicitpeggedREAL -> BRLoverride) andfxFallbackPrice()(1 for USD pegs,1/fxRatefor fiat pegs, 0 forpeggedVAR/unknown).storeCharts.ts,getChainDominance.ts: usepegTypeFxTickerinstead ofslice(-3). Also fixed the dominance guard:typeof (1/undefined) === "number"is true for NaN, so the old check never caught a missing rate — nowisFinite.getStableCoins.ts,getStablecoinChains.ts: replace the hardcoded 0 withfxFallbackPricefed from the same cron FX cache, so these responses price fiat pegs consistently with the chart/dominance paths.Test
npm test brthpasses (supply adapter reads 2.97k BRTH live from Polygon).Fallback exercised against the live FX feed:
No new type errors in the touched files (the two pre-existing TS2322s in storeCharts/getChainDominance are unchanged on master).