IRouter
Title: Router Interface
Author: Async Labs
This interface defines the functions for the Router contract, which allows users to swap tokens and fill orders using async orders.
Functions
swap
Swaps tokens using an async order.
function swap(AsyncOrder calldata order, bytes calldata userData) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
order | AsyncOrder | The async order to be placed. |
userData | bytes | Additional data for the user, allowing user to specify an executor. |
fillOrder
Fills an async order.
function fillOrder(AsyncOrder calldata order, bytes calldata userData) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
order | AsyncOrder | The async order to be filled. |
userData | bytes | Additional data for the user, allowing user to specify an executor. |
withdraw
function withdraw(PoolKey memory key, bool zeroForOne, uint256 amount) external;
multicall
Execute multiple orders with graceful failure handling.
Individual order failures don't revert the entire transaction.
function multicall(AsyncOrder[] calldata orders, bytes[] calldata ordersData)
external
payable
returns (bool[] memory results);
Parameters
| Name | Type | Description |
|---|---|---|
orders | AsyncOrder[] | Array of orders to execute. |
ordersData | bytes[] | Array of filler data corresponding to each order. |
Returns
| Name | Type | Description |
|---|---|---|
results | bool[] | Array of booleans indicating success/failure for each order. |
Structs
SwapCallback
Callback structure for the swap function.
struct SwapCallback {
ActionType action;
AsyncOrder order;
uint256 amountOut;
}
Properties
| Name | Type | Description |
|---|---|---|
action | ActionType | The action type, either Swap or FillOrder. |
order | AsyncOrder | The async order that is in context for the swap or fill operation. |
amountOut | uint256 | The amount the filler is offering (only used for FillOrder action). |
WithdrawCallback
struct WithdrawCallback {
ActionType action;
PoolKey key;
bool zeroForOne;
uint256 amount;
address user;
}
MulticallCallback
struct MulticallCallback {
ActionType action;
AsyncOrder[] orders;
bytes[] ordersData;
}
Enums
ActionType
Enum representing the action type for the swap callback.
- Swap - If the action is a swap, this will specify the async swap order intent.
- FillOrder - If the action is a fill order, this will specify fill order intent.
- Withdrawal - If the action is a withdrawal, this will specify withdrawal intent.
- Multicall - If the action is a multicall, this will specify multicall intent.
enum ActionType {
Swap,
FillOrder,
Withdrawal,
Multicall
}