When most people imagine trading, they picture a marketplace with buyers and sellers posting offers and someone in the middle matching them up. Traditional stock exchanges and centralized crypto exchanges work more or less this way. But a large and growing slice of crypto trading happens on decentralized exchanges, or DEXs, where there is no matching engine, no order book, and no company facilitating trades. Instead, trades are executed against pools of funds governed by a simple mathematical formula. That mechanism is called an automated market maker, or AMM.
**The Problem AMMs Were Built to Solve**
Running an order book on a blockchain is genuinely difficult. Every update to an order book — every new bid, every cancellation — would need to be recorded as a transaction, which costs fees and takes time. On a busy exchange, that would be both slow and expensive. Early attempts to build decentralized order books struggled with this reality.
AMMs sidestep the problem entirely. Instead of matching a buyer with a specific seller, they let anyone trade against a shared pool of two tokens. The price is set not by human bids but by a formula that responds to changes in the pool's composition.
**How the Math Works**
The most widely used AMM formula is elegantly simple. It states that the product of the two token quantities in a pool must remain constant. If a pool holds Token A and Token B, then the amount of A multiplied by the amount of B always equals the same number, often written as x × y = k.
When a trader swaps Token A for Token B, they add A to the pool and remove B. Because the product must stay constant, removing B forces its price — relative to A — to rise. The more B you try to take out in a single trade, the higher the price climbs. This is called price impact or slippage, and it naturally discourages any single trade from draining a pool.
This formula was popularized by Uniswap, the Ethereum-based DEX that launched in 2018 and remains one of the most-used decentralized protocols. Many other AMM-based DEXs followed, each iterating on the core idea in different ways.
**Liquidity Providers: The Other Half of the System**
For an AMM to work, someone has to supply the tokens that traders swap against. These are called liquidity providers, or LPs. Anyone can become an LP by depositing an equal value of two tokens into a pool. In return, they receive LP tokens representing their share of the pool, and they earn a cut of every trading fee generated by that pool.
It sounds straightforward, but there is a meaningful risk LPs need to understand: impermanent loss. Because the AMM automatically rebalances the pool as prices shift, an LP can end up holding a different ratio of tokens than they originally deposited — one that may be worth less than if they had simply held the tokens in a wallet. The loss is called "impermanent" because it only locks in when the LP withdraws; if prices return to their original levels, the loss disappears. In practice, sharp or sustained price moves can make impermanent loss a real cost.
**Variations on the Formula**
Not all AMMs use the constant product formula. Different designs suit different assets.
Stablecoin pools, for example, benefit from a formula that keeps prices very close to a fixed ratio rather than letting them drift widely. Curve Finance pioneered this approach, using a hybrid formula that behaves like a constant product near the edges but holds prices tightly in the middle range where most stablecoin trading happens. This results in far less slippage for trades between assets that are supposed to hold the same value.
Concentrated liquidity, introduced by Uniswap v3, lets LPs specify a price range in which they want to provide liquidity rather than spreading funds across all possible prices. This makes LP capital more efficient — it earns more fees per dollar deposited when the market price stays within the chosen range — but it also introduces more active management and a higher risk of the price moving outside the range entirely.
**Where AMMs Live**
AMMs have spread well beyond Ethereum. Solana, BNB Chain, and numerous other blockchains host their own DEXs built on AMM architecture. Raydium and Orca operate on Solana; PancakeSwap is among the largest on BNB Chain. Cross-chain bridges and aggregators now route trades across multiple AMMs simultaneously to find the best price.
**What AMMs Mean for Users**
For ordinary traders, the practical upshot is that you can swap tokens at any hour without creating an account, without a company holding your funds, and without waiting for a counterparty to accept your order. Your wallet connects to the protocol directly, the smart contract executes the trade, and your tokens arrive in seconds or minutes depending on the chain.
The tradeoffs are real, though. Slippage on large trades can be significant in shallow pools. Smart contract bugs have led to serious losses across DeFi's history. And the user experience — managing wallets, gas fees, and approvals — remains more complex than a centralized app.
**The Bigger Picture**
AMMs represent one of the more genuinely novel ideas to emerge from decentralized finance. By replacing human market makers with a formula embedded in code, they allow open, permissionless trading to exist at scale. The design is not without flaws, and it continues to evolve, but understanding the constant product formula and liquidity pools is foundational to understanding how a significant portion of crypto trading actually works today.