mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 14:12:35 +03:00
fix: bigint errors fix: TS errors fix: gasLimit fetch fix: review comments fix: contracts errors chore: bump rc version fix: revert wrong fix fix: ts config fix: ts config fix: ts config feat: update signer
14 lines
602 B
TypeScript
14 lines
602 B
TypeScript
import { BigNumber } from 'bignumber.js';
|
|
|
|
/**
|
|
* Converts normalized blockchain ("machine-readable") number to denormalized ("human-readable") number.
|
|
* @param input Any blockchain-normalized numeric value
|
|
* @param decimals Blockchain asset precision
|
|
* @returns BigNumber
|
|
*/
|
|
export default function denormalizeNumber(input: bigint, decimals: bigint) {
|
|
const decimalsBN = new BigNumber(decimals.toString());
|
|
if (!decimalsBN.isInteger()) throw new Error(`Decimals '${decimalsBN.toString()}' is not an integer`);
|
|
return new BigNumber(input.toString()).div(new BigNumber(10).pow(decimalsBN));
|
|
}
|