π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:
Input amount must be greater than 0
Fee amount cannot exceed input amount
For ETH swaps, msg.value must equal inputAmount
Output amount must be greater than minOutputAmount
feeAmount can be set to 0 to indicate no fee, in which case feeRecipient must also be set to the 0 address
When real-time commission is needed, feeAmount and feeRecipient parameters can be passed
executeBridge
Function: Execute cross-chain bridge
Parameters:
Example:
Notes:
Input amount must be greater than 0
Fee amount cannot exceed input amount
For ETH bridges, msg.value must equal inputAmount
Recipient address cannot be 0
feeAmount can be set to 0 to indicate no fee, in which case feeRecipient must also be set to the 0 address
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:
All values will be converted to string type
Empty or undefined fields will be ignored
The final result is a hexadecimal string of URL-encoded parameters
Last updated
Was this helpful?