@lelantos-org/sdk / wallet / sizeBNote
Function: sizeBNote() โ
function sizeBNote(
minOut,
scaleOut,
feeBps,
relayerFee?
): bigint;Defined in: @lelantos-org/sdk/dist/wallet/swap.d.ts:32
Smallest B-note value whose on-chain Permit2 pull covers minOut.
The wrapper enforces a window, not a ceiling: minOut โค pulled โค actualOut, as MaspPullBelowMinOut and MaspPullExceedsActualOut. Solving only the upper bound โ the closed form minOut * BPS / (scale * (BPS + feeBps)) โ lands below minOut whenever the division is inexact, and reverts.
pulled is principal, the pool's fee, and the note paying whoever flushes the deposit โ and the pool floors its fee, so the pull advances in steps no closed form always hits. Start from the floor-div estimate and walk to the smallest v that still covers minOut. Minimality is what keeps the answer under actualOut; any overshoot is wrapper-side dust forwarded to the treasury.
relayerFee is in circuit units of the out asset and rides in the same pull, so a non-zero one makes the B-note smaller: the flush is paid for out of the swap's own output rather than by a second charge to the user.
Public because it is the only correct answer to "how much will this swap credit me?", and that is a question every caller showing a quote has to answer before the user commits. executeSwap encodes this exact value as the deposit leg's publicIn, so it is what the wallet receives โ not a floor, since the wrapper pulls only what the B-note needs and forwards any better-than-quoted fill to the treasury. Callers that derive it themselves reach for the closed form above and get a figure that is both wrong on screen and, if used to size a transaction, reverting on chain.
Parameters โ
| Parameter | Type |
|---|---|
minOut | bigint |
scaleOut | bigint |
feeBps | bigint |
relayerFee? | bigint |
Returns โ
bigint