How Crypto Actually Trades

AMMs, Liquidity & Slippage

The constant-product formula is simple math with non-obvious consequences, and understanding it tells you exactly where your money leaks when you trade on-chain.

Most DEX volume runs through automated market makers. There is no order book, no counterparty placing a limit order. Instead, a pool of two assets rebalances mechanically according to a formula. The elegance of the design also produces several ways to lose money that are worth understanding precisely.

x times y equals k

The Uniswap v2 constant product formula is x * y = k. If a pool holds 100 ETH and 200,000 USDC, k = 20,000,000. If you buy 10 ETH, the pool must still satisfy k after the trade. The new ETH reserve is 90. Solve: 90 * y = 20,000,000, so y = 222,222 USDC. You paid 22,222 USDC for 10 ETH. The implied price was 2,000 before; you paid 2,222 per ETH. That difference is price impact.

x * y = k

the constant product invariant; trade size relative to pool depth determines price impact, not a flat fee schedule

Price impact and slippage

Price impact is the change in pool price caused by your trade. Slippage is the difference between the expected price when you submit and the actual execution price. Slippage tolerance in a DEX interface is a cap: if the price moves more than X percent by the time the transaction confirms, it reverts. Setting tolerance too low causes frequent reverts on volatile pairs. Setting it too high is how MEV bots (sandwich attacks) extract value from you.

  1. You submit swapexpected price at submission
  2. Bot sees pending txfront-runs with buy order in same block
  3. Your tx executesat worse price; within your tolerance
  4. Bot sells immediatelyextracts the difference
A 1% slippage tolerance on a low-liquidity token is not conservative. It is an invitation. On a thin pool, 1% of price movement covers significant extraction. Keep slippage tight and use private RPC endpoints or MEV protection relays for large swaps.

Impermanent loss explained without euphemism

If you provide liquidity to a pool, you deposit both assets in the current ratio. As price moves, the pool rebalances, and your holdings drift toward the asset that is declining in relative value. When you withdraw, you receive a ratio that reflects the new price. Impermanent loss is the difference between what you received and what you would have held if you had done nothing. It is not a fee or a penalty; it is the opportunity cost of providing liquidity versus simply holding.

It becomes realized the moment you withdraw after a price divergence. If the price returns to the original level before you exit, impermanent loss is zero. The name is misleading: the loss is only "impermanent" in the sense that it could reverse if prices reconverge, which is not guaranteed. Trading fees earned by the pool offset it partly. Whether they offset it fully depends on fee tier, volume, and volatility.

Concentrated liquidity (Uniswap v3) amplifies both fee earnings and impermanent loss within the specified range. If price exits your range, you hold 100% of the underperforming asset with no fee income. It requires active management or you are better off in a full-range position.

Key takeaways

1The constant product formula x*y=k means price impact scales with your trade size relative to pool depth, not a flat fee.
2Price impact and slippage are distinct: impact is what your trade does to the pool, slippage is the execution variance you accept.
3High slippage tolerance on illiquid pairs is a direct input to sandwich attack profitability.
4Impermanent loss is the opportunity cost versus holding the two assets, it is realized at withdrawal and fees may or may not offset it.
5Concentrated liquidity amplifies fee earnings and impermanent loss simultaneously, and requires active range management.

Educational content only, not financial advice. Trading and investing carry real risk of loss, including your entire capital. Do your own research and consult a licensed professional before making financial decisions.

This is one lesson of 541.

The whole Foundation is free — 16 subjects, beginner to advanced. Sign in to track what you have read, take the end-of-module quizzes, and use the terminal.