---
title: Constant Function Market Makers (CFMMs)
url: https://www.emergentmind.com/topics/constant-function-market-makers-cfmms-6b3e94e1-2b76-4102-b7b4-b4843a36d073
type: topic
---

# Constant Function Market Makers (CFMMs)

Constant Function Market Makers (CFMMs) are a class of automated market making mechanisms fundamental to decentralized exchanges (DEXs) operating on blockchains such as Ethereum. A CFMM is defined by a deterministic, continuously maintained trading function (also called an invariant or potential) over the reserves of multiple assets. Trades are executable if, and only if, the proposed post-trade reserves satisfy the invariant, which is typically a concave, increasing function for multi-asset pools. This framework generalizes the constant-product rule (Uniswap), the weighted geometric mean (Balancer), constant-sum forms, and more exotic functions such as those used in Curve and option-replicating AMMs. The CFMM framework enables trustless, on-chain liquidity provision, transparent price discovery, and algorithmic equilibrium subject to rigorous convexity, separability, and scaling axioms.

## 1. Foundational Structure and Core Properties

A CFMM holds reserves $R \in \mathbb{R}^n_+$ of $n$ assets. Its dynamics are encoded by an invariant function $\Phi: \mathbb{R}_+^n \rightarrow \mathbb{R}$, required to be concave, increasing, and typically differentiable. Given a fee parameter $\gamma \in (0,1]$, a trade proposing to deposit $\Delta \in \mathbb{R}^n_+$ and withdraw $\Lambda \in \mathbb{R}^n_+$ is accepted if
$$
\Phi(R + \gamma \Delta - \Lambda) \geq \Phi(R),
$$
with equality typically enforced by maximizing $\Lambda$ for the provided $\Delta$ [2107.12484].

