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

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(): 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:
Loss is deducted from margin first, then fees are taken from the remainder:
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
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