When you swap tokens on a decentralized exchange, there’s no company matching your trade with another person. Instead, you’re trading against a pool of tokens governed by a formula. That pool — and the formula — is called an automated market maker, or AMM, and it powers most of crypto’s trading.
This guide explains how AMMs work, where the price comes from, and what the x·y=k formula everyone mentions actually means.
id=”how-amms-work”>How AMMs Work
An AMM is a smart contract holding reserves of two (or more) tokens — say ETH and USDC. Anyone can trade against it: you deposit one token, the contract calculates how much of the other you get, and it updates the reserves. No order book, no counterparty, no waiting — the pool is always ready to trade, 24/7.
The price you get is set purely by the ratio of the two reserves. If lots of people buy ETH from the pool, ETH becomes scarcer in the pool and its price rises automatically. Arbitrage traders then step in to align the pool’s price with the wider market, keeping it honest.
The x·y=k Formula, Simply
The classic AMM rule is x·y=k: the product of the two token quantities must stay constant. If a pool holds 10 ETH and 20,000 USDC, the product is 200,000. Buy 1 ETH and the pool must rebalance so the product stays 200,000 — meaning you pay slightly more than the “headline” price, with the premium growing for larger trades.
That premium is called price impact: bigger trades move the price more. It’s why small swaps on big pools feel free and large swaps on small pools feel expensive. This math also explains why bots target your swaps — your trade predictably moves the price, and bots exploit that.
Who Provides the Liquidity?
Anyone can deposit both tokens into a pool and become a liquidity provider (LP), earning a share of the trading fees. It sounds like free money, but LPs take on impermanent loss: if the tokens’ prices diverge, the LP ends up with less value than if they’d just held the tokens.
Newer AMM designs concentrate liquidity in price ranges or use different formulas for stablecoin pairs, improving efficiency. But the core idea is unchanged: pools of user-supplied tokens, priced by math, available to anyone at any time.

The Bottom Line
AMMs replace traditional exchanges with pools of tokens priced by a simple formula — no middleman, always open. They’re elegant, but mind the price impact on your trades and the impermanent loss if you provide liquidity.
This guide is for education only — not financial advice.
