How automated market makers work
Where the price actually comes from.
Educational content only — not investment advice. Independent and not affiliated with Uniswap Labs.
Three things shape what a swap on a decentralized exchange actually costs: how your trade moves the pool's price, how much that price can drift before your transaction lands, and the network fee you pay to process it. Understanding each makes the numbers on screen far less mysterious.
When you prepare a swap on an automated market maker (AMM) like Uniswap, the interface usually shows several numbers beyond the headline exchange rate. This article walks through what those numbers mean. It is educational only, is not affiliated with Uniswap or Uniswap Labs, and is not financial, legal, or tax advice.
An AMM does not look up prices on an external market. Instead, the price comes from the ratio of reserves held in a liquidity pool. A pool holding two tokens prices them against each other based on how much of each it currently contains. You can read more about this in how AMMs set prices.
Because the price is set by that ratio, the act of swapping changes it. When you put one token into the pool and take the other out, you alter both balances, which nudges the ratio and therefore the price. This shift is called price impact. The key idea is proportion: a swap that is tiny relative to the pool's size barely moves the ratio, while a swap that is large relative to the pool moves it noticeably.
So the same trade can have very different price impact depending on the pool. In a deep pool with large reserves, your trade is a small fraction of the total and the price barely budges. In a shallow pool, the same trade represents a bigger share of the reserves and the price moves more.
For illustration only. Imagine a pool that, for this example, prices Token A at about 100 units of Token B. A small trade buying a handful of Token A might execute very close to that 100 figure, with price impact well under a fraction of a percent. A large trade buying a sizable share of the pool's Token A might push the effective price toward, say, 108 units of Token B by the time the swap completes, a noticeably larger price impact. These numbers are invented purely to show the pattern: bigger trade relative to pool size means bigger price impact. They are not real prices.
Slippage is the difference between the price you expected when you reviewed the swap and the price at which it actually executes. Markets move between the moment you submit a transaction and the moment it is processed, so the final price can differ from the quote.
To manage this, AMM interfaces offer a slippage tolerance setting. It defines how far the executed price may move against your quote before the transaction is automatically canceled. If the price stays within your tolerance, the swap proceeds; if the market moves beyond it, the transaction can fail rather than fill at an unexpected price. Some pool designs may also result in a swap being partially filled. A wider tolerance reduces the chance of a failed transaction but allows a larger gap between quoted and executed price; a narrower tolerance does the reverse.
On Ethereum, every transaction requires gas, a unit that measures the computational work needed to process it. A swap involves more steps than a simple transfer, so it generally uses more gas. You pay for that gas in the network's native currency, and the total fee depends on both the amount of work and the current price per unit of gas.
That price per unit is driven by demand. When many people are transacting at once, the cost to have a transaction included rises; when the network is quieter, it tends to fall. This is why the same swap can cost very different amounts at different times. Layer-2 networks are separate networks that process transactions and settle back to Ethereum; they generally have lower fees than the main Ethereum network because of how they batch and handle that work. Gas fees are paid to process the transaction and are not refunded if a transaction fails.
You may encounter the term MEV (maximal extractable value), sometimes discussed alongside front-running. Because pending transactions are publicly visible before they are confirmed, the order in which transactions are processed can be rearranged in ways that affect prices. This is a known phenomenon in public blockchains, described here purely for awareness. Slippage tolerance relates to this topic because a tighter tolerance limits how far your executed price can stray from your quote. This is informational only and not a strategy or instruction.
A few plain points of awareness round things out. Blockchain transactions are irreversible once confirmed, so it is worth double-checking the token, network, and amounts before submitting. Network fees are non-refundable, including when a transaction fails. And the values shown are estimates that can change as the network and pool state change. For more context on what can go wrong, see DeFi risks.
Background helps: see how AMMs set prices and the glossary.
Disclaimer: This article is educational content only. It is not investment, financial, legal, or tax advice, and not a recommendation to buy, sell, or trade any asset. Crypto involves significant risk, including total loss of funds.