"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const hardhat_1 = require("hardhat");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = ({ getNamedAccounts, deployments, network, artifacts, }) => __awaiter(void 0, void 0, void 0, function* () {
    const { deploy } = deployments;
    const { deployer } = yield getNamedAccounts();
    const oracle = yield hardhat_1.ethers.getContract("ResilientOracle");
    const proxyOwnerAddress = network.live ? deploymentConfig_1.ADDRESSES[network.name].timelock : deployer;
    const { ankrBNB, stkBNB, BNBx, BNBxStakeManager, slisBNBStakeManager, stkBNBStakePool, slisBNB, wBETH } = deploymentConfig_1.ADDRESSES[network.name];
    const ETH = deploymentConfig_1.assets[network.name].find(asset => asset.token === "ETH");
    const defaultProxyAdmin = yield artifacts.readArtifact("hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin");
    yield deploy("BNBxOracle", {
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [BNBxStakeManager, BNBx, oracle.address],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentUpgradeableProxy",
            viaAdminContract: {
                name: "DefaultProxyAdmin",
                artifact: defaultProxyAdmin,
            },
        },
        skipIfAlreadyDeployed: true,
    });
    yield deploy("SlisBNBOracle", {
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [slisBNBStakeManager, slisBNB, oracle.address],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentUpgradeableProxy",
            viaAdminContract: {
                name: "DefaultProxyAdmin",
                artifact: defaultProxyAdmin,
            },
        },
        skipIfAlreadyDeployed: true,
    });
    yield deploy("StkBNBOracle", {
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [stkBNBStakePool, stkBNB, oracle.address],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentUpgradeableProxy",
            viaAdminContract: {
                name: "DefaultProxyAdmin",
                artifact: defaultProxyAdmin,
            },
        },
        skipIfAlreadyDeployed: true,
    });
    const ankrBNBAddress = ankrBNB || (yield hardhat_1.ethers.getContract("MockAnkrBNB")).address;
    yield deploy("AnkrBNBOracle", {
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [ankrBNBAddress, oracle.address],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentUpgradeableProxy",
            viaAdminContract: {
                name: "DefaultProxyAdmin",
                artifact: defaultProxyAdmin,
            },
        },
        skipIfAlreadyDeployed: true,
    });
    const wBETHAddress = wBETH || (yield hardhat_1.ethers.getContract("MockWBETH")).address;
    yield deploy("WBETHOracle", {
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [wBETHAddress, ETH === null || ETH === void 0 ? void 0 : ETH.address, oracle.address],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentUpgradeableProxy",
            viaAdminContract: {
                name: "DefaultProxyAdmin",
                artifact: defaultProxyAdmin,
            },
        },
        skipIfAlreadyDeployed: true,
    });
});
exports.default = func;
func.tags = ["bnb_lst"];
func.skip = (hre) => __awaiter(void 0, void 0, void 0, function* () { return hre.network.name !== "bscmainnet" && hre.network.name !== "bsctestnet"; });
//# sourceMappingURL=5-deploy-bnb-lst-oracles.js.map