diff --git a/client/idl/generateIdl.js b/client/idl/generateIdl.js index 84c2e5cc2..187364439 100644 --- a/client/idl/generateIdl.js +++ b/client/idl/generateIdl.js @@ -87,8 +87,6 @@ function modifyIdlCore(programName) { } } - // TODO: Override u128 price in the output for QuoteAtomsPerBaseAtom - for (const idlAccount of idl.accounts) { if (idlAccount.type && idlAccount.type.fields) { idlAccount.type.fields = idlAccount.type.fields.map((field) => { diff --git a/client/ts/src/utils/numbers.ts b/client/ts/src/utils/numbers.ts index d0574caa3..9906d697c 100644 --- a/client/ts/src/utils/numbers.ts +++ b/client/ts/src/utils/numbers.ts @@ -28,7 +28,9 @@ export function convertU128(n: bignum): number { } else { // can only initialize up to 2**53, but need to divide by 10**20. const divisor = new BN(10 ** 10); - // TODO: This may lose decimals, so after the first divide, convert to number. + if (n.div(divisor) < new BN(2 ** 53 - 1)) { + return n.div(divisor).toNumber() / 10 ** 10; + } target = n.div(divisor).div(divisor).toNumber(); } return target;