Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement tryCalcRate, implement new precision. #146

Merged
merged 3 commits into from
Oct 6, 2024
Merged

Conversation

Brean0
Copy link
Contributor

@Brean0 Brean0 commented Sep 29, 2024

Problem

When MultiFlowPump attempts to Cap the change in ratio of reserves, It calls WellFunction.calcRate(..) in order to calculate the last rate with the last reserves, and the current rate. If calcRate fails, then the Pump reverts, and thus bricks the Well.

When MultiFlowPump attempts to calculate the Capped Reserves, it assumes the Well uses a Constant Product 2 Well Function.

Solution

  • Update MultiFlowPump to fail gracefully when calcRate fails.

  • Update IMultiFlowWellFunction to implement ratioPrecision(uint256 j, bytes data), which returns the precision that the MultiFlowPump should use when calculating the capped Reserves.

  • Update MultiFlowPump to use ratioPrecision when calculating for ratios[j] in calcReservesAtRatioSwap.

  • Update ConstantProduct2, ConstantProduct, and Stable2 to implement ratioPrecision.

  • Update IWellFunction to implement version(), allowing users to verify WellFunctions.

@Brean0 Brean0 merged commit 830ccd8 into master Oct 6, 2024
2 checks passed
@Brean0 Brean0 deleted the multi-flow-pump-v1.2 branch October 6, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant