GluexRouter v1
The GluexRouter
smart contract provides versatile functionality for routing tokens, collecting fees, and executing
on-chain interactions through a structured interface. This contract is designed for high security and usability,
ensuring strict adherence to routing and slippage rules.
Deployment
The GluexRouter
contract is deployed at the following address:
Contract Address: 0xaF6Dd700b655D100e56201b92B29BD7A9E406CEB
Availability on Chains
Check the chains where GlueX Router is currently available here. This provides up-to-date information about the supported chains.
Functions
swap
Executes a token routing operation through an external IExecutor
contract using a predefined set of interactions.
Parameters
executor
(IExecutor
): The executor contract responsible for processing interactions.desc
(RouteDescription calldata
): A structured object containing input/output token information, fees, limits, and recipient addresses.interactions
(Interaction[] calldata
): An array of interaction steps to be executed by the executor.
Returns
finalOutputAmount
(uint256
): The final amount of output token received by theoutputReceiver
after fees and surplus/slippage sharing.
Reverts
InvalidNativeTokenInputAmount
: If the ETH value sent does not match the expected input amount.RoutingFeeTooHigh
: Ifdesc.routingFee
exceeds the maximum allowed fee (_MAX_FEE
).RoutingFeeTooLow
: Ifdesc.routingFee
is below the minimum required fee (_MIN_FEE
).PartnerSurplusShareTooHigh
: Ifdesc.partnerSurplusShare
exceeds_MAX_PARTNER_SURPLUS_SHARE_LIMIT
.ProtocolSurplusShareTooLow
: Ifdesc.protocolSurplusShare
is below_MIN_PROTOCOL_SURPLUS_SHARE_LIMIT
.PartnerSlippageShareTooHigh
: Ifdesc.partnerSlippageShare
exceeds_MAX_PARTNER_SLIPPAGE_SHARE_LIMIT
.ProtocolSlippageShareTooLow
: Ifdesc.protocolSlippageShare
is below_MIN_PROTOCOL_SLIPPAGE_SHARE_LIMIT
.ZeroAddress
: If any required address (e.g.inputReceiver
,outputReceiver
) is a zero address.InvalidSlippage
: Ifdesc.minOutputAmount
is zero.SlippageLimitTooLarge
: Ifdesc.minOutputAmount
exceedsdesc.outputAmount
.InsufficientBalance
: If the router does not hold sufficient balance for the intended transfer.NativeTransferFailed
: If the native token transfer fails.
Event: Routed
Emitted upon successful completion of a routing operation.
Event Signature
event Routed(
bytes32 indexed uniquePID,
address indexed userAddress,
address outputReceiver,
IERC20 inputToken,
uint256 inputAmount,
IERC20 outputToken,
uint256 finalOutputAmount,
uint256 partnerFee,
uint256 routingFee,
uint256 partnerShare,
uint256 protocolShare
);
Parameters
uniquePID
(bytes): The unique identifier 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.finalOutputAmount
(uint256): The actual output amount received after routing.partnerFee
(uint256): The fee charged for the partner.routingFee
(uint256): The fee charged for the routing operation.partnerShare
(uint256): The share of surplus/slippage allocated to the partner.protocolShare
(uint256): The share of surplus/slippage allocated to the protocol.