Technical Design

Liquidity Distribution

In CLMM, liquidity is concentrated within user-defined price ranges rather than spread uniformly. Each liquidity position is defined by a lower tick TLT_L and an upper tick TUT_U, corresponding to specific prices PLP_L and PUP_U. The total liquidity at any price is the sum of all active positions that include that price. When the market price moves outside a position’s range, the liquidity becomes inactive, earning no fees and potentially incurring impermanent loss.

Tick-Based Model

CLMM discretizes the price spectrum into ticks, each representing a small price increment. For example, a tick spacing of 1 might correspond to a 0.01% price change (e.g., a multiplier of 1.0001). This tick-based model:

  • Enables Precise Liquidity Placement: LPs can target specific price ranges, such as $100 to $110 for a token pair.

  • Reduces Computational Overhead: Discrete ticks simplify liquidity calculations compared to a continuous price model.

  • Supports Granularity: Smaller tick spacing allows finer control, suitable for stablecoin pairs, while larger spacing suits volatile assets.

The price at a given tick (i) can be calculated as: P(i) = 1.0001^i where (i) is the tick index, and 1.0001 is the price multiplier per tick for a 0.01% fee tier.

Tick-based in Ferra's CLMM liquidity model

Fee Structure

Component
Description

Swap Fee

Percentage charged on every trade (e.g., 0.05 %, 0.30 %, 1 %).

Fee Tier

Each pool has a fixed swap‑fee tier chosen at deployment. Multiple pools with different tiers can coexist for the same token pair.

Protocol Fee

A configurable share of the swap fee routed to the Ferra treasury. The remainder goes to LPs. It is set to 20% by default

Fee Calculation

Fees in CLMM are collected when trades occur within a position’s active price range. The fee rate depends on the pool’s fee tier (e.g., 0.3% for volatile pairs, 0.01% for stable pairs). Fees are distributed proportionally to LPs based on their share of liquidity at the traded price. The protocol tracks fee growth per tick, allowing LPs to claim accumulated fees when they withdraw liquidity or collect earnings.

Mathematical Formulas

CLMM relies on mathematical formulas to manage liquidity and fees. Key equations include:

  • Liquidity Amount L: When an LP adds liquidity, the amount of liquidity provided is calculated based on the token amounts and the price range. For a position between prices PLP_L and PUP_U, the liquidity (L) is:

L=ΔyPUPL(for token Y when price is below range) L = \frac{\Delta y}{\sqrt{P_U} - \sqrt{P_L}} \quad \text{(for token Y when price is below range)}
L=ΔxPLPUPUPL(for token X when price is above range) L = \frac{\Delta x \cdot \sqrt{P_L} \cdot \sqrt{P_U}}{\sqrt{P_U} - \sqrt{P_L}} \quad \text{(for token X when price is above range)}

Where ΔX\Delta X and ΔY\Delta Y are the amounts of token X and token Y provided, respectively.

  • Position Value: The value of a position depends on the current price (P). If PLPPUP_L \leq P \leq P_U, the position is active, and its value includes both tokens and accumulated fees.

  • Fee Growth: Fees are tracked as “fee growth per unit of liquidity” for each tick range. When a trade occurs, the fee growth is updated, and LPs can claim fees proportional to their liquidity share.

Position Management

LPs interact with CLMM through the following actions:

  • Minting Positions: Create a new position by specifying a tick range and token amounts.

  • Adding Liquidity: Increase liquidity in an existing position.

  • Removing (Burning) Positions: Withdraw liquidity, receiving the underlying tokens and any accumulated fees.

  • Collecting Fees: Claim earned fees without removing liquidity.

Positions are active only when the current price is within the specified range. If the price moves outside, the position earns no fees and may face impermanent loss.

Impermanent Loss

CLMM reduces impermanent loss by allowing LPs to focus liquidity in stable price ranges, but it does not eliminate it. If the price moves outside a position’s range, the LP holds only one token (the less valuable one), potentially leading to losses compared to holding the tokens outside the pool. The concentrated nature of CLMM can amplify impermanent loss in volatile markets, requiring active position management.

Swap Mechanics (High‑Level)

  • User submits amountIn of TokenA for TokenB.

  • Contract computes the maximum amount consumable before hitting the next initialized tick.

  • Constant‑product math updates the pool within the current tick and deducts the swap fee.

  • If amountIn remains, the algorithm crosses the next tick, activates its liquidity, and repeats until the full amount is swapped.

  • Fee growth variables are updated so LPs can later collect their share.

Liquidity Strategies

Unlike DLMM, a CLMM pool has only one fundamental liquidity layout, functionally similar to the Spot shape in DLMM. Your strategy therefore comes from how wide or narrow you set your price range, not from choosing different shapes. The comparison below shows how range width affects performance and maintenance.

Range Strategy
Typical Width
When to Use
Pros
Const
Upkeep

Narrow

±0.5 – 2 % around spot

High‑volume, low‑volatility pairs; active LPs

Highest fee APR per dollar

Falls out‑of‑range quickly; needs frequent re‑centering

High

Medium

±5 – 10 %

Range‑bound blue chips

Balanced uptime vs. efficiency

Lower APR than narrow; some upkeep

Medium

Wide

±20 – 50 %

Long‑term passive LPs; volatile tokens

Stays active longer; low maintenance

Capital spread thin → lower fee capture

Low

Ladder

Stacked narrow + medium + wide

Diversify IL risk and fee capture

Blends benefits of multiple widths

Higher gas costs; more complex

Medium,

High

Last updated