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: 11/63
Findings: 2
Award: $95.50
🌟 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
77.0681 USDC - $77.07
Low risk, non-critical
Quality coding :
Line number 191, 192 can be above Line number 202, https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L191-L192
Because, balances and debt are used after this line 202 only. This could save the execution cost. Its type of gas savings too. I believe this is better way of coding.
Comment could be corrected as under-collateralized in, https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L14
initialization : its better to initialize as zero in below line of code. Relying on the unknown storage data could be risky. https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L133
variable name suggestion in below line of code. https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L99-L100 proportion = VaultProportion, initialOffer = ColletralProportion
code simplification: https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L303-L309 Since artIn already knw from the line - 303, I would write the condition as below instead of using the ternary operator. Because the code could simple and readable. if( artIn > auction_.art ) artIn = auction_.art;
I would suggest the contract name as LiquidEngine.sol instead of Witch.sol Similarly, the variable , otherWitches could be OtherLiquidEngine Function name, setAnotherWitch could be seAnotherLiquidEngine
Its better to use the same datatype in all places. I see there are too many castings. it could tough to track each of the casting to verify appropriate data type during coding. There could be possibility of missing in some places.
For more decentralization: It could better if the governor related cautions is displayed in front end. For example, displaying the auctioner reward in front end.
#0 - alcueca
2022-07-22T14:27:17Z
Useful report with original though behind it, thank you.
🌟 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
18.4309 USDC - $18.43
Gas saving:
Handling validation check Condition check could be >= in below line of code. This could save gas by skipping the calculation done in the else part. https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L586 When elapsed==duration, below calculation will always return 1e18 https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L588-L592
memory can be used instead of storage in following lines of codes https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L254 https://github.com/code-423n4/2022-07-yield/blob/6ab092b8c10e4dabb470918ae15c6451c861655f/contracts/Witch.sol#L231
#0 - alcueca
2022-07-22T14:23:16Z
Thanks!
#1 - JeeberC4
2022-07-27T20:53:13Z
Renamed for warden as they did not have another Gas report.