Router
Inherits: IRouter
Author: Async Labs
This contract implements the Router interface, allowing users to swap tokens and fill async orders through the PoolManager and Async Swap hook.
State Variables
POOLMANAGER
PoolManager contract to interact with the pools.
IPoolManager immutable POOLMANAGER
HOOK
Async Swap Hook contract to execute async orders.
IAsyncSwapAMM immutable HOOK
ACTION_LOCATION
keccak256("Router.ActionType") - 1
bytes32 constant ACTION_LOCATION = 0xf3b150ebf41dad0872df6788629edb438733cb4a5c9ea779b1b1f3614faffc69
USER_LOCATION
keccak256("Router.User") - 1
bytes32 constant USER_LOCATION = 0x3dde20d9bf5cc25a9f487c6d6b54d3c19e3fa4738b91a7a509d4fc4180a72356
ASYNC_FILLER_LOCATION
keccak256("Router.AsyncFiller") - 1
bytes32 constant ASYNC_FILLER_LOCATION = 0xd972a937b59dc5cb8c692dd9f211e85afa8def4caee6e05b31db0f53e16d02e0
Functions
constructor
Initializes the Router contract with the PoolManager and Async CSMM hook.
constructor(IPoolManager _poolManager, IAsyncSwapAMM _hook) ;
Parameters
| Name | Type | Description |
|---|---|---|
_poolManager | IPoolManager | The PoolManager contract that manages the pools. |
_hook | IAsyncSwapAMM | The Async CSMM hook contract that executes async orders. |
onlyPoolManager
Only allow the PoolManager to call certain functions.
modifier onlyPoolManager() ;
_checkCallerIsPoolManager
function _checkCallerIsPoolManager() internal view;
swap
Swaps tokens using an async order.
function swap(AsyncOrder calldata order, bytes memory userData) external;
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) external;
Parameters
| Name | Type | Description |
|---|---|---|
order | AsyncOrder | The async order to be filled. |
<none> | bytes |
unlockCallback
Callback handler to unlock the PoolManager after a swap or fill order.
function unlockCallback(bytes calldata data) external onlyPoolManager returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
data | bytes | The callback data containing the action type and order information. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | Data to return back to the PoolManager after unlock. |