From 81a50e969dc5730c89b3e0fcce34db42b2851e68 Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Mon, 23 Aug 2021 23:35:06 +0200 Subject: [PATCH 1/7] Add new Yearn vault connector --- .../mainnet/connectors/yearn_v2/events.sol | 6 + .../mainnet/connectors/yearn_v2/interface.sol | 8 + .../mainnet/connectors/yearn_v2/main.sol | 74 +++++++++ hardhat.config.js | 4 +- test/yearn/yearn.test.js | 142 ++++++++++++++++++ 5 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 contracts/mainnet/connectors/yearn_v2/events.sol create mode 100644 contracts/mainnet/connectors/yearn_v2/interface.sol create mode 100644 contracts/mainnet/connectors/yearn_v2/main.sol create mode 100644 test/yearn/yearn.test.js diff --git a/contracts/mainnet/connectors/yearn_v2/events.sol b/contracts/mainnet/connectors/yearn_v2/events.sol new file mode 100644 index 00000000..d1a140eb --- /dev/null +++ b/contracts/mainnet/connectors/yearn_v2/events.sol @@ -0,0 +1,6 @@ +pragma solidity ^0.7.0; + +contract Events { + event LogDeposit(address indexed vault, uint256 amt, uint256 getId, uint256 setId); + event LogWithdraw(address indexed recipient, uint256 amt, uint256 getId, uint256 setId); +} \ No newline at end of file diff --git a/contracts/mainnet/connectors/yearn_v2/interface.sol b/contracts/mainnet/connectors/yearn_v2/interface.sol new file mode 100644 index 00000000..265b5569 --- /dev/null +++ b/contracts/mainnet/connectors/yearn_v2/interface.sol @@ -0,0 +1,8 @@ +pragma solidity ^0.7.0; + +interface YearnV2Interface { + function deposit(uint256 amount, address recipient) external returns (uint256); + function withdraw(uint256 maxShares, address recipient) external returns (uint256); + function token() external view returns (address); +} + diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol new file mode 100644 index 00000000..92f54f28 --- /dev/null +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -0,0 +1,74 @@ +pragma solidity ^0.7.0; + +/** + * @title Yearn V2. + * @dev Vaults & yield. + */ + +import { TokenInterface } from "../../common/interfaces.sol"; +import { Basic } from "../../common/basic.sol"; +import { Events } from "./events.sol"; +import { YearnV2Interface } from "./interface.sol"; + +abstract contract YearnResolver is Events, Basic { + /** + * @dev Deposit funds in the vault, issuing shares to recipient. + * @param vault The address of the vault to deposit funds into. + * @param amt The amount of tokens to deposit. + * @param getId ID to retrieve amtA. + * @param setId ID stores the amount of shares received. + */ + function deposit( + address vault, + uint256 amt, + uint256 getId, + uint256 setId + ) external returns (string memory _eventName, bytes memory _eventParam) { + uint _amt = getUint(getId, amt); + + YearnV2Interface yearn = YearnV2Interface(vault); + + address want = yearn.token(); + + TokenInterface tokenContract = TokenInterface(want); + + _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; + approve(tokenContract, vault, _amt); + + uint256 _shares = yearn.deposit(_amt, address(this)); + setUint(setId, _shares); + + _eventName = "LogDeposit(address, uint256, uint256, uint256)"; + _eventParam = abi.encode(vault, _amt, getId, setId); + } + + /** + * @dev Withdraw shares from the vault. + * @param vault The address of the vault to withdraw shares from. + * @param amt The amount of shares to withdraw. + * @param getId ID to retrieve amtA. + * @param setId ID stores the amount want token redeemed. + */ + function withdraw( + address vault, + uint256 amt, + uint256 getId, + uint256 setId + ) external returns (string memory _eventName, bytes memory _eventParam) { + uint _amt = getUint(getId, amt); + + YearnV2Interface yearn = YearnV2Interface(vault); + TokenInterface tokenContract = TokenInterface(vault); + + _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; + uint256 _wantRedeemed = yearn.withdraw(_amt, address(this)); + setUint(setId, _wantRedeemed); + + _eventName = "LogWithdraw(address, uint256, uint256, uint256)"; + _eventParam = abi.encode(vault, _amt, getId, setId); + } +} + +contract ConnectV2YearnV2 is YearnResolver { + string public constant name = "YearnV2-v1.0"; +} diff --git a/hardhat.config.js b/hardhat.config.js index 86ed948b..9e142bae 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -57,7 +57,7 @@ module.exports = { hardhat: { forking: { url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`, - blockNumber: 12696000, + blockNumber: 12796965, }, blockGasLimit: 12000000, }, @@ -78,4 +78,4 @@ module.exports = { mocha: { timeout: 100 * 1000, }, -}; +}; \ No newline at end of file diff --git a/test/yearn/yearn.test.js b/test/yearn/yearn.test.js new file mode 100644 index 00000000..409161b0 --- /dev/null +++ b/test/yearn/yearn.test.js @@ -0,0 +1,142 @@ +const { expect } = require("chai"); +const hre = require("hardhat"); +const { waffle, ethers } = hre; +const { provider } = waffle + +const deployAndEnableConnector = require("../../scripts/deployAndEnableConnector.js") +const buildDSAv2 = require("../../scripts/buildDSAv2") +const encodeSpells = require("../../scripts/encodeSpells.js") +const getMasterSigner = require("../../scripts/getMasterSigner") + +const tokens = require("../../scripts/constant/tokens"); +const addresses = require("../../scripts/constant/addresses"); +const abis = require("../../scripts/constant/abis"); +const connectV2YearnArtifacts = require("../../artifacts/contracts/mainnet/connectors/yearn_v2/main.sol/ConnectV2YearnV2.json") + +const toBytes32 = (bn) => { + return ethers.utils.hexlify(ethers.utils.zeroPad(bn.toHexString(), 32)); +}; +const setStorageAt = async (address, index, value) => { + await ethers.provider.send("hardhat_setStorageAt", [address, index, value]); + await ethers.provider.send("evm_mine", []); // Just mines to the next block +}; + +describe("Yearn", function () { + const connectorName = "YEARN-TEST-A" + + let dsaWallet0 + let masterSigner; + let instaConnectorsV2; + let connector; + + const wallets = provider.getWallets() + const [wallet0, wallet1, wallet2, wallet3] = wallets + before(async () => { + masterSigner = await getMasterSigner(wallet3) + instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); + connector = await deployAndEnableConnector({ + connectorName, + contractArtifact: connectV2YearnArtifacts, + signer: masterSigner, + connectors: instaConnectorsV2 + }) + console.log("Connector address", connector.address) + }) + + it("Should have contracts deployed.", async function () { + expect(!!instaConnectorsV2.address).to.be.true; + expect(!!connector.address).to.be.true; + expect(!!masterSigner.address).to.be.true; + }); + + describe("DSA wallet setup", function () { + it("Should build DSA v2", async function () { + dsaWallet0 = await buildDSAv2(wallet0.address) + expect(!!dsaWallet0.address).to.be.true; + }); + + it("Deposit ETH into DSA wallet", async function () { + await wallet0.sendTransaction({ + to: dsaWallet0.address, + value: ethers.utils.parseEther("10") + }); + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); + }); + }); + + describe("Main", function () { + + it("Should increase the DAI balance to 100 DAI", async function () { + const DAI = new ethers.Contract(tokens.dai.address, abis.basic.erc20, ethers.provider); + const DAI_SLOT = 2; + const locallyManipulatedBalance = ethers.utils.parseEther("100"); + + // Get storage slot index + const index = ethers.utils.solidityKeccak256( + ["uint256", "uint256"], + [dsaWallet0.address, DAI_SLOT] + ); + // Manipulate local balance (needs to be bytes32 string) + await setStorageAt( + tokens.dai.address, + index.toString(), + toBytes32(locallyManipulatedBalance).toString() + ); + + // Get DAI balance + const balance = await DAI.balanceOf(dsaWallet0.address); + expect(await ethers.BigNumber.from(balance).eq(ethers.utils.parseEther("100"))); + }); + + it("Should deposit and withdraw 50 DAI in/out the Yearn Vault", async function () { + const DAI = new ethers.Contract(tokens.dai.address, abis.basic.erc20, ethers.provider); + const DAI_VAULT = '0xdA816459F1AB5631232FE5e97a05BBBb94970c95'; + const amount = ethers.utils.parseEther("50") // 50 DAI + const setId = "132456"; + const spells = [ + { + connector: connectorName, + method: "deposit", + args: [DAI_VAULT, amount, 0, setId] + }, + { + connector: connectorName, + method: "withdraw", + args: [DAI_VAULT, amount, setId, 0] + } + ] + + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0.address); + await tx.wait(); + + // Get DAI balance + const balance = await DAI.balanceOf(dsaWallet0.address); + expect(await ethers.BigNumber.from(balance).eq(ethers.utils.parseEther("100"))); + }); + + it("Should deposit 70 DAI in the Yearn Vault", async function () { + const DAI_VAULT = '0xdA816459F1AB5631232FE5e97a05BBBb94970c95'; + const DAI = new ethers.Contract(tokens.dai.address, abis.basic.erc20, ethers.provider); + const YVDAI = new ethers.Contract(DAI_VAULT, abis.basic.erc20, ethers.provider); + const amount = ethers.utils.parseEther("70") // 70 DAI + const setId = "568445"; + const spells = [ + { + connector: connectorName, + method: "deposit", + args: [DAI_VAULT, amount, 0, setId] + } + ] + + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet0.address); + await tx.wait(); + + // Get DAI balance + const yvDAIBalance = await YVDAI.balanceOf(dsaWallet0.address); + const daiBalance = await DAI.balanceOf(dsaWallet0.address); + const correctDaiBalance = await ethers.BigNumber.from(daiBalance).eq(ethers.utils.parseEther("30")); + const correctYVDaiBalance = await ethers.BigNumber.from(yvDAIBalance).lte(ethers.utils.parseEther("70")); + expect(correctDaiBalance && correctYVDaiBalance); + }); + }) +}) From e50bb11bd4199071d4ce9d9e5f2ae44d251a7de1 Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Mon, 23 Aug 2021 23:35:31 +0200 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9C=A8=20Fixing=20doc=20issues=20&=20pay?= =?UTF-8?q?able?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/mainnet/connectors/yearn_v2/main.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol index 92f54f28..a28a1c59 100644 --- a/contracts/mainnet/connectors/yearn_v2/main.sol +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -13,6 +13,7 @@ import { YearnV2Interface } from "./interface.sol"; abstract contract YearnResolver is Events, Basic { /** * @dev Deposit funds in the vault, issuing shares to recipient. + * @notice This will deposit funds to a specific Yearn Vault. * @param vault The address of the vault to deposit funds into. * @param amt The amount of tokens to deposit. * @param getId ID to retrieve amtA. @@ -23,11 +24,11 @@ abstract contract YearnResolver is Events, Basic { uint256 amt, uint256 getId, uint256 setId - ) external returns (string memory _eventName, bytes memory _eventParam) { + ) external payable returns (string memory _eventName, bytes memory _eventParam) { uint _amt = getUint(getId, amt); YearnV2Interface yearn = YearnV2Interface(vault); - + address want = yearn.token(); TokenInterface tokenContract = TokenInterface(want); @@ -44,6 +45,7 @@ abstract contract YearnResolver is Events, Basic { /** * @dev Withdraw shares from the vault. + * @notice This will withdraw the share from a specific Yearn Vault. * @param vault The address of the vault to withdraw shares from. * @param amt The amount of shares to withdraw. * @param getId ID to retrieve amtA. @@ -54,7 +56,7 @@ abstract contract YearnResolver is Events, Basic { uint256 amt, uint256 getId, uint256 setId - ) external returns (string memory _eventName, bytes memory _eventParam) { + ) external payable returns (string memory _eventName, bytes memory _eventParam) { uint _amt = getUint(getId, amt); YearnV2Interface yearn = YearnV2Interface(vault); From 04f6bebefdb82f633d3be6d6ffb4bd3771d094e6 Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Thu, 2 Sep 2021 10:00:55 +0200 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=91=A5=20Update=20for=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/mainnet/connectors/yearn_v2/events.sol | 4 ++-- contracts/mainnet/connectors/yearn_v2/main.sol | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/mainnet/connectors/yearn_v2/events.sol b/contracts/mainnet/connectors/yearn_v2/events.sol index d1a140eb..f289044b 100644 --- a/contracts/mainnet/connectors/yearn_v2/events.sol +++ b/contracts/mainnet/connectors/yearn_v2/events.sol @@ -1,6 +1,6 @@ pragma solidity ^0.7.0; contract Events { - event LogDeposit(address indexed vault, uint256 amt, uint256 getId, uint256 setId); - event LogWithdraw(address indexed recipient, uint256 amt, uint256 getId, uint256 setId); + event LogDeposit(address indexed vault, uint256 shareAmt, uint256 depositAmt, uint256 getId, uint256 setId); + event LogWithdraw(address indexed recipient, uint256 shareAmt, uint256 withdrawAmt, uint256 getId, uint256 setId); } \ No newline at end of file diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol index a28a1c59..748d20b6 100644 --- a/contracts/mainnet/connectors/yearn_v2/main.sol +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -16,7 +16,7 @@ abstract contract YearnResolver is Events, Basic { * @notice This will deposit funds to a specific Yearn Vault. * @param vault The address of the vault to deposit funds into. * @param amt The amount of tokens to deposit. - * @param getId ID to retrieve amtA. + * @param getId ID to retrieve amt. * @param setId ID stores the amount of shares received. */ function deposit( @@ -39,8 +39,8 @@ abstract contract YearnResolver is Events, Basic { uint256 _shares = yearn.deposit(_amt, address(this)); setUint(setId, _shares); - _eventName = "LogDeposit(address, uint256, uint256, uint256)"; - _eventParam = abi.encode(vault, _amt, getId, setId); + _eventName = "LogDeposit(address,uint256,uint256,uint256,uint256)"; + _eventParam = abi.encode(vault, _shares, _amt, getId, setId); } /** @@ -48,7 +48,7 @@ abstract contract YearnResolver is Events, Basic { * @notice This will withdraw the share from a specific Yearn Vault. * @param vault The address of the vault to withdraw shares from. * @param amt The amount of shares to withdraw. - * @param getId ID to retrieve amtA. + * @param getId ID to retrieve amt. * @param setId ID stores the amount want token redeemed. */ function withdraw( @@ -66,8 +66,8 @@ abstract contract YearnResolver is Events, Basic { uint256 _wantRedeemed = yearn.withdraw(_amt, address(this)); setUint(setId, _wantRedeemed); - _eventName = "LogWithdraw(address, uint256, uint256, uint256)"; - _eventParam = abi.encode(vault, _amt, getId, setId); + _eventName = "LogWithdraw(address,uint256,uint256,uint256,uint256)"; + _eventParam = abi.encode(vault, _amt, _wantRedeemed, getId, setId); } } From 90b0a62f4707476066bd9b70961db88f3892998b Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Tue, 7 Sep 2021 10:04:51 +0200 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=91=B7=20Review=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainnet/connectors/yearn_v2/interface.sol | 4 ++++ .../mainnet/connectors/yearn_v2/main.sol | 24 +++++++++++++++---- test/yearn/yearn.test.js | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/contracts/mainnet/connectors/yearn_v2/interface.sol b/contracts/mainnet/connectors/yearn_v2/interface.sol index 265b5569..b72e6181 100644 --- a/contracts/mainnet/connectors/yearn_v2/interface.sol +++ b/contracts/mainnet/connectors/yearn_v2/interface.sol @@ -2,7 +2,11 @@ pragma solidity ^0.7.0; interface YearnV2Interface { function deposit(uint256 amount, address recipient) external returns (uint256); + function withdraw(uint256 maxShares, address recipient) external returns (uint256); + function token() external view returns (address); + + function balanceOf(address owner) external view returns (uint256); } diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol index 748d20b6..d5f34517 100644 --- a/contracts/mainnet/connectors/yearn_v2/main.sol +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -14,12 +14,14 @@ abstract contract YearnResolver is Events, Basic { /** * @dev Deposit funds in the vault, issuing shares to recipient. * @notice This will deposit funds to a specific Yearn Vault. + * @param token The address of the token to deposit. * @param vault The address of the vault to deposit funds into. * @param amt The amount of tokens to deposit. * @param getId ID to retrieve amt. * @param setId ID stores the amount of shares received. */ function deposit( + address token, address vault, uint256 amt, uint256 getId, @@ -29,11 +31,19 @@ abstract contract YearnResolver is Events, Basic { YearnV2Interface yearn = YearnV2Interface(vault); + bool isEth = token == ethAddr; address want = yearn.token(); TokenInterface tokenContract = TokenInterface(want); - _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; + if (isEth && want == wethAddr) { + _amt = _amt == uint(-1) ? address(this).balance : _amt; + convertEthToWeth(isEth, tokenContract, _amt); + } else { + require(want == token, "incorrect token"); + _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; + } + approve(tokenContract, vault, _amt); uint256 _shares = yearn.deposit(_amt, address(this)); @@ -59,13 +69,17 @@ abstract contract YearnResolver is Events, Basic { ) external payable returns (string memory _eventName, bytes memory _eventParam) { uint _amt = getUint(getId, amt); - YearnV2Interface yearn = YearnV2Interface(vault); - TokenInterface tokenContract = TokenInterface(vault); + YearnV2Interface vault = YearnV2Interface(vault); - _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; - uint256 _wantRedeemed = yearn.withdraw(_amt, address(this)); + + _amt = _amt == uint(-1) ? vault.balanceOf(address(this)) : _amt; + uint256 _wantRedeemed = vault.withdraw(_amt, address(this)); setUint(setId, _wantRedeemed); + TokenInterface tokenContract = TokenInterface(vault.token()); + bool isWEth = vault.token() == wethAddr; + convertWethToEth(isWEth, tokenContract, _amt); + _eventName = "LogWithdraw(address,uint256,uint256,uint256,uint256)"; _eventParam = abi.encode(vault, _amt, _wantRedeemed, getId, setId); } diff --git a/test/yearn/yearn.test.js b/test/yearn/yearn.test.js index 409161b0..3df70948 100644 --- a/test/yearn/yearn.test.js +++ b/test/yearn/yearn.test.js @@ -97,7 +97,7 @@ describe("Yearn", function () { { connector: connectorName, method: "deposit", - args: [DAI_VAULT, amount, 0, setId] + args: [tokens.dai.address, DAI_VAULT, amount, 0, setId] }, { connector: connectorName, @@ -124,7 +124,7 @@ describe("Yearn", function () { { connector: connectorName, method: "deposit", - args: [DAI_VAULT, amount, 0, setId] + args: [tokens.dai.address, DAI_VAULT, amount, 0, setId] } ] From bc80d780eceb16c3ce84d4beb4897dc699c4135a Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Tue, 7 Sep 2021 13:31:24 +0200 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=91=B7=20Update=20after=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/mainnet/connectors/yearn_v2/main.sol | 8 ++------ test/yearn/yearn.test.js | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol index d5f34517..e1d8343d 100644 --- a/contracts/mainnet/connectors/yearn_v2/main.sol +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -14,14 +14,12 @@ abstract contract YearnResolver is Events, Basic { /** * @dev Deposit funds in the vault, issuing shares to recipient. * @notice This will deposit funds to a specific Yearn Vault. - * @param token The address of the token to deposit. * @param vault The address of the vault to deposit funds into. * @param amt The amount of tokens to deposit. * @param getId ID to retrieve amt. * @param setId ID stores the amount of shares received. */ function deposit( - address token, address vault, uint256 amt, uint256 getId, @@ -31,16 +29,14 @@ abstract contract YearnResolver is Events, Basic { YearnV2Interface yearn = YearnV2Interface(vault); - bool isEth = token == ethAddr; address want = yearn.token(); - + bool isEth = want == ethAddr; TokenInterface tokenContract = TokenInterface(want); - if (isEth && want == wethAddr) { + if (isEth) { _amt = _amt == uint(-1) ? address(this).balance : _amt; convertEthToWeth(isEth, tokenContract, _amt); } else { - require(want == token, "incorrect token"); _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; } diff --git a/test/yearn/yearn.test.js b/test/yearn/yearn.test.js index 3df70948..409161b0 100644 --- a/test/yearn/yearn.test.js +++ b/test/yearn/yearn.test.js @@ -97,7 +97,7 @@ describe("Yearn", function () { { connector: connectorName, method: "deposit", - args: [tokens.dai.address, DAI_VAULT, amount, 0, setId] + args: [DAI_VAULT, amount, 0, setId] }, { connector: connectorName, @@ -124,7 +124,7 @@ describe("Yearn", function () { { connector: connectorName, method: "deposit", - args: [tokens.dai.address, DAI_VAULT, amount, 0, setId] + args: [DAI_VAULT, amount, 0, setId] } ] From 605bcc9dcf391253823e546ae5489ac16680ec22 Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Tue, 7 Sep 2021 13:34:01 +0200 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=90=9B=20Fixing=20issue=20with=20weth?= =?UTF-8?q?Addr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/mainnet/connectors/yearn_v2/main.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol index e1d8343d..74d3d567 100644 --- a/contracts/mainnet/connectors/yearn_v2/main.sol +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -30,7 +30,7 @@ abstract contract YearnResolver is Events, Basic { YearnV2Interface yearn = YearnV2Interface(vault); address want = yearn.token(); - bool isEth = want == ethAddr; + bool isEth = want == wethAddr; TokenInterface tokenContract = TokenInterface(want); if (isEth) { From d738ec4627cab2e704f8bd93192c0a9bb09e949e Mon Sep 17 00:00:00 2001 From: Thomas Bouder Date: Tue, 7 Sep 2021 13:34:54 +0200 Subject: [PATCH 7/7] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Rename=20variable=20is?= =?UTF-8?q?Eth=20to=20iswEth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/mainnet/connectors/yearn_v2/main.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/mainnet/connectors/yearn_v2/main.sol b/contracts/mainnet/connectors/yearn_v2/main.sol index 74d3d567..c8a238f3 100644 --- a/contracts/mainnet/connectors/yearn_v2/main.sol +++ b/contracts/mainnet/connectors/yearn_v2/main.sol @@ -30,12 +30,12 @@ abstract contract YearnResolver is Events, Basic { YearnV2Interface yearn = YearnV2Interface(vault); address want = yearn.token(); - bool isEth = want == wethAddr; + bool iswETH = want == wethAddr; TokenInterface tokenContract = TokenInterface(want); - if (isEth) { + if (iswETH) { _amt = _amt == uint(-1) ? address(this).balance : _amt; - convertEthToWeth(isEth, tokenContract, _amt); + convertEthToWeth(iswETH, tokenContract, _amt); } else { _amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt; }