The GluexRouter smart contract (version 1) facilitates secure and efficient execution of complex DeFi operations. It provides versatile functionality for routing tokens, collecting protocol fees and executing diverse onchain interactions via a structured interface. The contract prioritizes high security and usability, ensuring strict adherence to predefined routing and slippage rules

Deployment

The GluexRouter-v1 contract is deployed at the following address on the supported chains by GlueX: Contract Address: 0x6Ec7612828B776cC746fe0Ee5381CC93878844f7

Functions

Swap

Executes a token routing operation using a specified IExecutor contract and predefined interaction data. This function is the primary entry point for orchestrating multi-step DeFi flows Function Signature
function swap(
    IExecutor executor,
    RouteDescription calldata desc,
    Interaction[] calldata interactions,
    uint256 deadline
) external payable returns (uint256 finalOutputAmount);
Parameters
  • executor (IExecutor): The executor contract performing the interactions
  • desc (RouteDescription calldata): The route description containing input, output and fee details
  • interactions (Interaction[] calldata): The interactions encoded for execution by the executor
  • deadline (uint256): The timestamp after which the transaction will revert
Returns
  • finalOutputAmount (uint256): The final amount of output token received
Reverts
  • Deadline passed: If the block timestamp exceeds the deadline
  • Routing fee too high: If desc.routingFee exceeds _MAX_FEE
  • Routing fee too low: If desc.routingFee is below _MIN_FEE
  • Negative slippage limit: If desc.minOutputAmount is less than or equal to zero
  • Slippage limit too large: If desc.minOutputAmount exceeds desc.outputAmount

Events

Routed

Emitted upon the successful completion of a token routing operation Event Signature
event Routed(
    bytes indexed uniquePID,
    address indexed userAddress,
    address outputReceiver,
    IERC20 inputToken,
    uint256 inputAmount,
    IERC20 outputToken,
    uint256 outputAmount,
    uint256 partnerFee,
    uint256 routingFee,
    uint256 finalOutputAmount
);
Parameters
  • uniquePID (bytes): The unique identifier (integrator id) for the partner
  • userAddress (address): The address of the user who initiated the route
  • outputReceiver (address): The address of the receiver of the output token
  • inputToken (IERC20): The ERC20 token used as input
  • inputAmount (uint256): The amount of input token used for routing
  • outputToken (IERC20): The ERC20 token received as output
  • outputAmount (uint256): The expected output amount from the route
  • partnerFee (uint256): The fee charged for the partner
  • routingFee (uint256): The fee charged for the routing operation
  • finalOutputAmount (uint256): The actual output amount received after routing