Skip to content

fix: call _updateRewards during claimRewards to transfer correct amount of accumulated DIP - #6

Open
VQToan wants to merge 1 commit into
etherisc:developfrom
VQToan:fix-claim-rewards-zero
Open

VQToan wants to merge 1 commit into
etherisc:developfrom
VQToan:fix-claim-rewards-zero

Conversation

@VQToan

@VQToan VQToan commented May 14, 2026

Copy link
Copy Markdown

Fixes #2

Description

Calling claimRewards() before unstake() incorrectly sends 0 DIP rewards because info.rewardBalance was not being updated with newly accrued rewards before transferring. Meanwhile, _decreaseRewards() updates info.updatedAt to the current block, which essentially resets the reward calculations, wiping out any accumulated rewards the user had.

Changes

  • Added a call to _updateRewards(info) inside the claimRewards(NftId stakeId) function in StakingV01.sol. This ensures that info.rewardBalance accurately reflects the accrued rewards before _claimRewards(user, info) determines the payout amount.
  • This change aligns StakingV01.sol with the correct behavior already present in StakingV02.sol.

This PR was created with AI assistance.

@openzeppelin-code

Copy link
Copy Markdown

fix: call _updateRewards during claimRewards to transfer correct amount of accumulated DIP

Generated at commit: dfbf1461c92dda319a57a4926486b8985cc3ca4d

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
1
0
7
22
30
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
1
8
9

For more details view the full report in OpenZeppelin Code Inspector

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.

[Bug]: claimRewards() is always sending 0 DIP rewards and resets user's rewardsBalance when called before unstake()

1 participant