darkforestry / amms-rs

A Rust library to interact with automated market makers across EVM chains.
438 stars 117 forks source link

feat: v2 + v3 factory address tracked for better discovery debugging / analysis #215

Open HilliamT opened 1 month ago

HilliamT commented 1 month ago

Motivation

A factory_address field in V2 and V3 proves helpful in understand what pools from which factories are discovered via the PairCreated / PoolCreated event. This can also prove helpful in analysing the contributions from which V2-like / V3-like protocols in pathing e.g 0x-style.

image

Solution

PR Checklist

0xKitsune commented 4 weeks ago

Thanks for the PR, this change makes sense to me!

Thoughts on making thefactory_address optional? There are some cases where a user may want to initialize a handful of pools with new_from_address without needing to know the factory.

HilliamT commented 2 weeks ago

@0xKitsune Apologies for the delay - makes sense for factory_address to be optional.

One later function that can be added as a filter is to filter in only e.g v2 / v3 AMMs with a whitelisted factory_address, especially after discovering other AMMs from merely logs. This does require more thinking of how other AMM cases should be handled though, but can be done later when better thought out.