Platform: Code4rena
Start Date: 05/04/2022
Pot Size: $30,000 USDC
Total HM: 10
Participants: 47
Period: 3 days
Judge: gzeon
Total Solo HM: 4
Id: 106
League: ETH
Rank: 25/47
Findings: 1
Award: $127.38
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0v3rf10w, 0x1f8b, 0xkatana, CertoraInc, FSchmoede, Funen, IllIllI, Kenshin, Meta0xNull, TerrierLover, Tomio, csanuragjain, joshie, obront, rayn, rfa, robee, saian, securerodd, sorrynotsorry, t11s, z3s
127.3764 USDC - $127.38
expressions assigned to constant variables are replaced where its used and executed when referenced, the variable can be changed to immutable so that it is executed once
/// See {INFTLoanFacilitator-SCALAR}. uint256 public immutable override SCALAR = 10 ** INTEREST_RATE_DECIMALS;
the constant variable can be changed to immutable
Revert string takes a minimum of 32 bytes, increasing the string size increases gas during deployment and when the revert condition is met
Some examples in code
Reduce the size of the strings or use custom errors
Variables that are read multiple times in a code block can be cached and re-used instead of reading from storage to save gas
requiredImprovementRate
in
lendTicketContract
in
storage value can be stored in a temporary variable and re-used
In updateOriginationFeeRate
expression with integer constants and constant variable can be replaced by the result to save gas, and the expression can be added to the comments
// require(_originationFeeRate <= 5 * (10 ** (INTEREST_RATE_DECIMALS - 2)), "NFTLoanFacilitator: max fee 5%");
the expression can be replaced by the final value
>
can be replaced by !=
to save gas!=
save gas compared to >
with uint in require statements, uint can be less than zero >
can be replaced with !=
require(_improvementRate != 0, 'NFTLoanFacilitator: 0 improvement rate');
>
can be replaced by !=
in the require statement