OrderHub
The OrderHub
contract manages user orders and custody of tokens until orders are filled, withdrawn, or expired. It acts as a gateway for off-chain orders, allowing users (or their solver bot delegates for gasless execution) to submit orders by providing a signed order request. Each order request comes with a nonce to prevent order creation replay, orders themselves are signed by the user using the EIP712 standard or the EIP165 for smart contract signatures.
Data coming from the RFQ stream is fed into the order intent and signed by the user, then broadcasted to the designated solver for execution or the order directly created by the user on-chain.
Events emitted
TimeBufferUpdated: Emitted when the
timeBuffer
value is changed.MaxOrderDeadlineUpdated: Emitted when the maximum order deadline is updated.
OrderCreated: Emitted upon the successful creation of a new order. Includes the unique order ID, nonce, order details, and the caller’s address.
OrderWithdrawn: Emitted when an active order is withdrawn, returning custody of tokens to the user.
OrderSettled: Emitted when an order is settled through cross-chain communication from the Spoke.
ERC721Received, ERC1155Received, ERC1155BatchReceived: Standard events to log receipt of ERC721 and ERC1155 tokens.
Custom errors
For gas-efficient error handling, the contract defines several custom errors:
RequestNonceReused: Thrown if the provided nonce has already been used.
RequestExpired: Thrown if the order request’s deadline has passed.
InvalidOrderInputApprovals: Thrown when the number of permits does not match the number of order inputs.
InvalidOrderSignature: Thrown when the order signature does not validate.
InvalidDeadline: Thrown if the order deadline exceeds the allowed maximum.
OrderDeadlinesMismatch: Thrown when the primary filler deadline is later than the order deadline.
OrderPrimaryFillerExpired: Thrown if the primary filler deadline has already passed.
OrderCannotBeWithdrawn: Thrown when conditions for withdrawal are not met.
OrderCannotBeFilled: Thrown if an order cannot be filled (e.g., due to an invalid status).
OrderExpired: Thrown if an order has expired by the time of processing.
Last updated