If you have ever swapped one cryptocurrency for another on a platform like Uniswap or Curve, you have used an automated market maker — probably without realizing it. AMMs are one of the foundational pieces of decentralized finance, and understanding how they work helps explain why decentralized exchanges (DEXs) function so differently from the platforms most people grew up with.
**The Problem AMMs Were Built to Solve**
Traditional exchanges — think stock markets or centralized crypto platforms — use an order book. Buyers post the price they are willing to pay; sellers post the price they are willing to accept. When the two sides agree, a trade happens. This works well when there is a large, active pool of participants constantly updating their offers.
On a decentralized blockchain, order books become awkward. Every update to an order book would need to be recorded on-chain, which costs transaction fees and is slow. More importantly, early DEXs simply did not have enough users to keep order books liquid. If nobody is posting sell orders for a token you want, you cannot buy it — no matter how much you are willing to pay.
AMMs solve this by removing human counterparties from the equation entirely.
**How an AMM Actually Works**
Instead of matching buyers with sellers, an AMM holds reserves of two (or more) tokens in a smart contract called a liquidity pool. Anyone who wants to trade deposits one token and receives the other directly from that pool. The price is not set by humans — it is calculated automatically by a mathematical formula based on the ratio of tokens in the pool.
The most common formula is deceptively simple: x × y = k. Here, x and y represent the quantities of each token in the pool, and k is a constant. If you buy some of token Y by depositing token X, the quantity of Y in the pool drops and the quantity of X rises. The formula ensures k stays the same, which means the price adjusts automatically. The more of a token you try to buy, the more expensive each additional unit becomes — a built-in mechanism that prevents any single trade from draining the pool completely.
Ethereum-based Uniswap popularized this constant-product formula starting in 2018, and it remains the backbone of most AMMs today.
**Liquidity Providers: The Other Side of the Trade**
If there are no human sellers, where does the liquidity come from? From liquidity providers (LPs) — anyone who deposits an equal value of two tokens into a pool. In return, they receive LP tokens representing their share of the pool. Every time a trade is made, the protocol charges a small fee (often 0.3%), which is distributed proportionally to LPs. This fee income is what incentivizes people to supply liquidity in the first place.
This mechanic is elegant but comes with a trade-off called impermanent loss. If the price of one token in a pool shifts significantly relative to the other, LPs can end up with less value than if they had simply held their tokens without providing liquidity. The loss is called "impermanent" because it only locks in if the LP withdraws at that moment — if prices revert, the loss disappears. In volatile markets, however, impermanent loss is a real risk that every liquidity provider needs to understand.
**Variations on the Formula**
The constant-product model is not the only approach. Different AMM designs optimize for different situations.
Curve Finance, for example, uses a hybrid formula specifically tuned for assets that should stay close to the same price — like two stablecoins both pegged to the US dollar. Its formula allows for much lower slippage (the difference between the expected and actual price of a trade) when the assets are near parity, making it more efficient for stable-to-stable swaps.
Balancer extended the model further, allowing pools with more than two tokens and with weighted ratios rather than a strict 50/50 split. This lets a pool hold, say, 80% Bitcoin and 20% Solana and still function as an automated market maker.
Concentrated liquidity, introduced by Uniswap v3, lets LPs choose specific price ranges within which their capital is active. This can generate more fee income per dollar deposited, but it requires more active management.
**Why DEXs Prefer AMMs**
From the perspective of a decentralized exchange, AMMs offer several advantages. There is no need to recruit professional market makers to keep order books populated. Anyone with tokens can become a liquidity provider. Trades settle directly on-chain with no intermediary holding custody of funds. And the pricing mechanism is transparent — the smart contract code is publicly readable, so anyone can verify exactly how a price is calculated.
This composability also matters. Because liquidity pools are smart contracts, other protocols can build on top of them. Yield aggregators, lending platforms, and arbitrage bots all interact with AMM pools programmatically, creating a dense web of interconnected DeFi activity.
**A Trade-Off Worth Knowing**
AMMs are not perfect. Slippage on large trades can be significant, especially in shallow pools. The constant-presence of arbitrage traders — who profit by rebalancing pools when prices drift — is a major source of impermanent loss for LPs. And complex multi-hop routes (trading token A for token B, then token B for token C) can accumulate fees quickly.
Still, the AMM model addressed a real problem and opened decentralized trading to a far wider audience than order-book DEXs ever managed. Understanding the mechanics — the pools, the formula, the LP incentives — gives you a clearer picture of how a significant portion of on-chain activity actually happens.