Skip to content

fix: held tokens price data#9008

Draft
GeorgeGkas wants to merge 1 commit into
mainfrom
swaps-fix-price-data
Draft

fix: held tokens price data#9008
GeorgeGkas wants to merge 1 commit into
mainfrom
swaps-fix-price-data

Conversation

@GeorgeGkas
Copy link
Copy Markdown
Contributor

@GeorgeGkas GeorgeGkas commented Jun 4, 2026

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Scoped selector change for display and quote metadata pricing; bridge controller rates still take precedence and legacy paths are unchanged when assetsPrice is absent.

Overview
Fixes missing fiat values for held tokens (e.g. USDC) when clients use unified AssetsController pricing via useAssetsControllerForRates.

selectExchangeRateByAssetId now looks up fungible assetsPrice entries (after bridge assetExchangeRates, before legacy marketData / currency slices), mapping price / usdPrice to exchangeRate / usdExchangeRate. normalizeAssetId aligns lowercased CAIP-19 IDs with checksummed keys; NFT and invalid price rows are skipped. Exchange-rate source types include optional assetsPrice. Tests and changelog document the behavior.

Reviewed by Cursor Bugbot for commit ffab58f. Bugbot is set up for automated code reviews on this repo. Configure here.

@GeorgeGkas GeorgeGkas requested review from a team as code owners June 4, 2026 16:00
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 ffab58f. Configure here.

// held tokens (e.g. USDC) produce a fiat value. `normalizeAssetId` checksums
// EVM ERC-20 references so a lower-cased input matches the stored key.
const assetPrice =
assetsPrice?.[normalizeAssetId(assetId)] ?? assetsPrice?.[assetId];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Malformed ERC20 lookup throws

Medium Severity

selectExchangeRateByAssetId now always calls normalizeAssetId before legacy rate paths. For invalid short EVM ERC-20 references, normalizeAssetId checksums via toChecksumAddress, which throws on non–40-character hex. That breaks the prior contract of returning {} without throwing for malformed asset IDs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ffab58f. Configure here.

@GeorgeGkas GeorgeGkas marked this pull request as draft June 4, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant