Skip to content

feat: modularize ponder config with per-chain src/chains/ (COW-978)#67

Merged
lgahdl merged 10 commits into
developfrom
luizhatem/cow-978-modularize-ponder-config-per-chain-files-under-srcchains
May 29, 2026
Merged

feat: modularize ponder config with per-chain src/chains/ (COW-978)#67
lgahdl merged 10 commits into
developfrom
luizhatem/cow-978-modularize-ponder-config-per-chain-files-under-srcchains

Conversation

@lgahdl
Copy link
Copy Markdown
Contributor

@lgahdl lgahdl commented May 28, 2026

Summary

  • Extract per-chain contract addresses and config into src/chains/, one file per chain (mainnet.ts, gnosis.ts, arbitrum.ts stub)
  • A central src/chains/index.ts exports ACTIVE_CHAINS: ChainConfig[]; ponder.config.ts becomes a pure derivation with no hardcoded addresses
  • Enabling or disabling a chain is a single commented/uncommented line in src/chains/index.ts

Changes

  • Added src/chains/types.tsChainConfig interface with all per-chain fields
  • Added src/chains/mainnet.ts, src/chains/gnosis.ts — full chain configs
  • Added src/chains/arbitrum.ts — placeholder with commented-out config (addresses not yet confirmed)
  • Added src/chains/index.ts — exports ACTIVE_CHAINS and re-exports ChainConfig
  • Refactored ponder.config.ts — all config derived via Object.fromEntries(ACTIVE_CHAINS.map(...)); imports CoWShedFactoryAbi and GPv2SettlementAbi directly
  • Updated src/data.ts — removed per-chain deployment objects; BLOCK_TIME_SECONDS, COMPOSABLE_COW_ADDRESS_BY_CHAIN_ID, AAVE_V3_ADAPTER_FACTORY_ADDRESSES, GPV2_SETTLEMENT_DEPLOYMENTS, and ORDERBOOK_API_URLS now derived from ACTIVE_CHAINS

How to Test

  1. pnpm codegen — should complete without errors
  2. pnpm typecheck — should pass
  3. pnpm lint — should pass
  4. Comment out gnosis in src/chains/index.ts and verify pnpm typecheck still passes (single-chain deploy works)

Breaking Changes

None — runtime behavior is identical. src/data.ts no longer exports COMPOSABLE_COW_DEPLOYMENTS, ComposableCowContract, COW_SHED_FACTORY_DEPLOYMENTS, CoWShedFactoryContract, GPv2SettlementContract, or FLASH_LOAN_ROUTER_ADDRESSES; the only consumers were ponder.config.ts (now using chains directly).

Related Issues

COW-978

… (COW-978)

Extract per-chain addresses into src/chains/{mainnet,gnosis,arbitrum}.ts with
a central ACTIVE_CHAINS index. ponder.config.ts now derives all config with no
hardcoded addresses. Toggling a chain requires one line in src/chains/index.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 28, 2026

COW-978

Copy link
Copy Markdown

@yvesfracari yvesfracari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple mainnet and gnosis mentions on docs and etc that will be outdated once a new chain is added. Also, the chain ids supported should be imported from cow-sdk as Anxo said to us on the feedback, making missing chains be throw by typescript error. Let me know if you think that this should be addressed on another PR

Comment thread src/chains/arbitrum.ts
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should add all current cow chains in this PR and just having somekind of filter to only run gnosis and mainnet.

Comment thread src/chains/gnosis.ts Outdated
},
flashLoanRouter: "0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69", // confirmed via ROUTER() on Gnosis AaveV3AdapterFactory
aaveV3AdapterFactory: "0xdeCc46a4b09162f5369c5c80383aaa9159bcf192", // verified on Gnosisscan
contractPollerInterval: 4, // ~20s — avoids wasteful RPC calls given 1,461+ generators
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would derivate this from chain time

@lgahdl lgahdl changed the base branch from main to develop May 28, 2026 16:52
- Use SupportedChainId from @cowprotocol/cow-sdk for chainId typing in ChainConfig
- Derive contractPollerInterval from blockTime via pollerInterval() helper (~20s target)
- Add arbitrum, base, and sepolia chain config files (cowShedFactory/gpv2Settlement
  marked null until addresses are confirmed)
- Export ALL_DEFINED_CHAINS for ORDERBOOK_API_URLS; ACTIVE_CHAINS stays mainnet+gnosis
- Make cowShedFactory nullable in ChainConfig; filter in ponder.config.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lgahdl lgahdl requested a review from yvesfracari May 28, 2026 20:21
Copy link
Copy Markdown
Contributor

@jeffersonBastos jeffersonBastos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown

@yvesfracari yvesfracari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding this PR should add all the cow deployed chains as well. However, there are multiple missing (BNB, Avalanche, etc)

Comment thread src/chains/base.ts Outdated
Comment on lines +18 to +21
cowShedFactory: null, // TODO: confirm CoWShedFactory address on Base
gpv2Settlement: null, // TODO: enable once AaveV3AdapterFactory is confirmed on Base
flashLoanRouter: null, // TODO: confirm via ROUTER() on Base AaveV3AdapterFactory
aaveV3AdapterFactory: null, // TODO: verify on Basescan
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding this should be done on this PR, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm addressing this on #76

Comment thread src/chains/arbitrum.ts Outdated
flashLoanRouter: null, // TODO: confirm via ROUTER() on Arbitrum AaveV3AdapterFactory
aaveV3AdapterFactory: null, // TODO: verify on Arbiscan
contractPollerInterval: pollerInterval(blockTime),
orderbookApiUrl: "https://api.cow.fi/arbitrum_one",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick, would change it to orderbookApiPath with only arbitrum_one

lgahdl and others added 3 commits May 29, 2026 16:30
…W-978)

Every chain in cow-sdk's ALL_SUPPORTED_CHAIN_IDS now has a config file in
src/chains/. New stubs (BNB, Polygon, Lens, Plasma, Avalanche, Ink, Linea)
follow the same pattern as existing stubs — composableCow address is the
known CREATE2 deployment; all other addresses are null with TODOs pointing
to the relevant block explorer. None are active until addresses are confirmed
(tracked in COW-986).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…der-config-per-chain-files-under-srcchains' into luizhatem/cow-986-support-all-cow-protocol-chain-ids-bnb-ink-linea-etc
…(COW-986)

Add verified ComposableCoW deployment blocks where confirmed on-chain via
cowprotocol/composable-cow networks.json cross-referenced with block explorers
and public RPC nodes. Also verify orderbook API URLs against cow-sdk
ORDER_BOOK_PROD_CONFIG source.

Verified startBlocks:
- Arbitrum (42161):  204751436 (networks.json + arbiscan)
- Base (8453):        21794150 (basescan, 2024-10-31)
- Sepolia (11155111):  5072748 (networks.json + sepolia.etherscan.io, 2024-01-12)
- BNB (56):           48433175 (networks.json + bscscan.com, 2025-04-17)
- Polygon (137):      70406888 (polygonscan.com, 2025-04-17)
- Lens (232):          3516559 (networks.json + rpc.lens.xyz, 2025-09)
- Plasma (9745):       4810535 (networks.json + rpc.plasma.to)
- Avalanche (43114):  60434336 (snowscan.xyz, 2025-04-17)
- Ink (57073):        34878187 (Blockscout API + rpc-gel.inkonchain.com)
- Linea (59144):      25028474 (networks.json + lineascan.build)

Verified orderbook API URLs (all return HTTP 200 from api.cow.fi):
- bnb, polygon, plasma, avalanche, ink, linea — confirmed active
- lens — NOT yet in cow-sdk ORDER_BOOK_PROD_CONFIG; api.cow.fi/lens returns 404

Also restore CHAIN_NAMES export in src/data.ts (removed during merge conflict
resolution) — derived from ACTIVE_CHAINS.name instead of the old getChainInfo().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lgahdl and others added 2 commits May 29, 2026 17:45
…rbookApiUrl to orderbookApiPath (COW-978)

- Remove contractPollerInterval field from ChainConfig; compute inline in ponder.config.ts via pollerInterval()
- Rename orderbookApiUrl -> orderbookApiPath storing only the path suffix (e.g. "mainnet", "xdai")
- Update src/data.ts to construct full URL from path: https://api.cow.fi/${c.orderbookApiPath}
- Update all 12 chain files accordingly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…978)

Replace placeholder startBlocks (0 / rough estimates) with values verified
from cowprotocol/composable-cow networks.json and block explorers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lgahdl and others added 3 commits May 29, 2026 18:07
…b-ink-linea-etc' into luizhatem/cow-978-modularize-ponder-config-per-chain-files-under-srcchains

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…2Settlement for 5 chains (COW-978)

All addresses confirmed on-chain via ROUTER() call. Deployment blocks verified
by binary search on each chain's RPC.

Chains: arbitrum, base, avalanche, linea, polygon

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…2Settlement for BNB and Plasma (COW-978)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lgahdl lgahdl merged commit a26106b into develop May 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants