Skip to content

@swapped/connect-sdk / format / formatCurrencyAmount

Function: formatCurrencyAmount()

formatCurrencyAmount(number, options?): string

Defined in: src/format/formatCurrencyAmount.ts:38

Formats a currency-style value with smarter handling for very small amounts. Defaults to fiatDecimals (2 when unset). With firstNonZeroDecimal, expands past that floor so the first significant digit is visible (e.g. 0.0001).

Accepts a JS number or a plain decimal / scientific string (23, 1e-7). Grouped strings, NaN, and Infinity return ''.

Parameters

number

string | number

Value to format (number or numeric string)

options?

FormatCurrencyAmountOptions = {}

Optional formatting flags

Returns

string

Formatted currency-style string, or '' when number is not a plain amount