CoinBrew CoinBrew
education · CoinBrew

What Is a DEX? Decentralized Exchanges Explained

If you’ve spent more than five minutes in crypto, you’ve heard someone say “just swap it on a DEX.” But what actually is a DEX, how does it work under the hood, and why does it matter that it’s decentralized in the first place? Let’s break it down without the fluff.

What Is a DEX?

A decentralized exchange (DEX) is a platform that lets you trade cryptocurrencies directly from your wallet — no sign-up, no KYC, no company holding your funds. The trades happen via smart contracts on a blockchain, not through a central company acting as middleman.

Compare that to a centralized exchange (CEX) like Coinbase or Binance. When you deposit funds there, you’re handing custody to that company. They match your buy order with someone else’s sell order. They hold the keys. If they get hacked, go bankrupt, or freeze withdrawals (see: FTX), you’re at their mercy.

On a DEX, your wallet stays your wallet. You connect it, approve a transaction, and the swap happens on-chain. That’s it. No account needed.

How Traditional Exchanges Work: Order Books

Before DEXs, every exchange — crypto or otherwise — used an order book. Here’s the concept:

  • Buyers post bids: “I’ll buy 1 ETH at $2,800”
  • Sellers post asks: “I’ll sell 1 ETH at $2,850”
  • When a bid and ask match, the trade executes

Order books work fine when there’s tons of liquidity and active market makers (professional traders who constantly post bids and asks to keep markets flowing). Stock exchanges have been doing this for centuries.

The problem? Replicating this on a blockchain is painfully inefficient. Every order update is a transaction. Gas fees eat you alive. Slow block times mean stale prices. Early DEXs tried the order book model and largely failed.

Then came the AMM.

What Is an AMM (Automated Market Maker)?

An Automated Market Maker is the engine behind most modern DEXs. Instead of matching buyers with sellers, it uses a liquidity pool and a mathematical formula to determine prices automatically.

Here’s the core idea:

Instead of needing a counterparty who wants to sell ETH when you want to buy it, you trade against a pool of funds. That pool contains both ETH and USDC (for example). A formula adjusts the price based on supply and demand within the pool.

The most famous formula is Uniswap’s constant product formula:

x * y = k

Where:

  • x = amount of Token A in the pool
  • y = amount of Token B in the pool
  • k = a constant that never changes

When you buy ETH from a ETH/USDC pool, you’re adding USDC and removing ETH. This changes the ratio, which changes the price. The more ETH you try to buy at once, the higher the price goes — that’s price impact (also called slippage).

It’s elegant. No order book required. No market makers needed. Just math and smart contracts.

What Is a Liquidity Pool?

A liquidity pool is a smart contract holding two (or more) tokens that users have deposited. Those depositors are called liquidity providers (LPs).

Why would anyone lock their tokens in a pool? Fees. Every time someone trades against the pool, a small fee (typically 0.05%–1% depending on the pool) gets distributed to LPs proportionally to their share.

This created a whole new category of DeFi activity: liquidity mining and yield farming — depositing assets into pools to earn trading fees and protocol token rewards. That’s a bigger topic for another day, but the point is that DEX liquidity is incentivized by real economics.

The risk? Impermanent loss. If the price of one token in your pool changes significantly relative to the other, you end up with less dollar value than if you’d just held. It’s one of the more counterintuitive concepts in DeFi, and it trips up a lot of people.

Uniswap: The DEX That Changed Everything

Uniswap launched in 2018 and became the blueprint for modern DEXs. It implemented the constant product AMM, open-sourced everything, and proved that decentralized trading at scale was actually possible.

Here’s what made it revolutionary:

  • Permissionless listing: Anyone can create a trading pair by deploying a liquidity pool. No application, no approval, no listing fee.
  • Non-custodial: Trades go directly from your wallet to the smart contract and back. Uniswap never touches your funds.
  • Composable: Because it’s open smart contracts, other protocols can build on top of it. Uniswap liquidity powers countless other DeFi apps.

Uniswap has gone through several versions. V3 introduced concentrated liquidity — LPs can choose a specific price range to provide liquidity, making capital far more efficient. V4 pushed further with “hooks” — customizable logic that lets developers modify pool behavior.

Other major DEXs followed the AMM model: SushiSwap, Curve (optimized for stablecoins), Balancer (multi-token pools), PancakeSwap (on BNB Chain), and Trader Joe (on Avalanche). Each has tweaks, but AMMs are the backbone.

