Fraxlend (Frax Finance) contest - a12jmx's results

Fraxlend: A permissionless lending platform and the final piece of the Frax Finance Defi Trinity.

General Information

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

Frax Finance

Findings Distribution

Researcher Performance

Rank: 74/120

Findings: 2

Award: $67.00

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA


Contract: SafeERC20.sol

Initializing the uint8 in line 22 is unnecessary as they get set to 0 by default

Recommendation:

uint8 i;

2.

Initializing the variable in the following for loops is unnecessary as they get set to 0 by default

Contract: FraxlendWhitelist.sol

line 51 line 66 line 81

Contract: FraxlendPairCore.sol

line 265 line 270

Contract: FraxlendPair.sol

line 289 line 308

Contract: FraxlendPairDeployer.sol

line 402

Recommendations:

for (uint256 i; i < _addresses.length; i++) for (uint256 i; i < _approvedBorrowers.length; ++i) for (uint256 i; i < _approvedLenders.length; ++i) for (uint256 i; i < _lenders.length; i++) for (uint256 i; i < _borrowers.length; i++) for (uint256 i; i < _lengthOfArray; )

3.

Contract: FraxlendPairDeployer.sol

Not initializing uint256 i in line 126 and line 150 is excellent, but there is no need for this, and the for var to then get set to i = 0 in line 127 and line 152 as they get set to 0 by default. Both uint256 do not get used outside of the for loops throughout the rest of either function so this might as well be added inside the for loops.

Recommendation:

for (uint256 i; i < _lengthOfArray; )

#0 - gititGoro

2022-10-06T00:47:04Z

Point 3 was a little unclear.

Contract: SafeERC20.sol

When dealing with function arguments such as in line 22, there is no inherent benefit to set to uint8 because the compiler does not pack these values. Using smaller-size uints such as uint8 is only more efficient when you can pack variables into the same storage slot, such as in structs. In this case, a function and in a loop, uint256 is more gas efficient than uint8. It brings a difference of about 1500 gas per contract deployment.

Recommendation:

uint256;

2.

Switching the i++ to ++i in for loops will save about 5 gas per iteration

Contract: SafeERC20.sol

line 27

Contract: FraxlendWhitelist.sol

line 51 line 66 line 81

Contract: FraxlendPair.sol

line 289 line 308

Recommendations:

for (i = 0; i < 32 && data[i] != 0; ++i) for (uint256 i = 0; i < _addresses.length; ++i) for (uint256 i = 0; i < _lenders.length; ++i) for (uint256 i = 0; i < _borrowers.length; ++i)
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter