Frax Ether Liquid Staking contest - emrekocak's results

A liquid ETH staking derivative designed to uniquely leverage the Frax Finance ecosystem.

General Information

Platform: Code4rena

Start Date: 22/09/2022

Pot Size: $30,000 USDC

Total HM: 12

Participants: 133

Period: 3 days

Judge: 0xean

Total Solo HM: 2

Id: 165

League: ETH

Frax Finance

Findings Distribution

Researcher Performance

Rank: 120/133

Findings: 1

Award: $12.81

🌟 Selected for report: 0

🚀 Solo Findings: 0

++i COSTS LESS GAS COMPARED TO i++ OR i += 1

++i costs less gas compared to i++ or i += 1 for unsigned integer, as pre-increment is cheaper (about 5 gas per iteration). This statement is true even with the optimizer enabled.

i++ increments i and returns the initial value of i. Which means:

uint i = 1; i++; // == 1 but i == 2 But ++i returns the actual incremented value:

uint i = 1; ++i; // == 2 and i == 2 too, so no need for a temporary variable In the first case, the compiler has to create a temporary variable (when used) for returning 1 instead of 2

Instance include:

src/ERC20/ERC20PermitPermissionedMint.sol:84: I suggest using ++i instead of i++ to increment the value of a uint variable.


Cache array length in for loops can save gas

Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack. Caching the array length in the stack saves around 3 gas per iteration.

Instances include:

src/ERC20/ERC20PermitPermissionedMint.sol:84: src/OperatorRegistry.sol:114:


In require(), Use != 0 Instead of > 0 With Uint Values

In a require, when checking a uint, using != 0 instead of > 0 saves 6 gas. This will jump over or avoid an extra ISZERO opcode.

Instances include: src/frxETHMinter.sol:79 src/frxETHMinter.sol:126


Not initializing unit variable to default value of zero

Instances include: src/ERC20/ERC20PermitPermissionedMint.sol:84 src/frxETHMinter.sol:129 src/OperatorRegistry.sol:63 src/OperatorRegistry.sol:84 src/OperatorRegistry.sol:114

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