Platform: Code4rena
Start Date: 20/05/2022
Pot Size: $1,000,000 USDC
Total HM: 4
Participants: 59
Period: 14 days
Judge: leastwood
Id: 128
League: ETH
Rank: 54/59
Findings: 1
Award: $434.51
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0x1f8b, 0x29A, 0xalpharush, Chom, Czar102, Hawkeye, IllIllI, MaratCerby, MiloTruck, NoamYakov, OriDabush, RoiEvenHaim, Spearbit, Tadashi, TerrierLover, TomJ, asutorufos, cccz, cmichel, csanuragjain, defsec, delfin454000, djxploit, ellahi, foobar, gzeon, hake, hickuphh3, ignacio, ilan, joestakey, kaden, mayo, ming, oyc_109, peritoflores, rfa, sach1r0, sashik_eth, shung, sirhashalot, twojoy, zer0dot, zkhorse
434.5068 USDC - $434.51
The default value of uint varibles are 0. Therefore, there is no need to set 0 on uint variables. Not setting 0 on uint variables can reduce the deployment gas cost.
Here are some examples:
https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/lib/AmountDeriver.sol#L44
uint256 extraCeiling = 0;
for (uint256 i = 0; i < totalCriteriaResolvers; ++i) {
They can be modified as follows:
uint256 extraCeiling;
for (uint256 i; i < totalCriteriaResolvers; ++i) {
Since it has if (considerationItem.amount > execution.item.amount)
check, following parts can be wrapped by unchecked like them.
if (considerationItem.amount > execution.item.amount) { ... unchecked { advancedOrders[targetComponent.orderIndex] .parameters .consideration[targetComponent.itemIndex] .startAmount = considerationItem.amount - execution.item.amount; }
} else { ... unchecked { advancedOrders[targetComponent.orderIndex] .parameters .offer[targetComponent.itemIndex] .startAmount = execution.item.amount - considerationItem.amount; }
#0 - HardlyDifficult
2022-07-05T00:10:01Z
No need to set 0 on uint variables
I tested this and got mixed results - some functions saved a tiny amount, others got a bit worse.
The other suggestion should have small savings.