(amount: bigint, decimals: number)
| 89 | |
| 90 | // Formats a balance that is a bigint into a string with the correct number of decimals |
| 91 | export const formatBalance = (amount: bigint, decimals: number): string => { |
| 92 | const integerPart = amount / BigInt(10 ** decimals); |
| 93 | const remainder = amount % BigInt(10 ** decimals); |
| 94 | const integerPartStr = integerPart.toString(); |
| 95 | const remainderStr = remainder.toString().padStart(decimals, '0'); |
| 96 | |
| 97 | return `${integerPartStr}.${remainderStr}`; |
| 98 | }; |
| 99 | |
| 100 | export const amountToBigInt = (amount: string, decimals: number): bigint => { |
| 101 | const [integer, decimal] = amount.split('.'); |
no test coverage detected