Platform: Code4rena
Start Date: 07/07/2022
Pot Size: $75,000 USDC
Total HM: 32
Participants: 141
Period: 7 days
Judge: HardlyDifficult
Total Solo HM: 4
Id: 144
League: ETH
Rank: 65/141
Findings: 2
Award: $103.94
π Selected for report: 0
π Solo Findings: 0
π Selected for report: xiaoming90
Also found by: 0x1f8b, 0x29A, 0x52, 0xA5DF, 0xDjango, 0xNazgul, 0xNineDec, 0xf15ers, 0xsanson, 0xsolstars, 242, 8olidity, Amithuddar, Aymen0909, Bnke0x0, BowTiedWardens, David_, Deivitto, ElKu, Funen, Hawkeye, IllIllI, JC, Kaiziron, Keen_Sheen, Kthere, Kulk0, Kumpa, Lambda, MEP, ReyAdmirado, Rohan16, Ruhum, Sm4rty, TomJ, Tomio, Treasure-Seeker, TrungOre, Tutturu, Viksaa39, Waze, _Adam, __141345__, ak1, apostle0x01, asutorufos, async, ayeslick, aysha, bbrho, benbaessler, berndartmueller, c3phas, cccz, chatch, cloudjunky, codexploder, cryptphi, delfin454000, dipp, durianSausage, dy, exd0tpy, fatherOfBlocks, hake, hansfriese, horsefacts, hubble, joestakey, jonatascm, kebabsec, kenzo, kyteg, mektigboy, neumo, oyc_109, pashov, pedr02b2, peritoflores, rajatbeladiya, rbserver, robee, rokinot, s3cunda, sach1r0, sahar, sashik_eth, scaraven, shenwilly, simon135, sorrynotsorry, sseefried, svskaushik, unforgiven, z3s, zzzitron
66.4718 USDC - $66.47
Events without indexed event parameters make it harder and inefficient for off-chain tools to analyze them.
Indexed parameters (βtopicsβ) are searchable event parameters. They are stored separately from unindexed event parameters in an efficient manner to allow for faster access. This is useful for efficient off-chain-analysis, but it is also more costly gas-wise.
InstallPlugin and UninstallPlugin events do not use indexed parameters.
https://github.com/code-423n4/2022-07-fractional/blob/main/src/interfaces/IVault.sol#L29 https://github.com/code-423n4/2022-07-fractional/blob/main/src/interfaces/IVault.sol#L39
Consider which event parameters could be particularly useful to off-chain tools and should be indexed.
Magic numbers are hardcoded numbers used in the code which are ambiguous to their intended purpose. These should be replaced with constants to make code more readable and maintainable.
uint values in the operation are hardcoded and would be more readable and maintainable if declared as a constant
https://github.com/code-423n4/2022-07-fractional/blob/main/src/modules/Buyout.sol#L209-L211 https://github.com/code-423n4/2022-07-fractional/blob/main/src/modules/Buyout.sol#L86-L87
Replace magic hardcoded numbers with declared constants.
Critical functions do not emit events.
Events should be emitted for critical functions that are access-controlled, setters of protocol parameters or those affecting protocol in significant ways such as transfers, mints or withdrawals:
https://github.com/code-423n4/2022-07-fractional/blob/main/src/modules/Vault.sol#L115-L139
Emit appropriate events with necessary parameters.
Names and descriptions of functions and variables should be distinct and clearly indicate their purpose and effects to improve code readability, development and maintenance. They should also follow best-practices and be consistent when it comes to naming convention.
_controller and controller_variable names are very similar.
https://github.com/code-423n4/2022-07-fractional/blob/main/src/FERC1155.sol#L19 https://github.com/code-423n4/2022-07-fractional/blob/main/src/FERC1155.sol#L38
Use distinct/clear names and descriptions for functions and variables. Consider following best-practices and be consistent when it comes to naming convention to improve the readability, development, maintenance and not create any harmful confusion.
Single-step ownership change in transferOwnership is risky
When privileged roles are being changed, it is recommended to follow a two-step approach:
For e.g., in a single-step change, if the current admin accidentally changes the new admin to a zero-address or an incorrect address (where the private keys are not available), the system is left without an operational admin and will have to be redeployed. transferOwnership implements a single-step ownership change.
https://github.com/code-423n4/2022-07-fractional/blob/main/src/modules/Vault.sol#L93-L97
Single-step ownership change can be overridden to a two-step change.
π Selected for report: joestakey
Also found by: 0x1f8b, 0x29A, 0xA5DF, 0xKitsune, 0xNazgul, 0xNineDec, 0xalpharush, 0xkatana, 0xsanson, 0xsolstars, 8olidity, Avci, Bnke0x0, BowTiedWardens, Chom, Deivitto, ElKu, Fitraldys, Funen, IllIllI, JC, Kaiziron, Lambda, Limbooo, MEP, NoamYakov, PwnedNoMore, RedOneN, ReyAdmirado, Rohan16, Ruhum, Saintcode_, Sm4rty, TomJ, Tomio, TrungOre, Tutturu, Waze, _Adam, __141345__, ajtra, apostle0x01, asutorufos, benbaessler, brgltd, c3phas, codexploder, cryptphi, delfin454000, dharma09, djxploit, durianSausage, fatherOfBlocks, giovannidisiena, gogo, horsefacts, hrishibhat, hyh, ignacio, jocxyen, jonatascm, karanctf, kebabsec, kyteg, m_Rassska, mektigboy, oyc_109, pedr02b2, rbserver, robee, rokinot, sach1r0, sashik_eth, simon135, slywaters
37.4674 USDC - $37.47
Functions should have the strictest visibility possible. Public functions may lead to more gas usage by forcing the copy of their parameters to memory from calldata.
If a function is never called from the contract it should be marked as external. This will save gas.
https://github.com/code-423n4/2022-07-fractional/tree/main/src/utils/SelfPermit.sol#L18-L37 https://github.com/code-423n4/2022-07-fractional/tree/main/src/utils/Metadata.sol#L39-L41 https://github.com/code-423n4/2022-07-fractional/tree/main/src/utils/MerkleBase.sol#L43-L56
Loop indices need not be initialised to 0.
Loop indices are 0 valued by default and there is no need to explicitly initialise them again to 0. This saves gas.
https://github.com/code-423n4/2022-07-fractional/blob/main/src/modules/protoforms/BaseVault.sol#L83 https://github.com/code-423n4/2022-07-fractional/blob/main/src/modules/protoforms/BaseVault.sol#L107 https://github.com/code-423n4/2022-07-fractional/blob/main/src/utils/MerkleBase.sol#L51 https://github.com/code-423n4/2022-07-fractional/blob/main/src/Vault.sol#L78
d. Mitigation: Remove explicit initialization to 0 for loop indices.
The iterator on the for loops can be changed to ++i, this would affect only to gas used as it the last operation in the loop. Also the use of unchecked decreases gas cost
b1) i++ should be change to ++i for gas optimization because it must increment a value and "return" the old value, so it may require holding two numbers in memory. ++i only ever uses one number in memory. b2) following with the code style, change i++ to ++i then put in a unchecked block at the very end of the for loop block, so it doesn't check for the overflow value for an extra gas optimization as in a for loop is not supposed to be able to reach the overflow value.
https://github.com/code-423n4/2022-07-fractional/blob/main/src/Vault.sol#L78 https://github.com/code-423n4/2022-07-fractional/blob/main/src/Vault.sol#L104
Use ++i in for loops in the iteration and unchecked for the overflow ignore