From de1472e98fdfe81e0b15718b7e90a1429aa8eee5 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Wed, 26 May 2021 07:03:45 +0530 Subject: [PATCH 01/14] Updated 1inch connector --- .../mainnet/connectors/1inch/helpers.sol | 9 +++++-- contracts/mainnet/connectors/1inch/main.sol | 4 ++-- contracts/mainnet/connectors_old/1inch.sol | 24 +++++++++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/contracts/mainnet/connectors/1inch/helpers.sol b/contracts/mainnet/connectors/1inch/helpers.sol index 1aa7b6a1..41cc4b0d 100644 --- a/contracts/mainnet/connectors/1inch/helpers.sol +++ b/contracts/mainnet/connectors/1inch/helpers.sol @@ -9,10 +9,15 @@ abstract contract Helpers is DSMath, Basic { /** * @dev 1Inch Address */ - address internal constant oneInchAddr = 0x111111125434b319222CdBf8C261674aDB56F3ae; + address internal constant oneInchAddr = 0x11111112542D85B3EF69AE05771c2dCCff4fAa26; /** * @dev 1inch swap function sig */ - bytes4 internal constant oneInchSig = 0x90411a32; + bytes4 internal constant oneInchSwapSig = 0x7c025200; + + /** + * @dev 1inch swap function sig + */ + bytes4 internal constant oneInchUnoswapSig = 0x2e95b6c8; } \ No newline at end of file diff --git a/contracts/mainnet/connectors/1inch/main.sol b/contracts/mainnet/connectors/1inch/main.sol index 31901334..2d892cbd 100644 --- a/contracts/mainnet/connectors/1inch/main.sol +++ b/contracts/mainnet/connectors/1inch/main.sol @@ -25,7 +25,7 @@ abstract contract OneInchResolver is Helpers, Events { assembly { sig := mload(add(_data, 32)) } - isOk = sig == oneInchSig; + isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; } /** @@ -124,5 +124,5 @@ abstract contract OneInch is OneInchResolverHelpers { } contract ConnectV2OneInch is OneInch { - string public name = "1Inch-v1"; + string public name = "1Inch-v1.1"; } diff --git a/contracts/mainnet/connectors_old/1inch.sol b/contracts/mainnet/connectors_old/1inch.sol index fc4b728d..b71b2771 100644 --- a/contracts/mainnet/connectors_old/1inch.sol +++ b/contracts/mainnet/connectors_old/1inch.sol @@ -82,14 +82,21 @@ abstract contract OneHelpers is Stores, DSMath { * @dev Return 1Inch Address */ function getOneInchAddress() internal pure returns (address) { - return 0x111111125434b319222CdBf8C261674aDB56F3ae; + return 0x11111112542D85B3EF69AE05771c2dCCff4fAa26; } /** * @dev Return 1inch swap function sig */ - function getOneInchSig() internal pure returns (bytes4) { - return 0x90411a32; + function getOneInchSwapSig() internal pure returns (bytes4) { + return 0x7c025200; + } + + /** + * @dev Return 1inch swap function sig + */ + function getOneInchUnoswapSig() internal pure returns (bytes4) { + return 0x2e95b6c8; } function convert18ToDec(uint _dec, uint256 _amt) internal pure returns (uint256 amt) { @@ -224,7 +231,7 @@ abstract contract OneInchResolver is OneProtoResolver { assembly { sig := mload(add(_data, 32)) } - isOk = sig == getOneInchSig(); + isOk = sig == getOneInchSwapSig() || sig == getOneInchUnoswapSig(); } struct OneInchData { @@ -585,5 +592,12 @@ abstract contract OneInch is OneProto { } contract ConnectOne is OneInch { - string public name = "1inch-1proto-v1"; + string public name = "1inch-1proto-v1.2"; + + /** + * @dev Connector Details + */ + function connectorID() public pure returns(uint _type, uint _id) { + (_type, _id) = (1, 98); + } } From 1a9ab0ac702a253cf009451e4d6501001800e48c Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 01:25:04 +0530 Subject: [PATCH 02/14] Fixed approve(token.approve => approve()) --- contracts/mainnet/common/basic.sol | 11 ++++++++++- contracts/mainnet/connectors/1inch/main.sol | 2 +- contracts/mainnet/connectors/1proto/main.sol | 4 ++-- contracts/mainnet/connectors/aave/v1/main.sol | 4 ++-- contracts/mainnet/connectors/aave/v2-amm/main.sol | 4 ++-- contracts/mainnet/connectors/aave/v2/main.sol | 4 ++-- contracts/mainnet/connectors/compound/main.sol | 8 ++++---- contracts/mainnet/connectors/cream/main.sol | 8 ++++---- contracts/mainnet/connectors/dydx/main.sol | 12 ++++++------ contracts/mainnet/connectors/erc20_staking/main.sol | 2 +- .../mainnet/connectors/guniswap_v3_erc20/main.sol | 12 ++++++------ .../connectors/guniswap_v3_erc20_staking/main.sol | 2 +- contracts/mainnet/connectors/kyber/main.sol | 2 +- contracts/mainnet/connectors/makerdao/main.sol | 8 ++++---- contracts/mainnet/connectors/oasis/main.sol | 4 ++-- contracts/mainnet/connectors/polygon-bridge/main.sol | 4 ++-- .../mainnet/connectors/refinance/helpers/aaveV1.sol | 4 ++-- .../mainnet/connectors/refinance/helpers/aaveV2.sol | 4 ++-- .../connectors/refinance/helpers/compound.sol | 4 ++-- contracts/mainnet/connectors/reflexer/main.sol | 6 +++--- contracts/mainnet/connectors/uniswap/helpers.sol | 6 +++--- contracts/mainnet/connectors/uniswap/main.sol | 4 ++-- contracts/mainnet/connectors/weth/main.sol | 2 +- contracts/mainnet/connectors_old/1inch.sol | 6 +++--- contracts/polygon/common/basic.sol | 11 ++++++++++- contracts/polygon/connectors/aave/v2/main.sol | 4 ++-- contracts/polygon/connectors/paraswap/helpers.sol | 2 +- 27 files changed, 81 insertions(+), 63 deletions(-) diff --git a/contracts/mainnet/common/basic.sol b/contracts/mainnet/common/basic.sol index fb0882b5..febeb784 100644 --- a/contracts/mainnet/common/basic.sol +++ b/contracts/mainnet/common/basic.sol @@ -27,6 +27,15 @@ abstract contract Basic is DSMath, Stores { return abi.encode(eventName, eventParam); } + function approve(TokenInterface token, address spender, uint256 amount) internal { + try token.approve(spender, amount) { + + } catch { + token.approve(spender, 0); + token.approve(spender, amount); + } + } + function changeEthAddress(address buy, address sell) internal pure returns(TokenInterface _buy, TokenInterface _sell){ _buy = buy == ethAddr ? TokenInterface(wethAddr) : TokenInterface(buy); _sell = sell == ethAddr ? TokenInterface(wethAddr) : TokenInterface(sell); @@ -38,7 +47,7 @@ abstract contract Basic is DSMath, Stores { function convertWethToEth(bool isEth, TokenInterface token, uint amount) internal { if(isEth) { - token.approve(address(token), amount); + approve(token, address(token), amount); token.withdraw(amount); } } diff --git a/contracts/mainnet/connectors/1inch/main.sol b/contracts/mainnet/connectors/1inch/main.sol index 31901334..cc3b7384 100644 --- a/contracts/mainnet/connectors/1inch/main.sol +++ b/contracts/mainnet/connectors/1inch/main.sol @@ -74,7 +74,7 @@ abstract contract OneInchResolverHelpers is OneInchResolver { if (address(_sellAddr) == ethAddr) { ethAmt = oneInchData._sellAmt; } else { - TokenInterface(_sellAddr).approve(oneInchAddr, oneInchData._sellAmt); + approve(TokenInterface(_sellAddr), oneInchAddr, oneInchData._sellAmt); } require(checkOneInchSig(oneInchData.callData), "Not-swap-function"); diff --git a/contracts/mainnet/connectors/1proto/main.sol b/contracts/mainnet/connectors/1proto/main.sol index aec46e0d..f3c2f380 100644 --- a/contracts/mainnet/connectors/1proto/main.sol +++ b/contracts/mainnet/connectors/1proto/main.sol @@ -30,7 +30,7 @@ abstract contract OneProtoResolver is Helpers, Events { if (address(_sellAddr) == ethAddr) { ethAmt = _sellAmt; } else { - _sellAddr.approve(address(oneProto), _sellAmt); + approve(_sellAddr, address(oneProto), _sellAmt); } @@ -64,7 +64,7 @@ abstract contract OneProtoResolver is Helpers, Events { if (address(_sellAddr) == ethAddr) { ethAmt = _sellAmt; } else { - _sellAddr.approve(address(oneProto), _sellAmt); + approve(_sellAddr, address(oneProto), _sellAmt); } uint initalBal = getTokenBal(_buyAddr); diff --git a/contracts/mainnet/connectors/aave/v1/main.sol b/contracts/mainnet/connectors/aave/v1/main.sol index 3dd63cc6..0354c0e8 100644 --- a/contracts/mainnet/connectors/aave/v1/main.sol +++ b/contracts/mainnet/connectors/aave/v1/main.sol @@ -37,7 +37,7 @@ abstract contract AaveResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(aaveProvider.getLendingPoolCore(), _amt); + approve(tokenContract, aaveProvider.getLendingPoolCore(), _amt); } aave.deposit{value: ethAmt}(token, _amt, referralCode); @@ -129,7 +129,7 @@ abstract contract AaveResolver is Events, Helpers { if (token == ethAddr) { ethAmt = _amt; } else { - TokenInterface(token).approve(aaveProvider.getLendingPoolCore(), _amt); + approve(TokenInterface(token), aaveProvider.getLendingPoolCore(), _amt); } aave.repay{value: ethAmt}(token, _amt, payable(address(this))); diff --git a/contracts/mainnet/connectors/aave/v2-amm/main.sol b/contracts/mainnet/connectors/aave/v2-amm/main.sol index 996976a9..4c2f624e 100644 --- a/contracts/mainnet/connectors/aave/v2-amm/main.sol +++ b/contracts/mainnet/connectors/aave/v2-amm/main.sol @@ -42,7 +42,7 @@ abstract contract AaveResolver is Events, Helpers { _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; } - tokenContract.approve(address(aave), _amt); + approve(tokenContract, address(aave), _amt); aave.deposit(_token, _amt, address(this), referralCode); @@ -153,7 +153,7 @@ abstract contract AaveResolver is Events, Helpers { if (isEth) convertEthToWeth(isEth, tokenContract, _amt); - tokenContract.approve(address(aave), _amt); + approve(tokenContract, address(aave), _amt); aave.repay(_token, _amt, rateMode, address(this)); diff --git a/contracts/mainnet/connectors/aave/v2/main.sol b/contracts/mainnet/connectors/aave/v2/main.sol index 7a37ad79..4b9f4656 100644 --- a/contracts/mainnet/connectors/aave/v2/main.sol +++ b/contracts/mainnet/connectors/aave/v2/main.sol @@ -42,7 +42,7 @@ abstract contract AaveResolver is Events, Helpers { _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; } - tokenContract.approve(address(aave), _amt); + approve(tokenContract, address(aave), _amt); aave.deposit(_token, _amt, address(this), referralCode); @@ -153,7 +153,7 @@ abstract contract AaveResolver is Events, Helpers { if (isEth) convertEthToWeth(isEth, tokenContract, _amt); - tokenContract.approve(address(aave), _amt); + approve(tokenContract, address(aave), _amt); aave.repay(_token, _amt, rateMode, address(this)); diff --git a/contracts/mainnet/connectors/compound/main.sol b/contracts/mainnet/connectors/compound/main.sol index fa4a653c..01ee5fc3 100644 --- a/contracts/mainnet/connectors/compound/main.sol +++ b/contracts/mainnet/connectors/compound/main.sol @@ -40,7 +40,7 @@ abstract contract CompoundResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(cToken, _amt); + approve(tokenContract, cToken, _amt); require(CTokenInterface(cToken).mint(_amt) == 0, "deposit-failed"); } setUint(setId, _amt); @@ -196,7 +196,7 @@ abstract contract CompoundResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); require(tokenContract.balanceOf(address(this)) >= _amt, "not-enough-token"); - tokenContract.approve(cToken, _amt); + approve(tokenContract, cToken, _amt); require(cTokenContract.repayBorrow(_amt) == 0, "repay-failed."); } setUint(setId, _amt); @@ -254,7 +254,7 @@ abstract contract CompoundResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(cToken, _amt); + approve(tokenContract, cToken, _amt); require(ctokenContract.mint(_amt) == 0, "deposit-ctoken-failed."); } @@ -385,7 +385,7 @@ abstract contract CompoundResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(tokenToPay); require(tokenContract.balanceOf(address(this)) >= _amt, "not-enough-token"); - tokenContract.approve(cTokenPay, _amt); + approve(tokenContract, cTokenPay, _amt); require(cTokenContract.liquidateBorrow(borrower, _amt, cTokenColl) == 0, "liquidate-failed"); } diff --git a/contracts/mainnet/connectors/cream/main.sol b/contracts/mainnet/connectors/cream/main.sol index 8d3849d4..2852147a 100644 --- a/contracts/mainnet/connectors/cream/main.sol +++ b/contracts/mainnet/connectors/cream/main.sol @@ -40,7 +40,7 @@ abstract contract CreamResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(cToken, _amt); + approve(tokenContract, cToken, _amt); require(CTokenInterface(cToken).mint(_amt) == 0, "deposit-failed"); } setUint(setId, _amt); @@ -196,7 +196,7 @@ abstract contract CreamResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); require(tokenContract.balanceOf(address(this)) >= _amt, "not-enough-token"); - tokenContract.approve(cToken, _amt); + approve(tokenContract, cToken, _amt); require(cTokenContract.repayBorrow(_amt) == 0, "repay-failed."); } setUint(setId, _amt); @@ -254,7 +254,7 @@ abstract contract CreamResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(token); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(cToken, _amt); + approve(tokenContract, cToken, _amt); require(ctokenContract.mint(_amt) == 0, "deposit-ctoken-failed."); } @@ -384,7 +384,7 @@ abstract contract CreamResolver is Events, Helpers { } else { TokenInterface tokenContract = TokenInterface(tokenToPay); require(tokenContract.balanceOf(address(this)) >= _amt, "not-enough-token"); - tokenContract.approve(cTokenPay, _amt); + approve(tokenContract, cTokenPay, _amt); require(cTokenContract.liquidateBorrow(borrower, _amt, cTokenColl) == 0, "liquidate-failed"); } diff --git a/contracts/mainnet/connectors/dydx/main.sol b/contracts/mainnet/connectors/dydx/main.sol index d38588e8..dedad6ac 100644 --- a/contracts/mainnet/connectors/dydx/main.sol +++ b/contracts/mainnet/connectors/dydx/main.sol @@ -36,11 +36,11 @@ abstract contract DyDxResolver is Events, Helpers { TokenInterface tokenContract = TokenInterface(wethAddr); _amt = _amt == uint(-1) ? address(this).balance : _amt; tokenContract.deposit{value: _amt}(); - tokenContract.approve(address(solo), _amt); + approve(tokenContract, address(solo), _amt); } else { TokenInterface tokenContract = TokenInterface(token); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - tokenContract.approve(address(solo), _amt); + approve(tokenContract, address(solo), _amt); } solo.operate(getAccountArgs(), getActionsArgs(_marketId, _amt, true)); @@ -77,7 +77,7 @@ abstract contract DyDxResolver is Events, Helpers { if (token == ethAddr) { TokenInterface tokenContract = TokenInterface(wethAddr); - tokenContract.approve(address(tokenContract), _amt); + approve(tokenContract, address(tokenContract), _amt); tokenContract.withdraw(_amt); } @@ -111,7 +111,7 @@ abstract contract DyDxResolver is Events, Helpers { if (token == ethAddr) { TokenInterface tokenContract = TokenInterface(wethAddr); - tokenContract.approve(address(tokenContract), _amt); + approve(tokenContract, address(tokenContract), _amt); tokenContract.withdraw(_amt); } @@ -148,11 +148,11 @@ abstract contract DyDxResolver is Events, Helpers { TokenInterface tokenContract = TokenInterface(wethAddr); require(address(this).balance >= _amt, "not-enough-eth"); tokenContract.deposit{value: _amt}(); - tokenContract.approve(address(solo), _amt); + approve(tokenContract, address(solo), _amt); } else { TokenInterface tokenContract = TokenInterface(token); require(tokenContract.balanceOf(address(this)) >= _amt, "not-enough-token"); - tokenContract.approve(address(solo), _amt); + approve(tokenContract, address(solo), _amt); } solo.operate(getAccountArgs(), getActionsArgs(_marketId, _amt, true)); diff --git a/contracts/mainnet/connectors/erc20_staking/main.sol b/contracts/mainnet/connectors/erc20_staking/main.sol index 176b21fa..70f83947 100644 --- a/contracts/mainnet/connectors/erc20_staking/main.sol +++ b/contracts/mainnet/connectors/erc20_staking/main.sol @@ -38,7 +38,7 @@ contract Main is Helpers, Events { _amt = _amt == uint(-1) ? stakingToken.balanceOf(address(this)) : _amt; - stakingToken.approve(address(stakingContract), _amt); + approve(stakingToken, address(stakingContract), _amt); stakingContract.stake(_amt); setUint(setId, _amt); diff --git a/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol b/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol index 3c7895bd..77b36687 100644 --- a/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol +++ b/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol @@ -54,12 +54,12 @@ abstract contract UniswapV3Resolver is Events, Helpers { if (depositData.amount0In > 0) { IERC20 _token0 = depositData.poolContract.token0(); convertEthToWeth(address(_token0) == wethAddr, TokenInterface(address(_token0)), depositData.amount0In); - _token0.safeApprove(address(pool), depositData.amount0In); + approve(TokenInterface(address(_token0)), address(pool), depositData.amount0In); } if (depositData.amount1In > 0) { IERC20 _token1 = depositData.poolContract.token1(); convertEthToWeth(address(_token1) == wethAddr, TokenInterface(address(_token1)), depositData.amount1In); - _token1.safeApprove(address(pool), depositData.amount1In); + approve(TokenInterface(address(_token1)), address(pool), depositData.amount1In); } (uint amount0, uint amount1,) = depositData.poolContract.mint(depositData.mintAmount, address(this)); @@ -151,7 +151,7 @@ abstract contract UniswapV3Resolver is Events, Helpers { depositAndSwap.mintAmount; if (address(depositAndSwap._token0) == wethAddr) { - depositAndSwap._token1.approve(address(gUniRouter), amount1In); + approve(depositAndSwap._token1, address(gUniRouter), amount1In); (depositAndSwap.amount0, depositAndSwap.amount1, depositAndSwap.mintAmount) = gUniRouter.rebalanceAndAddLiquidityETH{value: amount0In}( @@ -166,7 +166,7 @@ abstract contract UniswapV3Resolver is Events, Helpers { address(this) ); } else if (address(depositAndSwap._token1) == wethAddr) { - depositAndSwap._token0.approve(address(gUniRouter), amount0In); + approve(depositAndSwap._token0, address(gUniRouter), amount0In); (depositAndSwap.amount0, depositAndSwap.amount1,depositAndSwap. mintAmount) = gUniRouter.rebalanceAndAddLiquidityETH{value: amount1In}( @@ -181,8 +181,8 @@ abstract contract UniswapV3Resolver is Events, Helpers { address(this) ); } else { - depositAndSwap._token0.approve(address(gUniRouter), amount0In); - depositAndSwap._token1.approve(address(gUniRouter), amount1In); + approve(depositAndSwap._token0, address(gUniRouter), amount0In); + approve(depositAndSwap._token1, address(gUniRouter), amount1In); (depositAndSwap.amount0, depositAndSwap.amount1, depositAndSwap.mintAmount) = gUniRouter.rebalanceAndAddLiquidity( depositAndSwap.poolContract, diff --git a/contracts/mainnet/connectors/guniswap_v3_erc20_staking/main.sol b/contracts/mainnet/connectors/guniswap_v3_erc20_staking/main.sol index 4cd4fbcc..47a2d62a 100644 --- a/contracts/mainnet/connectors/guniswap_v3_erc20_staking/main.sol +++ b/contracts/mainnet/connectors/guniswap_v3_erc20_staking/main.sol @@ -35,7 +35,7 @@ contract Main is Helpers, Events { _amt = _amt == uint(-1) ? stakingTokenContract.balanceOf(address(this)) : _amt; - stakingTokenContract.approve(address(stakingContract), _amt); + approve(stakingTokenContract, address(stakingContract), _amt); stakingContract.stake(_amt); setUint(setId, _amt); diff --git a/contracts/mainnet/connectors/kyber/main.sol b/contracts/mainnet/connectors/kyber/main.sol index 8961b851..cdf810a7 100644 --- a/contracts/mainnet/connectors/kyber/main.sol +++ b/contracts/mainnet/connectors/kyber/main.sol @@ -37,7 +37,7 @@ abstract contract KyberResolver is Helpers, Events { } else { TokenInterface sellContract = TokenInterface(sellAddr); _sellAmt = _sellAmt == uint(-1) ? sellContract.balanceOf(address(this)) : _sellAmt; - sellContract.approve(address(kyber), _sellAmt); + approve(sellContract, address(kyber), _sellAmt); } uint _buyAmt = kyber.trade{value: ethAmt}( diff --git a/contracts/mainnet/connectors/makerdao/main.sol b/contracts/mainnet/connectors/makerdao/main.sol index e9240770..ae77595e 100644 --- a/contracts/mainnet/connectors/makerdao/main.sol +++ b/contracts/mainnet/connectors/makerdao/main.sol @@ -96,7 +96,7 @@ abstract contract MakerResolver is Helpers, Events { _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; } - tokenContract.approve(address(colAddr), _amt); + approve(tokenContract, address(colAddr), _amt); tokenJoinContract.join(address(this), _amt); VatLike(managerContract.vat()).frob( @@ -245,7 +245,7 @@ abstract contract MakerResolver is Helpers, Events { require(_maxDebt >= _amt, "paying-excess-debt"); - daiJoinContract.dai().approve(address(daiJoinContract), _amt); + approve(daiJoinContract.dai(), address(daiJoinContract), _amt); daiJoinContract.join(urn, _amt); managerContract.frob( @@ -357,7 +357,7 @@ abstract contract MakerResolver is Helpers, Events { _amtDeposit = _amtDeposit == uint(-1) ? makerData.tokenContract.balanceOf(address(this)) : _amtDeposit; } - makerData.tokenContract.approve(address(makerData.colAddr), _amtDeposit); + approve(makerData.tokenContract, address(makerData.colAddr), _amtDeposit); makerData.tokenJoinContract.join(urn, _amtDeposit); managerContract.frob( @@ -462,7 +462,7 @@ abstract contract MakerResolver is Helpers, Events { VatLike vat = daiJoinContract.vat(); uint chi = potContract.drip(); - daiJoinContract.dai().approve(address(daiJoinContract), _amt); + approve(daiJoinContract.dai(), address(daiJoinContract), _amt); daiJoinContract.join(address(this), _amt); if (vat.can(address(this), address(potContract)) == 0) { vat.hope(address(potContract)); diff --git a/contracts/mainnet/connectors/oasis/main.sol b/contracts/mainnet/connectors/oasis/main.sol index 4761ad65..07393309 100644 --- a/contracts/mainnet/connectors/oasis/main.sol +++ b/contracts/mainnet/connectors/oasis/main.sol @@ -49,7 +49,7 @@ contract OasisResolver is DSMath, Basic, Events { bool isEth = address(_sellAddr) == wethAddr; convertEthToWeth(isEth, _sellAddr, _expectedAmt); - _sellAddr.approve(address(oasis), _expectedAmt); + approve(_sellAddr, address(oasis), _expectedAmt); uint _sellAmt = oasis.buyAllAmount( address(_buyAddr), @@ -104,7 +104,7 @@ contract OasisResolver is DSMath, Basic, Events { bool isEth = address(_sellAddr) == wethAddr; convertEthToWeth(isEth, _sellAddr, _sellAmt); - _sellAddr.approve(address(oasis), _sellAmt); + approve(_sellAddr, address(oasis), _sellAmt); uint _buyAmt = oasis.sellAllAmount( address(_sellAddr), diff --git a/contracts/mainnet/connectors/polygon-bridge/main.sol b/contracts/mainnet/connectors/polygon-bridge/main.sol index 0540f3c0..5c2356e2 100644 --- a/contracts/mainnet/connectors/polygon-bridge/main.sol +++ b/contracts/mainnet/connectors/polygon-bridge/main.sol @@ -36,10 +36,10 @@ abstract contract PolygonBridgeResolver is Events, Helpers { TokenInterface _token = TokenInterface(token); _amt = _amt == uint(-1) ? _token.balanceOf(address(this)) : _amt; if (migrator.rootToChildToken(token) != address(0)) { - _token.approve(erc20Predicate, _amt); + approve(_token, erc20Predicate, _amt); migrator.depositFor(targetDsa, token, abi.encode(_amt)); } else { - _token.approve(address(migratorPlasma), _amt); + approve(_token, address(migratorPlasma), _amt); migratorPlasma.depositERC20ForUser(token, targetDsa, _amt); } } diff --git a/contracts/mainnet/connectors/refinance/helpers/aaveV1.sol b/contracts/mainnet/connectors/refinance/helpers/aaveV1.sol index bc33c624..dc8a3d33 100644 --- a/contracts/mainnet/connectors/refinance/helpers/aaveV1.sol +++ b/contracts/mainnet/connectors/refinance/helpers/aaveV1.sol @@ -102,7 +102,7 @@ contract AaveV1Helpers is protocolHelpers { if (isEth) { ethAmt = _amt; } else { - token.approve(address(aaveCore), _amt); + approve(token, address(aaveCore), _amt); } transferFees(_token, feeAmt); @@ -180,7 +180,7 @@ contract AaveV1Helpers is protocolHelpers { if (isEth) { ethAmt = amt; } else { - token.approve(address(aaveCore), amt); + approve(token, address(aaveCore), amt); } aave.repay{value:ethAmt}(_token, amt, payable(address(this))); diff --git a/contracts/mainnet/connectors/refinance/helpers/aaveV2.sol b/contracts/mainnet/connectors/refinance/helpers/aaveV2.sol index 488deae3..9e8b5f27 100644 --- a/contracts/mainnet/connectors/refinance/helpers/aaveV2.sol +++ b/contracts/mainnet/connectors/refinance/helpers/aaveV2.sol @@ -109,7 +109,7 @@ contract AaveV2Helpers is protocolHelpers { convertEthToWeth(isEth, token, _amt); - token.approve(address(aave), _amt); + approve(token, address(aave), _amt); aave.deposit(address(token), _amt, address(this), getReferralCode); @@ -178,7 +178,7 @@ contract AaveV2Helpers is protocolHelpers { convertEthToWeth(isEth, token, _amt); - token.approve(address(aave), _amt); + approve(token, address(aave), _amt); aave.repay(address(token), _amt, rateMode, address(this)); } diff --git a/contracts/mainnet/connectors/refinance/helpers/compound.sol b/contracts/mainnet/connectors/refinance/helpers/compound.sol index c6bebc42..56e90cc8 100644 --- a/contracts/mainnet/connectors/refinance/helpers/compound.sol +++ b/contracts/mainnet/connectors/refinance/helpers/compound.sol @@ -83,7 +83,7 @@ contract CompoundHelpers is protocolHelpers { (uint feeAmt, uint _amt) = calculateFee(amt, fee, false); if (_token != ethAddr) { - token.approve(address(ctoken), _amt); + approve(token, address(ctoken), _amt); require(ctoken.mint(_amt) == 0, "deposit-failed"); } else { CETHInterface(address(ctoken)).mint{value:_amt}(); @@ -138,7 +138,7 @@ contract CompoundHelpers is protocolHelpers { amt = ctoken.borrowBalanceCurrent(address(this)); } if (address(token) != wethAddr) { - token.approve(address(ctoken), amt); + approve(token, address(ctoken), amt); require(ctoken.repayBorrow(amt) == 0, "repay-failed."); } else { CETHInterface(address(ctoken)).repayBorrow{value:amt}(); diff --git a/contracts/mainnet/connectors/reflexer/main.sol b/contracts/mainnet/connectors/reflexer/main.sol index ffeb6fe3..1a6d47eb 100644 --- a/contracts/mainnet/connectors/reflexer/main.sol +++ b/contracts/mainnet/connectors/reflexer/main.sol @@ -73,7 +73,7 @@ abstract contract GebResolver is Helpers, Events { _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; } - tokenContract.approve(address(colAddr), _amt); + approve(tokenContract, address(colAddr), _amt); tokenJoinContract.join(address(this), _amt); SafeEngineLike(managerContract.safeEngine()).modifySAFECollateralization( @@ -222,7 +222,7 @@ abstract contract GebResolver is Helpers, Events { require(_maxDebt >= _amt, "paying-excess-debt"); - coinJoinContract.systemCoin().approve(address(coinJoinContract), _amt); + approve(coinJoinContract.systemCoin(), address(coinJoinContract), _amt); coinJoinContract.join(handler, _amt); managerContract.modifySAFECollateralization( @@ -335,7 +335,7 @@ abstract contract GebResolver is Helpers, Events { _amtDeposit = _amtDeposit == uint(-1) ? gebData.tokenContract.balanceOf(address(this)) : _amtDeposit; } - gebData.tokenContract.approve(address(gebData.colAddr), _amtDeposit); + approve(gebData.tokenContract, address(gebData.colAddr), _amtDeposit); gebData.tokenJoinContract.join(handler, _amtDeposit); managerContract.modifySAFECollateralization( diff --git a/contracts/mainnet/connectors/uniswap/helpers.sol b/contracts/mainnet/connectors/uniswap/helpers.sol index 10569cd8..f435a78b 100644 --- a/contracts/mainnet/connectors/uniswap/helpers.sol +++ b/contracts/mainnet/connectors/uniswap/helpers.sol @@ -78,8 +78,8 @@ abstract contract Helpers is DSMath, Basic { isEth = address(_tokenB) == wethAddr; convertEthToWeth(isEth, _tokenB, _amtB); - _tokenA.approve(address(router), _amtA); - _tokenB.approve(address(router), _amtB); + approve(_tokenA, address(router), _amtA); + approve(_tokenB, address(router), _amtB); uint minAmtA = getMinAmount(_tokenA, _amtA, slippage); uint minAmtB = getMinAmount(_tokenB, _amtB, slippage); @@ -141,6 +141,6 @@ abstract contract Helpers is DSMath, Basic { TokenInterface uniToken = TokenInterface(exchangeAddr); _uniAmt = _amt == uint(-1) ? uniToken.balanceOf(address(this)) : _amt; - uniToken.approve(address(router), _uniAmt); + approve(uniToken, address(router), _uniAmt); } } \ No newline at end of file diff --git a/contracts/mainnet/connectors/uniswap/main.sol b/contracts/mainnet/connectors/uniswap/main.sol index 68da00f5..18f0140b 100644 --- a/contracts/mainnet/connectors/uniswap/main.sol +++ b/contracts/mainnet/connectors/uniswap/main.sol @@ -114,7 +114,7 @@ abstract contract UniswapResolver is Helpers, Events { bool isEth = address(_sellAddr) == wethAddr; convertEthToWeth(isEth, _sellAddr, _expectedAmt); - _sellAddr.approve(address(router), _expectedAmt); + approve(_sellAddr, address(router), _expectedAmt); uint _sellAmt = router.swapTokensForExactTokens( _buyAmt, @@ -171,7 +171,7 @@ abstract contract UniswapResolver is Helpers, Events { bool isEth = address(_sellAddr) == wethAddr; convertEthToWeth(isEth, _sellAddr, _sellAmt); - _sellAddr.approve(address(router), _sellAmt); + approve(_sellAddr, address(router), _sellAmt); uint _buyAmt = router.swapExactTokensForTokens( _sellAmt, diff --git a/contracts/mainnet/connectors/weth/main.sol b/contracts/mainnet/connectors/weth/main.sol index 9a5f1444..f4d8f056 100644 --- a/contracts/mainnet/connectors/weth/main.sol +++ b/contracts/mainnet/connectors/weth/main.sol @@ -50,7 +50,7 @@ abstract contract Resolver is Events, DSMath, Basic, Helpers { uint _amt = getUint(getId, amt); _amt = _amt == uint(-1) ? wethContract.balanceOf(address(this)) : _amt; - wethContract.approve(wethAddr, _amt); + approve(wethContract, wethAddr, _amt); wethContract.withdraw(_amt); setUint(setId, _amt); diff --git a/contracts/mainnet/connectors_old/1inch.sol b/contracts/mainnet/connectors_old/1inch.sol index fc4b728d..796c909e 100644 --- a/contracts/mainnet/connectors_old/1inch.sol +++ b/contracts/mainnet/connectors_old/1inch.sol @@ -155,7 +155,7 @@ abstract contract OneProtoResolver is OneHelpers { if (address(_sellAddr) == ethAddr) { ethAmt = _sellAmt; } else { - _sellAddr.approve(address(oneProtoContract), _sellAmt); + approve(_sellAddr, address(oneProtoContract), _sellAmt); } @@ -197,7 +197,7 @@ abstract contract OneProtoResolver is OneHelpers { if (address(_sellAddr) == ethAddr) { ethAmt = _sellAmt; } else { - _sellAddr.approve(address(oneSplitContract), _sellAmt); + approve(_sellAddr, address(oneSplitContract), _sellAmt); } uint initalBal = getTokenBal(_buyAddr); @@ -442,7 +442,7 @@ abstract contract OneInchResolverHelpers is OneProtoResolverHelpers { if (address(_sellAddr) == ethAddr) { ethAmt = oneInchData._sellAmt; } else { - TokenInterface(_sellAddr).approve(getOneInchAddress(), oneInchData._sellAmt); + approve(TokenInterface(_sellAddr), getOneInchAddress(), oneInchData._sellAmt); } require(checkOneInchSig(oneInchData.callData), "Not-swap-function"); diff --git a/contracts/polygon/common/basic.sol b/contracts/polygon/common/basic.sol index fea2b1ec..a5c83c7e 100644 --- a/contracts/polygon/common/basic.sol +++ b/contracts/polygon/common/basic.sol @@ -32,13 +32,22 @@ abstract contract Basic is DSMath, Stores { _sell = sell == maticAddr ? TokenInterface(wmaticAddr) : TokenInterface(sell); } + function approve(TokenInterface token, address spender, uint256 amount) internal { + try token.approve(spender, amount) { + + } catch { + token.approve(spender, 0); + token.approve(spender, amount); + } + } + function convertMaticToWmatic(bool isMatic, TokenInterface token, uint amount) internal { if(isMatic) token.deposit{value: amount}(); } function convertWmaticToMatic(bool isMatic, TokenInterface token, uint amount) internal { if(isMatic) { - token.approve(address(token), amount); + approve(token, address(token), amount); token.withdraw(amount); } } diff --git a/contracts/polygon/connectors/aave/v2/main.sol b/contracts/polygon/connectors/aave/v2/main.sol index eddf8855..a76873e0 100644 --- a/contracts/polygon/connectors/aave/v2/main.sol +++ b/contracts/polygon/connectors/aave/v2/main.sol @@ -43,7 +43,7 @@ abstract contract AaveResolver is Events, Helpers { _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; } - tokenContract.approve(address(aave), _amt); + approve(tokenContract, address(aave), _amt); aave.deposit(_token, _amt, address(this), referralCode); @@ -154,7 +154,7 @@ abstract contract AaveResolver is Events, Helpers { if (isEth) convertMaticToWmatic(isEth, tokenContract, _amt); - tokenContract.approve(address(aave), _amt); + approve(tokenContract, address(aave), _amt); aave.repay(_token, _amt, rateMode, address(this)); diff --git a/contracts/polygon/connectors/paraswap/helpers.sol b/contracts/polygon/connectors/paraswap/helpers.sol index 3a54f10f..0f0bc803 100644 --- a/contracts/polygon/connectors/paraswap/helpers.sol +++ b/contracts/polygon/connectors/paraswap/helpers.sol @@ -45,7 +45,7 @@ abstract contract Helpers is DSMath, Basic { maticAmt = swapData._sellAmt; } else { address tokenProxy = AugustusSwapperInterface(paraswap).getTokenTransferProxy(); - TokenInterface(_sellAddr).approve(tokenProxy, swapData._sellAmt); + approve(TokenInterface(_sellAddr), tokenProxy, swapData._sellAmt); } swapData._buyAmt = _swapHelper(swapData, maticAmt); From 217b3d402cee6b8b138bbb8d4459380e7f8dbfe8 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 01:29:19 +0530 Subject: [PATCH 03/14] Reverted change in old connector --- contracts/mainnet/connectors_old/1inch.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/mainnet/connectors_old/1inch.sol b/contracts/mainnet/connectors_old/1inch.sol index 796c909e..fc4b728d 100644 --- a/contracts/mainnet/connectors_old/1inch.sol +++ b/contracts/mainnet/connectors_old/1inch.sol @@ -155,7 +155,7 @@ abstract contract OneProtoResolver is OneHelpers { if (address(_sellAddr) == ethAddr) { ethAmt = _sellAmt; } else { - approve(_sellAddr, address(oneProtoContract), _sellAmt); + _sellAddr.approve(address(oneProtoContract), _sellAmt); } @@ -197,7 +197,7 @@ abstract contract OneProtoResolver is OneHelpers { if (address(_sellAddr) == ethAddr) { ethAmt = _sellAmt; } else { - approve(_sellAddr, address(oneSplitContract), _sellAmt); + _sellAddr.approve(address(oneSplitContract), _sellAmt); } uint initalBal = getTokenBal(_buyAddr); @@ -442,7 +442,7 @@ abstract contract OneInchResolverHelpers is OneProtoResolverHelpers { if (address(_sellAddr) == ethAddr) { ethAmt = oneInchData._sellAmt; } else { - approve(TokenInterface(_sellAddr), getOneInchAddress(), oneInchData._sellAmt); + TokenInterface(_sellAddr).approve(getOneInchAddress(), oneInchData._sellAmt); } require(checkOneInchSig(oneInchData.callData), "Not-swap-function"); From 2d4341a8013d6435cf986cc630b5ce9754e3a574 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 01:31:04 +0530 Subject: [PATCH 04/14] Minor fix --- contracts/mainnet/connectors/guniswap_v3_erc20/main.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol b/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol index 77b36687..f7ee90e7 100644 --- a/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol +++ b/contracts/mainnet/connectors/guniswap_v3_erc20/main.sol @@ -151,7 +151,7 @@ abstract contract UniswapV3Resolver is Events, Helpers { depositAndSwap.mintAmount; if (address(depositAndSwap._token0) == wethAddr) { - approve(depositAndSwap._token1, address(gUniRouter), amount1In); + approve(TokenInterface(address(depositAndSwap._token1)), address(gUniRouter), amount1In); (depositAndSwap.amount0, depositAndSwap.amount1, depositAndSwap.mintAmount) = gUniRouter.rebalanceAndAddLiquidityETH{value: amount0In}( @@ -166,7 +166,7 @@ abstract contract UniswapV3Resolver is Events, Helpers { address(this) ); } else if (address(depositAndSwap._token1) == wethAddr) { - approve(depositAndSwap._token0, address(gUniRouter), amount0In); + approve(TokenInterface(address(depositAndSwap._token0)), address(gUniRouter), amount0In); (depositAndSwap.amount0, depositAndSwap.amount1,depositAndSwap. mintAmount) = gUniRouter.rebalanceAndAddLiquidityETH{value: amount1In}( @@ -181,8 +181,8 @@ abstract contract UniswapV3Resolver is Events, Helpers { address(this) ); } else { - approve(depositAndSwap._token0, address(gUniRouter), amount0In); - approve(depositAndSwap._token1, address(gUniRouter), amount1In); + approve(TokenInterface(address(depositAndSwap._token0)), address(gUniRouter), amount0In); + approve(TokenInterface(address(depositAndSwap._token1)), address(gUniRouter), amount1In); (depositAndSwap.amount0, depositAndSwap.amount1, depositAndSwap.mintAmount) = gUniRouter.rebalanceAndAddLiquidity( depositAndSwap.poolContract, From 8c9866d4e5d87f81bee8e6e2bfbe0a1c6679c87d Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 20:48:51 +0530 Subject: [PATCH 05/14] Minor change --- contracts/mainnet/connectors/1proto/main.sol | 2 +- scripts/deploy.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/mainnet/connectors/1proto/main.sol b/contracts/mainnet/connectors/1proto/main.sol index f3c2f380..d347b629 100644 --- a/contracts/mainnet/connectors/1proto/main.sol +++ b/contracts/mainnet/connectors/1proto/main.sol @@ -2,7 +2,7 @@ pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; /** - * @title 1Proto. + * @title 1Inch(On-chain). * @dev On-chain and off-chian DEX Aggregator. */ diff --git a/scripts/deploy.js b/scripts/deploy.js index 681cd095..e00420c9 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -9,6 +9,7 @@ async function main() { const connectMapping = { '1INCH-A': 'ConnectV2OneInch', + '1INCH-B': 'ConnectV2OneProto', 'AAVE-V1-A': 'ConnectV2AaveV1', 'AAVE-V2-A': 'ConnectV2AaveV2', 'AUTHORITY-A': 'ConnectV2Auth', From c3b327f1a681b98a44f6b710da5dcd97d99783bc Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 20:57:53 +0530 Subject: [PATCH 06/14] Updated 1inch connector --- contracts/mainnet/connectors/1inch/helpers.sol | 9 +++++++-- contracts/mainnet/connectors/1inch/main.sol | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/contracts/mainnet/connectors/1inch/helpers.sol b/contracts/mainnet/connectors/1inch/helpers.sol index 1aa7b6a1..41cc4b0d 100644 --- a/contracts/mainnet/connectors/1inch/helpers.sol +++ b/contracts/mainnet/connectors/1inch/helpers.sol @@ -9,10 +9,15 @@ abstract contract Helpers is DSMath, Basic { /** * @dev 1Inch Address */ - address internal constant oneInchAddr = 0x111111125434b319222CdBf8C261674aDB56F3ae; + address internal constant oneInchAddr = 0x11111112542D85B3EF69AE05771c2dCCff4fAa26; /** * @dev 1inch swap function sig */ - bytes4 internal constant oneInchSig = 0x90411a32; + bytes4 internal constant oneInchSwapSig = 0x7c025200; + + /** + * @dev 1inch swap function sig + */ + bytes4 internal constant oneInchUnoswapSig = 0x2e95b6c8; } \ No newline at end of file diff --git a/contracts/mainnet/connectors/1inch/main.sol b/contracts/mainnet/connectors/1inch/main.sol index cc3b7384..a1c3eec0 100644 --- a/contracts/mainnet/connectors/1inch/main.sol +++ b/contracts/mainnet/connectors/1inch/main.sol @@ -25,7 +25,7 @@ abstract contract OneInchResolver is Helpers, Events { assembly { sig := mload(add(_data, 32)) } - isOk = sig == oneInchSig; + isOk = isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; } /** @@ -124,5 +124,5 @@ abstract contract OneInch is OneInchResolverHelpers { } contract ConnectV2OneInch is OneInch { - string public name = "1Inch-v1"; + string public name = "1Inch-v1.1"; } From 53a725a716e3126aed11326980e176219ca09dff Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 21:00:34 +0530 Subject: [PATCH 07/14] Added polygon 1inch connector --- contracts/polygon/connectors/1inch/events.sol | 12 ++ .../polygon/connectors/1inch/helpers.sol | 23 ++++ .../polygon/connectors/1inch/interface.sol | 30 ++++ contracts/polygon/connectors/1inch/main.sol | 128 ++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 contracts/polygon/connectors/1inch/events.sol create mode 100644 contracts/polygon/connectors/1inch/helpers.sol create mode 100644 contracts/polygon/connectors/1inch/interface.sol create mode 100644 contracts/polygon/connectors/1inch/main.sol diff --git a/contracts/polygon/connectors/1inch/events.sol b/contracts/polygon/connectors/1inch/events.sol new file mode 100644 index 00000000..bec3b27a --- /dev/null +++ b/contracts/polygon/connectors/1inch/events.sol @@ -0,0 +1,12 @@ +pragma solidity ^0.7.0; + +contract Events { + event LogSell( + address indexed buyToken, + address indexed sellToken, + uint256 buyAmt, + uint256 sellAmt, + uint256 getId, + uint256 setId + ); +} \ No newline at end of file diff --git a/contracts/polygon/connectors/1inch/helpers.sol b/contracts/polygon/connectors/1inch/helpers.sol new file mode 100644 index 00000000..41cc4b0d --- /dev/null +++ b/contracts/polygon/connectors/1inch/helpers.sol @@ -0,0 +1,23 @@ +pragma solidity ^0.7.0; + +import { TokenInterface } from "../../common/interfaces.sol"; +import { DSMath } from "../../common/math.sol"; +import { Basic } from "../../common/basic.sol"; + + +abstract contract Helpers is DSMath, Basic { + /** + * @dev 1Inch Address + */ + address internal constant oneInchAddr = 0x11111112542D85B3EF69AE05771c2dCCff4fAa26; + + /** + * @dev 1inch swap function sig + */ + bytes4 internal constant oneInchSwapSig = 0x7c025200; + + /** + * @dev 1inch swap function sig + */ + bytes4 internal constant oneInchUnoswapSig = 0x2e95b6c8; +} \ No newline at end of file diff --git a/contracts/polygon/connectors/1inch/interface.sol b/contracts/polygon/connectors/1inch/interface.sol new file mode 100644 index 00000000..f35b9277 --- /dev/null +++ b/contracts/polygon/connectors/1inch/interface.sol @@ -0,0 +1,30 @@ +pragma solidity ^0.7.0; + +import { TokenInterface } from "../../common/interfaces.sol"; + +interface OneInchInterace { + function swap( + TokenInterface fromToken, + TokenInterface toToken, + uint256 fromTokenAmount, + uint256 minReturnAmount, + uint256 guaranteedAmount, + address payable referrer, + address[] calldata callAddresses, + bytes calldata callDataConcat, + uint256[] calldata starts, + uint256[] calldata gasLimitsAndValues + ) + external + payable + returns (uint256 returnAmount); +} + +struct OneInchData { + TokenInterface sellToken; + TokenInterface buyToken; + uint _sellAmt; + uint _buyAmt; + uint unitAmt; + bytes callData; +} \ No newline at end of file diff --git a/contracts/polygon/connectors/1inch/main.sol b/contracts/polygon/connectors/1inch/main.sol new file mode 100644 index 00000000..1abae97f --- /dev/null +++ b/contracts/polygon/connectors/1inch/main.sol @@ -0,0 +1,128 @@ +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +/** + * @title 1Inch. + * @dev On-chain DEX Aggregator. + */ + +// import files from common directory +import { TokenInterface , MemoryInterface } from "../../common/interfaces.sol"; +import { Stores } from "../../common/stores.sol"; +import { OneInchInterace, OneInchData } from "./interface.sol"; +import { Helpers } from "./helpers.sol"; +import { Events } from "./events.sol"; + +abstract contract OneInchResolver is Helpers, Events { + /** + * @dev 1inch swap uses `.call()`. This function restrict it to call only swap/trade functionality + * @param callData - calldata to extract the first 4 bytes for checking function signature + */ + function checkOneInchSig(bytes memory callData) internal pure returns(bool isOk) { + bytes memory _data = callData; + bytes4 sig; + // solium-disable-next-line security/no-inline-assembly + assembly { + sig := mload(add(_data, 32)) + } + isOk = isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; + } + + /** + * @dev 1inch API swap handler + * @param oneInchData - contains data returned from 1inch API. Struct defined in interfaces.sol + * @param ethAmt - Eth to swap for .value() + */ + function oneInchSwap( + OneInchData memory oneInchData, + uint ethAmt + ) internal returns (uint buyAmt) { + TokenInterface buyToken = oneInchData.buyToken; + (uint _buyDec, uint _sellDec) = getTokensDec(buyToken, oneInchData.sellToken); + uint _sellAmt18 = convertTo18(_sellDec, oneInchData._sellAmt); + uint _slippageAmt = convert18ToDec(_buyDec, wmul(oneInchData.unitAmt, _sellAmt18)); + + uint initalBal = getTokenBal(buyToken); + + // solium-disable-next-line security/no-call-value + (bool success, ) = oneInchAddr.call{value: ethAmt}(oneInchData.callData); + if (!success) revert("1Inch-swap-failed"); + + uint finalBal = getTokenBal(buyToken); + + buyAmt = sub(finalBal, initalBal); + + require(_slippageAmt <= buyAmt, "Too much slippage"); + } + +} + +abstract contract OneInchResolverHelpers is OneInchResolver { + + /** + * @dev Gets the swapping data from 1inch's API. + * @param oneInchData Struct with multiple swap data defined in interfaces.sol + * @param setId Set token amount at this ID in `InstaMemory` Contract. + */ + function _sell( + OneInchData memory oneInchData, + uint setId + ) internal returns (OneInchData memory) { + TokenInterface _sellAddr = oneInchData.sellToken; + + uint ethAmt; + if (address(_sellAddr) == maticAddr) { + ethAmt = oneInchData._sellAmt; + } else { + approve(TokenInterface(_sellAddr), oneInchAddr, oneInchData._sellAmt); + } + + require(checkOneInchSig(oneInchData.callData), "Not-swap-function"); + + oneInchData._buyAmt = oneInchSwap(oneInchData, ethAmt); + setUint(setId, oneInchData._buyAmt); + + return oneInchData; + + // emitLogSellThree(oneInchData, setId); + } +} + +abstract contract OneInch is OneInchResolverHelpers { + /** + * @dev Sell ETH/ERC20_Token using 1Inch. + * @notice Swap tokens from exchanges like kyber, 0x etc, with calculation done off-chain. + * @param buyAddr The address of the token to buy.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) + * @param sellAddr The address of the token to sell.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) + * @param sellAmt The amount of the token to sell. + * @param unitAmt The amount of buyAmt/sellAmt with slippage. + * @param callData Data from 1inch API. + * @param setId ID stores the amount of token brought. + */ + function sell( + address buyAddr, + address sellAddr, + uint sellAmt, + uint unitAmt, + bytes calldata callData, + uint setId + ) external payable returns (string memory _eventName, bytes memory _eventParam) { + OneInchData memory oneInchData = OneInchData({ + buyToken: TokenInterface(buyAddr), + sellToken: TokenInterface(sellAddr), + unitAmt: unitAmt, + callData: callData, + _sellAmt: sellAmt, + _buyAmt: 0 + }); + + oneInchData = _sell(oneInchData, setId); + + _eventName = "LogSell(address,address,uint256,uint256,uint256,uint256)"; + _eventParam = abi.encode(buyAddr, sellAddr, oneInchData._buyAmt, oneInchData._sellAmt, 0, setId); + } +} + +contract ConnectV2OneInchPolygon is OneInch { + string public name = "1Inch-v1"; +} From 5341aeb1b4bec6d18760011609a275f38871986f Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 22:45:54 +0530 Subject: [PATCH 08/14] Updated package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df593366..9cfa0ad1 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@nomiclabs/hardhat-ethers": "^2.0.2", - "@nomiclabs/hardhat-etherscan": "^2.1.2", + "@nomiclabs/hardhat-etherscan": "^2.1.3", "@nomiclabs/hardhat-waffle": "^2.0.1", "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/test-helpers": "^0.5.6", From 17569033568ebfbc365d2762f017a705bc6164a9 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 22:49:14 +0530 Subject: [PATCH 09/14] Updated connector version --- contracts/mainnet/connectors/1inch/main.sol | 2 +- contracts/mainnet/connectors/1proto/main.sol | 2 +- contracts/mainnet/connectors/aave/v1/main.sol | 2 +- contracts/mainnet/connectors/aave/v2/main.sol | 2 +- contracts/mainnet/connectors/compound/main.sol | 2 +- contracts/mainnet/connectors/makerdao/main.sol | 2 +- contracts/mainnet/connectors/uniswap/main.sol | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/mainnet/connectors/1inch/main.sol b/contracts/mainnet/connectors/1inch/main.sol index a1c3eec0..dab1199d 100644 --- a/contracts/mainnet/connectors/1inch/main.sol +++ b/contracts/mainnet/connectors/1inch/main.sol @@ -124,5 +124,5 @@ abstract contract OneInch is OneInchResolverHelpers { } contract ConnectV2OneInch is OneInch { - string public name = "1Inch-v1.1"; + string public name = "1Inch-v1.2"; } diff --git a/contracts/mainnet/connectors/1proto/main.sol b/contracts/mainnet/connectors/1proto/main.sol index d347b629..963e6551 100644 --- a/contracts/mainnet/connectors/1proto/main.sol +++ b/contracts/mainnet/connectors/1proto/main.sol @@ -221,5 +221,5 @@ abstract contract OneProto is OneProtoResolverHelpers { } contract ConnectV2OneProto is OneProto { - string public name = "1proto-v1"; + string public name = "1Proto-v1.1"; } diff --git a/contracts/mainnet/connectors/aave/v1/main.sol b/contracts/mainnet/connectors/aave/v1/main.sol index 0354c0e8..03f900ef 100644 --- a/contracts/mainnet/connectors/aave/v1/main.sol +++ b/contracts/mainnet/connectors/aave/v1/main.sol @@ -166,5 +166,5 @@ abstract contract AaveResolver is Events, Helpers { } contract ConnectV2AaveV1 is AaveResolver { - string constant public name = "AaveV1-v1"; + string constant public name = "AaveV1-v1.1"; } diff --git a/contracts/mainnet/connectors/aave/v2/main.sol b/contracts/mainnet/connectors/aave/v2/main.sol index 4b9f4656..d3f7d01a 100644 --- a/contracts/mainnet/connectors/aave/v2/main.sol +++ b/contracts/mainnet/connectors/aave/v2/main.sol @@ -211,5 +211,5 @@ abstract contract AaveResolver is Events, Helpers { } contract ConnectV2AaveV2 is AaveResolver { - string constant public name = "AaveV2-v1"; + string constant public name = "AaveV2-v1.1"; } diff --git a/contracts/mainnet/connectors/compound/main.sol b/contracts/mainnet/connectors/compound/main.sol index 01ee5fc3..9753b275 100644 --- a/contracts/mainnet/connectors/compound/main.sol +++ b/contracts/mainnet/connectors/compound/main.sol @@ -437,5 +437,5 @@ abstract contract CompoundResolver is Events, Helpers { } contract ConnectV2Compound is CompoundResolver { - string public name = "Compound-v1"; + string public name = "Compound-v1.1"; } diff --git a/contracts/mainnet/connectors/makerdao/main.sol b/contracts/mainnet/connectors/makerdao/main.sol index ae77595e..3afff9b3 100644 --- a/contracts/mainnet/connectors/makerdao/main.sol +++ b/contracts/mainnet/connectors/makerdao/main.sol @@ -519,5 +519,5 @@ abstract contract MakerResolver is Helpers, Events { } contract ConnectV2MakerDAO is MakerResolver { - string public constant name = "MakerDAO-v1.1"; + string public constant name = "MakerDAO-v1.2"; } diff --git a/contracts/mainnet/connectors/uniswap/main.sol b/contracts/mainnet/connectors/uniswap/main.sol index 18f0140b..a8ee9959 100644 --- a/contracts/mainnet/connectors/uniswap/main.sol +++ b/contracts/mainnet/connectors/uniswap/main.sol @@ -192,5 +192,5 @@ abstract contract UniswapResolver is Helpers, Events { } contract ConnectV2UniswapV2 is UniswapResolver { - string public constant name = "UniswapV2-v1"; + string public constant name = "UniswapV2-v1.1"; } From 9b9fb2d7fbc0b3ba2741fa2cb4c57a39b3a61c23 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Fri, 25 Jun 2021 23:57:39 +0530 Subject: [PATCH 10/14] Minor change --- contracts/polygon/connectors/aave/v2/main.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/polygon/connectors/aave/v2/main.sol b/contracts/polygon/connectors/aave/v2/main.sol index a76873e0..5dc8578c 100644 --- a/contracts/polygon/connectors/aave/v2/main.sol +++ b/contracts/polygon/connectors/aave/v2/main.sol @@ -211,6 +211,6 @@ abstract contract AaveResolver is Events, Helpers { } } -contract ConnectV2AaveV2 is AaveResolver { +contract ConnectV2AaveV2Polygon is AaveResolver { string constant public name = "AaveV2-v1"; } From acafed23d013187328b14ea8f04a75a9ffc2099a Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Sat, 26 Jun 2021 00:05:28 +0530 Subject: [PATCH 11/14] Updated connector list --- docs/connectors.json | 15 ++++++++------- hardhat.config.js | 10 ++++++++-- scripts/deploy.js | 9 --------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/connectors.json b/docs/connectors.json index 858ea7bf..755b74da 100644 --- a/docs/connectors.json +++ b/docs/connectors.json @@ -1,14 +1,15 @@ { "1" : { - "1INCH-A": "0x2A6d6d4EE84015F7D64B4d1F66a409bA3f2BAC00", - "1INCH-B": "0x36880391afb430e99d43fe94217446b56d4f2c5b", - "AAVE-V1-A": "0x127d8cD0E2b2E0366D522DeA53A787bfE9002C14", - "AAVE-V2-A": "0x497Bc53507DF17e60F731e9534cff74E8BC9DBb8", "AUTHORITY-A": "0x351Bb32e90C35647Df7a584f3c1a3A0c38F31c68", "BASIC-A": "0x9926955e0Dd681Dc303370C52f4Ad0a4dd061687", + "1INCH-A": "0x235fca310ac7be45c7ad45f111203468743e4b7c", + "1INCH-B": "0xaBac3dCf164eD827EAfda8e05eCc8208D6bc5E04", + "COMPOUND-A": "0xbb153cf09a123746e0eb3b3a436c544a7eeb24b6", + "AAVE-V1-A": "0x612c5CA43230D9F97a0ac87E4420F66b8DF97e9D", + "AAVE-V2-A": "0x68b27A84101ac5120bBAb7Ce8d6b096C961df52C", + "MAKERDAO-A": "0x4049db23c605b197f764072569b8db2464653ef6", + "UNISWAP-V2-A": "0x1E5CE41BdB653734445FeC3553b61FebDdaFC43c", "COMP-A": "0xB446e325D44C52b93eC122Bf76301f235f90B9c9", - "COMPOUND-A": "0x911F4e4e762AeFA6F2Fc1b24e6B1A928200a88a8", - "MAKERDAO-A": "0x29AA7b765008b5dDbD687413B7F0D6E9d349F765", "UNISWAP-A": "0xA4BF319968986D2352FA1c550D781bBFCCE3FcaB", "POLYGON-BRIDGE-A": "0x1b79B302132370B434fb7807b36CB72FB0510aD5", "AAVE-CLAIM-A": "0x611C1FA59Aa1d6352c4C8bD44882063c6aEE85E0", @@ -20,7 +21,7 @@ "INSTAPOOL-A": "0x5806Af7AB22E2916fA582Ff05731Bf7C682387B2", "MAKERDAO-CLAIM-A": "0x2f8cBE650af98602a215b6482F2aD60893C5A4E8", "WETH-A": "0x22075fa719eFb02Ca3cF298AFa9C974B7465E5D3", - "REFINANCE-A": "0x9eA34bE6dA51aa9F6408FeA79c946FDCFA424442" + "REFINANCE-A": "0x9eA34bE6dA51aa9F6408FeA79c946FDCFA424442", "INST-A": "0x52C2C4a0db049255fF345EB9D3Fb1f555b7a924A" }, "137" : { diff --git a/hardhat.config.js b/hardhat.config.js index a3d99c31..79716efc 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -24,7 +24,13 @@ module.exports = { solidity: { compilers: [ { - version: "0.7.6" + version: "0.7.6", + settings: { + optimizer: { + enabled: false, + runs: 200 + } + } }, { version: "0.6.0" @@ -47,7 +53,7 @@ module.exports = { url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`, accounts: [`0x${PRIVATE_KEY}`], timeout: 150000, - gasPrice: parseInt(utils.parseUnits("34", "gwei")) + gasPrice: parseInt(utils.parseUnits("30", "gwei")) }, hardhat: { forking: { diff --git a/scripts/deploy.js b/scripts/deploy.js index e00420c9..26f65d8e 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -28,15 +28,6 @@ async function main() { for (const key in connectMapping) { addressMapping[key] = await deployConnector(connectMapping[key]) } - - const connectorsAbi = [ - "function addConnectors(string[] _connectorNames, address[] _connectors)" - ] - - // Replace the address with correct v2 connectors registry address - const connectorsContract = new ethers.Contract("0x84b457c6D31025d56449D5A01F0c34bF78636f67", connectorsAbi, wallet) - - await connectorsContract.addConnectors(Object.keys(addressMapping), Object.values(addressMapping)) } main() From a22103533b8281034fa939682c55c4537338a255 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Sat, 26 Jun 2021 00:06:08 +0530 Subject: [PATCH 12/14] Minor fix --- contracts/polygon/connectors/1inch/main.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/polygon/connectors/1inch/main.sol b/contracts/polygon/connectors/1inch/main.sol index 1abae97f..38a720c0 100644 --- a/contracts/polygon/connectors/1inch/main.sol +++ b/contracts/polygon/connectors/1inch/main.sol @@ -25,7 +25,7 @@ abstract contract OneInchResolver is Helpers, Events { assembly { sig := mload(add(_data, 32)) } - isOk = isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; + isOk = sig == oneInchSwapSig || sig == oneInchUnoswapSig; } /** From 88604da176211c1fb25ac84ffeaa3e2b45f1e3f5 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Sat, 26 Jun 2021 00:30:19 +0530 Subject: [PATCH 13/14] Updated connector list --- docs/connectors.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/connectors.json b/docs/connectors.json index 858ea7bf..3936bab9 100644 --- a/docs/connectors.json +++ b/docs/connectors.json @@ -24,6 +24,7 @@ "INST-A": "0x52C2C4a0db049255fF345EB9D3Fb1f555b7a924A" }, "137" : { + "1INCH-A": "0xC0d9210496afE9763F5d8cEb8deFfBa817232A9e", "AAVE-V2-A": "0xE84d8010Afc3663919F44685cB53ED88866da3eE", "AUTHORITY-A": "0xf73C94402BC24148b744083eD02654EEc2C37D5B", "BASIC-A": "0x1cAF5EC802ca602E98139AD96A8f2B7BC524264E", From a14f4c6e025b90e26025d1dd8e465d80d9b45ac1 Mon Sep 17 00:00:00 2001 From: Thrilok Kumar Date: Sat, 26 Jun 2021 01:25:34 +0530 Subject: [PATCH 14/14] Updated flashloan code --- .../mainnet/connectors/instapool_v2/main.sol | 92 ++++--------------- .../connectors/instapool_v2/variables.sol | 4 +- 2 files changed, 18 insertions(+), 78 deletions(-) diff --git a/contracts/mainnet/connectors/instapool_v2/main.sol b/contracts/mainnet/connectors/instapool_v2/main.sol index 5e8e75bc..7c436aa0 100644 --- a/contracts/mainnet/connectors/instapool_v2/main.sol +++ b/contracts/mainnet/connectors/instapool_v2/main.sol @@ -3,10 +3,11 @@ pragma experimental ABIEncoderV2; /** * @title Instapool. - * @dev Flash Loan in DSA. + * @dev Inbuilt Flash Loan in DSA */ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; +import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { TokenInterface } from "../../common/interfaces.sol"; import { AccountInterface } from "./interfaces.sol"; @@ -20,10 +21,8 @@ contract LiquidityResolver is DSMath, Stores, Variables, Events { /** * @dev Borrow Flashloan and Cast spells. - * @notice Borrows flashloan and cast the spells. * @param token Token Address. * @param amt Token Amount. - * @param route Route to borrow. * @param data targets & data for cast. */ function flashBorrowAndCast( @@ -31,25 +30,20 @@ contract LiquidityResolver is DSMath, Stores, Variables, Events { uint amt, uint route, bytes memory data - ) external payable returns (string memory _eventName, bytes memory _eventParam) { + ) external payable { AccountInterface(address(this)).enable(address(instaPool)); + (string[] memory _targets, bytes[] memory callDatas) = abi.decode(data, (string[], bytes[])); - address[] memory tokens = new address[](1); - uint[] memory amts = new uint[](1); - tokens[0] = token; - amts[0] = amt; + bytes memory callData = abi.encodeWithSignature("cast(string[],bytes[],address)", _targets, callDatas, address(instaPool)); - instaPool.initiateFlashLoan(tokens, amts, route, data); + instaPool.initiateFlashLoan(token, amt, route, callData); + emit LogFlashBorrow(token, amt); AccountInterface(address(this)).disable(address(instaPool)); - - _eventName = "LogFlashBorrow(address,uint256)"; - _eventParam = abi.encode(token, amt); } /** * @dev Return token to InstaPool. - * @notice Payback borrowed flashloan. * @param token Token Address. * @param amt Token Amount. * @param getId Get token amount at this ID from `InstaMemory` Contract. @@ -60,78 +54,24 @@ contract LiquidityResolver is DSMath, Stores, Variables, Events { uint amt, uint getId, uint setId - ) external payable returns (string memory _eventName, bytes memory _eventParam) { + ) external payable { uint _amt = getUint(getId, amt); IERC20 tokenContract = IERC20(token); - tokenContract.safeTransfer(address(instaPool), _amt); + if (token == ethAddr) { + Address.sendValue(payable(address(instaPool)), _amt); + } else { + tokenContract.safeTransfer(address(instaPool), _amt); + } + setUint(setId, _amt); - _eventName = "LogFlashPayback(address,uint256)"; - _eventParam = abi.encode(token, _amt); - } - - /** - * @dev Borrow Flashloan and Cast spells. - * @notice Borrows multiple flashloan tokens and cast the spells. - * @param tokens Array of token Addresses. - * @param amts Array of token Amounts. - * @param route Route to borrow. - * @param data targets & data for cast. - */ - function flashMultiBorrowAndCast( - address[] calldata tokens, - uint[] calldata amts, - uint route, - bytes calldata data - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - AccountInterface(address(this)).enable(address(instaPool)); - - instaPool.initiateFlashLoan(tokens, amts, route, data); - - AccountInterface(address(this)).disable(address(instaPool)); - - _eventName = "LogFlashMultiBorrow(address[],uint256[])"; - _eventParam = abi.encode(tokens, amts); - } - - /** - * @dev Return Multiple token liquidity to InstaPool. - * @notice Payback borrowed multiple flashloan tokens. - * @param tokens Array of token addresses. - * @param amts Array of token amounts. - * @param getId get token amounts at this IDs from `InstaMemory` Contract. - * @param setId set token amounts at this IDs in `InstaMemory` Contract. - */ - function flashMultiPayback( - address[] calldata tokens, - uint[] calldata amts, - uint[] calldata getId, - uint[] calldata setId - ) external payable returns (string memory _eventName, bytes memory _eventParam) { - uint _length = tokens.length; - - uint[] memory _amts = new uint[](_length); - - for (uint i = 0; i < _length; i++) { - uint _amt = getUint(getId[i], amts[i]); - - _amts[i] = _amt; - - IERC20 tokenContract = IERC20(tokens[i]); - - tokenContract.safeTransfer(address(instaPool), _amt); - - setUint(setId[i], _amt); - } - - _eventName = "LogFlashMultiPayback(address[],uint256[])"; - _eventParam = abi.encode(tokens, _amts); + emit LogFlashPayback(token, _amt); } } contract ConnectV2InstaPool is LiquidityResolver { - string public name = "Instapool-v1"; + string public name = "Instapool-v1.1"; } \ No newline at end of file diff --git a/contracts/mainnet/connectors/instapool_v2/variables.sol b/contracts/mainnet/connectors/instapool_v2/variables.sol index a6d80231..47dcc9f7 100644 --- a/contracts/mainnet/connectors/instapool_v2/variables.sol +++ b/contracts/mainnet/connectors/instapool_v2/variables.sol @@ -6,7 +6,7 @@ import { InstaFlashV2Interface } from "./interfaces.sol"; contract Variables { /** - * @dev Instapool / Receiver contract proxy + * @dev Instapool contract proxy */ - InstaFlashV2Interface public constant instaPool = InstaFlashV2Interface(0x691d4172331a11912c6D0e6D1A002E3d7CED6a66); + InstaFlashV2Interface public constant instaPool = InstaFlashV2Interface(0x2a1739D7F07d40e76852Ca8f0D82275Aa087992F); } \ No newline at end of file