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

Unoptimized Array Initialization in the checkLiquidatableAccounts function

Relevant GitHub Links

https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/branches/LiquidationBranch.sol#L42-L86

Summary

The array initialization in checkLiquidatableAccounts leads to inefficiencies by potentially allocating more memory than necessary.

Vulnerability Details

The array liquidatableAccountsIds is initialized with a size based on the upper and lower bounds of the iteration, which might be larger than the actual number of liquidatable accounts, leading to inefficient memory usage and increased gas costs.

Impact

  • Increased Gas Costs: Unnecessary allocation of memory increases gas consumption.

  • Inefficiency: Potential waste of resources due to oversized array initialization.

Tools Used

Manual

Recommendations

Optimize Array Initialization: Initialize the array to the exact number of liquidatable accounts found.

+ uint256 count = 0;
for (uint256 i = lowerBound; i < upperBound; i++) {
// logic to count liquidatable accounts
}
+ liquidatableAccountsIds = new uint128[](count);
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.