mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
refactoring + updates
This commit is contained in:
parent
d028fcb41c
commit
b561e6d014
|
@ -1,10 +1,37 @@
|
||||||
//SPDX-License-Identifier: MIT
|
//SPDX-License-Identifier: MIT
|
||||||
pragma solidity ^0.7.0;
|
pragma solidity ^0.7.0;
|
||||||
import "./variables.sol";
|
import "./interface.sol";
|
||||||
import "./events.sol";
|
import "./events.sol";
|
||||||
import { Basic } from "../../common/basic.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
|
* @dev Get Enetered markets for a user
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,7 +50,7 @@ abstract contract Euler is Helpers {
|
||||||
approve(tokenContract, EULER_MAINNET, _amt);
|
approve(tokenContract, EULER_MAINNET, _amt);
|
||||||
|
|
||||||
IEulerEToken eToken = IEulerEToken(markets.underlyingToEToken(_token));
|
IEulerEToken eToken = IEulerEToken(markets.underlyingToEToken(_token));
|
||||||
eToken.deposit(subAccount, _amt); //0 for primary
|
eToken.deposit(subAccount, _amt);
|
||||||
|
|
||||||
if (enableCollateral) {
|
if (enableCollateral) {
|
||||||
markets.enterMarket(subAccount, _token);
|
markets.enterMarket(subAccount, _token);
|
||||||
|
@ -183,11 +183,7 @@ abstract contract Euler is Helpers {
|
||||||
convertEthToWeth(isEth, TokenInterface(_token), _amt);
|
convertEthToWeth(isEth, TokenInterface(_token), _amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
_amt = _amt == type(uint256).max
|
approve(TokenInterface(_token), EULER_MAINNET, _amt);
|
||||||
? borrowedDToken.balanceOf(address(this))
|
|
||||||
: _amt;
|
|
||||||
|
|
||||||
TokenInterface(_token).approve(EULER_MAINNET, _amt);
|
|
||||||
borrowedDToken.repay(subAccount, _amt);
|
borrowedDToken.repay(subAccount, _amt);
|
||||||
|
|
||||||
setUint(setId, _amt);
|
setUint(setId, _amt);
|
||||||
|
@ -405,9 +401,6 @@ abstract contract Euler is Helpers {
|
||||||
address _token = isEth ? wethAddr : token;
|
address _token = isEth ? wethAddr : token;
|
||||||
|
|
||||||
IEulerDToken dToken = IEulerDToken(markets.underlyingToDToken(_token));
|
IEulerDToken dToken = IEulerDToken(markets.underlyingToDToken(_token));
|
||||||
_amt = _amt == type(uint256).max
|
|
||||||
? dToken.balanceOf(address(this))
|
|
||||||
: _amt;
|
|
||||||
|
|
||||||
dToken.approveDebt(subAccountId, debtReceiver, _amt);
|
dToken.approveDebt(subAccountId, debtReceiver, _amt);
|
||||||
|
|
||||||
|
@ -417,25 +410,6 @@ abstract contract Euler is Helpers {
|
||||||
_eventParam = abi.encode(subAccountId, debtReceiver, token, _amt);
|
_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.
|
* @dev Swap.
|
||||||
* @notice Executes swap.
|
* @notice Executes swap.
|
||||||
|
@ -518,10 +492,6 @@ abstract contract Euler is Helpers {
|
||||||
|
|
||||||
for (uint256 i = 0; i < _length; i++) {
|
for (uint256 i = 0; i < _length; i++) {
|
||||||
address _token = tokens[i] == ethAddr ? wethAddr : tokens[i];
|
address _token = tokens[i] == ethAddr ? wethAddr : tokens[i];
|
||||||
|
|
||||||
IEulerEToken eToken = IEulerEToken(
|
|
||||||
markets.underlyingToEToken(_token)
|
|
||||||
);
|
|
||||||
markets.enterMarket(subAccountId, _token);
|
markets.enterMarket(subAccountId, _token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user