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());
    });
};
import { LiquidationStrategy } from "@ionicprotocol/types";
import { getUniswapV2Router } from "./redemptionStrategy";
const estimateGas = (sdk, borrower, liquidationAmount, strategiesAndDatas, flashSwapPair, liquidationStrategy, debtFundingStrategies, debtFundingStrategiesData) => __awaiter(void 0, void 0, void 0, function* () {
    switch (liquidationStrategy) {
        case LiquidationStrategy.DEFAULT:
            return yield sdk.contracts.IonicLiquidator.estimateGas.safeLiquidate(borrower.account, liquidationAmount, borrower.debt[0].cToken, borrower.collateral[0].cToken, 0, {
                gasLimit: 1e9,
                from: process.env.ETHEREUM_ADMIN_ACCOUNT
            });
        case LiquidationStrategy.UNISWAP:
            return yield sdk.contracts.IonicLiquidator.estimateGas.safeLiquidateToTokensWithFlashLoan({
                borrower: borrower.account,
                repayAmount: liquidationAmount,
                cErc20: borrower.debt[0].cToken,
                cTokenCollateral: borrower.collateral[0].cToken,
                minProfitAmount: 0,
                uniswapV2RouterForBorrow: sdk.chainSpecificAddresses.UNISWAP_V2_ROUTER,
                uniswapV2RouterForCollateral: getUniswapV2Router(sdk, borrower.collateral[0].cToken),
                redemptionStrategies: strategiesAndDatas.strategies,
                strategyData: strategiesAndDatas.datas,
                flashSwapPair,
                debtFundingStrategies,
                debtFundingStrategiesData
            }, {
                gasLimit: 1e9,
                from: process.env.ETHEREUM_ADMIN_ACCOUNT
            });
    }
});
export default estimateGas;
