Platform: Code4rena
Start Date: 08/11/2022
Pot Size: $60,500 USDC
Total HM: 6
Participants: 72
Period: 5 days
Judge: Picodes
Total Solo HM: 2
Id: 178
League: ETH
Rank: 8/72
Findings: 1
Award: $735.51
š Selected for report: 0
š Solo Findings: 0
735.5126 USDC - $735.51
_handleFees
method when feeBp
parameter is equals to 0.Currently only receipt fee is checked to call _handleFees
method but if you see its implementation, orderFee
value will be 0 if mentioned parameter is equal to 0.
So, it is possible to save all _handleFees()
execution gas making this validation.
Validation to add:
https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/proxies/SeaportProxy.sol#L133
if (feeRecipient != address(0) && feeBp != 0) _handleFees(orders, feeBp, feeRecipient);
Place where the fees become 0 when feeBp
is equals to 0:
https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/proxies/SeaportProxy.sol#L147
lastOrderCurrency
variable at the beggining of _handleFees
method to remove loop condition.Note: This improvement is valid if you add G-1 too.
Consider that when handleFees
method is called, orders.length
is validated to have some row.
So you could set lastOrderCurrency = orders[0].currency
and remove if (fee != 0)
loop condition. Doing that, it is not possible to have fee == 0
at this point because feeBP
parameter is not equals to 0 and the first time the loop is executed if (currency == lastOrderCurrency)
condition will be true.
Place assignation lastOrderCurrency = orders[0].currency
in the following line:
https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/proxies/SeaportProxy.sol#L141
Remove conditional and call _transferFee
method direclty:
https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/proxies/SeaportProxy.sol#L152
Important: Does not remove the conditional at line 163 because is still valid. https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/proxies/SeaportProxy.sol#L163
execute
method.Replace memory declaration for calldata for order
variable due to it is only used to read data.
https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/proxies/LooksRareProxy.sol#L65
Original:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāā¬āāāāāāāāā¬āāāāāāāāā¬āāāāāāāāā¬āāāāāāāāāā® ā contracts/proxies/LooksRareProxy.sol:LooksRareProxy contract ā ā ā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāŖāāāāāāāāāāāāāāāāāāŖāāāāāāāāāŖāāāāāāāāāŖāāāāāāāāāŖāāāāāāāāāā” ā Deployment Cost ā Deployment Size ā ā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā⤠ā 1683078 ā 8635 ā ā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā⤠ā Function Name ā min ā avg ā median ā max ā # calls ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā⤠ā execute ā 300453 ā 300453 ā 300453 ā 300453 ā 1 ā ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāā“āāāāāāāāā“āāāāāāāāā“āāāāāāāāā“āāāāāāāāāāÆ
Optimized:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāā¬āāāāāāāāā¬āāāāāāāāā¬āāāāāāāāā¬āāāāāāāāāā® ā contracts/proxies/LooksRareProxy.sol:LooksRareProxy contract ā ā ā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāŖāāāāāāāāāāāāāāāāāāŖāāāāāāāāāŖāāāāāāāāāŖāāāāāāāāāŖāāāāāāāāāā” ā Deployment Cost ā Deployment Size ā ā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā⤠ā 1644436 ā 8442 ā ā ā ā ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā⤠ā Function Name ā min ā avg ā median ā max ā # calls ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā¼āāāāāāāāā⤠ā execute ā 298845 ā 298845 ā 298845 ā 298845 ā 1 ā ā°āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāā“āāāāāāāāā“āāāāāāāāā“āāāāāāāāā“āāāāāāāāāāÆ
As you can see you will save 1608*N Gas, where N is orders
parameter length.
Deployment cost is 38642 Gas cheaper too.
#0 - c4-judge
2022-11-21T18:16:57Z
Picodes marked the issue as grade-a
#1 - 0xhiroshi
2022-11-24T22:42:25Z
(we are dropping fees altogether, but will answer the above as if we are still implementing it)
G-1: invalid, fee bp and recipient will either be nonzero together, or zero together
G-2: acknowledged
G-3: valid
#2 - c4-sponsor
2022-11-24T22:42:31Z
0xhiroshi requested judge review