A decentralized exchange (DEX) is a cryptocurrency trading venue whose matching and settlement are carried out by smart contracts on a blockchain. Traders swap tokens directly from their own wallets: the exchange never takes custody of their assets, and each trade settles on-chain in a single transaction. Most DEXs do not require users to open an account or provide identity documents.
A DEX is the counterpart of a centralized exchange, such as a traditional crypto exchange that holds customer funds, keeps its own order book and converts between crypto and bank money. DEXs are one of the core services of decentralized finance and among the most widely used decentralized applications. Most trade only tokens on the same blockchain, so users still need a fiat on-ramp to get money in and out.
How a DEX works, in everyday terms
A centralized exchange is like a currency bureau at an airport: you hand over your money, the clerk holds it, and you trust them to give you the other currency. A DEX is more like a self-service coin-swap machine that anyone can stock. People put pairs of tokens into the machine and earn a small fee every time someone uses it, and the machine sets the price automatically from how much of each token it holds.
You never hand your tokens to a person. You connect your wallet, ask the machine for a swap, and either the whole swap happens or nothing happens. The flip side is that nobody checks whether the token you are buying is genuine, and no one can reverse the swap if you make a mistake.
Main designs
- Automated market makers. Most DEX volume runs through an automated market maker, in which a liquidity pool holds two or more tokens and a formula sets the price. Uniswap, launched on Ethereum in 2018, popularised the design; PancakeSwap and Curve are other large examples.
- Order-book DEXs. Buyers and sellers post bids and offers in an order book, as on a traditional exchange. These work best on fast, low-fee chains or specialised app-chains and are common for derivatives trading.
- Aggregators. Routing services split a trade across several DEXs to find the best overall price.
- Cross-chain swaps. Some services move value between chains using a bridge or atomic swaps, though bridges add risk.
How AMM pricing works
The simplest AMM, the "constant product" formula used by early Uniswap versions, keeps the product of the two token balances fixed:
- is the pool's balance of the first token.
- is the pool's balance of the second token.
- is a constant that stays the same during a trade, ignoring fees.
Suppose a pool holds 100 ETH and 300,000 USDC, so is 30,000,000 and the starting price is 3,000 USDC per ETH. A trader adds 30,000 USDC. The pool must now hold 330,000 USDC, so its ETH balance falls to 30,000,000 ÷ 330,000 ≈ 90.91 ETH. The trader receives about 9.09 ETH, an average price of about 3,300 USDC, 10% worse than the starting price. That gap is slippage, and it shrinks as pools get deeper. Other curves and the fee maths are covered in Formulas for Automated Market Makers (AMMs).
Liquidity providers
A liquidity provider deposits both tokens of a pair into a pool and receives a liquidity provider token representing its share. Providers earn a share of trading fees, often 0.3% per trade in the classic Uniswap design, but bear impermanent loss when the relative price of the two tokens moves. Later versions let providers concentrate liquidity in a chosen price range, which earns more fees but needs closer management. Uniswap's fourth version, launched in January 2025, added "hooks" that let developers attach custom logic to pools.
Risks and regulation
DEX users face risks that a regulated exchange would normally screen out:
- Scam tokens. Anyone can create a pool, so fake or worthless tokens are listed freely and a rug pull can drain a pool overnight.
- Front-running. Pending transactions are public, so bots can trade ahead of a large order and profit from the price move it causes.
- Contract risk. Bugs in pool or router contracts have been exploited for large losses.
- Costs. Each swap pays a gas fee, which on busy networks can exceed the trade's value; many DEXs now run on a layer 2 network to cut fees.
Most DEXs do not perform know-your-customer checks, which raises money-laundering and sanctions concerns. Regulators generally aim at identifiable parties, such as companies running a DEX's website or controlling its contracts, rather than the contracts themselves, and the EU's MiCA regulation leaves fully decentralized services outside its scope. Users connect through a non-custodial wallet and remain responsible for their own keys.