"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chains_1 = require("../helpers/chains");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const markets_1 = require("../helpers/markets");
const rateModelHelpers_1 = require("../helpers/rateModelHelpers");
const func = async function (hre) {
    const { deployments, getNamedAccounts, network } = hre;
    const { deploy } = deployments;
    const chain = (0, chains_1.assertBlockBasedChain)(hre.network.name);
    const { deployer } = await getNamedAccounts();
    // Keeping this hardcoded since 003-deploy-VBep20 (used in subgraph tests) depends on it
    if (!network.live) {
        await deploy("InterestRateModelVUSDC", {
            contract: "JumpRateModel",
            from: deployer,
            log: true,
            autoMine: true,
            args: [0, "50000000000000000", "1090000000000000000", "800000000000000000", deploymentConfig_1.DEFAULT_BLOCKS_PER_YEAR],
        });
        await deploy("InterestRateModelVETH", {
            contract: "JumpRateModel",
            from: deployer,
            log: true,
            autoMine: true,
            args: [0, "40000000000000000", "1080000000000000000", "700000000000000000", deploymentConfig_1.DEFAULT_BLOCKS_PER_YEAR],
        });
    }
    const marketsConfig = markets_1.markets[chain];
    const blocksPerYear = chains_1.blocksPerYear[chain];
    for (const market of marketsConfig) {
        const { interestRateModel, symbol } = market;
        const rateModelName = (0, rateModelHelpers_1.getRateModelName)(interestRateModel, blocksPerYear);
        console.log(`Deploying interest rate model ${rateModelName} for ${symbol}`);
        if (interestRateModel.model === "whitepaper") {
            await deploy(rateModelName, {
                from: deployer,
                contract: "WhitePaperInterestRateModel",
                args: [interestRateModel.baseRatePerYear, interestRateModel.multiplierPerYear, blocksPerYear],
                log: true,
                autoMine: true,
                skipIfAlreadyDeployed: true,
            });
        }
        else if (interestRateModel.model === "jump") {
            await deploy(rateModelName, {
                from: deployer,
                contract: "JumpRateModel",
                args: [
                    interestRateModel.baseRatePerYear,
                    interestRateModel.multiplierPerYear,
                    interestRateModel.jumpMultiplierPerYear,
                    interestRateModel.kink,
                    blocksPerYear,
                ],
                log: true,
                autoMine: true,
                skipIfAlreadyDeployed: true,
            });
        }
        else if (interestRateModel.model === "two-kinks") {
            await deploy(rateModelName, {
                contract: "TwoKinksInterestRateModel",
                from: deployer,
                args: [
                    interestRateModel.baseRatePerYear,
                    interestRateModel.multiplierPerYear,
                    interestRateModel.kink,
                    interestRateModel.multiplierPerYear2,
                    interestRateModel.baseRatePerYear2,
                    interestRateModel.kink2,
                    interestRateModel.jumpMultiplierPerYear,
                    blocksPerYear,
                ],
                log: true,
                autoMine: true,
                skipIfAlreadyDeployed: true,
            });
        }
    }
};
func.tags = ["InterestRateModel"];
func.skip = (0, deploymentConfig_1.skipRemoteNetworks)();
exports.default = func;
