Decentralized Finance (DeFi): AMMs, DEXs, and Liquidity Pools

DeFi replaces intermediaries with smart contracts. The central innovation is a different way to make markets.

The constant product AMM

xy=kx \cdot y = k

A pool holds two tokens. Trades must leave the product unchanged, and that constraint sets the price.

Worked example: buying 1 ETH from a pool

A pool with 10 ETH and 20,000 USDC, so k=200,000k = 200{,}000. The implied price is 2,000 USDC per ETH.

Buy 1 ETH: the pool must hold 200,000922,222\frac{200{,}000}{9} \approx 22{,}222 USDC, so you pay 2,222 USDC. Your average price is 2,222 rather than 2,000, and the difference is slippage determined entirely by trade size relative to pool depth.

No order book, no quotes, no market makers deciding anything. The formula prices everything.

Constant product AMM

USDCETH in pool

Pool at 10 ETH and 20000 USDC, so k = 200000 and the spot price is 2000. Taking 1 ETH out leaves 9, so the pool must hold 22222 USDC to keep the product fixed. Afterwards it quotes 2469: the trade moved the price by itself, with nobody deciding anything.

Pool at 200.0 ETH and 400000 USDC, so k = 80000000 and the spot price is 200000. Taking 140.00 ETH out leaves 140.00, so the pool must hold 80000000 USDC to keep the product fixed. Afterwards it quotes 200000: the trade moved the price by itself, with nobody deciding anything.

1.0
10
20000

x · y = k. Hold the trade size still and deepen the pool: the slippage falls away, and nothing else changes.

You pay
2222 USDC
Average price
2222
Slippage
11.11%

Buying 1 ETH from a 10 ETH pool costs 2,222 rather than 2,000. All of it is mechanism.

Hold the trade size still and deepen the pool: the slippage falls away and nothing else changes. That is the whole of the claim above, that the cost of a trade here is set by size against depth and by nothing else at all.

Key takeaway

An AMM is a market maker with a fixed, public pricing rule. It always quotes, never runs out, and never adjusts for information, which is exactly what makes it exploitable by anyone who knows more.

Liquidity providers

Anyone can deposit both tokens into the pool and earn a share of trading fees, typically 0.05% to 1% per trade.

This is passive market making, open to anyone. It is also market making without the ability to skew, widen or pull quotes, which is why it carries a specific risk.

Impermanent loss

The most important concept here, and the one most often misunderstood.

Since the pool must maintain xy=kx \cdot y = k, it automatically sells the appreciating asset and buys the depreciating one. A liquidity provider ends up with less of whatever went up than if they had simply held.

Worked example: impermanent loss when ETH doubles

Deposit 10 ETH and 20,000 USDC at 2,000 per ETH, total value 40,000.

ETH doubles to 4,000. Arbitrageurs rebalance the pool to roughly 7.07 ETH and 28,284 USDC, worth about 56,568.

Simply holding would be worth 10×4,000+20,000=60,00010 \times 4{,}000 + 20{,}000 = 60{,}000.

Shortfall: about 3,432, or 5.7%. That is impermanent loss.

It is called impermanent because it reverses if the price returns. It is permanent if you withdraw at the new price, which makes the name misleading.

Providing liquidity is profitable when fees>impermanent loss\text{Providing liquidity is profitable when fees} > \text{impermanent loss}

What this is, in familiar terms

Impermanent loss is a short volatility position. You earn fees steadily and lose when the price moves substantially in either direction, which is the payoff shape of a sold straddle.

That reframing is the useful one. Liquidity provision is not passive yield; it is selling volatility, and it should be evaluated as such: are the fees earned more than the volatility being sold?

Tip

"Is providing liquidity profitable?" is the same question as "is realised volatility below the implied volatility I am effectively selling?" Stable pairs make it easy; volatile pairs frequently do not.

Test your knowledge

On a Uniswap-style AMM, suppose the liquidity pool holds 100 units of token \( x \) and 200 units of token \( y \). Using the constant product formula \( x \cdot y = k \), how many units of token \( y \) will remain in the pool after a user swaps 10 units of token \( x \) into the pool? Round your answer to two decimal places.
A liquidity provider earns a steady stream of fees and suffers a shortfall against simply holding whenever the pair's price moves substantially, in either direction. Which traditional position has the same payoff shape?