DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: low
Invalid

Inconsistency in Unstaking Behavior for Current Epoch in `FjordStaking::unstakeAll` Function

Summary

The `FjordStaking::unstakeAll` function does not allow users to unstake tokens from the current epoch (when `dr.epoch == currentEpoch`), unlike the regular `FjordStaking::unstake` function, which does support this. This inconsistency could lead to confusion and prevent users from fully unstaking their tokens in a single transaction.

Specifically, the `unstakeAll` function includes a condition that skips over any deposits from the current epoch, thus preventing users from unstaking these tokens in one transaction

Vulnerability Details

  • In the `FjordStaking::unstakeAll` function, the logic only allows unstaking from epochs that are older than the current epoch (`currentEpoch - epoch > lockCycle`). This means that users who have deposited tokens in the current epoch are unable to unstake all their tokens including the one deposited in that epoch in a single transaction. using `unstakeAll`.

  • The regular `FjordStaking::unstake` function, on the other hand, includes a condition that allows immediate unstaking if `dr.epoch == currentEpoch`, providing more flexibility for users.

  • In the natspec of our `unstake` function we wrote `// _epoch is same as current epoch then user can unstake immediately` . So by system, a user is suppose to Unstake tokens that were staked in the current epoch.

Impact

  1. This discrepancy in behavior could confuse users, as they might expect to be able to unstake from the current epoch using `FjordStaking::unstakeAll`, just as they can with `FjordStaking::unstake`

  2. Users who have staked tokens in the current epoch may find themselves unable to fully unstake their holdings in a single transaction using `unstakeAll`, potentially leading to frustration or misuse of the staking platform.

Tools Used

Manual Review

Recommendations

Consider modifying the `FjordStaking::unstakeAll` function to include logic that allows for unstaking from the current epoch when `dr.epoch == currentEpoch`. This change would make the behavior consistent with the regular `FjordStaking::unstake` function and provide a more intuitive user experience.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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