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:
- Start at the active bin
- Compute executable amount at bin's fixed price P (constant-sum)
- Charge base fee for that chunk
- Update/compute volatility accumulator using time since last swap and bin distance traveled
- Charge variable fee: A * (v_a * s)² for this bin's chunk
- Update reserves in bin; add collected fees to bin.fee_account
- If one side is depleted → advance to next bin; else break
- 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:
- Choose your target bins based on your strategy (Spot, Curve, or Bid-Ask)
- For each target bin, the protocol computes how your deposit affects that bin's L (liquidity) and composition
- LP positions/records are minted and tied to those bins
- 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