20,000 USDC
View results
Submission Details
Severity: gas

## [G-03] Add unchecked {} for subtractions where the operands cannot underflow because of a previous require() or if statement

Summary

[G-03] Add unchecked {} for subtractions where the operands cannot underflow because of a previous require() or if statement

require(a <= b); x = b - a => require(a <= b); unchecked { x = b - a }
if(a <= b); x = b - a => if(a <= b); unchecked { x = b - a }
This will stop the check for overflow and underflow so it will save gas

file: /src/Lender.sol#
201 _updatePoolBalance(poolId, pools[poolId].poolBalance - amount);

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L201

Support

FAQs

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