Implement tryCalcRate, implement new precision. #146
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When MultiFlowPump attempts to Cap the change in ratio of
reserves
, It callsWellFunction.calcRate(..)
in order to calculate the last rate with the last reserves, and the current rate. IfcalcRate
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 implementratioPrecision(uint256 j, bytes data)
, which returns the precision that the MultiFlowPump should use when calculating the capped Reserves.Update
MultiFlowPump
to useratioPrecision
when calculating forratios[j]
incalcReservesAtRatioSwap
.Update
ConstantProduct2
,ConstantProduct
, andStable2
to implementratioPrecision
.Update
IWellFunction
to implementversion()
, allowing users to verify WellFunctions.