From bc12131ccf6ec1cd78b44c1d289404654c6a809e Mon Sep 17 00:00:00 2001 From: Richa-iitr Date: Mon, 4 Apr 2022 01:41:52 +0530 Subject: [PATCH] updated tests --- .../aave/v3-import-permit/helpers.sol | 3 +- test/polygon/aave/aaveV3-import-test.ts | 157 +----------------- 2 files changed, 5 insertions(+), 155 deletions(-) diff --git a/contracts/polygon/connectors/aave/v3-import-permit/helpers.sol b/contracts/polygon/connectors/aave/v3-import-permit/helpers.sol index b7eb7cd9..54afb590 100644 --- a/contracts/polygon/connectors/aave/v3-import-permit/helpers.sol +++ b/contracts/polygon/connectors/aave/v3-import-permit/helpers.sol @@ -240,8 +240,7 @@ contract AaveHelpers is Helper { uint256[] memory expiry ) internal { for(uint256 i = 0; i < tokens.length; i++) { - ATokenInterface aTokenContracts = ATokenInterface(tokens[i]); - aTokenContracts.permit(userAccount, address(this), uint(-1), expiry[i], v[i], r[i], s[i]); + aTokenContracts[i].permit(userAccount, address(this), uint(-1), expiry[i], v[i], r[i], s[i]); } } diff --git a/test/polygon/aave/aaveV3-import-test.ts b/test/polygon/aave/aaveV3-import-test.ts index d9ddbf5c..c5729575 100644 --- a/test/polygon/aave/aaveV3-import-test.ts +++ b/test/polygon/aave/aaveV3-import-test.ts @@ -25,27 +25,11 @@ const ABI = [ const aDaiAddress = "0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE"; const aaveAddress = "0x794a61358D6845594F94dc1DB02A252b5b4814aD"; const account = "0xf04adbf75cdfc5ed26eea4bbbb991db002036bdd"; -// const account = "0x44df7e55c643c3cB048465E176A443Ad5670A6fa"; const DAI = "0x8f3cf7ad23cd3cadbd9735aff958023239c6a063"; const USDC = "0x2791bca1f2de4661ed88a30c99a7a9449aa84174"; const mnemonic = "test test test test test test test test test test test junk"; const erc20Abi = [ - - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, { "constant": false, "inputs": [ @@ -83,47 +67,6 @@ const erc20Abi = [ "stateMutability": "view", "type": "function" }, - { - "constant": false, - "inputs": [ - { - "name": "_from", - "type": "address" - }, - { - "name": "_to", - "type": "address" - }, - { - "name": "_value", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, { "constant": true, "inputs": [ @@ -143,20 +86,6 @@ const erc20Abi = [ "stateMutability": "view", "type": "function" }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, { "constant": false, "inputs": [ @@ -179,80 +108,9 @@ const erc20Abi = [ "payable": false, "stateMutability": "nonpayable", "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_owner", - "type": "address" - }, - { - "name": "_spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "payable": true, - "stateMutability": "payable", - "type": "fallback" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" } ]; + const token = new ethers.Contract(DAI, erc20Abi); const aDai = new ethers.Contract(aDaiAddress, ABI); const usdcToken = new ethers.Contract(USDC, erc20Abi); @@ -384,7 +242,6 @@ describe("Import Aave", function () { signer = await ethers.getSigner(account); - console.log(await token.connect(signer).balanceOf(signer.address)); await token.connect(signer).transfer(wallet0.address, ethers.utils.parseEther("8")); instaConnectorsV2 = await ethers.getContractAt(abis.core.connectorsV2, addresses.core.connectorsV2); @@ -395,8 +252,6 @@ describe("Import Aave", function () { connectors: instaConnectorsV2 }); - console.log("Connector address", connector.address); - const aave = new ethers.Contract(aaveAddress, aaveAbi); // approve DAI to aavePool @@ -451,7 +306,8 @@ describe("Import Aave", function () { const PERMIT_TYPEHASH = "0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9"; let nonce = (await aDai.connect(wallet0).nonces(wallet.address)).toNumber(); - const amount = await aDai.connect(wallet0).balanceOf(wallet.address); + //Approving max amount + const amount = ethers.constants.MaxUint256; const expiry = Date.now() + 20 * 60; const digest = keccak256( @@ -471,20 +327,15 @@ describe("Import Aave", function () { ) ); const { v, r, s } = ecsign(Buffer.from(digest.slice(2), "hex"), Buffer.from(wallet.privateKey.slice(2), "hex")); - // console.log(v); - // console.log(pubToAddress(ecrecover(Buffer.from(digest.slice(2),'hex'),v,r,s))); - // console.log(dsaWallet0.address); - // console.log(wallet.address); const amount0 = new BigNumber(await usdcToken.connect(wallet0).balanceOf(wallet.address)); const amountB = new BigNumber(amount0.toString()).multipliedBy(5).dividedBy(1e4); const amountWithFee = amount0.plus(amountB); - console.log(amountWithFee); const flashSpells = [ { connector: "AAVE-V3-IMPORT-PERMIT-X", method: "importAave", - args: [wallet.address, [[DAI], [USDC], false, [amountB.toFixed(0)]], [[v], [ethers.utils.hexlify(r)], [ethers.utils.hexlify(s)], [expiry]]] + args: [wallet.address, [[DAI], [USDC], false, [amountB.toFixed(0)]], [[ethers.utils.hexlify(v)], [ethers.utils.hexlify(r)], [ethers.utils.hexlify(s)], [expiry]]] }, { connector: "INSTAPOOL-C",