CommunitySign in

Share

Crypto

Definition

A decentralized exchange (DEX) is a platform where users swap tokens directly from their own wallets through smart contracts, without depositing funds with a central operator.

How it works

Most DEXs use an automated market maker (AMM) instead of matching buyers and sellers in an order book. Liquidity providers deposit two tokens into a pool, and the price comes from the ratio of the two balances. In the common constant-product design, the pool keeps x × y = k, where x and y are the token balances and k stays fixed during a trade, apart from fees. Buying one token adds the other token to the pool and removes the one you buy, so each additional unit costs more. Some DEXs instead run order books on the blockchain.

That price shift is called price impact, and it grows when the trade is large relative to the pool. Before you sign, the interface shows the expected output and a slippage tolerance, the largest shortfall you accept; if the result would be worse, the transaction fails. Each swap pays a pool trading fee, which goes to liquidity providers, plus the network's gas fee.

Anyone can create a token and a pool, so a token with a copied name and logo can appear next to the real one. The contract address, not the name, is what identifies a token. Trades settle on the blockchain and cannot be reversed.

Example (hypothetical numbers)

Suppose a pool holds 1,000 Token X and 100,000 stablecoin units worth $1 each, so the quoted price is $100 per Token X.

k = 1,000 × 100,000 = 100,000,000. You pay 5,000 stablecoins, so the pool now holds 105,000 stablecoins and 100,000,000 ÷ 105,000 ≈ 952.38 Token X.

You receive 1,000 − 952.38 ≈ 47.62 Token X, an average price of $5,000 ÷ 47.62 ≈ $105, about 5% above the quoted $100 (fees ignored).

The example shows that on an AMM the trade itself moves the price, so a large trade in a small pool costs more per token.

Common mistakes

  • Picking a token by its name or logo instead of its contract address.
  • Setting a very high slippage tolerance, which invites worse fills and front-running bots.
  • Ignoring price impact when trading a large amount in a small pool.

Related calculators

This glossary is for education only and is not investment advice. Examples use hypothetical numbers.

All glossary terms