Closed sherlock-admin2 closed 5 months ago
1 comment(s) were left on this issue during the judging contest.
0xmystery commented:
valid because lastRewardBlock for each pool should indeed sync with the latest startBlock
This report should be valid as it described scenario 2 of https://github.com/sherlock-audit/2024-05-sophon-judging/issues/108.
araj
medium
Updating
startBlock
inSophonFarming::setStartBlock()
leads to wrong rewardPoints calculationSummary
Updating
startBlock
inSophonFarming::setStartBlock()
leads to wrongrewardPoints
calculation because it doesn't update thepool.lastRewardBlock
Vulnerability Detail
Lets go step by step:-
initialize()
withstartBlock
= block.number + 100(ie in future), which will set thepool.lastRewardBlock
of all pools tostartBlock
ie block.number + 100changed
thestartBlock
to block.number + 50(ie wanted to start early)deposited
100e18 at startBlock(block.number + 50)should
get therewardPoints
for depositing from block.number + 50(startBlock) but will not get until block.number + 100(ie lastRewardBlock) becausereward
is calculated fromlastRewardBlock
&lastRewardBlock
is not updated insetStartBlock
//Here is coded POC
Results:-
Impact
Users will loss on rewardPoints
Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L272C4-L280C6 https://github.com/sherlock-audit/2024-05-sophon/blob/main/farming-contracts/contracts/farm/SophonFarming.sol#L153C5-L187C6
Tool used
Manual Review
Recommendation
Update
lastRewardBlock
of all pools whenstartBlock
is changedDuplicate of #108