Skip to content

fix(utils): prevent scientific notation in formatTokenAmount for large decimals#2604

Open
jaffarkeikei wants to merge 1 commit intocoinbase:mainfrom
jaffarkeikei:fix/formatTokenAmount-scientific-notation
Open

fix(utils): prevent scientific notation in formatTokenAmount for large decimals#2604
jaffarkeikei wants to merge 1 commit intocoinbase:mainfrom
jaffarkeikei:fix/formatTokenAmount-scientific-notation

Conversation

@jaffarkeikei
Copy link
Copy Markdown

What changed? Why?

formatTokenAmount now returns proper decimal notation instead of scientific notation for small amounts with large decimals.

Notes to reviewers

Without fix:

formatTokenAmount('1000', 50)  // Returns "1e-47" ❌

With fix:

formatTokenAmount('1000', 50)  // Returns "0.00000...001" ✓

Uses toFixed() for small numbers (<1) to avoid scientific notation, then strips trailing zeros.

How has it been tested?

Manual testing:

  • Large decimals (50): proper decimal notation
  • Normal decimals (18): works as before
  • Zero/negative amounts: handled correctly

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 29, 2026

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

A member of the Team first needs to authorize it.

@cb-heimdall
Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants