Fraxlend (Frax Finance) contest - fatherOfBlocks'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: 50/120

Findings: 2

Award: $67.11

🌟 Selected for report: 0

🚀 Solo Findings: 0

FraxlendPairCore

  • L480 - When defining the value of _feesShare, it is divided by (_totalAsset.amount - _feesAmount), but it is not validated that this is != 0, if it were equal to zero, it would revert without knowing the reason why, therefore It should validate before and show the corresponding message.

  • L539 - When defining the value of _exchangeRate, it is divided by oracleNormalization, but it is not validated that this is != 0, if it were equal to zero, it would revert without knowing the reason why, therefore it should be validated before and show the corresponding message.

FraxlendPair

  • L30/31/36/37/38/39 - There are imports like ReentrancyGuard, AggregatorV3Interface, IERC4626, IFraxlendWhitelist, IRateCalculator, ISwapper that are never used in the code.

FraxlendPairConstants

  • L34/35/36/37 - There are multiple constants in storage where most have the same value: LTV_PRECISION, LIQ_PRECISION, UTIL_PREC and FEE_PRECISION. The solution could be to create a single variable called PRECISION.

VaultAccountingLibrary

  • The library is called VaultAccountingLibrary, but the file is called VaultAccounting.sol, this can be confusing, it should be renamed. Also, the name VaultAccountingLibrary is redundant since it is located in the folder: library.

FraxlendPairCore

  • L265/270 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

  • L265/270 - Within a for loop, gas could be saved if instead of consulting the size of the array "array.length" in each iteration, a variable in memory of the length of the array is created.

  • L330/342/351/359 - The modifier can generate much less gas cost if you use private view functions.

  • L477/754/835/1002/1094 - It is less expensive to validate that: "variable != 0" than to validate: "variable > 0".

  • L1089/1090/1175/1176 - Instead of variable - 1 or variable--, much more gas is saved by doing: --variable.

  • L1195/1199 - When a variable is used only once, it is not necessary to create a variable in memory, it can be used directly where it is to be used.

FraxlendPairDeployer

  • L126/127/150/152/402 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

  • L130/158/408 - Instead of variable + 1 or variable ++, much more gas is saved by doing: ++variable.

  • L205/228/253/365/368 - When a message has a size greater than 32 bytes, it generates a higher expense if it has 32 characters or less.

  • L379/380 - It is less expensive to validate that: "variable != 0" than to validate: "variable > 0".

FraxlendPair

  • L289/308 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

  • L289/308 - Instead of variable + 1 or variable ++, much more gas is saved by doing: ++variable.

  • L289/308 - Within a for loop, gas could be saved if instead of consulting the size of the array "array.length" in each iteration, a variable in memory of the length of the array is created.

FraxlendPairConstants

  • L47 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

FraxlendWhitelist

  • L51/66/81 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

  • L51/66/81 - Instead of variable + 1 or variable ++, much more gas is saved by doing: ++variable.

  • L51/66/81 - Within a for loop, gas could be saved if, instead of consulting the size of the array "array.length" in each iteration, a variable in memory of the length of the array is created.

VaultAccountingLibrary

  • L26/43 - Instead of variable + 1 or variable ++, much more gas is saved by doing: ++variable.

LinearInterestRate

  • L33 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

  • L59/63/67 - When a message has a size greater than 32 bytes, it generates a higher expense if it has 32 characters or less.

  • L57/61/65 - The require and the modifier can generate much less gas cost if you use if and custom errors and also private view functions.

  • L66 - It is less expensive to validate that: "variable != 0" than to validate: "variable > 0".

  • L83/84/85/86/87/88/89/90 - The mathematical operations found in these lines have no way of generating overflows or underflows, therefore it could be defined as unchecked.

SafeERC20

  • L22 - It is not necessary to create a variable and set it to its default value, this generates an extra gas expense without providing greater understanding.

  • L24/27 - Instead of variable + 1 or variable ++, much more gas is saved by doing: ++variable.

#0 - gititGoro

2022-10-09T14:29:59Z

Please group by issue type, not file analyzed.

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