diff --git a/scripts/deploy_mainnet_v1.js b/scripts/deploy_mainnet_v1.js index 660ff4a..1d96db3 100644 --- a/scripts/deploy_mainnet_v1.js +++ b/scripts/deploy_mainnet_v1.js @@ -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, @@ -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() { @@ -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(); diff --git a/scripts/deploy_vault_v1.js b/scripts/deploy_vault_v1.js index fdc5787..8df841a 100644 --- a/scripts/deploy_vault_v1.js +++ b/scripts/deploy_vault_v1.js @@ -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(); @@ -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);