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

The epoch field can be removed from the FjordStaking::DepositReceipt struct to optimize gas usage.

Summary

The uint16 epoch field can be removed from the FjordStaking::DepositReceipt struct to optimize gas usage.

Vulnerability Details

The FjordStaking::DepositReceipt struct is only used within the FjordStaking::deposits mapping, which already tracks the epoch. Therefore, including the epoch in DepositReceipt is redundant. The only use of epoch is in the conditional check if (dr.epoch == 0) to determine if a user has staked before, which can be replaced by if (dr.staked == 0).

Impact

Removing the epoch field from DepositReceipt reduces gas consumption in frequently used functions like FjordStaking::stake and FjordStaking::unstake.

Tools Used

Manual code review

Recommendations

Redefine the DepositReceipt struct as follows:

struct DepositReceipt {
uint256 staked;
uint256 vestedStaked;
}

Replace all instances of dr.epoch == 0 with dr.staked == 0.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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