A decentralised exchange (DEX) swaps tokens through a smart contract instead of a company. Most use an automated market maker (AMM): no order book, just a liquidity pool, a contract holding two tokens, such as USDC and ETH. Liquidity providers (LPs) deposit both tokens and earn a share of the trading fees. A pool's size is its total value locked (TVL): the dollar value of the tokens in it (more in lesson 03).
The rule: x × y = k
In words: the amount of one token times the amount of the other stays the same after every trade (fees aside). The price is the ratio: USDC held ÷ ETH held.
Taking ETH out means putting in enough USDC to keep the product at k, so each extra ETH costs more.
- Price impact: how far your own trade moves the price against you, which depends on your trade's size compared with the pool's.
- Slippage: the price changing between your quote and your trade running, because others traded first. Swap apps set a minimum output; below it, the trade fails (Uniswap docs).
What LPs earn and risk
LPs earn fees, but the pool rebalances itself: as ETH rises, traders buy ETH out of it; as ETH falls, traders sell ETH into it. Impermanent loss (IL) is how much less an LP's share is worth than simply holding the two tokens. It shrinks if the price returns, and becomes real when the LP withdraws.
In words: IL = 2 × the square root of r, divided by (1 + r), minus 1, where r is the new price ÷ the old price. It applies to a "full-range" pool such as Uniswap v2.
| ETH price move | IL against holding |
|---|---|
| −30% | −1.6% |
| −50% | −5.7% |
| +50% | −2.0% |
| ×2 | −5.7% |
| ×4 | −20.0% |
Either direction hurts; fees must beat it.