15,000 USDC
View results
Submission Details
Severity: gas
Valid

Gas Optimization

Summary

Gas Optimization

Vulnerability Detail

  1. array length should be cached to save gas in for loop

  2. No need to explicitly initialize variables with default values: uint i = 0; in for loop

  3. ++i costs less gas compared to i++.

  4. add this if (amount != 0) code
    Test: getAccountCollateralValue: this is only [weth, wbtc] if there are more Collaterals it will cost more.
    before: 127827 :: after : 112009

Impact

Code Snippet

Tool used

Manual Review

Recommendation

for loop: cache length.

uint L = s_collateralTokens.length;

for(uint i; i < L; ++i) {}

Support

FAQs

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