"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.allStrategyIds = exports.allStrategies = exports.allScyEpochStrategies = exports.allScyStrategies = exports.allRebalancingStrategies = exports.allScionStrategies = exports.strategies = exports.getStrategyContractData = exports.lendStrats = exports.imxLend = exports.levConvex = exports.hlpStrats = exports.imxStrats = exports.symbolToMinTvl = void 0;
var types_1 = require("./types");
var utils_1 = require("../utils");
var stratConfigs_json_1 = __importDefault(require("../stratConfigs.json"));
var common_1 = require("./common");
var address_1 = require("../utils/address");
var contracts_json_1 = __importDefault(require("../contracts.json"));
__exportStar(require("./harvestParams"), exports);
__exportStar(require("./types"), exports);
var common_2 = require("./common");
Object.defineProperty(exports, "symbolToMinTvl", { enumerable: true, get: function () { return common_2.symbolToMinTvl; } });
__exportStar(require("./imxCapacity"), exports);
var StrategyList;
(function (StrategyList) {
    StrategyList["IMX"] = "_list_LLP";
    StrategyList["HLP"] = "_list_HLP";
    StrategyList["levConvex"] = "_list_LCVX";
    StrategyList["imxLending"] = "_list_imxLend";
    StrategyList["Stargate"] = "_list_Stargate";
    StrategyList["Synapse"] = "_list_Synapse";
})(StrategyList || (StrategyList = {}));
var getStrategiesByType = function (type) {
    return getAllInstances(setVersion(stratConfigs_json_1.default[type].map(function (key) { return stratConfigs_json_1.default[key]; })));
};
var DEFAULT_VERSION = 'v0';
var instances = (_a = {},
    _a["HLP_USDC-MOVR_Solar-Well_moonriver_".concat(DEFAULT_VERSION)] = 2,
    _a);
var versions = {};
var getAllInstances = function (configs) {
    return configs.reduce(function (a, c) { return __spreadArray(__spreadArray([], __read(a), false), __read(Array(instances[c.symbol] || 1)
        .fill(undefined)
        .map(function (_, i) { return (__assign(__assign({}, c), { name: "".concat(c.name, "_").concat(i), symbol: "".concat(c.symbol, "_").concat(i) })); })), false); }, []);
};
var setVersion = function (strats) {
    return strats.map(function (s) { return (__assign(__assign({}, s), { name: "".concat(s.name, "_").concat(versions[s.name] || DEFAULT_VERSION), symbol: "".concat(s.name, "_").concat(versions[s.symbol] || DEFAULT_VERSION) })); });
};
exports.imxStrats = getStrategiesByType(StrategyList.IMX).map(function (params) { return (__assign(__assign({}, params), { type: types_1.StrategyType.IMX, performanceFee: common_1.defaults.performanceFee, managementFee: common_1.defaults.managementFee, swap: (0, address_1.getDexFromRouter)(params.pairRouter) })); });
exports.hlpStrats = getStrategiesByType(StrategyList.HLP)
    // .reduce((a, p) => [...a, ...getAllInstances(p)], [])
    .map(function (params) { return (__assign(__assign({}, params), { type: types_1.StrategyType.HLP, performanceFee: common_1.defaults.performanceFee, managementFee: common_1.defaults.managementFee })); });
var deployLevConvex = [
    // 'LCVX_USDC-gUSD-3Crv_Gearbox_mainnet',
    // 'USDC-FRAX3CRV-levConvex',
    // 'USDC-lUSD-levConvex',
    'LCVX_USDC-sUSD_Gearbox_mainnet',
    // 'USDC-FRAXUSDC-levConvex'
];
exports.levConvex = getStrategiesByType(StrategyList.levConvex)
    .filter(function (s) {
    var e_1, _a;
    try {
        for (var deployLevConvex_1 = __values(deployLevConvex), deployLevConvex_1_1 = deployLevConvex_1.next(); !deployLevConvex_1_1.done; deployLevConvex_1_1 = deployLevConvex_1.next()) {
            var deploy = deployLevConvex_1_1.value;
            if (s.symbol.match(deploy))
                return true;
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (deployLevConvex_1_1 && !deployLevConvex_1_1.done && (_a = deployLevConvex_1.return)) _a.call(deployLevConvex_1);
        }
        finally { if (e_1) throw e_1.error; }
    }
})
    // .reduce((a, p) => [...a, ...getAllInstances(p)], [])
    .map(function (params) { return (__assign(__assign({}, params), { contract: params.is3crv ? 'levConvex3Crv' : 'levConvex', harvestPath: params.harvestPaths, type: types_1.StrategyType.LCVX, performanceFee: common_1.defaults.performanceFee, managementFee: common_1.defaults.managementFee })); });
exports.imxLend = getStrategiesByType(StrategyList.imxLending).map(function (params) { return (__assign(__assign({}, params), { type: types_1.StrategyType.IMXL, yieldToken: params.strategy, strategyId: 0, contract: 'IMXLendStrategy', performanceFee: common_1.defaults.performanceFee, managementFee: common_1.defaults.managementFee })); });
exports.lendStrats = __spreadArray(__spreadArray(__spreadArray([], __read(getStrategiesByType(StrategyList.Stargate).map(function (params) { return (__assign(__assign({}, params), { type: types_1.StrategyType.LND, contract: 'StargateStrategy', performanceFee: common_1.defaults.performanceFee, managementFee: common_1.defaults.managementFee })); })), false), __read(getStrategiesByType(StrategyList.Synapse).map(function (params) { return (__assign(__assign({}, params), { type: types_1.StrategyType.LND, contract: 'SynapseStrategy', performanceFee: common_1.defaults.performanceFee, managementFee: common_1.defaults.managementFee })); })), false), __read(exports.imxLend), false);
// start contracts
var getStrategyContractData = function (chain, id) {
    var _a, _b, _c;
    var chainId = (_a = utils_1.CHAIN_IDS[chain]) === null || _a === void 0 ? void 0 : _a.toString();
    return (_c = (_b = contracts_json_1.default[chainId]) === null || _b === void 0 ? void 0 : _b.find(function (c) { return c.name === chain; })) === null || _c === void 0 ? void 0 : _c.contracts[id];
};
exports.getStrategyContractData = getStrategyContractData;
exports.strategies = __spreadArray([], __read(exports.hlpStrats), false);
exports.allScionStrategies = __spreadArray([], __read(exports.hlpStrats), false);
exports.allRebalancingStrategies = __spreadArray(__spreadArray(__spreadArray([], __read(exports.imxStrats), false), __read(exports.hlpStrats), false), __read(exports.levConvex), false);
exports.allScyStrategies = __spreadArray(__spreadArray(__spreadArray([], __read(exports.imxStrats), false), __read(exports.lendStrats), false), __read(exports.hlpStrats), false);
exports.allScyEpochStrategies = __spreadArray([], __read(exports.levConvex), false);
exports.allStrategies = __spreadArray(__spreadArray(__spreadArray([], __read(exports.allScionStrategies), false), __read(exports.allScyStrategies), false), __read(exports.allScyEpochStrategies), false);
exports.allStrategyIds = exports.allStrategies.map(function (x) { return x.symbol; });
//# sourceMappingURL=index.js.map