Skip to content

@lelantos-org/sdk / protocol / decompose

Function: decompose() ​

ts
function decompose(
   amount, 
   ladder, 
   maxPieces
): Decomposition;

Defined in: @lelantos-org/sdk/dist/protocol/denominations.d.ts:68

Split amount into at most maxPieces parts, as many on the ladder as fit.

Greedy largest-first, reserving the final part for the remainder. The parts always sum to amount: value conservation is enforced in-circuit, so a remainder is placed, never rounded away.

decompose(4900n, USDC, 4) → pieces [2000, 2000, 500], dust 400

Dust is transient: an internal transfer publishes no amount, so a later self-spend can re-split 400 → 200 + 200 without disclosure.

Parameters ​

ParameterType
amountbigint
ladderLadder
maxPiecesnumber

Returns ​

Decomposition