Platform: Code4rena
Start Date: 07/01/2022
Pot Size: $80,000 USDC
Total HM: 21
Participants: 37
Period: 7 days
Judge: 0xean
Total Solo HM: 14
Id: 71
League: ETH
Rank: 30/37
Findings: 1
Award: $30.37
🌟 Selected for report: 0
🚀 Solo Findings: 0
2.9784 INSURE - $1.04
1.5637 USDC - $1.56
OriDabush
in some loops in the smart contracts the loops look like this:
for (uint256 i = 0; i < _ids.length; i++) { ... }
It can be turned to this instead to save some gas while incrementing i:
for (uint256 i = 0; i < _ids.length; ++i) { ... }
Some example for these loops are in:
#0 - oishun1112
2022-01-13T17:52:40Z
#1 - 0xean
2022-01-27T23:54:11Z
duplicate of #254
3.723 INSURE - $1.30
1.9546 USDC - $1.95
OriDabush
There is no need to write expressions like <boolean expression> == true
or <boolean expression> == false
, because if it is a boolean expression it will be resolved to true or false directly, and you can use it straight like this or use the not operator (!) in order to require the opposite expression.
For example, in line 165 there is the following require:
require( templates[address(_template)].approval == true, "ERROR: UNAUTHORIZED_TEMPLATE" );
It can be replaced with the following code in order to save the comparison (==):
require( templates[address(_template)].approval, "ERROR: UNAUTHORIZED_TEMPLATE" );
Another example for it is in line 169. The following code:
if (templates[address(_template)].isOpen == false) { require( ownership.owner() == msg.sender, "ERROR: UNAUTHORIZED_SENDER" ); }
can be replaced with this code:
if (!(templates[address(_template)].isOpen)) { require( ownership.owner() == msg.sender, "ERROR: UNAUTHORIZED_SENDER" ); }
#0 - oishun1112
2022-01-13T17:55:24Z
28.022 INSURE - $9.81
14.7115 USDC - $14.71
OriDabush
Vault.sol
In the loop in lines 109-113 you can unroll the loop in order to save creating the i
variable and incrementing it.
code before:
for (uint128 i = 0; i < 2; i++) { uint256 _allocation = (_shares[i] * _attributions) / MAGIC_SCALE_1E6; attributions[_beneficiaries[i]] += _allocation; _allocations[i] = _allocation; }
code after:
uint256 _allocation = (_shares[0] * _attributions) / MAGIC_SCALE_1E6; attributions[_beneficiaries[0]] += _allocation; _allocations[0] = _allocation; _allocation = (_shares[1] * _attributions) / MAGIC_SCALE_1E6; attributions[_beneficiaries[1]] += _allocation; _allocations[1] = _allocation;
#0 - oishun1112
2022-01-13T17:51:53Z