A DEX (decentralized exchange) is a marketplace that lets you swap one cryptocurrency for another directly from your own wallet, using smart contracts instead of a company to match and settle trades. Unlike a centralized exchange, a DEX never takes custody of your funds: you connect a self-custody wallet, approve the trade yourself, and the tokens move on-chain the moment the transaction confirms.
Key takeaways
- A DEX lets you trade tokens without depositing them with a third party, so you keep custody until the moment of the swap.
- Most DEXs use an automated market maker model, where trades happen against pooled liquidity rather than a traditional order book.
- You pay network gas fees and a small trading fee, and prices can move against you through slippage on large or low-liquidity trades.
- DEXs are permissionless and transparent, but they expose you to smart-contract, token-scam, and price-impact risks.
How a DEX works
On a centralized exchange, you send money to the company, it holds your balance, and it matches your order internally. A DEX removes that middleman. The exchange logic lives in smart contracts deployed to a blockchain, and those contracts hold pooled funds and execute swaps according to fixed rules. When you want to trade, you connect your wallet, choose the tokens and amount, and sign a transaction. The contract swaps your tokens and sends the result straight back to your address.
Because everything runs on-chain, every trade is public and verifiable, and no one can freeze your account or block your withdrawal. The flip side is that there is no password reset and no support team. If you sign a bad transaction or interact with a malicious token, there is usually no way to undo it.
Order books versus automated market makers
There are two main designs. A small number of DEXs use an on-chain order book, matching individual buy and sell orders much like a traditional exchange. Far more common is the automated market maker (AMM) model, where trades execute against a shared pool of two tokens and a formula sets the price based on the ratio in the pool. If you want the full mechanics, see our guide to automated market makers. The AMM design is what makes it possible to trade at any hour without a counterparty waiting on the other side.
Routers and aggregators
Many DEX interfaces add a routing layer on top of the underlying pools. Rather than sending your whole trade through one pool, a router or aggregator splits it across several pools and even several exchanges to find the best overall price. For you as a trader this happens behind a single click, but it explains why a quoted price can draw on liquidity from many sources at once. It also means the smart contracts you interact with may include the router itself, which is one more piece of code to consider when you assess safety.
Liquidity, fees, and slippage
An AMM-based DEX depends on liquidity providers, users who deposit pairs of tokens into a pool and earn a share of trading fees in return. The deeper the pool, the smaller the price impact of any single trade. When a pool is shallow relative to your trade size, the price moves as you buy or sell, and you receive less than the quoted amount. That gap is called slippage, and our explainer on slippage and liquidity shows how to estimate and limit it.
Costs on a DEX come in two parts. First, the network charges a gas fee to process your transaction, which varies with how busy the blockchain is. Second, the protocol charges a small trading fee that goes mostly to liquidity providers. Most DEX interfaces let you set a maximum slippage tolerance so a trade will fail rather than execute at a much worse price than expected.
How a DEX compares to a centralized exchange
A DEX and a centralized exchange solve the same problem in opposite ways. Choosing between them depends on what you value:
- Custody: a DEX leaves assets in your wallet until you trade; a centralized exchange holds them for you.
- Access: a DEX is open to anyone with a wallet and usually needs no identity verification, while centralized exchanges typically require account signup and KYC.
- Token range: DEXs often list new or niche tokens far earlier, which is both an opportunity and a scam risk.
- Ease of use: centralized exchanges tend to be simpler for beginners and support direct fiat deposits, which most DEXs do not.
Many people use both, buying with fiat on a centralized platform and then moving on-chain to trade or explore DeFi. You can compare independently reviewed venues on our decentralized exchanges ratings page, and start with the fundamentals of decentralized finance.
Risks to understand
Trading on a DEX gives you control, but it also removes the safety nets you might expect. Keep these risks in mind:
- Smart-contract risk: the exchange is only as safe as its code. Bugs or exploits in the contracts can lead to lost funds, and unaudited protocols are especially risky.
- Malicious token risk: anyone can create a token and list it. Some are designed so you can buy but never sell, or drain your wallet through a hidden approval. Verify contract addresses before trading.
- Token approval risk: to trade a token, you grant the DEX permission to move it. Overly broad or forgotten approvals can be abused later, so revoke ones you no longer need.
- Slippage and price impact: large trades in shallow pools can execute at a much worse price than shown; always set a sensible slippage limit.
- Front-running: because pending trades are public, bots can sometimes sequence their transactions around yours to profit at your expense.
Trying a DEX safely
If you are new to DEXs, start small. Use a reputable self-custody wallet, double-check you are on the correct site, and verify the token you intend to trade against a trusted source. Make a tiny first swap so you can see how approvals, gas, and slippage settings behave before committing more. Learn the wider ecosystem through our guides, and treat every unfamiliar token or link with suspicion. A DEX puts you in full control of your trades, which is exactly why careful habits matter so much.



