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

S2 upgr well remediations 2 #145

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

Brean0
Copy link
Contributor

@Brean0 Brean0 commented Sep 6, 2024

This PR addresses the findings found from the codeArena remediation audit.

  • decreased PRICE_THRESHOLD from 100 to 10, used in calcReservesAtRatioSwap and calcReserveAtRatioLiquidity. This significantly increases the accuracy of the reserve with a marginal increase in gas.
  • In extreme edge cases, calcLpTokenSupply would not converge at extreme ratios, and would instead oscillate +/- 2 unit around the target value. An boolean check was added if this case occurred, which stops the infinite loop and return the average.
  • Stable2 currently sets the initial step size and reserves by checking the absolute difference between the target price and the high/low price from the lookup table. This results in cases where the price may be marginally closer to the target price, but in practice, the reserves are much further from the target reserves (which is most obvious in the extreme range case). This caused the newton estimation to iterate through many more times than expected. Stable2 now checks the percent difference instead, which is a much more precise check to set the guess.

@Brean0 Brean0 merged commit ff0936e into s2-upgr-well-remediations Sep 6, 2024
2 checks passed
@Brean0 Brean0 deleted the s2-upgr-well-remediations-2 branch September 6, 2024 09:35
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