Staking.sol
Description: The current implementation of staking logic allows users to claim more tokens than they should be entitled to. Additionally, if rewards are claimed before the completion of the last week, users lose the rewards for that week.
Impact: The issues with the staking logic lead to the following consequences:
The claimRewards()
function assigns the wrong timestamp to users claiming rewards for the first time, resulting in incorrect reward calculations.
For these users, the timestamp when the soulmate token was minted is assigned as the last claim. Since the rewards for each user are calculated as:
This implies that users don't need to deposit tokens in the contract to accrue love tokens, it will be enough depositing them the same day they want to claim the rewards (they have to at least wait for a week). This is in line with the next issue.
After the initial claim, the user's lastClaim
timestamp is updated. Subsequently, as the reward is solely updated upon calling Staking.sol::claimRewards()
, users can strategically deposit tokens on the same day they intend to claim rewards. This behavior implies that users don't necessarily need to maintain token deposits for longer than a week if they choose not to. This compounds with the issue highlighted earlier, exacerbating the potential for users to exploit the system by minimizing their token deposits to optimize reward accumulation.
In the same function Staking.sol::claimRewards()
, users lose the tokens claimed after the completion of the last week, if they don't want to loose any of their rewards they have to claim them at exactly the end of the week:
The amount lost is equal to (block.timestamp-lastClaim[msg.sender])%1 weeks*userStakes[msg.sender]/ 1 weeks
.
Proof of Concept: Place the following in StakingTest.t.sol
:
Recommended Mitigation: Keep track of users' rewards in different points in time by implementing a modifier updateReward()
and a function earned()
as shown in the example below:
High severity, this allows users to claim additional rewards without committing to intended weekly staking period via multi-deposit/deposit right before claiming rewards.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.