Author(s)
@bleu @bsvalverde @ribeirojose
Experiences and Qualifications
bleu collaborates with companies and DAOs as a web3 technology and user experience partner. We are the team behind several core CoW Protocol developer tools and have a deep understanding of the codebase.
Our track record with CoW:
- [CoW] Framework Agnostic SDK: We re-architected the CoW SDK to support Viem natively, abstracting away the Ethers.js dependency. This grant operationalizes that work.
- [CoW] Playground Offline Mode: (Recently Approved) Created the local dev environment with offline signing for backend engineers.
- [CoW] Hook dApps: Integrated Hook dApps and developed the cow-shed module.
Grant Description
The CoW Swap frontend currently relies on Web3React, an aging library that is largely unmaintained, and initializes the CoW SDK using the legacy Ethers.js adapter. This creates technical debt, mobile connection instability, and requires workarounds to support modern features like EIP-6963 (Multi-Injected Providers).
In addition, the current wallet and frontend code paths rely heavily on Ethers.js v5 and TypeChain-generated ABIs.
The current web3-react stack presents growing risks to the Protocol:
- The library is unmaintained;
- Existing EIP-6963 support is a hacky Web3React workaround and can still cause wallet conflicts.
- The current wallet integration is brittle; modern libraries like Reown offer superior reliability.
- Integrating new chains or wallets requires complex custom code rather than simple configuration.
- Ethers.js- and TypeChain-based patterns make the code harder to modernize and maintain compared to a Viem-based approach.
As part of this grant, we will:
- Remove Web3React entirely from the frontend,
- Migrate SDK and wallet flows to Viem + Wagmi,
- Maintain full support for all existing wallet connectors: EIP-6963, injected browser extensions (window.ethereum, including mobile web3 browsers), WalletConnect, Coinbase Wallet, and Gnosis Safe, and
- Remove Ethers.js and TypeChain (ethers-v5 targets) from the frontend wallet/connection layer, migrating to viem-native primitives.
We will use CoW Swap’s existing LaunchDarkly feature flags to run the old and new stacks in parallel, allowing a gradual rollout and instant rollback if any issues are detected.
Key Dependencies to Update
As part of this migration, we will also update the Safe SDK stack to their latest major versions, which provide Viem-native support and drop Ethers.js:
| Package | Current | Target | Note |
|---|---|---|---|
| @safe-global/api-kit | ^1.3.0 | ^4.0.1 | New API surface |
| @safe-global/protocol-kit | ^1.2.0 | ^6.1.2 | Viem-native support |
| @safe-global/safe-core-sdk-types | ^2.2.0 | ^5.1.0 | Updated type definitions |
| @safe-global/safe-ethers-lib | ^1.9.4 | Removed | Replaced by Viem / Safe tooling |
Impact
-
Fixing wallet connection flakiness directly improves the “Connect Wallet” conversion rate, ensuring fewer users drop off before trading.
-
Native EIP-6963 support means users can choose between injected wallets in the UI without disabling browser extensions. This removes reliance on the previous custom Web3React workaround.
-
Offloads complex connection logic to maintained libraries (Wagmi), reducing the maintenance burden on the CoW core team and easing onboarding for new developers.
-
Operationalizes the DAO’s previous investment in the Framework Agnostic SDK.
-
Improved frontend stability and maintainability and cleaner abstractions for future development, easing onboarding to new devs.
Type of Grant
Milestone-based grant
Milestones
| Milestone | Title | Due date (*) | Funding request |
|---|---|---|---|
| Milestone 1 | Core Architecture & SDK Integration | Week 1-2 | 4,000 xDAI |
| Milestone 2 | Wallet Connection & EIP-6963 | Week 2-3 | 4,000 xDAI |
| Milestone 3 | Safe Wallet Integration | Week 4 | 3,100 xDAI |
| Milestone 4 | Chain Selection & Network Handling | Week 5-6 | 5,000 xDAI |
| Milestone 5 | QA, Testing & Staged Rollout | Week 7-8 | 5,000 xDAI |
| Milestone 6 | Frontend Route Migration | Week 9 | 3,100 xDAI |
| Milestone 7 | Cleanup & Documentation | Week 9–10 | 4,000 xDAI |
(*) Weeks after acceptance/commencement. Some milestones overlap; overall completion is expected within 10 weeks.
M1: Core Architecture & SDK Integration
Tasks:
- Install Viem, Wagmi, and Reown.
- Configure the new provider architecture behind an existing LaunchDarkly feature flag (reusing CoW Swap’s current flag infrastructure).
- Switch CoW SDK to use ViemAdapter (leveraging our previous grant work), while keeping EthersV5Adapter available as a fallback behind the flag.
- Implement a compatibility hook for legacy components that provides wallet and chain state from a single interface. The hook will internally decide whether to fetch data from the old or new stack based on the feature flag, allowing all components to use a consistent API during the gradual migration.
Deliverables:
- Functional app built with the new stack wired and hidden behind a LaunchDarkly feature flag.
- Short architecture documentation describing the new connection layer, feature-flag wiring, and SDK integration (ViemAdapter vs Ethers adapter).
M2: Wallet Connection & EIP-6963
Tasks:
- Implement Reown (AppKit) connection flows.
- Replace custom EIP-6963 support with native Wagmi support (fixing multi-injected wallet conflicts).
- Migrate Trezor connection logic to Wagmi/Reown (or adapter) while preserving feature parity (account selection, signing).
- Implement robust connect/disconnect handling for all supported wallets.
- Keep the existing Web3React connection system running in parallel behind the feature flag for safe comparison and fallback.
Note on Trezor verification: Trezor hardware wallet validation requires CoW team assistance for device testing. We will coordinate testing sessions with team members who have Trezor devices to validate account selection, message signing, and order signing flows.
Deliverables:
- All existing wallet connectors (EIP-6963, injected extensions including mobile, WalletConnect, Coinbase, and Gnosis Safe) connecting via Wagmi/Reown;
- No remaining custom EIP-6963 patches or Web3React-based shims;
M3: Safe Wallet Integration
Tasks:
- Upgrade the Safe SDK stack (@safe-global/api-kit, @safe-global/protocol-kit, @safe-global/safe-core-sdk-types) to the target versions listed in Key Dependencies to Update, and remove @safe-global/safe-ethers-lib.
- Integrate Safe Apps SDK v2
- Implement Safe detection (Safe iframe and Safe via WalletConnect).
- Ensure bundle transaction support (approval + presign flows) for Safe.
- Retrieve Safe metadata such as owners, chain, and context for UX.
Deliverables:
- Parity with existing Safe functionality.
- Tested flows for Safe connection, signing, and bundled transactions;
M4: Chain Selection & Network Handling
Tasks:
- Migrate chain switching logic for all 11 supported networks to Wagmi/Viem.
- Handle “Unsupported Network” states gracefully in the UI.
- Improve RPC error messages and auto-switch flows where appropriate.
Deliverables:
- Robust network switching via Wagmi hooks, including error handling.
- Frontend reading chain state exclusively from the new connection layer when enabled.
M5: QA, Testing & Staged Rollout
Tasks:
- Introduce or significantly expand automated end-to-end tests (e.g. Cypress/Playwright) for wallet connect/disconnect, chain switching, and basic trading flows, given current limited automated coverage.
- Test mobile WalletConnect on iOS and Android (Reown AppKit).
- Enable the feature flag on Staging and run both stacks in parallel;
- Monitor logs, metrics, and user feedback for regressions – in coordination with the CoW Swap frontend team.
M6: Frontend Route Migration
Tasks:
- Update wallet state usage across critical routes:
- Swap widget
- Order history
- Balances
- Limit Orders
- TWAP and related advanced order flows
- Ensure components no longer depend directly on Web3React hooks, relying instead on Wagmi/Viem (or the compatibility shim where absolutely necessary).
- Fix any remaining ethers-based patterns in these frontend routes as they relate to wallet/connection logic.
Deliverables:
- All targeted routes functioning with the new wallet/chain state.
- Visual and behavioral parity verified for these routes.
- No direct Web3React usage in the frontend routes covered by this milestone.
M7: Cleanup & Documentation
Tasks:
- Delete Web3React code (47+ files and related helpers).
- Remove @web3-react/* packages from package.json.
- Remove Ethers.js-based wallet/connection usage from the frontend path (including the EthersV5Adapter code path for the SDK).
- Update TypeChain configuration and generated types so that frontend contract interactions use Viem-compatible typings/ABIs instead of ethers-v5 targets.
- Migrate remaining BigNumber-based wallet/frontend code to bigint/Viem primitives;
- Remove the migration feature flag once production is stable and the new stack is validated.
Deliverables:
- Clean codebase with:
- Zero Web3React imports or dependencies.
- Zero EthersV5Adapter usage in the frontend.
- No Ethers.js usage in the wallet/frontend path covered by this grant.
- TypeChain removed, using SDK instead.
- A short architecture/migration note (ADR-style) explaining key decisions for future maintainers.
Length
(Suggested) Start Date: January 5th
Expected Completion: Up to 10 weeks from commencement
Funding Request
Total Funding: 28,200 xDAI
Payment Information
Gnosis Chain Address: 0x554866e3654E8485928334e7F91B5AfC37D18e04
Terms and Conditions
By submitting this grant application, I acknowledge and agree to be bound by the CoW DAO Participation Agreement and the CoW DAO Grant Agreement Terms.