Lumaktaw papunta sa pangunahing content


This contract handles the nonce logic that is used for invalidating maker orders that exist off-chain. The nonce logic revolves around three parts at the user level: - order nonce (orders sharing an order nonce are conditional, OCO-like) - subset (orders can be grouped under a same subset) - bid/ask (all orders can be executed only if the bid/ask nonce matches the user's one on-chain) Only the order nonce is invalidated at the time of the execution of a maker order that contains it.



Magic value nonce returned if executed (or cancelled).


mapping(address => struct INonceManager.UserBidAskNonces) userBidAskNonces

This tracks the bid and ask nonces for a user address.


mapping(address => mapping(uint256 => bytes32)) userOrderNonce

This checks whether the order nonce for a user was executed or cancelled.


mapping(address => mapping(uint256 => bool)) userSubsetNonce

This checks whether the subset nonce for a user was cancelled.


function cancelOrderNonces(uint256[] orderNonces) external

This function allows a user to cancel an array of order nonces.

It does not check the status of the nonces to save gas and to prevent revertion if one of the orders is filled in the same block.


orderNoncesuint256[]Array of order nonces


function cancelSubsetNonces(uint256[] subsetNonces) external

This function allows a user to cancel an array of subset nonces.

It does not check the status of the nonces to save gas.


subsetNoncesuint256[]Array of subset nonces


function incrementBidAskNonces(bool bid, bool ask) external

This function increments a user's bid/ask nonces.

The logic for computing the quasi-random number is inspired by Seaport v1.2. The pseudo-randomness allows non-deterministic computation of the next ask/bid nonce. A deterministic increment would make the cancel-all process non-effective in certain cases (orders signed with a greater ask/bid nonce). The same quasi-random number is used for incrementing both the bid and ask nonces if both values are incremented in the same transaction. If this function is used twice in the same block, it will return the same quasiRandomNumber but this will not impact the overall business logic.


bidboolWhether to increment the user bid nonce
askboolWhether to increment the user ask nonce