fix(assets-controller): preserve EVM bridge exchange rates when currency has no CAIP mapping - #10064
Open
gomesalexandre wants to merge 2 commits into
Open
Conversation
…ncy has no CAIP mapping formatExchangeRatesForBridge bailed out of the whole function - wiping EVM marketData/currencyRates too - when a currency lookup needed only by the non-EVM branch (to key conversionRates) failed. Fixed to only affect the non-EVM entry for a genuinely unmapped currency, preserving EVM output. The fallback omits (rather than mislabels) the non-EVM entry, since price is already denominated in selectedCurrency and relabeling it as some other currency would be wrong data. Also adds the missing `gel` (Georgian lari) entry to MAP_CAIP_CURRENCIES - the only SupportedCurrency actually absent from the map today, confirmed against packages/core-backend's SupportedCurrency type and the live price API's supportedVsCurrencies list.
gomesalexandre
marked this pull request as ready for review
September 1, 2026 22:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it says on the box
formatExchangeRatesForBridgebailed out of the entire exchange-rate response — wiping EVMmarketData/currencyRatestoo — when a currency lookup that's only needed by the non-EVM branch (to keyconversionRates) failed to find a match inMAP_CAIP_CURRENCIES. This was broken today for at least one real, currently-supported currency (gel), and the shared map has no test coverage tying it to the actual set of supported currencies, so the gap could reopen silently.The real gap this closes
Cross-checked
MAP_CAIP_CURRENCIES's keys againstpackages/core-backend/src/api/shared-types.ts'sSupportedCurrencytype (the authoritative "currencies this backend actually supports" list) — after addinggel, the map is now a full superset:Also confirmed live against the price API
formatExchangeRatesForBridge's data ultimately comes from (https://price.api.cx.metamask.io/v1/supportedVsCurrencies) — it returns 94 supported vs-currencies includinggel.The fix
packages/assets-controllers/src/MultichainAssetsRatesController/constant.ts— added the missinggel: 'swift:0/iso4217:GEL'entry. This is the actual production gap; every otherSupportedCurrencywas already mapped.formatExchangeRatesForBridge.ts— the top-level bail-out is gone. The currency lookup only affects the non-EVM (else) branch that actually consumes it — EVMmarketData/currencyRatesare computed unconditionally, regardless of whether the selected currency has a CAIP mapping.For a genuinely unmapped currency (any future gap, or caller error), the fix deliberately omits rather than mislabels the non-EVM
conversionRatesentry —pricefor a non-EVM asset is already denominated inselectedCurrency, so silently falling back to e.g.MAP_CAIP_CURRENCIES.usd(my first draft's approach, corrected after adversarial review — see receipts) would emit agel-denominated price mislabeled as USD. That's wrong data, not a safe fallback, so it's correctly left out instead.Mirrors the same-map-consuming sibling
MultichainAssetsRatesController.ts's existing pattern of not letting an unmapped currency wipe out unrelated computed data.Testing
New tests cover:
'xyz') currency: EVMmarketData/currencyRatesare still returned; the non-EVMconversionRatesentry is correctly omitted (not mislabeled).gelspecifically, end-to-end: EVM data resolves normally, and the non-EVMconversionRatesentry resolves under the correctswift:0/iso4217:GELCAIP currency (not USD).receipts
Codex adversarial review
Ran
codex execsynchronously (not backgrounded) as a second reviewer, twice.First pass caught a real correctness bug in my initial fix: my first draft fell back to
MAP_CAIP_CURRENCIES.usdfor any unmapped currency — which is semantically wrong, since a non-EVM asset'spricefield is already denominated inselectedCurrency(onlyusdPriceis always USD), so labeling agel-denominated price asswift:0/iso4217:USDwould be incorrect data. Codex also independently ran its own cross-check (SupportedCurrencytype vs.MAP_CAIP_CURRENCIESkeys) and foundgelis the only real gap — which reframed the fix from "add a generic fallback" to "close the actual gap directly, and make the generic fallback path correctly omit instead of mislabel." Rewrote accordingly (this PR's current state).Second pass confirmed the correctness issue is fully resolved, and caught two minor follow-ups (a formatting nit, missing changelog entries in both touched packages) — both fixed before opening.
risk
Low.
packages/assets-controllers/src/MultichainAssetsRatesController/constant.tsgets one new key (gel), which is purely additive — no existing key or value changes.formatExchangeRatesForBridge.ts's behavior is unchanged for every currently-supported currency (all of which are now in the map); the change only affects the previously-broken unmapped-currency path.Note
Low Risk
Additive
gelmap entry and narrowed behavior change only for previously broken unmapped-currency paths; mapped currencies behave as before.Overview
Fixes bridge exchange-rate formatting when the selected fiat currency is missing from
MAP_CAIP_CURRENCIES(notably Georgian lari /gel). PreviouslyformatExchangeRatesForBridgereturned emptymarketDataandcurrencyRatesfor the whole response if the CAIP lookup failed, even though that lookup is only needed for non-EVMconversionRates.MAP_CAIP_CURRENCIESnow includesgel → swift:0/iso4217:GEL.formatExchangeRatesForBridgeno longer early-exits on a failed lookup; EVMmarketData/currencyRatesare always built, and non-EVMconversionRatesare added only whencurrencyCaipexists—otherwise they are omitted (not mislabeled as USD).Tests cover the fictional unmapped currency path and end-to-end
gelbehavior.Reviewed by Cursor Bugbot for commit c934195. Bugbot is set up for automated code reviews on this repo. Configure here.