Initial rewards may be lost when the total staked UNI tokens is zero. #148
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-369
🤖_06_group
AI based duplicate group recommendation
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-02-uniswap-foundation/blob/5a2761c8277541a24bc551fbd624413b384bea94/src/UniStaker.sol#L570-L599
Vulnerability details
Once the protocol fees for a pool have been purchased, the amount is sent to the
unistaker.sol
, and thennotifyRewardAmount()
is called. This function calculates the reward rate per second and also records the start of the reward period. The issue here will occur at the beginning stages of the protocol if no UNI holder has staked their token yet but an auction has already been done to buy a pool's fees.This function determines the number of tokens to be given as a reward per unit of time (in seconds) and records the duration of the reward cycle. However, there is a unique situation where rewards are not tallied during the initial time span until there is at least one participant (a UNI holder). In this initial period, the reward rate remains applicable, but since there are no participants, no one can claim these rewards, resulting in the loss of these rewards within the system.
This issue has been discovered before, here is a reference for a better understanding
0xMacro Blog-Synthetix
Impact
Rewards allocated for distribution to stakers will be lost in the system.
Tools Used
Manual Review
Recommended Mitigation Steps
UniStaker.sol
should account for whentotalStaked == 0
and should only begin rewards distribution after the first UNI holder has stakedAssessed type
Math
The text was updated successfully, but these errors were encountered: