XYK means: put a pair of assets into a “pool”, and require that the product of the two asset amounts always stays equal:
x * y = k. All swaps must follow this rule, and therefore price, slippage, yield and risk all naturally come from this formula.
Let’s walk through the math step by step.
1. Traditional Trading: Why Do We Need an Order Book?
In traditional exchanges, the core mechanism is the order book:
- A places a buy order at 100 for 1 ETH
- B places a sell order at 101 for 2 ETH
- The system matches orders and completes the trade
This design has several characteristics:
1. Requires professional market makers
- Without someone providing orders, ordinary traders cannot trade
- Market makers must watch the market and continuously update orders
2. Requires a centralized matching engine
- Run by the exchange
- You have to trust the intermediary
3. Ordinary users cannot participate in market-making easily
- Hard to provide liquidity
- Most profits go to institutions
For blockchain, which emphasizes open participation, this is too centralized.
2. AMM: Turning Market Making into a Liquidity Pool
The innovation of AMM (Automated Market Maker) is transforming trading from order matching into a liquidity pool that anyone can join.
A liquidity pool holds two assets (e.g., ETH and USDT) and follows:
x * y = k
This is the XYK constant product market maker model.
When someone buys ETH with USDT, ETH decreases and USDT increases, while keeping the product constant.
AMM replaces the order book:
- no buy/sell orders
- no professional market makers
- no centralized matching engine
- anyone can join
So essentially:
AMM = liquidity pool + mathematical rule
Price, slippage and liquidity depth all follow from this.
3. How Is Price Determined?
Example:
Pool state:
- ETH
x = 100 - USDT
y = 10000
Then the price is naturally:
price = y / x = 10000 / 100 = 100 USDT
Key points:
- Price is not quoted manually
- Price changes automatically with pool state
- External arbitrage aligns the pool price to market price
So in AMM:
Price = asset ratio in pool
4. How Do Trades Change Price?
Initial State
x = 100 ETH
y = 10000 USDT
k = 1,000,000
P₀ = 100
A user wants to spend 1000 USDT to buy ETH.
Transaction rule
Must satisfy
x * y = kbefore and after the swap
After the swap
User adds:
Δy = +1000
y₂ = 11000
x₂ = 1,000,000 / 11000 ≈ 90.909
Δx ≈ 9.091
Average price ≈ 110 Final price ≈ 121
You observe:
- Average paid ≈ 110
- Final price ≈ 121
- Initial price = 100
That feeling of:
“I buy → the price jumps!”
That is slippage.
5. Slippage: Not a Fee, But Price You Push Higher
Slippage is not a fee:
- You moved the price by trading
You are literally buying along the curve from cheap → expensive. Bigger trades cause more slippage.
6. Why Bigger Pools Have Lower Slippage?
Compare:
Small pool: 100 / 10000
Price moves 100 → 121
Big pool: 1000 / 100000
Price moves 100 → 102
Conclusion:
More liquidity → milder price curve → lower slippage
It’s like:
- a basin vs. a lake
- adding a bucket changes the level much more in a basin
7. What Exactly Is Liquidity?
Liquidity = actual asset amounts in the pool
- more liquidity → flatter curve → stable prices
- less liquidity → steep curve → price impact increases
Anyone can provide liquidity, therefore:
Market-making becomes open
8. How Do You Join as a Liquidity Provider?
Pool state:
x = 100 ETH
y = 10000 USDT
Price = 100 USDT/ETH
To add liquidity, you must deposit proportionally:
- add 1 ETH
- plus 100 USDT
Otherwise you change the price.
You receive LP tokens representing your share.
When you withdraw, you take a share of the pool, not exactly what you put in.
This is important for understanding impermanent loss.
9. How Do LPs Earn Fees?
Each trade pays a small fee (e.g., 0.3%), and this fee:
- does NOT go to “the platform”
- goes into the pool
- distributed to LPs
Think of it as:
Traders use your assets, and you charge toll fees
LP earnings:
- trading fees
- token incentives
10. Impermanent Loss
LPs earn fees but face impermanent loss.
Example pool:
1 ETH + 100 USDT
You add:
1 ETH + 100 USDT
Pool:
2 ETH + 200 USDT
(You own 50%)
If ETH price falls, the pool becomes:
4 ETH + 100 USDT
You withdraw:
2 ETH + 50 USDT = 100 USDT value
You deposited value: 200 You withdraw value: 100
You lose value because:
- pool moved toward the depreciating asset
- arbitrage takes the increasing asset out
The pool automatically rebalances toward cheaper assets.
11. What Problems Does XYK Solve?
- No order book
- Price determined algorithmically
- Anyone can become a market maker
- Infrastructure becomes public and open
12. Limitations & Evolution
XYK drawbacks
- Large slippage → specialized stable-swap curves (Curve)
- Poor capital efficiency → concentrated liquidity (Uniswap v3)
- Impermanent loss → LP bears volatility risk
Still:
XYK is the entrance door to AMM design
Understanding XYK makes everything else easier.
13. The One Simple Formula
Back to:
x * y = k
From this follows:
- price:
P = y / x - slippage
- liquidity depth
- LP revenue
- impermanent loss
XYK is the F = ma of DeFi:
deceptively simple, yet the foundation of decentralized trading.