You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
accountBalance is calculated using balanceOf function and as we know that reward per token is calculated using totalStaked() value
} else {
uint256 end = Math.min(block.timestamp, $.periodFinish);
if ($.lastUpdateTime < end) {
timeElapsed = end - $.lastUpdateTime;
} else {
timeElapsed =0;
}
}
uint256 rewardIncrease = $.rewardRate * timeElapsed;
&> rewardPerToken = $.rewardPerTokenStored
+ rewardIncrease.mulDiv(1e24, totalStaked(), Math.Rounding.Floor); // 1e6 for precision loss
This calculation is wrong because totalStaked() represents total staked usualS token amount but balanceOf function is also including the unclaimed original allocation.
This situation will cause loss of yield for the last reward claimer due to misaccounting.
Attack Path
Total staked usualS token = 100, we have 5 users and 20 token staked by each of them and 1st user also have unclaimed original allocation which is 20 unit
100 unit of token is added as reward
At the end of the reward period, first 4 user claimed their rewards
1st user is claimed 40 unit of token because his balance is 20 staked + 20 original allocation (unclaimed ) and the others claimed 20 unit of token
5th user cannot claim his rewards because there is no token left, first 4 user claimed all the tokens.
Impact
High - It will cause direct loss of yield which is high severity issue due to wrong calculation yields are directly impacted.
Mitigation
Also add original allocations to denominator while the calculation of reward per token
The text was updated successfully, but these errors were encountered:
sherlock-admin4
changed the title
Old Brunette Puma - Miscalculation of earned token amount may cause loss of funds
TessKimy - Miscalculation of earned token amount may cause loss of funds
Nov 19, 2024
TessKimy
High
Miscalculation of earned token amount may cause loss of funds
Summary
Miscalculation of earned token amount may cause loss of yields
Root Cause
In RewardAccrualBase,
_earned()
function is used for calculation of user's earned rewards. Earned rewards is calculated as follows:accountBalance
is calculated usingbalanceOf
function and as we know that reward per token is calculated usingtotalStaked()
valueThis calculation is wrong because
totalStaked()
represents total stakedusualS
token amount butbalanceOf
function is also including the unclaimed original allocation.This situation will cause loss of yield for the last reward claimer due to misaccounting.
Attack Path
Impact
High - It will cause direct loss of yield which is high severity issue due to wrong calculation yields are directly impacted.
Mitigation
Also add original allocations to denominator while the calculation of reward per token
The text was updated successfully, but these errors were encountered: