Domain Model
The domain model establishes fundamental data structures and business logic for overseeing programmatic orders. Location:src/types/model.ts
ConditionalOrder Type
This type represents a programmatic order that has been registered within the system.Field Descriptions
id A unique identifier derived fromkeccak256(serialized_order). Used as the context key in the ComposableCoW contract.
tx
Hash of the transaction creating this programmatic order, helpful for tracking and debugging purposes.
params
Programmatic order parameters from the CoW Protocol SDK, including handler contract address, salt, and static input data.
proof
Contains merkle root and path array for orders created via merkle root; null for single orders.
orders
Tracks discrete orders posted for this programmatic order, mapping Order UID to status (SUBMITTED or FILLED).
composableCow
Contract address for polling to create discrete orders, typically ComposableCoW but may be a custom handler.
pollResult
Cached last poll result containing execution timestamp, block number, and poll outcome.
Related Types
Registry Class
This class manages state across all programmatic orders for every owner.Field Details
version Schema version used for migrations during structural changes. Currently at version2.
ownerOrders
Primary data structure mapping owner addresses to their programmatic orders.
Methods
Registry.load() Retrieves the registry from the database.genesisBlockNumber - 1 if none exists. Schema migrations occur automatically based on persisted version.
Registry.dump()
Exports the registry as JSON.
/api/dump/:chainId endpoints.
write()
Persists the registry to the database atomically.
ExecutionContext
Supplies dependencies to domain logic functions.Usage Example
RegistryBlock
Represents a processed block.Storage Keys
The registry utilizes these database keys:Data Serialization
The registry handles non-native JSON data structures through custom serialization.Map Serialization
Set Serialization
Schema Migrations
When the registry schema evolves:- Increment
CONDITIONAL_ORDER_REGISTRY_VERSION - Add migration logic in
parseConditionalOrders() - Migrations run automatically upon load
Example: Version 1 to 2
Version 2 introduced theid field: