diff --git a/contracts/mainnet/connectors/euler/helpers.sol b/contracts/mainnet/connectors/euler/helpers.sol index 22068766..73660049 100644 --- a/contracts/mainnet/connectors/euler/helpers.sol +++ b/contracts/mainnet/connectors/euler/helpers.sol @@ -1,10 +1,37 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.7.0; -import "./variables.sol"; +import "./interface.sol"; import "./events.sol"; import { Basic } from "../../common/basic.sol"; -contract Helpers is Basic, Variables, Events { +contract Helpers is Basic, Events { + + address internal constant EULER_MAINNET = + 0x27182842E098f60e3D576794A5bFFb0777E025d3; + IEulerMarkets internal constant markets = + IEulerMarkets(0x3520d5a913427E6F0D6A83E07ccD4A4da316e4d3); + IEulerSwap internal constant swapExec = + IEulerSwap(0x7123C8cBBD76c5C7fCC9f7150f23179bec0bA341); + + struct swapHelper { + address _sellAddr; + address _buyAddr; + uint256 _buyDec; + uint256 _sellDec; + uint256 _sellAmt18; + uint256 _slippageAmt; + } + + struct swapParams { + uint256 subAccountFrom; + uint256 subAccountTo; + address buyAddr; + address sellAddr; + uint256 sellAmt; + uint256 unitAmt; + bytes callData; + } + /** * @dev Get Enetered markets for a user */ diff --git a/contracts/mainnet/connectors/euler/main.sol b/contracts/mainnet/connectors/euler/main.sol index e97af1d6..dfbe43f7 100644 --- a/contracts/mainnet/connectors/euler/main.sol +++ b/contracts/mainnet/connectors/euler/main.sol @@ -50,7 +50,7 @@ abstract contract Euler is Helpers { approve(tokenContract, EULER_MAINNET, _amt); IEulerEToken eToken = IEulerEToken(markets.underlyingToEToken(_token)); - eToken.deposit(subAccount, _amt); //0 for primary + eToken.deposit(subAccount, _amt); if (enableCollateral) { markets.enterMarket(subAccount, _token); @@ -183,11 +183,7 @@ abstract contract Euler is Helpers { convertEthToWeth(isEth, TokenInterface(_token), _amt); } - _amt = _amt == type(uint256).max - ? borrowedDToken.balanceOf(address(this)) - : _amt; - - TokenInterface(_token).approve(EULER_MAINNET, _amt); + approve(TokenInterface(_token), EULER_MAINNET, _amt); borrowedDToken.repay(subAccount, _amt); setUint(setId, _amt); @@ -405,9 +401,6 @@ abstract contract Euler is Helpers { address _token = isEth ? wethAddr : token; IEulerDToken dToken = IEulerDToken(markets.underlyingToDToken(_token)); - _amt = _amt == type(uint256).max - ? dToken.balanceOf(address(this)) - : _amt; dToken.approveDebt(subAccountId, debtReceiver, _amt); @@ -417,25 +410,6 @@ abstract contract Euler is Helpers { _eventParam = abi.encode(subAccountId, debtReceiver, token, _amt); } - struct swapHelper { - address _sellAddr; - address _buyAddr; - uint256 _buyDec; - uint256 _sellDec; - uint256 _sellAmt18; - uint256 _slippageAmt; - } - - struct swapParams { - uint256 subAccountFrom; - uint256 subAccountTo; - address buyAddr; - address sellAddr; - uint256 sellAmt; - uint256 unitAmt; - bytes callData; - } - /** * @dev Swap. * @notice Executes swap. @@ -518,10 +492,6 @@ abstract contract Euler is Helpers { for (uint256 i = 0; i < _length; i++) { address _token = tokens[i] == ethAddr ? wethAddr : tokens[i]; - - IEulerEToken eToken = IEulerEToken( - markets.underlyingToEToken(_token) - ); markets.enterMarket(subAccountId, _token); }