Platform: Code4rena
Start Date: 12/08/2022
Pot Size: $50,000 USDC
Total HM: 15
Participants: 120
Period: 5 days
Judge: Justin Goro
Total Solo HM: 6
Id: 153
League: ETH
Rank: 106/120
Findings: 1
Award: $21.17
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xA5DF, 0xDjango, 0xNazgul, 0xSmartContract, 0xackermann, 0xbepresent, 0xc0ffEE, 0xkatana, 2997ms, Amithuddar, Aymen0909, Bnke0x0, Chinmay, Chom, CodingNameKiki, Deivitto, Diraco, Dravee, ElKu, EthLedger, Fitraldys, Funen, IgnacioB, JC, Junnon, Lambda, LeoS, Metatron, MiloTruck, Noah3o6, NoamYakov, PaludoX0, Randyyy, ReyAdmirado, Rohan16, Rolezn, Ruhum, SaharAP, Sm4rty, SooYa, TomJ, Tomio, Waze, Yiko, _Adam, __141345__, a12jmx, ajtra, ak1, asutorufos, ballx, brgltd, c3phas, cRat1st0s, carlitox477, chrisdior4, d3e4, delfin454000, dharma09, djxploit, durianSausage, erictee, fatherOfBlocks, find_a_bug, flyx, francoHacker, gerdusx, gogo, gzeon, hakerbaya, ignacio, jag, kyteg, ladboy233, ltyu, m_Rassska, medikko, mics, mrpathfindr, newfork01, nxrblsrpr, oyc_109, pfapostol, rbserver, reassor, ret2basic, robee, sach1r0, saian, simon135, sryysryy, zeesaw
21.1709 USDC - $21.17
Using a prefix increment (++i) instead of a postfix increment (i++) saves gas for each loop cycle and so can have a big gas impact when the loop executes on a large number of elements.
There are 8 occurrences
FraxlendPair.sol
L289 for (uint256 i = 0; i < _lenders.length; i++) {
L308 for (uint256 i = 0; i < _borrowers.length; i++) {
FraxlendPairDeployer.sol
L127 for (i = 0; i < _lengthOfArray; ) {
L152 for (i = 0; i < _lengthOfArray; ) {
L402 for (uint256 i = 0; i < _lengthOfArray; ) {
FraxlendWhitelist.sol
L51 for (uint256 i = 0; i < _addresses.length; i++) {
L66 for (uint256 i = 0; i < _addresses.length; i++) {
L81 for (uint256 i = 0; i < _addresses.length; i++) {
Use prefix not postfix to increment in a loop
Strings in solidity are handled in 32 byte chunks. A require string longer than 32 bytes uses more gas. Shortening these strings will save gas.
There are 6 occurrences
FraxlendPairDeployer.sol
L253 require(deployedPairsByName[_name] == address(0), "FraxlendPairDeployer: Pair name must be unique");
L365 require(_maxLTV <= GLOBAL_MAX_LTV, "FraxlendPairDeployer: _maxLTV is too large");
L366 require(
LinearInterestRate.sol
L57 require(
L61 require(
L65 require(
Shorten all require strings to less than 32 characters
Solidity does not recognize null as a value, so uint variables are initialized to zero. Setting a uint variable to zero is redundant and can waste gas.
There are 9 occurrences
FraxlendPair.sol
L289 for (uint256 i = 0; i < _lenders.length; i++) {
L308 for (uint256 i = 0; i < _borrowers.length; i++) {
FraxlendPairCore.sol
L265 for (uint256 i = 0; i < _approvedBorrowers.length; ++i) {
L270 for (uint256 i = 0; i < _approvedLenders.length; ++i) {
FraxlendPairDeployer.sol
L402 for (uint256 i = 0; i < _lengthOfArray; ) {
FraxlendWhitelist.sol
L51 for (uint256 i = 0; i < _addresses.length; i++) {
L66 for (uint256 i = 0; i < _addresses.length; i++) {
L81 for (uint256 i = 0; i < _addresses.length; i++) {
LinearInterestRate.sol
L33 uint256 private constant MIN_INT = 0; // 0.00% annual rate
Remove the redundant zero initialization] uint256 amount
Custom errors from Solidity 0.8.4 are cheaper than revert strings (cheaper deployment cost and runtime cost when the revert condition is met)
There are 7 occurrences
FraxlendPairDeployer.sol
L253 require(deployedPairsByName[_name] == address(0), "FraxlendPairDeployer: Pair name must be unique");
L365 require(_maxLTV <= GLOBAL_MAX_LTV, "FraxlendPairDeployer: _maxLTV is too large");
L366 require(
L399 require(msg.sender == CIRCUIT_BREAKER_ADDRESS, "Circuit Breaker only");
LinearInterestRate.sol
L57 require(
L61 require(
L65 require(
Recommended to replace revert strings with custom errors.