Skip to content
LogoLogo

IncomingMatching

Git Source

Fund a crossing arrival, match it in memory, then index only its remainder.

Active LP pools retain the existing storage path. Pending orders cannot match before funding.

Constants

STAGE

bytes32 private constant STAGE = keccak256("asyncswap.incoming.record");

POOL

bytes32 private constant POOL = keccak256("asyncswap.incoming.pool");

ID

bytes32 private constant ID = keccak256("asyncswap.incoming.id");

Functions

pending

function pending(PoolId poolId) public view returns (bool result);

Parameters

NameTypeDescription
poolIdPoolId

Returns

NameTypeDescription
resultbool

addOrder

Shared stored-admission wrapper. Keeping it here avoids duplicating admission bytecode in AsyncMatching, which only needs reductions and settlement for existing orders.

function addOrder(AsyncFiller.State storage self, AsyncFiller.Book storage book, AsyncFiller.NewOrder memory order)
        public;

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
orderAsyncFiller.NewOrder

stage

function stage(AsyncFiller.State storage self, AsyncFiller.Book storage book, AsyncFiller.NewOrder memory order)
        public;

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
orderAsyncFiller.NewOrder

_canCross

Resting-only arrivals keep ordinary admission. The memory bridge pays off when an opposite order crosses; repeat full selection after funding because callbacks can reprice.

function _canCross(AsyncFiller.Book storage book, AsyncFiller.NewOrder memory order) private view returns (bool);

Parameters

NameTypeDescription
bookAsyncFiller.Book
orderAsyncFiller.NewOrder

Returns

NameTypeDescription
<none>bool

matchNewOrder

Delegatecall keeps escrow and the LP self-call in the hook context, while moving venue orchestration out of the hook's size-constrained runtime. Funding/auth stay in the Router/hook.

function matchNewOrder(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        AsyncOrder calldata order,
        bytes32 id
    ) public returns (uint8 matched);

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
orderAsyncOrder
idbytes32

Returns

NameTypeDescription
matcheduint8

_poolBeatsBook

The pool goes first only while its adjusted price beats the best opposite level. An equal level or empty opposite side leaves the book first; the existing LP limit is unchanged.

function _poolBeatsBook(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        PoolKey calldata key,
        bool isBuy
    ) private view returns (bool, uint160);

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
keyPoolKey
isBuybool

Returns

NameTypeDescription
<none>bool
<none>uint160

_matchPending

function _matchPending(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        PoolKey calldata key,
        bytes32 id,
        address owner
    ) private returns (bool handled, uint8 matched);

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
keyPoolKey
idbytes32
owneraddress

Returns

NameTypeDescription
handledbool
matcheduint8

_load

function _load(bytes32 id, address owner) private returns (AsyncFiller.OrderInfo memory incoming);

Parameters

NameTypeDescription
idbytes32
owneraddress

Returns

NameTypeDescription
incomingAsyncFiller.OrderInfo

_crosses

function _crosses(
        AsyncFiller.State storage self,
        AsyncFiller.OrderInfo memory incoming,
        bytes32 id,
        bytes32 bid,
        bytes32 ask
    ) private view returns (bool);

Parameters

NameTypeDescription
selfAsyncFiller.State
incomingAsyncFiller.OrderInfo
idbytes32
bidbytes32
askbytes32

Returns

NameTypeDescription
<none>bool

_persist

function _persist(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        bytes32 id,
        AsyncFiller.OrderInfo memory info
    ) private;

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
idbytes32
infoAsyncFiller.OrderInfo

_best

function _best(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        AsyncFiller.OrderInfo memory incoming,
        bytes32 id,
        bool buy
    ) private view returns (bytes32);

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
incomingAsyncFiller.OrderInfo
idbytes32
buybool

Returns

NameTypeDescription
<none>bytes32

_match

function _match(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        PoolKey calldata key,
        bytes32 id,
        AsyncFiller.OrderInfo memory incoming,
        bytes32 bid,
        bytes32 ask,
        ClaimTransfers.Batch memory batch
    ) private returns (bool);

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
keyPoolKey
idbytes32
incomingAsyncFiller.OrderInfo
bidbytes32
askbytes32
batchClaimTransfers.Batch

Returns

NameTypeDescription
<none>bool

_reduce

function _reduce(
        AsyncFiller.State storage self,
        AsyncFiller.Book storage book,
        PoolKey calldata key,
        bytes32 id,
        AsyncFiller.OrderInfo memory info,
        uint256 consumed,
        ClaimTransfers.Batch memory batch
    ) private returns (uint256 refund);

Parameters

NameTypeDescription
selfAsyncFiller.State
bookAsyncFiller.Book
keyPoolKey
idbytes32
infoAsyncFiller.OrderInfo
consumeduint256
batchClaimTransfers.Batch

Returns

NameTypeDescription
refunduint256