---
title: 'CFAMM: Constant-Function Automated Market Maker'
url: https://www.emergentmind.com/topics/constant-function-automated-market-maker-cfamm
type: topic
---

# CFAMM: Constant-Function Automated Market Maker

A Constant-Function Automated Market Maker (CFAMM) is a class of decentralized trading protocol in which feasible trades are those that leave a specified deterministic function of the pool’s asset reserves invariant. This mechanism generalizes multiple classical AMM models including constant-product, constant-sum, and constant-mean invariants, underpinning prominent decentralized exchanges such as Uniswap and Balancer. CFAMMs serve as critical primitives in decentralized finance, providing continuous liquidity, implicit price discovery, and an on-chain price oracle via arbitrage incentives.

## 1. Formal Structure and Canonical Invariant

A CFAMM is structurally defined by a reserve vector $R \in \mathbb{R}^n_+$ (for $n$ assets) and a continuous, typically concave, homogeneous trading function or invariant $\varphi: \mathbb{R}^n_+ \to \mathbb{R}_+$. A valid trade—formalized via input vector $\Delta$ and output vector $\Lambda$—transforms the reserves from $R$ to $R' = R + \gamma\Delta - \Lambda$ (with $\gamma$ the fee-adjusted scaling), and must satisfy:
\[
\varphi(R, \Delta, \Lambda) = \varphi(R, 0, 0)
\]
or, in level-set form for classical invariants,
\[
\psi(R') = \psi(R)
\]
Exemplars include:
- **Constant product AMM (Uniswap)**: $\varphi(R, \Delta, \Lambda) = (R_1 + \gamma\Delta_1 - \Lambda_1)(R_2 + \gamma\Delta_2 - \Lambda_2)$,
- **Constant mean/balancer**: $\varphi(R, \Delta, \Lambda) = \prod_{i=1}^n (R_i + \gamma\Delta_i - \Lambda_i)^{w_i}$, $\sum w_i = 1$,
- **Elliptic/circle invariants**: $C(q) = \sum_{i=1}^n (q_i - a)^2 + b\sum_{i \neq j} q_i q_j$.

The trading set $T(R)$ and reachable set $S(R)$ encode all possible trades and resultant reserves, forming the basis for geometric, dual, and optimization-based analyses [2003.10001][2308.08066].

## 2. Price Discovery and Oracle Property

The invariant function implicitly defines the marginal (no-arbitrage) prices. Formally, for differentiable $\psi$:
\[
\text{price} \propto \nabla \psi(R)
\]
Choosing a numéraire (e.g., asset $k$), the relative price between assets $j$ and $k$ is:
\[
P_{j/k} = \frac{w_j/R_j}{w_k/R_k}
\]
for a constant-mean invariant. Arbitrage ensures that whenever the CFAMM’s internal prices deviate from external references, profit-seeking traders rebalance reserves until the supporting hyperplane (gradient of the constraint surface) matches the external vector of asset prices [2003.10001].

Under path deficiency or its strict variant, the reserves' value (measured in any strictly positive price vector) is non-decreasing over feasible trade sequences, precluding “drain” exploits and rendering the CFAMM a robust oracle [2003.10001]. 

## 3. Axiomatic Foundations and Equivalence to Prediction Markets

Axiomatic analyses reveal that CFAMMs emerge naturally from simple principles:
- **Separability (independence)** ensures the exchange rates between assets depend only on the relevant pair’s inventories, not on others.
- **Scale invariance** (for DeFi) leads to functional forms such as constant-product and constant-mean (“constant inventory elasticity” class), while **translation invariance** (for prediction markets) uniquely determines the LMSR cost function [2210.00048][2302.00196].

Consequently, every "good" (i.e., liquid, path-independent, responsive, and non-dominated) market maker is necessarily a CFAMM with a concave invariant, and vice versa. There exists a duality: every CFAMM defines a proper scoring rule, and every scoring-rule-based prediction market can be recast as a CFAMM with an invariant $\phi(q) = -C(-q)$, where $C$ is the cost function [2302.00196].

## 4. Replication, Duality, and Portfolio Interpretation

The space of convex, homogeneous, nonnegative, nondecreasing “portfolio value” functions $V(\cdot)$ is equivalent to the space of CFAMMs via Fenchel conjugacy:
\[
\psi_V(R) = \inf_{c \in \mathbb{R}^n} (c^T R - V(c))
\]
Conversely, the set of feasible reserves is $S = \{R \geq 0 : c^\top R \geq V(c)\ \forall\,c\}$ [2103.14769]. This duality, sometimes encoded as $\psi_V(R) = -(-V)^*(-R)$, statically replicates nonlinear payoff profiles—including those of European options and exotic derivatives—within the canonical CFAMM framework.

Geometric perspectives further demonstrate that the canonical trading function and the minimal-cost portfolio function are dually associated through the liquidity cone $K$ via conic duality:
\[
\phi(R) = \sup\{\lambda > 0: R/\lambda \in S\},\quad V(c) = \inf_{R > 0} \frac{c^T R}{\phi(R)}
\]
This equivalence persists with minimal assumptions: convexity and monotonicity suffice [2308.08066].

## 5. Liquidity Microstructure, Slippage, and Impermanent Loss

CFAMMs enforce nonlinear price responses to order size due to their invariant curve geometry. For the constant-product model, marginal price sensitivity is $-\frac{y}{x}$, resulting in nonlinear “slippage.” Larger trades against shallow pools incur superlinear price impact, quantified explicitly by $[(1/(1-f)^2)-1]\times 100\%$ for a trade of fraction $f$ of a token reserve [2105.02782]. 

For liquidity providers (LPs), providing capital to a CFAMM results in “impermanent loss” (IL): the difference between holding assets directly and keeping them in the pool. This is a deterministic, convex function of the spot price ratio and market volatility—losses increase in shallow or highly volatile conditions:
\[
\text{IL} = (\sqrt{V_E+1} - 1)\times 100\%
\]
Design flexibility is encoded in generalized invariants. The power root family
\[
V_{\operatorname{pow}}(a, b; p) = (a^p + b^p)^{1/p}
\]
with $q = p/(p-1)$ interpolates sum, product, harmonic mean, and reserve invariants, tuning the trade-off between slippage (for traders) and impermanent loss (for LPs) [2205.07452].

## 6. Optimal Design, Fee Dynamics, and Practical Implementations

Recent frameworks treat CFAMM design as a convex optimization over the space of liquidity allocation functions $L(p)$, parameterized by beliefs (density $\psi$) on future asset prices. Constraints on total reserves and optimality (maximizing the fraction of settled trades or net profit) yield trading functions that minimize expected trade failure, with dual formulas for inferring LP beliefs from observed invariants [2212.03340].

Dynamic fee optimization is analyzed as a stochastic control problem, leading to (i) two regimes: high fees to deter arbitrage when inventory drifts from balanced, and low or negative fees to attract noise traders and increase volume; and (ii) explicit, nearly linear fee formulas in inventory misalignment and external price deviation:
\[
p^*(t, y) = \frac{g(t, y, s) - g(t, y+\Delta^+)}{\Delta^+} + \frac{1}{k \Delta^+}
\]
where $g$ arises from the HJB equation solved for the AMM’s value function [2506.02869].

Concentrated liquidity protocols allow LPs to allocate over intervals ("ticks"), supporting strategic positioning based on profitability, volatility, and predicted price drift—analytic solutions exist in single-pool settings, whereas multi-pool provision leverages deep learning approaches such as LSTM networks for high-dimensional allocation [2407.16885].

## 7. Option-Theoretic Interpretation and LVR Analysis

A rigorous option-theoretic model represents a CFAMM liquidity position as a static portfolio of perpetual American continuous-installment (CI) options. Each option, funded at a constant rate $q$ per unit time, statically replicates the AMM’s delta exposure:
\[
\partial_S \Pi(S) = V'(S)
\]
where $V$ is the CFAMM value function and $\Pi$ the replicated portfolio. The loss-versus-rebalancing (LVR)—the adverse-selection cost incurred by non-instantaneous rebalancing relative to continuous hedging—is proven analytically equal to the continuous funding theta of the at-the-money CI option:
\[
d\text{LVR}_t = \frac{1}{2} \sigma^2 S_t^2 V''(S_t)\, dt
\]
Calibration procedures allow mapping the perpetual volatility to term-structure-implied market values; the framework supports liquidity band selection that renders LVR nearly constant and predictable over arbitrary horizons [2508.02971].

## Table: Core Invariant and Pricing Formulas

| CFAMM Family       | Invariant $\psi(\cdot)$                             | Marginal Price Formula                              |
|--------------------|-----------------------------------------------------|-----------------------------------------------------|
| Constant Product   | $x y = k$                                           | $y/x$                                               |
| Constant-Mean      | $\prod_{i=1}^n x_i^{w_i}$, $\sum w_i=1$             | $(w_j/x_j)/(w_k/x_k)$ (numéraire $k$)               |
| Power Root         | $(x^q + y^q)^{1/q} = k$                             | $x^{q-1} y^{1-q}$                                   |
| Constant Ellipse   | $\sum (q_i - a)^2 + b \sum_{i \neq j} q_i q_j = k$  | $2(q_i - a) + b \sum_{j \ne i} q_j$                 |

## References

- [2003.10001]: generalized framework, price oracle mechanism, path deficiency, supporting hyperplane method
- [2210.00048]: axiomatic derivation, scale vs translation invariance, CPMM and LMSR connection
- [2302.00196]: equivalence with prediction markets, scoring rules
- [2103.14769]: duality between payoff and trading function, replication via Fenchel conjugacy
- [2508.02971]: option-theoretic replication and LVR interpretation
- [2506.02869]: dynamic fee optimization and regime analysis
- [2404.13291]: optimal design for LPs under risk preferences and portfolio efficiency

---

The CFAMM framework systematically underpins the microstructure and economic incentives of decentralized markets, generalizing myriad mechanisms for liquidity aggregation, price discovery, and incentive-compatible fee structures. Through geometric, dual, and axiomatic analyses, it demonstrates robust market properties—such as manipulability resistance, arbitrage protection, and capital-efficient liquidity allocation—while also exposing tractable trade-offs between trader experience, LP risk, and protocol design. The option-theoretic interpretation and optimization-based design offer rigorous paths for further innovation and empirical performance tuning in automated market infrastructure.

Source: https://www.emergentmind.com/topics/constant-function-automated-market-maker-cfamm