Constant function market maker
Constant-function market makers (CFMM) are a paradigm in the design of trading venues where a trading function and a set of rules determine how liquidity takers (LTs) and liquidity providers (LPs) interact, and how markets are cleared. The trading function is deterministic and known to all market participants.
Overview
Constant-function market makers (CFMM) are a paradigm in the design of trading venues where a trading function and a set of rules determine how liquidity takers (LTs) and liquidity providers (LPs) interact, and how markets are cleared. The trading function is deterministic and known to all market participants. CFMMs display pools of liquidity of two assets. The takers and providers of liquidity interact in the liquidity pools: LPs deposit their assets in the pool and LTs exchange assets directly with the pool. CFMMs rely on two rules; the LT trading condition and the LP provision condition. The LT trading condition links the state of the pool before and after a trade is executed, and it determines the relative prices between the assets by their quantities in the pool. The LP provision condition links the state of the pool before and after liquidity is deposited or withdrawn by an LP. Thus, the trading function establishes the link between liquidity and prices, so LTs can compute the execution costs of their trades as a function of the trade size, and LPs can compute the exact quantities that they deposit. In CFMMs, both conditions state that price formation happens only through LT trades (see below). In decentralized platforms running on peer-to-peer networks, CFMMs are hard-coded and immutable programs implemented as Smart Contracts, where LPs and LTs invoke the code of the contract to execute their transactions. A particular case of CFMMs are the constant product market makers (CPMMs) such as Uniswap v2 and Uniswap v3 where the trading function uses the product of the quantities of each asset in the pool to determine clearing prices. CFMMs are also popular in prediction markets.
History
An early description of a CFMM was published by economist Robin Hanson in "Logarithmic Market Scoring Rules for Modular Combinatorial Information Aggregation" (2002). Early literature referred to the broader class of "automated market makers", including that of the Hollywood Stock Exchange founded in 1999; the term "constant-function market maker" was introduced in "Improved Price Oracles: Constant Function Market Makers" (Angeris & Chitra 2020). First be seen in production on a Minecraft server in 2012, CFMMs are a popular DEX architecture.
Trading function
Consider a reference asset
X
{\displaystyle X}
and an asset
Y
{\displaystyle Y}
which is valued in terms of
X
{\displaystyle X}
. Assume that the liquidity pool of the CFMM initially consists of quantity
x
{\displaystyle x}
of asset
X
{\displaystyle X}
and quantity
y
{\displaystyle y}
of asset
Y
LT trading condition and convexity
LT transactions involve exchanging a quantity
Δ
y
{\displaystyle \Delta ^{y}}
of asset
Y
{\displaystyle Y}
for a quantity
Δ
x
{\displaystyle \Delta ^{x}}
of asset
X
{\displaystyle X}
, and vice-versa. The quantities to exchange are determined by the LT trading condition:
(1)
f ( x , y ) = f ( x +
Δ
x
, y −
LP provision condition and homotheticity
LP transactions involve depositing or withdrawing quantities
(
Δ
x
,
Δ
y
)
{\displaystyle (\Delta ^{x},\Delta ^{y})}
of asset
X
{\displaystyle X}
and asset
Y
{\displaystyle Y}
. Let
κ
0
{\displaystyle \kappa _{0}}
be the initial depth of the pool and let
Constant Product Market Maker
In CPMMs such as Uniswap v2, the trading function is
f
(
x , y
)
= x × y ,
{\displaystyle f\left(x,y\right)=x\times y,}
so the level function is
φ
( y )
=
κ
2
/
y
{\displaystyle \varphi \left(y\right)=\kappa ^{2}{\big /}y}
, the marginal exchange rate is
Z = x
/
y ,
Fees
For LPs, the key difference between the traditional markets based on LOBs and CFMMs is that in LOBs, market makers post limit orders above and below the mid-price to earn the spread on roundtrip trades, while in CFMMs, LPs earn fees paid by LTs when their liquidity is used.
Loss-Versus-Rebalancing
Without fees paid by LTs, liquidity provision in CFMMs is a loss-leading activity. Loss-Versus-Rebalancing (LVR) is a popular measure of these losses. Assume the price follows the dynamics
d
S
t
=
σ
t
d
W
t
{\displaystyle dS_{t}=\sigma _{t}dW_{t}}
then the LVR is given by
LVR
t
= −
1 2
∫
0
t
σ
Predictable loss
To thoroughly characterise their losses, LPs can also use Predictable Loss (PL), which is a comprehensive and model-free measure for the unhedgeable and predictable losses of liquidity provision. One source of PL is the convexity cost (losses due to adverse selection, they can be regarded as generalized LVR) whose magnitude depends on liquidity taking activity and the convexity of the level function. The other source is the opportunity cost, which is incurred by LPs who lock assets in the pool instead of investing them in the risk-free asset. For an LP providing reserves
(
x
0
,
y
0
)
{\displaystyle (x_{0},y_{0})}
at time
t = 0
{\displaystyle t=0}
and withdrawing liquidity at time
T > 0
{\displaystyle T>0}
, PL is
PL
T
= −
1 2
Impermanent loss
Impermanent loss, or divergence loss, is sometimes used to characterise the risk of providing liquidity in a CFMM. Impermanent loss compares the evolution of the value of the LP's assets in the pool with the evolution of a self-financing buy-and-hold portfolio invested in an alternative venue. The self-financing portfolio is initiated with the same quantities
(
x
0
,
y
0
)
{\displaystyle \left(x_{0},y_{0}\right)}
as those that the LP deposits in the pool. It can be shown that the impermanent loss
IL
t
{\displaystyle {\text{IL}}_{t}}
at time
t > 0
{\displaystyle t>0}
is
IL
t
=
Concentrated liquidity
Concentrated liquidity is a feature introduced by Uniswap v3 for CPMMs. The key feature of a CPMM pool with CL is that LPs specify a range of exchange rates in which to post liquidity. The bounds of the liquidity range take values in a discretised finite set of exchange rates called ticks. Concentrating liquidity increases fee revenue, but also increases PL and concentration risk, i.e., the risk of the exchange rate exiting the range.
Wikipedia contributors · Constant function market maker · revision 1341936189 · CC BY-SA 4.0 · Plain text extracted and formatting adapted; tags derived from linked topics.