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
Field | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
order_ | LimitOrders.Order | Order parameters. Specified in the Data Structures section above. |
executeOrder
Execute a single order. Permissioned.
Parameters
Name | Type | Description |
---|---|---|
order_ | LimitOrders.Order | Order parameters. Specified in the Data Structures section above. |
signature_ | bytes | ECDSA signature of the EIP712 hash digest of the |
fee_ | uint256 | Amount of quote tokens to charge as a fee. Must be less than or equal to |
executeOrders
Execute multiple orders in one transaction. Permissioned.
Parameters
Name | Type | Description |
---|---|---|
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 |
fees_ | uint256[] | Array of quote token amounts to charge as a fee on the corresponding |
reinstateOrder
Reinstates a previously cancelled order.
Parameters
Name | Type | Description |
---|---|---|
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
Name | Type | Description |
---|---|---|
user | address | undefined |
newAuthority | contract Authority | undefined |
OrderCancelled
Parameters
Name | Type | Description |
---|---|---|
digest | bytes32 | undefined |
OrderExecuted
Parameters
Name | Type | Description |
---|---|---|
digest | bytes32 | undefined |
OrderReinstated
Parameters
Name | Type | Description |
---|---|---|
digest | bytes32 | undefined |
OwnerUpdated
Parameters
Name | Type | Description |
---|---|---|
user | address | undefined |
newOwner | address | undefined |
Errors
LimitOrders_AlreadyExecuted
Parameters
Name | Type | Description |
---|---|---|
digest | bytes32 | undefined |
LimitOrders_InvalidFee
Parameters
Name | Type | Description |
---|---|---|
fee | uint256 | undefined |
maxFee | uint256 | undefined |
LimitOrders_InvalidParams
LimitOrders_InvalidSignature
Parameters
Name | Type | Description |
---|---|---|
signature | bytes | undefined |
LimitOrders_InvalidUpdate
LimitOrders_InvalidUser
LimitOrders_MarketClosed
Parameters
Name | Type | Description |
---|---|---|
marketId | uint256 | undefined |
LimitOrders_NotAuthorized
LimitOrders_OrderCancelled
Parameters
Name | Type | Description |
---|---|---|
digest | bytes32 | undefined |
LimitOrders_OrderExpired
Parameters
Name | Type | Description |
---|---|---|
deadline | uint256 | undefined |
Last updated