fix too aggressively flooring BN math (#276)
This commit is contained in:
parent
3993c5926b
commit
28c542be3f
|
@ -34,13 +34,14 @@ export function toUiDecimals(
|
||||||
nativeAmount: BN | I80F48 | number,
|
nativeAmount: BN | I80F48 | number,
|
||||||
decimals: number,
|
decimals: number,
|
||||||
): number {
|
): number {
|
||||||
if (nativeAmount instanceof BN) {
|
if (nativeAmount instanceof I80F48) {
|
||||||
return nativeAmount.div(new BN(Math.pow(10, decimals))).toNumber();
|
|
||||||
} else if (nativeAmount instanceof I80F48) {
|
|
||||||
return nativeAmount
|
return nativeAmount
|
||||||
.div(I80F48.fromNumber(Math.pow(10, decimals)))
|
.div(I80F48.fromNumber(Math.pow(10, decimals)))
|
||||||
.toNumber();
|
.toNumber();
|
||||||
}
|
}
|
||||||
|
if (nativeAmount instanceof BN) {
|
||||||
|
nativeAmount = nativeAmount.toNumber();
|
||||||
|
}
|
||||||
return nativeAmount / Math.pow(10, decimals);
|
return nativeAmount / Math.pow(10, decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue