Omniscia Mean Finance Audit
TakeRunSwapAndTransfer Code Style Findings
TakeRunSwapAndTransfer Code Style Findings
TRS-01C: Cross-Contract Function Overlap
Type | Severity | Location |
---|---|---|
Code Style | TakeRunSwapAndTransfer.sol:L39-L53 |
Description:
The takeRunSwapAndTransfer
function contains the exact same statements as the takeAndRunSwap
function of the TakeAndRunSwap
contract except for the last statement.
Example:
solidity/contracts/extensions/TakeRunSwapAndTransfer.sol
33function takeRunSwapAndTransfer(TakeRunSwapAndTransferParams calldata _parameters)34 public35 payable36 virtual37 onlyAllowlisted(_parameters.swapper)38{39 if (_parameters.tokenIn != PROTOCOL_TOKEN) {40 _takeFromMsgSender(IERC20(_parameters.tokenIn), _parameters.maxAmountIn);41 _maxApproveSpenderIfNeeded(42 IERC20(_parameters.tokenIn),43 _parameters.allowanceTarget,44 _parameters.swapper == _parameters.allowanceTarget, // If target is a swapper, then it's ok as allowance target45 _parameters.maxAmountIn46 );47 _executeSwap(_parameters.swapper, _parameters.swapData, 0);48 } else {49 _executeSwap(_parameters.swapper, _parameters.swapData, _parameters.maxAmountIn);50 }51 if (_parameters.checkUnspentTokensIn) {52 _sendBalanceOnContractToRecipient(_parameters.tokenIn, msg.sender);53 }54 _sendBalanceOnContractToRecipient(_parameters.tokenOut, _parameters.recipient);55}
Recommendation:
We advise the TakeAndRunSwap
contract to refactor its code to make use of internal
functions and the TakeRunSwapAndTransfer
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.