Function formatAmount

  • un-scales unit with give decimals and returns

    Parameters

    • value: string | bigint
    • decimals: number
    • Optional displayDecimals: number

    Returns {
        base: bigint;
        display: string;
        formatted: string;
    }

    base: original value, display: unScaled value with 0-3 decimals with comma, formatted: unScaled value with all decimals

    • base: bigint
    • display: string
    • formatted: string

    Example

    getFormattedAmount('12345678900223', 6, 3) // { base: 12345678900223n, display: '12,345,678.9', formatted: '12345678.900223' }