DEX vs CEX: Real Trade-offs

Let’s be honest — DEXs aren’t strictly better than CEXs. They’re different, with real advantages and real downsides.

DEX Advantages

  • Self-custody: You hold your keys, always
  • No KYC: Trade without revealing your identity
  • Access to new tokens: Long before they hit Coinbase, tokens are live on DEXs
  • Censorship resistance: No company can freeze your account
  • Transparency: Every trade is on-chain and auditable

DEX Disadvantages

  • Gas fees: Every swap costs network fees, which can be brutal on Ethereum mainnet
  • Slippage: Large trades on illiquid pools move the price against you
  • MEV/front-running: Bots watch the mempool and can sandwich your transaction
  • Complexity: If you mess up a transaction, there’s no customer support
  • Scam tokens: Anyone can list anything — fake tokens, honeypots, rug pulls galore

For most retail users just buying Bitcoin or Ethereum, a CEX is simpler and cheaper. DEXs shine when you need access to tokens not listed elsewhere, want to stay non-custodial, or are deep in DeFi.

Types of DEXs Beyond AMMs

Not every DEX uses the AMM model. A few worth knowing:

Order Book DEXs: Some chains are fast and cheap enough to run order books on-chain. dYdX (now its own chain) and Hyperliquid do this for perpetuals trading. The experience feels more like a traditional exchange but stays non-custodial.

Aggregators: 1inch, Paraswap, and Odos aren’t DEXs themselves — they route your trade across multiple DEXs to get the best price. They split orders, find optimal paths, and minimize slippage. Using an aggregator is almost always better than trading on a single DEX directly.

Concentrated Liquidity Managers: Protocols like Arrakis and Gamma automatically manage Uniswap V3 positions for LPs, keeping liquidity in the most profitable price range.

How to Actually Use a DEX

Here’s the short version:

  1. Get a wallet: MetaMask, Rabby, or any web3 wallet
  2. Fund it: Buy ETH (or whatever chain’s gas token) on a CEX and send it to your wallet
  3. Connect to the DEX: Go to app.uniswap.org (or whichever DEX), click “Connect Wallet”
  4. Select tokens: Choose what you’re swapping from and to
  5. Check slippage settings: Default is usually fine; adjust for low-liquidity tokens
  6. Approve + Swap: You’ll sign two transactions — one to approve the token, one to execute the swap
  7. Wait for confirmation: Seconds on L2s, longer on mainnet

One thing beginners get wrong: you need the native gas token of whatever chain you’re on. Swapping on Ethereum? You need ETH for gas. On Arbitrum? Still ETH. On Polygon? MATIC (now POL). On BNB Chain? BNB. Running out of gas mid-transaction is a common gotcha.

Is a DEX Safe?

Safer than a CEX in terms of custody risk. More dangerous in terms of smart contract risk.

DEX smart contracts have been hacked. Bugs, logic errors, and economic exploits have drained pools worth hundreds of millions. Established protocols with years of audits (like Uniswap) are relatively safe. New, unaudited forks are not.

The golden rules:

  • Stick to well-established protocols
  • Verify contract addresses through official channels
  • Don’t interact with random tokens sent to your wallet
  • Use hardware wallets for significant holdings

FAQ

What’s the difference between a DEX and a CEX? A CEX (centralized exchange) is run by a company that holds your funds and matches orders. A DEX is peer-to-contract: you trade directly from your wallet via smart contracts, with no company controlling your assets.

Can I lose money using a DEX? Yes — through price impact/slippage on large trades, impermanent loss as a liquidity provider, smart contract bugs, or simply buying a bad token. DEXs don’t protect you from bad decisions or scams. Do your research.

Why are gas fees so high on DEX trades? On Ethereum mainnet, every transaction competes for limited block space. Complex DEX swaps require more computation = more gas. Using Layer 2 networks like Arbitrum or Base dramatically cuts costs — often to cents.

How do liquidity providers make money on a DEX? LPs deposit token pairs into a pool and earn a percentage of every trade that goes through it. Most pools charge 0.05%–1% per trade, split proportionally among LPs. Some protocols also reward LPs with additional governance tokens.

What is MEV and should I worry about it? MEV (Maximal Extractable Value) refers to bots that reorder or insert transactions to profit at your expense — commonly via “sandwich attacks” where they front-run your swap. For small trades, it’s a minor tax. For large trades on illiquid pools, it can be significant. Using aggregators with MEV protection (like 1inch Fusion) helps.