Skip to content

@swapped/connect-sdk / format / roundTokenBalance

Function: roundTokenBalance()

roundTokenBalance(params): string

Defined in: src/format/roundTokenBalance.ts:21

Formats a token balance string to at most maxDecimals places, rounding half up. When decimals is provided, balance is treated as raw smallest units and converted via formatUnits; otherwise balance is treated as an already-human amount string.

Parameters

params

RoundTokenBalanceParams

Rounding options

Returns

string

Rounded balance string, or '' when balance is empty