Function convertAmountToNativeDisplay

  • Returns a formatted string given a value, currency, and buffer. buffer defaults to 3, based on handleSignificantDecimals.

    Calculation of the amount in the formatted string is as follows. If value is between -1 and 1, the amount is value rounded to one of the following decimal places (whichever is smaller), then formatted to a minimum of 2 decimal places:

    • 8
    • number of decimal places to reach value's first significant digit + buffer. Buffer basically acts as the number of significant digits to show

    Otherwise the amount is value rounded to the smaller of the specified currency's decimals and buffer, formatted with at least 2 decimal places.

    Example

    convertAmountToNativeDisplay(1.112, 'USD', 1) // $1.10 USD - the buffer is smaller than the 2 decimal places specified by USD
    convertAmountToNativeDisplay(1.112, 'USD', 3) // '$1.11 USD' - USD specifies 2 decimal places

    See

    handleSignificantDecimals for more details on calculating amount

    Parameters

    • value: Value
    • nativeCurrency: string
    • Optional buffer: number

    Returns string

Generated using TypeDoc