Skip to content

@lelantos-org/sdk / protocol / sizeBNote

Function: sizeBNote() ​

ts
function sizeBNote(
   minOut, 
   scaleOut, 
   feeBps, 
   relayerFee?, 
   yieldPricing?
): bigint;

Defined in: @lelantos-org/sdk/dist/protocol/swap-sizing.d.ts:25

Smallest B-note value whose on-chain Permit2 pull covers minOut: the exact amount a swap credits, which executeSwap encodes as the deposit leg's publicIn.

The wrapper enforces minOut ≤ pulled ≤ actualOut (MaspPullBelowMinOut, MaspPullExceedsActualOut). pulled is principal plus the pool's fee plus the flush fee note, and the pool floors its fee, so the closed form minOut * BPS / (scale * (BPS + feeBps)) lands below minOut whenever the division is inexact, which reverts. The function starts from that estimate and walks to the smallest v that covers minOut. Minimality keeps the result under actualOut; the wrapper forwards anything above the pull to the treasury.

relayerFee is in circuit units of the out asset and is paid from the same pull, so a non-zero fee reduces the B-note rather than charging the user separately.

Parameters ​

ParameterTypeDescription
minOutbigint-
scaleOutbigint-
feeBpsbigintThe out asset's depositBps: leg 2 mints the B-note as a deposit.
relayerFee?bigint-
yieldPricing?YieldPricingThe out asset's yield pricing: a yield B-note's pull is priced in units at the rate.

Returns ​

bigint