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

Gas Optimization

Summary

Vulnerability Details

  1. use getPoolId poolId oldPoolId to be sure in case you change something in getPoolId function it will apply the change in the whole contract.
    example:

    bytes32 poolId = keccak256(abi.encode(loan.lender, loan.loanToken, loan.collateralToken));

    to

    bytes32 poolId = getPoolId(loan.lender, loan.loanToken, loan.collateralToken);

  2. cache the length i.e: uint256 l = loandIds.length
    example: for(uint i; i < loandIds.length; ++i) => uint l = loandIds.length; for(uint i; i < l; ++i)

  3. If a variable is not set, it has the default value 0. it is anti-pattern and wastes gas.
    example: for(uint i=0; i < l, i++) => for(uint i; i < l; ++i)

  4. using ++i costs less gas then i++, about 5 gas per iteration.

Impact

Tools Used

Recommendations

Support

FAQs

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