Router Contract

The Router contract handles the execution of swaps and ensures tokens are transferred correctly between pools.

Key Features

  • Multi-hop swaps
  • Exact input/output swaps
  • Slippage protection
  • Support for native token wrapping/unwrapping

Core Functions

function exactInputSingle(ExactInputSingleParams calldata params)
external
payable
returns (uint256 amountOut);

function exactInput(ExactInputParams calldata params)
external
payable
returns (uint256 amountOut);

Architecture Overview

Security Considerations

  1. Slippage Protection
  2. Deadline Checks

Security Considerations

Our router implements two key security features that are controlled by the user during transaction construction:

1. Slippage Protection

Users can specify their maximum acceptable slippage when building a transaction. This prevents excessive value loss due to price movements or MEV attacks.

Example parameters controlled by user:

//defaults to this in all scenarios except amountOutMinimum
{
  amountOutMinimum: string
}

//used for gas zrc20 token if needed
{
  amountInMaximum: string
}

User Control

All security parameters are set during transaction construction and cannot be modified by the router contract. This gives users complete control over their risk tolerance:

  1. Slippage Tolerance: Users can set aggressive or relaxed slippage limits based on:

    • Market volatility
    • Transaction size
    • Urgency of execution
  2. Transaction Deadline: Users can set appropriate timeouts based on:

    • Network congestion
    • Transaction priority
    • Expected execution time

Best Practices

  1. Consider using our SDK’s built-in security parameter calculations