mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
update
This commit is contained in:
parent
e7b0de2dda
commit
7bf4447174
24
scripts/deployAvaxConnector.ts
Normal file
24
scripts/deployAvaxConnector.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import * as hre from "hardhat";
|
||||
const { ethers, deployments, getUnnamedAccounts } = hre;
|
||||
const { deploy } = deployments;
|
||||
|
||||
async function main() {
|
||||
const deployer = (await getUnnamedAccounts())[0];
|
||||
const connector = "ConnectV2InstaPoolV3Avalanche";
|
||||
|
||||
const connectorInstance = await deploy(connector, {
|
||||
from: deployer,
|
||||
});
|
||||
console.log(`${connector} deployed: `, connectorInstance.address);
|
||||
|
||||
await hre.run("sourcify", {
|
||||
address: connectorInstance.address,
|
||||
});
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
79
scripts/deployCompoundMapping.ts
Normal file
79
scripts/deployCompoundMapping.ts
Normal file
|
@ -0,0 +1,79 @@
|
|||
import * as hre from "hardhat";
|
||||
const { ethers } = hre;
|
||||
async function main() {
|
||||
const CONNECTORS_V2 = "0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11";
|
||||
|
||||
const ctokenMapping = {
|
||||
"ETH-A": "0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5",
|
||||
"BAT-A": "0x6c8c6b02e7b2be14d4fa6022dfd6d75921d90e4e",
|
||||
"COMP-A": "0x70e36f6bf80a52b3b46b3af8e106cc0ed743e8e4",
|
||||
"DAI-A": "0x5d3a536e4d6dbd6114cc1ead35777bab948e3643",
|
||||
"REP-A": "0x158079ee67fce2f58472a96584a73c7ab9ac95c1",
|
||||
"UNI-A": "0x35a18000230da775cac24873d00ff85bccded550",
|
||||
"USDC-A": "0x39aa39c021dfbae8fac545936693ac917d5e7563",
|
||||
"USDT-A": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9",
|
||||
"WBTC-A": "0xc11b1268c1a384e55c48c2391d8d480264a3a7f4",
|
||||
"WBTC-B": "0xccF4429DB6322D5C611ee964527D42E5d685DD6a",
|
||||
"ZRX-A": "0xb3319f5d18bc0d84dd1b4825dcde5d5f7266d407",
|
||||
"YFI-A": "0x80a2ae356fc9ef4305676f7a3e2ed04e12c33946",
|
||||
"SUSHI-A": "0x4b0181102a0112a2ef11abee5563bb4a3176c9d7",
|
||||
"MKR-A": "0x95b4ef2869ebd94beb4eee400a99824bf5dc325b",
|
||||
"AAVE-A": "0xe65cdb6479bac1e22340e4e755fae7e509ecd06c",
|
||||
"TUSD-A": "0x12392f67bdf24fae0af363c24ac620a2f67dad86",
|
||||
"LINK-A": "0xface851a4921ce59e912d19329929ce6da6eb0c7",
|
||||
};
|
||||
|
||||
const tokenMapping = {
|
||||
"ETH-A": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
||||
"BAT-A": "0x0D8775F648430679A709E98d2b0Cb6250d2887EF",
|
||||
"COMP-A": "0xc00e94cb662c3520282e6f5717214004a7f26888",
|
||||
"DAI-A": "0x6b175474e89094c44da98b954eedeac495271d0f",
|
||||
"REP-A": "0x1985365e9f78359a9B6AD760e32412f4a445E862",
|
||||
"UNI-A": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
|
||||
"USDC-A": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
||||
"USDT-A": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
||||
"WBTC-A": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||
"WBTC-B": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
||||
"ZRX-A": "0xe41d2489571d322189246dafa5ebde1f4699f498",
|
||||
"YFI-A": "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
|
||||
"SUSHI-A": "0x6B3595068778DD592e39A122f4f5a5cF09C90fE2",
|
||||
"MKR-A": "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2",
|
||||
"AAVE-A": "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9",
|
||||
"TUSD-A": "0x0000000000085d4780B73119b644AE5ecd22b376",
|
||||
"LINK-A": "0x514910771af9ca656af840dff83e8264ecf986ca",
|
||||
};
|
||||
|
||||
const Mapping = await ethers.getContractFactory("InstaCompoundMapping");
|
||||
const mapping = await Mapping.deploy(
|
||||
CONNECTORS_V2,
|
||||
Object.keys(ctokenMapping),
|
||||
Object.values(tokenMapping),
|
||||
Object.values(ctokenMapping)
|
||||
);
|
||||
await mapping.deployed();
|
||||
|
||||
console.log(`InstaCompoundMapping Deployed: ${mapping.address}`);
|
||||
|
||||
try {
|
||||
await hre.run("verify:verify", {
|
||||
address: mapping.address,
|
||||
constructorArguments: [
|
||||
CONNECTORS_V2,
|
||||
Object.keys(ctokenMapping),
|
||||
Object.values(tokenMapping),
|
||||
Object.values(ctokenMapping),
|
||||
],
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(`Failed to verify: InstaCompoundMapping@${mapping.address}`);
|
||||
console.log(error);
|
||||
console.log();
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
111
scripts/deployConnectorsFromCmd.ts
Normal file
111
scripts/deployConnectorsFromCmd.ts
Normal file
|
@ -0,0 +1,111 @@
|
|||
import * as fs from "fs";
|
||||
import { ethers, network, config } from "hardhat";
|
||||
|
||||
let args = process.argv;
|
||||
args = args.splice(2, args.length);
|
||||
let params = {};
|
||||
|
||||
for (let i = 0; i < args.length; i += 2) {
|
||||
if (args[i][0] !== "-" || args[i][1] !== "-") {
|
||||
console.log("Please add '--' for the key");
|
||||
process.exit(-1);
|
||||
}
|
||||
let key = args[i].slice(2, args[i].length);
|
||||
params[key] = args[i + 1];
|
||||
}
|
||||
|
||||
if (!params.hasOwnProperty("connector")) {
|
||||
console.error("Should include connector params");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
if (!params.hasOwnProperty("network")) {
|
||||
console.error("Should include network params");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
if (!params.hasOwnProperty("gasPrice")) {
|
||||
console.error("Should include gas params");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
let privateKey = process.env.PRIVATE_KEY;
|
||||
let provider = new ethers.providers.JsonRpcProvider(
|
||||
config.networks[params["network"]].url
|
||||
);
|
||||
let wallet = new ethers.Wallet(privateKey, provider);
|
||||
|
||||
network.name = params["networkName"];
|
||||
network.config = config.networks[params["networkName"]];
|
||||
network.provider = provider;
|
||||
let contracts = [];
|
||||
|
||||
const parseFile = async (filePath: fs.PathOrFileDescriptor) => {
|
||||
const data = fs.readFileSync(filePath, "utf-8");
|
||||
let parsedData = data.split("contract ");
|
||||
parsedData = parsedData[parsedData.length - 1].split(" ");
|
||||
parsedData = parsedData[0];
|
||||
return parsedData;
|
||||
};
|
||||
|
||||
const parseDir = async (root, basePath, addPath) => {
|
||||
for (let i = 0; i < root.length; i++) {
|
||||
addPath = "/" + root[i];
|
||||
const dir = fs.readdirSync(basePath + addPath);
|
||||
if (dir.indexOf("main.sol") !== -1) {
|
||||
const fileData = await parseFile(basePath + addPath + "/main.sol");
|
||||
contracts.push(fileData);
|
||||
} else {
|
||||
await parseDir(dir, basePath + addPath, "");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
const mainnet = fs.readdirSync("./contracts/mainnet/connectors/");
|
||||
const polygon = fs.readdirSync("./contracts/polygon/connectors/");
|
||||
let basePathMainnet = "./contracts/mainnet/connectors/";
|
||||
let basePathPolygon = "./contracts/polygon/connectors/";
|
||||
|
||||
const connectorName = params["connector"];
|
||||
|
||||
await parseDir(mainnet, basePathMainnet, "");
|
||||
await parseDir(polygon, basePathPolygon, "");
|
||||
|
||||
if (contracts.indexOf(connectorName) === -1) {
|
||||
throw new Error(
|
||||
"can not find the connector!\n" +
|
||||
"supported connector names are:\n" +
|
||||
contracts.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
const Connector = await ethers.getContractFactory(connectorName);
|
||||
const connector = await Connector.connect(wallet).deploy({
|
||||
gasPrice: ethers.utils.parseUnits(params["gasPrice"], "gwei"),
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
return connector.address;
|
||||
};
|
||||
|
||||
main()
|
||||
.then(() => {
|
||||
console.log("Done successfully");
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("error:", err);
|
||||
process.exit(1);
|
||||
});
|
37
scripts/deployInstaMappingController.ts
Normal file
37
scripts/deployInstaMappingController.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import * as hre from "hardhat";
|
||||
const { ethers } = hre;
|
||||
|
||||
async function main() {
|
||||
if (hre.network.name === "mainnet") {
|
||||
console.log("\n\n Deploying Contracts to mainnet. Hit ctrl + c to abort");
|
||||
} else if (hre.network.name === "hardhat") {
|
||||
console.log("\n\n Deploying Contracts to hardhat.");
|
||||
}
|
||||
|
||||
const InstaMappingController = await ethers.getContractFactory(
|
||||
"InstaMappingController"
|
||||
);
|
||||
const instaMappingController = await InstaMappingController.deploy();
|
||||
await instaMappingController.deployed();
|
||||
|
||||
console.log(
|
||||
"InstaMappingController deployed: ",
|
||||
instaMappingController.address
|
||||
);
|
||||
|
||||
if (hre.network.name === "mainnet") {
|
||||
await hre.run("verify:verify", {
|
||||
address: instaMappingController.address,
|
||||
constructorArguments: [],
|
||||
});
|
||||
} else if (hre.network.name === "hardhat") {
|
||||
console.log("Contracts deployed.");
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
34
scripts/deployMappingContract.ts
Normal file
34
scripts/deployMappingContract.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import * as hre from "hardhat";
|
||||
const { ethers } = hre;
|
||||
|
||||
async function main() {
|
||||
if (hre.network.name === "mainnet") {
|
||||
console.log("\n\n Deploying Contracts to mainnet. Hit ctrl + c to abort");
|
||||
} else if (hre.network.name === "hardhat") {
|
||||
console.log("\n\n Deploying Contracts to hardhat.");
|
||||
}
|
||||
|
||||
const mappingContract = "CONTRACT_NAME";
|
||||
|
||||
const InstaProtocolMapping = await ethers.getContractFactory(mappingContract);
|
||||
const instaProtocolMapping = await InstaProtocolMapping.deploy();
|
||||
await instaProtocolMapping.deployed();
|
||||
|
||||
console.log(`${mappingContract} deployed: `, instaProtocolMapping.address);
|
||||
|
||||
if (hre.network.name === "mainnet") {
|
||||
await hre.run("verify:verify", {
|
||||
address: instaProtocolMapping.address,
|
||||
constructorArguments: [],
|
||||
});
|
||||
} else if (hre.network.name === "hardhat") {
|
||||
console.log("Contracts deployed.");
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
27
scripts/deploySingle.ts
Normal file
27
scripts/deploySingle.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import * as hre from "hardhat";
|
||||
const { ethers } = hre;
|
||||
|
||||
const deployConnector = require("./deployConnector");
|
||||
|
||||
async function main() {
|
||||
const address = await deployConnector("ConnectOne"); // Example
|
||||
|
||||
const connectorsAbi = [
|
||||
"function addConnectors(string[] _connectorNames, address[] _connectors)",
|
||||
];
|
||||
|
||||
const connectorsContract = new ethers.Contract(
|
||||
"0x84b457c6D31025d56449D5A01F0c34bF78636f67",
|
||||
connectorsAbi,
|
||||
ethers.provider
|
||||
);
|
||||
|
||||
await connectorsContract.addConnectors(["1inch"], [address]);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
16
scripts/encodeFlashcastData.ts
Normal file
16
scripts/encodeFlashcastData.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { addresses } from "./constant/addresses";
|
||||
import { abis } from "./constant/abis";
|
||||
import * as hre from "hardhat";
|
||||
const { web3 } = hre;
|
||||
|
||||
import { encodeSpells } from "./encodeSpells.js";
|
||||
|
||||
module.exports = function(spells: any) {
|
||||
const encodeSpellsData = encodeSpells(spells);
|
||||
const targetType = "string[]";
|
||||
let argTypes = [targetType, "bytes[]"];
|
||||
return web3.eth.abi.encodeParameters(argTypes, [
|
||||
encodeSpellsData[0],
|
||||
encodeSpellsData[1],
|
||||
]);
|
||||
};
|
Loading…
Reference in New Issue
Block a user