Grant Application: Framework agnostic SDK

Grant Title:

Framework agnostic CoW SDK


Author:

@bleu @yvesfracari @ribeirojose @mendesfabio


About You:

bleu collaborates with companies and DAOs as a web3 technology and user experience partner. We’re passionate about bridging the experience gap we see in blockchain and web3.


Additional Links:

We developed multiple grants with CoW Swap. The ones that are more related to this project are:

  • [CoW] Hook dApps: a set of Hook dApps integrated on the CoW Swap frontend. During this project, we developed the cow-shed module of the @cowprotocol/cow-sdk. This module was created to help developers to use CoW Shed to create permissioned hooks.
  • [CoW] Python SDK (waiting for review): we’re helping CoW put together a Python version of the cow TS SDKs to provide developers with query on-chain data, manage orders, and integrate with the CoW Protocol’s smart contracts. This gives the team a big understanding of all the CoW TS packages.
  • [Pike] Pike SDK (in progress): Outside our work with CoW, we also started to create an SDK for Pike, a to-be-launched lending protocol. The project is in its first stages but the design of the SDK followed the same principles of framework agnostic that we’re proposing for this project.

Grant Category:

Core Infrastructure & Developer Tooling


Grant Description:

As described in this RFP, the CoW Protocol ecosystem currently relies heavily on Ethers.js v5 for its blockchain interactions. This grant proposal aims to not only upgrade to Ethers.js v6 but also to fundamentally restructure the SDK architecture to be more composability with framework-agnostic base packages with EVM adapters. We propose a comprehensive overhaul that includes:

  1. Expanded Scope with EVM Independence: Beyond the core SDK, we will also modernize the app-data and contracts packages, ensuring framework-agnostic base packages. This means that we will remove the current dependency of ethers v5 of the business logic.
  2. Multiple Adapter Support: We will develop separate adapter packages for:
    • Ethers.js v5 (for backward compatibility)
    • Ethers.js v6
    • Viem
    • Wagmi
  3. Modular Package Architecture: The SDK will be restructured into smaller and modular packages that developers can install based on their specific needs to simplify dependency management.

For a better understanding of the view of the package structure, a demonstration of this architecture with some methods implementations can be found here. In addition, we started to also build a demo of how the adapter would work on this branch.


Grant Goals and Impact:

This grant aims to refactor CoW Protocol ecosystem by creating a more flexible, maintainable, and developer-friendly architecture. By transitioning to a modular and composability with EVM-independent base package design, we will facilitate the integration of new systems. The impact extends beyond mere technical upgrades – it will foster broader adoption of the CoW Protocol by allowing developers to integrate the protocol using their preferred tools and frameworks.


Milestones:

Milestone Duration Payment (15k xDAI)
SDK Refactoring 2 weeks 5k xDAI
New adapters and CoWSwap Integration 2 weeks 5k xDAI
Deployment and Documentation 2 weeks 5k xDAI

SDK Refactoring (2 weeks)

This milestone focuses on refactoring the SDK packages while maintaining ethers v5. We will implement a modular package system that separates reusable logic from blockchain interactions. The work will continue with this demo structure, implementing proper tooling, and ensuring all existing functionality works within the new architecture (with test replication). This milestone includes refactoring the app-data and contracts packages into the new structure, setting the stage for future adapter implementations. Considering the demo structure, we want to deliver on this milestone the following packages:

  • cow-order-book
  • cow-app-data
  • cow-trading
  • cow-abi (includes part of the contract logic)
  • cow-shed
  • cow-composable
  • cow-common (includes part of the contract logic)
  • cow-config
  • cow-order-book
  • cow-subgraph
  • cow-ts
  • cow-order-signing
  • cow-sdk (exports all the other packages)
  • cow-sdk-ethers-v5 (includes part of contract logic)

New adapters and Cowswap Integration (2 weeks)

The second milestone centers on creating the viem, ethers v6, and wagmi adapters and integrating the selected ones on the CoW Swap application. We will implement comprehensive testing for the new adapter and update all CoWSwap-related projects (including explorer and other sub-projects) to work with the new SDK architecture. This will include:

  • cow-sdk-ethers-v6
  • cow-sdk-viem
  • cow-sdk-wagmi

Deployment and Documentation (2 weeks)

The milestone concludes with a fully documented, tested, and production-ready system supporting all three adapters. We will update the existent SDK docs to cover new packages (core, adapters, etc), and provide thorough migration guides for existing users.

This phase includes creating integration examples for each adapter, implementing end-to-end testing across all supported libraries, and preparing the entire system for production deployment. This stage will also include the update of the tutorials on the Learn website.


Funding Request:

We propose that milestone payments be released upon each milestone’s approval.


Budget Breakdown:

The budget includes the hourly rates of a developer during the execution and a project manager on a need basis. The xDAI part of the budget shall be paid after each milestone’s completion.

In addition, we request a 10k COW payment vested over 1 year to cover diluted maintenance and related costs for the same period. The vesting should be created once all the project milestones are completed.


Gnosis Chain Address (to receive the grant):

0x5D40015034DA6cD75411c54dd826135f725c2498


Other Information:

  • All the code will be open-source from day 0. We’re open to feedback during PRs as well;
  • We’re happy to answer any questions and are open to feedback about this proposal;

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.

5 Likes

Hi,
In general, I’m in favour of this grant application, especially considering that the scope includes the update of the Learn website which is an invaluable resource to have interactive tutorials, easing the difficulty for developers when integrating. This also greatly alleviates a large element of technical debt, therefore warranting such costs.

A minor point, but an important one nonetheless, in regards to the vesting elements of COW that is requested, please break this out into a specific area so that it is not embedded within the milestones table, as this may be misconstrued. It should be obvious (such as a note) under the milestone table.

mfw78

2 Likes

Thanks for the feedback!

I edit the proposal to move the vesting payment to the “Budget Breakdown” section. Let me know if it is not clear.

In addition, I also updated the address to receive the grant.

IMO, the total amounts should be visible in 1 area so as to not be referential and allow “ease of review”. We do have a new template forthcoming which does put this into effect (not here yet though).

Thank you for the application, Bleu team.
It’s very through and proposes a lot of great features!

Questions:

  1. When you say packages, you mean each of them will be an individual npm package, or is it more like an internal logical segmentation instead, and only a selected handful will be exported?

  2. I see the proposed structure is using Turborepo Introduction | Turborepo. In CoW Swap’s monorepo we use NX https://nx.dev/. Any particular reason why Turborepo was chosen?
    I’m not saying I prefer NX over Turborepo, just want to understand the reasoning and whether makes sense to use a different tool than what we already have.

  3. When you say:

modernize the app-data … ensuring framework-agnostic base packages. This means that we will remove the current dependency of ethers v5 of the business logic.

Does that mean that you intent to make app-data also support multiple adapters? (ethers v5, v6, viem, etc).

2 Likes

One more question, what does the maintenance cover?
What should we expect during this 1 year?

1 Like

Thanks for the feedback! Answering the questions:

  1. Npm packages, but cow-sdk package would export all the other ones so it is composable and also easy to integrate all.
  2. No specific reason and we would be open to changing it if you guys prefer.
  3. Our view is that no package depends on ethers, viem etc. If it has any feature that needs to interact with this package, the adapter would provide this integration.

About maintenance, it covers:

  • review new pull requests;
  • address bugs in the codebase;
  • provide technical support on Discord/GitHub;
  • handle package publishing, versioning, and dependency management;