Submitted by Varun_05
https://github.com/code-423n4/2024-05-olas/blob/3ce502ec8b475885b90668e617f3983cea3ae29f/tokenomics/contracts/Dispenser.sol#L393https://github.com/code-423n4/2024-05-olas/blob/3ce502ec8b475885b90668e617f3983cea3ae29f/tokenomics/contracts/Dispenser.sol#L849
If a nominee is removed in the ith epoch then they are eligible to receive staking incentives for the ith epoch if they had enough staking weight. However, due to current implementation the removed nominee would never receive staking incentives for the ith epoch thus causing loss of staking incentives for the nominee. It is evident from the code that it is intended that the nominee is eligible to receive staking incentives for the epoch when it was removed. Plus, I have also asked from the sponsors and they have agreed too that nominee is eligible to receive incentives for that epoch.
Following is calculateStaking incentives function:
From the above for loop it is visible that the staking incentives are calculated until lastClaimedEpoch-1.
Following function is used to check for which epoches is the nominee eligible to receive the staking incentives:
From the following if condition, it is clear that nominee is also eligible to receive staking incentives for the epoch in which it was removed:
As initially for loop ran until lastClaimedEpoch-1, it is evident that removed nominee is eligible for the staking incentives in which it was removed too.
Now lets see what happens when a nominee is removed. Firstly it is removed in VoteWeighting.sol in removeNominee function which is as follows:
Key thing to note is that if a nominee is removed in ith week then its weight/bias in the upcoming weeks is set to zero; i.e., from i+1 weeks it will have no weight.
Also removeNominee in dispensor is also called, as follows:
Key thing to note here is the following condition:
From the above condition, it is clear that it is only allowed to remove a nominee if the time left to epoch end is greater than a week. In simpler terms if the epoch end time is scheduled to be at ith week then the nominee can only be removed in the weeks before the ith week (not including the ith week).
As we have seen from above, if a nominee is removed in ith week then its weight in the weeks starting from the i+1th week will be zero.
Now, when the staking incentives are calculated for the removed nominee for the epoch in which they were removed, it would always return zero as the weight of the nominee will always be zero.
In the current code base as it is intended that the removed nominee is eligible for the epoch in which they were removed and currently they are not receiving it; thus, it is a issue/bug.
The easiest way would be to not allow staking incentives for the epoch in which they were removed or you can do the following:
But in this case, two staking incentives can be lost if the epoch didnt end for few more weeks.
Context
kupermind (Olas) confirmed
0xA5DF (judge) decreased severity to Medium and commented:
Olas mitigated here and here.
Varun_05 (warden) commented:
