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
3b91d64d65
commit
82add64d43
|
@ -28,6 +28,100 @@ const account = "0xf04adbf75cdfc5ed26eea4bbbb991db002036bdd";
|
||||||
const DAI = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063";
|
const DAI = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063";
|
||||||
const USDC = "0x2791bca1f2de4661ed88a30c99a7a9449aa84174";
|
const USDC = "0x2791bca1f2de4661ed88a30c99a7a9449aa84174";
|
||||||
const mnemonic = "test test test test test test test test test test test junk";
|
const mnemonic = "test test test test test test test test test test test junk";
|
||||||
|
const connectorName = "AAVE-V3-IMPORT-PERMIT-X";
|
||||||
|
let signer: any, wallet0: any;
|
||||||
|
|
||||||
|
const aaveAbi = [
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "asset",
|
||||||
|
type: "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "amount",
|
||||||
|
type: "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "interestRateMode",
|
||||||
|
type: "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint16",
|
||||||
|
name: "referralCode",
|
||||||
|
type: "uint16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "onBehalfOf",
|
||||||
|
type: "address"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
name: "borrow",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "asset",
|
||||||
|
type: "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "amount",
|
||||||
|
type: "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "onBehalfOf",
|
||||||
|
type: "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint16",
|
||||||
|
name: "referralCode",
|
||||||
|
type: "uint16"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
name: "deposit",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "asset",
|
||||||
|
type: "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "amount",
|
||||||
|
type: "uint256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "onBehalfOf",
|
||||||
|
type: "address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint16",
|
||||||
|
name: "referralCode",
|
||||||
|
type: "uint16"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
name: "supply",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const erc20Abi = [
|
const erc20Abi = [
|
||||||
{
|
{
|
||||||
|
@ -114,103 +208,9 @@ const erc20Abi = [
|
||||||
const token = new ethers.Contract(DAI, erc20Abi);
|
const token = new ethers.Contract(DAI, erc20Abi);
|
||||||
const aDai = new ethers.Contract(aDaiAddress, ABI);
|
const aDai = new ethers.Contract(aDaiAddress, ABI);
|
||||||
const usdcToken = new ethers.Contract(USDC, erc20Abi);
|
const usdcToken = new ethers.Contract(USDC, erc20Abi);
|
||||||
|
const aave = new ethers.Contract(aaveAddress, aaveAbi);
|
||||||
|
|
||||||
describe("Import Aave V3 with Permit", function () {
|
describe("Import Aave", function () {
|
||||||
const connectorName = "AAVE-V3-IMPORT-PERMIT-X";
|
|
||||||
let signer: any, wallet0: any;
|
|
||||||
|
|
||||||
const aaveAbi = [
|
|
||||||
{
|
|
||||||
inputs: [
|
|
||||||
{
|
|
||||||
internalType: "address",
|
|
||||||
name: "asset",
|
|
||||||
type: "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "amount",
|
|
||||||
type: "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "interestRateMode",
|
|
||||||
type: "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint16",
|
|
||||||
name: "referralCode",
|
|
||||||
type: "uint16"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "address",
|
|
||||||
name: "onBehalfOf",
|
|
||||||
type: "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
name: "borrow",
|
|
||||||
outputs: [],
|
|
||||||
stateMutability: "nonpayable",
|
|
||||||
type: "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
inputs: [
|
|
||||||
{
|
|
||||||
internalType: "address",
|
|
||||||
name: "asset",
|
|
||||||
type: "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "amount",
|
|
||||||
type: "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "address",
|
|
||||||
name: "onBehalfOf",
|
|
||||||
type: "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint16",
|
|
||||||
name: "referralCode",
|
|
||||||
type: "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
name: "deposit",
|
|
||||||
outputs: [],
|
|
||||||
stateMutability: "nonpayable",
|
|
||||||
type: "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
inputs: [
|
|
||||||
{
|
|
||||||
internalType: "address",
|
|
||||||
name: "asset",
|
|
||||||
type: "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "amount",
|
|
||||||
type: "uint256"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "address",
|
|
||||||
name: "onBehalfOf",
|
|
||||||
type: "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint16",
|
|
||||||
name: "referralCode",
|
|
||||||
type: "uint16"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
name: "supply",
|
|
||||||
outputs: [],
|
|
||||||
stateMutability: "nonpayable",
|
|
||||||
type: "function"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
let dsaWallet0: any;
|
let dsaWallet0: any;
|
||||||
let masterSigner: Signer;
|
let masterSigner: Signer;
|
||||||
let instaConnectorsV2: Contract;
|
let instaConnectorsV2: Contract;
|
||||||
|
@ -251,19 +251,32 @@ describe("Import Aave V3 with Permit", function () {
|
||||||
signer: masterSigner,
|
signer: masterSigner,
|
||||||
connectors: instaConnectorsV2
|
connectors: instaConnectorsV2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
const aave = new ethers.Contract(aaveAddress, aaveAbi);
|
describe("check user AAVE position", async () => {
|
||||||
|
it("Should create Aave v3 position of DAI(collateral) and USDC(debt)", async () => {
|
||||||
|
// approve DAI to aavePool
|
||||||
|
await token.connect(wallet0).approve(aaveAddress, parseEther("8"));
|
||||||
|
|
||||||
// approve DAI to aavePool
|
//deposit DAI in aave
|
||||||
await token.connect(wallet0).approve(aaveAddress, parseEther("8"));
|
await aave.connect(wallet0).supply(DAI, parseEther("8"), wallet.address, 3228);
|
||||||
|
console.log("Supplied DAI on aave");
|
||||||
|
|
||||||
//deposit DAI in aave
|
//borrow USDC from aave
|
||||||
await aave.connect(wallet0).supply(DAI, parseEther("8"), wallet.address, 3228);
|
await aave.connect(wallet0).borrow(USDC, parseUnits("5", 6), 2, 3228, wallet.address);
|
||||||
console.log("Supplied DAI on aave");
|
console.log("Borrowed USDC from aave");
|
||||||
|
});
|
||||||
|
|
||||||
//borrow USDC from aave
|
it("Should check position of user", async () => {
|
||||||
await aave.connect(wallet0).borrow(USDC, parseUnits("5", 6), 2, 3228, wallet.address);
|
expect(await aDai.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
|
||||||
console.log("Borrowed USDC from aave");
|
new BigNumber(8).multipliedBy(1e18).toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(await usdcToken.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
|
||||||
|
new BigNumber(5).multipliedBy(1e6).toString()
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Deployment", async () => {
|
describe("Deployment", async () => {
|
||||||
|
@ -288,18 +301,6 @@ describe("Import Aave V3 with Permit", function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("check user AAVE position", async () => {
|
|
||||||
it("Should check position of user", async () => {
|
|
||||||
expect(await aDai.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
|
|
||||||
new BigNumber(8).multipliedBy(1e18).toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(await usdcToken.connect(wallet0).balanceOf(wallet.address)).to.be.gte(
|
|
||||||
new BigNumber(5).multipliedBy(1e6).toString()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Aave position migration", async () => {
|
describe("Aave position migration", async () => {
|
||||||
it("Should migrate Aave position", async () => {
|
it("Should migrate Aave position", async () => {
|
||||||
const DOMAIN_SEPARATOR = await aDai.connect(wallet0).DOMAIN_SEPARATOR();
|
const DOMAIN_SEPARATOR = await aDai.connect(wallet0).DOMAIN_SEPARATOR();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user