DiffusalOptionsOrderBook
Signature-first order placement and ID-based match settlement
DiffusalOptionsOrderBook is the on-chain order coordination contract for the limit order flow. The current integration model is signature-first: makers sign typed data, a caller submits the signed payload on-chain, and the contract stores compact order data keyed by orderId.
The current implementation also uses these deployed contracts:
DiffusalOrderBookAuthfor typed-data hashing and signature recoveryDiffusalOrderBookCoordinatorfor signed-order validation and execution-tick preparationDiffusalOrderBookExecutorfor position, collateral, and fee effects
It does three things:
- registers signed orders (event + compact storage)
- tracks fill/cancel state
- orchestrates settlement by order IDs
Key Functions
Signed Order Request Structs
All signature-first MM entry points take canonical request structs:
struct SignedPlaceOrder {
bytes32 seriesId;
uint256 portfolioId;
bool isBuy;
uint32 tick;
uint128 size;
uint32 expiry;
uint256 nonce;
uint256 deadline;
bytes signature;
}
struct SignedCancelOrder {
bytes32 orderId;
uint256 nonce;
uint256 deadline;
bytes signature;
}
struct SignedReplaceOrder {
SignedCancelOrder cancel;
SignedPlaceOrder place;
}Canonical MM Order-Maintenance Surface
placeOrderSigned(SignedPlaceOrder request) returns (bytes32 orderId)
batchPlaceOrders(SignedPlaceOrder[] requests) returns (bytes32[] orderIds)
cancelOrderSigned(SignedCancelOrder request)
batchCancelOrders(SignedCancelOrder[] requests)
replaceOrderSigned(SignedReplaceOrder request) returns (bytes32 newOrderId)
batchReplaceOrders(SignedReplaceOrder[] requests) returns (bytes32[] newOrderIds)placeOrderSigned(...) is the canonical MM placement path and consumes the SignedPlaceOrder struct (EIP-712 PlaceOrder typed data plus packed signature). cancelOrderSigned(...) is the canonical cancel path. replaceOrderSigned(...) atomically cancels a resting order and places its replacement in one transaction. The batchPlaceOrders, batchCancelOrders, and batchReplaceOrders variants apply the same signature-first flow to all-or-nothing batches — useful for requoting an entire MM book in one transaction.
Invalidate
invalidateOrder(OrderTypes.Order order, bytes32 orderId)Permissionless cleanup for orders whose maker portfolio can no longer support them.
Lower-Level Direct Registration
These direct write functions are still available for low-level integrations where the maker wallet submits its own transaction:
registerOrderInPortfolio(bytes32 seriesId, uint256 portfolioId, bool isBuy, uint32 tick, uint128 size, uint32 expiry) returns (bytes32 orderId)
registerOrderInPortfolioWithSeriesParams(bytes32 seriesId, uint256 portfolioId, bool isBuy, uint32 tick, uint128 size, uint32 expiry, SeriesParams seriesParams) returns (bytes32 orderId)
cancelOrderById(bytes32 orderId)registerOrderInPortfolioWithSeriesParams(...) is the only entry point that can lazily create a series on first placement — use it when the series may not exist yet. Note that SeriesRegistry only accepts operator callers, so persona wallets must route new-series flows through an operator contract.
Settle Matches
settleMatchByOrderId(bytes32 makerOrderId, bytes32 takerOrderId, uint128 fillAmount)Settlement is operator-gated and uses stored order data. It delegates execution logic to DiffusalOrderBookExecutor.
Important Events
OrderRegisteredOrderCancelledMatchSettledTradeFeesCollectedExecutorUpdated
Core State
orderFilled(orderId)tracks cumulative fill amountorderPortfolioId(orderId)tracks portfolio routingstoredOrder(orderId)returns compact order metadataunorderedNonceBitmap(owner, wordPos)tracks consumed signature noncesexecutor()returns delegated execution contract
Owner Controls
setOperator(address, bool)setFees(int256 makerFeeBps, uint256 takerFeeBps)setFeeCollector(address)setMarginCalculator(address)setExecutor(address)
Integration Notes
- Canonical MM workflow: build a
SignedPlaceOrder, sign the EIP-712PlaceOrdertyped data, then callplaceOrderSigned(...)(orbatchPlaceOrders(...)for multiple orders). - Use the authenticated managed order placement reference when you want the API to return the exact
typed_datapayload or relay-ready calldata — the API wraps the same signed-order structs and submits them via the meta-transaction relay. - To requote, prefer
replaceOrderSigned(...)/batchReplaceOrders(...)over manual cancel-then-place so the cancel and place land atomically. - If the series may not exist yet, use
registerOrderInPortfolioWithSeriesParams(...)from the low-level direct-registration surface — it is the only entry point that creates a series in the same transaction as placement. - Direct registration functions (
registerOrderInPortfolio,registerOrderInPortfolioWithSeriesParams,cancelOrderById) remain available for low-level integrations, but the signature-first path is the canonical current flow. - Off-chain matcher should treat
orderIdas canonical identifier. - Use order registration events for orderbook reconstruction.
- Use
orderFilled+ cancellation/invalidation state for residual size.