Installation
Core Components
ConditionalOrderFactory
Registry-based factory for creating different types of conditional orders:Multiplexer
Manages batches of conditional orders using merkle trees:ConditionalOrder
Base class for implementing custom conditional order types:Basic Usage
Order Types
Stop-Loss Orders
Automatically sell when price drops below a threshold:Limit Orders
Execute trades at specific price points:DCA (Dollar Cost Averaging)
Regularly buy or sell assets at predetermined intervals:See the TWAP Orders page for detailed information about Time-Weighted Average Price orders.
Merkle Tree Management
Conditional orders are stored in merkle trees for efficient on-chain verification:Order Validation
Validate conditional orders before execution:Context Dependencies
Orders can depend on external data sources:Order Registry Management
Register custom order types:Smart Contract Integration
ComposableCoW Contract
Proof Generation and Storage
Complete Example
Here’s a complete example setting up a stop-loss order:Best Practices
Always validate orders before submission
Always validate orders before submission
Use the
isValid() method to catch configuration errors early:Store proofs off-chain
Store proofs off-chain
Generate and store merkle proofs off-chain to enable watchtowers to execute your orders:
Use appropriate context factories
Use appropriate context factories
Set context factories for orders that need on-chain data:
Next Steps
TWAP Orders
Learn about Time-Weighted Average Price orders
Hooks
Execute custom logic with pre and post hooks