πŸ“—Aggregator

Aggregator Contract API Documentation

Overview

The Aggregator contract is a smart contract that handles token swaps, cross-chain bridging, and batch transfers. It implements an upgradeable pattern and includes the following security features:

  • Pausable functionality (emergency stop)

  • Reentrancy protection

  • Access control through ownership

Core Methods

executeSwap

Function: Execute token swap

Parameters:

struct SwapRequest {
    address inputToken;    // Input token address
    address outputToken;   // Output token address
    uint256 inputAmount;   // Input amount
    uint256 minOutputAmount; // Minimum output amount
    uint256 feeAmount;     // Fee amount
    address feeRecipient;  // Fee recipient address
    address recipient;     // Recipient address
    bool unwrapped;        // Whether to unwrap WETH
    bytes extData;        // Extended data
}

struct Call {
    address target;        // Target contract address
    bytes callData;       // Call data
    uint256 value;        // Transfer amount
}

Example:

Notes:

  1. Input amount must be greater than 0

  2. Fee amount cannot exceed input amount

  3. For ETH swaps, msg.value must equal inputAmount

  4. Output amount must be greater than minOutputAmount

  5. feeAmount can be set to 0 to indicate no fee, in which case feeRecipient must also be set to the 0 address

  6. When real-time commission is needed, feeAmount and feeRecipient parameters can be passed

executeBridge

Function: Execute cross-chain bridge

Parameters:

Example:

Notes:

  1. Input amount must be greater than 0

  2. Fee amount cannot exceed input amount

  3. For ETH bridges, msg.value must equal inputAmount

  4. Recipient address cannot be 0

  5. feeAmount can be set to 0 to indicate no fee, in which case feeRecipient must also be set to the 0 address

  6. When real-time commission is needed, feeAmount and feeRecipient parameters can be passed

extData Generation Instructions

The extData field is used to pass extended data, formatted as a hexadecimal representation of URL-encoded parameters.

Field Mapping:

Generation Example:

Notes:

  1. All values will be converted to string type

  2. Empty or undefined fields will be ignored

  3. The final result is a hexadecimal string of URL-encoded parameters

Last updated

Was this helpful?