Skip to main content
The Open Nile Protocol collects three types of fees: trading fees on every position event, liquidation penalties on distressed positions, and oracle fees for price reads. All fees use snapshotted rates from position open time, ensuring traders know their costs upfront. Fees are distributed between the protocol treasury and the liquidity pool according to a configurable split.
Nile Markets uses flat fee rates in M2 — there are no volume-based tiers or maker/taker distinctions. Every trader pays the same rates regardless of volume. Volume-tiered pricing is planned for M3.

Fee Types

Default Values

Trading Fee

5 bps (0.05%)Applied to the notional amount on every position open, increase, settlement, early termination, and reduction.

Liquidation Penalty

30 bps (0.3%)Applied to the notional amount only during liquidation, added on top of the trading fee. Combined liquidation fee = 35 bps.

Oracle Fee

0.10 USDCFlat fee per forward price lookup. Collected from the trader’s collateral each time a forward price is read.

Fee Distribution

All collected fees (trading fees and liquidation penalties) are split between two destinations: The distribution is executed by FeeLib.distributeFee(), which iterates through all configured fee destinations and transfers proportional shares.
Fee destination shares must sum to exactly 10,000 basis points (100%). This is enforced by Config.setFeeDestinations() and is one of the protocol’s core invariants. If shares do not sum correctly, the configuration transaction reverts.

Fee Capping

Fees are always capped at available margin. The protocol never reverts on insufficient fee funds — it collects whatever is available. This ensures that settlement and liquidation cannot be blocked by a position that has been drained by losses.
When a position is profitable, the full calculated fee is typically collected since the margin is intact, and the trader receives marginAfterFee + pnl.
The fee waterfall is fee-first: actualFee is computed against the full marginAtRisk, then PnL is applied from the remainder. Under bad debt, LPs absorb the difference rather than the fee being trimmed. This is a deliberate design choice that makes fee revenue independent of PnL outcomes.

Fee Collection Methods

Fees are collected through different mechanisms depending on the context:
The oracle fee uses collectFeeFromCollateral, which can draw from the locked portion of collateral, not just the free balance. This is because oracle fees are small (0.10 USDC) and must be collected reliably for every price read. Allowing it to draw from locked collateral prevents oracle fee collection from failing when a trader has minimal free collateral.

Snapshotted Rates

All fee rates are captured at position open time and stored in the position struct: If the protocol admin changes fee rates after a position is opened, the position continues to use its snapshotted rates. Only newly opened positions use the updated rates. This protects traders from retroactive fee changes.

Worked Examples

Position:
  • Notional: 1,000 USDC (1,000,000,000 raw)
  • Trading fee: 5 bps
Calculation:
Distribution:
  • Treasury (30%): 0.50 * 3,000 / 10,000 = 0.15 USDC
  • Pool (70%): 0.50 * 7,000 / 10,000 = 0.35 USDC
Position:
  • Notional: 1,000 USDC
  • Trading fee: 5 bps
  • Liquidation penalty: 30 bps
Calculation:
Distribution:
  • Treasury (30%): 3.50 * 3,000 / 10,000 = 1.05 USDC
  • Pool (70%): 3.50 * 7,000 / 10,000 = 2.45 USDC
Position:
  • Notional: 1,000 USDC
  • IM locked (marginAtRisk): 20 USDC
  • Calculated loss: -19 USDC
  • Trading fee calculated: 1 USDC (combined trading + liquidation penalty in this example)
Fee-first waterfall:
What if the loss had been 25 USDC instead?
Under fee-first, the fee is always collected as long as marginAtRisk > 0. The pool absorbs any uncollectable loss as bad debt, but fee revenue stays deterministic.

Liquidation Penalty Destination

The liquidation penalty goes entirely to fee destinations (30% treasury, 70% pool), not to the address that triggers the liquidation. The liquidator receives no reward — they only pay gas. This design choice means that in M2, the keeper service performs liquidations as a protocol service rather than as an economically motivated external actor.

Fee on Position Increase

When a position is increased via increasePosition, the trading fee is calculated on the additional notional only, not the full new notional:
The trader has already paid the trading fee on the original notional at position open. Only the new exposure incurs a fee.

Fee on Position Reduction

Similarly, when a position is reduced via reducePosition, the fee is on the reduction amount only:
This ensures fees are proportional to the notional being transacted, not the full position size.