Skip to content

Conversation

@salimtb
Copy link
Contributor

@salimtb salimtb commented Nov 18, 2025

Explanation

What is the current state of things and why does it need to change?

The CurrencyRateController has a fallback mechanism that uses spot prices from the token prices service when the primary exchange rates API fails. However, this fallback was sending duplicate native token addresses (the 0x0000...0000 address) to the API endpoint, causing requests to fail with the error: "All tokenAddresses's elements must be unique".

What is the solution your changes offer and how does it work?

The issue occurred because:

  1. The CurrencyRateController was explicitly passing the native token address in the tokenAddresses array: tokenAddresses: [nativeTokenAddress]
  2. The fetchTokenPrices method in CodefiTokenPricesServiceV2 automatically prepends the native token address to any token addresses passed to it (line 496 in codefi-v2.ts)
  3. This resulted in the native token address appearing twice in the API URL

The fix changes tokenAddresses: [nativeTokenAddress] to tokenAddresses: [] since the service already handles including the native token address automatically. This ensures each address appears only once in the final API request.

Are there any changes whose purpose might not be obvious to those unfamiliar with the domain?

The empty array [] might seem counterintuitive, but it's the correct approach because the fetchTokenPrices method is designed to always include the native token address by default for any chain.

References

Fixes the duplicate token address validation error in the spot price fallback mechanism introduced after removing the CryptoCompare fallback in #7167.

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Stops sending the native token address explicitly to fetchTokenPrices (pass tokenAddresses: []) to avoid duplicates in spot price fallback requests.

  • CurrencyRateController:
    • Update fallback spot price logic to call fetchTokenPrices({ chainId, tokenAddresses: [], currency }), relying on the service to include the native token automatically.
  • Tests:
    • Adjust expectations in CurrencyRateController.test.ts to assert tokenAddresses: [] for ETH/BNB/POL scenarios and related calls.
  • Changelog:
    • Add Unreleased fix entry describing duplicate native token address issue in spot price fallback.

Written by Cursor Bugbot for commit 64c9a6b. This will update automatically on new commits. Configure here.

@salimtb salimtb force-pushed the fix/currency-rate-duplicate-native-token branch from cb4b688 to 64c9a6b Compare November 18, 2025 17:13
@salimtb salimtb marked this pull request as ready for review November 18, 2025 17:18
@salimtb salimtb requested review from a team as code owners November 18, 2025 17:18
@salimtb salimtb added this pull request to the merge queue Nov 18, 2025
Merged via the queue into main with commit 579cb28 Nov 18, 2025
275 checks passed
@salimtb salimtb deleted the fix/currency-rate-duplicate-native-token branch November 18, 2025 17:27
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.

3 participants