Mimo August 2022 contest - 0xSmartContract's results

Bridging the chasm between the DeFi world and the world of regulated financial institutions.

General Information

Platform: Code4rena

Start Date: 02/08/2022

Pot Size: $50,000 USDC

Total HM: 12

Participants: 69

Period: 5 days

Judge: gzeon

Total Solo HM: 5

Id: 150

League: ETH

Mimo DeFi

Findings Distribution

Researcher Performance

Rank: 64/69

Findings: 1

Award: $40.74

🌟 Selected for report: 0

🚀 Solo Findings: 0

For Gas Optimizations, the details in this link have been taken into account and excluded.

#non-gas-optimized-syntax

1-Setting The Constructor To Payable

Context:

MIMOVaultActions.sol#L28-L39 MIMOSwap.sol#L26-L32 MIMORebalance.sol#L25-L35 MIMOLeverage.sol#L25-L35 MIMOFlashloan.sol#L21-L26 MIMOEmptyVault.sol#L25-L34

Description: You can cut out 10 opcodes in the creation-time EVM bytecode if you declare a constructor payable. Making the constructor payable eliminates the need for an initial check of msg.value == 0 and saves 21💰 gas on deployment with no security risks.

Proof of Concept: https://forum.openzeppelin.com/t/a-collection-of-gas-optimisation-tricks/19966/5?u=pcaversaccio

Recommendation: Set the constructor to payable.This is a new approach in Solidity

2 – There is no need to assign default values to variables

Context:

MIMOProxy.sol#L132

Description: When a variable is declared solidity assigns the default value. In case the contract assigns the value again, it costs extra gas.

Example: uint x = 0 costs more gas than uint x without having any different functionality.

Recommendation: uint x = 0 costs more gas than uint x without having any different functionality.

3 – Function Ordering via Method ID

Context: All Contracts

Description: Contracts most called functions could simply save gas by function ordering via Method ID. Calling a function at runtime will be cheaper if the function is positioned earlier in the order (has a relatively lower Method ID) because 22💰 gas are added to the cost of a function for every position that came before it. The caller can save on gas if you prioritize most called functions.

Recommendation: Find a lower method ID name for the most called functions for example Call() vs. Call1() is cheaper by 22 gas.

Proof of Consept:

Details

4 – Use double require instead of using if &&

Context:

MIMOProxyRegistry.sol#L49

Description:

Using double require instead of operator && can save more gas When having a require statement with 2 or more expressions needed, place the expression that cost less gas first. So, in require statements with && or || operators, place the cheapest expression first for execution, so that the second and most expensive expression can (sometimes) be bypassed.

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