DeFiBeginner

What Is a DEX?

A DEX (decentralized exchange) is a set of smart contracts that lets you swap tokens straight from your own wallet, with no company holding your funds or approving your account. Prices come from code, usually a liquidity pool formula, and every trade settles on the blockchain in a single transaction.

By DappAtlas editors · · 6 min read

In this article

Key takeaways

  • A DEX runs on smart contracts, so you keep custody until the swap executes; there is no deposit step and no account.
  • Most DEXs use an automated market maker: Uniswap v2 prices trades with the constant product rule x * y = k and charges 0.30% per swap.
  • Large trades against small pools move the price; that price impact, plus MEV bots, is where most hidden cost comes from.
  • You pay the pool fee plus the network gas fee, and a bad token approval can expose your wallet long after the trade.

How a DEX differs from a centralized exchange

On a centralized exchange such as Coinbase or Kraken, you send coins to the company, it records your balance in its own database, and it matches your order against other customers. On a DEX there is no internal ledger: the smart contract holds the pooled tokens, and your wallet signs a transaction that moves tokens in and out in one step. ethereum.org frames the difference plainly: in DeFi you hold your money, while in traditional finance it is held by companies.[1]

That design has direct consequences. There is no sign-up and no deposit or withdrawal step, because the contracts run on the chain itself. There is also no support desk that can reverse a mistake. If you send tokens to the wrong contract or approve a malicious one, the chain treats that as a valid instruction.[1]

DEXs exist on many smart-contract chains, and the contracts differ from one to the next, but the custody model is the same: the tokens stay under your own keys until the moment the swap executes.

See also: Uniswap · PancakeSwap · Curve Finance · Jupiter

How automated market makers set the price

Most DEXs do not use an order book. They use an automated market maker (AMM): a contract that holds reserves of two tokens and quotes a price from a formula. Uniswap v1 and v2 use a constant product formula, where the product of the two reserves may not decrease after a trade. Written out, x * y = k, with x and y being the pool's two token balances.[2]

The reserves come from liquidity providers (LPs), who deposit both tokens of the pair and receive a share of trading fees. In Uniswap v2 every trade pays a 30 basis point fee, 0.30%, which stays in the pool for LPs. The v2 whitepaper also describes an optional protocol fee switch that, if turned on, would send 5 of those 30 basis points to the protocol and leave 25 for LPs.[2]

Uniswap v3, described in a March 2021 whitepaper, changed two things. LPs can concentrate their capital inside a chosen price range instead of spreading it from zero to infinity, and each pair can have several pools with different fees. The initial fee tiers were 0.05%, 0.30% and 1%, so a USDC and USDT pool can charge far less than a pool for a thinly traded token.[3]

The formula also explains why pool prices track the wider market. If ETH trades at $3,100 on other venues while a pool still quotes $3,000, an arbitrage trader buys ETH from the pool until the reserves imply the outside price. That arbitrage is how a contract with no price feed stays roughly in line with other markets.[2]

Flash swaps are a side effect of the same design. The v2 whitepaper notes that a user can take tokens out of a pool and repay them within the same transaction, paying the same 0.30% fee, which makes every pool a source of one-transaction loans.[2]

Worked example: one swap against a v2 pool

Take a Uniswap v2 style pool holding 100 ETH and 300,000 USDC. The spot price is 300,000 / 100 = 3,000 USDC per ETH, and k = 100 * 300,000 = 30,000,000. You want to sell 10 ETH.[2]

First the 0.30% fee comes off the input: 10 * 0.997 = 9.97 ETH counts toward the formula. The pool must end with x * y still equal to k, so the ETH reserve used in the formula is 109.97 and the new USDC reserve is 30,000,000 / 109.97 = 272,801.67. You receive the difference: 300,000 minus 272,801.67, or about 27,198 USDC.[2]

At the old spot price, 10 ETH would have been worth 30,000 USDC. You got roughly 27,198, so about 90 USDC went to the fee and the remaining 2,700 or so is price impact: your own trade pushed the price down as it went. After the swap the pool quotes about 2,480 USDC per ETH (272,801.67 / 110). The same 10 ETH sold into a pool ten times larger would lose closer to 1% to price impact. That is the whole reason aggregators split orders across pools.

What a DEX trade really costs

Every DEX trade has up to four costs. The pool fee is set by the contract, for example 0.30% in a v2 pool or 0.05% in a low-fee v3 pool. The network fee, or gas, goes to validators and depends on how busy the chain is, not on the size of your trade. Price impact depends on your trade size relative to the pool. The fourth cost, MEV, is the one users rarely see.[3]

