-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjusted deploy script to use existing ztokens
- Loading branch information
Showing
2 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const { ethers, upgrades } = require("hardhat"); | ||
const fs = require('fs'); | ||
const { AdminClient } = require('@openzeppelin/defender-admin-client'); | ||
const {MAINNET_MULTISIG, DEFENDER_API_KEY, DEFENDER_API_SECRET, MAINNET_DATAFEED} = require('../keystore.json'); | ||
|
||
const client = new AdminClient({ apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_API_SECRET }); | ||
|
||
let ZTokenAbi = require('../contracts/abis/Ztoken.json'); | ||
let OracleAbi = require('../contracts/abis/Oracle.json'); | ||
let VaultAbi = require('../contracts/abis/Vault.json'); | ||
|
||
const datafeed = MAINNET_DATAFEED; | ||
|
||
const MULTISIG = MAINNET_MULTISIG; | ||
|
||
const collateral = "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"; | ||
const Oracle = "0x3dbC7F6b6AB5178C7e0eefbCf361dba1968DbF58"; | ||
const zUSD = "0x9626B9583519E9dAa1C3a7B2E374518743C91ed2"; | ||
|
||
async function deployToken(_name, _symbol) { | ||
const ZToken = await ethers.getContractFactory("ZToken"); | ||
console.log(`deploying ${_name}`); | ||
|
||
const ztoken = await ZToken.deploy(_name, _symbol, MULTISIG); | ||
|
||
await ztoken.waitForDeployment(); | ||
tokens[_name] = ztoken.address; | ||
console.log(`${_name} token is deployed at ${ztoken.target}`); | ||
|
||
return ztoken.target; | ||
} | ||
|
||
async function deployOracle(_admin, _datafeed, _zusd, _zngn, _zzar ,_zxaf) { | ||
const Oracle = await ethers.getContractFactory("BakiOracle"); | ||
console.log("deploying oracle"); | ||
|
||
const oracle = await Oracle.deploy(_admin, _datafeed, _zusd, _zngn, _zzar ,_zxaf); | ||
|
||
await oracle.waitForDeployment(); | ||
|
||
console.log(`oracle is deployed is ${oracle.target}`); | ||
return oracle.target; | ||
} | ||
|
||
async function addContract(_address, _name, _abi) { | ||
const success = await client.addContract({ | ||
network: 'fuji', | ||
address: _address, | ||
name: _name, | ||
abi: _abi, | ||
natSpec: '{devdoc:{...}, userdoc: {...}}', | ||
}); | ||
console.log('success'); | ||
return success; | ||
} | ||
|
||
async function main() { | ||
|
||
console.log("deploying mainnet"); | ||
|
||
const Vault = await ethers.getContractFactory("Vault"); | ||
|
||
// deploy ztokens contracts | ||
// const zUSD = await deployToken("zUSD", "zUSD"); | ||
// const zNGN = await deployToken("zNGN", "zNGN"); | ||
// const zZAR = await deployToken("zZAR", "zZAR"); | ||
// const zXAF = await deployToken("zXAF", "zXAF"); | ||
|
||
// Oracle = await deployOracle(MULTISIG, datafeed, zUSD, zNGN, zZAR, zXAF); | ||
|
||
// console.log(Oracle); | ||
|
||
const vault = await upgrades.deployProxy( | ||
Vault, | ||
[MULTISIG, Oracle, collateral, zUSD], | ||
{ | ||
initializer: "vault_init", | ||
} | ||
); | ||
|
||
await vault.waitForDeployment(); | ||
console.log("Vault deployed to:", vault); | ||
|
||
console.log('Transferring ownership of ProxyAdmin...'); | ||
|
||
await upgrades.admin.transferProxyAdminOwnership(vault.target, MULTISIG); | ||
console.log('Transferred ownership of ProxyAdmin to:', MULTISIG); | ||
|
||
// addContract(zUSD, 'zUSD', JSON.stringify(ZTokenAbi)); | ||
// addContract(zNGN, 'zNGN', JSON.stringify(ZTokenAbi)); | ||
// addContract(zZAR, 'zZAR', JSON.stringify(ZTokenAbi)); | ||
// addContract(zXAF, 'zXAF', JSON.stringify(ZTokenAbi)); | ||
// addContract(Oracle, 'Oracle', JSON.stringify(OracleAbi)); | ||
addContract(vault.target, 'Vault', JSON.stringify(VaultAbi)); | ||
|
||
const filePath = 'keystore.json'; | ||
|
||
fs.unlink(filePath, (err) => { | ||
if (err) { | ||
console.error(`Error deleting file: ${err}`); | ||
return; | ||
} | ||
console.log('File deleted successfully'); | ||
}); | ||
} | ||
|
||
main() |