Skip to content

@lelantos-org/sdk / protocol / toTokenUnits

Function: toTokenUnits() ​

ts
function toTokenUnits(
   circuitAmount, 
   scale, 
   opts?
): TokenAmount;

Defined in: @lelantos-org/sdk/dist/protocol/units.d.ts:44

Circuit units → ERC-20 base units: token = circuit * scale * index / RAY. At the default index of RAY this is exactly circuit * scale.

With a pool-managed index the conversion is lossy, so it rounds down by default: the direction out of the pool (see divRound).

A display conversion: to size a payment, use toTokenUnitsAtRate (see YieldRate).

Parameters ​

ParameterType
circuitAmountCircuitAmount
scalebigint
opts?{ index?: bigint; round?: "down" | "up"; }
opts.index?bigint
opts.round?"down" | "up"

Returns ​

TokenAmount