How DLMM Works

Deep dive into the mechanics of Dynamic Liquidity Market Maker protocol

Swap Algorithm

When a swap request comes in, the protocol executes the following steps:

  1. Start at the active bin
  2. Compute executable amount at bin's fixed price P (constant-sum)
  3. Charge base fee for that chunk
  4. Update/compute volatility accumulator using time since last swap and bin distance traveled
  5. Charge variable fee: A * (v_a * s)² for this bin's chunk
  6. Update reserves in bin; add collected fees to bin.fee_account
  7. If one side is depleted → advance to next bin; else break
  8. Set active_bin = last bin with both tokens

Volatility Measurement

To estimate volatility in real time, DLMM maintains a Volatility Accumulator v_a(k) for the k-th crossed bin, which blends:

  • A Volatility Reference (v_r) that decays over time if trading slows and is sticky when activity is fast
  • The instantaneous bin distance traveled by the current swap

The variable fee per bin is: f_v(k) = A · (v_a(k) · s)², where A is a control parameter and s is the bin step. More/faster bin hops → bigger v_a → surge pricing that compensates LPs during choppy markets.

LP Deposits

When you deposit as an LP:

  1. Choose your target bins based on your strategy (Spot, Curve, or Bid-Ask)
  2. For each target bin, the protocol computes how your deposit affects that bin's L (liquidity) and composition
  3. LP positions/records are minted and tied to those bins
  4. From now on, when that bin is active and used, you earn proportional per-bin fees that you can claim

Key Design Benefits

  • Discrete bins = state machine: Small, transparent steps make it easy to reason about execution, fees, and tick-like price movement
  • Fixed price inside bins: No slippage within a bin; slippage only happens when you cross bins (discrete steps)
  • Dynamic fees: Automatic compensation when the market is hectic (more bin hops + faster cadence ⇒ higher fees). This discourages snipers at launches and better aligns LP rewards with risk