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

Loading State Variables to Memory

Summary

Updating a struct stored in storage efficiently in terms of gas costs involves minimizing unnecessary read and write operations.

Vulnerability Details

In function buyLoan, read the state of storage pools[poolId].interestRate and pools[poolId].poolBalance many times.

Impact

cost more gas.

Tools Used

Recommendations

uint256 interestRate = pools[poolId].interestRate. then use interestRate instead of pools[poolId].interestRate In function buyLoan.
uint256 poolBalance = pools[poolId].poolBalance .then use poolBalance instead of pools[poolId].poolBalance In function buyLoan.

Support

FAQs

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