Papers
Topics
Authors
Recent
Search
2000 character limit reached

Constant Function Market Maker (CFMM)

Updated 19 February 2026
  • CFMMs are automated market makers that maintain a constant invariant function for every trade, ensuring consistent liquidity dynamics.
  • They leverage properties like concavity, homogeneity, and scale invariance to enable efficient decentralized price discovery and programmable liquidity.
  • Generalized invariants such as G3Ms offer flexible trade-offs between slippage and capacity, supporting optimal routing and robust risk management.

A constant function market maker (CFMM) is an automated market maker defined by an invariant: a deterministic, typically concave and nondecreasing, function of its reserves that must remain constant (up to fees) for each allowable trade. CFMMs underpin most decentralized exchanges (DEXs), offering programmable and algorithmically tractable liquidity, price discovery, and routing. Their mathematical structure unifies major DeFi protocols, connects to prediction market literature, and has motivated both axiomatic and optimization-based research frameworks.

1. Formal Structure and Axiomatic Foundations

A CFMM is specified by a reserve vector r=(r1,,rn)R+nr = (r_1,\dots,r_n) \in \mathbb{R}^n_+ and a trading (or potential/invariant) function ϕ:R+nR\phi: \mathbb{R}^n_+ \to \mathbb{R}, usually required to be strictly increasing, continuous, and concave on the relevant domain. A valid trade updates reserves to rr' if and only if ϕ(r)=ϕ(r)\phi(r') = \phi(r), potentially with input fees adjusted by factor γ\gamma (Zanger, 2022, Frongillo et al., 2023, Schlegel et al., 2022).

Key Axioms for an Invariant Function

  • Increasingness: ϕ\phi is strictly increasing in each reserve.
  • Separability/Independence: Marginal rates depend on only the assets traded.
  • Scale Invariance: ϕ(λr)=λϕ(r)\phi(\lambda r) = \lambda \phi(r) for all λ>0\lambda > 0.
  • Concavity: Ensures convexity of trade sets and monotonic worsening of terms with trade size.
  • Symmetry/Non-Concentrated Liquidity: No axis intersection; infinite liquidity unless all but one reserve is exhausted (Schlegel et al., 2022).

A broad class of trading functions includes the constant-product (Uniswap), constant-sum, and weighted geometric mean (Balancer) forms: Constant-product:ϕ(x,y)=xy Constant-sum:ϕ(x,y)=x+y Weighted mean (Balancer):ϕ(r)=i=1nriwi,wi=1 \begin{align*} \text{Constant-product:} &\quad \phi(x,y) = x y \ \text{Constant-sum:} &\quad \phi(x,y) = x + y \ \text{Weighted mean (Balancer):} &\quad \phi(r) = \prod_{i=1}^n r_i^{w_i}, \quad \sum w_i = 1 \ \end{align*}

Axiomatic analysis proves that scale-invariant, independent CFMMs are necessarily constant-product (geometric mean) forms—justifying their dominance in DeFi (Schlegel et al., 2022, Frongillo et al., 2023). Translation invariance, relevant in prediction markets, yields log-linear (LMSR) forms.

2. Family of Invariants: G3Ms and Generalized f-Means

CFMM models can be generalized via generalized mean invariants (G3Ms), parameterized by pp (Zanger, 2022): Mp(x,y)=(12xp+12yp)1/pM_p(x, y) = \left( \tfrac{1}{2} x^p + \tfrac{1}{2} y^p \right)^{1/p}

  • p=1p=1: arithmetic mean (constant-sum), giving zero slippage but finite trade capacity.
  • p0p \to 0: geometric mean (constant-product), supports unbounded trades but induces slippage.

The G3M defines a one-parameter family interpolating between these two extremes, with the trade output for input Δx\Delta x given by: Δy=y(xp+yp(x+Δx)p)1/p\Delta y = y - \left( x^p + y^p - (x + \Delta x)^p \right)^{1/p} For p(0,1)p \in (0,1), G3M admits unbounded trades with slippage growing as a sublinear negative power of remaining reserve (Zanger, 2022). Concavity, homogeneity, and monotonicity of MpM_p for p[0,1]p \in [0,1] guarantee economic tractability and arbitrage bounds.

A more general extension is the generalized f-mean: Mf(x1,,xn)=f1(iwif(xi))M_f(x_1,\ldots,x_n) = f^{-1}\left( \sum_{i} w_i f(x_i) \right) where ff is any continuous, strictly monotone function. These Gf3Ms allow designer sculpting of slippage, depth, and risk curves beyond the G3M parameterization, preserving CFMM validity where MfM_f is concave, homogeneous, and differentiable (Zanger, 2022).

3. Analytical Properties: Slippage, Price Impact, and Liquidity

