# Grant Application: CoW BYOS — Bring Your Own Solver

- Space: [CoW DAO Grants](https://snapshot.box/s:cowgrants.eth.md)
- Author: 0xa90914762709441d557De208bAcE1edB1A3968b2
- State: Passed
- Voting type: Basic
- Start: 2026-07-06 12:00 UTC
- End: 2026-07-09 12:00 UTC
- Votes: 3
- Quorum: 3 voting power
- Discussion: https://forum.cow.fi/t/grant-application-cow-byos-bring-your-own-solver/3476
- Open in Snapshot: https://snapshot.box/#/s:cowgrants.eth/proposal/0x20ccb47133bfa19561197acc9e083f36a08cdaccde0af90bacca0a575df532b2

## Results

- For: 3 voting power, 100.0%
- Against: 0 voting power, 0.0%
- Abstain: 0 voting power, 0.0%

## Proposal

**Grant Title:**

CoW BYOS — Bring Your Own Solver

---

**Author:**

[@bleu](https://github.com/bleu-studio) [@jean-neiverth](https://github.com/jean-neiverth) [@yvesfracari](https://github.com/yvesfracari) [@mendesfabio](https://github.com/mendesfabio)

---

**About You:**

bleu collaborates with companies and DAOs as a web3 technology and user experience partner. We have completed 12+ grants for CoW Protocol, building core infrastructure and developer tooling across the CoW ecosystem.

---

**Additional Links:**

- [Offline Development Mode](https://forum.cow.fi/t/grant-application-cow-playground-offline-development-mode/3262): Self-contained local environment for CoW Protocol backend (autopilot, driver, settlement contracts, baseline solver).
- [Framework-agnostic SDK](https://forum.cow.fi/t/grant-application-framework-agnostic-sdk/2811): Modular monorepo refactor of the CoW SDK supporting multiple EVM adapters.
- [Programmatic Orders API](https://forum.cow.fi/t/grant-application-programmatic-orders-api/3346): Indexing infrastructure for all programmatic order types.
- [Hook dApps](https://forum.cow.fi/t/grant-application-cow-hooks-dapps/2544): Suite of hook dApps including `cow-shed` module (CREATE2 proxy pattern reused in BYOS Trampoline).
- [Silo Finance](https://www.silo.finance/): Lending protocol backend services, liquidation bot, incentives, indexers, and [public API](https://silodocs2.netlify.app/docs/developers/apis/api-overview).

---

**Grant Category:**

Core Infrastructure & Solver Development

---

**Grant Description:**

CoW DAO's [BYOS RFP](https://forum.cow.fi/t/rfp-bring-your-own-solver-byos/3469) describes a bonded solver that opens CoW's auction to permissionless sub-solvers — participants who compute routes for individual orders without the overhead of becoming a bonded solver. We propose to build the complete BYOS system: solver engine, Trampoline contract, Escrow contract, public Proposal API, audit remediation, and gnosis + mainnet deployment with live sub-solver onboarding.

Architecture research and an initial PoC ([BYOS crate](https://github.com/bleu/cowprotocol-services/tree/byos-api/crates/byos), [sub-solver crate](https://github.com/bleu/cowprotocol-services/tree/byos-api/crates/subsolver)) are already complete, covering the proposal API skeleton, EIP-712 schema, Trampoline calldata encoding, and a working sub-solver client.

The sections below describe our **initial design decisions**, **subject to change** based on reviewer feedback and testing findings.

#### Trampoline: one instance per sub-solver

One CREATE2 Trampoline instance per sub-solver address. Isolation ensures residual state (approvals, balance) from one settlement cannot be exploited by another sub-solver. The zero-balance post-condition (sweep remainder back to `GPv2Settlement`) is enforced regardless. Per-instance addresses in calldata also enable clean attribution for escrow debits.

#### Escrow contract

Per-chain, native-token, immutable contract with owner/operator separation. **Owner** (multisig): sets operator, configures cooldown, withdraws debits. **Operator** (BYOS EOA): debits sub-solvers, freezes/unfreezes — cannot withdraw or change config. Depositing grants blanket debit authority up to balance. Withdrawal with configurable cooldown; freeze blocks `executeWithdrawal()` only. No proxy, no upgrade key.

#### API & execution authority

Gated routes require an EIP-712 signature over the request payload, recovered to the caller's address.

| Route | Auth | Description |
|---|---|---|
| `POST /proposals` | gated | Submit proposal with interactions + EIP-712 sig |
| `GET /proposal/{id}` | public | Single proposal status |
| `GET /proposals/{subsolver_address}` | gated | Caller's active proposals |
| `DELETE /proposal/{id}` | gated | Cancel proposal |

![byos-diagram.png](ipfs://bafkreig56vckxw7hulxaddxaxcoargfethrwpm7jmpb27ic4hwaswanxym)

**Signature-gated Trampoline execution:** The sub-solver's EIP-712 signature commits to amounts and `interactionsHash`. The Trampoline verifies `keccak256(abi.encode(interactions)) == interactionsHash` before executing, preventing fabricated faults and making Track A debits indisputable.

**Rate limiting:** IP-based coarse filter + signer-based fine limit scaled by escrow balance tier.

![lifecycle-diagram.png](ipfs://bafkreicjhdtwofgf25fpz4szgeyk5nuai32x4mcy3u7son2rezu2cyi3wi)

#### Solver engine

A thin scoring layer serving `/solve` from an in-memory cache. Pre-ranking via `score = surplus + fee - gas`, returning the highest-scoring proposal per order UID. Singleton settlement per sub-solver for clean attribution (batching to be evaluated during M1). Each solution wrapped in a single `Trampoline_S.execute(signature, interactions)` call. Continuous re-simulation every 3–5 blocks with permanent drop on revert. Self-contained chain monitoring for settlement outcomes and Track A escrow debits.

No simulation, no RPC calls, no database queries on the `/solve` hot path.

#### Settlement value flow

1. `GPv2Settlement` pulls user's `sellAmount` via vault relayer.
2. `sellToken.transfer(Trampoline_S, sellAmount)` pushes trade capital into the instance.
3. `Trampoline_S.execute(signature, route, buyToken, buyAmount)` verifies signature, runs interactions, transfers exactly `buyAmount` back to `GPv2Settlement`.
4. `GPv2Settlement` pays the user.

The trade is **self-funding**: if the route produces less than `buyAmount`, the transfer reverts atomically and BYOS's buffer is never net-drained.

![trampoline-diagram.png](ipfs://bafkreigybljl3epn4mdj72la3abyc3cqm5hkdvylwu2axz2qdz6qawqmpi)

#### Escrow lifecycle & slashing

Reproduces CoW Protocol's existing penalty framework (Track A/B) adapted for the BYOS-to-sub-solver relationship.

**Track A (revert/gas penalties):** BYOS-unilateral, immediate. Debits `gas + c_l` from escrow. On-chain-verifiable via tx receipt and Trampoline CREATE2 address. 72h dispute window.

**Track B (EBBO/fairness):** CoW core team as arbiter. BYOS freezes escrow, relays evidence, 36h challenge window — mirrors CoW's own penalty process.

![escrow-diagram.png](ipfs://bafkreicj2dl54vrtokyk6yjb7c2d4r7ar2oof7vxvt4le7ajn6fcg6wqc4)

#### Sub-solver strategy

The grant includes a **baseline reference sub-solver** for integration testing. Future production sub-solvers for specific protocols are **outside grant scope** but represent bleu's long-term incentive to keep BYOS operational — each integration is a project opportunity that only exists if BYOS works well.

---

**Grant Goals and Impact:**

- **Permissionless access** to CoW solver competition without the overhead of becoming a bonded solver.
- **New liquidity sources** from sub-solvers routing through any DEX or protocol.
- **Self-sustaining system** via CoW's standard reward mechanism — no ongoing grant funding needed.
- **Open-source** under an OSI-approved license.

---

**Milestones:**

| Milestone | Duration | Payment |
|-----------|----------|---------|
| M1: Contracts & Design | 6 weeks | 18,000 USDC |
| M2: Solver Engine, API & Staging | 5 weeks | 15,000 USDC |
| M3: Audit Remediation, Gnosis & Mainnet | 3 weeks | 9,000 USDC |

### M1: Contracts & Design (6 weeks, 18,000 USDC)

- Final design document (Trampoline topology, proposal schema, escrow interface, fee mechanism, slashing policy).
- BYOS app with proposals API, EIP-712 schema, solve endpoint, Trampoline calldata encoding, scoring, Escrow operator for Track A/B.
- Trampoline contract: per-sub-solver CREATE2 instances, factory, signature-gated `execute`, zero-balance sweep.
- Escrow contract: owner/operator roles, blanket debit, withdrawal with cooldown, freeze semantics.
- Full test suite and audit-ready package. Audit begins immediately after M1, running in parallel with M2.
- **Offline-mode testing** using CoW's [Offline Development Mode](https://github.com/cowdao-grants/offline-mode): happy paths, malicious sub-solver behavior, malformed orders, Track A/B scenarios, and lifecycle edge cases.

### M2: Solver Engine, API & Staging (5 weeks, 15,000 USDC)

- Final BYOS app with complete validation, rate limiting, continuous simulation, settlement watcher, fee mechanism.
- Solver engine integrated with CoW driver/autopilot on staging.
- Public Proposal API live; at least one sub-solver settling on staging.
- Deployment documentation and operational runbook.

### M3: Audit Remediation, Gnosis & Mainnet (3 weeks, 9,000 USDC)

- Audit findings remediated.
- Contracts deployed and BYOS operational on Gnosis Chain.
- Bonded solver onboarded on Ethereum mainnet with at least one external sub-solver settling live orders.
- Monitoring and operational runbook in place.

---

**Funding Request:**

Total: **42,000 USDC** (or other stablecoin) at **3,000 USDC/week**. Milestone payments released upon each milestone's approval. No COW token vesting — BYOS should be profitable via CoW's reward mechanism.

---

**Gnosis Chain Address (to receive the grant):**

0x5D40015034DA6cD75411c54dd826135f725c2498

---

**Other Information:**

- We will work closely with the Core Team Reviewer on open design decisions.
- The 14 weeks represent active engineering; the overall timeline will be longer due to expected idle periods (audit, stabilization).
- The security audit is expected to be coordinated with CoW DAO (audit cost not included in this grant).
- For a more detailed version of this proposal, please visit the forum discussion attached below.

---

**Terms and Conditions:**

By submitting this grant application, we acknowledge and agree to be bound by the [CoW DAO Participation Agreement](https://bafybeihzwhrc5ioaasi3pcvq4fjrwe7b4hjxcahqvvffgfcw7rg4ejo2du.ipfs.inbrowser.link/) and the [CoW Grant Terms and Conditions](https://bafybeifxjfmo2ubbnrmz32gwzh5wh7uetqa323wrpn57bagkfosfwlmx7u.ipfs.inbrowser.link/).

---

To vote or create proposals from an AI assistant, connect the Snapshot MCP at https://mcp.snapshot.box

