mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
replaced ethAddr
This commit is contained in:
parent
81e54d6841
commit
7f7d03157e
|
@ -15,12 +15,12 @@ abstract contract Basic is DSMath, Stores {
|
|||
}
|
||||
|
||||
function getTokenBal(TokenInterface token) internal view returns(uint _amt) {
|
||||
_amt = address(token) == getEthAddr() ? address(this).balance : token.balanceOf(address(this));
|
||||
_amt = address(token) == ethAddr ? address(this).balance : token.balanceOf(address(this));
|
||||
}
|
||||
|
||||
function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) {
|
||||
buyDec = address(buyAddr) == getEthAddr() ? 18 : buyAddr.decimals();
|
||||
sellDec = address(sellAddr) == getEthAddr() ? 18 : sellAddr.decimals();
|
||||
buyDec = address(buyAddr) == ethAddr ? 18 : buyAddr.decimals();
|
||||
sellDec = address(sellAddr) == ethAddr ? 18 : sellAddr.decimals();
|
||||
}
|
||||
|
||||
function encodeEvent(string memory eventName, bytes memory eventParam) internal pure returns (bytes memory) {
|
||||
|
|
|
@ -27,7 +27,7 @@ abstract contract OneProtoResolver is Helpers, Events {
|
|||
uint _slippageAmt = getSlippageAmt(_buyAddr, _sellAddr, _sellAmt, oneProtoData.unitAmt);
|
||||
|
||||
uint ethAmt;
|
||||
if (address(_sellAddr) == getEthAddr()) {
|
||||
if (address(_sellAddr) == ethAddr) {
|
||||
ethAmt = _sellAmt;
|
||||
} else {
|
||||
_sellAddr.approve(address(oneProtoContract), _sellAmt);
|
||||
|
@ -63,7 +63,7 @@ abstract contract OneProtoResolver is Helpers, Events {
|
|||
|
||||
OneProtoInterface oneSplitContract = OneProtoInterface(getOneProtoAddress());
|
||||
uint ethAmt;
|
||||
if (address(_sellAddr) == getEthAddr()) {
|
||||
if (address(_sellAddr) == ethAddr) {
|
||||
ethAmt = _sellAmt;
|
||||
} else {
|
||||
_sellAddr.approve(address(oneSplitContract), _sellAmt);
|
||||
|
@ -232,7 +232,7 @@ abstract contract OneInchResolverHelpers is OneProtoResolverHelpers {
|
|||
TokenInterface _sellAddr = oneInchData.sellToken;
|
||||
|
||||
uint ethAmt;
|
||||
if (address(_sellAddr) == getEthAddr()) {
|
||||
if (address(_sellAddr) == ethAddr) {
|
||||
ethAmt = oneInchData._sellAmt;
|
||||
} else {
|
||||
TokenInterface(_sellAddr).approve(getOneInchAddress(), oneInchData._sellAmt);
|
||||
|
|
|
@ -101,12 +101,12 @@ abstract contract OneHelpers is Stores, DSMath {
|
|||
}
|
||||
|
||||
function getTokenBal(TokenInterface token) internal view returns(uint _amt) {
|
||||
_amt = address(token) == getEthAddr() ? address(this).balance : token.balanceOf(address(this));
|
||||
_amt = address(token) == ethAddr ? address(this).balance : token.balanceOf(address(this));
|
||||
}
|
||||
|
||||
function getTokensDec(TokenInterface buyAddr, TokenInterface sellAddr) internal view returns(uint buyDec, uint sellDec) {
|
||||
buyDec = address(buyAddr) == getEthAddr() ? 18 : buyAddr.decimals();
|
||||
sellDec = address(sellAddr) == getEthAddr() ? 18 : sellAddr.decimals();
|
||||
buyDec = address(buyAddr) == ethAddr ? 18 : buyAddr.decimals();
|
||||
sellDec = address(sellAddr) == ethAddr ? 18 : sellAddr.decimals();
|
||||
}
|
||||
|
||||
function getSlippageAmt(
|
||||
|
@ -152,7 +152,7 @@ abstract contract OneProtoResolver is OneHelpers {
|
|||
uint _slippageAmt = getSlippageAmt(_buyAddr, _sellAddr, _sellAmt, oneProtoData.unitAmt);
|
||||
|
||||
uint ethAmt;
|
||||
if (address(_sellAddr) == getEthAddr()) {
|
||||
if (address(_sellAddr) == ethAddr) {
|
||||
ethAmt = _sellAmt;
|
||||
} else {
|
||||
_sellAddr.approve(address(oneProtoContract), _sellAmt);
|
||||
|
@ -194,7 +194,7 @@ abstract contract OneProtoResolver is OneHelpers {
|
|||
|
||||
OneProtoInterface oneSplitContract = OneProtoInterface(getOneProtoAddress());
|
||||
uint ethAmt;
|
||||
if (address(_sellAddr) == getEthAddr()) {
|
||||
if (address(_sellAddr) == ethAddr) {
|
||||
ethAmt = _sellAmt;
|
||||
} else {
|
||||
_sellAddr.approve(address(oneSplitContract), _sellAmt);
|
||||
|
@ -439,7 +439,7 @@ abstract contract OneInchResolverHelpers is OneProtoResolverHelpers {
|
|||
TokenInterface _sellAddr = oneInchData.sellToken;
|
||||
|
||||
uint ethAmt;
|
||||
if (address(_sellAddr) == getEthAddr()) {
|
||||
if (address(_sellAddr) == ethAddr) {
|
||||
ethAmt = oneInchData._sellAmt;
|
||||
} else {
|
||||
TokenInterface(_sellAddr).approve(getOneInchAddress(), oneInchData._sellAmt);
|
||||
|
|
|
@ -96,7 +96,7 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
AaveInterface aave = AaveInterface(getAaveProvider().getLendingPool());
|
||||
|
||||
uint ethAmt;
|
||||
if (token == getEthAddr()) {
|
||||
if (token == ethAddr) {
|
||||
_amt = _amt == uint(-1) ? address(this).balance : _amt;
|
||||
ethAmt = _amt;
|
||||
} else {
|
||||
|
@ -127,9 +127,9 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
ATokenInterface atoken = ATokenInterface(aaveCore.getReserveATokenAddress(token));
|
||||
TokenInterface tokenContract = TokenInterface(token);
|
||||
|
||||
uint initialBal = token == getEthAddr() ? address(this).balance : tokenContract.balanceOf(address(this));
|
||||
uint initialBal = token == ethAddr ? address(this).balance : tokenContract.balanceOf(address(this));
|
||||
atoken.redeem(_amt);
|
||||
uint finalBal = token == getEthAddr() ? address(this).balance : tokenContract.balanceOf(address(this));
|
||||
uint finalBal = token == ethAddr ? address(this).balance : tokenContract.balanceOf(address(this));
|
||||
|
||||
_amt = sub(finalBal, initialBal);
|
||||
setUint(setId, _amt);
|
||||
|
@ -170,7 +170,7 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
_amt = add(_amt, fee);
|
||||
}
|
||||
uint ethAmt;
|
||||
if (token == getEthAddr()) {
|
||||
if (token == ethAddr) {
|
||||
ethAmt = _amt;
|
||||
} else {
|
||||
TokenInterface(token).approve(getAaveProvider().getLendingPoolCore(), _amt);
|
||||
|
|
|
@ -129,7 +129,7 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
AaveInterface aave = AaveInterface(getAaveProvider().getLendingPool());
|
||||
AaveDataProviderInterface aaveData = getAaveDataProvider();
|
||||
|
||||
bool isEth = token == getEthAddr();
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? getWethAddr() : token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
@ -165,7 +165,7 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
uint _amt = getUint(getId, amt);
|
||||
|
||||
AaveInterface aave = AaveInterface(getAaveProvider().getLendingPool());
|
||||
bool isEth = token == getEthAddr();
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? getWethAddr() : token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
@ -196,7 +196,7 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
|
||||
AaveInterface aave = AaveInterface(getAaveProvider().getLendingPool());
|
||||
|
||||
bool isEth = token == getEthAddr();
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? getWethAddr() : token;
|
||||
|
||||
aave.borrow(_token, _amt, rateMode, getReferralCode(), address(this));
|
||||
|
@ -221,7 +221,7 @@ abstract contract BasicResolver is AaveHelpers {
|
|||
AaveInterface aave = AaveInterface(getAaveProvider().getLendingPool());
|
||||
AaveDataProviderInterface aaveData = getAaveDataProvider();
|
||||
|
||||
bool isEth = token == getEthAddr();
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? getWethAddr() : token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
|
|
@ -31,7 +31,7 @@ abstract contract BasicResolver is Stores {
|
|||
*/
|
||||
function deposit(address erc20, uint tokenAmt, uint getId, uint setId) public payable {
|
||||
uint amt = getUint(getId, tokenAmt);
|
||||
if (erc20 != getEthAddr()) {
|
||||
if (erc20 != ethAddr) {
|
||||
IERC20 token = IERC20(erc20);
|
||||
amt = amt == uint(-1) ? token.balanceOf(msg.sender) : amt;
|
||||
token.safeTransferFrom(msg.sender, address(this), amt);
|
||||
|
@ -61,7 +61,7 @@ abstract contract BasicResolver is Stores {
|
|||
) public payable {
|
||||
// require(AccountInterface(address(this)).isAuth(to), "invalid-to-address");
|
||||
uint amt = getUint(getId, tokenAmt);
|
||||
if (erc20 == getEthAddr()) {
|
||||
if (erc20 == ethAddr) {
|
||||
amt = amt == uint(-1) ? address(this).balance : amt;
|
||||
to.transfer(amt);
|
||||
} else {
|
||||
|
|
|
@ -130,7 +130,7 @@ abstract contract DydxHelpers is DSMath, Stores {
|
|||
*/
|
||||
function getMarketId(SoloMarginContract solo, address token) internal view returns (uint _marketId) {
|
||||
uint markets = solo.getNumMarkets();
|
||||
address _token = token == getEthAddr() ? getWETHAddr() : token;
|
||||
address _token = token == ethAddr ? getWETHAddr() : token;
|
||||
|
||||
for (uint i = 0; i < markets; i++) {
|
||||
if (_token == solo.getMarketTokenAddress(i)) {
|
||||
|
@ -164,7 +164,7 @@ abstract contract BasicResolver is DydxHelpers {
|
|||
(uint depositedAmt, bool sign) = getDydxPosition(dydxContract, _marketId);
|
||||
require(depositedAmt == 0 || sign, "token-borrowed");
|
||||
|
||||
if (token == getEthAddr()) {
|
||||
if (token == ethAddr) {
|
||||
TokenInterface tokenContract = TokenInterface(getWETHAddr());
|
||||
_amt = _amt == uint(-1) ? address(this).balance : _amt;
|
||||
tokenContract.deposit{value: _amt}();
|
||||
|
@ -202,7 +202,7 @@ abstract contract BasicResolver is DydxHelpers {
|
|||
|
||||
dydxContract.operate(getAccountArgs(), getActionsArgs(_marketId, _amt, false));
|
||||
|
||||
if (token == getEthAddr()) {
|
||||
if (token == ethAddr) {
|
||||
TokenInterface tokenContract = TokenInterface(getWETHAddr());
|
||||
tokenContract.approve(address(tokenContract), _amt);
|
||||
tokenContract.withdraw(_amt);
|
||||
|
@ -231,7 +231,7 @@ abstract contract BasicResolver is DydxHelpers {
|
|||
|
||||
dydxContract.operate(getAccountArgs(), getActionsArgs(_marketId, _amt, false));
|
||||
|
||||
if (token == getEthAddr()) {
|
||||
if (token == ethAddr) {
|
||||
TokenInterface tokenContract = TokenInterface(getWETHAddr());
|
||||
tokenContract.approve(address(tokenContract), _amt);
|
||||
tokenContract.withdraw(_amt);
|
||||
|
@ -261,7 +261,7 @@ abstract contract BasicResolver is DydxHelpers {
|
|||
_amt = _amt == uint(-1) ? borrowedAmt : _amt;
|
||||
require(_amt <= borrowedAmt, "payback-exceeds");
|
||||
|
||||
if (token == getEthAddr()) {
|
||||
if (token == ethAddr) {
|
||||
TokenInterface tokenContract = TokenInterface(getWETHAddr());
|
||||
require(address(this).balance >= _amt, "not-enough-eth");
|
||||
tokenContract.deposit{value: _amt}();
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract contract FlashLoanResolver is Stores {
|
|||
function borrowAndCast(address token, uint tokenAmt, bytes memory data) public payable {
|
||||
AccountInterface(address(this)).enable(getDydxLoanAddr());
|
||||
|
||||
address _token = token == getEthAddr() ? getWethAddr() : token;
|
||||
address _token = token == ethAddr ? getWethAddr() : token;
|
||||
|
||||
DydxFlashInterface(getDydxLoanAddr()).initiateFlashLoan(_token, tokenAmt, data);
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ abstract contract KyberResolver is KyberHelpers {
|
|||
uint _sellAmt = getUint(getId, sellAmt);
|
||||
|
||||
uint ethAmt;
|
||||
if (sellAddr == getEthAddr()) {
|
||||
if (sellAddr == ethAddr) {
|
||||
_sellAmt = _sellAmt == uint(-1) ? address(this).balance : _sellAmt;
|
||||
ethAmt = _sellAmt;
|
||||
} else {
|
||||
|
|
|
@ -85,12 +85,12 @@ abstract contract UniswapHelpers is Stores, DSMath {
|
|||
}
|
||||
|
||||
function getTokenBalace(address token) internal view returns (uint256 amt) {
|
||||
amt = token == getEthAddr() ? address(this).balance : TokenInterface(token).balanceOf(address(this));
|
||||
amt = token == ethAddr ? address(this).balance : TokenInterface(token).balanceOf(address(this));
|
||||
}
|
||||
|
||||
function changeEthAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){
|
||||
_buy = buy == getEthAddr() ? TokenInterface(getAddressWETH()) : TokenInterface(buy);
|
||||
_sell = sell == getEthAddr() ? TokenInterface(getAddressWETH()) : TokenInterface(sell);
|
||||
_buy = buy == ethAddr ? TokenInterface(getAddressWETH()) : TokenInterface(buy);
|
||||
_sell = sell == ethAddr ? TokenInterface(getAddressWETH()) : TokenInterface(sell);
|
||||
}
|
||||
|
||||
function convertEthToWeth(TokenInterface token, uint amount) internal {
|
||||
|
@ -162,8 +162,8 @@ abstract contract LiquidityHelpers is UniswapHelpers {
|
|||
address[] memory tokens
|
||||
) internal pure returns(TokenInterface[] memory _tokens) {
|
||||
_tokens = new TokenInterface[](2);
|
||||
_tokens[0] = tokens[0] == getEthAddr() ? TokenInterface(getAddressWETH()) : TokenInterface(tokens[0]);
|
||||
_tokens[1] = tokens[1] == getEthAddr() ? TokenInterface(getAddressWETH()) : TokenInterface(tokens[1]);
|
||||
_tokens[0] = tokens[0] == ethAddr ? TokenInterface(getAddressWETH()) : TokenInterface(tokens[0]);
|
||||
_tokens[1] = tokens[1] == ethAddr ? TokenInterface(getAddressWETH()) : TokenInterface(tokens[1]);
|
||||
}
|
||||
|
||||
function _addLiquidity(
|
||||
|
@ -463,7 +463,7 @@ abstract contract UniswapResolver is UniswapLiquidity {
|
|||
address[] memory paths = getPaths(address(_buyAddr), address(_sellAddr));
|
||||
|
||||
if (_sellAmt == uint(-1)) {
|
||||
_sellAmt = sellAddr == getEthAddr() ? address(this).balance : _sellAddr.balanceOf(address(this));
|
||||
_sellAmt = sellAddr == ethAddr ? address(this).balance : _sellAddr.balanceOf(address(this));
|
||||
}
|
||||
|
||||
uint _slippageAmt = convert18ToDec(_buyAddr.decimals(),
|
||||
|
|
|
@ -40,7 +40,7 @@ contract BasicResolver is Memory {
|
|||
/**
|
||||
* @dev ETH Address.
|
||||
*/
|
||||
function getEthAddr() internal pure returns (address) {
|
||||
function ethAddr internal pure returns (address) {
|
||||
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ contract BasicResolver is Memory {
|
|||
uint tokenAmt
|
||||
) external payable {
|
||||
uint amt;
|
||||
if (erc20 == getEthAddr()) {
|
||||
if (erc20 == ethAddr) {
|
||||
amt = tokenAmt == uint(-1) ? address(this).balance : tokenAmt;
|
||||
msg.sender.transfer(amt);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user