"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePriceOffsetSlippage = void 0;
var react_1 = require("react");
var hooks_1 = require("../../hooks");
var utils_1 = require("../../utils");
var DEFAULT_ADD_TO_SLIPPAGE = 60;
var usePriceOffsetSlippage = function (strategy, addToSlippage) {
    if (addToSlippage === void 0) { addToSlippage = DEFAULT_ADD_TO_SLIPPAGE; }
    var priceOffsetBN = (0, hooks_1.useCallPoll)(10, strategy === null || strategy === void 0 ? void 0 : strategy.getPriceOffset).res;
    var slippage = (0, react_1.useMemo)(function () { return priceOffsetBN === null || priceOffsetBN === void 0 ? void 0 : priceOffsetBN.add(addToSlippage); }, [priceOffsetBN, addToSlippage]);
    var priceOffsetFmt = (0, react_1.useMemo)(function () { return (0, utils_1.formatPercentageBN)(priceOffsetBN, 4); }, [priceOffsetBN]);
    var addToSlippageFmt = (0, react_1.useMemo)(function () { return (0, utils_1.formatPercentageBN)(addToSlippage, 4); }, [addToSlippage]);
    var slippageFmt = (0, react_1.useMemo)(function () { return (0, utils_1.formatPercentageBN)(slippage, 4); }, [slippage]);
    var slippageDescription = (0, react_1.useMemo)(function () {
        return "Price Offset: ".concat(priceOffsetFmt, " + ").concat(addToSlippageFmt, " = ").concat(slippageFmt);
    }, [priceOffsetFmt, addToSlippageFmt, slippageFmt]);
    return { slippage: slippage, slippageDescription: slippageDescription };
};
exports.usePriceOffsetSlippage = usePriceOffsetSlippage;
//# sourceMappingURL=usePriceOffsetSlippage.js.map