Glossary
Automated market maker (AMM)
A smart contract that sets the price of a token swap by formula, using pooled tokens in place of an order book and human market makers.
An automated market maker (AMM) is the pricing engine of most decentralized exchanges. On a stock exchange, a market maker quotes prices at which it will buy and sell. An AMM replaces that with a formula applied to a liquidity pool.
The constant product formula
The best-known design, used by Uniswap since its launch in 2018, keeps the product of the two token balances constant.
Here x and y are the amounts of each token in the pool. A trader who takes out one token must add enough of the other to keep k unchanged, before fees.
What follows from the formula
- Price impact grows with trade size relative to the pool. This is the AMM form of slippage.
- The pool never runs out, because the price rises without limit as a token becomes scarce.
- Arbitrage sets the price. The pool does not know the price elsewhere. Traders profit by correcting any gap, and that profit comes from the liquidity providers. This is the source of impermanent loss.
Variations
Later designs let providers concentrate their funds in a chosen price range, or use other formulas for tokens that should trade near one to one, such as two dollar stablecoins.
Limits
Large trades are costly in small pools. Pending swaps are visible before they execute, so others can trade ahead of them. Code flaws have led to losses.
