Skip to main content

LimitOrderProtocol

Derives

Structs

Order

struct Order {
uint256 salt;
Address maker;
Address receiver;
Address makerAsset;
Address takerAsset;
uint256 makingAmount;
uint256 takingAmount;
MakerTraits makerTraits;
}

Functions

constructor

constructor(
contract IWETH weth
)

Parameters:

NameTypeDescription
wethcontract IWETH

invalidatorForOrderRFQ

function bitInvalidatorForOrder(
address maker,
uint256 slot
) external view returns(uint256 result)

Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes

Parameters:

NameTypeDescription
makeraddressMaker address
slotuint256Slot number to return bitmask for

Return Values:

NameTypeDescription
resultuint256Each bit represents whether corresponding was already invalidated

remainingInvalidatorForOrder

function remainingInvalidatorForOrder(
address maker,
bytes32 orderHash
) external view returns(uint256)

Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes

Parameters:

NameTypeDescription
makeraddressMaker address
orderHashbytes32Hash of the order

Return Values:

NameTypeDescription
remaininguint256Remaining amount of the order

rawRemainingInvalidatorForOrder

function rawRemainingInvalidatorForOrder(
address maker,
bytes32 orderHash
) external view returns(uint256)

Returns bitmask for double-spend invalidators based on lowest byte of order.info and filled quotes

Parameters:

NameTypeDescription
makeraddressMaker address
orderHashbytes32Hash of the order

Return Values:

NameTypeDescription
remainingRawuint256Remaining amount of the order plus 1 if order was partially filled, otherwise 0

simulate

function simulate(
address target,
bytes calldata data
) external

Delegates execution to custom implementation. Could be used to validate if transferFrom works properly The function always reverts and returns the simulation results in revert data.

Parameters:

NameTypeDescription
targetaddressAddresses that will be delegated
databytesData that will be passed to delegatee

cancelOrder

function cancelOrder(
MakerTraits makerTraits,
bytes32 orderHash
) public

Cancels orders' quotes

Parameters:

NameTypeDescription
makerTraitsMakerTraitsOrders makerTraits
orderHashbytes32Hashes of the orders to cancel

cancelOrders

function cancelOrders(
MakerTraits[] calldata makerTraits,
bytes32[] calldata orderHashes
) external

Cancels orders' quotes

Parameters:

NameTypeDescription
makerTraitsMakerTraits[]Orders makerTraits
orderHashesbytes32[]Hashes of the orders to cancel

bitsInvalidateForOrder

function bitsInvalidateForOrder(
MakerTraits makerTraits,
uint256 additionalMask
) external

Cancels all quotes of the maker (works for bit-invalidating orders only)

Parameters:

NameTypeDescription
makerTraitsMakerTraitsOrder makerTraits
additionalMaskuint256Additional bitmask to invalidate orders

hashOrder

function hashOrder(
Order calldata order
) external view returns(bytes32)

Returns order hash, hashed with limit order protocol contract EIP712

Parameters:

NameTypeDescription
orderOrderOrder

Return Values:

NameTypeDescription
hashbytes32Hash of the order

checkPredicate

function checkPredicate(
bytes calldata predicate
) public view returns(bool)

See {IOrderMixin-checkPredicate}

Parameters:

NameTypeDescription
predicatebytes

Return Values:

NameTypeDescription
successbool

fillOrder

function fillOrder(
Order calldata order,
bytes32 r,
bytes32 vs,
uint256 amount,
TakerTraits takerTraits
) external payable returns(uint256,uint256,bytes32)

Fills order's quote, fully or partially (whichever is possible)

Parameters:

NameTypeDescription
orderOrderOrder quote to fill
rbytes32R component of signature
vsbytes32VS component of signature
amountuint256Taker amount to fill
takerTraitsTakerTraitsSpecifies threshold as maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount. Top-most bit specifies whether taker wants to skip maker's permit.

Return Values:

NameTypeDescription
makingAmountuint256Actual amount transferred from maker to taker
takingAmountuint256Actual amount transferred from taker to maker
orderHashbytes32Hash of the filled order

fillOrderExt

function fillOrderExt(
Order calldata order,
bytes32 r,
bytes32 vs,
uint256 amount,
TakerTraits takerTraits,
bytes calldata extension
) external payable returns(uint256,uint256,bytes32)

See {IOrderMixin-fillOrderExt}

Parameters:

NameTypeDescription
orderOrder
rbytes32
vsbytes32
amountuint256
takerTraitsTakerTraits
extensionbytes

Return Values:

NameTypeDescription
makingAmountuint256
takingAmountuint256
orderHashbytes32

fillOrderTo

function fillOrderTo(
Order calldata order,
bytes32 r,
bytes32 vs,
uint256 amount,
TakerTraits takerTraits,
address target,
bytes calldata interaction
) external payable returns(uint256,uint256,bytes32)

Same as fillOrder but allows to specify funds destination instead of msg.sender

Parameters:

NameTypeDescription
orderOrderOrder quote to fill
rbytes32R component of signature
vsbytes32VS component of signature
amountuint256Taker amount to fill
takerTraitsTakerTraitsSpecifies threshold as maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount. Top-most bit specifies whether taker wants to skip maker's permit.
targetaddressAddress that will receive swap funds
interactionbytesA call data for Interactive. Taker may execute interaction after getting maker assets and before sending taker assets.

Return Values:

NameTypeDescription
makingAmountuint256Actual amount transferred from maker to taker
takingAmountuint256Actual amount transferred from taker to maker
orderHashbytes32Hash of the filled order

fillOrderToExt

function fillOrderToExt(
Order calldata order,
bytes32 r,
bytes32 vs,
uint256 amount,
TakerTraits takerTraits,
address target,
bytes calldata interaction,
bytes calldata extension
) public payable returns(uint256,uint256,bytes32)

See {IOrderMixin-fillOrderToExt}

Parameters:

NameTypeDescription
orderOrder
rbytes32
vsbytes32
amountuint256
takerTraitsTakerTraits
targetaddress
interactionbytes
extensionbytes

Return Values:

NameTypeDescription
makingAmountuint256
takingAmountuint256
orderHashbytes32

fillOrderToWithPermit

function fillOrderToWithPermit(
Order calldata order,
bytes32 r,
bytes32 vs,
uint256 amount,
TakerTraits takerTraits,
address target,
bytes calldata interaction,
bytes calldata permit
) external returns(uint256,uint256,bytes32)

Same as fillOrderTo but calls permit first. It allows to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of msg.sender

Parameters:

NameTypeDescription
orderOrderOrder quote to fill
rbytes32R component of signature
vsbytes32VS component of signature
amountuint256Taker amount to fill
takerTraitsTakerTraitsSpecifies threshold as maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount. Top-most bit specifies whether taker wants to skip maker's permit.
targetaddressAddress that will receive swap funds
interactionbytesA call data for Interactive. Taker may execute interaction after getting maker assets and before sending taker assets.
permitbytesShould contain abi-encoded calldata for IERC20Permit.permit call

Return Values:

NameTypeDescription
makingAmountuint256Actual amount transferred from maker to taker
takingAmountuint256Actual amount transferred from taker to maker
orderHashbytes32Hash of the filled order

fillContractOrder

function fillContractOrder(
Order calldata order,
bytes calldata signature,
uint256 amount,
TakerTraits takerTraits,
address target,
bytes calldata interaction
) external returns(uint256,uint256,bytes32)

Same as fillOrderTo but calls permit first. It allows to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of `msg.sender

Parameters:

NameTypeDescription
orderOrderOrder quote to fill
signaturebytesSignature to confirm quote ownership
amountuint256Taker amount to fill
takerTraitsTakerTraitsSpecifies threshold as maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount. Top-most bit specifies whether taker wants to skip maker's permit.
targetaddressAddress that will receive swap funds
interactionbytesA call data for Interactive. Taker may execute interaction after getting maker assets and before sending taker assets.

Return Values:

NameTypeDescription
makingAmountuint256Actual amount transferred from maker to taker
takingAmountuint256Actual amount transferred from taker to maker
orderHashbytes32Hash of the filled order

fillContractOrderWithPermit

function fillContractOrderWithPermit(
Order calldata order,
bytes calldata signature,
uint256 amount,
TakerTraits takerTraits,
address target,
bytes calldata interaction,
bytes calldata permit
) external returns(uint256,uint256,bytes32)

Same as fillOrderTo but calls permit first. It allows to approve token spending and make a swap in one transaction. Also allows to specify funds destination instead of msg.sender

Parameters:

NameTypeDescription
orderOrderOrder quote to fill
signaturebytesSignature to confirm quote ownership
amountuint256Taker amount to fill
takerTraitsTakerTraitsSpecifies threshold as maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount. Top-most bit specifies whether taker wants to skip maker's permit.
targetaddressAddress that will receive swap funds
interactionbytesA call data for Interactive. Taker may execute interaction after getting maker assets and before sending taker assets.
permitbytesShould contain abi-encoded calldata for IERC20Permit.permit call

Return Values:

NameTypeDescription
makingAmountuint256Actual amount transferred from maker to taker
takingAmountuint256Actual amount transferred from taker to maker
orderHashbytes32Hash of the filled order

fillContractOrderExt

function fillContractOrderExt(
Order calldata order,
bytes calldata signature,
uint256 amount,
TakerTraits takerTraits,
address target,
bytes calldata interaction,
bytes calldata permit,
bytes calldata extension
) public returns(uint256,uint256,bytes32)

See {IOrderMixin-fillContractOrderExt}

Parameters:

NameTypeDescription
orderOrder
signaturebytes
amountuint256
takerTraitsTakerTraits
targetaddress
interactionbytes
permitbytes
extensionbytes

Return Values:

NameTypeDescription
makingAmountuint256
takingAmountuint256
orderHashbytes32

Events

OrderFilled

event OrderFilled(
bytes32 orderHash,
uint256 makingAmount
);

Emitted when order gets filled

Parameters:

NameTypeDescription
orderHashbytes32Hash of the order
makingAmountuint256Amount of the maker asset that was transferred from maker to taker