UNPKG

@cyberk/hyperion-sdk

Version:

Hyperion SDK from Cyberk

33 lines 1.09 kB
import { queryContractSmart } from "../utils"; import some from "lodash/some"; import { transformPairInfo } from "../utils/types"; export const getAllPairsQueryMsg = ({ limit = 100 }) => { return { pairs: { limit, }, }; }; export const getAllPairsQueryKey = (options) => { return ["allPairs", options.factoryAddress, options.limit]; }; export 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 queryContractSmart(client, factoryAddress, getAllPairsQueryMsg(options)); return pairs ?.filter((p) => !some(p.asset_infos, (ai) => !!ai.token?.contract_addr)) .map(transformPairInfo); }; export const getAllPairsQueryOptions = (options) => { return { queryFn: async () => getAllPairsFn(options), queryKey: getAllPairsQueryKey(options), }; }; //# sourceMappingURL=getAllPairs.js.map