Grant Application: Decentralizing CoW’s Watchtower

Grant Title:

Implementation of CoW’s Watchtower as a Decentralized and Robust Off-chain System


Valory AG,
Main contact person: David Galindo, CTO, Valory AG
Github valory-xyz

About You:

Valory is the expert in decentralized off-chain and autonomous systems and inventor of We pioneered the Autonolas stack which is crypto’s cutting-edge open-source framework for developing custom, DAO-owned, decentralized, autonomous off-chain systems.

We offer expert, customized support to those interested in decentralizing & owning their own apps.

Additional Links:


Twitter: valoryag , autonolas

Github profiles: valory-xyz , DavidMinarsch , dagacha , 0xArdi , jmoreira-valory

Grant Category:


Grant Description:


The primary purpose of this project is to enhance the decentralization of CoW Protocol’s off-chain infra.

Specifically, we propose to optimize the functionality of CoW Protocol’s Smart Contract Orders (SCOs) and Watchtower Framework using Autonolas technology.

The project is designed to align with CoW Protocol’s phased approach to achieving full decentralization, coding a decentralized application that can easily be scaled to increased nodes, without sacrificing the agility and improving the robustness of the systems in question.

The intent is to strike a balance between decentralization, efficiency, and scalability, paving the way for a more autonomous, secure, and transparent trading ecosystem.


The project aims to meet four key objectives, with an emphasis on 1 & 4:

  1. To transform the Watchtower into a decentralized and robust system.
  2. To enable the Watchtower to execute the getTradeableOrder function up to every block.
  3. To equip the Watchtower to concurrently support thousands of orders.
  4. To develop a software architecture that progressively decentralizes off-chain services, while maintaining development agility.

High level Project description

The scope of the project is to build a Watchtower off-chain agent service for the SCOs called Composable Conditional Orders (ComposableCoW). The SCOs allow autonomous trading based on predefined rules and strategies. The Watchtower monitors the activity of SCOs, registers new contracts, and forwards tradeable orders to the CoW Protocol API.

The project will leverage Autonolas technology to implement a multi-agent based service for the Watchtower, enabling it to operate as efficiently while minimizing the trust assumptions involved with running off-chain architecture. This improved Watchtower design is expected to meet the first and fourth objectives and maintain parity on the second and third ones.

Technical design

Agent services that use Autonolas technology are implemented as Finite State Machines FSMApps, where the logic is split across independent components: rounds define the rules to transition across different states and behaviors to implement the actual business logic of the service. Agents in the service have a synchronized, shared state. At the end of each round, the agents making up the service agree on the round’s data output.

The tentative high-level design of the new FSM that we propose to build for the Watchtower is given below. This is to be interpreted as our current proposal, given our current understanding of CoW Protocol’s watchtower. The concrete implementation might vary depending on the concrete technical requirements or on the complexity of the solution.

  • SCOMonitor: sidecar/background skill where the service listens for on-chain SCO creation events and adds them to the shared state. Each SCO in that list is called every few seconds (getTradeableOrder) to check if they are ready to trade. Orders are removed from the queue whenever they are fulfilled or expired.

  • Randomness: the service retrieves randomness from a VRF.

  • SelectKeeper: an agent among all the participants is selected as keeper. The keeper can be configured to be updated every n transitions.

  • SelectOrders: agents agree on a set of orders that are ready to be sent to the API.

  • PlaceOrders: the keeper sends the SCO selection to the CowSwap API. Orders must be sent once at a time.

  • VerifyExecution: agents get the orders from the API to verify that they have been correctly sent and update their status so they can be cleaned by the SCOMonitor. Alternatively agents can check the order fulfillment status using the order hash.

The new FSMapp will be chained with the following FSMApps to obtain the full Watchtower autonomous service:

  • Agent Registration: a required stage in each agent service, where agents indicate their willingness to participate in the service.
  • Reset and Pause: wait a bit and restart the main cycle of the service.

Grant Goals and impact:

The overarching objective of this grant is to illustrate a feasible route towards the decentralization of the CoW Protocol’s substantial off-chain architecture, all while preserving its efficiency, scalability, and adaptability.

The immediate goal involves the decentralization of the Watchtower, serving as a litmus test for Autonolas technology—a potential game-changer for a burgeoning protocol like CoW Protocol that seeks to balance growth with a commitment to decentralization.

The successful execution of this grant will yield numerous benefits, directly impacting various stakeholders in the CoW Protocol ecosystem:

  • Enhanced Security: As decentralization inherently distributes authority and control, it can provide a more secure environment by eliminating single points of failure. This increases the protocol’s resilience against attacks and fraudulent activities.
  • Greater Transparency: The shift to a decentralized system can provide higher levels of transparency. The need for coordination between the different agents in the system implies that the code run off-chain needs to be publicly available.
  • Scalability and Sustainability: The proposed Watchtower design, operating at block level, can effectively handle a large number of orders concurrently. This scalability is vital for the protocol’s sustainability, as it will be able to accommodate growth in user base and transaction volume over time.