The spot price at state (x,y)(x, y) is dictated by the gradient of the invariant: Ep=xMp(x,y)yMp(x,y)E_p = - \frac{ \partial_x M_p(x, y) }{ \partial_y M_p(x, y) } Slippage for a finite trade is the deviation of the realized price Δy/Δx\Delta y / \Delta x from the local spot; for constant-sum (p=1), this is zero, but for geometric mean (p=0), slippage increases rapidly as reserves are depleted (Zanger, 2022).

Liquidity depth is determined directly by the invariant and is often proportional to the reserves (degree-1 homogeneity). For a homogeneous invariant, arbitrage bounds, depth metrics, and reserve depletion safeguards are inherited from the convex geometry of the invariant function (Angeris et al., 2023, Frongillo et al., 2023).

4. Optimization, Routing, and Generalization

CFMMs offer a convex-analytic framework for multi-asset and multi-market trading and optimal routing (Angeris et al., 2021, Angeris et al., 2022, Diamandis et al., 2023). In networks of CFMMs, the set of feasible trades is convex, and optimal routing reduces to a convex program: maxU(Ψ)s.t. Ψ=i=1mAiΔi, ΔiTi\max U(\Psi) \quad \text{s.t.}~\Psi = \sum_{i=1}^m A_i \Delta_i,~\Delta_i \in T_i where TiT_i are convex trade sets derived from the invariants of each market, and U(Ψ)U(\Psi) encodes the objective (utility, liquidation value, or arbitrage detection). The dual variables of this routing program converge to no-arbitrage price vectors. Special structure (e.g., Uniswap v3's "aggregate" bins) enables efficient per-bin or per-pool parallelization and rapid optimization (Diamandis et al., 2023).

Beyond two-token pools, CFMMs generalize to n-asset settings, batch auctions, and hybrid protocols. Axiomatic and geometric frameworks subsume both DeFi and cost-function prediction market structures, with convex duality providing a bridge to proper scoring rules and information-elicitation markets (Frongillo et al., 2023, Schlegel et al., 2022).

5. Economic Implications, Adversarial Considerations, and MEV

CFMMs' properties are shaped by invariant curvature. Low-curvature (flat) curves minimize slippage and benefit LPs in pools with uninformed or mean-reverting flows (e.g., stablecoins), whereas high curvature offers adverse selection protection for LPs against informed traders (Angeris et al., 2020). This trade-off is central in pool design, especially for incentivized liquidity or "yield farming."

Maximal Extractable Value (MEV)—adversarial profit from reordering or sandwiching trades—depends structurally on CFMM invariants and liquidity parameters. The game-theoretic analysis establishes that routing and reordering MEV are bounded by pool curvature and liquidity depth. For well-designed CFMMs and sufficient liquidity, the price of anarchy remains constant, and the worst-case user price impact under adversarial trade reordering only grows logarithmically with the number of trades (Kulkarni et al., 2022).

Arbitrageurs maintain price parity between CFMM-implied prices and external/oracle prices, enforcing a direct connection between reserves and real-world markets. Under mild convexity and path-deficiency conditions, rational arbitrageurs ensure efficient, truthful price discovery in the absence of external manipulation (Angeris et al., 2020, Angeris et al., 2023).

6. Extensions: Privacy, Derivative Replication, and Design Optimization

Recent work extends the CFMM framework to address privacy protection (personalized local differential privacy with per-trade fees calibrated to liquidity and privacy parameters) (Goyal et al., 2023), time-dependent option replication (e.g., RMM-01 pools that replicate Black–Scholes covered calls) (Jepsen et al., 2023), and optimal curve design derived directly from beliefs about future price distributions (Goyal et al., 2022). The latter is achieved by convex optimization over the liquidity profile function L(p)L(p), resulting in optimal trade-off curves for slippage, fee revenue, and LP opportunity cost, and enabling the inference of implicit market-maker beliefs from an observed curve.

Design choices for fee rates, curve curvature, and liquidity range are quantitatively linked to pool profitability, capital efficiency, and market robustness (Evans et al., 2021, Dewey et al., 2023, Monga, 2024). Concentrated liquidity models (e.g., Uniswap v3) enhance capital efficiency while sacrificing convexity and continuous trade support.

7. Synthesis and Theoretical Impact

CFMMs unify core concepts from DeFi market microstructure, convex optimization, prediction market elicitation, and geometric functional analysis. The canonical trading functions are nondecreasing, concave, and positively homogeneous—properties ensuring robust economic incentives and tractable trade/price computations (Angeris et al., 2023, Angeris et al., 2021). The “geometry-first” viewpoint enables the systematic composition and aggregation of multiple market primitives.

The theoretical framework gives rigorous characterizations of admissible invariants, trade sets, and payoffs, allowing for derivative-replicating pools, risk-shaping through invariant design, and formal analysis of practical phenomena such as MEV, privacy cost, and the trade-off between capital efficiency and impermanent loss (Angeris et al., 2021, Goyal et al., 2022).


References:

Topic to Video (Beta)

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Constant Function Market Maker (CFMM).