Module 6 · Ethereum & Shared Applications / 6.8
A market made of two reserves.
How an automated market maker turns an exchange into a rule.
A market stall keeps two jars: one holds token A, the other token B. You can add B and take out A, but the amount you receive follows a rule.
No seller needs to answer your request at that moment. The inventory is already there. This is the starting idea behind an automated market maker, or AMM.
The inventory is waiting.
An order-book exchange matches buy and sell orders. An AMM commonly lets a trader exchange against a liquidity pool: assets deposited into a contract by liquidity providers.
The contract calculates an exchange using its pricing rule and available inventory. The trader still depends on the tokens, contract, network, and any special controls. Removing a traditional matching desk does not remove all intermediaries or risk.
One influential rule is the constant product: the amount of A multiplied by the amount of B stays constant during an idealized swap. Call the reserves x and y. The rule is x × y = k.
Start with 100 A and 100 B. Their product is 10,000. If you add 10 B, the pool has 110 B. To keep the product at 10,000, it must finish with about 90.91 A. You receive about 9.09 A.
Fee-free constant product, no intervening trades. Actual swaps include fees and rounding.
This model ignores fees and assumes ordinary tokens, no other trades, and immediate execution. Real contracts add fees and rounding, so the exact quote must come from the actual pool.
A larger purchase moves the price.
As A leaves the pool, it becomes scarcer relative to B. The rule makes each additional unit of A more expensive in B. The pool does not offer unlimited inventory at its opening price.
The 10 B purchase averaged about 1.10 B per A, even though the initial marginal price was 1 B per A. The pool’s marginal price after that trade is about 1.21 B per A. An average execution price and the price of the next tiny trade are different numbers.
This change caused by your own trade is price impact. Slippage describes a difference between an expected execution and what actually occurs, for example because another transaction changes the pool first. Interfaces sometimes combine the terms, so inspect what the displayed minimum received actually protects.
A slippage limit can make an unfavorable swap fail. It does not eliminate price impact, transaction fees, malicious tokens, or every ordering attack.
Other markets pull on the jars.
Suppose A becomes more valuable elsewhere. Traders can buy it from a pool that still offers a cheaper price and sell it in the other market. This is arbitrage.
Their trades remove A and add B, moving the pool’s price toward the outside price. Costs and risks limit how closely prices line up. The contract does not need to understand the news for its inventory to respond.
This explains a surprising feature: liquidity providers can end up with less of the asset whose price rose and more of the other asset. Fees compensate them for a service, but do not guarantee they come out ahead.
The innovation is a reusable exchange mechanism that other contracts can call, with participation rules defined in code. Different designs solve different inventory problems. We will compare those designs before examining the provider’s risk.
The pool and outside market both begin at 1 B per A.
The idea to keep
An AMM is not a price oracle or free money machine. It is a rule for exchanging against inventory, with consequences for both the trader and the people supplying it.