Moreover, the implications of this grant extend beyond the immediate task of Watchtower decentralization. Its successful implementation could serve as a stepping stone towards greater impacts for the CoW Protocol community. For example, it could accelerate the decentralization of other parts of the CoW Protocol, such as the order database and solver algorithms. This would further democratize the protocol, empower its ecosystem participants, and uphold the core principles of decentralization.

In essence, this grant is not just about improving a single component of the CoW Protocol, but also about bolstering the protocol’s commitment to decentralization, efficiency, and scalability—setting the stage for future advancements that will benefit the community at large.

Milestones & Grant Timeline:

Date Payment
Milestone 1 Development of a Fully-Fledged Requirements Document 2 weeks after grant approval N/A
Milestone 2 Implementation of the Watchtower Agent Service 4 weeks after grant approval N/A
Milestone 3 Deployment and Operation of the Service with Four Agents 5 weeks after grant approval N/A
Milestone 4 Integration of Developed Components within the Autonolas Protocol 7 weeks after grant approval 8500 xDAI

Milestone 1: Development of a Fully-Fledged Requirements Document

In the first milestone, our focus will be on creating a comprehensive requirements document that aligns with the CoWDAO’s expectations and needs. The document will define the technical, functional, and non-functional requirements for the Watchtower agent service, ensuring clear communication and understanding between all stakeholders. The completion of this milestone will establish a solid foundation for the development and implementation of the agent service in the next milestone.

Milestone 2: Implementation of the Watchtower Agent Service

With the requirements document as our guide, we will proceed to the development and implementation of the Watchtower agent service during the second milestone. The service will be designed to accomplish Features 1 and 4 from the Ideal Implementation while maintaining at least parity on Features 2 and 3. The successful completion of this milestone will result in a fully functional Watchtower agent service, ready for deployment and operation.

Milestone 3: Deployment and Operation of the Service with Four Agents

During the third milestone, we will assist CoWDAO in launching the service and ensuring its operation with four agents on Valory Propel or a Kubernetes Cluster managed by CoW Swap on a cloud/multiple clouds of their choice. These four agents will provide redundancy, enhancing the reliability and resilience of the service. Successful completion of this milestone will see the Watchtower agent service fully operational.

Milestone 4: Integration of Developed Components within the Autonolas Protocol

In the final milestone, we will provide assistance to CoWDAO to integrate any developed component within the Autonolas Protocol. This integration will not only facilitate the sourcing of operators for the service, it would also make the components developed during this grant eligible for reward through the Auotonolas tokenomics. For more information on tokenomics please refer to Autonolas whitepaper

In week 8 after approval of the grant, the decentralized Watchtower service will be run by CoW or, Cow DAO can instruct Valory to run it under the Service Ops Propel plan subscription.

Funding Request:

8500 xDAI

Budget Breakdown:

Item Cost
Project Management & Requirements Document & Operational Support 2500 USD
Development of the Watchtower Components & Integration of Developed Components 6000 USD
Total 8500 USD

Gnosis Chain Address (to receive the grant):


Other Information:

Please see our live products and services at this link

Please see the current services registered in the Autonolas protocol

For more detail about Autonolas please see our whitepaper


@middleway_eth - Twitter handle

Terms and conditions:

By submitting this grant application, I acknowledge and agree to be bound by the CoW DAO Participation Agreement and the CoW Grant Terms and Conditions.

1 Like

I support this proposal. Decentralizing the CoW Protocol, beginning with the “Watchtower Agent Service”, presents an excellent opportunity to enhance security and scalability, by removing single points of failure and promoting transparency. Successful implementation would serve as a strategic step toward wider decentralization and growth of the protocol.


Thanks for the proposal!
The proposal was already evaluated and discussed prior to the official submission.
It is important for the delivery of the upcoming TWAP feature and will definitely represent a step towards decentralizing CoW Protocol infrastructure.

Please post the proposal on snapshot to allow the grants committee to vote on it.

1 Like

I support this proposal, a good step forward for decentralizing the protocol.

@dagacha Thanks for the detailed grant application.

Can you please confirm:

  1. All tech from which to run the solution is/will be open-source?
  2. The proposed solution represents 100% ownership by CowDAO with no trailing fees / protocol fees etc.
  3. An estimate for transaction fees that would be incurred for the consensus mechanism? (mainnet/gnosis chain/goerli).

From a tech side, for the P2P component, is this limited to communication only between agents?

Hello @mfw78 Please find below my answers:

  • All tech from which to run the solution is/will be open-source?

Yes. In particular, the new code specific to the watchtower service will be released under Apache 2.0 license.

  • The proposed solution represents 100% ownership by CowDAO with no trailing fees / protocol fees etc.

The code from which to run the solution is open source. It can be forked and run by anyone (in particular CoW DAO). The lifecycle of a service implies several transactions on mainnet. However these are meant to happen rarely and do not depend on the level of activity of the service (cf. Manage the life cycle of a service - Autonolas Developer Documentation for an overview of an autonomous service life cycle).

  • An estimate for transaction fees that would be incurred for the consensus mechanism? (mainnet/gnosis chain/goerli).

No fees incurred (to be confirmed once the full spec of the service is available).

From a tech side, for the P2P component, is this limited to communication only between agents?