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

Findings: 2

Award: $85.69

🌟 Selected for report: 0

🚀 Solo Findings: 0

Table Of Content

QA REPORT

Different solidity versions are in use

The project is compiled with different versions of solidity, which is not recommended because it can lead to undefined behaviors.

Missing 0 address check at transfer

Some contracts does not support 0 transfer, then the transaction will revert with no explanation. We recommend to add a require statement that the amount is not 0.

Code Instances:

Loss of precision: multiplications should be before divisions

Consider changing the order of the following instances math operators such that multiplications comes before divisions to improve calculation precision with no cost.

Code Instances:

SPDX license not provided in source file

Before publishing, consider adding a comment containing 'SPDX-License-Identifier: MIT' at the beginning of each source file.

Code Instances:

validate fee parameter

The fee parameter should be validated to be strictly greater than 0 and less than 100%. In the following lines at least one of those checks is missing.

Code Instances:

Should approve(0) first

Some tokens (like USDT L199) do not work when changing the allowance from an existing non-zero allowance value. They must first be approved by zero and then the actual allowance must be approved.

Code Instances:

Loss of precision by using division over possible multiplication

In cases of computing a / b < c you could improve precision by doing instead a < c * b.

Code Instances:

Array access is out of bounds

There is no check for the access to be in the array bounds.

Code Instances:

Avoid floating pragma

Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively. (SWC-103)

Code Instances:

Events not emitted for important state changes

When changing state variables events are not emitted. Emitting events allows monitoring activities with off-chain monitoring tools.

Code Instances:

Add event to the following functions

Code Instances:

Consider removing the unused parameters names in the following functions

Code Instances:

Not indexed events

The emitted event is not indexed, making off-chain scripts such as front-ends of dApps difficult to filter the events efficiently.

Code Instances:

Several functions are declaring named returns but then are using return statements. I suggest choosing only one for readability reasons.

Using both named returns and a return statement isn't necessary. Removing one of those can improve code clarity.

Code Instances:

Some of the following function specification is missing

Code Instances:

Table Of Content

GAS REPORT

Using abiEncodePacked() is more efficient that abiEncode()

Code Instances:

Don't cache msg.sender

reading msg.sender is 2 gas units which is less than a read of a local var + the unnecessary store operation.

Code Instances:

Use bytes32 instead string whenever possible

For instance, FraxlendPairDeployer.sol#L314

Use assembly opcodes iszero instead of solidity equation to save gas

Code Instances:

If the function is onlyOwner you may make it payable to reduce gas usage.

Code Instances:

Use custom errors

In the following require statements you can use custom errors to save gas and improve code quality.

Code Instances:

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