Overview

Understanding the four swap routing strategies

DexAggregator automatically detects and implements the optimal swap type based on liquidity distribution and routing efficiency. Understanding these types helps you interpret the routing logic and optimize your integrations.

The Four Swap Types

Type
Structure
Use Case
Complexity

TokenA → [DEX] → TokenB

Direct swap via single DEX

Low

Multiple DEXes in parallel

Split liquidity for better rates

Medium

Sequential swaps through tokens

No direct liquidity pool

Medium

Parallel routes with internal hops

Complex routing optimization

High

Quick Comparison

Simple Swap

WBNB ─────[PancakeSwapV3]────→ USDT
      (100% of liquidity)

When used: Direct pool exists with sufficient liquidity

Batch Swap

WBNB ─────[PancakeSwapV3 60%]────→ USDT
     └────[UniswapV2 40%]─────────┘

When used: Multiple pools offer competitive rates

Multi-Hop Swap

When used: No direct TokenA-USDT pool exists

Parallel Multi-Hop

When used: Complex routing through multiple intermediate paths

Automatic Detection

The API automatically selects the optimal swap type:

  1. Analyze Route Structure - Examine KyberSwap's routing recommendation

  2. Calculate Split Ratios - Determine liquidity distribution

  3. Select Swap Type - Choose the most efficient encoding

  4. Generate Calldata - Encode parameters for smart contract

Detection Logic

Response Field: swapType

Every response includes the detected swap type:

Gas Costs by Type

Swap Type
Typical Gas
Description

Simple

100k-150k

Lowest gas cost

Batch

150k-250k

Scales with number of splits

Multi-Hop

200k-300k

Depends on hop count

Parallel Multi-Hop

300k-500k

Most complex, highest gas

Gas Optimization

Gas costs are estimates. Actual costs depend on:

  • Number of token swaps

  • DEX protocol complexity (V2 vs V3)

  • Current network congestion

Choosing Swap Types

When Simple is Best

  • ✅ Direct liquidity pool exists

  • ✅ Single pool has sufficient depth

  • ✅ Lowest gas cost priority

When Batch is Better

  • ✅ Multiple competitive price sources

  • ✅ Large swap amounts

  • ✅ Price improvement > gas cost

When Multi-Hop is Needed

  • ✅ No direct pool available

  • ✅ Intermediate token has deep liquidity

  • ✅ Common routing pattern (e.g., via WETH)

When Parallel Multi-Hop Wins

  • ✅ Very large swap amounts

  • ✅ Single path has insufficient depth

  • ✅ Multiple intermediate routing options

Examples by Token Pair

Exotic Pairs (Multi-Hop)

Large Amounts (Parallel Multi-Hop)

Route Visualization

The routeInfo field provides detailed routing breakdown:

Simple Swap

Batch Swap

Multi-Hop Swap

Understanding Percentages

In Batch and Parallel Multi-Hop swaps, percentages indicate liquidity split:

The smart contract handles the splitting automatically based on executorData.

Best Practices

Deep Dive Pages

Learn more about each swap type:

Last updated