You’re at the market and want to buy some apples. In the middle of the market, there’s a big book that people can record things in. People that want to buy apples write down how many they want and at what price they’re willing to buy, and people that want to sell apples do the same in reverse. A trade happens when a buyer and seller agree on a price and quantity.
This is the standard central limit order book (CLOB) system that most stock brokerages use. In big markets dealing with popular assets like apples, there are usually also businesses built around constantly filling both sides of the book to keep the market liquid. These businesses require significant capital, and generally only focus on the largest markets.
So what happens if you actually want to buy oranges, and there isn’t a company willing to be a market maker that fills both sides of an order book? The issue isn’t a lack of buyers or sellers, or that the price isn’t determinable, it’s that trading gets tricky when there aren’t many offers on either side. An orange might truly be worth $2, but if the buy side only has an order for $1 and the sell side only has an order for $3, anyone that wants to buy or sell an orange is going to have to be out a dollar.
One way to solve this is by creating a marketplace that doesn’t need an order book, and instead lets trade happen at any time by setting pricing according to an algorithm.
Imagine in this same market, the book in the middle gets replaced with a magic scale. The scale has a spell on it such that the two sides must always be balanced, and that the number of objects must always multiply to a fixed number set when the scale was calibrated. Taking the same example of oranges, let’s say the scale gets set up when oranges are $2. Someone puts 5 oranges on one side, and 10 dollar bills on the other. People can buy and sell oranges at any time, as long as the number of oranges times the number of dollar bills is equal to 50, the scale stays balanced. When you generalize the concept, you can use a formula like x * y = k, where x and y are the units of each asset and k is a constant value.
Going back to our oranges, if I want to buy 3 oranges, I take 3 from that side, leaving 2. To know how much those oranges are going to cost, we can do the math of 50 (the constant target) divided by 2 (the number of oranges left). This means that there would need to be 25 dollar bills on the other side to keep things equal. There are already 10 dollars there, so I would need to pay 15 to rebalance the scale. You might notice that the price of the oranges here isn’t 2 dollars, but rather 5. This difference is called price impact. It happens when you try to make a large trade compared to the amount of liquidity available. Since there are only 5 oranges, buying 3 is taking up more than half the supply, which naturally moves the price much higher.
On the flip side of that, let’s say I want to sell 5 oranges instead. We start with the 5 on the scale, add 5 more to get 10, and then divide 50 by that to get 5. Since there are 10 dollars on the other side of the scale, I need to take 5 to get back to a balance. The same principle of price impact applies here, just in the other direction.
The effect of price impact is reduced when there are more people willing to add both oranges and dollars to each side of the scale. If the scale had 5000 oranges on it, removing 3 wouldn’t require much change on the other side. The people who add both oranges and dollars to the scale are called liquidity providers, and the assets they provide are collectively called a liquidity pool. When you make a trade through this pool, you pay a small fee, just like you would on a brokerage platform. In this case, the fee is split proportionally between the liquidity providers. This fee gives liquidity providers a way to earn money for keeping the system running smoothly.
In both of these directions, people can continue to buy and sell oranges to an infinite amount. So, while traditional markets need buyers and sellers to line up their prices, an AMM system lets anyone trade anytime.