AMMs & Liquidity Pools
Lesson by Uvin Vindula
The innovation that made DEXs viable is the Automated Market Maker (AMM). Instead of matching buyers with sellers through an order book, AMMs use mathematical formulas and liquidity pools to enable instant trading.
What Is a Liquidity Pool?
A liquidity pool is a smart contract that holds a pair of tokens (e.g., ETH and USDC). Anyone can deposit tokens into the pool and become a liquidity provider (LP). In return, LPs earn a share of trading fees generated by the pool.
The Constant Product Formula
Most AMMs (like Uniswap) use the constant product formula:
x × y = k
Where x is the amount of Token A, y is the amount of Token B, and k is a constant. When someone buys Token A, they add Token B to the pool and remove Token A. The formula ensures that k stays constant, which automatically adjusts the price.
Example:
- Pool has 10 ETH and 30,000 USDC (k = 300,000).
- Price of 1 ETH = 3,000 USDC.
- Someone buys 1 ETH by adding USDC.
- Pool now has 9 ETH and ~33,333 USDC (k still ≈ 300,000).
- New price of 1 ETH = ~3,704 USDC — the price moved up because demand increased.
Becoming a Liquidity Provider
Anyone can earn trading fees by depositing tokens into a liquidity pool:
- Choose a pool: Select a token pair (e.g., ETH/USDC).
- Deposit equal value: You must deposit both tokens in equal USD value.
- Receive LP tokens: These represent your share of the pool.
- Earn fees: Every trade in the pool pays a fee (typically 0.3%), distributed proportionally to LPs.
- Withdraw anytime: Burn your LP tokens to get your share back (plus earned fees).
However, providing liquidity comes with risks — most notably impermanent loss, which we'll cover in the DEX safety lesson.
Key Takeaways
- •AMMs use liquidity pools and mathematical formulas instead of order books
- •The constant product formula (x × y = k) automatically adjusts prices based on supply and demand
- •Anyone can become a liquidity provider and earn trading fees
- •LPs must deposit equal value of both tokens in a pair
Quick Quiz
Question 1 of 3
0 correct so far
What is the constant product formula used by Uniswap?