ao-js-sdk - v0.2.11
    Preparing search index...

    Class CurrencyAmount

    Concrete implementation of ICurrencyAmount for handling currency amounts with precise decimal arithmetic.

    Implements

    Index

    Constructors

    Properties

    None: CurrencyAmount = ...

    Static field representing a zero currency amount with 0 decimals.

    Methods

    • Formats the currency amount using abbreviated notation (K, M, B, T). Examples: 1,500 -> "1.5K", 2,500,000 -> "2.5M", 1,000,000,000 -> "1B"

      Parameters

      • decimalPlaces: number = 1

        Optional number of decimal places for the abbreviated value (default: 1)

      Returns string

      Formatted string with K/M/B/T suffix

    • Formats the currency amount to a string with a specified number of decimal places.

      Parameters

      • decimalPlaces: number

        The number of decimal places to display

      Returns string

      Formatted string with the specified decimal places

    • Converts the currency amount to a JavaScript number. Note: This may lose precision for very large amounts.

      Returns number

      The amount as a number

    • Creates a CurrencyAmount from a decimal string or number.

      Parameters

      • value: string | number

        The decimal value as a string or number

      • _decimals: string | number

      Returns CurrencyAmount

      A new CurrencyAmount instance