Rewards in the UniStaker.sol
contract for the initial period can be lost
#224
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-369
edited-by-warden
🤖_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/main/src/UniStaker.sol#L570-L599
Vulnerability details
Impact
The
UniStaker.sol
contract within theUniStaker Infrastructure Protocol
is designed to manage the staking of UNI tokens and the distribution of rewards generated from protocol fees onUniswap V3
. This contract allows UNI holders to stake their tokens, delegate their governance voting rights, and earn rewards based on the fees collected from Uniswap V3 pools. The rewards are distributed in a designated token, which is determined at the deployment of the contracts.The staking mechanism is inspired by the Synthetix
StakingRewards.sol
implementation, which distributes rewards over a fixed period. This period restarts whenever new rewards are added to the system. Stakers can deposit their UNI tokens into the contract, delegate their voting rights, and specify a beneficiary for their rewards. The contract tracks each staker's deposit on a per-position basis, allowing for independent management of each staking position.Rewards management and distribution are handled through a system where the accrued fees from Uniswap V3 pools are auctioned for the designated reward token. The
UniStaker.sol
contract collects these tokens and distributes them to stakers based on their share of the total staked UNI. The distribution rate is determined by the amount of reward tokens available and the duration over which they are to be distributed.The reward calculation and distribution mechanism is designed to ensure fair and proportional allocation of rewards to all stakers based on their contribution to the pool. However, this system relies on the accurate tracking of staking durations and the timely update of reward rates.
The primary impact of the bug in the
UniStaker.sol
contract is the potential loss of rewards for the initial period of staking. This can occur when the reward distribution mechanism does not account for the time elapsed between the initiation of the reward period and the participation of the first staker.The vulnerability in the
UniStaker.sol
contract mirrors the issue found in Synthetix's staking rewards mechanism, where rewards for the initial period can be lost if there are no participants to claim them. In the context of the UniStaker Infrastructure Protocol, this means that rewards generated from protocol fees could go unclaimed during periods of low or no participation in staking. This not only leads to inefficiencies in reward distribution but also disincentivizes early participation in the staking process.Proof of Concept
UniStaker.sol#notifyRewardAmount()
functionIn essence, the issue arises when the contract begins to accrue rewards from the start of a reward period, regardless of whether there are stakers present to claim these rewards. If the reward period starts and continues without any stakers, the accrued rewards during this time are effectively lost from the perspective of potential participants.
This is a known vulnerability that have been covered before, The following reports can be used as a reference for the described issue:
Tools Used
Manual Review
Recommended Mitigation Steps
A possible solution to the issue would be to set the start and end time for the current reward cycle when the first participant joins the reward program, i.e. when the total supply is greater than zero, instead of starting the process in the
UniStaker.sol#notifyRewardAmount()
function.Assessed type
Context
The text was updated successfully, but these errors were encountered: