Skip to main content

OrderMixin

Regular Limit Order mixin

Derives#

Functions#

remaining#

function remaining(  bytes32 orderHash) external returns (uint256)

Returns unfilled amount for order. Throws if order does not exist

Parameters:#

NameTypeDescription
orderHashbytes32

remainingRaw#

function remainingRaw(  bytes32 orderHash) external returns (uint256)

Returns unfilled amount for order

Parameters:#

NameTypeDescription
orderHashbytes32

Return Values:#

NameTypeDescription
Resultuint256Unfilled amount of order plus one if order exists. Otherwise 0

remainingsRaw#

function remainingsRaw(  bytes32[] orderHashes) external returns (uint256[])

Same as remainingRaw but for multiple orders

Parameters:#

NameTypeDescription
orderHashesbytes32[]

simulateCalls#

function simulateCalls(  address[] targets,  bytes[] data) external

Calls every target with corresponding data. Then reverts with CALL_RESULTS_0101011 where zeroes and ones denote failure or success of the corresponding call

Parameters:#

NameTypeDescription
targetsaddress[]Array of addresses that will be called
databytes[]Array of data that will be passed to each call

cancelOrder#

function cancelOrder(  struct OrderLib.Order order) external

Cancels order by setting remaining amount to zero

Parameters:#

NameTypeDescription
orderstruct OrderLib.Order

fillOrder#

function fillOrder(  struct OrderLib.Order order,  bytes signature,  bytes interaction,  uint256 makingAmount,  uint256 takingAmount,  uint256 thresholdAmount) external returns (uint256, uint256)

Fills an order. If one doesn't exist (first fill) it will be created using order.makerAssetData

Parameters:#

NameTypeDescription
orderstruct OrderLib.OrderOrder quote to fill
signaturebytesSignature to confirm quote ownership
interactionbytesMaking amount
makingAmountuint256Taking amount
takingAmountuint256Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount
thresholdAmountuint256

fillOrderToWithPermit#

function fillOrderToWithPermit(  struct OrderLib.Order order,  bytes signature,  bytes interaction,  uint256 makingAmount,  uint256 takingAmount,  uint256 thresholdAmount,  address target,  bytes permit) external returns (uint256, uint256)

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

See tests for examples

Parameters:#

NameTypeDescription
orderstruct OrderLib.OrderOrder quote to fill
signaturebytesSignature to confirm quote ownership
interactionbytesMaking amount
makingAmountuint256Taking amount
takingAmountuint256Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount
thresholdAmountuint256Address that will receive swap funds
targetaddressShould consist of abiencoded token address and encoded IERC20Permit.permit call.
permitbytes

fillOrderTo#

function fillOrderTo(  struct OrderLib.Order order_,  bytes signature,  bytes interaction,  uint256 makingAmount,  uint256 takingAmount,  uint256 thresholdAmount,  address target) public returns (uint256, uint256)

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

Parameters:#

NameTypeDescription
order_struct OrderLib.OrderOrder quote to fill
signaturebytesSignature to confirm quote ownership
interactionbytesMaking amount
makingAmountuint256Taking amount
takingAmountuint256Specifies maximum allowed takingAmount when takingAmount is zero, otherwise specifies minimum allowed makingAmount
thresholdAmountuint256Address that will receive swap funds
targetaddress

checkPredicate#

function checkPredicate(  struct OrderLib.Order order) public returns (bool)

Checks order predicate

Parameters:#

NameTypeDescription
orderstruct OrderLib.Order

hashOrder#

function hashOrder(  struct OrderLib.Order order) public returns (bytes32)

Parameters:#

NameTypeDescription
orderstruct OrderLib.Order

Events#

OrderFilled#

event OrderFilled(  address maker,  bytes32 orderHash,  uint256 remaining)

Emitted every time order gets filled, including partial fills

Parameters:#

NameTypeDescription
makeraddress
orderHashbytes32
remaininguint256

OrderCanceled#

event OrderCanceled(  address maker,  bytes32 orderHash,  uint256 remainingRaw)

Emitted when order gets cancelled

Parameters:#

NameTypeDescription
makeraddress
orderHashbytes32
remainingRawuint256