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

Resolve DIV/0 unstaking in a burn epoch with no burn #748

Merged
merged 5 commits into from
Apr 18, 2023

Conversation

EdNoepel
Copy link
Contributor

@EdNoepel EdNoepel commented Apr 17, 2023

Description of change

High level

Resolves bug if user unstakes following a burn epoch where nobody bid on the reserve auction.
Out of scope: Fuzz test improvements to capture scenario of 0 takes (this issue) or > 1 take.

Description of bug or vulnerability and solution

Resolves #744.

Contract size

Pre Change

============ Deployment Bytecode Sizes ============
  RewardsManager           -   9,509B  (38.69%)

Post Change

============ Deployment Bytecode Sizes ============
  RewardsManager           -   9,539B  (38.81%)

Gas usage

Slightly higher median cost due to 0 checks.

Pre Change

src/RewardsManager.sol:RewardsManager contract
Function Name min avg median max # calls
calculateRewards 33603 45828 35922 163586 125
claimRewards 500 111048 104047 392830 128
getBucketStateStakeInfo 704 2702 2704 2704 81279
getStakeInfo 727 727 727 727 159
moveStakedLiquidity 1834728 1990365 1990365 2146003 2
stake 119064 346317 313046 894723 37
unstake 78743 180958 141392 398959 11
updateBucketExchangeRatesAndClaim 9680 254216 186927 537881 34

Post Change

src/RewardsManager.sol:RewardsManager contract
Function Name min avg median max # calls
calculateRewards 33637 43022 35956 163688 291
claimRewards 500 112788 104081 392932 294
getBucketStateStakeInfo 704 2702 2704 2704 81279
getStakeInfo 727 727 727 727 334
moveStakedLiquidity 1834728 1990391 1990391 2146055 2
stake 119064 314061 197504 894723 46
unstake 78743 176425 141420 399137 13
updateBucketExchangeRatesAndClaim 9680 236554 176202 538191 44

@EdNoepel EdNoepel marked this pull request as ready for review April 17, 2023 15:16
Copy link
Contributor

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@MikeHathaway MikeHathaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants