Total Trading Fee

Liquidity Providers (LPs) earn trading fees from each swap. The total swap fee (f_s) consists of two parts:
f_s = f_b + f_v
Where:
  • f_b: Base Fee (fixed)
  • f_v: Variable Fee (dynamic)
Fees are calculated per bin and distributed proportionally to LPs in each bin.

Base Fee

The base fee is the minimum fee charged on every swap.

Formula

f_b = B × s
Where:
  • B: Base factor (set by pool creator)
  • s: Bin step
A higher base fee earns more per volume but may reduce trade volume. Lower base fees give room for dynamic fees to optimize based on market volatility.

Variable Fee (Dynamic)

The variable fee accounts for real-time market volatility.

Formula (per bin k)

f_v(k) = A × (v_a(k) × s)²
Where:
  • A: Variable fee control parameter
  • s: Bin step
  • v_a(k): Volatility accumulator for bin k

Variable Fee Characteristics

Variable fees are:
  • Higher for volatile markets
  • Calculated per bin crossed in large swaps
  • Distributed to LPs of each crossed bin

Volatility Accumulator (v_a)

The volatility accumulator tracks real-time market activity.

Formula

v_a(k) = v_r + |i_r - (activeID + k)|
Where:
  • v_r: Volatility reference (based on time since last swap)
  • i_r: Index reference
  • activeID: ID of the active bin before the swap
  • k: Relative bin index crossed during the swap
The more bins crossed or the more frequent the swaps, the higher the volatility and fee.

Volatility Reference (v_r)

Volatility decays over time:
v_r = {
  v_r,             if t < t_f
  R × v_a,         if t_f ≤ t < t_d
  0,               if t ≥ t_d
}
Where:
  • t: Time since last transaction
  • t_f: Filter period (e.g., 1s)
  • t_d: Decay period (e.g., 5s)
  • R: Decay multiplier

Index Reference (i_r)

i_r = {
  i_r,           if t < t_f
  activeID,      if t ≥ t_f
}
i_r ensures fees cannot be gamed by frequent low-impact swaps.

Fee Distribution Per Bin

Each bin crossed in a swap contributes to total fee:
fee_k = swapAmount_k × (f_b + f_v(k))
Fees from each bin go to LPs providing liquidity in that bin.

Example: Volatility in Action

Swap ActionTimeBins Crossedv_a (max)
#1Initial+3 bins (100 → 103)3
#24s later+5 bins (103 → 108)6.5
#30.3s later-2 bins (108 → 106)4.5
Volatility builds with activity and decays over time, making fees adaptive and manipulation-resistant.

DLMM Protocol Fee

The protocol takes a portion of the dynamic fee (not just base).
Pool TypeProtocol Fee
Standard DLMM Pool5% of f_s
DLMM Launch Pools20% of f_s

Key Benefits

For Liquidity Providers

  • Higher returns during volatility - Dynamic fees increase when markets are active
  • Protection during quiet periods - Base fees ensure minimum earnings
  • Fair distribution - Fees go to bins that actually facilitate trades

For Traders

  • Predictable base costs - Minimum fee is always known
  • Fair pricing during volatility - Higher fees during high-impact trades protect LP capital
  • Manipulation resistance - Time-based decay prevents fee gaming

Understanding Fee Impact

Low Volatility Scenarios

  • Fees remain close to base fee
  • Suitable for stable trading environments
  • Lower cost for routine swaps

High Volatility Scenarios

  • Variable fees increase significantly
  • Compensates LPs for impermanent loss risk
  • Encourages liquidity provision during volatile periods
Dynamic fees are designed to balance trader costs with LP protection. During extreme volatility, fees may be substantially higher than base rates.