From 4ecb6e1e17b4d274a3cfd656135726307cf2729a Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Wed, 18 Oct 2023 11:37:12 +0100 Subject: [PATCH] fix: Correctly handle undefined token decimals in onchain balance. --- balancer-js/src/modules/data/pool/onchain-data.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/balancer-js/src/modules/data/pool/onchain-data.ts b/balancer-js/src/modules/data/pool/onchain-data.ts index 449edacdc..c9f9dc9de 100644 --- a/balancer-js/src/modules/data/pool/onchain-data.ts +++ b/balancer-js/src/modules/data/pool/onchain-data.ts @@ -148,9 +148,11 @@ const merge = (pool: T, result: OnchainData) => ({ .indexOf(token.address); const wrappedToken = pool.wrappedIndex && pool.tokensList[pool.wrappedIndex]; + const tokenDecimals = + token.decimals === undefined ? 18 : token.decimals; return { ...token, - balance: formatFixed(result.poolTokens[1][idx], token.decimals || 18), + balance: formatFixed(result.poolTokens[1][idx], tokenDecimals), weight: (result.weights && formatFixed(result.weights[idx], 18)) || token.weight,