Omniscia Euler Finance Audit

WithdrawalQueue Code Style Findings

WithdrawalQueue Code Style Findings

WQE-01C: Inefficient Argument Data Types

Description:

The Solidity language does not engage in tight-packing mechanisms for ABI encoded function arguments, meaning that utilizing sub-256-bit data types leads to assembly level inefficiencies in the generated bytecode.

Example:

src/module/WithdrawalQueue.sol
15/// @notice Swap two strategies indexes in the withdrawal queue.
16/// @param _index1 index of first strategy.
17/// @param _index2 index of second strategy.
18function reorderWithdrawalQueue(uint8 _index1, uint8 _index2) external virtual nonReentrant {
19 YieldAggregatorStorage storage $ = Storage._getYieldAggregatorStorage();
20
21 uint256 length = $.withdrawalQueue.length;
22 require(_index1 < length && _index2 < length, Errors.OutOfBounds());
23
24 require(_index1 != _index2, Errors.SameIndexes());
25
26 ($.withdrawalQueue[_index1], $.withdrawalQueue[_index2]) =
27 ($.withdrawalQueue[_index2], $.withdrawalQueue[_index1]);
28
29 emit Events.ReorderWithdrawalQueue(_index1, _index2);
30}

Recommendation:

We advise the function to accept uint256 arguments instead, optimizing its gas cost as the generated bytecode will no longer need to validate and / or clean the presently-unused bytes of the input arguments.

Alleviation:

The Euler Finance team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase.