Swap Types
Rainbow supports two main swap types:Same-Chain Swaps
Same-Chain Swaps exchange tokens on the same blockchain network.
- Fast execution: Single transaction
- Lower cost: Only one network’s gas fees
- Instant settlement: Immediate token receipt
- Wide token support: Thousands of tokens
Cross-Chain Swaps (Bridging)
Cross-Chain Swaps move tokens between different blockchain networks.
- Multi-step process: Bridge + swap if needed
- Higher cost: Gas on multiple networks
- Longer time: Minutes to hours
- Network flexibility: Access tokens on any chain
Swap Architecture
Rainbow uses a sophisticated swap system with shared values and reactive state:Quote Types
User Swap Flow
Select Input Token
Choose token to swap from:
- Tap input asset selector
- Search or browse tokens
- Shows your balance
- Filter by chain
Enter Amount
Specify swap amount:
- Type amount directly
- Use percentage slider (25%, 50%, 75%, 100%)
- See USD value live
- Validate sufficient balance
Select Output Token
Choose token to receive:
- Tap output asset selector
- Search tokens on any chain
- See popular suggestions
- Rainbow suggests bridged version if cross-chain
Review Quote
Rainbow fetches best quote:
- Multiple DEX aggregators queried
- Best rate automatically selected
- Shows exchange rate
- Displays estimated gas
- Indicates price impact
Adjust Settings (Optional)
Customize swap parameters:
- Slippage tolerance
- Gas speed (slow/normal/fast/urgent)
- MEV protection
- Swap source preference
Execute Swap
Complete the swap:
- Tap and hold swap button
- Approve token (if first time)
- Sign swap transaction
- Track in activity feed
Swap Settings
Customizable swap parameters:Slippage Tolerance
- How much price can change: Before transaction fails
- Basis points: 100 bips = 1%
- Default: 5% (500 bips) for most swaps
- Custom: Set your own tolerance
- Higher = more likely to succeed, worse price
- Lower = better price, more likely to fail
For volatile or low-liquidity tokens, you may need to increase slippage to 10-15% for swaps to succeed.
Gas Speed
- Normal: Default, usually confirms in 1-2 minutes
- Fast: Priority, confirms in less than 1 minute
- Urgent: Maximum priority, next block
- Custom: Set your own gas price and limit
Swap Source
Choose which aggregators to use:- Auto (default): Rainbow selects best
- Specific DEX: Force use of particular aggregator
- Rainbow Swap: Rainbow’s own routing
Quote Fetching
Quotes are fetched reactively:- Input/output asset changes
- Amount changes
- Slippage changes
- Gas settings change
- Every 12 seconds (automatic refresh)
Gas Estimation
Gas estimated before swap:- Token approval (if needed)
- Swap execution
- Cross-chain bridge (if applicable)
- Safety margin (10%)
Price Impact
Shows how swap affects market price:- Less than 1%: Low impact, good liquidity
- 1-3%: Medium impact, acceptable
- 3-5%: High impact, proceed with caution
- Greater than 5%: Very high impact, warning shown
Swap Confirmation
Before executing, review:- Amounts
- Fees
- Route
- Settings
Verify swap details:
- Input amount and token
- Output amount (minimum)
- Exchange rate
- USD values
Swap Execution
Approval Process
For ERC-20 tokens (not ETH):Check Allowance
Rainbow checks if approval needed:
- Query current allowance
- Compare with swap amount
- Skip if sufficient allowance
Request Approval
If approval needed:
- First transaction: Token approval
- User signs approval
- Wait for confirmation
Rainbow requests exact amount approval by default for security. You can enable unlimited approvals in settings if you prefer convenience over security.
Swap Status Tracking
Track swap progress:- Pending: Transaction submitted to network
- Confirming: Waiting for block confirmations
- Bridging: Cross-chain transfer in progress
- Complete: Tokens received
- Failed: Transaction reverted or rejected
Error Handling
Common swap errors:Insufficient Balance
Insufficient Balance
Error: Not enough tokens to swapSolutions:
- Reduce swap amount
- Account for gas fees
- Check you have balance on correct chain
Slippage Tolerance Exceeded
Slippage Tolerance Exceeded
Error: Price moved beyond slippage toleranceSolutions:
- Increase slippage tolerance
- Wait for less volatility
- Trade smaller amount
- Retry swap
Quote Fetch Failed
Quote Fetch Failed
Error: Cannot get swap quoteSolutions:
- Check network connection
- Verify token exists on chain
- Try different amount
- Check if pair has liquidity
Transaction Failed
Transaction Failed
Error: Swap transaction revertedSolutions:
- Check gas settings
- Increase slippage
- Verify balances
- Try again with updated quote
Best Practices
Check Multiple Quotes
Compare options:
- Let Rainbow auto-select best
- Review exchange rate
- Check gas costs
- Consider price impact
Set Appropriate Slippage
Balance risk and success:
- 0.5-1% for stable pairs
- 2-5% for standard tokens
- 5-15% for volatile/low liquidity
- Monitor for frontrunning with high slippage
Mind the Gas
Optimize costs:
- Don’t swap amounts smaller than gas cost
- Use L2s for small swaps
- Batch operations when possible
- Wait for lower gas if not urgent
Related Features
Quote Fetching
How swap quotes are obtained
Gas Estimation
Gas calculation and optimization
Atomic Swaps
Advanced atomic swap features
Assets Overview
Managing your tokens