Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

AsyncFiller

Git Source

Author: Async Labs

This library provides functionality for filling async swap orders in the Uniswap V4 pool.

Functions

isExecutor

Checks if the given executor is valid for the async order.

function isExecutor(AsyncOrder calldata order, State storage self, address executor) internal view returns (bool);

Parameters

NameTypeDescription
orderAsyncOrderThe async order to be filled.
selfStateThe storage slot that controls the state of orders.
executoraddressThe address of the executor to be checked.

Returns

NameTypeDescription
<none>boolisExecutor True if the executor is valid for the async order, false otherwise.

executeOrder

Fills async orders in batching mode, allowing multiple orders to be executed in a single transaction.

function executeOrder(AsyncOrder[] calldata orders, State storage self, bytes calldata userParams) external;

Parameters

NameTypeDescription
ordersAsyncOrder[]An array of async orders to be executed.
selfState
userParamsbytesAdditional data for the user, allowing user to specify an executor.

_execute

Fill an async order in an Async Swap AMM.

function _execute(AsyncOrder calldata order, State storage self, bytes calldata) internal;

Parameters

NameTypeDescription
orderAsyncOrderThe async order to be filled.
selfStateThe state of the AsyncFiller library, containing async orders and executors.
<none>bytes

Events

AsyncOrderFilled

Emitted when an async order is filled.

event AsyncOrderFilled(PoolId poolId, address owner, bool zeroForOne, uint256 amount);

Parameters

NameTypeDescription
poolIdPoolIdThe poolId of the pool where the order is placed.
owneraddressThe owner of the order, who can claim the order.
zeroForOneboolWhether the order is for a swap from currency0 to currency1 (true) or currency1 to currency0 (false).
amountuint256The amount of the order.

Errors

InvalidOrder

Error thrown when an order is invalid.

error InvalidOrder();

ZeroFillOrder

Error thrown when an order is of zero amount.

error ZeroFillOrder();

Structs

State

Represents the state of the AsyncFiller library storage for async orders and executors.

struct State {
  IPoolManager poolManager;
  IAlgorithm algorithm;
  mapping(address user => mapping(bool zeroForOne => uint256 claimable)) asyncOrderAmount;
  mapping(address owner => mapping(address executor => bool)) isExecutor;
}

Properties

NameTypeDescription
poolManagerIPoolManagerThe PoolManager contract that manages the pools.
algorithmIAlgorithm
asyncOrderAmountmapping(address user => mapping(bool zeroForOne => uint256 claimable))
isExecutormapping(address owner => mapping(address executor => bool))