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

CalcReserve extreme values fix [#25] [#22] #137

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

Brean0
Copy link
Contributor

@Brean0 Brean0 commented Aug 13, 2024

calcReserveAtRatioSwap and calcReserveAtRatioLiquidity utilize a LUT to decrease the computation needed to estimate the reserves. When this function is called at extremely high or low values, the function can revert due to overflow or the function not converging.

This PR implements the following:

  • readjusts the max step size when scaledReserve[j] is updated. This ensures that maxStep size can never be larger than the j reserve.

  • In the case where newton's method overestimates, set high/low price to the new price, which guarantees convergence.

This PR resolves #25 and #22.

@nickkatsios nickkatsios changed the title init CalcReserve extreme values fix Aug 14, 2024
@nickkatsios nickkatsios changed the base branch from stableswapWF-2 to s2-upgr-well-remediations August 15, 2024 12:15
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.

2 participants