A gas optimization issue has been identified in the way the contract loads the pool data. The function loads the pool into memory and then redundantly accesses the same data from storage, leading to inefficient gas consumption.
The function in question first loads the pool data into memory using the line Pool memory pool = pools[poolId];
. However, later in the function, instead of using the already loaded pool variable from memory, it accesses the pool data again from storage with pools[poolId].poolBalance. This redundant storage access, especially when using the SLOAD
opcode, is considerably more expensive in terms of gas than accessing data from memory using the MLOAD
opcode.
Users interacting with this function will incur higher gas fees than necessary due to the redundant storage access.
Manual Review
Modify the function to utilize the pool variable loaded into memory instead of redundantly accessing the storage.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.