cowprotocol / services

Off-chain services for CoW Protocol
https://cow.fi/
Other
199 stars 78 forks source link

chore: Automatically index CoW AMMs #2774

Closed MartinquaXD closed 4 months ago

MartinquaXD commented 5 months ago

Background

Currently we have to maintain a list of existing CoW AMMs. This is error prone and also just annoying. Instead we should add have a single CLI argument to pass the CoW AMM factory contract and "listen" for Deployed events. That way we automatically know about any new pool that gets deployed.

As the first step I would simply refetch all such events since contract deployment on every restart (to get the ball rolling). If this takes too much time we can consider persisting these events in our DB like we do with other events. For related code check the EventHandler and EventUpdater.

MartinquaXD commented 5 months ago

Pre-requisite for https://github.com/cowprotocol/services/issues/2755

fleupold commented 5 months ago

I wouldn't suggest doing that for the soon legacy CoW AMM pools (that are created via the factory) but instead focus on the Balancer created CoW AMM. At least the code should allow to easily add new types of creating CoW AMMs that get indexed.

MartinquaXD commented 5 months ago

Absolutely. But overall I don't expect the infra to be built to change in any meaningful way when we have to switch over to balancer developed cow amms. This issue is intended to make us ready from day one to include these pools instead of scrambling to add support after they get launched officially and until then we might as well index the current version of cow amms.

m-lord-renkse commented 4 months ago

Done in https://github.com/cowprotocol/services/pull/2790