Decentralised exchange (DEX)
A token exchange run by smart contracts where you keep your keys: Uniswap, Curve.
An automated market maker
On a classic exchange, buyers and sellers meet in an order book. On most decentralised exchanges, such as Uniswap, you trade against a pool: a contract that holds two tokens and sets the price from their ratio. The most common rule keeps the product of the two quantities constant (x x y = k).
Liquidity providers deposit both tokens and earn the fees on every trade, in exchange for the risk of impermanent loss.
- x and y
- quantities of the two tokens in the pool, k constant before fees.
The impact of a large purchase
- Pool: 100 ETH and 300,000 USDC, price $3,000, k = 30,000,000.
- You add 30,000 USDC: the pool holds 330,000.
- ETH left: 30,000,000 / 330,000 = 90.91; you receive 9.09 ETH.
- Average price paid: 30,000 / 9.09 = $3,300, 10% above the quoted price.
The larger the order relative to the pool, the stronger the price impact.
Common mistakes
- Ignoring the maximum slippage allowed: a bot can buy just before you and sell just after.
Questions and answers
DEX or centralised exchange?
On a DEX you keep your keys and no intermediary can freeze your funds, but you bear mistakes and contract risk. On a centralised exchange, it is the other way round.
Notitia newsroom · education, not investment advice.