@0xkitsune
There is actually an example that does exactly this.
https://github.com/darkforestry/amms-rs/blob/main/examples/discover-factories.rs
Note that the discovery module has not been updated recently so lmk if you run into any issues and I can push a patch.