Skip to content

DLMM explained

The Dynamic Liquidity Market Maker is the foundational primitive of the ClearPortX exchange. Every subsequent product — money markets, staking, yield loops — builds on top of the DLMM. This page explains what a DLMM is, why it beats traditional constant-product AMMs on capital efficiency, and how a swap actually executes on Canton.

If you are new to AMMs, skip to the glossary first. Otherwise, let’s begin.

A DLMM splits a trading pair’s price range into discrete, zero-slippage bins, and liquidity providers deposit capital into the exact bins they expect to be active — which makes each deposited dollar several orders of magnitude more productive than a traditional AMM.

Think of a traditional AMM as a continuous curve over the full price range. Every unit of liquidity contributes to prices from zero to infinity. Most of that contribution is wasted because trading never actually happens at extreme prices.

A DLMM instead discretizes the range into finite bins, each representing a narrow price interval. Inside a bin, the trade happens at a fixed price with zero slippage. Between bins, the price jumps by the configured bin_step. Liquidity is placed into specific bins, and swaps walk from the active bin outward until they find enough counterparty liquidity.

949596979899100101102103104105106ACTIVE BINLOW PRICEHIGH PRICELIQUIDITY

Figure 1. Discrete liquidity bins. The orange bin is the active bin where the current price lives.

At any moment, exactly one bin is the active bin — the bin that holds reserves of both tokens. Bins to the left of active hold only the quote token (token Y); bins to the right hold only the base token (token X). As trades execute, reserves in the active bin deplete and the active position shifts left or right.

Each bin has a deterministic price derived from its index and the pool’s bin_step parameter. The formula is an exponential ladder:

pbin=(1+s10,000)idp_{bin} = \left(1 + \frac{s}{10{,}000}\right)^{\text{id}}

where s is the bin step in basis points and id is the bin index (signed integer, zero at the initial price). A bin step of 10 bps means each bin is 0.1% higher than its left neighbor. A bin step of 100 bps means each bin is 1% higher.

Why exponential?

An exponential ladder guarantees that the percentage price change between bins is constant. This matches how market participants actually reason about price movement — “1% up” is a meaningful amount regardless of the absolute price level. It also keeps capital efficiency uniform across the entire range.

A pool on ClearPortX is uniquely identified by the tuple (TokenX, TokenY, bin_step). The same trading pair with two different bin steps yields two separate pools with independent liquidity.

Within a single bin, the invariant is constant sum — not constant product. The liquidity relationship is simply:

L=px+yL = p \cdot x + y

where L is the bin’s total liquidity, p is the bin’s fixed price, x is the reserve of token X, and y is the reserve of token Y. Because the price is fixed inside a bin, swaps within the bin execute with zero slippage. A trader moving 10,000 cBTC worth of value through an active bin that has 10,000 cBTC available gets exactly the quoted price, no worse.

When the active bin runs out of the token being requested, the price jumps to the next bin and execution continues from there. A large swap can walk across many bins in a single atomic transaction.

Consider a trader who wants to swap 500 CC for cBTC. The ClearPortX router locates the active CC/cBTC pool, reads the active bin index and its reserves, and walks outward until the trade is satisfied:

-- Simplified execution model (Daml pseudocode)
exercise poolCid Pool_Swap with
fromToken = CC
toToken = cBTC
amountIn = 500.0
minOut = 0.0048
recipient = traderParty

Under the hood, the swap:

  1. Reads the current activeId and volatilityState from the pool contract.
  2. Computes the base fee and variable fee for the first bin to be crossed.
  3. Exchanges reserves in that bin until either the trade is filled or the bin empties.
  4. If the bin empties, increments activeId, updates volatilityReference, and continues.
  5. Repeats until the full amount is filled or minOut would be violated (in which case the whole command reverts).
  6. Commits atomically across every touched bin contract.

The entire flow is a single Daml command — every bin exercise succeeds or none of them do. There is no intermediate state, no partial fill, no reentrancy surface.

The core appeal of a DLMM is capital efficiency. A concrete example makes it visible:

ScenarioTraditional AMMDLMM (5-bin range)
Price range considered0 → ∞±5% around current
Capital required to quote a $1M trade at ≤0.1% slippage~$20M~$1M
LP fees earned per $1 of TVL1× (baseline)up to 20×
Risk on a large adverse moveLower (passive)Higher (concentrated)

The trade-off is real: concentrated liquidity earns more when price stays in range and loses more (via impermanent loss) when price exits the range. ClearPortX addresses this through the three strategies — Spot, Curve, and Bid-Ask — each tuned for a different volatility regime. See Liquidity strategies.

Why this is the right primitive for Canton

Section titled “Why this is the right primitive for Canton”

Canton already prevents MEV structurally, provides atomic settlement across contracts, and hosts institutional counterparties who value capital efficiency. A DLMM is the exchange primitive that best matches these properties:

  • Atomic multi-bin walks are cheap because every Canton command is atomic by default. On Ethereum, walking many bins in one transaction is expensive in gas; on Canton, the cost is bounded and predictable.
  • Privacy means competing LPs cannot see each other’s bin positions in detail, only the aggregate pool state. This prevents quote-sniping and encourages tighter spreads.
  • Deterministic execution means that bin state can be precomputed off-chain before submission, eliminating the failure modes of optimistic routing.

The next page walks through bins and price discovery in more detail, with worked examples.