"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("ethers/lib/utils");
const hardhat_1 = require("hardhat");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async ({ getNamedAccounts, deployments, network, artifacts, }) => {
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();
    const proxyOwnerAddress = network.live ? deploymentConfig_1.ADDRESSES[network.name].timelock : deployer;
    const defaultProxyAdmin = await artifacts.readArtifact("hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin");
    const { sfrxETH, SfrxEthFraxOracle, acm } = deploymentConfig_1.ADDRESSES[network.name];
    const maxAllowedPriceDifference = (0, utils_1.parseUnits)("1.14", 18);
    await deploy("SFrxETHOracle", {
        contract: "SFrxETHOracle",
        from: deployer,
        log: true,
        deterministicDeployment: false,
        args: [SfrxEthFraxOracle || (await hardhat_1.ethers.getContract("MockSfrxEthFraxOracle")).address, sfrxETH],
        proxy: {
            owner: proxyOwnerAddress,
            proxyContract: "OptimizedTransparentProxy",
            execute: {
                methodName: "initialize",
                args: [acm, maxAllowedPriceDifference],
            },
            viaAdminContract: {
                name: "DefaultProxyAdmin",
                artifact: defaultProxyAdmin,
            },
        },
        skipIfAlreadyDeployed: true,
    });
    const sfrxETHOracle = await hardhat_1.ethers.getContract("SFrxETHOracle");
    if ((await sfrxETHOracle.owner()) === deployer) {
        await sfrxETHOracle.transferOwnership(proxyOwnerAddress);
    }
};
exports.default = func;
func.tags = ["sFraxETHOracle"];
func.skip = async (hre) => hre.network.name !== "ethereum" && hre.network.name !== "sepolia";
//# sourceMappingURL=11-deploy-sfrxeth-oracle.js.map