Skip to content

Commit

Permalink
fix: formatNumber format str
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMasayoshi committed May 3, 2024
1 parent e5a23b2 commit 1db3f55
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/sushi/src/format/number.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numeral from 'numbro'

export const formatNumber = (value: any, inputString = '0.00a') => {
export const formatNumber = (value: any, inputString = '0.[00]a') => {
if (typeof value === 'string') value = Number(value)

let negative = false
Expand All @@ -10,9 +10,9 @@ export const formatNumber = (value: any, inputString = '0.00a') => {
}

if (value === 0) return '0.00'
if (value < 0.0001) return numeral(value).format('0.000000a')
if (value < 0.001) return numeral(value).format('0.0000a')
if (value < 0.01) return numeral(value).format('0.000a')
if (value < 0.0001) return numeral(value).format('0.[000000]a')
if (value < 0.001) return numeral(value).format('0.[0000]a')
if (value < 0.01) return numeral(value).format('0.[000]a')
return `${negative ? '-' : ''}${numeral(value).format(inputString)}`
}

Expand Down

0 comments on commit 1db3f55

Please sign in to comment.