Platform: Code4rena
Start Date: 14/07/2022
Pot Size: $25,000 USDC
Total HM: 2
Participants: 63
Period: 3 days
Judge: PierrickGT
Total Solo HM: 1
Id: 147
League: ETH
Rank: 27/63
Findings: 2
Award: $56.11
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: hickuphh3
Also found by: 0x29A, 0x52, 0xNazgul, Chom, Deivitto, ElKu, Funen, IllIllI, Meera, ReyAdmirado, SooYa, TomJ, Trumpero, Waze, __141345__, ak1, asutorufos, c3phas, cRat1st0s, csanuragjain, delfin454000, exd0tpy, fatherOfBlocks, hake, hansfriese, horsefacts, hyh, karanctf, kenzo, kyteg, ladboy233, pashov, peritoflores, rajatbeladiya, rbserver, reassor, rokinot, simon135, wastewa
39.1982 USDC - $39.20
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.
AuctioneerRewardSet event do not use indexed parameters.
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L57
Consider which event parameters could be particularly useful to off-chain tools and should be indexed.
Y - event is missing indexed fields L57
The return values of functions need to be checked for the appropriate values/conditions to determine error conditions appropriately.
baseJoin.join(msg.sender, baseIn.u128()); ignores returns value, also no event emited to know if the assets had been moved
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L329
Consider checking return values of the functions to detect error codes/conditions and verify expected values. Also the use of events in the movement of assets is something to consider.
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.
The following values are hardcoded and would be more readable and maintainable, as a future developer that inherit or improves the code may missunderstand or generate a typo on this values. This can be avoid if declared as a constant or used within a function -1e18 to constant L102, L103, L105, L162, L163, L233, L438 -0.01e18 to constant L63, L105, L108 -10** to function L587, L591
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L63 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L102 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L103 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L105 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L108 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L162-163 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L233 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L438 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L587 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L591
Replace magic hardcoded numbers with declared constants.
Missing Natspec comments affect readability and maintainability of a codebase.
Function auction missing return descriptor in the natspec
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L176
Add @return descriptor
Code architecture, incentives, and error handling/reporting questions/issues should be resolved before deployment
The code includes a TODO already done that affects readiability and focus on the readers/auditors of the contracts
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L577-578
Remove already done TODO
solc-version 0.8.14 is too new for being recommended for deployment
New versions of solidity may add new interesting features and some fixes, however, as they are new, they are not tested enough, this may lead into unexpected behaviors or bugs
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L2
Take into account news about new bugs related to version 0.8.14 and/or consider using a previous version more tested in case you don’t need new features. This is informational.
code that are not used should be removed or may lead to confusion while reading
in this case the code doesn't tell exactly on that point what is going on, it should be on the comment of the function or in the exact piece of code
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L567-568
Remove or move to a proper place the commented code if it's useful
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L68
#0 - alcueca
2022-07-22T14:47:28Z
aquelarre
:rofl:
Gracias
Two useful
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, Aymen0909, Chom, Deivitto, ElKu, JC, JohnSmith, Kaiziron, Limbooo, MadWookie, Meera, ReyAdmirado, Rohan16, Sm4rty, SooYa, TomJ, Trumpero, Waze, __141345__, ajtra, ak1, antonttc, bulej93, c3phas, cRat1st0s, csanuragjain, defsec, durianSausage, fatherOfBlocks, gogo, hake, hickuphh3, ignacio, joestakey, karanctf, kyteg, m_Rassska, pashov, rajatbeladiya, rbserver, robee, rokinot, samruna, sashik_eth, simon135, tofunmi
16.9093 USDC - $16.91
Custom errors reduce 38 gas if the condition is met and 22 gas otherwise. Also reduces contract size and deployment costs.
Since version 0.8.4 the use of custom errors rather than revert() / require() saves gas as noticed in https://blog.soliditylang.org/2021/04/21/custom-errors/ https://github.com/code-423n4/2022-04-pooltogether-findings/issues/13
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L84 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L102 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L103 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L104-L106 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L108 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L189 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L200 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L255 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L256 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L300 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L313 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L328 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L358 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L365 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L395 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L416 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L437-440
replace each require by an error
using > 0 costs 6 more gas than != 0 when used on a require() statement as negative numbers are not allowed in uint values
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L255 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L300 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L358 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L393 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L398 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L416
replace > 0 to != 0 for extra gas savings by each time is called the condition
duplicated require() / revert() checks should be refactored to a modifier or function to save gas
https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L255 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L300 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L358 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L416 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L313 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L365 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L328 https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L395
refactor this checks to different functions to save gas