testcases updated

This commit is contained in:
Shriya Tyagi 2022-07-06 17:30:26 +04:00
parent ba0f866bba
commit 37103d99ef

View File

@ -5,12 +5,10 @@ import { addresses } from "../../../scripts/tests/mainnet/addresses";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector"; import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"; import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"; import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { ConnectV2Euler, ConnectV2Euler__factory, IERC20__factory } from "../../../typechain"; import { ConnectV2Euler__factory, IERC20__factory } from "../../../typechain";
import { parseEther } from "@ethersproject/units"; import { parseEther, parseUnits } from "@ethersproject/units";
import { encodeSpells } from "../../../scripts/tests/encodeSpells"; import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import { tokens } from "../../../scripts/tests/mainnet/tokens"; import { tokens } from "../../../scripts/tests/mainnet/tokens";
import { constants } from "../../../scripts/constant/constant";
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
const { ethers } = hre; const { ethers } = hre;
import type { Signer, Contract } from "ethers"; import type { Signer, Contract } from "ethers";
@ -25,7 +23,15 @@ describe("Euler", function () {
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
const ACC_USDC = '0xe78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0' const ACC_USDC = '0xe78388b4ce79068e89bf8aa7f218ef6b9ab0e9d0'
const Usdc = ethers.utils.parseUnits('5000', 6) const Usdc = parseUnits('5000', 6)
const DAI = '0x6b175474e89094c44da98b954eedeac495271d0f'
const ACC_DAI = '0xcd6Eb888e76450eF584E8B51bB73c76ffBa21FF2'
const Dai = parseUnits('5000', 18)
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
const ACC_WETH = '0x05547D4e1A2191B91510Ea7fA8555a2788C70030'
const Weth = parseUnits('50', 18)
before(async () => { before(async () => {
await hre.network.provider.request({ await hre.network.provider.request({
@ -99,12 +105,62 @@ describe("Euler", function () {
await token_usdc.connect(wallet0).transfer(dsaWallet0.address, Usdc); await token_usdc.connect(wallet0).transfer(dsaWallet0.address, Usdc);
expect(await token_usdc.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('5000', 6)
);
});
it("Deposit DAI into DSA wallet", async function () {
const token_dai = new ethers.Contract(
DAI,
IERC20__factory.abi,
ethers.provider,
)
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [ACC_DAI],
})
const signer_dai = await ethers.getSigner(ACC_DAI)
await token_dai.connect(signer_dai).transfer(wallet0.getAddress(), Dai)
await hre.network.provider.request({ await hre.network.provider.request({
method: 'hardhat_stopImpersonatingAccount', method: 'hardhat_stopImpersonatingAccount',
params: [ACC_USDC], params: [ACC_DAI],
}) })
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
parseEther("10") await token_dai.connect(wallet0).transfer(dsaWallet0.address, Dai);
expect(await token_dai.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('5000', 18)
);
});
it("Deposit WETH into DSA wallet", async function () {
const token_weth = new ethers.Contract(
WETH,
IERC20__factory.abi,
ethers.provider,
)
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [ACC_WETH],
})
const signer_weth = await ethers.getSigner(ACC_WETH)
await token_weth.connect(signer_weth).transfer(wallet0.getAddress(), Weth)
await hre.network.provider.request({
method: 'hardhat_stopImpersonatingAccount',
params: [ACC_WETH],
})
await token_weth.connect(wallet0).transfer(dsaWallet0.address, Weth);
expect(await token_weth.connect(masterSigner).balanceOf(dsaWallet0.address)).to.be.gte(
parseUnits('50', 18)
); );
}); });
}); });
@ -130,7 +186,44 @@ describe("Euler", function () {
{ {
connector: connectorName, connector: connectorName,
method: "borrow", method: "borrow",
args: ["0", tokens.dai.address, "1000000", "0", "0"], args: ["0", tokens.dai.address, "1000000000000000000", "0", "0"],
},
];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
parseUnits('1', 18)
);
})
it("Should repay DAI", async function () {
const spells = [
{
connector: connectorName,
method: "repay",
args: ["0", tokens.dai.address, "1000000000000000", "0", "0"],
},
];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
parseUnits('5000', 18)
);
})
it("Should withdraw USDC into DSA wallet", async function () {
const spells = [
{
connector: connectorName,
method: "withdraw",
args: ["0", tokens.usdc.address, "2000000", "0", "0"],
}, },
]; ];
@ -140,5 +233,146 @@ describe("Euler", function () {
await tx.wait(); await tx.wait();
}) })
it("Should eTransfer to subAccount 2", async function () {
const spells = [
{
connector: connectorName,
method: "eTransfer",
args: ["0", "1", tokens.usdc.address, "1000000", "0", "0"],
},
];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
})
it("Should dTransfer to subAccount 2", async function () {
const spell = [
{
connector: connectorName,
method: "deposit",
args: ["1", tokens.usdc.address, "10000000", "true", "0", "0"],
},
];
const txn = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spell), wallet1.getAddress());
await txn.wait();
const spells = [
{
connector: connectorName,
method: "dTransfer",
args: ["0", "1", tokens.dai.address, "100000000000000000", "0", "0"],
},
];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
})
it("Should give debt transfer allowance", async function () {
const spell = [
{
connector: connectorName,
method: "approveDebt",
args: ["0", "0x9F60699cE23f1Ab86Ec3e095b477Ff79d4f409AD", tokens.dai.address, "10000000", "0", "0"],
},
];
const txn = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spell), wallet1.getAddress());
await txn.wait();
})
it("Should enter the market", async function () {
const spell = [
{
connector: connectorName,
method: "enterMarket",
args: ["0", [tokens.weth.address]],
},
];
const txn = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spell), wallet1.getAddress());
await txn.wait();
});
it("Should exit the market", async function () {
const spell = [
{
connector: connectorName,
method: "exitMarket",
args: ["0", tokens.weth.address],
},
];
const txn = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spell), wallet1.getAddress());
await txn.wait();
});
it("Should mint", async function () {
const spells = [
{
connector: connectorName,
method: "deposit",
args: ["2", tokens.weth.address, "1000000000000000000", "true", "0", "0"],
},
];
const tx = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spells), wallet1.getAddress());
await tx.wait();
const spell = [
{
connector: connectorName,
method: "mint",
args: ["2", tokens.weth.address, "100000000", "0", "0"],
},
];
const txn = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spell), wallet1.getAddress());
await txn.wait();
})
it("Should burn", async function () {
const spell = [
{
connector: connectorName,
method: "burn",
args: ["2", tokens.weth.address, "10000000", "0", "0"],
},
];
const txn = await dsaWallet0
.connect(wallet0)
.cast(...encodeSpells(spell), wallet1.getAddress());
await txn.wait();
})
}); });
}); });