Skip to content

Commit

Permalink
Update deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatHB committed Sep 24, 2021
1 parent 914e8ff commit 38f7d57
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 16 deletions.
9 changes: 7 additions & 2 deletions deploy/01_MaidCafe.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { getWethAddress } = require("../scripts/utils");
const { getWethAddress, multiSigWallet } = require("../scripts/utils");

module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
const { deployer } = await getNamedAccounts();
const { deploy, get } = deployments;
const { deploy, get, read, execute } = deployments;

const chainId = await getChainId();
const maidCoin = (await get("MaidCoin")).address;
Expand All @@ -13,4 +13,9 @@ module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
args: [maidCoin, weth],
log: true,
});

if ((await read("MaidCafe", {log: true}, "owner")) !== multiSigWallet) {
console.log("Transfer MaidCafe Ownership to the multi-sig wallet");
await execute("MaidCafe", { from: deployer }, "transferOwnership", multiSigWallet);
}
};
14 changes: 11 additions & 3 deletions deploy/02_TheMaster.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { constants } = require("ethers");
const { network } = require("hardhat");
const { getPairAddress, getWethAddress, getSushiAddress } = require("../scripts/utils");

module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
Expand All @@ -7,15 +8,22 @@ module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {

const chainId = await getChainId();
const initialRewardPerBlock = constants.WeiPerEther;
const decreasingInterval = 520000;
const startBlock = 13266456; // TODO: update
const decreasingInterval = 525600;
const startBlock = 13316000;
const maidCoin = (await get("MaidCoin")).address;
const pair = getPairAddress(chainId, maidCoin, getWethAddress(chainId));
const sushi = getSushiAddress(chainId);

await deploy("TheMaster", {
const theMaster = await deploy("TheMaster", {
from: deployer,
args: [initialRewardPerBlock, decreasingInterval, startBlock, maidCoin, pair, sushi],
log: true,
});

if (network.name !== "mainnet") {
const owner = await read("MaidCoin", {}, "owner");
if (owner !== theMaster.address) {
await execute("MaidCoin", { from: deployer }, "transferOwnership", theMaster.address);
}
}
};
9 changes: 7 additions & 2 deletions deploy/03_Maids.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { getPairAddress, getWethAddress, getSushiAddress } = require("../scripts/utils");
const { getPairAddress, getWethAddress, getSushiAddress, multiSigWallet } = require("../scripts/utils");

module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
const { deployer } = await getNamedAccounts();
const { deploy, get } = deployments;
const { deploy, get, read, execute } = deployments;

const chainId = await getChainId();
const maidCoin = (await get("MaidCoin")).address;
Expand All @@ -15,4 +15,9 @@ module.exports = async ({ getNamedAccounts, deployments, getChainId }) => {
args: [pair, sushi, maidCafe],
log: true,
});

if ((await read("Maids", {log: true}, "owner")) !== multiSigWallet) {
console.log("Transfer Maids Ownership to the multi-sig wallet");
await execute("Maids", { from: deployer }, "transferOwnership", multiSigWallet);
}
};
9 changes: 8 additions & 1 deletion deploy/05_CloneNurses.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { multiSigWallet } = require("../scripts/utils");

module.exports = async ({ getNamedAccounts, deployments }) => {
const { deployer } = await getNamedAccounts();
const { deploy, get } = deployments;
const { deploy, get, read, execute } = deployments;

const nursePart = (await get("NursePart")).address;
const maidCoin = (await get("MaidCoin")).address;
Expand All @@ -12,4 +14,9 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
args: [nursePart, maidCoin, theMaster, maidCafe],
log: true,
});

if ((await read("CloneNurses", {log: true}, "owner")) !== multiSigWallet) {
console.log("Transfer CloneNurses Ownership to the multi-sig wallet");
await execute("CloneNurses", { from: deployer }, "transferOwnership", multiSigWallet);
}
};
31 changes: 26 additions & 5 deletions deploy/06_NurseRaid.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
const { constants } = require("ethers");
const { getSushiGirlsAddress, getLingerieGirlsAddress, getRNGAddress, multiSigWallet } = require("../scripts/utils");

