fix(assets): resolve USDC price via primary-protocol fallback in transfer dropdowns#167
Merged
Merged
Conversation
…sfer dropdowns The Swap/Deposit/Withdraw dropdowns priced each asset via pricesStore.prices[currency.key], where currency came from tryGetCurrencyByDenom(denom). For shared-IBC-denom assets like USDC, that denom-keyed map resolves to a single arbitrary protocol entry (e.g. USDC@NEUTRON) whose key has no published price, so the value defaulted to 0: USDC showed $0.00 and the stable-value comparator sorted it below zero-balance tokens. The Assets table was unaffected because it resolves via the network's primary protocol, which is priced. Add a shared getPriceForCurrency helper that returns the currency's own price or, when its key is absent from the feed, falls back to the network's primary-protocol key for the same ticker — the same path the Assets table uses — before defaulting to "0". Route all seven price lookups across the three forms through it (dropdown lists and amount estimators) so the modal stays consistent, and drop the now-unused prices-store wiring.
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.
Summary
Fix USDC (and other shared-IBC-denom assets) showing
$0.00and mis-sorting to the bottom of the Assets transfer modal's Swap/Deposit/Withdraw dropdowns despite a real balance. Closes #166.The dropdowns priced each asset via
pricesStore.prices[currency.key], wherecurrencyis resolved throughtryGetCurrencyByDenom(denom). For a shared IBC denom (e.g. USDC), that denom-keyed map holds one arbitrary protocol entry (e.g.USDC@NEUTRON) whose key has no published price, so the value defaulted to0. The main Assets table was unaffected because it resolves via the network's primary protocol, which is priced.Changes
getPriceForCurrency(currency)inCurrencyLookup.ts: returns the currency's own price, or — when its key is absent from the feed — falls back to the network's primary-protocol key for the same ticker (the same path the Assets table uses viagetCurrencyByTickerForNetwork), before defaulting to"0". Thedirect != nullcheck distinguishes "unpriced" from "genuinely priced at 0".calculatedBalance,firstCalculatedBalance,secondCalculatedBalance) — so the whole modal stays consistent, not just the dropdown listing.CurrencyLookup.test.tscovering own-price, primary-protocol fallback, the double-miss"0"default, and the dropdown sort position for a held-balance asset whose denom-resolved key is unpriced.Verification
npx tsc --noEmit— passednpx prettier --checkon changed files — passednpx eslint --max-warnings=0on changed files — passednpx vitest run— 764 tests passed across 49 files (4 new regression tests added)Notes