Bn

bn

Shortcut to create a BigNumber

Parameters

Returns BigNumber The BigNumber interface from the given value.

isValidBN

Helper to check whether a BigNumber is valid or not

Parameters

  • value BigNumber

Returns boolean true or false.

bnOrZero

Helper to create a big number from string or number If it fails to create a big number, a big number with value 0 will be returned instead

Parameters

Returns BigNumber The BigNumber interface from the given value. If invalid one is provided, will return 0.

validBNOrZero

Helper to validate a possible BigNumber If the given value is invalid or undefined, 0 is returned as a BigNumber

Parameters

Returns boolean true or false.

formatBN

Format a BaseNumber to a string depending on given decimal places

Parameters

  • value BigNumber
  • decimal number The decimal place. (optional) (optional, default 2)

Returns string The formatted string from the given BigNumber and decimal place.

SymbolPosition

The enumuration for symbol position. before or after

formatBNCurrency

Formats a big number value by prefixing it with $

Parameters

  • n BigNumber
  • decimalPlaces number The decimal place. (optional) (optional, default 2)
  • symbol string The currency symbol. (optional) (optional, default '$')
  • position position The symbol position. (optional) (optional, default SymbolPosition.BEFORE)

Returns string The formatted string from the given BigNumber, decimal places, symbol and position.

fixedBN

Helper to get a fixed BigNumber Returns zero BigNumber if value is invalid

Parameters

Returns BigNumber The BigNumber interface from the given value and decimal.