Platform: Code4rena
Start Date: 11/12/2023
Pot Size: $90,500 USDC
Total HM: 29
Participants: 127
Period: 17 days
Judge: TrungOre
Total Solo HM: 4
Id: 310
League: ETH
Rank: 91/127
Findings: 1
Award: $46.85
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Arz
Also found by: 0xStalin, 0xpiken, AlexCzm, Chinmay, HighDuty, Infect3d, JCN, Neon2835, Tendency, TheSchnilch, almurhasan, asui, c47ch3m4ll, critical-or-high, deliriusz, ether_sky, evmboi32, kaden, klau5, santipu_, sl1, zhaojohnson
46.8502 USDC - $46.85
When users stake on one gauge by credit tokens at the first time, they can claim more rewards that expected.
When user try to stake on gauge A at the first time, GuildToken will try to claim existing rewards at first and then increase user's gauge weight. When we try to claim gauge rewards ,we should update userGaugeProfitIndex[user][gauge] to the latest index. However, when user stake on gauge at the first time, We do not have any weight on this gauge. This function will return 0 directly and not update userGaugeWeight to latest index.
After that, when the user want to claim rewards, the rewards will calculate rewards from 1e18(initial) to latest index. Users can claim more rewards that expected.
function claimGaugeRewards( address user, address gauge ) public returns (uint256 creditEarned) { uint256 _userGaugeWeight = uint256( GuildToken(guild).getUserGaugeWeight(user, gauge) ); if (_userGaugeWeight == 0) { return 0; } uint256 _gaugeProfitIndex = gaugeProfitIndex[gauge]; uint256 _userGaugeProfitIndex = userGaugeProfitIndex[user][gauge]; if (_gaugeProfitIndex == 0) { _gaugeProfitIndex = 1e18; } if (_userGaugeProfitIndex == 0) { _userGaugeProfitIndex = 1e18; } uint256 deltaIndex = _gaugeProfitIndex - _userGaugeProfitIndex; if (deltaIndex != 0) { creditEarned = (_userGaugeWeight * deltaIndex) / 1e18; userGaugeProfitIndex[user][gauge] = _gaugeProfitIndex; } if (creditEarned != 0) { emit ClaimRewards(block.timestamp, user, gauge, creditEarned); CreditToken(credit).transfer(user, creditEarned); } }
Manual
if (_userGaugeWeight == 0) { // we should timely update userGaugeWeight here userGaugeProfitIndex[user][gauge] = _gaugeProfitIndex; return 0; }
Error
#0 - c4-pre-sort
2024-01-05T07:43:30Z
0xSorryNotSorry marked the issue as sufficient quality report
#1 - c4-pre-sort
2024-01-05T07:43:47Z
0xSorryNotSorry marked the issue as duplicate of #1211
#2 - c4-judge
2024-01-29T03:56:29Z
Trumpero marked the issue as satisfactory
#3 - c4-judge
2024-01-31T13:46:19Z
Trumpero changed the severity to 3 (High Risk)