"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("ethers/lib/utils");
const hardhat_1 = require("hardhat");
const hardhat_2 = require("hardhat");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async function (hre) {
    const { deployments, getNamedAccounts } = hre;
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();
    const deployerSigner = await hre.ethers.getSigner(deployer);
    if (!hardhat_2.network.live) {
        const accessControlManagerDeployment = await deploy("AccessControlManager", {
            from: deployer,
            args: [],
            log: true,
            autoMine: true,
        });
        const comptrollerDeployment = await deploy("Unitroller", {
            contract: "ComptrollerMock",
            from: deployer,
            log: true,
            autoMine: true,
            args: [],
        });
        const accessControlManager = await hardhat_1.ethers.getContractAt("AccessControlManager", accessControlManagerDeployment.address);
        const comptroller = await hardhat_1.ethers.getContractAt("ComptrollerMock", comptrollerDeployment.address);
        await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "_supportMarket(address)", deployer);
        await accessControlManager.giveCallPermission(hardhat_1.ethers.constants.AddressZero, "_setLiquidationIncentive(uint256)", deployer);
        await comptroller.connect(deployerSigner)._setAccessControl(accessControlManager.address);
        await comptroller.connect(deployerSigner)._setLiquidationIncentive((0, utils_1.parseUnits)("5", 18));
    }
};
func.tags = ["Comptroller"];
func.skip = (0, deploymentConfig_1.skipRemoteNetworks)();
exports.default = func;
