"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useArrakisPrice = void 0;
var react_1 = require("react");
var common_1 = require("../common");
var utils_1 = require("../../utils");
function useArrakisPrice(vault, helper, t0Decimals) {
    var underlyingStruct = (0, common_1.useCallOnce)(helper === null || helper === void 0 ? void 0 : helper.totalUnderlyingWithFeesAndLeftOver, (vault === null || vault === void 0 ? void 0 : vault.address) || '').res;
    var price = (0, react_1.useMemo)(function () {
        if (!underlyingStruct || t0Decimals == null)
            return;
        var amount0 = underlyingStruct.amount0, amount1 = underlyingStruct.amount1, fee0 = underlyingStruct.fee0, fee1 = underlyingStruct.fee1, leftOver0 = underlyingStruct.leftOver0, leftOver1 = underlyingStruct.leftOver1;
        var totalAmount0 = (0, utils_1.bnToNumber)(amount0.sub(fee0).sub(leftOver0), t0Decimals);
        var totalAmount1 = (0, utils_1.bnToNumber)(amount1.sub(fee1).sub(leftOver1), t0Decimals) || 0;
        if (!totalAmount0)
            return 0;
        var price = totalAmount0 / totalAmount1;
        return price;
    }, [underlyingStruct, t0Decimals]);
    return { price: price };
}
exports.useArrakisPrice = useArrakisPrice;
//# sourceMappingURL=useArrakisPrice.js.map