TokenEngineeringCommunity / BalancerPools_Model

cadCAD model to simulate Balancer AMMs
MIT License
54 stars 29 forks source link

Fetch weights/fee _state changes_ from GBQ, not the reconstructed state #76

Open markusbkoch opened 3 years ago

markusbkoch commented 3 years ago

The following is downloading the reconstructed state from GBQ, which is very resource intensive. GBQ has to process all state changes to reconstruct the state at every block and the downloaded dataset is much larger than it needed be, since most of the time weights and fees remains constant. Most pools are finalized and those parameters can't change at all.

https://github.com/TokenEngineeringCommunity/BalancerPools_Model/blob/9489bb040f90c546b925de1c86b35364a08df6dd/data/pulldata.py#L228-L231

I suggest this be modified so as to only download the state changes (basically the events subquery in view_pools_fees.sql and view_pools_weights.sql) and the state be reconstructed as part of the cadCAD simulation. This would be analogous to the current approach for swaps, joins, exits.