Skip to content

Commit

Permalink
fix: fixed balance formatting in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Dec 18, 2023
1 parent aa07787 commit e5cf719
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/elements/input/token/selector/row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
}
function formatBalanceString(balanceString: string) {
if (balanceString.length < 9) {
return balanceString
}
const balanceInIntegers = balanceString.split('.')[0]
const decimals = balanceString.split('.')[1]
if (balanceInIntegers.length < 8) {
return balanceInIntegers
return decimals?.length === 0
? balanceString
: `${balanceInIntegers}.${decimals.substring(0, 4)}`
}
return `${Number(balanceInIntegers) / 1000000} M`
Expand Down

0 comments on commit e5cf719

Please sign in to comment.