code-423n4 / 2022-05-opensea-seaport-findings

1 stars 0 forks source link

QA Report #200

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

[QA-1][AmountDeriver.sol] The order of checking if (!exact) does not map 1:1 betwen reference and optimized one

In the optimized contract, the logic order of _getFraction is as follows:

On the other hand, the reference contract does if (!exact) check at the last part of the function. https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/reference/lib/ReferenceAmountDeriver.sol#L96-L100


[QA-2][ZoneInteraction.sol] Missing comment at _callIsValidOrder function

Throughout the codebase, function has comments for their arguments and the note for dev. However, _callIsValidOrder function does not have comments explaining their arguments or its role. https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/lib/ZoneInteraction.sol#L56-L61


[QA-3][OrderFulfiller.sol] Unnecessary return statement

AdvancedOrder[] memory advancedOrders is defined at the function.

However, it also call return advancedOrders at the end of the function. It simply can remove return advancedOrders;. https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/lib/OrderFulfiller.sol#L477-L478


[QA-4][OrderValidator.sol] ++i does not need to be located at the end of for loop

These for loops are wrapped by unchecked.

https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/lib/OrderValidator.sol#L272-L311

https://github.com/code-423n4/2022-05-opensea-seaport/blob/main/contracts/lib/OrderValidator.sol#L350-L394

However, ++i exists at the end of function.

// Increment counter inside body of loop for gas efficiency.
++i;

It simply can be located at the for loop definition instead.

for (uint256 i = 0; i < totalOrders; ++i) {
0xleastwood commented 2 years ago
  1. This is not really an issue. The functions are equivalently the same, except the primary contract is optimised.
  2. The rest are minor issues.
GalloDaSballo commented 2 years ago

[QA-1][AmountDeriver.sol] The order of checking if (!exact) does not map 1:1 betwen reference and optimized one

It would still revert so disagree with the finding

[QA-2][ZoneInteraction.sol] Missing comment at _callIsValidOrder function

Disagree that natspec has to be 100% for all params, all of natspec is optional

[QA-3][OrderFulfiller.sol] Unnecessary return statement

Disagree because the codebase is consistently using named returns with explicit returns

[QA-4][OrderValidator.sol] ++i does not need to be located at the end of for loop

Disagree as the suggestion consumes more gas / misses the point

Agree with Invalid