Limit Orders
The LimitOrders.sol
contract is a settlement contract for executing orders from our off-chain limit order service. Users approve the contract to spend their tokens and provide signatures of their Order
to an off-chain API. An order execution bot monitors markets and executes them against this contract when allowed. Orders are executed on the contract by providing the Order parameters and an EIP712 Typed Data Signature of the Order, using the contracts domain information, to the executeOrder
function. The functions to execute orders on the contract are permissioned in the initial version as a security precaution.
Data Structures
marketId
uint256
ID of the market that the order is for
recipient
address
Address that will receive the payout of the order
referrer
address
Referrer address for the order. May receive a fee if set on the Teller contract for the market.
amount
uint256
Amount of quote tokens to spend on the order, in quote token decimals
minAmountOut
uint256
Minimum amount of payout tokens to receive from the order, in payout token decimals
maxFee
uint256
Maximum fee in the quote token that the user is willing to process the order, in quote token decimals
submitted
uint256
Timestamp that the order was submitted at. Used by the off-chain service to give priority to equivalent orders. API will not accept an order where the submitted date is a certain amount older than the current time.
deadline
uint256
Timestamp that the order is valid until. The order will not be executable after this time.
user
address
Address that the order proceeds will come from and that is required to sign the order.
Public Variables and View Methods
DOMAIN_SEPARATOR
The current domain separator hashed used to verify EIP712 signatures.
aggregator
The Bond Aggregator contract (i.e. top-level contract of the bond system) that this settlement contract supports.
authority
The Authority contract that determine access to permissioned functions on the contract.
chainId
Currently cached value for the chain ID.
getDigest
Returns the hash digest of the provided order. Used to calculate a unique order identifier and verify EIP712 signatures of Orders.
orderStatus
Returns the Status
of an order (identified by its hash digest).
State-Mutating Methods
cancelOrder
Cancels an order on the settlement contract. A cancelled order cannot be executed, even by a permissioned executor.
Parameters
order_
LimitOrders.Order
Order parameters. Specified in the Data Structures section above.
executeOrder
Execute a single order. Permissioned.
Parameters
order_
LimitOrders.Order
Order parameters. Specified in the Data Structures section above.
signature_
bytes
ECDSA signature of the EIP712 hash digest of the order_
by order_.user
fee_
uint256
Amount of quote tokens to charge as a fee. Must be less than or equal to order_.maxFee
. Determined by the executor based on network gas fees and token prices at the time of execution.
executeOrders
Execute multiple orders in one transaction. Permissioned.
Parameters
orders_
LimitOrders.Order[]
Array of Order parameters. Specified in the Data Structures section above.
signatures_
bytes[]
Array of ECDSA signatures of the EIP712 hash digest of the corresponding order_
by order_.user
fees_
uint256[]
Array of quote token amounts to charge as a fee on the corresponding order_
. Must be less than or equal to order_.maxFee
. Determined by the executor based on network gas fees and token prices at the time of execution.
reinstateOrder
Reinstates a previously cancelled order.
Parameters
order_
LimitOrders.Order
undefined
updateDomainSeparator
Updates the cached domain separator in the event that the chainId changes. Saves gas on future digest computations.
Events
AuthorityUpdated
Parameters
user indexed
address
undefined
newAuthority indexed
contract Authority
undefined
OrderCancelled
Parameters
digest
bytes32
undefined
OrderExecuted
Parameters
digest
bytes32
undefined
OrderReinstated
Parameters
digest
bytes32
undefined
OwnerUpdated
Parameters
user indexed
address
undefined
newOwner indexed
address
undefined
Errors
LimitOrders_AlreadyExecuted
Parameters
digest
bytes32
undefined
LimitOrders_InvalidFee
Parameters
fee
uint256
undefined
maxFee
uint256
undefined
LimitOrders_InvalidParams
LimitOrders_InvalidSignature
Parameters
signature
bytes
undefined
LimitOrders_InvalidUpdate
LimitOrders_InvalidUser
LimitOrders_MarketClosed
Parameters
marketId
uint256
undefined
LimitOrders_NotAuthorized
LimitOrders_OrderCancelled
Parameters
digest
bytes32
undefined
LimitOrders_OrderExpired
Parameters
deadline
uint256
undefined
Last updated