LogoLogo
  • Introduction
    • What We Do
  • The DeFi Problem
  • How iLayer solves it
  • Use Cases
  • Architecture
    • RFQ
  • Hub & Spoke
    • OrderHub
    • OrderSpoke
  • Router
    • LayerZero Router
    • Axelar Router
    • NullRouter
    • AxLzRouter
  • Solvers
  • Integration
    • Industries
    • EVM Smart contracts
      • Example: cross-chain LPing on Aave
      • Example: cross-chain contract call
  • Audit
Powered by GitBook
On this page
  • Events
  • Errors
Export as PDF
  1. Hub & Spoke

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.

TL;DR The OrderHub contract is a cross-chain “order book” that lets users create off-chain orders with ERC-20/ERC-721/ERC-1155/NATIVE tokens, lock their assets in this contract and send a message via a router to a counterparty settlement contract (the OrderSpoke) sitting on another chain. Once the counter-party funds and the router relays back, the contract releases the assets to the designated recipient. Users can also withdraw unfilled orders after a buffer period. Order checks enforce nonce unicity, deadlines, token approvals/permits and reentrancy protection.


Events

Event
Parameters
Description

SpokeUpdated

chainId, oldSpokeAddr, newSpokeAddr

Emitted when the owner changes the destination “spoke” address for a given chain.

TimeBufferUpdated

oldTimeBufferVal, newTimeBufferVal (indexed)

Emitted when the owner adjusts the extra time users have to withdraw expired orders.

MaxOrderDeadlineUpdated

oldDeadline, newDeadline (indexed)

Emitted when the owner sets a new maximum span users may set for an order’s deadline.

OrderCreated

orderId (indexed), nonce, Order order, caller (idx)

Emitted when a user successfully creates (locks) an order and it’s sent through the router.

OrderWithdrawn

orderId (indexed), caller (indexed)

Emitted when a user withdraws their active order and assets are returned.

OrderSettled

orderId (indexed), Order order

Emitted when the router calls back to settle (fill) the order and assets are forwarded.

ERC721Received

operator, from, tokenId, data

Emitted when this contract receives an ERC-721 token via safeTransferFrom.

ERC1155Received

operator, from, id, value, data

Emitted when this contract receives a single ERC-1155 token via safeTransferFrom.

ERC1155BatchReceived

operator, from, ids, values, data

Emitted when this contract receives multiple ERC-1155 tokens via safeBatchTransferFrom.


Errors

Error
Description

RequestNonceReused

The user’s off-chain order request nonce has already been used.

RequestExpired

The off-chain order request deadline (for signature validity) has passed.

UndefinedSpoke

No spoke address is set for the order’s destination chain.

InvalidOrderInputApprovals

The number of input tokens doesn’t match the number of provided permit blobs.

InvalidOrderSignature

The order’s EIP-712 signature failed to validate against the user’s address.

InvalidDeadline

The order’s deadline exceeds the configured maximum span.

InvalidSourceChain

The on-chain block.chainid doesn’t match the order’s declared source chain.

InvalidDestinationChain

The callback from the router came from an unexpected chain (shouldn’t happen in normal flow).

OrderDeadlinesMismatch

The primary-filler deadline is after the overall order deadline.

OrderPrimaryFillerExpired

The time window for the primary filler has elapsed before the order expires.

OrderCannotBeWithdrawn

Conditions to withdraw (wrong caller, still within buffer window, or non-active status) failed.

OrderCannotBeFilled

Conditions to settle (wrong status) failed when router callback arrives.

OrderExpired

The order’s deadline has passed before creation or settlement.

InsufficientGasValue

The user didn’t send enough native (ETH) value to cover the declared input amount.

PreviousHub & SpokeNextOrderSpoke

Last updated 24 days ago