Mcap -- BTC -- ETH -- SOL -- BNB -- XRP -- F&G -- View Market
Loading prices…

Automated Market Maker

AMM

A decentralised exchange design that replaces order books with algorithmic liquidity pools. When you swap on Uniswap, you are trading against an AMM.

DeFi 3 min read

Before Uniswap existed, decentralised exchanges tried to copy centralised exchanges. They had order books, they had bids and asks, they had makers and takers, and they did not really work. Every order and cancellation was a separate on-chain transaction. Ethereum was too slow and too expensive to run that kind of infrastructure, and the early DEXes (EtherDelta, IDEX, 0x) all struggled with thin books and bad UX.

Hayden Adams shipped Uniswap V1 in November 2018 with a completely different idea. Instead of matching orders, a swap would trade against a pool of two tokens, and the price would be set by a formula that kept the product of the two reserves constant. x Γ— y = k. That was the whole thing. It was a single smart contract per pair. Anyone could add liquidity. Anyone could trade. There was no order book and no market maker. It worked.

The design is now called a constant product AMM, and for better or worse, it turned out to be the right abstraction for on-chain trading. Every major DEX built since β€” Curve, Balancer, PancakeSwap, SushiSwap, Uniswap V2 and V3 β€” is some variation on the theme. Curve flattens the curve for assets that should trade near 1:1 (stablecoin pairs). Balancer generalises the formula to pools with more than two tokens and arbitrary weights. Uniswap V3 lets liquidity providers concentrate capital in a specific price range instead of spreading it across all prices. They are all AMMs.

What the Math Actually Does

The constant product rule is a way of ensuring a pool can never be drained. If there are 100 ETH and 300,000 USDC in a pool, then k is 30,000,000. If someone takes out 10 ETH, there must now be enough USDC in the pool to keep k equal to 30,000,000 given the new ETH balance. That works out to about 333,333 USDC β€” meaning the trader had to put in 33,333 USDC for 10 ETH, an effective price of 3,333 per ETH, which is higher than the 3,000 the pool started at. The price moved against the trader because the trade was large relative to the pool.

That price movement is slippage, and it is the main cost of trading on an AMM. Small trades against deep pools have minimal slippage. Large trades against shallow pools can cost several percent, which is why aggregators like 1inch and Jupiter split large orders across multiple pools to minimise total price impact.

Why This Is the Backbone of DeFi

Three properties. AMMs are permissionless β€” anyone can list a token by creating a pool, no listing fee and no committee. They are composable β€” other contracts can call them in the same transaction, which is how flash loans and atomic multi-hop swaps work. And they never go offline, because there is no operator to take them down.

Those properties are what made DeFi a thing. An order book DEX is just a worse centralised exchange. An AMM is a new kind of object that could not exist before smart contracts did.