Skip to content

@lelantos-org/sdk / index / Amount

Type Alias: Amount ​

ts
type Amount = 
  | string
  | CircuitAmount
  | {
  baseUnits: TokenAmount | bigint;
  round?: Rounding;
};

Defined in: @lelantos-org/sdk/dist/wallet/assets/amount.d.ts:145

An amount of one asset. Its runtime shape, never its magnitude, names the space it is in:

  • "12.5": human decimal string of the asset's token.
  • circuitAmount(12_500_000n): circuit units.
  • { baseUnits: 12_500_000n }: ERC-20 base units.

A plain bigint does not compile: 100n could be circuit units or base units, which differ by scale. Brand it with circuitAmount(x), pass { baseUnits: x }, or pass a value the SDK returned. A number does not compile either, and is refused at runtime with INVALID_ARGUMENT.

Off-unit strings and base units round by the asset's default: "exact" for a plain asset, "up" for a yield asset (the inverse of formatAmount, so a formatted balance parses back to itself and never over-draws). { baseUnits, round } overrides it; for a string, call parseAmount(value, asset, { round }) first.