The marginal price vector at any reserve state $R$ is given by the gradient $\nabla \Phi(R)$, with individual asset prices defined as $p_i = \frac{\nabla \Phi(R)_i}{\nabla \Phi(R)_n}$, using asset $n$ as numéraire [2107.12484, 2003.10001]. For two-asset CFMMs, the swap curve $F(\delta)$ relating the input and maximum output can often be given in closed form (e.g., for Uniswap's $\Phi(x, y) = xy$, $F(\delta) = y - \frac{xy}{x + \gamma \delta}$) [2107.12484].

**Axiomatic Characterization**: Essential properties are concavity, monotonicity, and (often) 1-homogeneity (scale invariance) of $\Phi$, enforced by the requirements of no-arbitrage, path-independence, dominated trade exclusion, demand responsiveness, and liquidation admissibility [2210.00048, 2302.00196]. Separability (pairwise independence) ensures that the marginal price of exchanging $i$ for $j$ is functionally independent of the other reserves [2210.00048].

## 2. Convexity, Optimization, and Trade Feasibility

The fundamental consequence of concavity is that the trade acceptance region, as well as the set of all attainable reserve states post-trade, is convex [2107.12484, 2308.08066]. The selection of optimal trades (including the utility-maximizing trade for a rational agent) reduces to solving the convex program:
$$
\begin{aligned}
\max_{\Delta, \Lambda} \quad & U(\Lambda - \Delta) \\
\text{s.t.} \quad & \Phi(R + \gamma \Delta - \Lambda) \geq \Phi(R), \;\; \Delta \geq 0, \;\; \Lambda \geq 0,
\end{aligned}
$$
where $U$ is a concave, increasing utility function [2107.12484].

Dual variables in the Lagrangian formulation correspond to the marginal prices reported by the CFMM at the post-trade reserve state, providing the canonical on-chain spot price and, in equilibrium with external prices, serving as a robust, incentive-compatible price oracle [2107.12484, 2003.10001]. Interior-point, operator-splitting, and first-order methods, leveraging domain-specific solvers (CVXPY, JuMP, ECOS, SCS), efficiently handle CFMMs even with hundreds of assets [2107.12484].

Routing problems across a network of CFMMs—splitting multi-token trades for optimal price or slippage—likewise reduce to convex optimization, or mixed-integer convex programming if fixed costs per pool are included. Dual-based decomposition and Fenchel conjugacy further yield efficient parallel algorithms for large networks and aggregation [2204.05238, 2302.04938].

## 3. Geometric and Axiomatic Formulations

CFMMs are geometrically characterized by the convex, upward-closed set of reachable reserve vectors $S \subseteq \mathbb{R}_+^n$, with the canonical trading function $\phi(R) = \sup\{\lambda : R/\lambda \in S\}$, guaranteed to be concave, homogeneous, and nondecreasing [2308.08066]. This construction via convex cones yields an explicit duality between the trading function and the portfolio value function:
$$
V(c) = \inf_{R \in S} c^T R, \quad \phi(R) = \inf_{c > 0} \frac{c^T R}{V(c)},
$$
and enables composition by scaling, Minkowski addition, and intersection of reachable sets [2308.08066].

Axiomatic approaches distinguish classes of CFMMs through invariance criteria: scale invariance (1-homogeneity) leads to the constant-product (CPMM) and CES family, while translation invariance leads to logarithmic scoring rule CFMMs (LMSR) used in prediction markets. The CPMM emerges as the extreme, trader-optimal point for a set of convex, symmetric, scale-invariant market makers [2210.00048]. Equivalence to cost-function prediction markets is established via convex duality: every concave, increasing CFMM can be associated with a convex cost-function market, and vice versa [2302.00196].

## 4. Parameter Choices, Curvature, and Fee Design

**Curvature** of the trading function determines sensitivity to trade size (“slippage”) and liquidity. For a two-asset CFMM, the price impact is governed by the local and global curvature of the invariant. High curvature (large second derivatives) increases slippage and liquidity-provider protection; low curvature reduces slippage but exposes LPs to adverse selection [2012.08040]. Quantitatively, price sensitivity $\mu = g'(0)$ and liquidity $\kappa = (g(0) - g(-L))/L$ characterize these effects and prescribe yield-farming subsidies to compensate for impermanent loss [2012.08040].

**Fee Optimization**: Trading fees $\gamma$ provide compensation to LPs for arbitrage-induced loss but also widen the “no-arbitrage band,” reducing price accuracy. For geometric mean market makers (G³Ms), mean-variance analysis shows that, in continuous-diffusion settings, optimal fees approach zero, with competitive dynamics in multi-pool settings driving fees toward the smallest nonzero values justified by fixed costs [2104.00446, 2105.13510]. Calibration to actual DEX data reveals smaller pools extract higher returns on capital at equilibrium, guiding optimal liquidity distribution among pools [2105.13510].

## 5. Privacy, Attacks, and Implementation Challenges

Commodity CFMMs provide no transaction privacy; under standard adversarial models, knowledge of pre- and post-trade reserves and marginal prices allows an observer to reconstruct individual trade sizes exactly whenever the invariant has nonzero curvature and is 1-homogeneous [2103.01193]. All practical attempts at privacy—randomized oracle noise, batching, private timing, or trusted hardware—face either efficacy, utility, or trust challenges.

Extensions to privacy-aware CFMMs add randomness (“noise trades”) to the asset reserves. The expected arbitrage loss from noise can be exactly offset by a “privacy fee” only if the noise is zero-mean in asset coordinates; the requisite fee is inversely proportional to pool liquidity [2309.14652]. This achieves priceability and truthfulness but necessarily exposes users to higher costs or loss of privacy when liquidity is concentrated.

**Game-theoretic attacks**: CFMMs are structurally susceptible to maximal extractable value (MEV), including sandwich attacks and transaction reordering. Analyses show that the marginal profit for MEV searchers is controlled by the slippage and the curvature of the CFMM. Systematic design of the invariant (curvature tuning, fee scaling) and careful setting of slippage tolerances by users can mitigate the worst-case impact [2207.11835].

## 6. Design Generalizations and Option-like CFMMs

The convex-analytic machinery underlying CFMMs supports arbitrarily general concave, 1-homogeneous, nondecreasing invariants, allowing for the engineering of payoff-matching AMMs (“replicating market makers”). There is a one-to-one correspondence between such “consistent” payoff functions and CFMM invariants via Fenchel conjugacy; for example, LP-tokens can be engineered to replicate option payoffs such as covered calls [2103.14769, 2310.14320].

Generalizations such as Generalized Mean Market Makers (G3Ms) and their further extensions (Gf3Ms) interpolate between constant-sum (arithmetic mean), constant-product (geometric mean), and more general mean functions, with tunable curvature and slippage characteristics [2208.07305]. Optimal design frameworks (e.g., maximizing the fraction of failed trades or minimizing failure risk for a given liquidity distribution) can be formulated as convex programs, calibrating the CFMM curve shape to the market-maker’s beliefs, fee targets, and loss aversion [2212.03340].

Concentrated liquidity (CL)—as in Uniswap v3—enables LPs to focus liquidity over selected price intervals, increasing capital efficiency and providing strategies for optimal liquidity provision under stochastic asset dynamics or via reinforcement learning with function approximation (e.g., LSTMs for state features) [2407.16885].

## 7. Applications and Extensions

CFMMs now underpin the majority of decentralized, on-chain exchange, liquidity, and yield strategies, with central roles in:

- Multiroute DEX aggregation and optimal routing [2204.05238, 2302.04938].
- On-chain option/derivative-like payoff synthesis (e.g., RMM-01 for covered calls) [2310.14320].
- On-chain, incentive-compatible price oracles and arbitrage-driven price alignment [2003.10001].
- Hybrid market designs with batch clearing, integration with off-chain orderbooks, or dynamic liquidity distribution [2210.04929].
- Arbitrage-resistant, incentive-aligned design for cost-function prediction markets and robust information elicitation [2302.00196].

Ongoing research continues to expand the scope of CFMMs with robust geometric, analytic, and computational frameworks, connecting DeFi mechanisms, prediction markets, convex analysis, and market microstructure. The convexity and duality structure of CFMMs enables modular, scalable design for both market participants and system architects.

---

**Principal references:**  
- [2107.12484], [2308.08066], [2210.00048], [2012.08040], [2103.01193], [2302.04938], [2204.05238], [2302.00196], [2105.13510], [2104.00446], [2212.03340], [2208.07305], [2210.04929], [2309.14652], [2310.14320], [2103.14769], [2407.16885], [2003.10001], [2306.11580], [2207.11835]

Source: https://www.emergentmind.com/topics/constant-function-market-makers-cfmms-6b3e94e1-2b76-4102-b7b4-b4843a36d073