The fundamental automated market maker formula where the product of two token reserves must remain constant, enabling decentralized token swaps without order books.
The constant product AMM (x × y = k) is the mathematical formula pioneered by Uniswap that powers most decentralized exchanges. It ensures that no matter how many trades occur, the product of two token reserves in a liquidity pool always stays the same — enabling always-available token swaps without order books or market makers.
How the Formula Works
The Core Equation
x = reserve of Token A in the pool
y = reserve of Token B in the pool
k = constant product that must be maintained
When a trader buys Token A, they add Token B and remove Token A
The product of the new reserves must still equal k
Price Discovery
The spot price of Token A in terms of Token B is simply:
Price of A = y / x
Copy link
As traders buy Token A, x decreases and y increases, so the price of A goes up — creating slippage that increases with trade size relative to pool depth.
Uniswap's Implementation
How Uniswap v2 Uses x*y=k
Action
Effect on Pool
Effect on Price
Buy Token A
x decreases, y increases
Price of A rises
Sell Token A
x increases, y decreases
Price of A falls
Add liquidity
Both x and y increase
No change
Remove liquidity
Both x and y decrease
No change
Liquidity Provider Mechanics
LPs deposit equal value of both tokens into the pool
They receive LP tokens representing their share of the pool
Trading fees (typically 0.3%) are distributed to LPs proportionally
LPs can withdraw their share at any time by burning LP tokens
Price Impact and Slippage
Understanding Slippage
Slippage is the difference between the expected price and the actual execution price. It increases with trade size relative to the pool's liquidity.
Trade Size vs Pool
Slippage Level
Under 0.1% of pool
Negligible
0.1-1% of pool
Low (0.1-1%)
1-5% of pool
Moderate (1-5%)
5-10% of pool
High (5-10%)
Over 10% of pool
Very High
Price Impact Formula
For a trade of Δx tokens into the pool:
Δy = y - (k / (x + Δx))
Copy link
The larger Δx is relative to x, the less Δy you receive per token — this is the price impact.
Comparison to Other AMM Models
AMM Model Comparison
Model
Formula
Best For
Drawback
Constant product
x × y = k
General purpose
High slippage on large trades
Constant sum
x + y = k
Stablecoins
Drains one side completely
StableSwap (Curve)
Hybrid
Like-price assets
Less effective for volatile pairs
Concentrated (Uniswap v3)
x × y = k in ranges
Capital efficiency
Active management needed
Weighted (Balancer)
When x*y=k Works Best
High-liquidity pairs with frequent trading
Tokens with moderate volatility
Long-tail assets where order books would be too thin
Situations where simplicity and trust-minimization matter most
Example Trade
State
Token A (x)
Token B (y)
Product (k)
Price
Initial
1,000
2,000
2,000,000
2.0
After buy 100 A
1,100
1,818
2,000,000
1.65
After buy 100 A
1,200
1,667
2,000,000
1.39
Each subsequent purchase of Token A costs more Token B — this is slippage in action.