Skip to content

Commit

Permalink
Fix 100M bug (#265)
Browse files Browse the repository at this point in the history
Fix 100M bug
  • Loading branch information
neural-machine authored Sep 30, 2022
1 parent 776c471 commit 0841f22
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions util/formatCompactNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ const formatWithOneDecimal = new Intl.NumberFormat('en-US', {
maximumFractionDigits: 1,
})

const oneMillion = 1000000
const hundredMillions = 100 * oneMillion
const oneMillion = 1e6

export const formatCompactNumber = (
value: number,
kind: 'tokenAmount' | 'dollarValue' = 'dollarValue'
) => {
if (value > hundredMillions) {
return `${Math.round(value / hundredMillions)}M`
}
if (value > oneMillion) {
return `${formatWithOneDecimal.format(value / oneMillion)}M`
}
Expand Down

0 comments on commit 0841f22

Please sign in to comment.