UNPKG

@cyberk/hyperion-sdk

Version:

Hyperion SDK from Cyberk

43 lines 1.68 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAllPairsQueryOptions = exports.getAllPairsFn = exports.getAllPairsQueryKey = exports.getAllPairsQueryMsg = void 0; const utils_1 = require("../utils"); const some_1 = __importDefault(require("lodash/some")); const types_1 = require("../utils/types"); const getAllPairsQueryMsg = ({ limit = 100 }) => { return { pairs: { limit, }, }; }; exports.getAllPairsQueryMsg = getAllPairsQueryMsg; const getAllPairsQueryKey = (options) => { return ["allPairs", options.factoryAddress, options.limit]; }; exports.getAllPairsQueryKey = getAllPairsQueryKey; const getAllPairsFn = async (options) => { const { client, factoryAddress } = options; if (!client) { throw new Error("Client is required"); } if (!factoryAddress) { throw new Error("Factory address is required"); } const { pairs } = await (0, utils_1.queryContractSmart)(client, factoryAddress, (0, exports.getAllPairsQueryMsg)(options)); return pairs ?.filter((p) => !(0, some_1.default)(p.asset_infos, (ai) => !!ai.token?.contract_addr)) .map(types_1.transformPairInfo); }; exports.getAllPairsFn = getAllPairsFn; const getAllPairsQueryOptions = (options) => { return { queryFn: async () => (0, exports.getAllPairsFn)(options), queryKey: (0, exports.getAllPairsQueryKey)(options), }; }; exports.getAllPairsQueryOptions = getAllPairsQueryOptions; //# sourceMappingURL=getAllPairs.js.map