How a swap works
Trading against a liquidity pool, step by step.
- Explain what happens when you buy from a pool
- Understand why the price moves with your own trade
- Know the difference between a quote and an execution
When you buy a token on a decentralised exchange, there is usually no seller on the other side. You trade against a liquidity pool: a contract holding the token and a currency. You put currency in and take tokens out.
- You signYour wallet signs: pay X USDC, receive at least Y tokens
- RouteThe order travels to the pool (directly or via a relay)
- PoolTakes your USDC, gives tokens at its current price
- BlockConfirmed — or reverted if you would get less than Y
Because the pool keeps a balance between its two reserves (in the simplest design, x · y = k), every purchase makes the remaining tokens more expensive. Your own trade moves the price — a little in a deep pool, a lot in a shallow one.
- Quote
- The estimate shown before you sign: how many tokens you should receive and the minimum you accept.
- Execution
- What actually happens when your transaction is included in a block. The price may have moved since the quote.
- Swaps trade against pools, not individual sellers.
- Your own trade moves the price, more in shallow pools.
- Quotes are estimates; execution happens in the block.
Check your understanding
Answers are checked on the server. You can retry as many times as you like.
Educational content only. Not financial, investment, legal or tax advice. Examples and simulators are hypothetical and simplified; they are not real market data or a prediction of results.
