mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
updated tests
This commit is contained in:
parent
2dd6321f5a
commit
67635feb26
|
@ -9,7 +9,8 @@ import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
|
|||
import { addresses } from "../../../scripts/tests/arbitrum/addresses";
|
||||
import { abis } from "../../../scripts/constant/abis";
|
||||
import { ConnectV2DSASpellArbitrum__factory } from "../../../typechain";
|
||||
import type { Signer, Contract } from "ethers";
|
||||
import { Signer, Contract } from "ethers";
|
||||
import { BigNumber } from "bignumber.js";
|
||||
|
||||
describe("DSA Spell", function () {
|
||||
const connectorName = "dsa-spell-test";
|
||||
|
@ -87,6 +88,8 @@ describe("DSA Spell", function () {
|
|||
let ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||
let USDC = "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8";
|
||||
let usdc = new ethers.Contract(USDC, abis.basic.erc20);
|
||||
let aETH = "0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8";
|
||||
let aEth = new ethers.Contract(aETH, abis.basic.aToken);
|
||||
var abi = [
|
||||
"function withdraw(address,uint256,address,uint256,uint256)",
|
||||
"function deposit(address,uint256,uint256,uint256)",
|
||||
|
@ -128,12 +131,16 @@ describe("DSA Spell", function () {
|
|||
});
|
||||
|
||||
it("should check balances after cast on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(ethers.utils.parseEther("0"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(ethers.utils.parseUnits("1", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("12"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(0);
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(
|
||||
new BigNumber(1).multipliedBy(1e6).toString()
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(12).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
|
||||
it("should retry spells", async function () {
|
||||
it("should cast spell on the first successful", async function () {
|
||||
async function getArg(connectors: any, spells: any, params: any) {
|
||||
let datas = [];
|
||||
for (let i = 0; i < connectors.length; i++) {
|
||||
|
@ -142,32 +149,32 @@ describe("DSA Spell", function () {
|
|||
return [connectors, datas];
|
||||
}
|
||||
|
||||
let connectors = ["BASIC-A", "BASIC-A", "AAVE-V3-A", "AAVE-V3-A"];
|
||||
let methods = ["deposit", "withdraw", "deposit", "borrow"];
|
||||
let connectors = ["AAVE-V3-A"];
|
||||
let methods = ["deposit"];
|
||||
let params = [
|
||||
[ETH, ethers.utils.parseEther("1"), 0, 0],
|
||||
[ETH, ethers.utils.parseEther("2"), dsaWallet1.address, 0, 0],
|
||||
[ETH, ethers.utils.parseEther("10"), 0, 0],
|
||||
[USDC, ethers.utils.parseUnits("3", 6), 2, 0, 0]
|
||||
[ETH, ethers.utils.parseEther("10"), 0, 0]
|
||||
];
|
||||
let arg = await getArg(connectors, methods, params);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "spellFactory",
|
||||
method: "castAny",
|
||||
args: arg
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0
|
||||
.connect(wallet0)
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress(), { value: ethers.utils.parseEther("1") });
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress());
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
|
||||
it("should check balances after spells on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("1"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(ethers.utils.parseUnits("3", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("2"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||
new BigNumber(2).multipliedBy(1e18).toString()
|
||||
);
|
||||
expect(await aEth.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(10).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -92,6 +92,8 @@ describe("DSA Spell", function () {
|
|||
let AVAX = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||
let USDC = "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E";
|
||||
let usdc = new ethers.Contract(USDC, abis.basic.erc20);
|
||||
let aAVAX = "0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97";
|
||||
let aAvax = new ethers.Contract(aAVAX, abis.basic.aToken);
|
||||
var abi = [
|
||||
"function withdraw(address,uint256,address,uint256,uint256)",
|
||||
"function deposit(address,uint256,uint256,uint256)",
|
||||
|
@ -133,12 +135,16 @@ describe("DSA Spell", function () {
|
|||
});
|
||||
|
||||
it("should check balances after cast on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(ethers.utils.parseEther("0"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(ethers.utils.parseUnits("1", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("12"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(0);
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(
|
||||
new BigNumber(1).multipliedBy(1e6).toString()
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(12).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
|
||||
it("should retry spells", async function () {
|
||||
it("should cast spell on the first successful", async function () {
|
||||
async function getArg(connectors: any, spells: any, params: any) {
|
||||
let datas = [];
|
||||
for (let i = 0; i < connectors.length; i++) {
|
||||
|
@ -147,32 +153,33 @@ describe("DSA Spell", function () {
|
|||
return [connectors, datas];
|
||||
}
|
||||
|
||||
let connectors = ["BASIC-A", "BASIC-A", "AAVE-V3-A", "AAVE-V3-A"];
|
||||
let methods = ["deposit", "withdraw", "deposit", "borrow"];
|
||||
let connectors = ["AAVE-V3-A", "AAVE-V2-A"];
|
||||
let methods = ["deposit","deposit"];
|
||||
let params = [
|
||||
[AVAX, ethers.utils.parseEther("1"), 0, 0],
|
||||
[AVAX, ethers.utils.parseEther("2"), dsaWallet1.address, 0, 0],
|
||||
[AVAX, ethers.utils.parseEther("10"), 0, 0],
|
||||
[USDC, ethers.utils.parseUnits("3", 6), 2, 0, 0]
|
||||
[AVAX, ethers.utils.parseEther("10"), 0, 0]
|
||||
];
|
||||
let arg = await getArg(connectors, methods, params);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "spellFactory",
|
||||
method: "castAny",
|
||||
args: arg
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0
|
||||
.connect(wallet0)
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress(), { value: ethers.utils.parseEther("1") });
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress());
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
|
||||
it("should check balances after spells on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("1"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(ethers.utils.parseUnits("3", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("2"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||
new BigNumber(2).multipliedBy(1e18).toString()
|
||||
);
|
||||
expect(await aAvax.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(10).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import { addresses } from "../../../scripts/tests/fantom/addresses";
|
|||
import { abis } from "../../../scripts/constant/abis";
|
||||
import { ConnectV2DSASpellFantom__factory } from "../../../typechain";
|
||||
import type { Signer, Contract } from "ethers";
|
||||
import BigNumber from "bignumber.js";
|
||||
|
||||
describe("DSA Spell", function () {
|
||||
const connectorName = "dsa-spell-test";
|
||||
|
@ -87,8 +88,10 @@ describe("DSA Spell", function () {
|
|||
|
||||
describe("Main", function () {
|
||||
let FTM = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||
let aFTM = "0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97";
|
||||
let USDC = "0x04068DA6C83AFCFA0e13ba15A6696662335D5B75";
|
||||
let usdc = new ethers.Contract(USDC, abis.basic.erc20);
|
||||
let aFtm = new ethers.Contract(aFTM, abis.basic.aToken);
|
||||
var abi = [
|
||||
"function withdraw(address,uint256,address,uint256,uint256)",
|
||||
"function deposit(address,uint256,uint256,uint256)",
|
||||
|
@ -130,12 +133,16 @@ describe("DSA Spell", function () {
|
|||
});
|
||||
|
||||
it("should check balances after cast on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(ethers.utils.parseEther("0"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(ethers.utils.parseUnits("1", 5));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("12"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(0);
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(
|
||||
new BigNumber(1).multipliedBy(1e5).toString()
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(12).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
|
||||
it("should retry spells", async function () {
|
||||
it("should cast spell on the first successful", async function () {
|
||||
async function getArg(connectors: any, spells: any, params: any) {
|
||||
let datas = [];
|
||||
for (let i = 0; i < connectors.length; i++) {
|
||||
|
@ -144,32 +151,32 @@ describe("DSA Spell", function () {
|
|||
return [connectors, datas];
|
||||
}
|
||||
|
||||
let connectors = ["BASIC-A", "BASIC-A", "AAVE-V3-A", "AAVE-V3-A"];
|
||||
let methods = ["deposit", "withdraw", "deposit", "borrow"];
|
||||
let connectors = ["AAVE-V3-A"];
|
||||
let methods = ["deposit"];
|
||||
let params = [
|
||||
[FTM, ethers.utils.parseEther("1"), 0, 0],
|
||||
[FTM, ethers.utils.parseEther("2"), dsaWallet1.address, 0, 0],
|
||||
[FTM, ethers.utils.parseEther("10"), 0, 0],
|
||||
[USDC, ethers.utils.parseUnits("1", 5), 2, 0, 0]
|
||||
[FTM, ethers.utils.parseEther("10"), 0, 0]
|
||||
];
|
||||
let arg = await getArg(connectors, methods, params);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "spellFactory",
|
||||
method: "castAny",
|
||||
args: arg
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0
|
||||
.connect(wallet0)
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress(), { value: ethers.utils.parseEther("1") });
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress());
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
|
||||
it("should check balances after spells on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("1"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(ethers.utils.parseUnits("1", 5));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("2"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||
new BigNumber(2).multipliedBy(1e18).toString()
|
||||
);
|
||||
expect(await aFtm.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(10).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import { addresses } from "../../../scripts/tests/mainnet/addresses";
|
|||
import { abis } from "../../../scripts/constant/abis";
|
||||
import { ConnectV2DSASpell__factory } from "../../../typechain";
|
||||
import type { Signer, Contract } from "ethers";
|
||||
import BigNumber from "bignumber.js";
|
||||
|
||||
describe("DSA Spell", function () {
|
||||
const connectorName = "dsa-spell-test";
|
||||
|
@ -87,6 +88,8 @@ describe("DSA Spell", function () {
|
|||
let ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||
let USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
||||
let usdc = new ethers.Contract(USDC, abis.basic.erc20);
|
||||
let aETH = "0x030bA81f1c18d280636F32af80b9AAd02Cf0854e";
|
||||
let aEth = new ethers.Contract(aETH, abis.basic.aToken);
|
||||
var abi = [
|
||||
"function withdraw(address,uint256,address,uint256,uint256)",
|
||||
"function deposit(address,uint256,uint256,uint256)",
|
||||
|
@ -126,11 +129,13 @@ describe("DSA Spell", function () {
|
|||
});
|
||||
|
||||
it("should check balances after cast on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(ethers.utils.parseEther("8"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("12"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(new BigNumber(8).multipliedBy(1e18).toString());
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(12).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
|
||||
it("should retry spells", async function () {
|
||||
it("should cast spell on the first successful", async function () {
|
||||
async function getArg(connectors: any, spells: any, params: any) {
|
||||
let datas = [];
|
||||
for (let i = 0; i < connectors.length; i++) {
|
||||
|
@ -139,29 +144,33 @@ describe("DSA Spell", function () {
|
|||
return [connectors, datas];
|
||||
}
|
||||
|
||||
let connectors = ["BASIC-A", "BASIC-A"];
|
||||
let methods = ["deposit", "withdraw"];
|
||||
let connectors = ["AAVE-V2-A", "AAVE-V1-A"];
|
||||
let methods = ["deposit", "deposit"];
|
||||
let params = [
|
||||
[ETH, ethers.utils.parseEther("1"), 0, 0],
|
||||
[ETH, ethers.utils.parseEther("2"), dsaWallet1.address, 0, 0]
|
||||
[ETH, ethers.utils.parseEther("10"), 0, 0],
|
||||
[ETH, ethers.utils.parseEther("10"), 0, 0]
|
||||
];
|
||||
let arg = await getArg(connectors, methods, params);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "spellFactory",
|
||||
method: "castAny",
|
||||
args: arg
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0
|
||||
.connect(wallet0)
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress(), { value: ethers.utils.parseEther("1") });
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress());
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
|
||||
it("should check balances after spells on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("13"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("10"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||
new BigNumber(2).multipliedBy(1e18).toString()
|
||||
);
|
||||
expect(await aEth.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(10).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import { addresses } from "../../../scripts/tests/optimism/addresses";
|
|||
import { abis } from "../../../scripts/constant/abis";
|
||||
import { ConnectV2DSASpellOptimism__factory } from "../../../typechain";
|
||||
import type { Signer, Contract } from "ethers";
|
||||
import BigNumber from "bignumber.js";
|
||||
|
||||
describe("DSA Spell", function () {
|
||||
const connectorName = "dsa-spell-test";
|
||||
|
@ -87,6 +88,8 @@ describe("DSA Spell", function () {
|
|||
let ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||
let USDC = "0x7F5c764cBc14f9669B88837ca1490cCa17c31607";
|
||||
let usdc = new ethers.Contract(USDC, abis.basic.erc20);
|
||||
let aETH = "0xe50fA9b3c56FfB159cB0FCA61F5c9D750e8128c8";
|
||||
let aEth = new ethers.Contract(aETH, abis.basic.aToken);
|
||||
var abi = [
|
||||
"function withdraw(address,uint256,address,uint256,uint256)",
|
||||
"function deposit(address,uint256,uint256,uint256)",
|
||||
|
@ -128,12 +131,16 @@ describe("DSA Spell", function () {
|
|||
});
|
||||
|
||||
it("should check balances after cast on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(ethers.utils.parseEther("0"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(ethers.utils.parseUnits("1", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("12"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(0);
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(
|
||||
new BigNumber(1).multipliedBy(1e6).toString()
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(12).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
|
||||
it("should retry spells", async function () {
|
||||
it("should cast spell on the first successful", async function () {
|
||||
async function getArg(connectors: any, spells: any, params: any) {
|
||||
let datas = [];
|
||||
for (let i = 0; i < connectors.length; i++) {
|
||||
|
@ -142,32 +149,32 @@ describe("DSA Spell", function () {
|
|||
return [connectors, datas];
|
||||
}
|
||||
|
||||
let connectors = ["BASIC-A", "BASIC-A", "AAVE-V3-A", "AAVE-V3-A"];
|
||||
let methods = ["deposit", "withdraw", "deposit", "borrow"];
|
||||
let connectors = ["AAVE-V3-A"];
|
||||
let methods = ["deposit"];
|
||||
let params = [
|
||||
[ETH, ethers.utils.parseEther("1"), 0, 0],
|
||||
[ETH, ethers.utils.parseEther("2"), dsaWallet1.address, 0, 0],
|
||||
[ETH, ethers.utils.parseEther("10"), 0, 0],
|
||||
[USDC, ethers.utils.parseUnits("3", 6), 2, 0, 0]
|
||||
[ETH, ethers.utils.parseEther("10"), 0, 0]
|
||||
];
|
||||
let arg = await getArg(connectors, methods, params);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "spellFactory",
|
||||
method: "castAny",
|
||||
args: arg
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0
|
||||
.connect(wallet0)
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress(), { value: ethers.utils.parseEther("1") });
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress());
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
|
||||
it("should check balances after spells on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("1"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(ethers.utils.parseUnits("3", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("2"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||
new BigNumber(2).multipliedBy(1e18).toString()
|
||||
);
|
||||
expect(await aEth.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(10).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -91,7 +91,9 @@ describe("DSA Spell", function () {
|
|||
describe("Main", function () {
|
||||
let MATIC = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||
let USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
||||
let aMATIC = "0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97";
|
||||
let usdc = new ethers.Contract(USDC, abis.basic.erc20);
|
||||
let aMatic = new ethers.Contract(aMATIC, abis.basic.aToken);
|
||||
var abi = [
|
||||
"function withdraw(address,uint256,address,uint256,uint256)",
|
||||
"function deposit(address,uint256,uint256,uint256)",
|
||||
|
@ -133,12 +135,16 @@ describe("DSA Spell", function () {
|
|||
});
|
||||
|
||||
it("should check balances after cast on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(ethers.utils.parseEther("0"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(ethers.utils.parseUnits("1", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(ethers.utils.parseEther("12"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.lte(0);
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet1.address)).to.be.gte(
|
||||
new BigNumber(1).multipliedBy(1e6).toString()
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(12).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
|
||||
it("should retry spells", async function () {
|
||||
it("should cast spell on the first successful", async function () {
|
||||
async function getArg(connectors: any, spells: any, params: any) {
|
||||
let datas = [];
|
||||
for (let i = 0; i < connectors.length; i++) {
|
||||
|
@ -147,32 +153,33 @@ describe("DSA Spell", function () {
|
|||
return [connectors, datas];
|
||||
}
|
||||
|
||||
let connectors = ["BASIC-A", "BASIC-A", "AAVE-V3-A", "AAVE-V3-A"];
|
||||
let methods = ["deposit", "withdraw", "deposit", "borrow"];
|
||||
let connectors = ["AAVE-V3-A", "AAVE-V2-A"];
|
||||
let methods = ["deposit","deposit"];
|
||||
let params = [
|
||||
[MATIC, ethers.utils.parseEther("1"), 0, 0],
|
||||
[MATIC, ethers.utils.parseEther("2"), dsaWallet1.address, 0, 0],
|
||||
[MATIC, ethers.utils.parseEther("10"), 0, 0],
|
||||
[USDC, ethers.utils.parseUnits("1", 6), 2, 0, 0]
|
||||
[MATIC, ethers.utils.parseEther("10"), 0, 0]
|
||||
];
|
||||
let arg = await getArg(connectors, methods, params);
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "spellFactory",
|
||||
method: "castAny",
|
||||
args: arg
|
||||
}
|
||||
];
|
||||
const tx = await dsaWallet0
|
||||
.connect(wallet0)
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress(), { value: ethers.utils.parseEther("1") });
|
||||
.cast(...encodeSpells(spells), await wallet0.getAddress());
|
||||
const receipt = await tx.wait();
|
||||
});
|
||||
|
||||
it("should check balances after spells on DSA", async function () {
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(ethers.utils.parseEther("1"));
|
||||
expect(await usdc.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(ethers.utils.parseUnits("1", 6));
|
||||
expect(await ethers.provider.getBalance(dsaWallet1.address)).to.be.gte(ethers.utils.parseEther("2"));
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(
|
||||
new BigNumber(2).multipliedBy(1e18).toString()
|
||||
);
|
||||
expect(await aMatic.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.gte(
|
||||
new BigNumber(10).multipliedBy(1e18).toString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user