ixWithdraw, or return base assets through ixWrapperWithdraw.
For raw/display units and fee-rate scale, see Units and Fees.
Withdrawal Preview Math
Withdrawal fees are charged before the redemption claim is calculated: OnlyredeemLpShares back the user’s asset claim:
The full lpAmountIn is burned from the user. The fee portion remains as pending protocol LP shares and is minted later through mintProtocolFeeShares.
In the simple case where the selected tranche only claims its own SY side, the SY output is:
When the market has cross-tranche claims from loss or recovery accounting, the program first decomposes the selected tranche’s effective NAV into Senior-source and Junior-source SY claims, scales each claim by redeemLpShares / (totalLpSupply + 1), then sums the resulting SY amounts. See Loss and Gain Waterfalls.
lpAmountIn, withdrawFeeLpShares, and redeemLpShares are raw LP units. amountOutSY is raw SY units. If the integration uses ixWrapperWithdraw, minBaseOut is raw base token units after the SY redemption step.
Senior Self-Liquidation Bonus
This branch applies only to Senior withdrawals. It is triggered when the market utilization has reached the configured liquidation threshold: Readstate.financials.utilization, state.riskConfig.liquidationUtilization, and state.riskConfig.srSelfLiquidationBonus. The bonus is based on the Senior user’s claim after withdrawal fees and before the bonus is added.
The program first computes the desired bonus in raw fixed-point NAV:
Then it caps the result:
maxUtilizationNeutralBonusNAV is the internal cap that prevents the bonus from increasing post-withdraw utilization. With:
the first cap is:
If seniorSourceCap <= C_s, the program uses seniorSourceCap. Otherwise it uses the mixed-source cap:
If either cap denominator is zero, the program treats that cap as zero.
After the cap is selected, the bonus NAV is converted back into raw SY units with floor rounding:
The Senior withdrawal output becomes:
Withdrawal Example
Assume a Junior withdrawal in a market with no cross-tranche claims:| Input | Value |
|---|---|
lpAmountIn | 1,000 Junior LP |
juniorWithdrawProtocolFee | 0.10% |
totalJuniorLpSupply | 10,000 Junior LP |
juniorSyAmount | 10,000 SY |
1,000 Junior LP and receives 998 SY before any wrapper redemption into the base asset. Market accounting total Junior LP supply decreases by 999, from 10,000 to 9,001, and 1 Junior LP share is added to pending withdrawal protocol fees.
If using ixWrapperWithdraw, the SY is redeemed through the linked SY program after the tranching withdrawal.