Skip to content

@swapped/connect-sdk / format / formatCompactTokenAmount

Function: formatCompactTokenAmount()

formatCompactTokenAmount(num, minThreshold?): string

Defined in: src/format/formatCompactTokenAmount.ts:11

Formats large magnitudes with compact suffixes (K/M), uppercased. Returns '' when num is below minThreshold so callers can fall back.

Parameters

num

number

Numeric amount to optionally abbreviate

minThreshold?

number = 10000

Minimum value that triggers compact format; default 10000

Returns

string

Compact uppercase string (e.g. 12.5K), or '' if below threshold