updated scripts

This commit is contained in:
pradyuman-verma 2021-11-29 22:51:11 +05:30
parent 3ed6a483dc
commit e7b0de2dda
12 changed files with 98 additions and 110 deletions

View File

@ -63,7 +63,7 @@ const tokenMapping = {
},
};
module.exports = async (tokenName: string, address: any, amt: any) => {
export async function addLiquidity(tokenName: string, address: any, amt: any) {
const [signer] = await ethers.getSigners();
tokenName = tokenName.toLowerCase();
if (!tokenMapping[tokenName]) {
@ -85,4 +85,4 @@ module.exports = async (tokenName: string, address: any, amt: any) => {
});
await token.process(impersonatedSigner, address, amt);
};
}

View File

@ -4,7 +4,7 @@ import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
import { abi } from "../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
export default async function(owner: any) {
export async function buildDSAv2(owner: any) {
const instaIndex = await ethers.getContractAt(
abis.core.instaIndex,
addresses.core.instaIndex

View File

@ -1,38 +0,0 @@
const hre = require("hardhat");
const { ethers } = hre;
const deployConnector = require("./deployConnector");
async function main() {
const accounts = await hre.ethers.getSigners()
const wallet = accounts[0]
const connectMapping = {
'1INCH-A': 'ConnectV2OneInch',
'1INCH-B': 'ConnectV2OneProto',
'AAVE-V1-A': 'ConnectV2AaveV1',
'AAVE-V2-A': 'ConnectV2AaveV2',
'AUTHORITY-A': 'ConnectV2Auth',
'BASIC-A': 'ConnectV2Basic',
'COMP-A': 'ConnectV2COMP',
'COMPOUND-A': 'ConnectV2Compound',
'DYDX-A': 'ConnectV2Dydx',
'FEE-A': 'ConnectV2Fee',
'GELATO-A': 'ConnectV2Gelato',
'MAKERDAO-A': 'ConnectV2Maker',
'UNISWAP-A': 'ConnectV2UniswapV2'
}
const addressMapping = {}
for (const key in connectMapping) {
addressMapping[key] = await deployConnector(connectMapping[key])
}
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});

36
scripts/deploy.ts Normal file
View File

@ -0,0 +1,36 @@
import { ethers } from "hardhat";
import { deployConnector } from "./deployConnector";
async function main() {
const accounts = await ethers.getSigners();
const wallet = accounts[0];
const connectMapping = {
"1INCH-A": "ConnectV2OneInch",
"1INCH-B": "ConnectV2OneProto",
"AAVE-V1-A": "ConnectV2AaveV1",
"AAVE-V2-A": "ConnectV2AaveV2",
"AUTHORITY-A": "ConnectV2Auth",
"BASIC-A": "ConnectV2Basic",
"COMP-A": "ConnectV2COMP",
"COMPOUND-A": "ConnectV2Compound",
"DYDX-A": "ConnectV2Dydx",
"FEE-A": "ConnectV2Fee",
"GELATO-A": "ConnectV2Gelato",
"MAKERDAO-A": "ConnectV2Maker",
"UNISWAP-A": "ConnectV2UniswapV2",
};
const addressMapping = {};
for (const key in connectMapping) {
addressMapping[key] = await deployConnector(connectMapping[key]);
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

View File

@ -1,19 +0,0 @@
const abis = require("./constant/abis");
const addresses = require("./constant/addresses");
const hre = require("hardhat");
const { ethers, waffle } = hre;
const { deployContract } = waffle;
const fs = require("fs")
module.exports = async function ({connectorName, contractArtifact, signer, connectors}) {
const connectorInstanace = await deployContract(signer, contractArtifact, []);
await connectors.connect(signer).addConnectors([connectorName], [connectorInstanace.address])
addresses.connectors[connectorName] = connectorInstanace.address
abis.connectors[connectorName] = contractArtifact.abi;
return connectorInstanace;
};

View File

@ -0,0 +1,25 @@
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
// const { deployContract } = waffle;
import { ethers } from "hardhat";
import { promises as fs } from "fs";
import { deployContract } from "ethereum-waffle";
export async function deployAndEnableConnector({
connectorName,
contractArtifact,
signer,
connectors,
}) {
const connectorInstanace = await deployContract(signer, contractArtifact, []);
await connectors
.connect(signer)
.addConnectors([connectorName], [connectorInstanace.address]);
addresses.connectors[connectorName] = connectorInstanace.address;
abis.connectors[connectorName] = contractArtifact.abi;
return connectorInstanace;
}

View File

@ -1,24 +0,0 @@
const hre = require("hardhat");
const { ethers } = hre;
module.exports = async (connectorName) => {
const Connector = await ethers.getContractFactory(connectorName);
const connector = await Connector.deploy();
await connector.deployed();
console.log(`${connectorName} Deployed: ${connector.address}`);
try {
await hre.run("verify:verify", {
address: connector.address,
constructorArguments: []
}
)
} catch (error) {
console.log(`Failed to verify: ${connectorName}@${connector.address}`)
console.log(error)
console.log()
}
return connector.address
}

View File

@ -0,0 +1,10 @@
import { ethers } from "hardhat";
export const deployConnector = async (connectorName: string) => {
const Connector = await ethers.getContractFactory(connectorName);
const connector = await Connector.deploy();
await connector.deployed();
console.log(`${connectorName} Deployed: ${connector.address}`);
return connector.address;
};

View File

@ -1,18 +0,0 @@
const abis = require("./constant/abis");
const addresses = require("./constant/addresses");
const { web3 } = hre;
module.exports = function (spells) {
const targets = spells.map(a => a.connector)
const calldatas = spells.map(a => {
const functionName = a.method;
// console.log(functionName)
const abi = abis.connectors[a.connector].find(b => {
return b.name === functionName
});
// console.log(functionName)
if (!abi) throw new Error("Couldn't find function")
return web3.eth.abi.encodeFunctionCall(abi, a.args)
})
return [targets, calldatas]
};

18
scripts/encodeSpells.ts Normal file
View File

@ -0,0 +1,18 @@
import { web3 } from "hardhat";
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
export function encodeSpells(spells: any[]) {
const targets = spells.map((a) => a.connector);
const calldatas = spells.map((a) => {
const functionName = a.method;
// console.log(functionName)
const abi = abis.connectors[a.connector].find((b) => {
return b.name === functionName;
});
// console.log(functionName)
if (!abi) throw new Error("Couldn't find function");
return web3.eth.abi.encodeFunctionCall(abi, a.args);
});
return [targets, calldatas];
}

View File

@ -1,9 +1,8 @@
const hre = require("hardhat");
const { ethers } = hre;
const addresses = require("./constant/addresses");
const abis = require("./constant/abis");
import { ethers, network } from "hardhat";
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
module.exports = async function() {
export async function getMasterSigner() {
const [_, __, ___, wallet3] = await ethers.getSigners();
const instaIndex = new ethers.Contract(
addresses.core.instaIndex,
@ -12,7 +11,7 @@ module.exports = async function() {
);
const masterAddress = await instaIndex.master(); // TODO: make it constant?
await hre.network.provider.request({
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [masterAddress],
});
@ -22,4 +21,4 @@ module.exports = async function() {
});
return await ethers.getSigner(masterAddress);
};
}

View File

@ -10,6 +10,5 @@ export const impersonateAccounts = async (accounts: any) => {
signers.push(await ethers.getSigner(account));
}
return signers;
};