This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
KupiaSec - Pending rewards need to be processed when BribeRewarder.Deposit()
is called
#585
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Escalation Resolved
This issue's escalations have been approved/rejected
High
A High severity issue.
Reward
A payout will be made for this issue
KupiaSec
High
Pending rewards need to be processed when
BribeRewarder.Deposit()
is calledSummary
The issue is that when the
BribeRewarder.Deposit()
function is called, the pending bribe rewards are not being processed. This can lead to an incorrect calculation of theaccDebtPerShare
value. As a result, the overall distribution of bribe rewards may be incorrect.Vulnerability Detail
In the
BribeRewarder.Deposit()
function,_modify()
is called and_lastUpdateTimestamp
is updated toblock.timestamp
.https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L143-L147
However, the rewards accrued in the previous epochs is not processed.
Assume that
BribeRewarder.Deposit()
is called withVoter.startNewVotingPeriod()
in the same transaction. Then,_lastUpdateTimestamp
is updated tostartTime
of the new epoch. It means that all the total pending rewards is not calculated.https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L260-L298
Impact
Bribe rewards can be distributed incorrectly.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L143-L147
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L260-L298
Tool used
Manual Review
Recommendation
Pending rewards need to be processed when
BribeRewarder.Deposit()
is called.Duplicate of #52
The text was updated successfully, but these errors were encountered: