"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("ethers/lib/utils");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async function (hre) {
    const { deployments, network, getNamedAccounts } = hre;
    const { deploy, catchUnknownSigner } = deployments;
    const { deployer } = await getNamedAccounts();
    const comptrollerAddress = (await deployments.get("Unitroller")).address;
    const accessControlManagerAddress = (await deployments.get("AccessControlManager")).address;
    const treasuryAddress = (await deployments.get(hre.network.name.includes("bsc") ? "VTreasury" : "VTreasuryV8"))
        .address;
    const timelockAddress = (await deployments.get("NormalTimelock")).address;
    const vbnbAddress = (await deployments.get("vBNB")).address;
    const wbnbAddress = (await deployments.get("WBNB")).address;
    const TREASURY_PERCENT = (0, utils_1.parseUnits)("0.05", 18);
    await catchUnknownSigner(deploy("Liquidator", {
        contract: "Liquidator",
        from: deployer,
        args: [comptrollerAddress, vbnbAddress, wbnbAddress],
        log: true,
        autoMine: true,
        proxy: {
            owner: network.name === "hardhat" ? deployer : timelockAddress,
            proxyContract: "OpenZeppelinTransparentProxy",
            execute: {
                methodName: "initialize",
                args: [TREASURY_PERCENT, accessControlManagerAddress, treasuryAddress],
            },
        },
    }));
};
func.tags = ["liquidator-upgrade"];
func.skip = (0, deploymentConfig_1.skipRemoteNetworks)();
exports.default = func;