ethereum.org defines maximal extractable value (MEV) as value taken from block production by including, excluding or reordering transactions. The best known form against DEX users is the sandwich: a bot sees your pending swap, buys just before it, lets your trade push the price up, and sells right after. The victim gets worse execution and higher slippage.[4]

Your slippage tolerance is the cap on how much worse than the quote you will accept. Setting it at 0.5% on a liquid pair limits what a sandwich can take. Setting it at 10% to make a trade go through invites exactly that attack.[4]

Gas is the cost that most changes the math on small trades. A swap that pays $4 in network fees costs 4% on a $100 trade and 0.04% on a $10,000 trade. That is one reason to check whether the same swap is available on a lower-fee layer 2 network.

Risks specific to DEXs

Contract risk comes first. A DEX is only as safe as its code and the code of every pool you touch, so check whether the exact contract version has been audited. On a permissionless DEX anyone can create a pool for any token, so a copycat token can carry the same name and ticker as a real one. Always match the contract address from the project's official site.[1]

Token approvals are the second risk. Before a contract can move your ERC-20 tokens it needs a token approval, and some interfaces ask for an unlimited amount. If that contract is later exploited, the approval still stands. Revoking unused approvals is routine hygiene, not paranoia.

For LPs there is also impermanent loss, which the v2 whitepaper ties to changes in the relative price of the two assets: when prices move, the pool rebalances toward the falling asset, so an LP can end with less value than simply holding both tokens. The 0.30% fee income has to outrun that loss to be worth it.[2]

Front-end risk is separate from contract risk. The website you use is just an interface to the contracts, and a hijacked domain or a lookalike URL can serve a page that asks for a malicious signature while the underlying protocol is fine. Bookmark the official address and check that your wallet prompt names the contract you expect before signing.

DEX, aggregator or centralized exchange

A single DEX quotes only its own pools. An aggregator such as 1inch, ParaSwap or CowSwap checks many DEXs and splits your order across them to reduce price impact. A centralized exchange offers deeper order books for major pairs, fiat on-ramps and account recovery, at the price of custody and identity checks.

Where each option fits
OptionWho holds fundsBest for
Single DEX (Uniswap, Curve)You, until the swap executesLiquid on-chain pairs, direct pool access
DEX aggregator (1inch, CowSwap)You, until the swap executesLarger swaps where routing cuts price impact
Centralized exchangeThe exchangeFiat deposits, deep order books, account support

See also: What is 1inch · 1inch · CowSwap · ParaSwap · Best crypto exchanges

The bottom line

Use a DEX when you already hold tokens in a self-custody wallet and want to swap them without handing them to anyone. Before each trade, check three numbers: the pool fee, the price impact line and your slippage setting. If price impact is large relative to the fee, split the trade or compare an aggregator quote; if you need dollars in a bank account, a centralized exchange is still the more direct tool.

See also: Best crypto wallets

Educational content, not financial advice. Crypto assets are volatile; do your own research.

How we write our guides

Every guide is written from primary sources: official docs, standards and regulator pages, listed below with the date we read them. No project pays to be mentioned. Editorial standards

Related terms

FAQ

Do I need an account to use a DEX?

No. You connect a self-custody wallet such as MetaMask or Phantom and sign transactions. There is no username, password or identity check at the contract level.

Why did I receive less than the quote?

The quote assumes the pool does not change before your trade lands. Other trades, MEV bots and your own price impact can move it. Your slippage tolerance sets the maximum shortfall you accept; beyond it, the transaction reverts.

Is a DEX safer than a centralized exchange?

It removes one risk, the exchange losing or freezing your funds, and adds others: smart contract bugs, fake tokens and malicious approvals. Neither is safe by default; the risks are different.

What is the fee on Uniswap?

Uniswap v2 pools charge 0.30% per swap. Uniswap v3 pools were launched with tiers of 0.05%, 0.30% and 1%. Network gas is paid on top of the pool fee.

Keep reading

Sources (4)
  1. [1] ethereum.org. “Decentralized finance (DeFi).” Accessed Sep 26, 2026.
  2. [2] Uniswap Labs. “Uniswap v2 Core whitepaper.” Accessed Sep 26, 2026.
  3. [3] Uniswap Labs. “Uniswap v3 Core whitepaper.” Accessed Sep 26, 2026.
  4. [4] ethereum.org. “Maximal extractable value (MEV).” Accessed Sep 26, 2026.

How this page works

Sources: ethereum.org, Uniswap Labs, Uniswap Labs. Data as of Sep 26, 2026.

How we review

Not affiliated with any project listed. Educational content, not financial advice.