This repository aims to provide an opinionated best-practices reference implementation of a Conditional Order (concretely a Dutch Auction), on CoW Protocol, using the ComposableCoW conditional order framework.
This repository uses Foundry as the smart contract development environment. If you're using Visual Studio Code, with Development Containers, then everything is ready to go out of the box!
If not, then you will need to install the following:
When designing a new order type, it is important to consider the following:
- What is the intended use case for the order type?
- What are the limitations of the order type?
- How can orders be made to be non-replayable?
- What are the security considerations for the order type?
- What data is required (if any) to be stored in the cabinet?
See the Dutch Auction documentation for an example of how to address these questions.
src/
: Source code for the Dutch Auction contracttest/
: Tests for the Dutch Auction contractscript/
: Script for deploying the Dutch Auction contractdocs/
: Documentation for the Dutch Auction contract
By extending BaseComposableCoWTest
, we get a number of useful helper functions for testing the `DutchAuction`` contract. This includes complete fixtures (fully functional deployments) for:
- Standalone CoW Protocol contracts
- Safe contracts
- Dogfooded ERC20 tokens (
token0
,token1
,token2
) - Test accounts (
alice
,bob
,safe1
)
Using the provided test harness, one may write complete E2E tests that will simulate the entire lifecycle of conditional orders, including:
- Configuring a Safe for ComposableCoW
- Creating a conditional order
- Settling a conditional order via the CoW Protocol settlement contract (
GPv2Settlement
)
forge build
forge test
forge fmt
forge snapshot
Before running the deployment script, you MUST set the following environment variables:
PRIVATE_KEY
: Private key of the deployerCOMPOSABLE_COW
: Address of the ComposableCoW contract
These can be set in a .env
file in the root of the repository.
source .env
forge script script/Deploy.s.sol:Deploy --rpc-url <your_rpc_url>
cast <subcommand>
forge --help
anvil --help
cast --help