Skip to main content

Overview

dKit’s routing engine intelligently finds the most efficient path for your swaps, whether direct or through multiple hops. The system considers factors like liquidity, fees, slippage, and execution time to optimize your trades.

Route Types

Direct Routes

Single-hop swaps within one provider: Characteristics:
  • Single transaction
  • Lower complexity
  • Predictable fees
  • Faster execution
Example:

Multi-Leg Routes

Swaps requiring multiple steps within a provider: Characteristics:
  • Multiple swaps in one transaction
  • Optimized routing through liquidity pools
  • Higher gas costs on EVM chains
  • Better rates for illiquid pairs

DEX Aggregation Routes

Cross-provider routes combining different protocols: Characteristics:
  • Multiple transactions across chains
  • Combines strengths of different providers
  • Enables otherwise impossible swaps
  • Requires careful tracking

Route Discovery Process

1. Asset Analysis

The routing engine first analyzes the assets:

2. Provider Selection

Based on asset analysis, relevant providers are identified:

3. Route Calculation

Each provider calculates possible routes:
  • Liquidity depth at each hop
  • Price impact based on swap size
  • Fee structure (network, protocol, LP fees)
  • Execution time estimates

4. Route Optimization

Routes are ranked by:
  1. Output amount (after all fees)
  2. Execution speed
  3. Route complexity
  4. Security considerations

Route Metadata

Each route includes rich metadata for decision-making:

Price Impact

Thresholds:
  • < 0.1% - Negligible impact
  • 0.1% - 1% - Low impact
  • 1% - 3% - Moderate impact
  • 3% - 5% - High impact
  • > 5% - Very high impact

Route Tags

Routes are tagged for easy identification:

Time Estimates

Complex Routing Examples

Cross-Chain Token to Token

Swapping USDC on Ethereum to USDC on Solana: Route Structure:

Arbitrage Routes

Finding profitable paths between assets:

Route Selection Strategies

Optimizing for Speed

Optimizing for Output

Balanced Optimization

Streaming Routes

For large swaps, THORChain automatically creates streaming routes:
Benefits:
  • Reduced price impact
  • Better execution price
  • Protection against manipulation
Trade-offs:
  • Longer execution time
  • Multiple transactions
  • Complex tracking

Route Warnings

Routes may include warnings about potential issues:
Common warning codes:
  • HIGH_PRICE_IMPACT - Significant market impact
  • LOW_LIQUIDITY - Shallow pools
  • LONG_EXECUTION - Extended completion time
  • REQUIRES_APPROVAL - Token approval needed
  • EXPERIMENTAL_ROUTE - New or untested path

Route Execution

Pre-execution Checks

Transaction Building

Different routes require different transaction formats:

Route Monitoring

Track multi-leg route progress:

Best Practices

  1. Always check route validity before execution
  2. Monitor expiration times for time-sensitive routes
  3. Implement fallback routes for critical swaps
  4. Cache route calculations for repeated queries
  5. Use appropriate slippage based on route complexity
  6. Track all legs of multi-hop routes
  7. Handle partial fills gracefully