Centralized vs Decentralized Exchanges: How Each Actually Works
How centralized and decentralized exchanges differ in custody, order matching, identity checks, counterparty risk, token approvals and MEV exposure.
A centralized exchange (CEX) holds your assets on its own books and matches orders internally. A decentralized exchange (DEX) is a set of smart contracts that move tokens between wallets according to rules written on-chain. The distinction that matters most is not speed or interface polish. It is who controls the asset at each step, and what has to be true for the trade to settle.
This page walks through the mechanics of both, so you can predict what happens in situations the marketing does not describe: an exchange halting withdrawals, a swap executing at a worse price than quoted, a token approval that outlives the trade.
Custody: who holds the asset between steps
On a CEX, a deposit address is controlled by the exchange. When you send tokens to it, the exchange credits an internal ledger balance to your account. From that point the tokens are an entry in the exchange’s database, not an asset in a wallet you control. Trading on a CEX is a change to that ledger. Withdrawal is the exchange sending tokens from its own wallets back to an address you specify.
This arrangement is why a CEX can offer features that are awkward on-chain: instant internal transfers, fiat on-ramps, order types that rest for weeks. It is also why the exchange’s solvency is your exposure. If the exchange has lent out or lost the assets backing its ledger balances, your balance is still displayed but the withdrawal may not clear. Nothing in the interface tells you the difference between a balance that is backed and one that is not until withdrawals are tested.
On a DEX, the contract never takes custody in the same sense. A swap is a single transaction in which your wallet sends one token and receives another, with the contract enforcing the exchange rate and the recipient address. Between transactions, the assets sit in your wallet. The risk shifts from the exchange’s balance sheet to the contract code and to whatever approvals you have granted.
Order books against automated market makers
A CEX matches buyers and sellers in an order book. A market order consumes the best available resting orders until it is filled, so the price you receive depends on how much liquidity sits at each level. A large order can walk through several levels and fill at an average price worse than the headline quote. This is ordinary order-book depth, and it exists on every venue that matches orders.
Most DEXs do not keep an order book. They use an automated market maker (AMM): a pool holding two or more tokens, with a formula that sets the price as the ratio of the reserves. A trade changes the reserves, so it changes the price for the next trade. The cost of a trade relative to the pool’s mid-price is slippage, and it grows with trade size relative to pool depth. A thin pool produces large slippage on a modest trade; a deep pool absorbs more before the price moves noticeably.
Liquidity providers supply the tokens in the pool and receive a share of trading fees. They also take on the risk that the pool’s ratio moves against them while they hold a position, which is the mechanism usually called impermanent loss. It is not a fee and it is not temporary in any guaranteed sense; it is the difference between holding the two tokens separately and holding them in the pool.
A DEX swap transaction usually includes a minimum-output parameter. If the pool price moves past that limit before the transaction executes, the swap reverts and you pay gas for a failed transaction. Setting the limit loosely makes the swap more likely to fill but accepts a worse price.
Identity checks and what they change about recovery
A CEX operates under the rules of the jurisdictions it serves and typically requires identity verification before deposits, trading or withdrawals above certain thresholds. That verification ties an account to a legal identity, which is what makes account recovery, support tickets and, in some jurisdictions, reporting obligations possible. It also means the exchange can freeze an account, restrict withdrawals, or be compelled to do so.
A DEX contract has no account in that sense. It does not know who is transacting, only which address is calling it. There is no password reset and no support desk that can reverse a transaction. If a wallet’s keys are lost, the assets in it are unreachable through the protocol. This is the trade: no intermediary to appeal to, and no intermediary to recover on your behalf.
Counterparty and insolvency risk on each side
On a CEX, the counterparty is the exchange. Your claim is against its ledger, and the exchange’s ability to honour withdrawals depends on its reserves, its lending arrangements and its operational controls. Proof-of-reserves disclosures vary in what they actually prove; a snapshot of assets does not by itself show liabilities. The practical test is whether withdrawals clear promptly and whether the exchange publishes liabilities alongside assets.
On a DEX, the counterparty is the contract and the pool. There is no balance sheet to become insolvent, but there are other failure modes: a bug in the contract, a misconfigured pool, a token with transfer restrictions, or a price feed that can be manipulated. The pool can also be drained by an attacker if the contract or its dependencies have a flaw. “Code is law” describes who enforces the rules, not a guarantee that the code is correct.
Approvals and MEV on the DEX side
Before a DEX contract can move an ERC-20 token from your wallet, you grant an allowance. The common pattern is an unlimited approval, which authorises the spender to move that token at any time in the future. The approval persists after the trade. If the spender contract is later exploited, the approval is the path to your balance of that token.
Approvals can be inspected and revoked with cast, which reads and writes chain state directly. The function signature is passed as a positional argument, not a flag.
cast call <token-address> "allowance(address,address)(uint256)" <owner-address> <spender-address> --rpc-url <url>
The output is the remaining allowance in the token’s smallest unit. A very large number indicates an unlimited or near-unlimited approval. Revoking is done by calling approve with a zero amount from the owner’s wallet, typically through a wallet interface rather than by hand.
Source: https://getfoundry.sh/cast/reference/
MEV is the value that can be extracted by reordering, inserting or censoring transactions before they are finalised. On a DEX, a pending swap is visible in the mempool, and a searcher can place a trade ahead of it to move the pool price, then reverse the position after the victim’s trade executes. This is a sandwich attack. The victim’s minimum-output setting is the main defence: a tight limit makes the sandwich unprofitable because the manipulated price would breach it and the swap would revert. Private transaction submission, where available, removes the pending transaction from public view.
What each route is and is not suited to
The table compares the two structures by mechanism, including the cases where each is the wrong tool.
| Property | Centralized exchange | Decentralized exchange | When this route is the wrong choice |
|---|---|---|---|
| Custody | Exchange holds assets on its ledger | Assets remain in your wallet between transactions | CEX: you need to hold the asset without relying on a third party’s solvency. DEX: you cannot manage keys safely |
| Matching | Order book, depth-dependent fills | AMM pool, slippage-dependent fills | CEX: you need to trade a token the exchange does not list. DEX: the pool is too thin for your size |
| Identity | Verification required | No account, address only | CEX: you cannot or will not complete verification. DEX: you need fiat settlement or a legal counterparty |
| Recovery | Support can act on the account | No recovery; keys are the only access | CEX: you want no third party able to freeze the balance. DEX: you need recourse after an error |
| Failure mode | Insolvency, withdrawal halt, account freeze | Contract bug, pool drain, approval exploit, MEV | CEX: you cannot tolerate the exchange’s balance-sheet risk. DEX: you cannot tolerate smart-contract risk |
| Cost structure | Trading fee, spread, withdrawal fee | Pool fee, gas, slippage | CEX: internal transfers are cheap but withdrawals are not. DEX: small trades can be dominated by gas |
The misconception that a DEX removes counterparty risk
A DEX removes the exchange as a custodian, not the counterparty as a concept. The pool is the counterparty, and the pool is a contract with code, dependencies and a price formula that can be moved by large trades. The risk is different in kind, not absent. A user who moves from a CEX to a DEX without checking pool depth, approval scope and minimum-output settings has changed which failure mode they are exposed to, not eliminated failure.
How to read the screen in front of you
On a CEX withdrawal screen, the fields that matter are the network, the destination address and the fee. A token sent on the wrong network to a CEX deposit address may be unrecoverable, because the exchange credits only the network it associates with that address. The withdrawal page usually states which networks are supported; the destination address format is the check.
On a DEX swap screen, the fields that matter are the pool being routed through, the price impact, the minimum received and the approval being requested. Price impact is the slippage the trade itself causes; minimum received is the floor the transaction enforces. An approval request for an unlimited amount is a standing permission, not a one-time authorisation, and it should be read as such.
Neither screen tells you whether the venue is solvent or the contract is correct. Those are questions about the counterparty, and they are answered outside the interface.
Common questions
What is the main difference between a CEX and a DEX?
A centralized exchange holds your assets on its own ledger and matches orders internally, so your balance is a claim on the exchange. A decentralized exchange is a set of smart contracts that swap tokens directly between wallets, so the assets stay in your control between transactions. The trade-off is counterparty risk on one side and contract and approval risk on the other.
Do I need to verify identity to use a DEX?
Most DEX contracts have no account system and do not collect identity documents; they see only the address that calls them. Some front-end interfaces apply their own restrictions depending on jurisdiction. A CEX, by contrast, generally requires verification before deposits or withdrawals.
Why does a DEX swap sometimes fail or fill at a worse price?
AMM pools price trades by their reserve ratio, so a large trade moves the price against itself, which is slippage. The swap transaction includes a minimum-output limit; if the pool moves past that limit before execution, the transaction reverts and gas is still spent. A loose limit makes the fill more likely but accepts a worse price.
What is a token approval and why does it matter?
An approval is an allowance that lets a contract move a specific token from your wallet. Many interfaces request an unlimited amount, which persists after the trade. If that contract is later exploited, the approval is a route to your balance, so approvals are worth reviewing and revoking when no longer needed.
Is a DEX safer than a CEX?
Neither is categorically safer; the failure modes differ. A CEX exposes you to the exchange's solvency and to account freezes. A DEX exposes you to contract bugs, pool manipulation, approval exploits and MEV. The right question is which failure mode you can assess and tolerate for a given trade.
Sources
Read next
- What DeFi Is: Smart Contracts That Call Each Other DeFi is a set of smart contracts for lending, trading and stablecoins that call each other. How the pieces fit, and where composability turns into risk.
- What Web3 Means: Keys, Signatures, and Centralized Edges Web3 explained: how wallet signatures replace logins, where assets actually live, and which parts of a dapp (front end, RPC, indexer) usually stay centralized.
- Wrapped Tokens: How They Work and What You Own Wrapped tokens represent an asset on another chain or a native coin as a token. Learn what the holder owns, how redemption works, and what can break it.
- What a Seed Phrase Actually Is Learn what a seed phrase really is: the master key to all your crypto. Understand how it works, why it's not a password, and how to keep it safe.
- What Crypto Tax Software Actually Does Learn how crypto tax software imports transactions, matches transfers, and applies cost basis. Understand its limitations and what you must verify manually.