"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCostBasisParams = void 0;
var types_1 = require("./types");
var SMOOTHING = 1;
var getCostBasisParams = function (rebalances) {
    var smoothing = SMOOTHING;
    var initalReb = (rebalances === null || rebalances === void 0 ? void 0 : rebalances[0]) || types_1.emptyRecord;
    var dBase = rebalances.reduce(function (a, r) { return Math.abs(r.dBase) * smoothing + a * (1 - smoothing); }, Math.abs(initalReb.dBase));
    var dQuote = rebalances.reduce(function (a, r) { return Math.abs(r.dQuote) * smoothing + a * (1 - smoothing); }, Math.abs(initalReb.dQuote));
    // smoothed cost basis
    var costBasis = rebalances.reduce(function (a, r) { return r.costBasis * smoothing + a * (1 - smoothing); }, initalReb.costBasis);
    var prevRecord = rebalances[rebalances.length - 1] || types_1.emptyRecord;
    // if rebalancing in same direction as before use prev cost for opposite side
    var adjustLowRange = prevRecord.costBasis > 0 ? true : false;
    var adjustHighRange = prevRecord.costBasis < 0 ? true : false;
    return {
        dBase: dBase,
        dQuote: dQuote,
        costBasis: costBasis,
        adjustLowRange: adjustLowRange,
        adjustHighRange: adjustHighRange,
        prevRecord: prevRecord,
    };
};
exports.getCostBasisParams = getCostBasisParams;
//# sourceMappingURL=uniV3MMUtils.js.map