Omniscia Native Audit

Multicall Code Style Findings

Multicall Code Style Findings

MLL-01C: Loop Iterator Optimization

TypeSeverityLocation
Gas OptimizationMulticall.sol:L15

Description:

The linked for loop increments / decrements the iterator "safely" due to Solidity's built-in safe arithmetics(post - 0.8.X).

Example:

contracts/libraries/Multicall.sol
15for (uint256 i = 0; i < data.length; i++) {

Recommendation:

We advise the increment / decrement operation to be performed in an unchecked code block as the last statement within the for loop to optimize its execution cost.

Alleviation:

The loop iterator is now optimally incremented in an unchecked code block as advised.

MLL-02C: Re-Order of Input Arguments

TypeSeverityLocation
Code StyleMulticall.sol:L32, L43

Description:

The multicall function overloads present in the Multicall contract should honour the original positional arguments of the "base" multicall function they invoke.

Example:

contracts/libraries/Multicall.sol
12/// @inheritdoc IMulticall
13function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) {
14 results = new bytes[](data.length);
15 for (uint256 i = 0; i < data.length; i++) {
16 (bool success, bytes memory result) = address(this).delegatecall(data[i]);
17
18 if (!success) {
19 // Next 5 lines from https://ethereum.stackexchange.com/a/83577
20 if (result.length < 68) revert();
21 assembly {
22 result := add(result, 0x04)
23 }
24 revert(abi.decode(result, (string)));
25 }
26
27 results[i] = result;
28 }
29}
30
31/// @inheritdoc IMulticall
32function multicall(uint256 deadline, bytes[] calldata data)
33 external
34 payable
35 override
36 checkDeadline(deadline)
37 returns (bytes[] memory)
38{
39 return multicall(data);
40}
41
42/// @inheritdoc IMulticall
43function multicall(bytes32 previousBlockhash, bytes[] calldata data)

Recommendation:

We advise the overloaded functions to have their input arguments swapped to ensure that all multicall implementations begin with the bytes[] calldata data argument.

Alleviation:

The Native team evaluated this exhibit but opted not to apply a remediation for it as they consider it inconsequential.