OrderSpoke
The OrderSpoke
smart contract acts as a decentralized mechanism to securely manage order fills and handle token transfers from solver entities directly to users.
Upon creation, it instantiates an Executor
contract responsible to execute the hooks in a safe way.
The main tasks of the order spoke are:
Order Validation: Ensures orders meet conditions such as expiration deadlines, duplication prevention and primary filler restrictions.
Funds Transfer: Handles secure transfers of output tokens from the solver to the user.
Hooks Execution: Executes additional external calls if specified in the order.
Cross-chain Settlement: Sends confirmation messages to the originating chain OrderSpoke upon successful order fill.
TL;DR
The OrderSpoke
contract is part of a cross-chain order fulfillment system. It receives “pending” order notifications from a central hub (via onMessageReceived
), allows an off-chain solver to fill those orders with exactly the right funds and call data (fillOrder
), manages fee deductions, executes an optional callback on fulfillment, and then relays a response back to the source chain’s hub. It also lets the owner sweep stranded tokens and update configuration settings (hub addresses and fee rate).
Events
HubUpdated
chainId
oldHubAddr
newHubAddr
Emitted when the owner changes the hub address for a given chain.
FeeUpdated
oldFee
(indexed)
newFee
(indexed)
Emitted when the owner updates the per-order fee rate (in basis-points out of 10 000).
PendingOrderReceived
orderId
(indexed)
spokeChainId
(indexed)
Emitted when a new order arrives from a hub on another chain and is marked PENDING.
OrderFilled
orderId
(indexed)
order
caller
(indexed)
Emitted after successfully filling an order: funds transferred, callback called (if any), and message sent back.
TokenSweep
tokenType
(indexed)
tokenId
token
(indexed)
to
(indexed)
amount
Emitted when the owner sweeps tokens/ETH out of the contract for arbitrary token types.
Errors
UndefinedHub()
Thrown if there is no configured hub address for the chain where the order originated or is destined.
InvalidFeeValue()
Thrown if the owner tries to set a fee greater than the maximum resolution (10 000 basis-points).
InvalidOrder()
Thrown if an order ID is unrecognized (never registered as PENDING).
OrderAlreadyFilled()
Thrown if attempting to fill an order that’s already marked FILLED.
OrderExpired()
Thrown if the block timestamp has passed the order’s deadline
field.
InvalidDestinationChain()
Thrown if the order’s destinationChainId
doesn’t match the current chain.
RestrictedToPrimaryFiller()
Thrown if a specific primary filler is designated and only that address can fill before its own deadline.
ExternalCallFailed()
Thrown if the optional callback (hook) execution fails inside the Executor
.
Inherited:
InsufficientGasValue()
Thrown if the sender didn’t supply enough native ETH to cover the order’s declared callValue
or output amount.
Last updated