From d69d473caa1437659e3f2ff7abbb8a5d9a6b3c58 Mon Sep 17 00:00:00 2001 From: Alexander Evchenko Date: Wed, 4 Oct 2023 13:49:15 +0400 Subject: [PATCH] fix: if no .BTC in usdPrices set the price param to 0 as in ERC20 --- src/redux/slices/balancesSlice/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/redux/slices/balancesSlice/index.ts b/src/redux/slices/balancesSlice/index.ts index cf29d47bd..81e55e5d7 100644 --- a/src/redux/slices/balancesSlice/index.ts +++ b/src/redux/slices/balancesSlice/index.ts @@ -33,9 +33,13 @@ export const getBalance = ( } let balance = balanceToDisplay(tokenBalance, token.decimals, 4) + + // if the balance's decimals places are greater than 4 if (Number(balance) === 0) { balance = balanceToDisplay(tokenBalance, token.decimals, 6) } + + // if the balance's decimals places are greater than 6 if (Number(balance) === 0) { balance = balanceToDisplay(tokenBalance, token.decimals, 8) } @@ -68,7 +72,7 @@ export const addOrUpdateBalances = createAsyncThunk< if (bitcoin) { // add bitcoin balance to balances state const bitBalances: TokenBalanceObject[] = bitcoin.networksArr.map(b => { - const { balance, usdBalance } = getBalance(b, usdPrices.BTC?.price) + const { balance, usdBalance } = getBalance(b, usdPrices.BTC?.price ?? 0) return { name: b.networkName, contractAddress: b.contractAddress,