|
| 1 | +import { ethers } from "hardhat"; |
| 2 | +import { DeployFunction } from "hardhat-deploy/dist/types"; |
| 3 | +import { HardhatRuntimeEnvironment } from "hardhat/types"; |
| 4 | + |
| 5 | +import { ADDRESSES, assets } from "../helpers/deploymentConfig"; |
| 6 | + |
| 7 | +const func: DeployFunction = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => { |
| 8 | + const { deploy } = deployments; |
| 9 | + const { deployer } = await getNamedAccounts(); |
| 10 | + |
| 11 | + const oracle = await ethers.getContract("ResilientOracle"); |
| 12 | + const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer; |
| 13 | + |
| 14 | + const { ankrBNB, stkBNB, BNBx, BNBxStakeManager, slisBNBStakeManager, stkBNBStakePool, slisBNB, wBETH } = |
| 15 | + ADDRESSES[network.name]; |
| 16 | + const ETH = assets[network.name].find(asset => asset.token === "ETH"); |
| 17 | + |
| 18 | + await deploy("BNBxOracle", { |
| 19 | + from: deployer, |
| 20 | + log: true, |
| 21 | + deterministicDeployment: false, |
| 22 | + args: [BNBxStakeManager, BNBx, oracle.address], |
| 23 | + proxy: { |
| 24 | + owner: proxyOwnerAddress, |
| 25 | + proxyContract: "OptimizedTransparentProxy", |
| 26 | + }, |
| 27 | + skipIfAlreadyDeployed: true, |
| 28 | + }); |
| 29 | + |
| 30 | + await deploy("SlisBNBOracle", { |
| 31 | + from: deployer, |
| 32 | + log: true, |
| 33 | + deterministicDeployment: false, |
| 34 | + args: [slisBNBStakeManager, slisBNB, oracle.address], |
| 35 | + proxy: { |
| 36 | + owner: proxyOwnerAddress, |
| 37 | + proxyContract: "OptimizedTransparentProxy", |
| 38 | + }, |
| 39 | + skipIfAlreadyDeployed: true, |
| 40 | + }); |
| 41 | + |
| 42 | + await deploy("StkBNBOracle", { |
| 43 | + from: deployer, |
| 44 | + log: true, |
| 45 | + deterministicDeployment: false, |
| 46 | + args: [stkBNBStakePool, stkBNB, oracle.address], |
| 47 | + proxy: { |
| 48 | + owner: proxyOwnerAddress, |
| 49 | + proxyContract: "OptimizedTransparentProxy", |
| 50 | + }, |
| 51 | + skipIfAlreadyDeployed: true, |
| 52 | + }); |
| 53 | + |
| 54 | + let ankrBNBAddress = ankrBNB; |
| 55 | + if (!ankrBNB) { |
| 56 | + // deploy MockAnkrBNB |
| 57 | + await deploy("MockAnkrBNB", { |
| 58 | + from: deployer, |
| 59 | + log: true, |
| 60 | + autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks |
| 61 | + skipIfAlreadyDeployed: true, |
| 62 | + args: ["Ankr Staked BNB ", "ankrBNB", "18"], |
| 63 | + }); |
| 64 | + |
| 65 | + const ankrBNBContract = await ethers.getContract("MockAnkrBNB"); |
| 66 | + ankrBNBAddress = ankrBNBContract.address; |
| 67 | + |
| 68 | + if ((await ankrBNBContract.owner()) === deployer) { |
| 69 | + await ankrBNBContract.transferOwnership(proxyOwnerAddress); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + await deploy("AnkrBNBOracle", { |
| 74 | + from: deployer, |
| 75 | + log: true, |
| 76 | + deterministicDeployment: false, |
| 77 | + args: [ankrBNBAddress, oracle.address], |
| 78 | + proxy: { |
| 79 | + owner: proxyOwnerAddress, |
| 80 | + proxyContract: "OptimizedTransparentProxy", |
| 81 | + }, |
| 82 | + skipIfAlreadyDeployed: true, |
| 83 | + }); |
| 84 | + |
| 85 | + let wBETHAddress = wBETH; |
| 86 | + if (!wBETH) { |
| 87 | + // deploy MockWBETH |
| 88 | + await deploy("MockWBETH", { |
| 89 | + from: deployer, |
| 90 | + log: true, |
| 91 | + autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks |
| 92 | + skipIfAlreadyDeployed: true, |
| 93 | + args: ["Wrapped Binance Beacon ETH", "wBETH", "18"], |
| 94 | + }); |
| 95 | + |
| 96 | + const wBETHContract = await ethers.getContract("MockWBETH"); |
| 97 | + wBETHAddress = wBETHContract.address; |
| 98 | + |
| 99 | + if ((await wBETHContract.owner()) === deployer) { |
| 100 | + await wBETHContract.transferOwnership(proxyOwnerAddress); |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + await deploy("WBETHOracle", { |
| 105 | + from: deployer, |
| 106 | + log: true, |
| 107 | + deterministicDeployment: false, |
| 108 | + args: [wBETHAddress, ETH?.address, oracle.address], |
| 109 | + proxy: { |
| 110 | + owner: proxyOwnerAddress, |
| 111 | + proxyContract: "OptimizedTransparentProxy", |
| 112 | + }, |
| 113 | + skipIfAlreadyDeployed: true, |
| 114 | + }); |
| 115 | +}; |
| 116 | + |
| 117 | +export default func; |
| 118 | +func.tags = ["bnb_lst"]; |
| 119 | +func.skip = async (hre: HardhatRuntimeEnvironment) => |
| 120 | + hre.network.name !== "bscmainnet" && hre.network.name !== "bsctestnet"; |
0 commit comments