diff --git a/hardhat.config.js b/hardhat.config.js index 896a5e96..7a07b081 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -27,7 +27,7 @@ module.exports = { version: "0.7.6", settings: { optimizer: { - enabled: false, + enabled: true, runs: 200, }, }, @@ -63,10 +63,9 @@ module.exports = { hardhat: { forking: { url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_ID}`, - blockNumber: 12796965, + blockNumber: 12696000, }, blockGasLimit: 12000000, - gasPrice: parseInt(utils.parseUnits("300", "gwei")) }, matic: { url: "https://rpc-mainnet.maticvigil.com/", diff --git a/test/aave/v1.test.js b/test/aave/v1.test.js index aea2a222..970ef3e8 100644 --- a/test/aave/v1.test.js +++ b/test/aave/v1.test.js @@ -13,6 +13,8 @@ const constants = require("../../scripts/constant/constant"); const addLiquidity = require("../../scripts/addLiquidity"); const { ethers } = hre; +const ALCHEMY_ID = process.env.ALCHEMY_ID; + describe("Aave V1", function() { const connectorName = "AAVEV1-TEST-A"; @@ -23,19 +25,34 @@ describe("Aave V1", function() { let masterSigner; before(async () => { - [wallet0, wallet1] = await ethers.getSigners(); - masterSigner = await getMasterSigner(); - instaConnectorsV2 = await ethers.getContractAt( - abis.core.connectorsV2, - addresses.core.connectorsV2 - ); - connector = await deployAndEnableConnector({ - connectorName, - contractArtifact: ConnectV2AaveV1, - signer: masterSigner, - connectors: instaConnectorsV2, - }); - console.log("Connector address", connector.address); + try { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12796965, + }, + }, + ], + }); + [wallet0, wallet1] = await ethers.getSigners(); + masterSigner = await getMasterSigner(); + instaConnectorsV2 = await ethers.getContractAt( + abis.core.connectorsV2, + addresses.core.connectorsV2 + ); + connector = await deployAndEnableConnector({ + connectorName, + contractArtifact: ConnectV2AaveV1, + signer: masterSigner, + connectors: instaConnectorsV2, + }); + console.log("Connector address", connector.address); + } catch (err) { + console.log("error", err); + } }); it("should have contracts deployed", async () => { diff --git a/test/aave/v2.test.js b/test/aave/v2.test.js index 09b023e6..67aac908 100644 --- a/test/aave/v2.test.js +++ b/test/aave/v2.test.js @@ -23,6 +23,17 @@ describe("Aave V2", function() { let masterSigner; before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12796965, + }, + }, + ], + }); [wallet0, wallet1] = await ethers.getSigners(); masterSigner = await getMasterSigner(); instaConnectorsV2 = await ethers.getContractAt( diff --git a/test/b.protocol/b.compound.test.js b/test/b.protocol/b.compound.test.js index 5d08235d..582a01ca 100644 --- a/test/b.protocol/b.compound.test.js +++ b/test/b.protocol/b.compound.test.js @@ -13,7 +13,7 @@ const abis = require("../../scripts/constant/abis"); const constants = require("../../scripts/constant/constant"); const tokens = require("../../scripts/constant/tokens"); -const connectV2CompoundArtifacts = require("../../artifacts/contracts/mainnet/connectors/b.protocol/compound/main.sol/ConnectV1BCompound.json") +const connectV2CompoundArtifacts = require("../../artifacts/contracts/mainnet/connectors/b.protocol/compound/main.sol/ConnectV2BCompound.json") describe("B.Compound", function () { const connectorName = "B.COMPOUND-TEST-A" @@ -26,6 +26,17 @@ describe("B.Compound", function () { const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); masterSigner = await getMasterSigner(wallet3) instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); connector = await deployAndEnableConnector({ diff --git a/test/b.protocol/b.liquity.test.js b/test/b.protocol/b.liquity.test.js index 8a180345..c50f111c 100644 --- a/test/b.protocol/b.liquity.test.js +++ b/test/b.protocol/b.liquity.test.js @@ -20,43 +20,54 @@ const LUSD_WHALE = "0x66017D22b0f8556afDd19FC67041899Eb65a21bb" // stability poo const BAMM_ADDRESS = "0x0d3AbAA7E088C2c82f54B2f47613DA438ea8C598" describe("B.Liquity", function () { - const connectorName = "B.LIQUITY-TEST-A" - - let dsaWallet0; - let dsaWallet1; - let masterSigner; - let instaConnectorsV2; - let connector; - let manager; - let vat; - let lusd; - let bammToken; - let stabilityPool; - - 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: connectorLiquityArtifacts, - signer: masterSigner, - connectors: instaConnectorsV2 - }) + const connectorName = "B.LIQUITY-TEST-A" - lusd = await ethers.getContractAt("../artifacts/contracts/mainnet/common/interfaces.sol:TokenInterface", "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0") - bammToken = await ethers.getContractAt("../artifacts/contracts/mainnet/connectors/b.protocol/liquity/interface.sol:BAMMLike", BAMM_ADDRESS) - stabilityPool = await ethers.getContractAt("../artifacts/contracts/mainnet/connectors/b.protocol/liquity/interface.sol:StabilityPoolLike", "0x66017D22b0f8556afDd19FC67041899Eb65a21bb") + let dsaWallet0; + let dsaWallet1; + let masterSigner; + let instaConnectorsV2; + let connector; + let manager; + let vat; + let lusd; + let bammToken; + let stabilityPool; - console.log("Connector address", connector.address) + const wallets = provider.getWallets() + const [wallet0, wallet1, wallet2, wallet3] = wallets + before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12996875, + }, + }, + ], + }); + masterSigner = await getMasterSigner(wallet3) + instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); + connector = await deployAndEnableConnector({ + connectorName, + contractArtifact: connectorLiquityArtifacts, + signer: masterSigner, + connectors: instaConnectorsV2 + }) + + lusd = await ethers.getContractAt("../artifacts/contracts/mainnet/common/interfaces.sol:TokenInterface", "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0") + bammToken = await ethers.getContractAt("../artifacts/contracts/mainnet/connectors/b.protocol/liquity/interface.sol:BAMMLike", BAMM_ADDRESS) + stabilityPool = await ethers.getContractAt("../artifacts/contracts/mainnet/connectors/b.protocol/liquity/interface.sol:StabilityPoolLike", "0x66017D22b0f8556afDd19FC67041899Eb65a21bb") + + console.log("Connector address", connector.address) }) it("test veryClose.", async function () { expect(veryClose(1000001, 1000000)).to.be.true - expect(veryClose(1000000, 1000001)).to.be.true + expect(veryClose(1000000, 1000001)).to.be.true expect(veryClose(1003000, 1000001)).to.be.false - expect(veryClose(1000001, 1000300)).to.be.false + expect(veryClose(1000001, 1000300)).to.be.false }); it("Should have contracts deployed.", async function () { @@ -68,44 +79,44 @@ describe("B.Liquity", function () { describe("DSA wallet setup", function () { it("Should build DSA v2", async function () { - dsaWallet0 = await buildDSAv2(wallet0.address) - expect(!!dsaWallet0.address).to.be.true; + dsaWallet0 = await buildDSAv2(wallet0.address) + expect(!!dsaWallet0.address).to.be.true; - dsaWallet1 = await buildDSAv2(wallet1.address) - expect(!!dsaWallet1.address).to.be.true; + dsaWallet1 = await buildDSAv2(wallet1.address) + expect(!!dsaWallet1.address).to.be.true; }); it("Deposit LUSD into DSA wallet", async function () { - await hre.network.provider.request({ - method: "hardhat_impersonateAccount", - params: [LUSD_WHALE], - }); + await hre.network.provider.request({ + method: "hardhat_impersonateAccount", + params: [LUSD_WHALE], + }); - const signer = await hre.ethers.provider.getSigner(LUSD_WHALE); - await lusd.connect(signer).transfer(dsaWallet0.address, ethers.utils.parseEther("100000")) + const signer = await hre.ethers.provider.getSigner(LUSD_WHALE); + await lusd.connect(signer).transfer(dsaWallet0.address, ethers.utils.parseEther("100000")) - expect(await lusd.balanceOf(dsaWallet0.address)).to.equal(ethers.utils.parseEther("100000")); + expect(await lusd.balanceOf(dsaWallet0.address)).to.equal(ethers.utils.parseEther("100000")); }); }); describe("Main", function () { it("should deposit 10k LUSD", async function () { - const totalSupplyBefore = await bammToken.totalSupply(); - const lusdBalanceBefore = await stabilityPool.getCompoundedLUSDDeposit(BAMM_ADDRESS); - const amount = ethers.utils.parseEther("10000"); - const spells = [ - { - connector: connectorName, - method: "deposit", - args: [amount, 0, 0, 0] - } - ] + const totalSupplyBefore = await bammToken.totalSupply(); + const lusdBalanceBefore = await stabilityPool.getCompoundedLUSDDeposit(BAMM_ADDRESS); + const amount = ethers.utils.parseEther("10000"); + const spells = [ + { + connector: connectorName, + method: "deposit", + args: [amount, 0, 0, 0] + } + ] - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - const expectedBalance = totalSupplyBefore.mul(amount).div(lusdBalanceBefore) - expect(veryClose(expectedBalance, await bammToken.balanceOf(dsaWallet0.address))).to.be.true + const expectedBalance = totalSupplyBefore.mul(amount).div(lusdBalanceBefore) + expect(veryClose(expectedBalance, await bammToken.balanceOf(dsaWallet0.address))).to.be.true }); it("should deposit all LUSD", async function () { @@ -115,11 +126,11 @@ describe("B.Liquity", function () { const balanceBefore = await bammToken.balanceOf(dsaWallet0.address) const spells = [ - { - connector: connectorName, - method: "deposit", - args: [amount, 0, 0, 0] - } + { + connector: connectorName, + method: "deposit", + args: [amount, 0, 0, 0] + } ] const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) @@ -128,54 +139,54 @@ describe("B.Liquity", function () { const expectedBalance = (totalSupplyBefore.mul(ethers.utils.parseEther("90000")).div(lusdBalanceBefore)).add(balanceBefore) expect(veryClose(expectedBalance, await bammToken.balanceOf(dsaWallet0.address))).to.be.true }); - + it("should withdraw half of the shares", async function () { const balanceBefore = await bammToken.balanceOf(dsaWallet0.address) const halfBalance = balanceBefore.div("2") const spells = [ - { - connector: connectorName, - method: "withdraw", - args: [halfBalance, 0, 0, 0] - } + { + connector: connectorName, + method: "withdraw", + args: [halfBalance, 0, 0, 0] + } ] const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) const receipt = await tx.wait() expect(veryClose(halfBalance, await bammToken.balanceOf(dsaWallet0.address))).to.be.true - expect(veryClose(ethers.utils.parseEther("50000"), await lusd.balanceOf(dsaWallet0.address))).to.be.true + expect(veryClose(ethers.utils.parseEther("50000"), await lusd.balanceOf(dsaWallet0.address))).to.be.true }); it("should withdraw all the shares", async function () { const amount = web3.utils.toBN("2").pow(web3.utils.toBN("256")).sub(web3.utils.toBN("1")); const spells = [ - { - connector: connectorName, - method: "withdraw", - args: [amount, 0, 0, 0] - } + { + connector: connectorName, + method: "withdraw", + args: [amount, 0, 0, 0] + } ] const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) const receipt = await tx.wait() - expect(veryClose(ethers.utils.parseEther("100000"), await lusd.balanceOf(dsaWallet0.address))).to.be.true - }); + expect(veryClose(ethers.utils.parseEther("100000"), await lusd.balanceOf(dsaWallet0.address))).to.be.true + }); }) }) function veryClose(n1, n2) { - n1 = web3.utils.toBN(n1) - n2 = web3.utils.toBN(n2) + n1 = web3.utils.toBN(n1) + n2 = web3.utils.toBN(n2) - _10000 = web3.utils.toBN(10000) - _9999 = web3.utils.toBN(9999) + _10000 = web3.utils.toBN(10000) + _9999 = web3.utils.toBN(9999) - if(n1.mul(_10000).lt(n2.mul(_9999))) return false - if(n2.mul(_10000).lt(n1.mul(_9999))) return false + if (n1.mul(_10000).lt(n2.mul(_9999))) return false + if (n2.mul(_10000).lt(n1.mul(_9999))) return false - return true + return true } diff --git a/test/b.protocol/b.maker.test.js b/test/b.protocol/b.maker.test.js index 57b687cd..5cc97daa 100644 --- a/test/b.protocol/b.maker.test.js +++ b/test/b.protocol/b.maker.test.js @@ -13,23 +13,34 @@ const abis = require("../../scripts/constant/abis"); const constants = require("../../scripts/constant/constant"); const tokens = require("../../scripts/constant/tokens"); -const connectorMakerArtifacts = require("../../artifacts/contracts/mainnet/connectors/b.protocol/makerdao/main.sol/ConnectV1BMakerDAO.json") +const connectorMakerArtifacts = require("../../artifacts/contracts/mainnet/connectors/b.protocol/makerdao/main.sol/ConnectV2BMakerDAO.json") describe("B.Maker", function () { const connectorName = "B.MAKER-TEST-A" - + let dsaWallet0; - let dsaWallet1; + let dsaWallet1; let masterSigner; let instaConnectorsV2; let connector; let manager; let vat; let dai; - + const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12696000, + }, + }, + ], + }); masterSigner = await getMasterSigner(wallet3) instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); connector = await deployAndEnableConnector({ @@ -44,263 +55,263 @@ describe("B.Maker", function () { dai = await ethers.getContractAt("../artifacts/contracts/mainnet/common/interfaces.sol:TokenInterface", tokens.dai.address) console.log("Connector address", connector.address) - }) + }) - it("test veryClose.", async function () { - expect(veryClose(1000001, 1000000)).to.be.true - expect(veryClose(1000000, 1000001)).to.be.true - expect(veryClose(1003000, 1000001)).to.be.false - expect(veryClose(1000001, 1000300)).to.be.false - }); - - 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; - expect(await connector.name()).to.be.equal("B.MakerDAO-v1.0"); - }); - - describe("DSA wallet setup", function () { - it("Should build DSA v2", async function () { - dsaWallet0 = await buildDSAv2(wallet0.address) - expect(!!dsaWallet0.address).to.be.true; - - dsaWallet1 = await buildDSAv2(wallet1.address) - expect(!!dsaWallet1.address).to.be.true; + it("test veryClose.", async function () { + expect(veryClose(1000001, 1000000)).to.be.true + expect(veryClose(1000000, 1000001)).to.be.true + expect(veryClose(1003000, 1000001)).to.be.false + expect(veryClose(1000001, 1000300)).to.be.false }); - it("Deposit ETH into DSA wallet", async function () { - await wallet0.sendTransaction({ - to: dsaWallet0.address, - value: ethers.utils.parseEther("10") + 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; + expect(await connector.name()).to.be.equal("B.MakerDAO-v1.0"); + }); + + describe("DSA wallet setup", function () { + it("Should build DSA v2", async function () { + dsaWallet0 = await buildDSAv2(wallet0.address) + expect(!!dsaWallet0.address).to.be.true; + + dsaWallet1 = await buildDSAv2(wallet1.address) + expect(!!dsaWallet1.address).to.be.true; }); - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); - await wallet1.sendTransaction({ - to: dsaWallet1.address, - value: ethers.utils.parseEther("10") + 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")); + + await wallet1.sendTransaction({ + to: dsaWallet1.address, + value: ethers.utils.parseEther("10") + }); + expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("10")); }); - expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("10")); - }); - }); - - describe("Main", function () { - let vault - let ilk - let urn - - it("Should open ETH-A vault Maker", async function () { - vault = Number(await manager.cdpi()) + 1 - const spells = [ - { - connector: connectorName, - method: "open", - args: ["ETH-A"] - } - ] - - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() - - expect(await manager.owns(vault)).to.be.equal(dsaWallet0.address) - - ilk = await manager.ilks(vault) - expect(ilk).to.be.equal("0x4554482d41000000000000000000000000000000000000000000000000000000") - - urn = await manager.urns(vault) }); - it("Should deposit", async function () { - const amount = ethers.utils.parseEther("7") // 7 ETH - const setId = "83478237" + describe("Main", function () { + let vault + let ilk + let urn - const spells = [ - { - connector: connectorName, - method: "deposit", - args: [vault, amount, 0, setId] - } - ] + it("Should open ETH-A vault Maker", async function () { + vault = Number(await manager.cdpi()) + 1 + const spells = [ + { + connector: connectorName, + method: "open", + args: ["ETH-A"] + } + ] - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("3")) + expect(await manager.owns(vault)).to.be.equal(dsaWallet0.address) - const urnData = await vat.urns(ilk, urn) - expect(urnData[0]).to.be.equal(amount) // ink - expect(urnData[1]).to.be.equal("0") // art + ilk = await manager.ilks(vault) + expect(ilk).to.be.equal("0x4554482d41000000000000000000000000000000000000000000000000000000") - }); + urn = await manager.urns(vault) + }); - it("Should withdraw", async function () { - const amount = ethers.utils.parseEther("1") // 1 ETH - const setId = "83478237" + it("Should deposit", async function () { + const amount = ethers.utils.parseEther("7") // 7 ETH + const setId = "83478237" - const spells = [ - { - connector: connectorName, - method: "withdraw", - args: [vault, amount, 0, setId] - } - ] + const spells = [ + { + connector: connectorName, + method: "deposit", + args: [vault, amount, 0, setId] + } + ] - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("4")) + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("3")) - const urnData = await vat.urns(ilk, urn) - expect(urnData[0]).to.be.equal(ethers.utils.parseEther("6")) // ink - expect(urnData[1]).to.be.equal("0") // art + const urnData = await vat.urns(ilk, urn) + expect(urnData[0]).to.be.equal(amount) // ink + expect(urnData[1]).to.be.equal("0") // art - }); + }); - it("Should borrow", async function () { - const amount = ethers.utils.parseEther("6000") // 6000 dai - const setId = "83478237" + it("Should withdraw", async function () { + const amount = ethers.utils.parseEther("1") // 1 ETH + const setId = "83478237" - const spells = [ - { - connector: connectorName, - method: "borrow", - args: [vault, amount, 0, setId] - } - ] + const spells = [ + { + connector: connectorName, + method: "withdraw", + args: [vault, amount, 0, setId] + } + ] - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - const urnData = await vat.urns(ilk, urn) - expect(urnData[0]).to.be.equal(ethers.utils.parseEther("6")) // ink - expect(urnData[1]).to.be.equal(await daiToArt(vat, ilk, amount)) // art - - expect(await dai.balanceOf(dsaWallet0.address)).to.be.equal(amount) - }); + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("4")) - it("Should repay", async function () { - const amount = ethers.utils.parseEther("500") // 500 dai - const setId = "83478237" + const urnData = await vat.urns(ilk, urn) + expect(urnData[0]).to.be.equal(ethers.utils.parseEther("6")) // ink + expect(urnData[1]).to.be.equal("0") // art - const spells = [ - { - connector: connectorName, - method: "payback", - args: [vault, amount, 0, setId] - } - ] + }); - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() + it("Should borrow", async function () { + const amount = ethers.utils.parseEther("6000") // 6000 dai + const setId = "83478237" - const urnData = await vat.urns(ilk, urn) - expect(urnData[0]).to.be.equal(ethers.utils.parseEther("6")) // ink - expect(urnData[1]).to.be.equal(await daiToArt(vat, ilk, ethers.utils.parseEther("5500"))) // art - expect(await dai.balanceOf(dsaWallet0.address)).to.be.equal(ethers.utils.parseEther("5500")) - }); + const spells = [ + { + connector: connectorName, + method: "borrow", + args: [vault, amount, 0, setId] + } + ] - it("Should depositAndBorrow", async function () { - const borrowAmount = ethers.utils.parseEther("1000") // 1000 dai - const depositAmount = ethers.utils.parseEther("1") // 1 dai - - const setId = "83478237" + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - const spells = [ - { - connector: connectorName, - method: "depositAndBorrow", - args: [vault, depositAmount, borrowAmount, 0, 0, 0, 0] - } - ] + const urnData = await vat.urns(ilk, urn) + expect(urnData[0]).to.be.equal(ethers.utils.parseEther("6")) // ink + expect(urnData[1]).to.be.equal(await daiToArt(vat, ilk, amount)) // art - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() + expect(await dai.balanceOf(dsaWallet0.address)).to.be.equal(amount) + }); - const urnData = await vat.urns(ilk, urn) - expect(urnData[0]).to.be.equal(ethers.utils.parseEther("7")) // ink - expect(await dai.balanceOf(dsaWallet0.address)).to.be.equal(ethers.utils.parseEther("6500")) - // calculation is not precise as the jug was dripped - expect(veryClose(urnData[1], await daiToArt(vat, ilk, ethers.utils.parseEther("6500")))).to.be.true - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("1")) - }); + it("Should repay", async function () { + const amount = ethers.utils.parseEther("500") // 500 dai + const setId = "83478237" - it("Should close", async function () { - // open a new vault - const newVault = vault + 1 - let spells = [ - { - connector: connectorName, - method: "open", - args: ["ETH-A"] - } - ] + const spells = [ + { + connector: connectorName, + method: "payback", + args: [vault, amount, 0, setId] + } + ] - let tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) - let receipt = await tx.wait() - - expect(await manager.owns(newVault)).to.be.equal(dsaWallet1.address) + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - ilk = await manager.ilks(newVault) - expect(ilk).to.be.equal("0x4554482d41000000000000000000000000000000000000000000000000000000") + const urnData = await vat.urns(ilk, urn) + expect(urnData[0]).to.be.equal(ethers.utils.parseEther("6")) // ink + expect(urnData[1]).to.be.equal(await daiToArt(vat, ilk, ethers.utils.parseEther("5500"))) // art + expect(await dai.balanceOf(dsaWallet0.address)).to.be.equal(ethers.utils.parseEther("5500")) + }); - urn = await manager.urns(newVault) + it("Should depositAndBorrow", async function () { + const borrowAmount = ethers.utils.parseEther("1000") // 1000 dai + const depositAmount = ethers.utils.parseEther("1") // 1 dai - // deposit and borrow - const borrowAmount = ethers.utils.parseEther("6000") // 6000 dai - const depositAmount = ethers.utils.parseEther("5") // 5 ETH - - spells = [ - { - connector: connectorName, - method: "depositAndBorrow", - args: [newVault, depositAmount, borrowAmount, 0, 0, 0, 0] - } - ] + const setId = "83478237" - tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) - receipt = await tx.wait() + const spells = [ + { + connector: connectorName, + method: "depositAndBorrow", + args: [vault, depositAmount, borrowAmount, 0, 0, 0, 0] + } + ] - const setId = 0 + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() - // repay borrow - spells = [ - { - connector: connectorName, - method: "payback", - args: [newVault, borrowAmount, 0, setId] - } - ] + const urnData = await vat.urns(ilk, urn) + expect(urnData[0]).to.be.equal(ethers.utils.parseEther("7")) // ink + expect(await dai.balanceOf(dsaWallet0.address)).to.be.equal(ethers.utils.parseEther("6500")) + // calculation is not precise as the jug was dripped + expect(veryClose(urnData[1], await daiToArt(vat, ilk, ethers.utils.parseEther("6500")))).to.be.true + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("1")) + }); - tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) - receipt = await tx.wait() + it("Should close", async function () { + // open a new vault + const newVault = vault + 1 + let spells = [ + { + connector: connectorName, + method: "open", + args: ["ETH-A"] + } + ] - // withdraw deposit - spells = [ - { - connector: connectorName, - method: "withdraw", - args: [newVault, depositAmount, 0, setId] - } - ] + let tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) + let receipt = await tx.wait() - tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) - receipt = await tx.wait() + expect(await manager.owns(newVault)).to.be.equal(dsaWallet1.address) - // close - spells = [ - { - connector: connectorName, - method: "close", - args: [newVault] - } - ] + ilk = await manager.ilks(newVault) + expect(ilk).to.be.equal("0x4554482d41000000000000000000000000000000000000000000000000000000") - tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) - receipt = await tx.wait() + urn = await manager.urns(newVault) - expect(await manager.owns(newVault)).not.to.be.equal(dsaWallet1.address) - }); - }) + // deposit and borrow + const borrowAmount = ethers.utils.parseEther("6000") // 6000 dai + const depositAmount = ethers.utils.parseEther("5") // 5 ETH + + spells = [ + { + connector: connectorName, + method: "depositAndBorrow", + args: [newVault, depositAmount, borrowAmount, 0, 0, 0, 0] + } + ] + + tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) + receipt = await tx.wait() + + const setId = 0 + + // repay borrow + spells = [ + { + connector: connectorName, + method: "payback", + args: [newVault, borrowAmount, 0, setId] + } + ] + + tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) + receipt = await tx.wait() + + // withdraw deposit + spells = [ + { + connector: connectorName, + method: "withdraw", + args: [newVault, depositAmount, 0, setId] + } + ] + + tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) + receipt = await tx.wait() + + // close + spells = [ + { + connector: connectorName, + method: "close", + args: [newVault] + } + ] + + tx = await dsaWallet1.connect(wallet1).cast(...encodeSpells(spells), wallet1.address) + receipt = await tx.wait() + + expect(await manager.owns(newVault)).not.to.be.equal(dsaWallet1.address) + }); + }) }) async function daiToArt(vat, ilk, dai) { @@ -317,10 +328,10 @@ function veryClose(n1, n2) { n2 = web3.utils.toBN(n2) _10000 = web3.utils.toBN(10000) - _9999 = web3.utils.toBN(9999) + _9999 = web3.utils.toBN(9999) - if(n1.mul(_10000).lt(n2.mul(_9999))) return false - if(n2.mul(_10000).lt(n1.mul(_9999))) return false + if (n1.mul(_10000).lt(n2.mul(_9999))) return false + if (n2.mul(_10000).lt(n1.mul(_9999))) return false return true } diff --git a/test/basic-ERC1155/ERC1155-transfer.js b/test/basic-ERC1155/ERC1155-transfer.js index cd2f2b12..a0835384 100644 --- a/test/basic-ERC1155/ERC1155-transfer.js +++ b/test/basic-ERC1155/ERC1155-transfer.js @@ -2,7 +2,7 @@ const { expect } = require("chai"); const hre = require("hardhat"); const { web3, deployments, waffle, ethers } = hre; const { provider, deployContract } = waffle -const {abi: implementationsABI} = require("../../scripts/constant/abi/core/InstaImplementations.json") +const { abi: implementationsABI } = require("../../scripts/constant/abi/core/InstaImplementations.json") const deployAndEnableConnector = require("../../scripts/deployAndEnableConnector.js") const buildDSAv2 = require("../../scripts/buildDSAv2") @@ -38,6 +38,17 @@ describe("BASIC-ERC1155", function () { const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); await hre.network.provider.request({ method: "hardhat_impersonateAccount", params: [TOKEN_OWNER_ADDR], diff --git a/test/basic-ERC721/ERC721-transfer.js b/test/basic-ERC721/ERC721-transfer.js index 01a5de0b..73dce8ca 100644 --- a/test/basic-ERC721/ERC721-transfer.js +++ b/test/basic-ERC721/ERC721-transfer.js @@ -2,7 +2,7 @@ const { expect } = require("chai"); const hre = require("hardhat"); const { web3, deployments, waffle, ethers } = hre; const { provider, deployContract } = waffle -const {abi: implementationsABI} = require("../../scripts/constant/abi/core/InstaImplementations.json") +const { abi: implementationsABI } = require("../../scripts/constant/abi/core/InstaImplementations.json") const deployAndEnableConnector = require("../../scripts/deployAndEnableConnector.js") const buildDSAv2 = require("../../scripts/buildDSAv2") @@ -38,6 +38,17 @@ describe("BASIC-ERC721", function () { const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); await hre.network.provider.request({ method: "hardhat_impersonateAccount", params: [TOKEN_OWNER_ADDR], diff --git a/test/compound/compound.test.js b/test/compound/compound.test.js index d1c77475..0719eb94 100644 --- a/test/compound/compound.test.js +++ b/test/compound/compound.test.js @@ -17,15 +17,26 @@ const connectV2CompoundArtifacts = require("../../artifacts/contracts/mainnet/co describe("Compound", function () { const connectorName = "COMPOUND-TEST-A" - + let dsaWallet0 let masterSigner; let instaConnectorsV2; let connector; - + const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); masterSigner = await getMasterSigner(wallet3) instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); connector = await deployAndEnableConnector({ @@ -35,93 +46,93 @@ describe("Compound", function () { 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("Should have contracts deployed.", async function () { + expect(!!instaConnectorsV2.address).to.be.true; + expect(!!connector.address).to.be.true; + expect(!!masterSigner.address).to.be.true; }); - it("Deposit ETH into DSA wallet", async function () { - await wallet0.sendTransaction({ - to: dsaWallet0.address, - value: ethers.utils.parseEther("10") + describe("DSA wallet setup", function () { + it("Should build DSA v2", async function () { + dsaWallet0 = await buildDSAv2(wallet0.address) + expect(!!dsaWallet0.address).to.be.true; }); - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); - }); - }); - describe("Main", function () { - - it("Should deposit ETH in Compound", async function () { - const amount = ethers.utils.parseEther("1") // 1 ETH - const spells = [ - { - connector: connectorName, - method: "deposit", - args: ["ETH-A", amount, 0, 0] - } - ] - - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9")); + 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")); + }); }); - it("Should borrow and payback DAI from Compound", async function () { - const amount = ethers.utils.parseEther("100") // 100 DAI - const setId = "83478237" - const spells = [ - { - connector: connectorName, - method: "borrow", - args: ["DAI-A", amount, 0, setId] - }, - { - connector: connectorName, - method: "payback", - args: ["DAI-A", 0, setId, 0] - } - ] + describe("Main", function () { - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9")); - }); + it("Should deposit ETH in Compound", async function () { + const amount = ethers.utils.parseEther("1") // 1 ETH + const spells = [ + { + connector: connectorName, + method: "deposit", + args: ["ETH-A", amount, 0, 0] + } + ] - it("Should deposit all ETH in Compound", async function () { - const spells = [ - { - connector: connectorName, - method: "deposit", - args: ["ETH-A", constants.max_value, 0, 0] - } - ] + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9")); + }); - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("0")); - }); + it("Should borrow and payback DAI from Compound", async function () { + const amount = ethers.utils.parseEther("100") // 100 DAI + const setId = "83478237" + const spells = [ + { + connector: connectorName, + method: "borrow", + args: ["DAI-A", amount, 0, setId] + }, + { + connector: connectorName, + method: "payback", + args: ["DAI-A", 0, setId, 0] + } + ] - it("Should withdraw all ETH from Compound", async function () { - const spells = [ - { - connector: connectorName, - method: "withdraw", - args: ["ETH-A", constants.max_value, 0, 0] - } - ] + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("9")); + }); - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) - const receipt = await tx.wait() - expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); - }); - }) + it("Should deposit all ETH in Compound", async function () { + const spells = [ + { + connector: connectorName, + method: "deposit", + args: ["ETH-A", constants.max_value, 0, 0] + } + ] + + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("0")); + }); + + it("Should withdraw all ETH from Compound", async function () { + const spells = [ + { + connector: connectorName, + method: "withdraw", + args: ["ETH-A", constants.max_value, 0, 0] + } + ] + + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address) + const receipt = await tx.wait() + expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("10")); + }); + }) }) diff --git a/test/instapool/instapool.test.js b/test/instapool/instapool.test.js index fa211e8d..cbae67c2 100644 --- a/test/instapool/instapool.test.js +++ b/test/instapool/instapool.test.js @@ -17,25 +17,36 @@ const tokens = require("../../scripts/constant/tokens"); const connectV2CompoundArtifacts = require("../../artifacts/contracts/mainnet/connectors/compound/main.sol/ConnectV2Compound.json") describe("Instapool", function () { - const connectorName = "COMPOUND-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: connectV2CompoundArtifacts, - signer: masterSigner, - connectors: instaConnectorsV2 - }) - console.log("Connector address", connector.address) + const connectorName = "COMPOUND-TEST-A" + + let dsaWallet0 + let masterSigner; + let instaConnectorsV2; + let connector; + + const wallets = provider.getWallets() + const [wallet0, wallet1, wallet2, wallet3] = wallets + before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); + masterSigner = await getMasterSigner(wallet3) + instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); + connector = await deployAndEnableConnector({ + connectorName, + contractArtifact: connectV2CompoundArtifacts, + signer: masterSigner, + connectors: instaConnectorsV2 + }) + console.log("Connector address", connector.address) }) it("Should have contracts deployed.", async function () { @@ -46,64 +57,64 @@ describe("Instapool", function () { describe("DSA wallet setup", function () { it("Should build DSA v2", async function () { - dsaWallet0 = await buildDSAv2(wallet0.address) - expect(!!dsaWallet0.address).to.be.true; + 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")); + 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 take 100 ETH flashloan from Instapool", async function () { - const amount = ethers.utils.parseEther("1") // 1 ETH - const flashloanAmount = ethers.utils.parseEther("100") // 100 ETH - const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + const amount = ethers.utils.parseEther("1") // 1 ETH + const flashloanAmount = ethers.utils.parseEther("100") // 100 ETH + const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - const IdOne = "2878734423" - const IdTwo = "783243246" + const IdOne = "2878734423" + const IdTwo = "783243246" - const spells = [ - { - connector: connectorName, - method: "deposit", - args: ["ETH-A", flashloanAmount, 0, IdOne] - }, - { - connector: connectorName, - method: "withdraw", - args: ["ETH-A", amount, IdOne, IdTwo] - }, - { - connector: "INSTAPOOL-A", - method: "flashPayback", - args: [ethAddress, flashloanAmount, IdTwo, 0], - } - ] + const spells = [ + { + connector: connectorName, + method: "deposit", + args: ["ETH-A", flashloanAmount, 0, IdOne] + }, + { + connector: connectorName, + method: "withdraw", + args: ["ETH-A", amount, IdOne, IdTwo] + }, + { + connector: "INSTAPOOL-A", + method: "flashPayback", + args: [ethAddress, flashloanAmount, IdTwo, 0], + } + ] - const calldata = encodeFlashcastData(spells); + const calldata = encodeFlashcastData(spells); - const spells2 = [ - { - connector: "INSTAPOOL-A", - method: "flashBorrowAndCast", - args: [ - "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", - flashloanAmount, - 0, // route - calldata, - ], - } - ] + const spells2 = [ + { + connector: "INSTAPOOL-A", + method: "flashBorrowAndCast", + args: [ + "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + flashloanAmount, + 0, // route + calldata, + ], + } + ] - const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells2), wallet1.address) - const receipt = await tx.wait() + const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells2), wallet1.address) + const receipt = await tx.wait() }); }) }) diff --git a/test/liquity/liquity.test.js b/test/liquity/liquity.test.js index 7b8dce39..e2acde15 100644 --- a/test/liquity/liquity.test.js +++ b/test/liquity/liquity.test.js @@ -21,6 +21,17 @@ describe("Liquity", () => { let liquity = null; before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); liquity = await helpers.deployAndConnect(contracts, true); expect(liquity.troveManager.address).to.exist; expect(liquity.borrowerOperations.address).to.exist; diff --git a/test/mappings/mappings.test.js b/test/mappings/mappings.test.js index 4702d54e..9a6546a3 100644 --- a/test/mappings/mappings.test.js +++ b/test/mappings/mappings.test.js @@ -20,6 +20,17 @@ describe("Test InstaMapping contract", () => { const testRoleAddress = "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723"; before("get signers", async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12796965, + }, + }, + ], + }); [account] = await ethers.getSigners(); const IndexContract = await ethers.getContractAt( @@ -33,6 +44,11 @@ describe("Test InstaMapping contract", () => { params: [masterAddress], }); + await network.provider.send("hardhat_setBalance", [ + masterAddress, + "0x1000000000000000000000000", + ]); + instaMaster = await ethers.getSigner(masterAddress); }); diff --git a/test/uniswap/uniswap.test.js b/test/uniswap/uniswap.test.js index d7a2e407..bd0efdad 100644 --- a/test/uniswap/uniswap.test.js +++ b/test/uniswap/uniswap.test.js @@ -51,6 +51,17 @@ describe("UniswapV3", function () { const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13005785, + }, + }, + ], + }); masterSigner = await getMasterSigner(wallet3) instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); nftManager = await ethers.getContractAt(nftManagerAbi, "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"); @@ -184,7 +195,7 @@ describe("UniswapV3", function () { const data = await nftManager.positions(tokenIds[0]) expect(data.liquidity).to.be.equals(liquidities[0]); - }) + }).timeout(10000000000); it("Should deposit successfully", async function () { const daiAmount = ethers.utils.parseEther("400") // 1 ETH diff --git a/test/uniswapStake/uniswapStake.test.js b/test/uniswapStake/uniswapStake.test.js index 043bd07f..dee656ee 100644 --- a/test/uniswapStake/uniswapStake.test.js +++ b/test/uniswapStake/uniswapStake.test.js @@ -48,6 +48,17 @@ describe("UniswapV3", function () { const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 13300000, + }, + }, + ], + }); masterSigner = await getMasterSigner(wallet3) instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); nftManager = await ethers.getContractAt(nftManagerAbi, "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"); diff --git a/test/yearn/yearn.test.js b/test/yearn/yearn.test.js index 409161b0..596029d3 100644 --- a/test/yearn/yearn.test.js +++ b/test/yearn/yearn.test.js @@ -32,6 +32,17 @@ describe("Yearn", function () { const wallets = provider.getWallets() const [wallet0, wallet1, wallet2, wallet3] = wallets before(async () => { + await hre.network.provider.request({ + method: "hardhat_reset", + params: [ + { + forking: { + jsonRpcUrl: hre.config.networks.hardhat.forking.url, + blockNumber: 12996975, + }, + }, + ], + }); masterSigner = await getMasterSigner(wallet3) instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); connector = await deployAndEnableConnector({