Platform: Code4rena
Start Date: 24/03/2023
Pot Size: $49,200 USDC
Total HM: 20
Participants: 246
Period: 6 days
Judge: Picodes
Total Solo HM: 1
Id: 226
League: ETH
Rank: 87/246
Findings: 2
Award: $52.85
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: brgltd
Also found by: 0x3b, 0xAgro, 0xGusMcCrae, 0xNorman, 0xRajkumar, 0xSmartContract, 0xTraub, 0xWagmi, 0xWaitress, 0xffchain, 0xhacksmithh, 0xkazim, 0xnev, 3dgeville, ArbitraryExecution, Aymen0909, BRONZEDISC, Bason, Bloqarl, BlueAlder, Brenzee, CodeFoxInc, CodingNameKiki, Cryptor, DadeKuma, DevABDee, Diana, Dug, Englave, Gde, Haipls, HollaDieWaldfee, Ignite, Infect3d, Jerry0x, Josiah, Kaysoft, Koko1912, KrisApostolov, Lavishq, LeoGold, Madalad, PNS, Rappie, RaymondFam, RedTiger, Rickard, Rolezn, Sathish9098, SunSec, T1MOH, UdarTeam, Udsen, Viktor_Cortess, Wander, adriro, ak1, alejandrocovrr, alexzoid, arialblack14, ayden, bin2chen, brevis, btk, c3phas, carlitox477, catellatech, ch0bu, chaduke, ck, climber2002, codeslide, descharre, dingo2077, ernestognw, fatherOfBlocks, favelanky, georgits, helios, hl_, inmarelibero, juancito, ks__xxxxx, lopotras, lukris02, m_Rassska, mahdirostami, maxper, nadin, navinavu, nemveer, p_crypt0, peanuts, pipoca, pixpi, qpzm, rbserver, reassor, roelio, rotcivegaf, scokaf, siddhpurakaran, slvDev, smaul, tnevler, tsvetanovv, turvy_fuzz, vagrant, wen, yac, zzzitron
42.0604 USDC - $42.06
SafEth.sol
L4/5/6/7/8 - Imports are made that are never used, therefore they generate an extra cost of gas and also generate less comprehensibility of the code since they fill the contract with unused code.
L73/74/75/92/93/94 - Loss of precision due to rounding - Add scalars so roundings are negligible. Case: (derivatives[i].ethPerDerivative(derivatives[i].balance()) * derivatives[i].balance()) / 10 ** 18;
L202 - The function setMaxSlippage() is responsible for defining the slippage of a derivative, but it would seem correct to add a require to the first line that checks that the _derivativeIndex is <= the derivativeCount. Because otherwise the slippage of an uncreated derivative would be setting, which later when it is created, would already have a slippege, this can cause confusion, therefore it is best to validate it and reverse it if this happens.
L170/171/172/173/190/191/192/193 - This code is repeated in two functions, therefore it would be easier to create a private function and have both use it. uint256 localTotalWeight = 0; for (uint256 i = 0; i < derivativeCount; i++) localTotalWeight += weights[i]; totalWeight = localTotalWeight;
L165/182 - There is a mechanism to add derivatives, but there is no specific mechanism to remove a derivative, the most similar thing is to use adjustWeight() and set the weight to 0, but this mechanism does not alter the derivativeCount, therefore, It would be advisable to be able to have one of these mechanisms since derivatives are not necessarily forever.
contracts/SafEth/derivatives/Reth.sol
L5 - Imports are made that are never used, therefore they generate an extra cost of gas and also generate less comprehensibility of the code since they fill the contract with unused code.
L7/8/9/10 - Multiple interfaces are imported that are not defined with the same standard as the others. Some interfaces are named as INAME and others as NAMEInterface. This should be modified and have the same standard among all.
L33 - Missing initializer modifier on constructor OpenZeppelin recommends that the initializer modifier be applied to constructors in order to avoid potential griefs, social engineering, or exploits. Ensure that the modifier is applied to the implementation contract. If the default constructor is currently being used, it should be changed to be an explicit one with the modifier applied.
L58/59 - Missing event and or timelock for critical parameter change Events help non-contract tools to track changes, and events prevent users from being surprised by changes.
L58/66/107/108/156/179/221/244 - Function ordering does not follow the Solidity style guide According to the Solidity style guide, functions should be laid out in the following order :constructor(), receive(), fallback(), external, public, internal, private, but the cases below do not follow this pattern.
L173/174/215 - Loss of precision due to rounding - Add scalars so roundings are negligible. Example Case: ((((rethPerEth * msg.value) / 10 ** 18) * ((10 ** 18 - maxSlippage))) / 10 ** 18);
L50/221 - The functions name() and balance() are found as public, but they are not used throughout the contract, the correct thing would be for them to be external.
contracts/SafEth/derivatives/SfrxEth.sol
L27 - Missing initializer modifier on constructor OpenZeppelin recommends that the initializer modifier be applied to constructors in order to avoid potential griefs, social engineering, or exploits. Ensure that the modifier is applied to the implementation contract. If the default constructor is currently being used, it should be changed to be an explicit one with the modifier applied.
L51 - Missing event and or timelock for critical parameter change Events help non-contract tools to track changes, and events prevent users from being surprised by changes.
L51/60/94/122/126 - Function ordering does not follow the Solidity style guide According to the Solidity style guide, functions should be laid out in the following order :constructor(), receive(), fallback(), external, public, internal, private, but the cases below do not follow this pattern.
L44/122 - The functions name() and balance() are found as public, but they are not used throughout the contract, the correct thing would be for them to be external.
contracts/SafEth/derivatives/WstEth.sol
L24 - Missing initializer modifier on constructor OpenZeppelin recommends that the initializer modifier be applied to constructors in order to avoid potential griefs, social engineering, or exploits. Ensure that the modifier is applied to the implementation contract. If the default constructor is currently being used, it should be changed to be an explicit one with the modifier applied.
L48 - Missing event and or timelock for critical parameter change Events help non-contract tools to track changes, and events prevent users from being surprised by changes.
L48/56/73/86/93/97 - Function ordering does not follow the Solidity style guide According to the Solidity style guide, functions should be laid out in the following order :constructor(), receive(), fallback(), external, public, internal, private, but the cases below do not follow this pattern.
L41/86/93 - The functions name(), ethPerDerivative() and balance() are found as public, but they are not used throughout the contract, the correct thing would be for them to be external.
#0 - c4-sponsor
2023-04-10T20:03:29Z
elmutt marked the issue as sponsor confirmed
#1 - c4-judge
2023-04-24T18:43:24Z
Picodes marked the issue as grade-a
🌟 Selected for report: Rolezn
Also found by: 0x3b, 0xGordita, 0xSmartContract, 0xhacksmithh, 0xnev, 0xpanicError, 4lulz, Angry_Mustache_Man, ArbitraryExecution, Aymen0909, Bason, BlueAlder, EvanW, Franfran, HHK, Haipls, IgorZuk, JCN, KrisApostolov, Madalad, MiksuJak, MiniGlome, RaymondFam, ReyAdmirado, Rickard, Sathish9098, Udsen, adriro, alexzoid, anodaram, arialblack14, c3phas, carlitox477, ch0bu, chaduke, codeslide, d3e4, dicethedev, ernestognw, fatherOfBlocks, georgits, hunter_w3b, inmarelibero, lukris02, mahdirostami, maxper, pavankv, pixpi, rotcivegaf, smaul, tank, tnevler, wen, yac
10.7864 USDC - $10.79
SafEth.sol
L75/80/81/94/98 - The number 10 ** 18 is used multiple times, it would be advisable to create a variable in memory with this value so as not to perform the same operation multiple times.
L88/91/144/145/149/152 - A variable is created but it is only used once, therefore it does not make much sense to create a variable, generating more gas costs.
contracts/SafEth/derivatives/Reth.sol
L201 - The operation rethBalance2 - rethBalance1 is performed and in L200 it is validated that rethBalance2 > rethBalance1, therefore the subtraction can be performed unchecked and less gas expense would be generated.
L201/202 - A variable is created but it is only used once, therefore it does not make much sense to create a variable, generating more gas costs.
contracts/SafEth/derivatives/SfrxEth.sol
contracts/SafEth/derivatives/WstEth.sol
L79/80 - A variable is created but it is only used once, therefore it does not make much sense to create a variable, generating more gas costs.
L60 - The 10 ** 18 operation is used multiple times, a variable could be created directly in memory and avoid doing the operation twice.
#0 - c4-sponsor
2023-04-10T20:08:20Z
elmutt marked the issue as sponsor confirmed
#1 - c4-judge
2023-04-23T19:12:55Z
Picodes marked the issue as grade-c
#2 - c4-judge
2023-04-23T19:13:22Z
Picodes marked the issue as grade-b