Ponder-based indexer and GraphQL API for CoW Protocol Composable CoW programmatic orders. Indexes on-chain events from the ComposableCoW contract, decodes order types, and exposes queryable data via GraphQL and SQL endpoints.
Built by @bleu as part of the CoW Grants Program.
- Ponder 0.16.x — blockchain indexing framework
- TypeScript — type-safe handlers and API
- viem — Ethereum interaction and ABI encoding
- Hono — lightweight web framework for API routes
- PostgreSQL — production database (SQLite for local dev)
ComposableCoW contract (Ethereum mainnet)
↓ events
ponder.config.ts ← src/data.ts (contract addresses + start blocks)
↓
src/application/handlers/ (event handlers)
↓
schema/tables.ts (table definitions)
↓
src/api/index.ts (Hono: /graphql + /sql/*)
| Path | Purpose |
|---|---|
abis/ |
Contract ABIs |
src/data.ts |
Chain configs and contract addresses |
schema/tables.ts |
Table definitions |
schema/relations.ts |
Drizzle relations |
src/application/handlers/ |
Event handlers (one file per contract) |
src/api/index.ts |
API layer — GraphQL and Ponder SQL client |
ponder.config.ts |
Ponder configuration (chains, contracts) |
- Node.js >= 18.14
- pnpm
- Docker (optional, for PostgreSQL)
git clone https://github.com/bleu-fi/cow-programmatic-orders-api.git
cd cow-programmatic-orders-api
pnpm installCopy the example env file and configure your RPC URL:
cp .env.example .env.localEdit .env.local and set at minimum:
MAINNET_RPC_URL=https://your-rpc-urlSQLite (default for local dev): No setup needed — Ponder uses SQLite by default.
PostgreSQL: Start the included Docker container:
docker compose up -dThis starts PostgreSQL on port 5432 with the connection string already configured in .env.example:
postgresql://postgres:postgres@localhost:5432/programmatic-orders
pnpm devThis starts the Ponder dev server, which will:
- Sync historical blocks from the configured start block
- Index
ConditionalOrderCreatedevents from the ComposableCoW contract - Serve the GraphQL API at
http://localhost:42069 - Serve the SQL endpoint at
http://localhost:42069/sql
pnpm startThe Ponder SQL client is available at /sql/* for direct SQL-style queries against the indexed data.
pnpm dev # Start the indexer in dev mode
pnpm codegen # Regenerate types (run after config/schema changes)
pnpm typecheck # TypeScript type checking
pnpm lint # ESLintGitHub Actions runs lint, typecheck, and codegen verification on every push to main and on pull requests.
This project is developed across four milestones:
| # | Milestone | Scope |
|---|---|---|
| 1 | Composable CoW Tracking | Event indexing, historical backfill, order type decoders (TWAP, Stop Loss, Perpetual Swap, GAT, TAT) |
| 2 | Flash Loan & CoWShed | Flash loan order-to-EOA mapping, CoWShed proxy ownership resolution |
| 3 | Orderbook Integration | Historical/real-time orderbook data, order matching, execution status, off-chain cache |
| 4 | Review & Documentation | Technical review, API docs, integration guides |
- Grant Application (CoW Forum)
- Composable CoW Repository
- CoW Protocol Programmatic Orders Docs
- Ponder Documentation
Open source. All code is open-source from day 0 and will be handed off to the CoW Protocol team after grant completion.