"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());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const CTokenFirstExtension_1 = __importDefault(require("../../../abis/CTokenFirstExtension"));
const AdjustableAnkrBNBIrm_json_1 = __importDefault(require("../../../artifacts/AdjustableAnkrBNBIrm.json"));
const utils_1 = require("../utils");
const JumpRateModel_1 = __importDefault(require("./JumpRateModel"));
class AdjustableAnkrBNBIrm extends JumpRateModel_1.default {
    init(interestRateModelAddress, assetAddress, provider) {
        return __awaiter(this, void 0, void 0, function* () {
            const interestRateModelContract = (0, utils_1.getContract)(interestRateModelAddress, AdjustableAnkrBNBIrm_json_1.default.abi, provider);
            this.baseRatePerBlock = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.getBaseRatePerBlock());
            this.multiplierPerBlock = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.getMultiplierPerBlock());
            this.jumpMultiplierPerBlock = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.jumpMultiplierPerBlock());
            this.kink = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.kink());
            const cTokenContract = (0, utils_1.getContract)(assetAddress, CTokenFirstExtension_1.default, provider);
            this.reserveFactorMantissa = ethers_1.BigNumber.from(yield cTokenContract.callStatic.reserveFactorMantissa());
            this.reserveFactorMantissa = this.reserveFactorMantissa.add(ethers_1.BigNumber.from(yield cTokenContract.callStatic.adminFeeMantissa()));
            this.reserveFactorMantissa = this.reserveFactorMantissa.add(ethers_1.BigNumber.from(yield cTokenContract.callStatic.ionicFeeMantissa()));
            this.initialized = true;
        });
    }
    _init(interestRateModelAddress, reserveFactorMantissa, adminFeeMantissa, ionicFeeMantissa, provider) {
        return __awaiter(this, void 0, void 0, function* () {
            const interestRateModelContract = (0, utils_1.getContract)(interestRateModelAddress, AdjustableAnkrBNBIrm_json_1.default.abi, provider);
            this.baseRatePerBlock = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.getBaseRatePerBlock());
            this.multiplierPerBlock = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.getMultiplierPerBlock());
            this.jumpMultiplierPerBlock = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.jumpMultiplierPerBlock());
            this.kink = ethers_1.BigNumber.from(yield interestRateModelContract.callStatic.kink());
            this.reserveFactorMantissa = ethers_1.BigNumber.from(reserveFactorMantissa);
            this.reserveFactorMantissa = this.reserveFactorMantissa.add(ethers_1.BigNumber.from(adminFeeMantissa));
            this.reserveFactorMantissa = this.reserveFactorMantissa.add(ethers_1.BigNumber.from(ionicFeeMantissa));
            this.initialized = true;
        });
    }
}
AdjustableAnkrBNBIrm.RUNTIME_BYTECODE_HASH = ethers_1.utils.keccak256(AdjustableAnkrBNBIrm_json_1.default.deployedBytecode.object);
exports.default = AdjustableAnkrBNBIrm;
