Skip to main content
The Open Nile Protocol collects fees on trading activity and distributes them between the protocol treasury and liquidity providers. All fee parameters are configurable by the admin and snapshotted at position open time.

Fee Types

FeeFormulaWhen Collected
Trading Feenotional * snapshotTradingFeeBps / 10,000Open, increase, settlement, close, reduce
Liquidation Penaltynotional * snapshotLiquidationPenaltyBps / 10,000Liquidation only (added on top of trading fee)
Oracle FeeFlat snapshotOracleFee per price readEvery forward price lookup
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 using FeeLib.distributeFee():
DestinationDefault ShareDescription
Treasury30% (3,000 bps)Protocol revenue, used for operations and development
Pool70% (7,000 bps)LP compensation, distributed via vault share price increase
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 destination shares must sum to exactly 10,000 basis points (100%). This is enforced by Config.setFeeDestinations() and is protocol invariant #9. Any configuration that does not sum to 10,000 will revert.

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.
The full margin at risk is available for fee collection:
actualFee = min(fee, marginAtRisk)
Loss is deducted from margin first, then fees are taken from the remainder:
marginAfterLoss = marginAtRisk - cappedLoss
actualFee = min(fee, marginAfterLoss)
The full margin at risk is available for fee collection:
actualFee = min(fee, marginAtRisk)
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:
ContextCollection MethodSource
Position opencollectFeeFree collateral (available balance)
Position increasecollectFeeFree collateral (available balance)
Settlement (maturity, liquidation, early close, reduce)Deducted in _settlePositionLocked margin (imLocked)
Oracle feecollectFeeFromCollateralTotal collateral (can draw from locked margin)
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:
ParameterValue
Trading Fee5 bps (0.05%)
Oracle Fee0.10 USDC (flat)
Treasury Share30% (3,000 bps)
Pool Share70% (7,000 bps)
Fees at open:
  • Trading fee: 10,000 * 5 / 10,000 = 5 USDC
  • Oracle fee: 0.10 USDC
  • Total: 5.10 USDC
Distribution:
  • 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
At settlement (assuming 5 bps trading fee again):
  • Another 5 USDC trading fee is collected from locked margin
  • Split the same way: 1.50 USDC to treasury, 3.50 USDC to pool