From 413f448cbddf13600d694a6cca8bf49b1503487c Mon Sep 17 00:00:00 2001 From: pradyuman-verma Date: Wed, 15 Dec 2021 13:13:41 +0530 Subject: [PATCH] updated scripts --- scripts/tests/addLiquidity.ts | 69 +++++-------------------------- scripts/tests/avalanche/tokens.ts | 64 ++++++++++++++++++++++++++++ scripts/tests/mainnet/tokens.ts | 64 ++++++++++++++++++++++++++++ scripts/tests/polygon/tokens.ts | 66 ++++++++++++++++++++++++++++- 4 files changed, 203 insertions(+), 60 deletions(-) diff --git a/scripts/tests/addLiquidity.ts b/scripts/tests/addLiquidity.ts index f29d6374..e06606d9 100644 --- a/scripts/tests/addLiquidity.ts +++ b/scripts/tests/addLiquidity.ts @@ -1,79 +1,30 @@ -import { Provider } from "@ethersproject/abstract-provider"; -import { Signer } from "@ethersproject/abstract-signer"; import { ethers } from "hardhat"; import { impersonateAccounts } from "./impersonate"; +import { tokenMapping as mainnetMapping } from "./mainnet/tokens"; +import { tokenMapping as polygonMapping } from "./polygon/tokens"; +import { tokenMapping as avalancheMapping } from "./avalanche/tokens"; const mineTx = async (tx: any) => { await (await tx).wait(); }; -const tokenMapping: Record = { - usdc: { - impersonateSigner: "0xfcb19e6a322b27c06842a71e8c725399f049ae3a", - address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", - abi: [ - "function mint(address _to, uint256 _amount) external returns (bool);", - ], - process: async function(owner: Signer | Provider, to: any, amt: any) { - const contract = new ethers.Contract(this.address, this.abi, owner); - - await mineTx(contract.mint(to, amt)); - }, - }, - dai: { - impersonateSigner: "0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503", - abi: ["function transfer(address to, uint value)"], - address: "0x6b175474e89094c44da98b954eedeac495271d0f", - process: async function(owner: Signer | Provider, to: any, amt: any) { - const contract = new ethers.Contract(this.address, this.abi, owner); - await mineTx(contract.transfer(to, amt)); - }, - }, - usdt: { - impersonateSigner: "0xc6cde7c39eb2f0f0095f41570af89efc2c1ea828", - address: "0xdac17f958d2ee523a2206206994597c13d831ec7", - abi: [ - "function issue(uint amount)", - "function transfer(address to, uint value)", - ], - process: async function(owner: Signer | Provider, address: any, amt: any) { - const contract = new ethers.Contract(this.address, this.abi, owner); - - await mineTx(contract.issue(amt)); - await mineTx(contract.transfer(address, amt)); - }, - }, - wbtc: { - impersonateSigner: "0xCA06411bd7a7296d7dbdd0050DFc846E95fEBEB7", - address: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", - abi: ["function mint(address _to, uint256 _amount) public returns (bool)"], - process: async function(owner: Signer | Provider, address: any, amt: any) { - const contract = new ethers.Contract(this.address, this.abi, owner); - await mineTx(contract.mint(address, amt)); - }, - }, - inst: { - impersonateSigner: "0x75e89d5979E4f6Fba9F97c104c2F0AFB3F1dcB88", - address: "0x6f40d4a6237c257fff2db00fa0510deeecd303eb", - abi: ["function transfer(address to, uint value)"], - process: async function(owner: Signer | Provider, address: any, amt: any) { - const contract = new ethers.Contract(this.address, this.abi, owner); - await mineTx(contract.transfer(address, amt)); - }, - }, +const tokenMapping: Record> = { + mainnet: mainnetMapping, + polygon: polygonMapping, + avalanche: avalancheMapping, }; export async function addLiquidity(tokenName: string, address: any, amt: any) { const [signer] = await ethers.getSigners(); tokenName = tokenName.toLowerCase(); - if (!tokenMapping[tokenName]) { + const chain = String(process.env.networkType); + if (!tokenMapping[chain][tokenName]) { throw new Error( `Add liquidity doesn't support the following token: ${tokenName}` ); } - const token = tokenMapping[tokenName]; - + const token = tokenMapping[chain][tokenName]; const [impersonatedSigner] = await impersonateAccounts([ token.impersonateSigner, ]); diff --git a/scripts/tests/avalanche/tokens.ts b/scripts/tests/avalanche/tokens.ts index fc679ab4..f35ad299 100644 --- a/scripts/tests/avalanche/tokens.ts +++ b/scripts/tests/avalanche/tokens.ts @@ -1,3 +1,11 @@ +import { Provider } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { ethers } from "hardhat"; + +const mineTx = async (tx: any) => { + await (await tx).wait(); +}; + export const tokens = { eth: { type: "token", @@ -21,3 +29,59 @@ export const tokens = { decimals: 6, }, }; + +export const tokenMapping: Record = { + usdc: { + impersonateSigner: "0xc5ed2333f8a2c351fca35e5ebadb2a82f5d254c3", + address: "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664", + abi: [ + "function mint(address _to, uint256 _amount) external returns (bool);", + ], + process: async function (owner: Signer | Provider, to: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + + await mineTx(contract.mint(to, amt)); + }, + }, + dai: { + impersonateSigner: "0xed2a7edd7413021d440b09d654f3b87712abab66", + address: "0xd586e7f844cea2f87f50152665bcbc2c279d8d70", + abi: ["function transfer(address to, uint value)"], + process: async function (owner: Signer | Provider, to: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.transfer(to, amt)); + }, + }, + usdt: { + impersonateSigner: "0xc5ed2333f8a2c351fca35e5ebadb2a82f5d254c3", + address: "0xc7198437980c041c805a1edcba50c1ce5db95118", + abi: [ + "function issue(uint amount)", + "function transfer(address to, uint value)", + ], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + + await mineTx(contract.issue(amt)); + await mineTx(contract.transfer(address, amt)); + }, + }, + wbtc: { + impersonateSigner: "0x63cdb19c13497383726ad6bbf7c6b6cf725a3164", + address: "0x50b7545627a5162f82a992c33b87adc75187b218", + abi: ["function mint(address _to, uint256 _amount) public returns (bool)"], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.mint(address, amt)); + }, + }, + // inst: { + // impersonateSigner: "0x75e89d5979E4f6Fba9F97c104c2F0AFB3F1dcB88", + // address: "0x6f40d4a6237c257fff2db00fa0510deeecd303eb", + // abi: ["function transfer(address to, uint value)"], + // process: async function (owner: Signer | Provider, address: any, amt: any) { + // const contract = new ethers.Contract(this.address, this.abi, owner); + // await mineTx(contract.transfer(address, amt)); + // }, + // }, +}; diff --git a/scripts/tests/mainnet/tokens.ts b/scripts/tests/mainnet/tokens.ts index d3c95180..4fa7a6b1 100644 --- a/scripts/tests/mainnet/tokens.ts +++ b/scripts/tests/mainnet/tokens.ts @@ -1,3 +1,11 @@ +import { Provider } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { ethers } from "hardhat"; + +const mineTx = async (tx: any) => { + await (await tx).wait(); +}; + export const tokens = { eth: { type: "token", @@ -21,3 +29,59 @@ export const tokens = { decimals: 6, }, }; + +export const tokenMapping: Record = { + usdc: { + impersonateSigner: "0xfcb19e6a322b27c06842a71e8c725399f049ae3a", + address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + abi: [ + "function mint(address _to, uint256 _amount) external returns (bool);", + ], + process: async function (owner: Signer | Provider, to: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + + await mineTx(contract.mint(to, amt)); + }, + }, + dai: { + impersonateSigner: "0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503", + abi: ["function transfer(address to, uint value)"], + address: "0x6b175474e89094c44da98b954eedeac495271d0f", + process: async function (owner: Signer | Provider, to: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.transfer(to, amt)); + }, + }, + usdt: { + impersonateSigner: "0xc6cde7c39eb2f0f0095f41570af89efc2c1ea828", + address: "0xdac17f958d2ee523a2206206994597c13d831ec7", + abi: [ + "function issue(uint amount)", + "function transfer(address to, uint value)", + ], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + + await mineTx(contract.issue(amt)); + await mineTx(contract.transfer(address, amt)); + }, + }, + wbtc: { + impersonateSigner: "0xCA06411bd7a7296d7dbdd0050DFc846E95fEBEB7", + address: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", + abi: ["function mint(address _to, uint256 _amount) public returns (bool)"], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.mint(address, amt)); + }, + }, + inst: { + impersonateSigner: "0x75e89d5979E4f6Fba9F97c104c2F0AFB3F1dcB88", + address: "0x6f40d4a6237c257fff2db00fa0510deeecd303eb", + abi: ["function transfer(address to, uint value)"], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.transfer(address, amt)); + }, + }, +}; diff --git a/scripts/tests/polygon/tokens.ts b/scripts/tests/polygon/tokens.ts index d621b68e..83b66b68 100644 --- a/scripts/tests/polygon/tokens.ts +++ b/scripts/tests/polygon/tokens.ts @@ -1,3 +1,11 @@ +import { Provider } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { ethers } from "hardhat"; + +const mineTx = async (tx: any) => { + await (await tx).wait(); +}; + export const tokens = { matic: { type: "token", @@ -10,7 +18,7 @@ export const tokens = { type: "token", symbol: "ETH", name: "Ethereum", - address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + address: "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619", decimals: 18, }, dai: { @@ -28,3 +36,59 @@ export const tokens = { decimals: 6, }, }; + +export const tokenMapping: Record = { + usdc: { + impersonateSigner: "0x6e7a5fafcec6bb1e78bae2a1f0b612012bf14827", + address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", + abi: [ + "function mint(address _to, uint256 _amount) external returns (bool);", + ], + process: async function (owner: Signer | Provider, to: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + + await mineTx(contract.mint(to, amt)); + }, + }, + dai: { + impersonateSigner: "0x4a35582a710e1f4b2030a3f826da20bfb6703c09", + address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063", + abi: ["function transfer(address to, uint value)"], + process: async function (owner: Signer | Provider, to: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.transfer(to, amt)); + }, + }, + usdt: { + impersonateSigner: "0x0d0707963952f2fba59dd06f2b425ace40b492fe", + address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", + abi: [ + "function issue(uint amount)", + "function transfer(address to, uint value)", + ], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + + await mineTx(contract.issue(amt)); + await mineTx(contract.transfer(address, amt)); + }, + }, + wbtc: { + impersonateSigner: "0xdc9232e2df177d7a12fdff6ecbab114e2231198d", + address: "0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6", + abi: ["function mint(address _to, uint256 _amount) public returns (bool)"], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.mint(address, amt)); + }, + }, + inst: { + impersonateSigner: "0xf1f22f25f748f79263d44735198e023b72806ab1", + address: "0xf50d05a1402d0adafa880d36050736f9f6ee7dee", + abi: ["function transfer(address to, uint value)"], + process: async function (owner: Signer | Provider, address: any, amt: any) { + const contract = new ethers.Contract(this.address, this.abi, owner); + await mineTx(contract.transfer(address, amt)); + }, + }, +};