Skip to content

Commit

Permalink
fix: coderabbit
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency committed Nov 26, 2024
1 parent f8bc045 commit 6f7b535
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils/maths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export const shiftDigits = (
};

export const parseNumberToBigInt = (v: string, maxDigits: number = 6) => {
const amount = BigNumber(v);
const precision = BigNumber(`1e${maxDigits}`);
const amount = new BigNumber(v);
if (!amount.isFinite()) {
console.error(`Invalid input passed to parseNumberToBigInt: ${v}`);
return BigInt(0);
}
const precision = new BigNumber(10).pow(maxDigits);
const b = amount.times(precision).toFixed();
return BigInt(b);
};
Expand Down

0 comments on commit 6f7b535

Please sign in to comment.