Batch Swap
Split liquidity across multiple DEXes for optimal rates
Structure
┌──[DEX A: 60%]──┐
TokenA ──┤ ├──> TokenB
└──[DEX B: 40%]──┘How It Works
Liquidity Distribution
When Batch Swap is Used
Example Response
Real-World Example: 5 BNB → USDT
Smart Contract Encoding
BatchSwapRoute Structure
Execution Flow
Gas Costs
Routes
BSC Gas
Ethereum Gas
Additional Cost
Advantages
✅ Better Rates for Large Orders
Swap Amount
Simple Swap Impact
Batch Swap Impact
Savings
✅ Reduced Slippage Risk
✅ Access More Liquidity
✅ Automatic Optimization
Limitations
❌ Higher Gas Costs
❌ Increased Complexity
❌ Percentage Precision
Code Examples
JavaScript Implementation
Python Implementation
Best Practices
✅ Minimum Swap Amount
✅ Monitor Individual Routes
✅ Set Conservative Slippage
Troubleshooting
Issue: One Route Fails, Entire TX Reverts
Issue: Worse Rate Than Expected
Issue: High Gas Cost
Comparison Table
Metric
Simple
Batch (2 DEX)
Batch (3 DEX)
Related Topics
Summary
Last updated