curveresearch / curvesim

Simulates Curve Finance pools
MIT License
155 stars 32 forks source link

Use Curve Prices API for pool volume #277

Closed nagakingg closed 1 year ago

nagakingg commented 1 year ago

Description

Updates historical pool volume functionality to use the new Curve Prices API. Pool volume for each token pair is denominated in the pair's quote token, rather than pseudo-dollars, to allow for correct volume limiting for v2 pools. In the volume-limited arbitrage pipeline, volume multipliers are computed for each pair using this data. Volume limiter modes are removed as this method is more accurate than all of the previous modes, which relied on aggregate pool volume across all pairs.

Hygiene checklist

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

nagakingg commented 1 year ago

A few open questions:

Edit:

github-actions[bot] commented 1 year ago

Coverage report

The coverage rate went from 76.03% to 78.08% :arrow_up: The branch rate is 64%.

91.15% of new lines are covered.

Diff Coverage details (click to unfold) ### curvesim/exceptions/__init__.py `100%` of new lines are covered (`100%` of the complete file). ### curvesim/network/curve_prices.py `91.42%` of new lines are covered (`86.84%` of the complete file). Missing lines: `47`, `48`, `122` ### curvesim/pipelines/vol_limited_arb/__init__.py `16.66%` of new lines are covered (`36.36%` of the complete file). Missing lines: `94`, `103`, `104`, `105`, `106` ### curvesim/pool/__init__.py `0%` of new lines are covered (`72.63%` of the complete file). Missing lines: `279` ### curvesim/pool_data/__init__.py `100%` of new lines are covered (`100%` of the complete file). ### curvesim/pool_data/queries/__init__.py `100%` of new lines are covered (`100%` of the complete file). ### curvesim/pool_data/queries/metadata.py `100%` of new lines are covered (`88%` of the complete file). ### curvesim/pool_data/queries/pool_volume.py `98.24%` of new lines are covered (`95.45%` of the complete file). Missing lines: `93`
nagakingg commented 1 year ago

Comparing 3pool sim results before and after the volume limit change. As expected: (a) Old version volume limits are roughly the average of the new version volume limits (b) the results are similar but not exactly the same

Volume Limits Old version: DAI/USDC: 0.000037 DAI/USDT: 0.000037 USDC/USDT: 0.000037

New version: DAI/USDC: 0.000016 DAI/USDT: 0.000022 USDC/USDT: 0.000054

Results Old Version: 3pool_old

New Version: 3pool_new