Skip to content

Commit

Permalink
Merge pull request #101 from meTokens/chore/rinkeby-deployment
Browse files Browse the repository at this point in the history
Fix deploy script for verification
  • Loading branch information
Carl Farterson authored Jan 21, 2022
2 parents 5873ec8 + da81ffc commit 2b9c09d
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 69 deletions.
24 changes: 12 additions & 12 deletions deployment/script-rinkeby.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"network": "rinkeby",
"Hub Contract Address": "0x7004A5D570f146EB8D57afb65283F5d3f04C7D88",
"VaultRegistry Contract Address": "0xaa95BCFFbD7a33F775f2D9D171F10C553ee92144",
"Migration Registry Contract Address": "0x55e005A2842c2d422723be0d5eFc944E659eD12b",
"SingleAsset Vault Contract Address": "0x4801DF98B65dF6503BD12ac407f38e90382FE053",
"Fee Contract Address": "0x949c7D4Dd835559Fe17E4CfD9e96EB0f9D02bEbc",
"Curve Registry Contract Address": "0x3F2990Df01253dc9e69dA85b3296aA4D3359845b",
"Bancor Curve Contract Address": "0x3Da7482b844c17A96f85e0B6743f19380162A052",
"Foundry Contract Address": "0x0C6c41b169fa60bF5a32d954fc1A28Af3331f4C8",
"MeToken Factory Contract Address": "0x7caFB5DC9ce4F3b805fF8587794f07443D33a491",
"MeToken Registry Contract Address": "0x202232b50A8efcC33cD156D54a1e2A3B118a05C8",
"WeightedAverage Contract Address": "0xE28883Ebc326C62f360cFB48Cf90d754f5c20845",
"Block Number": "9825169"
"Hub Contract Address": "0x179C3360FB84ABffe0a8B1B1e6a34f5c8ABbC11D",
"VaultRegistry Contract Address": "0xcB6E6b3397BfB9924A95EE61A9D4Fd1cc212A44c",
"Migration Registry Contract Address": "0x79C2fBf56FBcC8fC07644AcfDc0bf1b6b95941D9",
"SingleAsset Vault Contract Address": "0x87C4814e062d3b20E9ADA606015A534852a25903",
"Fee Contract Address": "0x27FaC8c1AfBC1d59af397eC767C08Febd193C4e4",
"Curve Registry Contract Address": "0x85044092D586328Be1BA51B1DA8f4bA7a622e7d2",
"Bancor Curve Contract Address": "0x336921185BcC47F721C1c95a890b21dcC06C4C0D",
"Foundry Contract Address": "0x08119868fcac3CDC2801EA5d844120695e4c29Ab",
"MeToken Factory Contract Address": "0x09ca2d1bD89CC50D48468f0e23CC82dc24751F73",
"MeToken Registry Contract Address": "0x8CC8a609fc1354e2bE475545036090e562e4546f",
"WeightedAverage Contract Address": "0x723eC9Cb2471accF91CC23b433053F28aac3463a",
"Block Number": "10028920"
}
129 changes: 72 additions & 57 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import { WeightedAverage } from "../artifacts/types/WeightedAverage";
import { BigNumber } from "ethers";
import { MigrationRegistry } from "../artifacts/types/MigrationRegistry";
import { Fees } from "../artifacts/types/Fees";
import { verifyContract } from "./utils";

const ETHERSCAN_CHAIN_IDS = [1, 3, 4, 5, 42];
const SUPPORTED_NETWORK = [1, 4, 100, 31337];
const deployDir = "deployment";
const contracts: any[] = [];
const contracts: { name?: string; address: string }[] = [];
const REFUND_RATIO = 800000;
const MAX_WEIGHT = 1000000;
const RESERVE_WEIGHT = BigNumber.from(MAX_WEIGHT).div(2).toString();
Expand Down Expand Up @@ -84,31 +86,45 @@ async function main() {

printLog("Deploying weightedAverage Contract...");
const weightedAverage = await deploy<WeightedAverage>("WeightedAverage");
contracts.push(weightedAverage.address);
contracts.push({
address: weightedAverage.address,
});

printLog("Deploying CurveRegistry Contract...");
const curveRegistry = await deploy<CurveRegistry>("CurveRegistry");
contracts.push(curveRegistry.address);
contracts.push({
name: "contracts/registries/CurveRegistry.sol:CurveRegistry",
address: curveRegistry.address,
});

printLog("Deploying VaultRegistry Contract...");
const vaultRegistry = await deploy<VaultRegistry>("VaultRegistry");
contracts.push(vaultRegistry.address);
contracts.push({
name: "contracts/registries/VaultRegistry.sol:VaultRegistry",
address: vaultRegistry.address,
});

printLog("Deploing MigrationRegistry Contract...");
printLog("Deploying MigrationRegistry Contract...");
const migrationRegistry = await deploy<MigrationRegistry>(
"MigrationRegistry"
);
contracts.push(migrationRegistry.address);
contracts.push({
address: migrationRegistry.address,
});

printLog("Deploying Foundry Contract...");
const foundry = await deploy<Foundry>("Foundry", {
WeightedAverage: weightedAverage.address,
});
contracts.push(foundry.address);
contracts.push({
address: foundry.address,
});

printLog("Deploying Hub Contract...");
const hub = await deploy<Hub>("Hub");
contracts.push(hub.address);
contracts.push({
address: hub.address,
});

printLog("Deploying BancorABDK Contract...");
const BancorABDK = await deploy<BancorABDK>(
Expand All @@ -117,11 +133,12 @@ async function main() {
hub.address,
foundry.address
);
contracts.push(BancorABDK.address);

printLog("Deploying MeTokenFactory Contract...");
const meTokenFactory = await deploy<MeTokenFactory>("MeTokenFactory");
contracts.push(meTokenFactory.address);
contracts.push({
address: meTokenFactory.address,
});

printLog("Deploying MeTokenRegistry Contract...");
const meTokenRegistry = await deploy<MeTokenRegistry>(
Expand All @@ -146,7 +163,9 @@ async function main() {

printLog("Deploying fees Contract...");
const fees = await deploy<Fees>("Fees");
contracts.push(fees.address);
contracts.push({
address: fees.address,
});

printLog("Registering Bancor Curve to curve registry...");
let tx = await curveRegistry.approve(BancorABDK.address);
Expand Down Expand Up @@ -203,51 +222,6 @@ async function main() {
);
await tx.wait();
const receipt = await deployer.provider.getTransactionReceipt(tx.hash);
const isEtherscan = ETHERSCAN_CHAIN_IDS.includes(chainId);
if (isEtherscan) {
printLog(`Waiting for Etherscan to index Contracts...`);
await tx.wait(5);
printLog("Verifying Contracts...\n");

const TASK_VERIFY = "verify";

try {
await run(TASK_VERIFY, {
address: singleAssetVault.address,
constructorArgsParams: [
DAO.address, // DAO
foundry.address, // foundry
hub.address, // hub
meTokenRegistry.address, //IMeTokenRegistry
migrationRegistry.address, //IMigrationRegistry
],
});
await run(TASK_VERIFY, {
address: meTokenRegistry.address,
constructorArgsParams: [
foundry.address,
hub.address,
meTokenFactory.address,
migrationRegistry.address,
],
});
} catch (error) {
console.error(`Error verifying ${singleAssetVault.address}: `, error);
}

for (let i = 0; i < contracts.length; ++i) {
try {
await run(TASK_VERIFY, {
address: contracts[i],
constructorArguments: [],
});
} catch (error) {
console.error(`Error verifying ${contracts[i]}: `, error);
}
}

console.log("\nVerified Contracts.");
}
printLog("Deployment done !");

const deploymentInfo = {
Expand All @@ -272,11 +246,52 @@ async function main() {

fs.writeFileSync(
`${deployDir}/script-${network.name}.json`,
JSON.stringify(deploymentInfo)
JSON.stringify(deploymentInfo, undefined, 2)
);
console.log(
`Latest Contract Address written to: ${deployDir}/script-${network.name}.json`
);

const isEtherscan = ETHERSCAN_CHAIN_IDS.includes(chainId);
if (isEtherscan) {
printLog(`Waiting for Etherscan to index Contracts...`);
await tx.wait(5);
printLog("Verifying Contracts...\n");

const TASK_VERIFY = "verify";

await verifyContract("singleAssetVault", singleAssetVault.address, [
DAO.address, // DAO
foundry.address, // foundry
hub.address, // hub
meTokenRegistry.address, //IMeTokenRegistry
migrationRegistry.address, //IMigrationRegistry
]);
await verifyContract("meTokenRegistry", meTokenRegistry.address, [
foundry.address,
hub.address,
meTokenFactory.address,
migrationRegistry.address,
]);
await verifyContract("BancorABDK", BancorABDK.address, [
hub.address,
foundry.address,
]);

for (let i = 0; i < contracts.length; ++i) {
try {
await run(TASK_VERIFY, {
contract: contracts[i].name || undefined,
address: contracts[i].address,
constructorArguments: [],
});
} catch (error) {
console.error(`Error verifying ${contracts[i].address}: `, error);
}
}

console.log("\nVerified Contracts.");
}
}

main()
Expand Down
21 changes: 21 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { run } from "hardhat";

export const verifyContract = async (
contractName: string,
contractAddress: string,
args: any = undefined
) => {
try {
console.log(
`Verifying ${contractName} with ${contractAddress} ${
args ? `with ${args.join(",")}` : ""
}`
);
await run("verify:verify", {
address: contractAddress,
constructorArguments: args,
});
} catch (error) {
console.log(`Error verifying ${contractAddress}: `, error);
}
};

0 comments on commit 2b9c09d

Please sign in to comment.