module.exports = async ({ getNamedAccounts, deployments }) => {
const { deployer } = await getNamedAccounts();
const { deploy, get } = deployments;
const { deploy, get, read, execute } = deployments;

const maidCoin = (await get("MaidCoin")).address;
const maidCafe = (await get("MaidCafe")).address;
const nursePart = (await get("NursePart")).address;
const rng = constants.AddressZero; // TODO: replace with the real address
const nurses = (await get("CloneNurses")).address;
const maids = (await get("Maids")).address;

const chainId = await getChainId();
const rng = getRNGAddress(chainId);
const sgirls = getSushiGirlsAddress(chainId);
const lgirls = getLingerieGirlsAddress(chainId);

await deploy("NurseRaid", {
const raid = await deploy("NurseRaid", {
from: deployer,
args: [maidCoin, maidCafe, nursePart, rng],
args: [maidCoin, maidCafe, nursePart, nurses, rng, sgirls, lgirls],
log: true,
});

if ((await read("NursePart", { log: true }, "owner")) !== raid.address) {
console.log("Transfer NursePart Ownership to the NurseRaid");
await execute("NursePart", { from: deployer }, "transferOwnership", raid.address);
}

if (raid.newlyDeployed) {
console.log("Approve Maids to NurseRaid");
await execute("NurseRaid", { from: deployer }, "approveMaids", [maids, lgirls, sgirls]);
}

if ((await read("NurseRaid", { log: true }, "owner")) !== multiSigWallet) {
console.log("Transfer NurseRaid Ownership to the multi-sig wallet");
await execute("NurseRaid", { from: deployer }, "transferOwnership", multiSigWallet);
}
};
31 changes: 28 additions & 3 deletions deploy/07_MasterCoin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
module.exports = async ({ getNamedAccounts, deployments }) => {
require("dotenv").config();
const { getPairAddress, getWethAddress } = require("../scripts/utils");

module.exports = async ({ ethers, getNamedAccounts, deployments }) => {
const { deployer } = await getNamedAccounts();
const { deploy } = deployments;
const { deploy, get, execute } = deployments;

await deploy("MasterCoin", {
const result = await deploy("MasterCoin", {
from: deployer,
args: [],
log: true,
});

{
console.log("Transfer MasterCoin to the devs");
await execute("MasterCoin", { from: deployer }, "transfer", process.env.DEV0, ethers.utils.parseEther("27.3"));
await execute("MasterCoin", { from: deployer }, "transfer", process.env.DEV1, ethers.utils.parseEther("27.3"));
await execute("MasterCoin", { from: deployer }, "transfer", process.env.DEV2, ethers.utils.parseEther("27.3"));
await execute("MasterCoin", { from: deployer }, "transfer", process.env.DEV3, ethers.utils.parseEther("15.1"));
}

if (result.newlyDeployed) {
const chainId = await getChainId();
const pair = getPairAddress(chainId, maidCoin, getWethAddress(chainId));
const nurses = (await get("CloneNurses")).address;
const masterCoin = result.address;

console.log("Add initial pools to TheMaster");

await execute("TheMaster", { from: deployer }, "add", masterCoin, false, false, ethers.constants.AddressZero, 0, 100);
await execute("TheMaster", { from: deployer }, "add", pair, false, false, ethers.constants.AddressZero, 0, 600);
await execute("TheMaster", { from: deployer }, "add", nurses, true, true, ethers.constants.AddressZero, 0, 300);
await execute("TheMaster", { from: deployer }, "add", pair, false, false, nurses, 30, 0);
}
};
42 changes: 42 additions & 0 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,52 @@ const getFactoryAddress = chainId => {
}
};

const multiSigWallet = "0x30080df30F21a710B31F5fC7FA149a5c452eABFa";

const getSushiGirlsAddress = chainId => {
if(chainId === "1") {
return "0xEB3b418e4A4430392Cd57b1356c5B1d2205A56d9";
} else if(chainId === "3") {
return "0x9fF326fecc05A5560Eea1A66C6c62a93a64afaFb";
} else if(chainId === "42") {
return "0xC85A160adbb5E7D22E0d764f03207090ae72197F";
} else {
throw new Error("Network not supported");
}
};

const getLingerieGirlsAddress = chainId => {
if(chainId === "1") {
return "0x579a60fbc649d3398f13e0385dbe79b3ffad757c";
} else if(chainId === "3") {
return "0xf35f860762540929B3157765B82E6616664f7e97";
} else if(chainId === "42") {
return "0xB555cA9C88CeB8ece57b9223AA6D7407dD273656";
} else {
throw new Error("Network not supported");
}
};

const getRNGAddress = chainId => {
if(chainId === "1") {
return ""; //TODO: mainnet address
} else if(chainId === "3") {
return "0x188d3C00FEC2e410DFDca7aaF0e0D386B0419603";
} else if(chainId === "42") {
return "0x965B1c306b7AFc8C680185D72B26a32520B971b8";
} else {
throw new Error("Network not supported");
}
};

module.exports = {
INIT_CODE_HASH,
getSushiAddress,
getWethAddress,
getPairAddress,
getFactoryAddress,
multiSigWallet,
getSushiGirlsAddress,
getLingerieGirlsAddress,
getRNGAddress,
};

0 comments on commit 38f7d57

Please sign in to comment.