"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withCreateContracts = void 0;
const ethers_1 = require("ethers");
const AuthoritiesRegistry_1 = __importDefault(require("../../abis/AuthoritiesRegistry"));
const CompoundMarketERC4626_1 = __importDefault(require("../../abis/CompoundMarketERC4626"));
const FlywheelStaticRewards_1 = __importDefault(require("../../abis/FlywheelStaticRewards"));
const ICErc20_1 = __importDefault(require("../../abis/ICErc20"));
const ICErc20PluginRewards_1 = __importDefault(require("../../abis/ICErc20PluginRewards"));
const ILeveredPositionFactory_1 = __importDefault(require("../../abis/ILeveredPositionFactory"));
const ILiquidatorsRegistry_1 = __importDefault(require("../../abis/ILiquidatorsRegistry"));
const IonicComptroller_1 = __importDefault(require("../../abis/IonicComptroller"));
const IonicFlywheel_1 = __importDefault(require("../../abis/IonicFlywheel"));
const IonicFlywheelLensRouter_1 = __importDefault(require("../../abis/IonicFlywheelLensRouter"));
const JumpRateModel_1 = __importDefault(require("../../abis/JumpRateModel"));
const LeveredPosition_1 = __importDefault(require("../../abis/LeveredPosition"));
const LeveredPositionsLens_1 = __importDefault(require("../../abis/LeveredPositionsLens"));
const MasterPriceOracle_1 = __importDefault(require("../../abis/MasterPriceOracle"));
const OptimizedAPRVaultFirstExtension_1 = __importDefault(require("../../abis/OptimizedAPRVaultFirstExtension"));
const OptimizedAPRVaultSecondExtension_1 = __importDefault(require("../../abis/OptimizedAPRVaultSecondExtension"));
const OptimizedVaultsRegistry_1 = __importDefault(require("../../abis/OptimizedVaultsRegistry"));
const PoolLensSecondary_1 = __importDefault(require("../../abis/PoolLensSecondary"));
const PoolRolesAuthority_1 = __importDefault(require("../../abis/PoolRolesAuthority"));
const Unitroller_1 = __importDefault(require("../../abis/Unitroller"));
function withCreateContracts(Base) {
    return class CreateContracts extends Base {
        constructor() {
            super(...arguments);
            this.createUnitroller = this.createContractInstance(Unitroller_1.default);
            this.createIonicFlywheel = this.createContractInstance(IonicFlywheel_1.default);
            this.createFlywheelStaticRewards = this.createContractInstance(FlywheelStaticRewards_1.default);
            this.createJumpRateModel = this.createContractInstance(JumpRateModel_1.default);
        }
        createContractInstance(abi) {
            return (address, signerOrProvider = this.signer) => new ethers_1.Contract(address, abi, signerOrProvider);
        }
        createComptroller(comptrollerAddress, signerOrProvider = this.provider) {
            if (this.chainDeployment.ComptrollerFirstExtension) {
                return new ethers_1.Contract(comptrollerAddress, [...IonicComptroller_1.default], signerOrProvider);
            }
            return new ethers_1.Contract(comptrollerAddress, IonicComptroller_1.default, signerOrProvider);
        }
        createICErc20(address, signerOrProvider = this.provider) {
            return new ethers_1.Contract(address, ICErc20_1.default, signerOrProvider);
        }
        createICErc20PluginRewards(cTokenAddress, signerOrProvider = this.provider) {
            return new ethers_1.Contract(cTokenAddress, ICErc20PluginRewards_1.default, signerOrProvider);
        }
        createMasterPriceOracle(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.MasterPriceOracle.address, MasterPriceOracle_1.default, signerOrProvider);
        }
        createCompoundMarketERC4626(address, signerOrProvider = this.provider) {
            return new ethers_1.Contract(address, CompoundMarketERC4626_1.default, signerOrProvider);
        }
        createOptimizedAPRVault(address, signerOrProvider = this.provider) {
            return new ethers_1.Contract(address, [...OptimizedAPRVaultFirstExtension_1.default, ...OptimizedAPRVaultSecondExtension_1.default], signerOrProvider);
        }
        createOptimizedVaultsRegistry(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.OptimizedVaultsRegistry.address, OptimizedVaultsRegistry_1.default, signerOrProvider);
        }
        createIonicFlywheelLensRouter(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.IonicFlywheelLensRouter.address, IonicFlywheelLensRouter_1.default, signerOrProvider);
        }
        createLeveredPositionFactory(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.LeveredPositionFactory.address, ILeveredPositionFactory_1.default, signerOrProvider);
        }
        createLeveredPosition(address, signerOrProvider = this.provider) {
            return new ethers_1.Contract(address, LeveredPosition_1.default, signerOrProvider);
        }
        createLeveredPositionLens(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.LeveredPositionsLens.address, LeveredPositionsLens_1.default, signerOrProvider);
        }
        createPoolLensSecondary(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.PoolLensSecondary.address, PoolLensSecondary_1.default, signerOrProvider);
        }
        createILiquidatorsRegistry(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.LiquidatorsRegistry.address, ILiquidatorsRegistry_1.default, signerOrProvider);
        }
        createAuthoritiesRegistry(signerOrProvider = this.provider) {
            return new ethers_1.Contract(this.chainDeployment.AuthoritiesRegistry.address, AuthoritiesRegistry_1.default, signerOrProvider);
        }
        createPoolRolesAuthority(poolAuthAddress, signerOrProvider = this.provider) {
            return new ethers_1.Contract(poolAuthAddress, PoolRolesAuthority_1.default, signerOrProvider);
        }
    };
}
exports.withCreateContracts = withCreateContracts;
