Skip to content

[good first issue] Add CoW Protocol v2 intent decoder (similar to Across) #4

@abhicris

Description

@abhicris

Context

resolver currently decodes two protocols: Across (src/intents/across.rs, landed in PR #3) and UniswapX (src/intents/uniswapx.rs). The Protocol enum in src/intents/types.rs already lists CowProtocol as a variant, but there is no decoder implementation. CoW Protocol's GPv2 orders (https://docs.cow.fi) are the third major intent source and need the same IntentDecoder shape as the other two so the solver engine can ingest them uniformly.

Scope

  • Create src/intents/cow.rs implementing IntentDecoder for CoW:
    • CowDecoder::new(chain: Chain) constructor.
    • fetch_open_intents — hits the CoW API (https://api.cow.fi/mainnet/api/v1/auction for mainnet; the CoW orderbook API endpoint list is in their docs).
    • decode(raw: &[u8]) — initially return ResolverError::Intent("raw CoW decoding not yet implemented") (mirroring UniswapXDecoder).
    • protocol() returns "CoW".
  • Parse the CoW auction JSON into Intent (token in/out, amount in, minBuy as min_amount_out, deadline from validTo, receiverrecipient).
  • Re-export CowDecoder from src/intents/mod.rs.
  • Add at least 2 unit tests using a golden CoW auction JSON fixture (save as tests/fixtures/cow_auction.json) — offline, no network.

Acceptance criteria

  • cargo test green including new tests.
  • cargo clippy --all-targets -- -D warnings clean.
  • Fixtures committed, not fetched at test time.
  • Protocol enum usage: a decoded Intent has protocol == Protocol::CowProtocol.

Reference: src/intents/uniswapx.rs for the full shape (API parse → Intent); src/intents/across.rs (PR #3) for how offline-parse unit tests are structured.

Estimated effort

S (3–5 hours)

kcolbchain / Abhishek Krishna

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions