Fee Types
All fee rates are snapshotted at position open time. If the admin changes fee configuration after a position is opened, the change only affects newly opened positions. Existing positions retain the rates they were opened with, ensuring traders know their costs upfront.
Distribution Split
Collected fees are split between two destinations usingFeeLib.distributeFee():
The pool’s share flows directly into the ERC-4626 vault’s total assets, increasing the share price for all liquidity providers proportionally to their holdings. LPs do not need to claim fees — they are automatically reflected in the value of their vault shares.
Fee Capping
Fees are always capped at the margin available after PnL settlement. The protocol never reverts due to insufficient funds for fees — it collects what is available.After Profit
After Profit
The full margin at risk is available for fee collection:
After Loss
After Loss
Loss is deducted from margin first, then fees are taken from the remainder:
Zero PnL
Zero PnL
The full margin at risk is available for fee collection:
If a position’s margin is insufficient to cover the full fee after PnL settlement, the protocol collects a partial fee rather than reverting. This ensures settlements and liquidations always complete, even in bad debt scenarios.
Fee Collection Methods
Fees are collected through different mechanisms depending on the context:The oracle fee uses
collectFeeFromCollateral, which can draw from the account’s total collateral balance including locked margin. This is necessary because oracle fees are incurred during price lookups that may happen before any position-specific margin is available.Example Fee Calculation
Consider a trader opening a 10,000 USDC notional LONG position with the following snapshotted parameters:
Fees at open:
- Trading fee:
10,000 * 5 / 10,000 = 5 USDC - Oracle fee:
0.10 USDC - Total:
5.10 USDC
- Treasury receives:
5 * 0.30 = 1.50 USDC(trading fee share) + oracle fee handling - Pool receives:
5 * 0.70 = 3.50 USDC(trading fee share), increasing vault share price
- Another
5 USDCtrading fee is collected from locked margin - Split the same way:
1.50 USDCto treasury,3.50 USDCto pool