Skip to content

Commit

Permalink
updated mainnet deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
David405 committed Apr 15, 2024
1 parent 89a7a91 commit 14918f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
44 changes: 18 additions & 26 deletions scripts/deploy_mainnet_v1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { ethers, upgrades } = require("hardhat");

const datafeed = process.env.MAINNET_DATAFEED;
const Controller = process.env.MAINNET_CONTROLLER;
const MULTISIG = process.env.MAINNET_MULTISIG;

let tokens = {
zUSD: null,
Expand All @@ -18,33 +18,25 @@ async function deployToken(_name, _symbol) {
const ZToken = await ethers.getContractFactory("ZToken");
console.log(`deploying ${_name}`);

const ztoken = await ZToken.deploy(_name, _symbol);
const ztoken = await ZToken.deploy(_name, _symbol, MULTISIG);

await ztoken.deployed();
await ztoken.waitForDeployment();
tokens[_name] = ztoken.address;
console.log(`${_name} token is deployed at ${ztoken.address}`);
console.log(`${_name} token is deployed at ${ztoken.target}`);

return ztoken.address;
return ztoken.target;
}

async function deployOracle(_datafeed, _zusd, _zngn, _zzar ,_zxaf) {
async function deployOracle(_admin, _datafeed, _zusd, _zngn, _zzar ,_zxaf) {
const Oracle = await ethers.getContractFactory("BakiOracle");
console.log("deploying oracle");

const oracle = await Oracle.deploy(_datafeed, _zusd, _zngn, _zzar ,_zxaf);
const oracle = await Oracle.deploy(_admin, _datafeed, _zusd, _zngn, _zzar ,_zxaf);

await oracle.deployed();
await oracle.waitForDeployment();

console.log(`oracle is deployed is ${oracle.address}`);
return oracle.address;
}

async function setVaultAddress(_name, _vaultAddress) {
const zToken = await hre.ethers.getContractAt("ZToken", tokens[_name]);

const txn = await zToken.addVaultAddress(_vaultAddress);

console.log(`Set Vault address on ${_name}:`, txn.hash);
console.log(`oracle is deployed is ${oracle.target}`);
return oracle.target;
}

async function main() {
Expand All @@ -59,25 +51,25 @@ async function main() {
const zZAR = await deployToken("zZAR", "zZAR");
const zXAF = await deployToken("zXAF", "zXAF");

Oracle = await deployOracle(datafeed, zUSD, zNGN, zZAR, zXAF);
Oracle = await deployOracle(MULTISIG, datafeed, zUSD, zNGN, zZAR, zXAF);

console.log(Oracle);

const vault = await upgrades.deployProxy(
Vault,
[Controller, Oracle, collateral, zUSD],
[MULTISIG, Oracle, collateral, zUSD],
{
initializer: "vault_init",
}
);

await vault.deployed();
console.log("Vault deployed to:", vault.address);
await vault.waitForDeployment();
console.log("Vault deployed to:", vault);

console.log('Transferring ownership of ProxyAdmin...');

await setVaultAddress("zUSD", vault.address);
await setVaultAddress("zNGN", vault.address);
await setVaultAddress("zZAR", vault.address);
await setVaultAddress("zXAF", vault.address);
await upgrades.admin.transferProxyAdminOwnership(vault.target, MULTISIG);
console.log('Transferred ownership of ProxyAdmin to:', MULTISIG);
}

main();
6 changes: 2 additions & 4 deletions scripts/deploy_vault_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ async function main() {
const zZAR = await deployToken("zZAR", "zZAR");
const zXAF = await deployToken("zXAF", "zXAF");

console.log(MULTISIG)

Oracle = await deployOracle(MULTISIG, Datafeed, zUSD, zNGN, zZAR, zXAF);

const collateral = await deployCollateral();
Expand All @@ -101,10 +99,10 @@ async function main() {
);

await vault.waitForDeployment();
console.log("Vault deployed to:", vault.target);
console.log("Vault deployed to:", vault);

console.log('Transferring ownership of ProxyAdmin...');
// The owner of the ProxyAdmin can upgrade our contracts

await upgrades.admin.transferProxyAdminOwnership(vault.target, MULTISIG);
console.log('Transferred ownership of ProxyAdmin to:', MULTISIG);

Expand Down

0 comments on commit 14918f6

Please sign in to comment.