Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Valid

If user stakes again, he will lose all of his rewards

Summary

Currently in VaultRouterBranch users can stake their shares to receive rewards in terms of WETH. If user has some of his shares staked and he decide to stake some more, but there is a reward accumulated, he will lose the reward if he stakes again, before claiming the reward.

Vulnerability Details

Let's have the following scenario:

  1. User A has 100 shares and he decides to stake 50 shares.

  2. After some period, some rewards are accumulated and the user is eligible to claim it.

  3. But he decides to stake the other 50, which will lead in situation where accumulateActor will update the state of the actor and accumulated rewards will be lost.

  4. User will be not able to claim the rewards for the first 50 tokens, which he staked.

The problem lies that the accumulateActor function will call underlying this function:

function _updateLastValuePerShare(
Data storage self,
Actor storage actor,
UD60x18 newActorShares
)
private
returns (SD59x18 valueChange)
{
valueChange = _getActorValueChange(self, actor);
actor.lastValuePerShare = newActorShares.eq(UD60x18_ZERO) ? int256(0) : self.valuePerShare;
}

The function will set lastValuePerShare to the current one and the user will be not able to claim anymore valueChange.

Impact

User will be not able to claim their rewards and this will lead to lost of reward.

Tools Used

Manual review

Recommendations

Consider implementing similar mechanism to the one in unstake:

UD60x18 amountToClaimX18 = vault.wethRewardDistribution.getActorValueChange(actorId).intoUD60x18();
// reverts if the claimable amount is NOT 0
if (!amountToClaimX18.isZero()) revert Errors.UserHasPendingRewards(actorId, amountToClaimX18.intoUint256());
Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Inside VaultRouterBranch if you stake wait some time then stake again makes you lose the rewards.

Appeal created

hard1k Auditor
8 months ago
inallhonesty Lead Judge
8 months ago
inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Inside VaultRouterBranch if you stake wait some time then stake again makes you lose the rewards.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.