import BigNumber from 'bignumber.js' ; export type BigNumberValue = string | number | BigNumber ; export const BigNumberZD = BigNumber . clone ( { DECIMAL_PLACES : 0 , ROUNDING_MODE : BigNumber . ROUND_DOWN , } ) ; export function valueToBigNumber ( amount ) { return new BigNumber ( amount ) ; } export function valueToZDBigNumber ( amount ) { return new BigNumberZD ( amount ) ; } const bn10 = new BigNumber ( 10 ) ; const bn10PowLookup = { } ; param decimals returns export function pow10 ( decimals ) { if ( ! bn10PowLookup [ decimals ] ) bn10PowLookup [ decimals ] = bn10 . pow ( decimals ) ; return bn10PowLookup [ decimals ] ; } export function normalize ( n , decimals ) { return normalizeBN ( n , decimals ) . toString ( 10 ) ; } export function normalizeBN ( n , decimals ) { return valueToBigNumber ( n ) . dividedBy ( pow10 ( decimals ) ) ; }