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

Storage Efficiency and User Experience Considerations in `unstakeAll` Function

Summary

In the `unstakeAll` function, deposit records are only deleted if both the `dr.vestedStaked` and `dr.staked` values are zero. If there are any remaining vested stakes, the function only resets the `dr.staked` value to zero, leaving the deposit record in storage. While this behavior may be intentional to track ongoing vested stakes, it can lead to unnecessary data retention and potential user confusion regarding their remaining stakes.

The `unstakeAll` function allows users to unstake their tokens from all active epochs at once. As it iterates through each of the user's active deposits, the function determines whether to delete the deposit record or merely update it based on the state of the user's stake

Impact

  1. Unnecessary Data Storage: Retaining deposit records when only vested stakes remain could lead to increased storage usage, which may result in higher gas costs over time, especially in contracts with many users or frequent staking activity.

  2. Potential User Confusion: Users might assume that all records are removed once they have unstaked their tokens. However, the presence of partial records could cause misunderstandings about what remains staked, especially if the details of this behavior are not clearly communicated.

Tools Used

Manual Review

Recommendations

  1. Consider Storage Optimization: Evaluate whether it is necessary to retain deposit records when only vested stakes remain. If not, optimizing the storage of these records could improve the contract's efficiency by reducing unnecessary storage costs.

  2. Enhanced Documentation: If the decision to retain partial records is intentional, it is crucial to document this behavior clearly. Users and developers should be informed that records will only be deleted when both `dr.staked` and `dr.vestedStaked` are zero. Clear documentation will help prevent confusion and ensure users understand how their stakes are managed.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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