DEX (Decentralized Exchange)¶
Overview¶
DEX (Decentralized Exchange) is a cryptocurrency trading platform built on blockchain smart contracts. Unlike CEXs (Centralized Exchanges such as Binance, Coinbase), DEXs do not rely on third-party intermediaries to custody user funds or match trades. Users interact directly with on-chain contracts through non-custodial wallets (such as MetaMask) to achieve peer-to-peer asset swaps.
DEXs are a core pillar of the DeFi (Decentralized Finance) ecosystem, embodying the blockchain ethos of being permissionless, censorship-resistant, and non-custodial.
Core Trading Models¶
DEXs primarily employ the following trading models:
1. Automated Market Maker (AMM)¶
The most mainstream DEX model currently. - Mechanism: Uses algorithmic pricing through Liquidity Pools to provide instant trading. Users trade with smart contracts rather than with other users. - Formula: The most classic is \(x \cdot y = k\) (constant product formula). - Roles: * Trader: Pays fees to swap tokens. * Liquidity Provider (LP): Deposits assets into the pool and earns trading fees. - Representative Projects: Uniswap, Curve, Balancer, PancakeSwap.
2. Order Book¶
Mimics the traditional financial market model, maintaining lists of buy and sell orders. - On-chain Order Book: All orders and matching occur on-chain, with high transparency but limited by blockchain TPS and Gas fees (e.g., early EtherDelta, many DEXs on Solana now). - Hybrid/Off-chain Order Book: Order matching occurs on off-chain servers, with only final settlement going on-chain to improve speed and reduce costs (e.g., dYdX, 0x Protocol). - Representative Projects: dYdX (derivatives), Serum (Solana), Loopring.
3. Aggregators (DEX Aggregators)¶
Do not own their own liquidity but search multiple DEXs for the best prices and routes, helping users complete trades with minimal slippage. - Representative Projects: 1inch, ParaSwap, CoW Swap.
Core Features¶
- Non-custodial: Users always control their private keys and funds, eliminating the risk of exchange exit scams or fund misappropriation.
- Permissionless: Anyone can access without KYC (identity verification) restrictions; anyone can create trading pairs for any token (in the AMM model).
- On-chain Transparency: All trading records and liquidity data are publicly verifiable.
- Composability: DEX protocols can be integrated by other DeFi applications (such as lending protocols, yield aggregators).
Challenges¶
- Impermanent Loss: In the AMM model, LPs may suffer losses relative to simply holding tokens when token prices fluctuate dramatically.
- Slippage: Large trades may cause the execution price to significantly deviate from the market price.
- MEV (Maximal Extractable Value): Miners or arbitrage bots can profit from ordinary users' trades through front-running or sandwich attacks.
- Transaction Speed and Cost: Limited by the underlying blockchain's performance, DEXs on Layer 1 may face congestion and high Gas fees.
Related Concepts¶
- Liquidity Mining: DEX protocols incentivize users to provide liquidity by distributing governance tokens.
- TVL (Total Value Locked): An important metric measuring DEX liquidity depth.