Skip to content
Highlighted coinsYour coin here?
Ad

DeFi

Explainer: how decentralized exchanges price trades

Sample article created by the setup wizard for demonstration. Edit or delete it.

Many decentralized exchanges do not use an order book. Instead they use an automated market maker: a smart contract holding two tokens in a liquidity pool and a formula that sets the price from the ratio between them.

When you swap, you add one token to the pool and remove the other, which moves the price. Large trades in small pools move it a lot, so the price you get can differ from the price you saw. That difference is slippage. Wallets let you set a maximum slippage so a trade fails rather than filling at a much worse price.

Liquidity providers deposit both tokens and earn a share of trading fees. If the two prices drift apart, providers can end up worse off than if they had simply held the tokens — an effect known as impermanent loss.

Because pending transactions are public in the mempool, bots sometimes trade just before and after a large swap to profit from the price move. This is one form of maximal extractable value, or MEV.

Explained in this article

  • Maximal Extractable Value

    Profit captured by reordering or inserting pending transactions. Full definition →

  • Automated Market Maker

    A DEX design that prices trades with a formula and token pools. Full definition →

  • Impermanent Loss

    The cost to liquidity providers when pooled token prices diverge. Full definition →

  • Liquidity Pool

    Tokens pooled in a contract to enable trading or lending. Full definition →

  • Slippage

    The gap between expected and actual execution price. Full definition →

Leave a Reply

Your email address will not be published. Required fields are marked *