Skip to content

fix: scientific notation price conversion bug#2053

Merged
CarsonRoscoe merged 3 commits intox402-foundation:mainfrom
coinbase:fix/nanopayment-usd-pricing
Apr 17, 2026
Merged

fix: scientific notation price conversion bug#2053
CarsonRoscoe merged 3 commits intox402-foundation:mainfrom
coinbase:fix/nanopayment-usd-pricing

Conversation

@CarsonRoscoe
Copy link
Copy Markdown
Contributor

Description

There existed a bug with parseFloat where if the string had 7 or more decimals of precision (e.g. "$0.0000001"), it would convert to scientific notation format and bugout.

In practice, this is not much of an issue. Nanopayments are not economically feasible in the schemes today (as gas is more expensive than the amount transferred), and this is such a small number that it in fact rounds down to 0 if you tried to express it in a stablecoin with 6 decimals such as USDC or USDT. However, it is nonetheless a bug, and nanopayments will be more economically feasible once we complete development of the batch-settlement scheme

Tests

Added new unit tests to cover the fix

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
  • I added a changelog fragment for user-facing changes (docs-only changes can skip)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

@CarsonRoscoe is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added typescript sdk Changes to core v2 packages labels Apr 16, 2026
@CarsonRoscoe CarsonRoscoe merged commit dc04108 into x402-foundation:main Apr 17, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sdk Changes to core v2 packages typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants