Omniscia Mean Finance Audit
TakeManyRunSwapsAndTransferMany Code Style Findings
TakeManyRunSwapsAndTransferMany Code Style Findings
TMS-01C: Cross-Contract Function Overlap
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | TakeManyRunSwapsAndTransferMany.sol:L40-L61 |
Description:
The takeManyRunSwapsAndTransferMany function contains the exact same final statements as the takeRunSwapsAndTransferMany of TakeRunSwapsAndTransferMany.
Example:
32function takeManyRunSwapsAndTransferMany(TakeManyRunSwapsAndTransferManyParams calldata _parameters) public payable virtual {33 // Take from caller34 for (uint256 i; i < _parameters.takeFromCaller.length; i++) {35 TakeFromCaller memory _takeFromCaller = _parameters.takeFromCaller[i];36 _takeFromMsgSender(_takeFromCaller.token, _takeFromCaller.amount);37 }38
39 // Validate that all swappers are allowlisted40 for (uint256 i; i < _parameters.swappers.length; i++) {41 _assertSwapperIsAllowlisted(_parameters.swappers[i]);42 }43
44 // Approve whatever is necessary45 for (uint256 i; i < _parameters.allowanceTargets.length; i++) {46 Allowance memory _allowance = _parameters.allowanceTargets[i];47 _maxApproveSpenderIfNeeded(_allowance.token, _allowance.allowanceTarget, false, _allowance.minAllowance);48 }49
50 // Execute swaps51 for (uint256 i; i < _parameters.swaps.length; i++) {52 SwapContext memory _context = _parameters.swapContext[i];53 _executeSwap(_parameters.swappers[_context.swapperIndex], _parameters.swaps[i], _context.value);54 }55
56 // Transfer out whatever was left in the contract57 for (uint256 i; i < _parameters.transferOutBalance.length; i++) {58 TransferOutBalance memory _transferOutBalance = _parameters.transferOutBalance[i];59 _sendBalanceOnContractToRecipient(_transferOutBalance.token, _transferOutBalance.recipient);60 }61}Recommendation:
We advise the TakeRunSwapsAndTransferMany contract to refactor its code to make use of internal functions and the TakeManyRunSwapsAndTransferMany contract to inherit from it and make proper use of its internal functions reducing code maintenance cost across the codebase.
Alleviation:
The Mean Finance team evaluated this exhibit and opted to not apply the optimization advised as they wish to retain the current implementation in favour of de-coupling and minimizing inter-contract dependencies. As a result, we consider this exhibit acknowledged.
TMS-02C: Loop Iterator Optimizations
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | TakeManyRunSwapsAndTransferMany.sol:L34, L40, L45, L51, L57 |
Description:
The linked for loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics(post - 0.8.X).
Example:
34for (uint256 i; i < _parameters.takeFromCaller.length; i++) {Recommendation:
We advise the increment / decrement operations to be performed in an unchecked code block as the last statement within each for loop to optimize their execution cost.
Alleviation:
All for loops have been appropriately optimized via the usage of the unchecked code block for each iterator's increment.
