Grant Application: Composable Conditional Orders

Safe Composable Conditional Orders

Grant Title: Safe Composable Conditional Orders


About You:

  • Experience in technical systems analysis, design and implementation with a strong emphasis on risk management / gap analysis.
  • Experienced technical writer in mission-critical, highly regulated, and technical industries.
  • Actively independently developing with emerging decentralised technologies, including Swarm and Waku.

Additional Links:

Grant category: Protocol Order Flow / Developer Tools

Grant Description:

Problem: With the limitless options available for EIP-1271 orders, there becomes a need to develop a standard by which orders can inherit from, such as to reduce the number of contract deployments required, increase gas efficiency and smooth the UX.

For example, the recent Cowswap TWAP Orders while providing an innovative method for storing only a signature of the TWAP and therefore providing gas efficiency, this method requires a new Fallback handler for each type of conditional order.

Solution: Implement a “Conditional Order Router” Fallback handler, with Conditional Orders being summarised in a merkle tree, whose root is signed by the Safe to assert truthfulness. This method would allow limitless simultaneous conditional orders meeting innumerable use cases.

Grant Goals and impact

  • Increase CoW protocol utility through composable DeFi-market unique order types.
  • Reduce UX friction for multiple conditional order types.


  1. Implement a MerkleConditionalOrderFallbackHandler contract that provides stock Safe functionality, while allowing authorisation of limitless types of conditional orders.
  2. Update TWAP orders:
    a. Add support for new Merkle Tree storage.
    b. Add support for Milkman price checkers.
  3. Adapt PerpetualStableSwap and TradeAboveThreshold for Merkle Tree storage (implementation of these conditional order types out of scope for audit).
  4. Revise the Tenderly Web3 Action to support composable conditional orders.
  5. Revise the CLI tool to allow creation of composable conditional orders (eg. create TWAP and TradeAboveThreshold).

Grant Timeline:

Phase 1: 4 weeks FTE.

Note 1: Full-Time Equivalent (FTE) corresponds to 40 hrs / week
Note 2: The above timelines do not make for allowances / timing associated with audit completion.

Funding Request:

Phase 1: $10,000.

Payment terms: Half paid up-front at the commencement of each phase with the remainder paid upon satisfactory completion of code as determined by the member(s) of the CoW team.

Budget Breakdown:

  • $10k: development / labor cost

This budget does not include any costs associated with audit by a 3rd party. It is expected that CoW would undertake the necessary steps / cost for audit. Any cost overruns associated with meeting the standards of an external audit (additional testing / code fixes) would be paid out of the development cost.

Gnosis Chain Address (to receive the grant):


Other Information: As an active member of the CowDAO Grants Committee, I hereby refrain from voting / signing on this proposal so as to eliminate conflicts of interest. In determining the timelines associated with this Grant, I have taken into consideration workloads due to my position as a Committee member, 3rd party work, and allowed appropriate buffer to ensure the Grant Committee’s continuance.

Referral: N/A

Terms and conditions:

By applying for this grant, I agree to be bound by the CowDAO Participation Agreement and the COWDAO Grant Terms and Conditions

1 Like

To elaborate on the above Grant Application, Composable Conditional Orders would allow for example the following conditional orders to be implemented - simultaneously:

  1. Alice is an OG developer in crypto and maintains a 1 year runway of costs in USDC.
  2. If Alice has anymore USDC than the 1 year runway requirements, she wants to sell this and hold ETH as a reserve currency.
  3. Alice receives payments in numerous different types of tokens, and sells these in batches to USDC.

Using Composable Conditional Orders, Alice would be able to:

  1. TWAP automatically sell tokens to USDC.
  2. If USDC balance exceeds 1 year runway, use the residual to buy ETH.

The primary advantage of composable conditional orders allow for many other conditional orders to be specified, with a relatively fixed gas cost.


I support this application as it will allow for unlimited conditional orders and improved DeFi composibility.

I’m in support of funding this proposal.
@mfw78 has implemented the TWAP/DCA smart orders which have passed an audit and is now available for use as a gas-efficient alternative to the milkman implementation.
His demonstrated experience and familiarity with CoW Protocol’s smart order is giving additional confidence in good execution of this proposal.

An efficient way to deploy composable conditional smart orders will open many use cases for DAOs and teams that want to deploy trustless onchain trading strategies.


Based on the signalling and feedback here, this Grant Application has been moved to snapshot voting by the committee.

1 Like

Voted in favour of the Grant on Snapshot based on the past successful work of Mfw78, and I’m excited to see these new use possibilities for CoW Protocol once the developpement will be done and they are deployed.

1 Like

First of all, apologies for the significant gap in communication on this grant (well, public release of such communication).

Currently, this grant was somewhat split into two “phases”:

  1. ExtensibleFallbackHandler - a new Safe fallback handler that allows for increased composability with Safe. See: Grant Application: Extensible Fallback Handler for Safe (Retrospective).
  2. ComposableCoW - providing a unified, composable conditional order framework, allowing users to specify either a single order, or a multitude of orders using a merkle root and associated proof.

Both of the above phases are feature complete, with the code for both currently undergoing audit.