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

caching variable of struct in one slot

Summary

store more than one variable in one storage slot save gas

Vulnerability Details

in struct Pool there are 3 variable can be packed into one storage slot .
// uint96 maxLoanRatio has a max value of 118 so uint96 is more efficient
// uint80 auctionLength has a max value of 3 days and this storage space can store 3
16 years
// uint80 interest rate has a max value of 1000*100

Impact

gas saving
Each slot saved can avoid an extra Gas (20000 gas) for the first setting of the struct
store the variable in one storage slot is more gas efficient .

Tools Used

manual review

Recommendations

using
// uint64 maxLoanRatio
// uint24 auctionLength
// uint24 interest rate
instead of
// uint256 maxLoanRatio
// uint256 auctionLength
// uint256 interest rate

Support

FAQs

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