From 48980f750931f09f0af24c80f7ed08e946e7a54f Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Sat, 15 Oct 2022 22:29:46 +0530 Subject: [PATCH] refactor isETH condition --- contracts/mainnet/connectors/morpho-aave/main.sol | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/contracts/mainnet/connectors/morpho-aave/main.sol b/contracts/mainnet/connectors/morpho-aave/main.sol index 35edc9cc..ab46b492 100644 --- a/contracts/mainnet/connectors/morpho-aave/main.sol +++ b/contracts/mainnet/connectors/morpho-aave/main.sol @@ -201,11 +201,9 @@ abstract contract MorphoAaveV2 is Helpers, Events { { uint256 _amt = getUint(_getId, _amount); - bool _isETH = _tokenAddress == ethAddr; - MORPHO_AAVE.borrow(_poolTokenAddress, _amt, _maxGasForMatching); - if (_isETH) convertWethToEth(_isETH, TokenInterface(wethAddr), _amt); + convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt); setUint(_setId, _amt); @@ -241,8 +239,6 @@ abstract contract MorphoAaveV2 is Helpers, Events { returns (string memory _eventName, bytes memory _eventParam) { uint256 _amt = getUint(_getId, _amount); - bool _isETH = _tokenAddress == ethAddr; - if (_amt == uint256(-1)) (, , _amt) = MORPHO_AAVE_LENS.getCurrentSupplyBalanceInOf( _poolTokenAddress, @@ -251,7 +247,7 @@ abstract contract MorphoAaveV2 is Helpers, Events { MORPHO_AAVE.withdraw(_poolTokenAddress, _amt); - if (_isETH) convertWethToEth(_isETH, TokenInterface(wethAddr), _amt); + convertWethToEth(_tokenAddress == ethAddr, TokenInterface(wethAddr), _amt); setUint(_setId, _amt); @@ -303,7 +299,7 @@ abstract contract MorphoAaveV2 is Helpers, Events { _amt = _amtDSA < _amtDebt ? _amtDSA : _amtDebt; } - if (_isETH) convertEthToWeth(_isETH, _tokenContract, _amt); + convertEthToWeth(_isETH, _tokenContract, _amt); approve(_tokenContract, address(MORPHO_AAVE), _amt); @@ -361,7 +357,7 @@ abstract contract MorphoAaveV2 is Helpers, Events { _amt = _amtDSA < _amtDebt ? _amtDSA : _amtDebt; } - if (_isETH) convertEthToWeth(_isETH, _tokenContract, _amt); + convertEthToWeth(_isETH, _tokenContract, _amt); approve(_tokenContract, address(MORPHO_AAVE), _amt);