Decentralized exchanges allow you to trade cryptocurrencies directly from your wallet without intermediaries. They're a cornerstone of DeFi.
What is a DEX?
Definition
DEX:
- Exchange without central operator
- Trade directly peer-to-peer
- Smart contract powered
- Non-custodial
Key Features
Characteristics:
- No account registration
- No KYC required
- Control your funds
- Transparent pricing
- Permissionless trading
DEX vs Centralized Exchange
Comparison
| Feature | CEX | DEX |
|---|---|---|
| Custody | Exchange holds | You hold |
| KYC | Required | Not required |
| Listing | Curated | Permissionless |
| Privacy | Limited | Higher |
| Speed | Faster | Variable |
| Fees | Trading fees | Gas + fees |
| Support | Customer service | Community |
Trade-offs
CEX Advantages:
- Faster execution
- Lower fees often
- Fiat on/off ramps
- Customer support
DEX Advantages:
- No KYC
- Self-custody
- Access to more tokens
- Cannot be hacked (no custody)
How DEXs Work
Automated Market Makers (AMM)
Concept:
- No order book
- Liquidity pools
- Algorithmic pricing
- Instant trades
How It Works:
- Traders swap against pools
- Price based on pool ratio
- Formula: x * y = k
- Always available liquidity
Liquidity Pools
Structure:
- Paired tokens (e.g., ETH/USDC)
- Deposited by liquidity providers
- Earn trading fees
- Enable swaps
Pricing Mechanism
Constant Product Formula:
- x * y = k
- x = amount of token A
- y = amount of token B
- k = constant
Example:
- Pool: 10 ETH + 10,000 USDC
- k = 100,000
- Buy 1 ETH → Price increases
- Pool ratio changes
Major DEXs
Uniswap
Overview:
- Largest DEX
- Pioneered AMM model
- Ethereum + L2s
- UNI governance token
Features:
- V3 concentrated liquidity
- Multiple fee tiers
- Most liquid pools
Curve Finance
Overview:
- Stablecoin focused
- Low slippage
- CRV token
Specialty:
- Stablecoin swaps
- Like-asset trades
- Minimal slippage
SushiSwap
Overview:
- Uniswap fork
- Multi-chain
- Additional features
- SUSHI token
PancakeSwap
Overview:
- BNB Chain largest
- Lower fees
- CAKE token
Comparison
| DEX | Chain | Specialty |
|---|---|---|
| Uniswap | Ethereum, L2s | General purpose |
| Curve | Multi-chain | Stablecoins |
| Balancer | Multi-chain | Custom pools |
| GMX | Arbitrum | Perpetuals |
Using a DEX
Basic Swap
Process:
- Connect wallet
- Select tokens (from/to)
- Enter amount
- Review price impact
- Approve token (first time)
- Confirm swap
- Wait for confirmation
Important Settings
Slippage Tolerance:
- Maximum price change allowed
- Too low = failed transactions
- Too high = worse prices
- Typical: 0.5-1%
Transaction Deadline:
- Maximum time for trade
- Protects against stale prices
Gas Considerations
Factors:
- Gas fees on top of swap
- Variable by network activity
- Can be significant on Ethereum
- L2s much cheaper
Price Impact and Slippage
Price Impact
Definition:
- Your trade's effect on price
- Larger trades = more impact
- Small pools = more impact
Example:
- Small swap: 0.1% impact
- Large swap: 5%+ impact
- Very large: May not be viable
Slippage
Definition:
- Difference from expected price
- Due to price movement
- Other trades during yours
- Set tolerance appropriately
Managing Both
Strategies:
- Split large trades
- Use aggregators
- Choose liquid pools
- Trade off-peak times
DEX Aggregators
What Are They?
Function:
- Compare prices across DEXs
- Find best rates
- Split orders for better pricing
- Single interface
Popular Aggregators
Options:
- 1inch
- Paraswap
- Cowswap
- Matcha
Benefits
Advantages:
- Best price discovery
- Optimized routing
- Gas efficiency
- Convenience
DEX Risks
Smart Contract Risk
Concern:
- Bugs in code
- Exploits possible
- Audit helps but not guarantee
Front-Running
Problem:
- Others see your transaction
- Execute before you
- Worse price for you
- MEV bots
Impermanent Loss
Concern:
- For liquidity providers
- Price divergence causes loss
- Covered in next section
Fake Tokens
Warning:
- Anyone can create tokens
- Scam tokens common
- Verify contract addresses
- Use official links
Safety Practices
Before Swapping
Verify:
- Correct contract address
- Official website used
- Reasonable slippage
- Gas cost acceptable
Token Verification
Check:
- CoinGecko/CMC links
- Official project site
- Contract on explorer
- Community verification
Red Flags
Warning Signs:
- Can't sell (honeypot)
- High taxes on trades
- Unknown tokens
- Too good to be true
Advanced Features
Limit Orders
Some DEXs Offer:
- Set target price
- Execute when reached
- More control
- Less common in AMM
Cross-Chain Swaps
Bridges:
- Trade across chains
- Additional risk
- Often through bridges
Perpetual DEXs
Examples:
- dYdX
- GMX
- Futures trading
- Leverage available
Key Takeaways
- DEXs enable trading without intermediaries
- AMMs use liquidity pools instead of order books
- No KYC, self-custody of funds
- Price impact increases with trade size
- Slippage tolerance protects against price changes
- Aggregators find best prices
- Verify token contracts to avoid scams
- Gas fees can be significant on Ethereum
What's Next?
Learn about yield farming and how to earn rewards in DeFi.
This article is for educational purposes only and does not constitute financial advice.