Crypto · DeFi and staking
Decentralized exchanges and liquidity pools: how AMMs price trades
How a liquidity pool sets a price with x × y = k, what a trade really costs, and what impermanent loss did to an ether pool position from 2024 to 2026.
On this page
A decentralized exchange, or DEX, lets people swap one crypto token for another without handing their tokens to a company first. Most of them do not match buyers with sellers at all. Instead, traders swap against a liquidity pool: a smart contract holding a pile of two tokens, which quotes a price from a formula. The formula, and the people who fund the pool, replace the order book and the market maker of a stock exchange.
That design has two consequences every user meets. A trader pays more than the quoted price, and the bigger the trade against the pool, the more they pay. And the people who supply the tokens, called liquidity providers, can end up with less than if they had left the tokens in a wallet, even after collecting fees.
This lesson works through the arithmetic of the simplest and most copied design, the constant product pool, with an invented pool first and then two years of real ether prices.
What a liquidity pool is
On a stock exchange or a centralized crypto exchange, prices come from an order book: a list of offers to buy and sell at stated prices. That needs a steady stream of orders being placed and cancelled, which is cheap on a company's servers and expensive on a blockchain, where every change costs gas.
A liquidity pool avoids the problem. It is a smart contract that holds reserves of two tokens, say ether (ETH) and a dollar stablecoin such as USDC. Anyone can trade against it at any time. The contract works out the price from the size of its own reserves, using a fixed rule. A design of this kind is called an automated market maker, or AMM.
The reserves come from liquidity providers (LPs): people who deposit both tokens, in equal dollar value, and receive in return a claim on a share of the pool. Each trade pays a fee that is added to the pool, so the LPs' share grows with trading volume. In the second version of Uniswap, the design this lesson uses, every pool charges 0.30% of the amount paid in. Since December 2025 Uniswap's documentation shows that fee split, 0.25% to liquidity providers and 0.05% to the protocol. The examples below keep the whole fee in the pool, as the original design did; the trader's cost is the same either way.
A DEX is therefore not a company's venue with rules, staff and a help desk. It is a set of contracts on a chain such as Ethereum. You connect a wallet, sign a transaction and the swap either happens in full or does not happen. Your tokens are never in the exchange's custody, which removes the risk that sank several centralized exchanges, and replaces it with others described below.
The constant product rule
Take an invented pool holding 1,000 ETH and 2,000,000 USDC. The quoted price of one ETH is 2,000,000 ÷ 1,000 = $2,000, and k is 1,000 × 2,000,000 = 2,000,000,000.
Now a trader wants to buy ETH with 20,000 USDC.
- The pool takes its 0.30% fee from what is paid in: 20,000 × 0.003 = $60. The remaining 19,940 USDC counts toward the swap.
- The USDC reserve rises to 2,019,940. For the product to stay at 2,000,000,000, the ETH reserve must fall to 2,000,000,000 ÷ 2,019,940 = 990.128.
- The trader receives the difference: 1,000 − 990.128 = 9.8716 ETH.
The trader paid 20,000 ÷ 9.8716 = $2,026.02 for each ETH, 1.30% above the $2,000 the pool quoted a moment earlier. Of that, 0.30% is the fee. The other 1.0% is price impact: the trade itself pushed the price up as it took ETH out of the pool. After the trade the pool holds 990.128 ETH and 2,020,000 USDC (the fee stays in), and quotes $2,040.14.
The same $20,000 at the quoted price would have bought 10 ETH. The pool gave 9.8716.
Bigger trades cost more
| USDC paid | Share of the pool's USDC | ETH received | Price paid per ETH | Above the quoted $2,000 |
|---|---|---|---|---|
| $2,000 | 0.1% | 0.9960 | $2,008.02 | 0.40% |
| $20,000 | 1% | 9.8716 | $2,026.02 | 1.30% |
| $100,000 | 5% | 47.4830 | $2,106.02 | 5.30% |
| $200,000 | 10% | 90.6611 | $2,206.02 | 10.30% |
| $400,000 | 20% | 166.2498 | $2,406.02 | 20.30% |
In this design the rule is close to exact: the cost above the quoted price is about the trade's share of the reserve, plus the fee. What matters is not the dollar size of your trade but its size against the pool. A $20,000 swap is trivial in a pool of hundreds of millions and ruinous in a pool of $100,000. This is the on-chain form of the liquidity that the bid-ask spread measures on a stock exchange.
Why the pool's price follows the market
The pool knows nothing about prices elsewhere. If ETH trades at $2,100 on large exchanges while the pool still quotes $2,000, anyone can buy the cheap ETH from the pool and sell it elsewhere, and will keep doing so until the pool's price has risen to about $2,100. These arbitrage traders keep the pool in line with the wider market. Their profit is not free money from nowhere: it comes out of the liquidity providers, which is the next subject.
Impermanent loss: the cost of providing liquidity
A liquidity provider starts with equal dollar amounts of the two tokens. As the price moves, arbitrage traders rebalance the pool for them, and always in the same direction: when ETH rises, traders take ETH out and leave dollars; when ETH falls, traders leave ETH and take dollars. The LP ends up holding less of whichever token went up and more of whichever went down.
The gap between the pool position and simply holding the original tokens is called impermanent loss. For a constant-product pool it depends on one number: the ratio r of the new price to the price at deposit.
For a $10,000 deposit ($5,000 of each token):
| Price move | Value if held | Value in the pool | Difference |
|---|---|---|---|
| ÷ 4 | $6,250 | $5,000 | −20.0% |
| ÷ 2 | $7,500 | $7,071 | −5.7% |
| × 1.25 | $11,250 | $11,180 | −0.6% |
| × 1.5 | $12,500 | $12,247 | −2.0% |
| × 2 | $15,000 | $14,142 | −5.7% |
| × 4 | $25,000 | $20,000 | −20.0% |
Three things follow. The loss is the same whether the price doubles or halves. It is small for small moves and grows quickly for large ones. And it is called impermanent only because it shrinks back to zero if the price returns to where it started. If the LP withdraws at a different price, or the price never returns, the loss is as permanent as any other.
The word "loss" also needs care. In the × 2 row the LP has $14,142, a gain of 41% on the deposit. The loss is against the $15,000 they would have had by doing nothing.
Two years of an ether pool, on real prices
Suppose someone put $10,000 into an ETH and dollar-stablecoin pool on November 18, 2024, when ether closed at $3,209.21: that is 1.558 ETH and $5,000. The figures below use ether's daily closes to November 18, 2026 and leave fee income out, so they show the cost fees must cover.
| Date | Ether | Held (half and half) | In the pool, no fees | Gap |
|---|---|---|---|---|
| August 22, 2025 (high) | $4,831.24 | $12,527 | $12,270 | −$258 (−2.1%) |
| April 8, 2025 (low) | $1,471.99 | $7,293 | $6,773 | −$521 (−7.1%) |
| November 18, 2026 (last) | $1,802.30 | $7,808 | $7,494 | −$314 (−4.0%) |
At the end the pool position held 2.079 ETH and $3,747: the pool had been buying ether all the way down. To match plain holding, the position needed $314 of fee income, 3.14% of the deposit over two years, or about 1.6% a year. Whether a real pool paid that depends on its trading volume against its size, which this page does not have data for. In a busy pool fees can exceed the gap; in a quiet one they do not come close.
The figure also shows what a pool position is not. It is not a hedge. With ether down 43.8% over the two years, both the holder and the LP lost more than a fifth of their money.
What else can go wrong
- Slippage and failed trades. The price can move between the moment you sign and the moment the transaction is included in a block. You set a slippage tolerance, the worst price you will accept. Too tight and the swap fails, and you still pay gas. Too loose and you invite the next problem.
- Sandwich trades. Pending transactions are public on many chains. A bot that sees a large swap with a loose tolerance can buy just before it, let it push the price up, and sell just after. The victim receives the worst price their tolerance allows. Ethereum's own documentation describes this under maximal extractable value (MEV).
- Fake and malicious tokens. Anyone can create a token with any name and open a pool for it. A token may share a ticker with a real one, or carry code that lets buyers in and blocks them from selling. A pool whose creators can withdraw all the liquidity can be emptied in one transaction, a rug pull.
- Token approvals. Before a swap, you approve the exchange's contract to move a token from your wallet. An unlimited approval given to a malicious or later-hacked contract lets it take that token at any time.
- Contract risk. The pool is code. A bug in the pool, or in a token it holds, can drain it. There is no deposit insurance, no SIPC and nobody to call.
- Thin pools. As the table showed, a small pool turns an ordinary trade into a large price move. The quoted price is real only for a trade that is tiny against the reserve.
- Gas. Every swap, approval, deposit and withdrawal pays the chain's transaction fee whether or not it works out. On a busy chain that can exceed the value of a small trade.
For a liquidity provider, add the price risk of both tokens. Impermanent loss measures the shortfall against holding. If one token in the pair goes to zero, arbitrage traders will have swapped nearly all of the LP's good token for the worthless one on the way down.
Later designs
Newer pools change the rule to use capital better. Uniswap's third version lets each LP supply liquidity only within a price range they choose, called concentrated liquidity. A narrow range earns more fees per dollar while the price stays inside it, and earns nothing once the price leaves, at which point the LP holds only the token that fell. The effect is larger impermanent loss for a given move: more fee income, in exchange for more of the risk described above. Pools built for two tokens that should trade at the same price, such as two dollar stablecoins, use a flatter curve so that large trades barely move the price, which works until one of the two loses its peg.
DEX pool against order-book exchange
| Liquidity pool (AMM) | Order book (centralized exchange) | |
|---|---|---|
| Who holds your tokens | You, until the swap executes | The exchange |
| Where the price comes from | A formula applied to the pool's reserves | The best bid and offer placed by traders |
| Cost of a trade | Pool fee + price impact + gas | Commission or spread + price impact |
| Who provides liquidity | Anyone who deposits both tokens | Market makers posting orders |
| Liquidity provider's main risk | Impermanent loss, contract bugs | Holding inventory that moves against them |
| Listing a new token | Anyone can open a pool | The exchange decides |
| Can a trade be reversed | No | Rarely, at the exchange's discretion |
| If something breaks | No operator to appeal to | An operator, which can also fail or freeze funds |
| Identity checks | Usually none at the contract; some front ends filter | Required at regulated exchanges |
Neither column is safer in general. A centralized exchange concentrates risk in one company that holds everyone's coins, a theme of Crypto wallets and custody: keys, seed phrases, hot and cold storage. A DEX spreads the risk across code, tokens and the user's own decisions.
How Finabase does it
Finabase shows market prices, not pool data. The crypto list and each coin's quote page, for example ETH.X or the Uniswap token UNI.X, give the price, the change over periods from a day to two years, volume and market cap. The price is a market-wide quote, not the price of any one pool, so a swap on a DEX will execute at a different price for the reasons on this page.
Finabase does not show pool reserves, fee rates, trading volume per pool or the yield of a liquidity position, and it does not connect to wallets or route swaps. The example on this page was computed from the same ether prices that draw the ETH.X chart, frozen on November 18, 2026, with the constant product formula applied to them. Owning a protocol's token, such as UNI, is also a different thing from providing liquidity on that protocol: the token's price is what the quote page shows, and it earns no trading fees by itself.
Frequently asked questions
What is the difference between a DEX and a centralized exchange?
A centralized exchange is a company that holds customers' coins and matches their orders on its own systems; a DEX is a set of smart contracts that swaps tokens directly from the user's wallet. The first asks you to trust the company. The second asks you to trust the code, the tokens in the pool and your own handling of keys and approvals.
Is impermanent loss a real loss?
It is a real shortfall against holding the two tokens, and it becomes final when you withdraw at a price different from the one you deposited at. It disappears only if the price returns to its starting point while you are still in the pool. Fee income may or may not cover it.
How do liquidity providers make money?
They earn a share of the fee charged on every trade through the pool, in proportion to their share of the reserves. Some protocols add reward tokens on top, a practice called yield farming. The return after impermanent loss can be negative even when the quoted fee yield looks high.
Why did I get fewer tokens than the price showed?
Because the quoted price holds only for a vanishingly small trade. Your swap paid the pool fee, moved the price as it executed, and may have been included in a block after other trades had already moved it. Front ends show an expected output and a minimum output; the gap between them is your slippage tolerance.
Is a swap on a DEX taxable in the United States?
Yes, under the rules as they stood in November 2026. The IRS treats digital assets as property, and lists disposing of one digital asset in exchange for another among the transactions that must be reported, whether or not there is a gain. Paying a transaction fee in a digital asset is on the same list. A swap through a pool is such an exchange, even though no dollars change hands and no broker sends a form. How depositing into and withdrawing from a pool is taxed has no specific IRS guidance that we could find, so this page does not describe it.
Summary
A decentralized exchange replaces the order book with liquidity pools, and the most common pool keeps the product of its two reserves constant. From that one rule come the price it quotes, the extra a trader pays as a trade grows against the reserve, and the shortfall a liquidity provider suffers when the price moves: 5.7% for a doubling or halving and 20% at four times. On real ether prices from November 2024 to November 2026 a pool position ended 4.0% behind simple holding before fees, while both lost heavily with ether itself. A DEX removes the risk of a custodian failing and puts contract bugs, fake tokens, approvals, sandwich trades and gas in its place, with no one able to reverse a mistake.
Check your understanding
5 questions on this lesson. Each answer comes with the reason, and nothing is scored.
A constant-product pool holds 500 ETH and 1,000,000 USDC. Ignoring fees, about how much ETH does a trader receive for 10,000 USDC?
- Exactly 5.00 ETH
- About 4.95 ETH
- About 5.05 ETH
Show the answer
B. About 4.95 ETH k = 500 × 1,000,000. After the trade the pool holds 1,010,000 USDC, so it must hold 500,000,000 ÷ 1,010,000 = 495.05 ETH. The trader gets 500 − 495.05 = 4.95 ETH, less than the 5 ETH the quoted price of $2,000 suggests, because the trade moved the price.
The same $20,000 swap is sent to two pools for the same pair, one with $4 million of reserves and one with $400,000. What differs?
- Nothing: both quote the same price
- The fee rate is ten times higher in the small pool
- The price impact is about ten times larger in the small pool
Show the answer
C. The price impact is about ten times larger in the small pool Price impact depends on the trade as a share of the reserve. $20,000 is about 1% of one side of the large pool and about 10% of one side of the small one, so the buyer pays roughly 1% against roughly 10% above the quoted price, before the fee.
A liquidity provider deposits when ETH is $2,000 and withdraws when it is $4,000. The position is worth 41% more than the deposit. Was there impermanent loss?
- No, the position made money
- Yes: holding the two tokens would have been worth 50% more, so the pool position is 5.7% behind
- Yes, the whole 41% is impermanent loss
Show the answer
B. Yes: holding the two tokens would have been worth 50% more, so the pool position is 5.7% behind Impermanent loss is measured against holding, not against the deposit. At a price ratio of 2 the pool position is 2√2 ÷ 3 − 1 = −5.7% against holding, even though both are up.
Why does a liquidity provider end up with more of the token that fell in price?
- The protocol buys the falling token to support its price
- Arbitrage traders sell the falling token into the pool and take the other one out until the pool’s price matches the market
- Fees are always paid in the falling token
Show the answer
B. Arbitrage traders sell the falling token into the pool and take the other one out until the pool’s price matches the market The pool quotes a price from its reserves and does not know the market price. When the market falls, traders profit by selling the token to the pool, which leaves the pool, and so its providers, holding more of it.
You set a slippage tolerance of 5% on a large swap in a public pool. What is the main risk?
- The swap cannot execute at all
- A bot can trade just before and just after you, so you receive close to the worst price you allowed
- The pool will charge a 5% fee
Show the answer
B. A bot can trade just before and just after you, so you receive close to the worst price you allowed A loose tolerance tells everyone how much worse a price you will accept. A sandwich trade pushes the price up before your swap and sells after it, taking the difference.
Sources and further reading
- Uniswap documentation — How Uniswap works (pools and the constant product formula)
- Uniswap documentation — Fees (0.30% in v2; protocol fees active since December 2025)
- Hayden Adams, Noah Zinsmeister and Dan Robinson — Uniswap v2 Core (whitepaper, March 2020)
- Hayden Adams and others — Uniswap v3 Core (whitepaper, March 2021): concentrated liquidity and fee tiers
- Ethereum.org — Maximal extractable value (front-running and sandwich trades)
- IRS — Digital assets (property treatment; exchanging one digital asset for another is reportable), page dated September 2, 2026
- Finabase chart data — ETH.X daily closes, November 18, 2024 to November 18, 2026; pool arithmetic computed by Finabase
