Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Prithpal-Sooriya
Copy link
Contributor

@Prithpal-Sooriya Prithpal-Sooriya commented Dec 5, 2025

Explanation

Adds back decimal precision bounding to 9dp for the CurrencyRateController conversionRate properties.

This is so our clients do not crash due to large decimals when using BigNumber (exceeding the 15 significant digit limit)

References

Fixes issues around BigNumber calculations (exceeding the 15 significant digit limit) - https://metamask.sentry.io/issues/7082421955/?project=273505&referrer=slack

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

Bounds CurrencyRateController conversion rates to 9 decimal places and updates tests/changelog accordingly.

  • Assets Controllers:
    • CurrencyRateController: Add boundedPrecisionNumber and clamp conversionRate and usdConversionRate to 9dp in both Price API path and token price fallback.
  • Tests:
    • Update expectations in CurrencyRateController.test.ts to reflect 9dp precision; minor namespace type cleanup.
  • Docs:
    • Update CHANGELOG.md with the fix.

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

Comment on lines +278 to +280
conversionRate: tokenPrice?.price
? boundedPrecisionNumber(tokenPrice.price)
: null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add bounds for the fallback currency fetching.

Screenshot 2025-12-05 at 11 30 10

Comment on lines 206 to 211
conversionRate: rate?.value
? boundedPrecisionNumber(1 / rate.value)
: null,
usdConversionRate: rate?.usd
? boundedPrecisionNumber(1 / rate.usd)
: null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add bounds for main currency fetches.

@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review December 5, 2025 12:23
@Prithpal-Sooriya Prithpal-Sooriya requested review from a team as code owners December 5, 2025 12:23
salimtb
salimtb previously approved these changes Dec 5, 2025
sahar-fehri
sahar-fehri previously approved these changes Dec 5, 2025
juanmigdr
juanmigdr previously approved these changes Dec 5, 2025
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Dec 5, 2025
Merged via the queue into main with commit 0601aeb Dec 5, 2025
281 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the fix/add-decimal-bounds-to-currency-rates branch December 5, 2025 13:23
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.

5 participants