Skip to main content
This page covers the raw units used by tranching preview math and the fee formulas that affect LP output or pending protocol LP shares.

Units and Display Values

The examples in this section use normalized values when they say so. The program and SDK operate on raw values.
TermRaw dimensionDisplay guidance
amountBase, minBaseOutBase token smallest unitsDivide by the base token mint decimals
amountIn, amountInSY, amountOutSY, seniorSyAmount, juniorSyAmountSY token smallest unitsDivide by the SY mint decimals
lpAmountIn, grossLpOut, netLpOut, totalLpSupply, pending fee sharesSelected-tranche LP mint unitsDivide by the LP mint decimals. LP mints are initialized with the SY mint decimals
syExchangeRateNumber fixed-point exchange rate applied to raw SY units1_000_000_000_000 means 1.0
NAV values, valueAllocated, lpPrice, capacity helpersNumber fixed-point values with 1_000_000_000_000 as one unitConvert the fixed-point scale, then apply the relevant token-decimal display rule
Fee rates, utilization, coverage, beta, return sharesNumber fixed-point ratios1_000_000_000_000 means 1.0; display as decimals or percentages
tranchingFromNumber removes the fixed-point scale only. It does not divide by token decimals. For example, if a 9-decimal SY amount is valued at an exchange rate of 1.0, the raw NAV for 1 displayed SY is 1_000_000_000 * 1_000_000_000_000. After fixed-point conversion, it is still 1_000_000_000 raw token units and should be divided by 10^9 for UI display.

Fee Scope

Deposit and withdrawal previews apply transfer fees only. Market-update fees such as srProtocolFee, jrProtocolFee, and juniorReturnProtocolFee are charged during market sync, converted into pending protocol LP shares, and reflected in the market state before the deposit or withdrawal quote is calculated. Do not subtract market-update fees again in an integration preview. Reload the market, use the current effective NAV and LP supply, then apply only the selected deposit or withdrawal fee. All fee fields are Number fixed-point rates. After tranchingNumberToRaw, a raw fee rate of 2_000_000_000 means 0.002, or 0.20%.
FlowFee field used in the previewFee base
Senior depositseniorDepositProtocolFeegrossLpOut
Junior depositjuniorDepositProtocolFeegrossLpOut
Senior withdrawalseniorWithdrawProtocolFeelpAmountIn
Junior withdrawaljuniorWithdrawProtocolFeelpAmountIn
Transfer fee rates must be less than 1.0. If rounding makes the user’s net LP output or asset output zero, the transaction fails its minimum-output check.

Market-Update Fees

Market-update fees use NAV bases before they become LP shares: seniorFeeNAV=seniorReturnShare×srProtocolFee\text{seniorFeeNAV} = \left\lfloor \text{seniorReturnShare} \times \text{srProtocolFee} \right\rfloor juniorGainFeeNAV=juniorNetGainAfterRecovery×jrProtocolFee\text{juniorGainFeeNAV} = \left\lfloor \text{juniorNetGainAfterRecovery} \times \text{jrProtocolFee} \right\rfloor juniorReturnFeeNAV=juniorReturnShare×juniorReturnProtocolFee\text{juniorReturnFeeNAV} = \left\lfloor \text{juniorReturnShare} \times \text{juniorReturnProtocolFee} \right\rfloor The *FeeNAV values are raw fixed-point NAV values. The program converts each tranche’s NAV fee into pending raw LP shares: protocolFeeLpShares=protocolFeeNAV×(totalLpSupply+1)feeExcludedNAV+1NAV\text{protocolFeeLpShares} = \left\lfloor \frac{\text{protocolFeeNAV} \times (\text{totalLpSupply} + 1)} {\text{feeExcludedNAV} + 1_{\text{NAV}}} \right\rfloor These market-update fees accrue only when the resulting market state is Active. The Junior gain fee is skipped when the net Junior gain is at or below jrNetAssetDustTolerance, and Senior return fees are skipped when the distributable Senior gain is at or below srNetAssetDustTolerance. For deposit and withdrawal transfer-fee formulas, see Deposit Previews and Withdrawal Previews.