Function createAmountFromBalance

  • Returns a new asset amount.

    Parameters

    • num: bigint

      The desired value for the amount, specified as smallest divisor.

    • Optional decimals: number

      The desired number of decimal digits.

    Returns Amount

    An asset amount with the specified value, and a decimal point added to it if needed. In this function, 1 is always the smallest non-zero amount that can be represented. If you want to convert user input to amounts, you'll probably want to use createAmount instead.

    Example

    createAmountFromBalance(1, 2) // returns 0.01
    createAmountFromBalance(100, 2) // returns 1.00