This repository has been archived by the owner on Nov 24, 2024. It is now read-only.
ZdravkoHr. - SophonFarming.updatePool
doesn't check if the farming has started
#40
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Medium
A valid Medium severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
ZdravkoHr.
medium
SophonFarming.updatePool
doesn't check if the farming has startedSummary
The contract should start accumulating rewards after the current
block.number
passes thestartBlock
. However, the function that accrues rewards does not check this.Vulnerability Detail
In the initialize function the
startBlock
is set and the predifined pools are added.When adding the pool, the
lastRewardBlock
is set to the bigger value of the numbers of the current block and thestartBlock
.Then, in updatePool() it's checked that we are past the
lastRewardBlock
. This is a sufficient check to ensure rewards are not distributed before the initialstartBlock
.However, the owner should be able to update the
startBlock
by calling setStartBlock()When the owner updates the value of the startBlock, the pools'
lastRewardTime
will not be synced. SinceupdatePool
checks onlylastRewardTime
and not thestartBlock
, reward distribution will start earlier than expected.Impact
Reward distribution starts earlier. It's like
setStartBlock
was never called.Code Snippet
https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L163-L164
https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L413C1-L415C10
https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L272-L280
Tool used
Manual Review
Recommendation
Check the
startBlock
as wellDuplicate of #108
The text was updated successfully, but these errors were encountered: