diff --git a/ts/client/src/utils.ts b/ts/client/src/utils.ts index 16cf3a205..b5a9b9ec7 100644 --- a/ts/client/src/utils.ts +++ b/ts/client/src/utils.ts @@ -34,13 +34,14 @@ export function toUiDecimals( nativeAmount: BN | I80F48 | number, decimals: number, ): number { - if (nativeAmount instanceof BN) { - return nativeAmount.div(new BN(Math.pow(10, decimals))).toNumber(); - } else if (nativeAmount instanceof I80F48) { + if (nativeAmount instanceof I80F48) { return nativeAmount .div(I80F48.fromNumber(Math.pow(10, decimals))) .toNumber(); } + if (nativeAmount instanceof BN) { + nativeAmount = nativeAmount.toNumber(); + } return nativeAmount / Math.pow(10, decimals); }