Class ChainValue

A Value Object to facilitate calculations for token and coin values (QNT/NQT).

For efficiency reasons, the monetary values/quantities are stored as integers with a prefined set of decimals, e.g. Signa has 8 decimals and stores the values as Planck that is 1 Signa = 100_000_000 Planck (NQT) and tokens have configurable decimals (0 to 8), so that a custom FooCoin can hav 2 decimals only where 1 FOO = 100 FOOQNT

In this context integer quantities are denominates as _atomic values and fractional values considering the decimals are denominated as compound values.

Note: This class uses a big number representation (ES5 compatible) under the hood, so number limits and numeric calculations are much more precise than JS number type

Constructors

Methods

  • Gets the 'compound' representation

    Returns string

    value in decimal related representation, i.e. 100 QNT with 3 decimals results in '0.3'

  • Checks for greater or equality value

    Parameters

    • chainValue: ChainValue

      The other value to be compared

    Returns boolean

    true if greater or equal, otherwise false

  • Checks for lesser or equality

    Parameters

    • chainValue: ChainValue

      The other value to be compared

    Returns boolean

    true if less or equal, otherwise false

  • Sets value as atomic value, i.e. overwrites current hold value

    Parameters

    • a: string | number

      The atomic value. Float numbers are floored to first lower integer, i.e. 1.23 -> 1

    Returns ChainValue

    the updated value object