"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 }) => __awaiter(void 0, void 0, void 0, function* () {
    var _a;
    const { deploy } = deployments;
    const { deployer } = yield getNamedAccounts();
    console.log(`Deployer ${deployer}`);
    const networkName = network.name === "hardhat" ? "bsctestnet" : network.name;
    const proxyOwnerAddress = network.live ? deploymentConfig_1.ADDRESSES[networkName].timelock : deployer;
    const { stETHAddress, wstETHAddress } = deploymentConfig_1.ADDRESSES[networkName];
    const WETHAsset = deploymentConfig_1.assets[networkName].find(asset => asset.token === "WETH");
    const WETHAddress = (_a = WETHAsset === null || WETHAsset === void 0 ? void 0 : WETHAsset.address) !== null && _a !== void 0 ? _a : deploymentConfig_1.addr0000;
    const oracle = yield hardhat_1.ethers.getContract("ResilientOracle");
    yield deploy("WstETHOracle_Equivalence", {
        contract: "WstETHOracle",
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [wstETHAddress, WETHAddress, stETHAddress, oracle.address, true],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentProxy",
        },
    });
    yield deploy("WstETHOracle_NonEquivalence", {
        contract: "WstETHOracle",
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [wstETHAddress, WETHAddress, stETHAddress, oracle.address, false],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentProxy",
        },
    });
});
exports.default = func;
func.tags = ["wsteth"];
func.skip = (hre) => __awaiter(void 0, void 0, void 0, function* () { return hre.network.name !== "ethereum" && hre.network.name !== "sepolia"; });
//# sourceMappingURL=4-deploy-wstETH-oracle.js.map