"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAggregatorBalances = exports.useAggregatorVaultPageSubgraph = exports.useAggregatorVaultSubgraph = void 0;
var utils_1 = require("../../utils");
var types_1 = require("../../gql/types");
var router_1 = require("../router");
var react_router_dom_1 = require("react-router-dom");
var useError_1 = require("../useError");
var useSubgraphHelper_1 = require("./useSubgraphHelper");
var useAggregatorVaultSubgraph = function (chain, address) {
    var _a, _b;
    var query = (0, types_1.useAggregatorVaultQuery)({
        context: { chain: chain },
        variables: { id: (0, utils_1.getSgId)(address, chain) },
        pollInterval: 20000,
    });
    var error = query.error;
    (0, useError_1.useError)(error);
    return (0, useSubgraphHelper_1.useSubgraphHelper)(query, (_b = (_a = query === null || query === void 0 ? void 0 : query.data) === null || _a === void 0 ? void 0 : _a.aggregatorVault) === null || _b === void 0 ? void 0 : _b.address);
};
exports.useAggregatorVaultSubgraph = useAggregatorVaultSubgraph;
var useAggregatorVaultPageSubgraph = function () {
    var vaultAddress = (0, react_router_dom_1.useParams)().vaultAddress;
    var chain = (0, router_1.useChain)();
    return (0, exports.useAggregatorVaultSubgraph)(chain, vaultAddress);
};
exports.useAggregatorVaultPageSubgraph = useAggregatorVaultPageSubgraph;
var useAggregatorBalances = function (chain, address) {
    var _a, _b;
    var query = (0, types_1.useAggregatorBalancesQuery)({
        context: { chain: chain },
        variables: { id: (0, utils_1.getSgId)(address, chain) },
        pollInterval: 20000,
    });
    var error = query.error;
    (0, useError_1.useError)(error);
    return (0, useSubgraphHelper_1.useSubgraphHelper)(query, (_b = (_a = query === null || query === void 0 ? void 0 : query.data) === null || _a === void 0 ? void 0 : _a.aggregatorVault) === null || _b === void 0 ? void 0 : _b.address);
};
exports.useAggregatorBalances = useAggregatorBalances;
//# sourceMappingURL=useAggregatorVaultSubgraph.js.map