Multi-Hop Swap

Sequential swaps through intermediate tokens

Multi-Hop Swap routes trades through one or more intermediate tokens when no direct liquidity pool exists between the input and output tokens.

Structure

TokenA ──[DEX 1]──> TokenB ──[DEX 2]──> TokenC
       (Hop 1)              (Hop 2)

Characteristics:

  • Sequential token swaps

  • Uses intermediate "bridge" tokens (WBNB, WETH, USDT, etc.)

  • Single path through multiple pools

  • Necessary when direct pair doesn't exist

When Multi-Hop is Used

The API automatically selects Multi-Hop when:

No direct pool - TokenA/TokenC pool doesn't exist ✅ Intermediate liquidity - Strong pools for TokenA→TokenB and TokenB→TokenC ✅ Common bridge token - TokenB is a major token (WBNB, USDT, BUSD) ✅ Better than alternatives - More efficient than batch splitting

Common Routing Patterns

Pattern 1: Through Native Token

Most common pattern for tokens without USDT pair.

Pattern 2: Through Stablecoin

Common for stablecoin swaps or tokens with better stablecoin liquidity.

Pattern 3: Extended Hop (Rare)

Used when TokenA has no USDT pool but has WBNB pool.

Example Response

Real Example: CAKE → USDT

Breakdown:

  • Hop 1: 100 CAKE → 2.5 WBNB (via PancakeSwapV3)

  • Hop 2: 2.5 WBNB → 580.12 USDT (via UniswapV2)

  • Total Gas: 220k (vs 120k for simple)

Smart Contract Encoding

MultiHopSwapParams Structure

Execution Flow

Gas Costs

Hops
BSC Gas
Ethereum Gas
vs Simple

2 hops

200k-250k

220k-300k

+80-130k

3 hops

280k-350k

320k-450k

+160-230k

4 hops

350k-450k

420k-600k

+230-330k

Gas increases with:

  • Number of hops

  • DEX protocol complexity (V3 > V2)

  • Token transfer costs

Example Calculation:

Advantages

✅ Enables Unavailable Swaps

Without multi-hop, many token pairs would be impossible:

✅ Accesses Deep Liquidity

Bridge tokens have the deepest liquidity:

✅ Predictable Routing

Standard routing patterns:

  • Most tokens have WBNB pair

  • WBNB has pairs with all major tokens

  • Easy to predict and understand

Limitations

❌ Higher Gas Costs

Each hop adds ~80-100k gas:

❌ Compounding Slippage

Each hop has its own slippage:

Must set higher slippage tolerance!

❌ Increased Failure Risk

Any hop can fail:

  • Bridge token price spike

  • Intermediate pool depleted

  • MEV attack on any hop

Atomic execution means one failure = entire swap reverts.

❌ Higher Price Impact

Affects two pools instead of one:

Code Examples

JavaScript Implementation

Python Implementation

Best Practices

✅ Higher Slippage Tolerance

Multi-hop needs more buffer:

✅ Verify Bridge Token Liquidity

Check intermediate pools before executing:

✅ Monitor Bridge Token Prices

Sudden bridge token price moves affect your swap:

✅ Set Appropriate Deadline

Longer paths need more time:

Troubleshooting

Issue: "Insufficient output amount" Error

Causes:

  • Slippage too tight for multi-hop

  • Bridge token price moved

  • One pool had high price impact

Solution:

Issue: One Hop Fails, TX Reverts

Diagnose which hop:

Issue: Worse Rate Than Expected

Check:

  • Bridge token arbitrage opportunities

  • MEV bots front-running

  • Recent price movements

Solution:

  • Use private transaction relay (Flashbots, BloXroute)

  • Add MEV protection

  • Increase slippage slightly

Comparison with Other Types

Feature
Simple
Multi-Hop
Batch

Direct pair needed

✅ Yes

❌ No

✅ Yes

Gas cost

⭐⭐⭐⭐⭐ Lowest

⭐⭐⭐ Medium

⭐⭐ Higher

Slippage

⭐⭐⭐⭐ Low

⭐⭐⭐ Medium

⭐⭐⭐⭐ Low

Complexity

⭐ Simple

⭐⭐⭐ Medium

⭐⭐⭐⭐ Complex

Use case

Common pairs

Exotic pairs

Large orders

Summary

Multi-Hop Swap is ideal for:

  • ✅ Token pairs without direct pools

  • ✅ Accessing deeper liquidity through bridge tokens

  • ✅ Swapping exotic/new tokens

  • ✅ When indirect routing provides better rates

Not recommended for:

  • ❌ High-frequency trading (gas cost)

  • ❌ Very tight slippage requirements

  • ❌ During bridge token volatility

  • ❌ When direct pool exists with good liquidity

Last updated