
Where a swap’s price comes from
A decentralized exchange of the kind most people use has no order book and nobody quoting prices. It has pools. Each pool holds two tokens that liquidity providers deposited, and a formula sets the price from the balance between them.
The simplest formula is constant product: multiply the two balances, and the answer must be the same before and after every trade.
Say a pool holds 100 ETH and 200,000 USDC. The product is 20,000,000, and the pool’s price is 200,000 divided by 100, or $2,000 an ETH. You put USDC in and the pool gives ETH out, keeping the product at 20,000,000.
The more you take, the less ETH remains, so each further unit costs more. That rising cost is called price impact, and it’s the first thing to understand about a swap.
Continue with The Crossover Pro
The rest of this story, plus two paid editions a week. $24.99 a month, or $249 a year. Already a member? Sign in above.
Subscribe to Pro