From e5cf719d3073cc11f6248afeef2936e33bf1d097 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 18 Dec 2023 10:15:39 -0800 Subject: [PATCH] fix: fixed balance formatting in dropdown --- src/components/elements/input/token/selector/row.svelte | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/elements/input/token/selector/row.svelte b/src/components/elements/input/token/selector/row.svelte index 91f00355..5a650ad6 100644 --- a/src/components/elements/input/token/selector/row.svelte +++ b/src/components/elements/input/token/selector/row.svelte @@ -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`