The thing that confused me for a long time about decentralized exchanges is that there is nobody on the other side of your trade. On a normal exchange there is an order book, a stack of bids and asks that some market maker is maintaining, and your buy matches against someone's sell. On most DEXs there is none of that. You are trading against a pool of two tokens and a formula. Once that clicked, everything about slippage and price impact stopped feeling like magic and started feeling like arithmetic you could do yourself. So let me walk through the arithmetic, because it is genuinely simple, and I think most people who trade on these venues never see it laid out.
The pool and the formula
An automated market maker pool holds two assets. Say a pool of ETH and USDC. The pool does not look up a price anywhere. It sets its own price entirely from how much of each token it currently holds, using one rule: the product of the two balances has to stay constant. That is the constant product formula, usually written as x times y equals k. The x is one token's balance, the y is the other, and k is a number that has to stay the same after any trade.
Let me put numbers on it so it is concrete. Imagine a pool with 10 ETH and 20,000 USDC. Multiply them and k is 200,000. The price the pool quotes for ETH is just the ratio of the two balances, so 20,000 divided by 10, which is 2,000 USDC per ETH. Nobody set that price. It falls out of the balances. If the pool held 10 ETH and 30,000 USDC instead, ETH would quote at 3,000. The ratio is the price, always.
What happens when you swap
Now suppose you want to buy 1 ETH from this pool. Here is where people expect to pay the quoted 2,000 and are surprised when they do not. The pool will not simply hand you 1 ETH at the old ratio, because the balances have to keep their product equal to k after the trade.
Work it through. You are taking 1 ETH out, so the pool drops from 10 ETH to 9 ETH. For k to stay at 200,000, the USDC balance has to rise to 200,000 divided by 9, which is about 22,222 USDC. The pool started with 20,000 USDC, so you have to put in the difference, roughly 2,222 USDC, to buy that single ETH. Not 2,000. The effective price you paid was about 2,222 per ETH, even though the pool was quoting 2,000 a second ago.
That gap is price impact, and it is not a fee or a trick. It is the whole mechanism. You moved the pool's ratio by trading against it, and the new ratio is a higher price. After your trade the pool holds 9 ETH and 22,222 USDC, so it now quotes ETH at about 2,469. Your one purchase nudged the pool's price up by more than twenty percent, which tells you this is a small pool.
Why big trades hurt and deep pools do not
The reason your trade moved the price so much is that the pool was tiny relative to your order. You pulled a tenth of the ETH out in one go. Run the same 1 ETH buy against a pool holding 1,000 ETH and 2,000,000 USDC and the picture changes completely. Same 2,000 starting price, but taking 1 ETH from 1,000 barely dents the ratio. You would pay something like 2,002 instead of 2,000. The price impact shrinks to almost nothing because your trade is small relative to the pool.
This is the single most useful intuition to carry around:
- Price impact scales with how big your trade is compared to the pool, not with the dollar size of your trade on its own.
- A 5,000 dollar swap can be painless in a deep pool and brutal in a shallow one. The number that matters is your size divided by the pool's size.
- The curve is not linear. The deeper you push into a pool, the worse each additional unit gets, because you are always dividing k by a smaller and smaller remaining balance.
The practical version of this is a habit worth building. Before you confirm a swap, look at the price impact the interface is showing you and look at the pool's total liquidity. If the impact is more than a fraction of a percent on a trade you think of as normal-sized, the pool is thin and you should either split the order into pieces, route through a different pool, or just accept that you are paying for the privilege of being the one who moved the market.
Arbitrage is what keeps the number honest
Here is the question that should be bothering you by now. If the pool sets its own price purely from its balances, and it just quoted me 2,469 after I bought, what stops it from drifting completely away from what ETH actually trades for everywhere else? The answer is arbitrage, and it is the quiet force that makes the whole system usable.
Go back to the small pool after my trade. It now thinks ETH is worth about 2,469, but every other venue still says 2,000. That is free money for anyone paying attention. An arbitrageur sells ETH into this pool, which pushes its ETH balance back up and its price back down, and they pocket the difference against the real market price. They keep doing it until the pool's quoted price lines up with everyone else's, because past that point there is no profit left. The pool did not correct itself out of good manners. Someone corrected it because the mispricing was money sitting on the table.
So an AMM does not discover the price of ETH on its own in any deep sense. It offers a price based on its balances, and arbitrageurs continuously drag that price toward the broader market by trading against any gap. The formula sets the mechanics. Arbitrage supplies the anchor to reality.
What to actually take from this
When you hit swap on a DEX, you are not matching an order. You are handing tokens to a pool and taking the other side out, and the ratio between what is left is your price. Bigger trades move that ratio more, thin pools move more than deep pools, and the price you get is the average across the whole move you caused, not the number you saw before you clicked. The slippage tolerance you set is your guardrail for how far that ratio is allowed to shift, including from other people's trades landing between your click and your transaction confirming.
None of this requires trusting the interface's summary. You can compute the pool's quoted price yourself from its two balances, and you can sanity check the impact of your own order with the same x times y equals k arithmetic I used above. When I am sizing anything meaningful, I would rather look at the pool depth directly than trust a single slippage number, and pulling those balances is something we lean on at Blockcircle when routing across venues. The math is basic. The mistake people make is not doing it at all, then wondering why the fill came back worse than the screen promised.