minor script fixes

This commit is contained in:
pradyuman-verma 2022-03-09 17:33:47 +05:30
parent 270a3f79b9
commit 74b0eccec0
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F
2 changed files with 16 additions and 30 deletions

View File

@ -24,8 +24,8 @@ async function deployRunner() {
name: "chain",
message: "What chain do you want to deploy on?",
type: "list",
choices: ["mainnet", "polygon", "avalanche", "arbitrum"],
},
choices: ["mainnet", "polygon", "avalanche", "arbitrum", "optimism"]
}
]);
// let connector = await connectorSelect(chain);
@ -48,8 +48,8 @@ async function deployRunner() {
{
name: "connector",
message: "Enter the connector contract name? (ex: ConnectV2Paraswap)",
type: "input",
},
type: "input"
}
]);
let { choice } = await inquirer.prompt([
@ -57,39 +57,29 @@ async function deployRunner() {
name: "choice",
message: "Do you wanna try deploy on hardhat first?",
type: "list",
choices: ["yes", "no"],
},
choices: ["yes", "no"]
}
]);
runchain = choice === "yes" ? "hardhat" : chain;
console.log(
`Deploying ${connector} on ${runchain}, press (ctrl + c) to stop`
);
console.log(`Deploying ${connector} on ${runchain}, press (ctrl + c) to stop`);
start = Date.now();
await execScript({
cmd: "npx",
args: [
"hardhat",
"run",
"scripts/deployment/deploy.ts",
"--network",
`${runchain}`,
],
args: ["hardhat", "run", "scripts/deployment/deploy.ts", "--network", `${runchain}`],
env: {
connectorName: connector,
networkType: chain,
},
networkType: chain
}
});
end = Date.now();
}
deployRunner()
.then(() => {
console.log(
`Done successfully, total time taken: ${(end - start) / 1000} sec`
);
console.log(`Done successfully, total time taken: ${(end - start) / 1000} sec`);
process.exit(0);
})
.catch((err) => {

View File

@ -1,4 +1,4 @@
import { ethers } from "hardhat";
import { ethers, network } from "hardhat";
import { impersonateAccounts } from "./impersonate";
import { tokenMapping as mainnetMapping } from "./mainnet/tokens";
@ -12,7 +12,7 @@ const mineTx = async (tx: any) => {
const tokenMapping: Record<string, Record<string, any>> = {
mainnet: mainnetMapping,
polygon: polygonMapping,
avalanche: avalancheMapping,
avalanche: avalancheMapping
};
export async function addLiquidity(tokenName: string, address: any, amt: any) {
@ -20,20 +20,16 @@ export async function addLiquidity(tokenName: string, address: any, amt: any) {
tokenName = tokenName.toLowerCase();
const chain = String(process.env.networkType);
if (!tokenMapping[chain][tokenName]) {
throw new Error(
`Add liquidity doesn't support the following token: ${tokenName}`
);
throw new Error(`Add liquidity doesn't support the following token: ${tokenName}`);
}
const token = tokenMapping[chain][tokenName];
const [impersonatedSigner] = await impersonateAccounts([
token.impersonateSigner,
]);
const [impersonatedSigner] = await impersonateAccounts([token.impersonateSigner]);
// send 2 eth to cover any tx costs.
await network.provider.send("hardhat_setBalance", [
impersonatedSigner.address,
ethers.utils.parseEther("2").toHexString(),
ethers.utils.parseEther("2").toHexString()
]);
await token.process(impersonatedSigner, address, amt);