@symmio/trading-core 3.6.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +248 -246
- package/dist/pools/markets/get-listing-markets.d.ts +2 -0
- package/dist/pools/markets/get-listing-markets.d.ts.map +1 -1
- package/dist/pools/markets/get-listing-markets.js +1 -0
- package/dist/pools/markets/get-listing-markets.js.map +1 -1
- package/dist/pools/markets/query.d.ts.map +1 -1
- package/dist/pools/markets/query.js +1 -0
- package/dist/pools/markets/query.js.map +1 -1
- package/dist/pools/markets/to-search-params.d.ts +1 -0
- package/dist/pools/markets/to-search-params.d.ts.map +1 -1
- package/dist/pools/markets/to-search-params.js +1 -1
- package/dist/pools/markets/to-search-params.js.map +1 -1
- package/dist/solvers/estimated-price/get-estimated-price.d.ts +2 -0
- package/dist/solvers/estimated-price/get-estimated-price.d.ts.map +1 -1
- package/dist/solvers/estimated-price/get-estimated-price.js +4 -1
- package/dist/solvers/estimated-price/get-estimated-price.js.map +1 -1
- package/dist/solvers/estimated-price/query.d.ts +6 -2
- package/dist/solvers/estimated-price/query.d.ts.map +1 -1
- package/dist/solvers/estimated-price/query.js +3 -2
- package/dist/solvers/estimated-price/query.js.map +1 -1
- package/dist/solvers/funding-info/adapters/enigma-funding-info.d.ts +4 -0
- package/dist/solvers/funding-info/adapters/enigma-funding-info.d.ts.map +1 -0
- package/dist/solvers/funding-info/adapters/enigma-funding-info.js +17 -0
- package/dist/solvers/funding-info/adapters/enigma-funding-info.js.map +1 -0
- package/dist/solvers/funding-info/adapters/rasa-funding-info.d.ts +4 -0
- package/dist/solvers/funding-info/adapters/rasa-funding-info.d.ts.map +1 -0
- package/dist/solvers/funding-info/adapters/rasa-funding-info.js +21 -0
- package/dist/solvers/funding-info/adapters/rasa-funding-info.js.map +1 -0
- package/dist/solvers/funding-info/get-funding-info.d.ts +22 -13
- package/dist/solvers/funding-info/get-funding-info.d.ts.map +1 -1
- package/dist/solvers/funding-info/get-funding-info.js +24 -12
- package/dist/solvers/funding-info/get-funding-info.js.map +1 -1
- package/dist/solvers/funding-info/query.d.ts +14 -6
- package/dist/solvers/funding-info/query.d.ts.map +1 -1
- package/dist/solvers/funding-info/query.js +1 -0
- package/dist/solvers/funding-info/query.js.map +1 -1
- package/dist/solvers/funding-info/to-funding-info.d.ts +8 -4
- package/dist/solvers/funding-info/to-funding-info.d.ts.map +1 -1
- package/dist/solvers/funding-info/to-funding-info.js +2 -1
- package/dist/solvers/funding-info/to-funding-info.js.map +1 -1
- package/dist/solvers/funding-info/types.d.ts +26 -4
- package/dist/solvers/funding-info/types.d.ts.map +1 -1
- package/dist/solvers/market-info/adapters/enigma-market-info.d.ts +3 -3
- package/dist/solvers/market-info/adapters/enigma-market-info.d.ts.map +1 -1
- package/dist/solvers/market-info/adapters/enigma-market-info.js +7 -5
- package/dist/solvers/market-info/adapters/enigma-market-info.js.map +1 -1
- package/dist/solvers/market-info/get-market-info.d.ts +3 -2
- package/dist/solvers/market-info/get-market-info.d.ts.map +1 -1
- package/dist/solvers/market-info/get-market-info.js.map +1 -1
- package/dist/solvers/market-info/types.d.ts +4 -3
- package/dist/solvers/market-info/types.d.ts.map +1 -1
- package/dist/solvers/notional-cap/get-notional-cap-all.d.ts +10 -10
- package/dist/solvers/notional-cap/get-notional-cap-all.d.ts.map +1 -1
- package/dist/solvers/notional-cap/get-notional-cap-all.js +26 -23
- package/dist/solvers/notional-cap/get-notional-cap-all.js.map +1 -1
- package/dist/solvers/notional-cap/get-notional-cap-page.d.ts +49 -0
- package/dist/solvers/notional-cap/get-notional-cap-page.d.ts.map +1 -0
- package/dist/solvers/notional-cap/get-notional-cap-page.js +37 -0
- package/dist/solvers/notional-cap/get-notional-cap-page.js.map +1 -0
- package/dist/solvers/notional-cap/index.d.ts +2 -0
- package/dist/solvers/notional-cap/index.d.ts.map +1 -1
- package/dist/solvers/notional-cap/query-page.d.ts +45 -0
- package/dist/solvers/notional-cap/query-page.d.ts.map +1 -0
- package/dist/solvers/notional-cap/query-page.js +26 -0
- package/dist/solvers/notional-cap/query-page.js.map +1 -0
- package/dist/solvers/symbols/get-symbols.d.ts +3 -2
- package/dist/solvers/symbols/get-symbols.d.ts.map +1 -1
- package/dist/solvers/symbols/get-symbols.js +17 -3
- package/dist/solvers/symbols/get-symbols.js.map +1 -1
- package/dist/solvers/trade-volume/get-trade-volume.d.ts +2 -1
- package/dist/solvers/trade-volume/get-trade-volume.d.ts.map +1 -1
- package/dist/solvers/trade-volume/get-trade-volume.js +6 -1
- package/dist/solvers/trade-volume/get-trade-volume.js.map +1 -1
- package/dist/solvers/trade-volume/to-daily-volume.d.ts +6 -6
- package/dist/solvers/trade-volume/to-daily-volume.js.map +1 -1
- package/dist/solvers/trade-volume/types.d.ts +4 -3
- package/dist/solvers/trade-volume/types.d.ts.map +1 -1
- package/dist/solvers/types/generated/enigma-solver.js +3 -3
- package/dist/solvers/types/generated/enigma-solver.js.map +1 -1
- package/dist/solvers/types/generated/rasa-solver.js +8 -2
- package/dist/solvers/types/generated/rasa-solver.js.map +1 -1
- package/package.json +3 -3
|
@@ -23,6 +23,8 @@ export type GetListingMarketsParameters = Compute<ChainIdParameter & {
|
|
|
23
23
|
chainIds?: readonly ListingDepositChainId[];
|
|
24
24
|
/** Restrict to one lifecycle status. */
|
|
25
25
|
marketStatus?: ListingMarketStatus;
|
|
26
|
+
/** Filter by inventory lock state. Omit for both; false explicitly requests unlocked markets. */
|
|
27
|
+
isLocked?: boolean;
|
|
26
28
|
/** Page size, `1`–`100`. Service default `20`. */
|
|
27
29
|
limit?: number;
|
|
28
30
|
/** Row offset. Service default `0`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-listing-markets.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/get-listing-markets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAKlB;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAC/C,gBAAgB,GAAG;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC5C,wCAAwC;IACxC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,gDAAgD;IAChD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,uCAAuC;IACvC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC,CACF,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,2BAAgC,GAC3C,OAAO,CAAC,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"get-listing-markets.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/get-listing-markets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE/E,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAKlB;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAC/C,gBAAgB,GAAG;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC5C,wCAAwC;IACxC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,iGAAiG;IACjG,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,gDAAgD;IAChD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,uCAAuC;IACvC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC,CACF,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,2BAAgC,GAC3C,OAAO,CAAC,2BAA2B,CAAC,CAwCtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-listing-markets.js","names":[],"sources":["../../../src/pools/markets/get-listing-markets.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type {\n ListingDepositChainId,\n ListingMarketFilters,\n ListingMarketPage,\n ListingMarketSortField,\n ListingMarketStatus,\n ListingSortDirection,\n} from \"../types\";\nimport { marketSearchV2MarketSearchGet } from \"../types/generated/listing-backend\";\nimport { toListingMarketPage } from \"./to-listing-market\";\nimport { toSearchParams } from \"./to-search-params\";\n\n/**\n * Parameters for {@link getListingMarkets}.\n *\n * Every field is optional: with none set the service returns its default first\n * page (20 rows, newest-listed first).\n */\nexport type GetListingMarketsParameters = Compute<\n ChainIdParameter & {\n /**\n * Free-text search, matched against contract address, ticker, and token\n * name.\n *\n * Named `search` rather than `query` because the TanStack options bag on the\n * matching query factory already owns `query`.\n */\n search?: string;\n /**\n * Restrict to tokens deposited on these chains. An empty array is sent as\n * no filter, matching the service's behavior for an absent param.\n */\n chainIds?: readonly ListingDepositChainId[];\n /** Restrict to one lifecycle status. */\n marketStatus?: ListingMarketStatus;\n /** Page size, `1`–`100`. Service default `20`. */\n limit?: number;\n /** Row offset. Service default `0`. */\n offset?: number;\n /** Server-side sort key. */\n sortBy?: ListingMarketSortField;\n /** Sort direction. Service default `\"desc\"`. */\n orderBy?: ListingSortDirection;\n /** Inclusive numeric range filters. */\n filters?: ListingMarketFilters;\n }\n>;\n\n/** Return type of {@link getListingMarkets}: one page of catalog rows. */\nexport type GetListingMarketsReturnType = ListingMarketPage;\n\n/**\n * Fetch a page of the permissionless-listing market catalog — the data behind a\n * pools list.\n *\n * The catalog spans every listing the service knows about, at every lifecycle\n * stage; pass `marketStatus: ListingMarketStatus.LISTED` to see only tradable\n * markets. Rows come back newest-listed first unless `sortBy` is set.\n *\n * @param config - The SDK config.\n * @param parameters - Search, filter, sort, and pagination inputs.\n * @returns One page of {@link ListingMarketPage} rows plus the total row count.\n * @throws {SymmApiError} when the service request fails.\n * @throws {SymmError} `LISTING_NOT_CONFIGURED` when the chain has no listing\n * backend. Gate with `supportsListingService` to hide Pools instead.\n *\n * @example\n * ```ts\n * const page = await getListingMarkets(config, {\n * marketStatus: ListingMarketStatus.LISTED,\n * sortBy: \"tvl\",\n * orderBy: \"desc\",\n * limit: 50,\n * });\n * ```\n */\nexport async function getListingMarkets(\n config: Config,\n parameters: GetListingMarketsParameters = {},\n): Promise<GetListingMarketsReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n\n const params = toSearchParams({\n query: parameters.search,\n chainIds: parameters.chainIds,\n marketStatus: parameters.marketStatus,\n limit: parameters.limit,\n offset: parameters.offset,\n sortBy: parameters.sortBy,\n orderBy: parameters.orderBy,\n filters: parameters.filters,\n });\n\n try {\n const response = await marketSearchV2MarketSearchGet(params, {\n baseURL,\n // The service expects repeated keys for array params (`chain_ids=1&chain_ids=2`).\n // Axios's default bracket form (`chain_ids[]=1`) is not rejected — it is\n // silently *ignored*, so the chain filter would drop and the caller would\n // get the whole catalog back. `indexes: null` selects the repeat form.\n paramsSerializer: { indexes: null },\n });\n\n return toListingMarketPage(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_LISTING_MARKETS_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"FETCH_LISTING_MARKETS_FAILED\",\n `Failed to fetch listing markets: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"get-listing-markets.js","names":[],"sources":["../../../src/pools/markets/get-listing-markets.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type {\n ListingDepositChainId,\n ListingMarketFilters,\n ListingMarketPage,\n ListingMarketSortField,\n ListingMarketStatus,\n ListingSortDirection,\n} from \"../types\";\nimport { marketSearchV2MarketSearchGet } from \"../types/generated/listing-backend\";\nimport { toListingMarketPage } from \"./to-listing-market\";\nimport { toSearchParams } from \"./to-search-params\";\n\n/**\n * Parameters for {@link getListingMarkets}.\n *\n * Every field is optional: with none set the service returns its default first\n * page (20 rows, newest-listed first).\n */\nexport type GetListingMarketsParameters = Compute<\n ChainIdParameter & {\n /**\n * Free-text search, matched against contract address, ticker, and token\n * name.\n *\n * Named `search` rather than `query` because the TanStack options bag on the\n * matching query factory already owns `query`.\n */\n search?: string;\n /**\n * Restrict to tokens deposited on these chains. An empty array is sent as\n * no filter, matching the service's behavior for an absent param.\n */\n chainIds?: readonly ListingDepositChainId[];\n /** Restrict to one lifecycle status. */\n marketStatus?: ListingMarketStatus;\n /** Filter by inventory lock state. Omit for both; false explicitly requests unlocked markets. */\n isLocked?: boolean;\n /** Page size, `1`–`100`. Service default `20`. */\n limit?: number;\n /** Row offset. Service default `0`. */\n offset?: number;\n /** Server-side sort key. */\n sortBy?: ListingMarketSortField;\n /** Sort direction. Service default `\"desc\"`. */\n orderBy?: ListingSortDirection;\n /** Inclusive numeric range filters. */\n filters?: ListingMarketFilters;\n }\n>;\n\n/** Return type of {@link getListingMarkets}: one page of catalog rows. */\nexport type GetListingMarketsReturnType = ListingMarketPage;\n\n/**\n * Fetch a page of the permissionless-listing market catalog — the data behind a\n * pools list.\n *\n * The catalog spans every listing the service knows about, at every lifecycle\n * stage; pass `marketStatus: ListingMarketStatus.LISTED` to see only tradable\n * markets. Rows come back newest-listed first unless `sortBy` is set.\n *\n * @param config - The SDK config.\n * @param parameters - Search, filter, sort, and pagination inputs.\n * @returns One page of {@link ListingMarketPage} rows plus the total row count.\n * @throws {SymmApiError} when the service request fails.\n * @throws {SymmError} `LISTING_NOT_CONFIGURED` when the chain has no listing\n * backend. Gate with `supportsListingService` to hide Pools instead.\n *\n * @example\n * ```ts\n * const page = await getListingMarkets(config, {\n * marketStatus: ListingMarketStatus.LISTED,\n * sortBy: \"tvl\",\n * orderBy: \"desc\",\n * limit: 50,\n * });\n * ```\n */\nexport async function getListingMarkets(\n config: Config,\n parameters: GetListingMarketsParameters = {},\n): Promise<GetListingMarketsReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n\n const params = toSearchParams({\n query: parameters.search,\n chainIds: parameters.chainIds,\n marketStatus: parameters.marketStatus,\n isLocked: parameters.isLocked,\n limit: parameters.limit,\n offset: parameters.offset,\n sortBy: parameters.sortBy,\n orderBy: parameters.orderBy,\n filters: parameters.filters,\n });\n\n try {\n const response = await marketSearchV2MarketSearchGet(params, {\n baseURL,\n // The service expects repeated keys for array params (`chain_ids=1&chain_ids=2`).\n // Axios's default bracket form (`chain_ids[]=1`) is not rejected — it is\n // silently *ignored*, so the chain filter would drop and the caller would\n // get the whole catalog back. `indexes: null` selects the repeat form.\n paramsSerializer: { indexes: null },\n });\n\n return toListingMarketPage(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_LISTING_MARKETS_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"FETCH_LISTING_MARKETS_FAILED\",\n `Failed to fetch listing markets: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;;AAmFA,eAAsB,EACpB,GACA,IAA0C,CAAC,GACL;CACtC,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,EAAE,SAAS,EAAW,QAAQ,CAAC,GAEhF,IAAS,EAAe;EAC5B,OAAO,EAAW;EAClB,UAAU,EAAW;EACrB,cAAc,EAAW;EACzB,UAAU,EAAW;EACrB,OAAO,EAAW;EAClB,QAAQ,EAAW;EACnB,QAAQ,EAAW;EACnB,SAAS,EAAW;EACpB,SAAS,EAAW;CACtB,CAAC;CAED,IAAI;EAUF,OAAO,GAAoB,MATJ,EAA8B,GAAQ;GAC3D;GAKA,kBAAkB,EAAE,SAAS,KAAK;EACpC,CAAC,GAEmC,IAAI;CAC1C,SAAS,GAAK;EAOZ,MANI,aAAe,IAAiB,IAEhC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAAgC;EAAQ,CAAC,IAG/E,IAAI,EACR,OACA,gCACA,oCAAoC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KACnF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAE/B,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,2BAA2B,GAAG,kBAAkB,CAAC,2DAE3G;AAED,oEAAoE;AACpE,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,2BAA2B,GACzB,cAAc,CAAC,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACjG,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,6BAA6B,GAAG,kBAAkB,CAC5D,qBAAqB,EACrB,KAAK,EACL,qBAAqB,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,wBAA6B,GACrC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAE/B,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,2BAA2B,GAAG,kBAAkB,CAAC,2DAE3G;AAED,oEAAoE;AACpE,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,2BAA2B,GACzB,cAAc,CAAC,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACjG,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,6BAA6B,GAAG,kBAAkB,CAC5D,qBAAqB,EACrB,KAAK,EACL,qBAAqB,EACrB,yBAAyB,CAC1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,wBAA6B,GACrC,6BAA6B,CAsB/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/markets/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getListingMarkets,\n type GetListingMarketsParameters,\n type GetListingMarketsReturnType,\n} from \"./get-listing-markets\";\n\n/** Data resolved by the {@link getListingMarketsQueryOptions} query. */\nexport type GetListingMarketsData = GetListingMarketsReturnType;\n\n/**\n * Build the TanStack Query key for {@link getListingMarketsQueryOptions}.\n *\n * @param options - Search parameters plus the resolved config key.\n * @returns A stable, hashable query key.\n */\nexport function getListingMarketsQueryKey(options: Compute<GetListingMarketsParameters & ConfigKeyParameter>) {\n return [\"getListingMarkets\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getListingMarketsQueryKey}. */\nexport type GetListingMarketsQueryKey = ReturnType<typeof getListingMarketsQueryKey>;\n\n/**\n * Options accepted by {@link getListingMarketsQueryOptions}: the action's\n * parameters, an optional cache scope, and TanStack overrides.\n */\nexport type GetListingMarketsOptions = Compute<\n GetListingMarketsParameters &\n QueryParameter<GetListingMarketsData, Error, GetListingMarketsData, GetListingMarketsQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getListingMarketsQueryOptions}. */\nexport type GetListingMarketsQueryOptions = SymmioQueryOptions<\n GetListingMarketsData,\n Error,\n GetListingMarketsData,\n GetListingMarketsQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getListingMarkets}.\n *\n * @param config - The SDK config.\n * @param options - Search parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(getListingMarketsQueryOptions(config, { sortBy: \"tvl\", limit: 50 }));\n * ```\n */\nexport function getListingMarketsQueryOptions(\n config: Config,\n options: GetListingMarketsOptions = {},\n): GetListingMarketsQueryOptions {\n return {\n ...options.query,\n queryKey: getListingMarketsQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () =>\n getListingMarkets(config, {\n chainId: options.chainId,\n search: options.search,\n chainIds: options.chainIds,\n marketStatus: options.marketStatus,\n limit: options.limit,\n offset: options.offset,\n sortBy: options.sortBy,\n orderBy: options.orderBy,\n filters: options.filters,\n }),\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,EAA0B,GAAoE;CAC5G,OAAO,CAAC,qBAAqB,EAAmB,CAAO,CAAC;AAC1D;AAkCA,SAAgB,EACd,GACA,IAAoC,CAAC,GACN;CAC/B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA0B;GAClC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eACE,EAAkB,GAAQ;GACxB,SAAS,EAAQ;GACjB,QAAQ,EAAQ;GAChB,UAAU,EAAQ;GAClB,cAAc,EAAQ;GACtB,OAAO,EAAQ;GACf,QAAQ,EAAQ;GAChB,QAAQ,EAAQ;GAChB,SAAS,EAAQ;GACjB,SAAS,EAAQ;EACnB,CAAC;CACL;AACF"}
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/markets/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getListingMarkets,\n type GetListingMarketsParameters,\n type GetListingMarketsReturnType,\n} from \"./get-listing-markets\";\n\n/** Data resolved by the {@link getListingMarketsQueryOptions} query. */\nexport type GetListingMarketsData = GetListingMarketsReturnType;\n\n/**\n * Build the TanStack Query key for {@link getListingMarketsQueryOptions}.\n *\n * @param options - Search parameters plus the resolved config key.\n * @returns A stable, hashable query key.\n */\nexport function getListingMarketsQueryKey(options: Compute<GetListingMarketsParameters & ConfigKeyParameter>) {\n return [\"getListingMarkets\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getListingMarketsQueryKey}. */\nexport type GetListingMarketsQueryKey = ReturnType<typeof getListingMarketsQueryKey>;\n\n/**\n * Options accepted by {@link getListingMarketsQueryOptions}: the action's\n * parameters, an optional cache scope, and TanStack overrides.\n */\nexport type GetListingMarketsOptions = Compute<\n GetListingMarketsParameters &\n QueryParameter<GetListingMarketsData, Error, GetListingMarketsData, GetListingMarketsQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getListingMarketsQueryOptions}. */\nexport type GetListingMarketsQueryOptions = SymmioQueryOptions<\n GetListingMarketsData,\n Error,\n GetListingMarketsData,\n GetListingMarketsQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getListingMarkets}.\n *\n * @param config - The SDK config.\n * @param options - Search parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(getListingMarketsQueryOptions(config, { sortBy: \"tvl\", limit: 50 }));\n * ```\n */\nexport function getListingMarketsQueryOptions(\n config: Config,\n options: GetListingMarketsOptions = {},\n): GetListingMarketsQueryOptions {\n return {\n ...options.query,\n queryKey: getListingMarketsQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () =>\n getListingMarkets(config, {\n chainId: options.chainId,\n search: options.search,\n chainIds: options.chainIds,\n marketStatus: options.marketStatus,\n isLocked: options.isLocked,\n limit: options.limit,\n offset: options.offset,\n sortBy: options.sortBy,\n orderBy: options.orderBy,\n filters: options.filters,\n }),\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,EAA0B,GAAoE;CAC5G,OAAO,CAAC,qBAAqB,EAAmB,CAAO,CAAC;AAC1D;AAkCA,SAAgB,EACd,GACA,IAAoC,CAAC,GACN;CAC/B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA0B;GAClC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eACE,EAAkB,GAAQ;GACxB,SAAS,EAAQ;GACjB,QAAQ,EAAQ;GAChB,UAAU,EAAQ;GAClB,cAAc,EAAQ;GACtB,UAAU,EAAQ;GAClB,OAAO,EAAQ;GACf,QAAQ,EAAQ;GAChB,QAAQ,EAAQ;GAChB,SAAS,EAAQ;GACjB,SAAS,EAAQ;EACnB,CAAC;CACL;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-search-params.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/to-search-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAuC,MAAM,UAAU,CAAC;AAC1F,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AAoC9F;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcrF;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,mCAAmC,
|
|
1
|
+
{"version":3,"file":"to-search-params.d.ts","sourceRoot":"","sources":["../../../src/pools/markets/to-search-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAuC,MAAM,UAAU,CAAC;AAC1F,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AAoC9F;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcrF;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,mCAAmC,CAa9F"}
|
|
@@ -34,7 +34,7 @@ function t(t) {
|
|
|
34
34
|
}
|
|
35
35
|
function n(e) {
|
|
36
36
|
let n = { ...t(e.filters) };
|
|
37
|
-
return e.query !== void 0 && (n.query = e.query), e.chainIds !== void 0 && (n.chain_ids = [...e.chainIds]), e.marketStatus !== void 0 && (n.market_status = e.marketStatus), e.limit !== void 0 && (n.limit = e.limit), e.offset !== void 0 && (n.offset = e.offset), e.sortBy !== void 0 && (n.sort_by = e.sortBy), e.orderBy !== void 0 && (n.order_by = e.orderBy), n;
|
|
37
|
+
return e.query !== void 0 && (n.query = e.query), e.chainIds !== void 0 && (n.chain_ids = [...e.chainIds]), e.marketStatus !== void 0 && (n.market_status = e.marketStatus), e.isLocked !== void 0 && (n.is_locked = e.isLocked), e.limit !== void 0 && (n.limit = e.limit), e.offset !== void 0 && (n.offset = e.offset), e.sortBy !== void 0 && (n.sort_by = e.sortBy), e.orderBy !== void 0 && (n.order_by = e.orderBy), n;
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
export { n as toSearchParams };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-search-params.js","names":[],"sources":["../../../src/pools/markets/to-search-params.ts"],"sourcesContent":["import type { ListingMarketFilters, ListingTimeRange, ListingValueRange } from \"../types\";\nimport type { MarketSearchV2MarketSearchGetParams } from \"../types/generated/listing-backend\";\n\n/**\n * SDK filter key to the wire field its `__ge` / `__le` bounds attach to.\n *\n * Kept as an explicit table rather than derived from the key name: several\n * fields do not round-trip through a naive camel-to-snake conversion\n * (`vol24h`, `apr24h` → `apr_24h`, `tvlDrivenApy` → `tvl_driven_apy`), and a\n * silent mismatch here is invisible — the service ignores unknown query params\n * and returns the unfiltered catalog.\n */\nconst FILTER_WIRE_FIELD = {\n marketCap: \"market_cap\",\n vol24h: \"vol24h\",\n tvl: \"tvl\",\n liquidity: \"liquidity\",\n openInterest: \"open_interest\",\n reward24h: \"reward_24h\",\n apr: \"apr\",\n apr1h: \"apr_1h\",\n apr6h: \"apr_6h\",\n apr24h: \"apr_24h\",\n apr30d: \"apr_30d\",\n tvlDrivenApy1h: \"tvl_driven_apy_1h\",\n tvlDrivenApy6h: \"tvl_driven_apy_6h\",\n tvlDrivenApy24h: \"tvl_driven_apy_24h\",\n tvlDrivenApy30d: \"tvl_driven_apy_30d\",\n tvlDrivenApy: \"tvl_driven_apy\",\n priceDrivenApy1h: \"price_driven_apy_1h\",\n priceDrivenApy6h: \"price_driven_apy_6h\",\n priceDrivenApy24h: \"price_driven_apy_24h\",\n priceDrivenApy30d: \"price_driven_apy_30d\",\n priceDrivenApy: \"price_driven_apy\",\n listingTime: \"listing_time\",\n} as const satisfies Record<keyof ListingMarketFilters, string>;\n\n/**\n * Flatten {@link ListingMarketFilters} into the service's `{field}__ge` /\n * `{field}__le` query params.\n *\n * `bigint` bounds are stringified rather than passed through: an 18-decimal\n * value exceeds `Number.MAX_SAFE_INTEGER`, so serializing it as a number would\n * round the bound. The service accepts the string form.\n *\n * @param filters - The SDK-shaped filters, or `undefined` for none.\n * @returns A flat bag of wire params; empty when nothing is filtered.\n */\nexport function toFilterParams(filters?: ListingMarketFilters): Record<string, string> {\n if (filters === undefined) return {};\n\n const params: Record<string, string> = {};\n\n for (const [key, wireField] of Object.entries(FILTER_WIRE_FIELD)) {\n const range = filters[key as keyof ListingMarketFilters] as ListingValueRange | ListingTimeRange | undefined;\n if (range === undefined) continue;\n\n if (range.min !== undefined) params[`${wireField}__ge`] = String(range.min);\n if (range.max !== undefined) params[`${wireField}__le`] = String(range.max);\n }\n\n return params;\n}\n\n/** Non-filter query inputs {@link toSearchParams} accepts. */\nexport interface ToSearchParamsInput {\n query?: string;\n chainIds?: readonly number[];\n marketStatus?: string;\n limit?: number;\n offset?: number;\n sortBy?: string;\n orderBy?: \"asc\" | \"desc\";\n filters?: ListingMarketFilters;\n}\n\n/**\n * Build the full `/v2/market/search` query bag from SDK-shaped inputs.\n *\n * Undefined inputs are omitted entirely rather than sent as empty values, so the\n * service applies its own defaults (`limit=20`, `offset=0`, `order_by=desc`).\n *\n * @param input - SDK-shaped search inputs.\n * @returns The wire query params.\n */\nexport function toSearchParams(input: ToSearchParamsInput): MarketSearchV2MarketSearchGetParams {\n const params: Record<string, unknown> = { ...toFilterParams(input.filters) };\n\n if (input.query !== undefined) params.query = input.query;\n if (input.chainIds !== undefined) params.chain_ids = [...input.chainIds];\n if (input.marketStatus !== undefined) params.market_status = input.marketStatus;\n if (input.limit !== undefined) params.limit = input.limit;\n if (input.offset !== undefined) params.offset = input.offset;\n if (input.sortBy !== undefined) params.sort_by = input.sortBy;\n if (input.orderBy !== undefined) params.order_by = input.orderBy;\n\n return params as MarketSearchV2MarketSearchGetParams;\n}\n"],"mappings":";AAYA,IAAM,IAAoB;CACxB,WAAW;CACX,QAAQ;CACR,KAAK;CACL,WAAW;CACX,cAAc;CACd,WAAW;CACX,KAAK;CACL,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,kBAAkB;CAClB,kBAAkB;CAClB,mBAAmB;CACnB,mBAAmB;CACnB,gBAAgB;CAChB,aAAa;AACf;AAaA,SAAgB,EAAe,GAAwD;CACrF,IAAI,MAAY,KAAA,GAAW,OAAO,CAAC;CAEnC,IAAM,IAAiC,CAAC;CAExC,KAAK,IAAM,CAAC,GAAK,MAAc,OAAO,QAAQ,CAAiB,GAAG;EAChE,IAAM,IAAQ,EAAQ;EAClB,MAAU,KAAA,MAEV,EAAM,QAAQ,KAAA,MAAW,EAAO,GAAG,EAAU,SAAS,OAAO,EAAM,GAAG,IACtE,EAAM,QAAQ,KAAA,MAAW,EAAO,GAAG,EAAU,SAAS,OAAO,EAAM,GAAG;CAC5E;CAEA,OAAO;AACT;
|
|
1
|
+
{"version":3,"file":"to-search-params.js","names":[],"sources":["../../../src/pools/markets/to-search-params.ts"],"sourcesContent":["import type { ListingMarketFilters, ListingTimeRange, ListingValueRange } from \"../types\";\nimport type { MarketSearchV2MarketSearchGetParams } from \"../types/generated/listing-backend\";\n\n/**\n * SDK filter key to the wire field its `__ge` / `__le` bounds attach to.\n *\n * Kept as an explicit table rather than derived from the key name: several\n * fields do not round-trip through a naive camel-to-snake conversion\n * (`vol24h`, `apr24h` → `apr_24h`, `tvlDrivenApy` → `tvl_driven_apy`), and a\n * silent mismatch here is invisible — the service ignores unknown query params\n * and returns the unfiltered catalog.\n */\nconst FILTER_WIRE_FIELD = {\n marketCap: \"market_cap\",\n vol24h: \"vol24h\",\n tvl: \"tvl\",\n liquidity: \"liquidity\",\n openInterest: \"open_interest\",\n reward24h: \"reward_24h\",\n apr: \"apr\",\n apr1h: \"apr_1h\",\n apr6h: \"apr_6h\",\n apr24h: \"apr_24h\",\n apr30d: \"apr_30d\",\n tvlDrivenApy1h: \"tvl_driven_apy_1h\",\n tvlDrivenApy6h: \"tvl_driven_apy_6h\",\n tvlDrivenApy24h: \"tvl_driven_apy_24h\",\n tvlDrivenApy30d: \"tvl_driven_apy_30d\",\n tvlDrivenApy: \"tvl_driven_apy\",\n priceDrivenApy1h: \"price_driven_apy_1h\",\n priceDrivenApy6h: \"price_driven_apy_6h\",\n priceDrivenApy24h: \"price_driven_apy_24h\",\n priceDrivenApy30d: \"price_driven_apy_30d\",\n priceDrivenApy: \"price_driven_apy\",\n listingTime: \"listing_time\",\n} as const satisfies Record<keyof ListingMarketFilters, string>;\n\n/**\n * Flatten {@link ListingMarketFilters} into the service's `{field}__ge` /\n * `{field}__le` query params.\n *\n * `bigint` bounds are stringified rather than passed through: an 18-decimal\n * value exceeds `Number.MAX_SAFE_INTEGER`, so serializing it as a number would\n * round the bound. The service accepts the string form.\n *\n * @param filters - The SDK-shaped filters, or `undefined` for none.\n * @returns A flat bag of wire params; empty when nothing is filtered.\n */\nexport function toFilterParams(filters?: ListingMarketFilters): Record<string, string> {\n if (filters === undefined) return {};\n\n const params: Record<string, string> = {};\n\n for (const [key, wireField] of Object.entries(FILTER_WIRE_FIELD)) {\n const range = filters[key as keyof ListingMarketFilters] as ListingValueRange | ListingTimeRange | undefined;\n if (range === undefined) continue;\n\n if (range.min !== undefined) params[`${wireField}__ge`] = String(range.min);\n if (range.max !== undefined) params[`${wireField}__le`] = String(range.max);\n }\n\n return params;\n}\n\n/** Non-filter query inputs {@link toSearchParams} accepts. */\nexport interface ToSearchParamsInput {\n query?: string;\n chainIds?: readonly number[];\n marketStatus?: string;\n isLocked?: boolean;\n limit?: number;\n offset?: number;\n sortBy?: string;\n orderBy?: \"asc\" | \"desc\";\n filters?: ListingMarketFilters;\n}\n\n/**\n * Build the full `/v2/market/search` query bag from SDK-shaped inputs.\n *\n * Undefined inputs are omitted entirely rather than sent as empty values, so the\n * service applies its own defaults (`limit=20`, `offset=0`, `order_by=desc`).\n *\n * @param input - SDK-shaped search inputs.\n * @returns The wire query params.\n */\nexport function toSearchParams(input: ToSearchParamsInput): MarketSearchV2MarketSearchGetParams {\n const params: Record<string, unknown> = { ...toFilterParams(input.filters) };\n\n if (input.query !== undefined) params.query = input.query;\n if (input.chainIds !== undefined) params.chain_ids = [...input.chainIds];\n if (input.marketStatus !== undefined) params.market_status = input.marketStatus;\n if (input.isLocked !== undefined) params.is_locked = input.isLocked;\n if (input.limit !== undefined) params.limit = input.limit;\n if (input.offset !== undefined) params.offset = input.offset;\n if (input.sortBy !== undefined) params.sort_by = input.sortBy;\n if (input.orderBy !== undefined) params.order_by = input.orderBy;\n\n return params as MarketSearchV2MarketSearchGetParams;\n}\n"],"mappings":";AAYA,IAAM,IAAoB;CACxB,WAAW;CACX,QAAQ;CACR,KAAK;CACL,WAAW;CACX,cAAc;CACd,WAAW;CACX,KAAK;CACL,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,gBAAgB;CAChB,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,kBAAkB;CAClB,kBAAkB;CAClB,mBAAmB;CACnB,mBAAmB;CACnB,gBAAgB;CAChB,aAAa;AACf;AAaA,SAAgB,EAAe,GAAwD;CACrF,IAAI,MAAY,KAAA,GAAW,OAAO,CAAC;CAEnC,IAAM,IAAiC,CAAC;CAExC,KAAK,IAAM,CAAC,GAAK,MAAc,OAAO,QAAQ,CAAiB,GAAG;EAChE,IAAM,IAAQ,EAAQ;EAClB,MAAU,KAAA,MAEV,EAAM,QAAQ,KAAA,MAAW,EAAO,GAAG,EAAU,SAAS,OAAO,EAAM,GAAG,IACtE,EAAM,QAAQ,KAAA,MAAW,EAAO,GAAG,EAAU,SAAS,OAAO,EAAM,GAAG;CAC5E;CAEA,OAAO;AACT;AAwBA,SAAgB,EAAe,GAAiE;CAC9F,IAAM,IAAkC,EAAE,GAAG,EAAe,EAAM,OAAO,EAAE;CAW3E,OATI,EAAM,UAAU,KAAA,MAAW,EAAO,QAAQ,EAAM,QAChD,EAAM,aAAa,KAAA,MAAW,EAAO,YAAY,CAAC,GAAG,EAAM,QAAQ,IACnE,EAAM,iBAAiB,KAAA,MAAW,EAAO,gBAAgB,EAAM,eAC/D,EAAM,aAAa,KAAA,MAAW,EAAO,YAAY,EAAM,WACvD,EAAM,UAAU,KAAA,MAAW,EAAO,QAAQ,EAAM,QAChD,EAAM,WAAW,KAAA,MAAW,EAAO,SAAS,EAAM,SAClD,EAAM,WAAW,KAAA,MAAW,EAAO,UAAU,EAAM,SACnD,EAAM,YAAY,KAAA,MAAW,EAAO,WAAW,EAAM,UAElD;AACT"}
|
|
@@ -21,6 +21,8 @@ export type GetEstimatedPriceParameters = Compute<ReadSolverParameter & {
|
|
|
21
21
|
* prices the fill relative to it.
|
|
22
22
|
*/
|
|
23
23
|
price: string;
|
|
24
|
+
/** Cancels the underlying HTTP request; no timeout is imposed by default. */
|
|
25
|
+
signal?: AbortSignal;
|
|
24
26
|
}>;
|
|
25
27
|
/**
|
|
26
28
|
* Return type of {@link getEstimatedPrice}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-estimated-price.d.ts","sourceRoot":"","sources":["../../../src/solvers/estimated-price/get-estimated-price.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAKnE,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAC/C,mBAAmB,GAAG;IACpB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,uDAAuD;IACvD,KAAK,EAAE,mBAAmB,CAAC;IAC3B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"get-estimated-price.d.ts","sourceRoot":"","sources":["../../../src/solvers/estimated-price/get-estimated-price.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAKnE,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAC/C,mBAAmB,GAAG;IACpB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,uDAAuD;IACvD,KAAK,EAAE,mBAAmB,CAAC;IAC3B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,kFAAkF;IAClF,cAAc,EAAE,MAAM,CAAC;CACxB;AAOD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,2BAA2B,GACtC,OAAO,CAAC,2BAA2B,CAAC,CA2BtC"}
|
|
@@ -21,7 +21,10 @@ async function c(n, c) {
|
|
|
21
21
|
position_type: s(c.positionType),
|
|
22
22
|
entry: c.entry,
|
|
23
23
|
price: c.price
|
|
24
|
-
}, {
|
|
24
|
+
}, {
|
|
25
|
+
baseURL: l.url,
|
|
26
|
+
signal: c.signal
|
|
27
|
+
})).data);
|
|
25
28
|
} catch (n) {
|
|
26
29
|
throw n instanceof t ? n : o(n) ? e.fromAxios(n, {
|
|
27
30
|
code: "FETCH_ESTIMATED_PRICE_FAILED",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-estimated-price.js","names":[],"sources":["../../../src/solvers/estimated-price/get-estimated-price.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { PositionType } from \"../../symmio-contracts/symmio/types\";\nimport { assertSolverKind } from \"../assert-solver-kind\";\nimport { getEstimatedPrice as requestEstimatedPrice } from \"../types/generated/enigma-solver\";\nimport { toEstimatedPrice } from \"./to-estimated-price\";\n\n/** Whether a price estimate is for **opening** or **closing** a position. */\nexport type EstimatedPriceEntry = \"open\" | \"close\";\n\n/**\n * Parameters for {@link getEstimatedPrice}.\n */\nexport type GetEstimatedPriceParameters = Compute<\n ReadSolverParameter & {\n /** Solver market id. */\n symbolId: number;\n /** Order quantity (decimal string). */\n quantity: string;\n /** Long or short. */\n positionType: PositionType;\n /** Whether this estimate is for an open or a close. */\n entry: EstimatedPriceEntry;\n /**\n * The price **sent to the solver** — the slippage-adjusted request price the\n * caller computed for the open/close, **not** the raw mark price. The solver\n * prices the fill relative to it.\n */\n price: string;\n }\n>;\n\n/**\n * Return type of {@link getEstimatedPrice}.\n */\nexport interface GetEstimatedPriceReturnType {\n /** Estimated execution price (decimal string); `\"0\"` when the solver omits it. */\n estimatedPrice: string;\n}\n\n/** Solver wire value for a position side (`\"long\"` / `\"short\"`). */\nfunction positionTypeToWire(positionType: PositionType): string {\n return positionType === PositionType.SHORT ? \"short\" : \"long\";\n}\n\n/**\n * Ask the solver what price an open or close would actually fill at — a\n * read-only simulation of the trade (`GET /estimated-price`; nothing is\n * submitted). Pass the order `quantity`, the side, whether it's an open or\n * close, and the slippage-adjusted request `price`; the solver returns the price\n * it would fill at, from which the UI derives price impact (see\n * {@link calculatePriceImpact}) and — for a close — an estimated PnL.\n *\n * @param config - The SDK config.\n * @param parameters - Market, quantity, side, entry (open/close), and request price.\n * @returns The estimated execution price.\n * @throws {SymmApiError} when the solver request fails.\n * @throws {SymmError} when the chain is unsupported.\n *\n * @example\n * ```ts\n * const { estimatedPrice } = await getEstimatedPrice(config, {\n * symbolId: 1,\n * quantity: \"1000\",\n * positionType: PositionType.LONG,\n * entry: \"open\",\n * price: requestPrice, // slippage-adjusted, from calculateTradeParams\n * });\n * ```\n */\nexport async function getEstimatedPrice(\n config: Config,\n parameters: GetEstimatedPriceParameters,\n): Promise<GetEstimatedPriceReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n assertSolverKind(solver, \"enigma\", \"getEstimatedPrice\");\n try {\n const response = await requestEstimatedPrice(\n {\n symbol_id: parameters.symbolId,\n quantity: parameters.quantity,\n position_type: positionTypeToWire(parameters.positionType),\n entry: parameters.entry,\n price: parameters.price,\n },\n { baseURL: solver.url },\n );\n return toEstimatedPrice(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_ESTIMATED_PRICE_FAILED\", baseURL: solver.url });\n }\n throw new SymmError(\n \"api\",\n \"FETCH_ESTIMATED_PRICE_FAILED\",\n `Failed to fetch estimated price: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"get-estimated-price.js","names":[],"sources":["../../../src/solvers/estimated-price/get-estimated-price.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { PositionType } from \"../../symmio-contracts/symmio/types\";\nimport { assertSolverKind } from \"../assert-solver-kind\";\nimport { getEstimatedPrice as requestEstimatedPrice } from \"../types/generated/enigma-solver\";\nimport { toEstimatedPrice } from \"./to-estimated-price\";\n\n/** Whether a price estimate is for **opening** or **closing** a position. */\nexport type EstimatedPriceEntry = \"open\" | \"close\";\n\n/**\n * Parameters for {@link getEstimatedPrice}.\n */\nexport type GetEstimatedPriceParameters = Compute<\n ReadSolverParameter & {\n /** Solver market id. */\n symbolId: number;\n /** Order quantity (decimal string). */\n quantity: string;\n /** Long or short. */\n positionType: PositionType;\n /** Whether this estimate is for an open or a close. */\n entry: EstimatedPriceEntry;\n /**\n * The price **sent to the solver** — the slippage-adjusted request price the\n * caller computed for the open/close, **not** the raw mark price. The solver\n * prices the fill relative to it.\n */\n price: string;\n /** Cancels the underlying HTTP request; no timeout is imposed by default. */\n signal?: AbortSignal;\n }\n>;\n\n/**\n * Return type of {@link getEstimatedPrice}.\n */\nexport interface GetEstimatedPriceReturnType {\n /** Estimated execution price (decimal string); `\"0\"` when the solver omits it. */\n estimatedPrice: string;\n}\n\n/** Solver wire value for a position side (`\"long\"` / `\"short\"`). */\nfunction positionTypeToWire(positionType: PositionType): string {\n return positionType === PositionType.SHORT ? \"short\" : \"long\";\n}\n\n/**\n * Ask the solver what price an open or close would actually fill at — a\n * read-only simulation of the trade (`GET /estimated-price`; nothing is\n * submitted). Pass the order `quantity`, the side, whether it's an open or\n * close, and the slippage-adjusted request `price`; the solver returns the price\n * it would fill at, from which the UI derives price impact (see\n * {@link calculatePriceImpact}) and — for a close — an estimated PnL.\n *\n * @param config - The SDK config.\n * @param parameters - Market, quantity, side, entry (open/close), and request price.\n * @returns The estimated execution price.\n * @throws {SymmApiError} when the solver request fails.\n * @throws {SymmError} when the chain is unsupported.\n *\n * @example\n * ```ts\n * const { estimatedPrice } = await getEstimatedPrice(config, {\n * symbolId: 1,\n * quantity: \"1000\",\n * positionType: PositionType.LONG,\n * entry: \"open\",\n * price: requestPrice, // slippage-adjusted, from calculateTradeParams\n * });\n * ```\n */\nexport async function getEstimatedPrice(\n config: Config,\n parameters: GetEstimatedPriceParameters,\n): Promise<GetEstimatedPriceReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n assertSolverKind(solver, \"enigma\", \"getEstimatedPrice\");\n try {\n const response = await requestEstimatedPrice(\n {\n symbol_id: parameters.symbolId,\n quantity: parameters.quantity,\n position_type: positionTypeToWire(parameters.positionType),\n entry: parameters.entry,\n price: parameters.price,\n },\n { baseURL: solver.url, signal: parameters.signal },\n );\n return toEstimatedPrice(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_ESTIMATED_PRICE_FAILED\", baseURL: solver.url });\n }\n throw new SymmError(\n \"api\",\n \"FETCH_ESTIMATED_PRICE_FAILED\",\n `Failed to fetch estimated price: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;;AA6CA,SAAS,EAAmB,GAAoC;CAC9D,OAAO,MAAiB,EAAa,QAAQ,UAAU;AACzD;AA2BA,eAAsB,EACpB,GACA,GACsC;CACtC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,EAAiB,GAAQ,UAAU,mBAAmB;CACtD,IAAI;EAWF,OAAO,GAAiB,MAVD,EACrB;GACE,WAAW,EAAW;GACtB,UAAU,EAAW;GACrB,eAAe,EAAmB,EAAW,YAAY;GACzD,OAAO,EAAW;GAClB,OAAO,EAAW;EACpB,GACA;GAAE,SAAS,EAAO;GAAK,QAAQ,EAAW;EAAO,CACnD,GACiC,IAAI;CACvC,SAAS,GAAK;EAKZ,MAJI,aAAe,IAAiB,IAChC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAAgC,SAAS,EAAO;EAAI,CAAC,IAE3F,IAAI,EACR,OACA,gCACA,oCAAoC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KACnF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
|
|
@@ -9,9 +9,13 @@ export declare function getEstimatedPriceQueryKey(options: Compute<GetEstimatedP
|
|
|
9
9
|
/** Query-key type produced by {@link getEstimatedPriceQueryKey}. */
|
|
10
10
|
export type GetEstimatedPriceQueryKey = ReturnType<typeof getEstimatedPriceQueryKey>;
|
|
11
11
|
/** Options accepted by {@link getEstimatedPriceQueryOptions}. */
|
|
12
|
-
export type GetEstimatedPriceOptions = Compute<GetEstimatedPriceParameters & QueryParameter<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>>;
|
|
12
|
+
export type GetEstimatedPriceOptions = Compute<Omit<GetEstimatedPriceParameters, "signal"> & QueryParameter<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>>;
|
|
13
13
|
/** TanStack Query options returned by {@link getEstimatedPriceQueryOptions}. */
|
|
14
|
-
export type GetEstimatedPriceQueryOptions = SymmioQueryOptions<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey
|
|
14
|
+
export type GetEstimatedPriceQueryOptions = Omit<SymmioQueryOptions<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>, "queryFn"> & {
|
|
15
|
+
queryFn: (context?: {
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}) => Promise<GetEstimatedPriceData>;
|
|
18
|
+
};
|
|
15
19
|
/**
|
|
16
20
|
* Build TanStack Query options for {@link getEstimatedPrice}. Disabled until
|
|
17
21
|
* `quantity` and `price` are non-empty, so the estimate does not fire on partial
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/estimated-price/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAE/B,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEhE,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,2BAA2B,GAAG,kBAAkB,CAAC,2DAE3G;AAED,oEAAoE;AACpE,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErF,iEAAiE;AACjE,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,2BAA2B,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/estimated-price/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EACjC,MAAM,uBAAuB,CAAC;AAE/B,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEhE,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,2BAA2B,GAAG,kBAAkB,CAAC,2DAE3G;AAED,oEAAoE;AACpE,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAErF,iEAAiE;AACjE,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,GACzC,cAAc,CAAC,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACjG,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,kBAAkB,CAAC,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,EAClG,SAAS,CACV,GAAG;IACF,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACjF,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,GAChC,6BAA6B,CAoB/B"}
|
|
@@ -12,14 +12,15 @@ function r(e, r) {
|
|
|
12
12
|
configKey: e.getChainConfigKey(r.chainId)
|
|
13
13
|
}),
|
|
14
14
|
enabled: (r.query?.enabled ?? !0) && r.quantity.length > 0 && r.price.length > 0,
|
|
15
|
-
queryFn: () => t(e, {
|
|
15
|
+
queryFn: (n) => t(e, {
|
|
16
16
|
chainId: r.chainId,
|
|
17
17
|
solverId: r.solverId,
|
|
18
18
|
symbolId: r.symbolId,
|
|
19
19
|
quantity: r.quantity,
|
|
20
20
|
positionType: r.positionType,
|
|
21
21
|
entry: r.entry,
|
|
22
|
-
price: r.price
|
|
22
|
+
price: r.price,
|
|
23
|
+
signal: n?.signal
|
|
23
24
|
})
|
|
24
25
|
};
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/estimated-price/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getEstimatedPrice,\n type GetEstimatedPriceParameters,\n type GetEstimatedPriceReturnType,\n} from \"./get-estimated-price\";\n\n/** Data resolved by the {@link getEstimatedPriceQueryOptions} query. */\nexport type GetEstimatedPriceData = GetEstimatedPriceReturnType;\n\n/** Build the TanStack Query key for {@link getEstimatedPriceQueryOptions}. */\nexport function getEstimatedPriceQueryKey(options: Compute<GetEstimatedPriceParameters & ConfigKeyParameter>) {\n return [\"getEstimatedPrice\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getEstimatedPriceQueryKey}. */\nexport type GetEstimatedPriceQueryKey = ReturnType<typeof getEstimatedPriceQueryKey>;\n\n/** Options accepted by {@link getEstimatedPriceQueryOptions}. */\nexport type GetEstimatedPriceOptions = Compute<\n GetEstimatedPriceParameters &\n QueryParameter<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getEstimatedPriceQueryOptions}. */\nexport type GetEstimatedPriceQueryOptions =
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/estimated-price/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getEstimatedPrice,\n type GetEstimatedPriceParameters,\n type GetEstimatedPriceReturnType,\n} from \"./get-estimated-price\";\n\n/** Data resolved by the {@link getEstimatedPriceQueryOptions} query. */\nexport type GetEstimatedPriceData = GetEstimatedPriceReturnType;\n\n/** Build the TanStack Query key for {@link getEstimatedPriceQueryOptions}. */\nexport function getEstimatedPriceQueryKey(options: Compute<GetEstimatedPriceParameters & ConfigKeyParameter>) {\n return [\"getEstimatedPrice\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getEstimatedPriceQueryKey}. */\nexport type GetEstimatedPriceQueryKey = ReturnType<typeof getEstimatedPriceQueryKey>;\n\n/** Options accepted by {@link getEstimatedPriceQueryOptions}. */\nexport type GetEstimatedPriceOptions = Compute<\n Omit<GetEstimatedPriceParameters, \"signal\"> &\n QueryParameter<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getEstimatedPriceQueryOptions}. */\nexport type GetEstimatedPriceQueryOptions = Omit<\n SymmioQueryOptions<GetEstimatedPriceData, Error, GetEstimatedPriceData, GetEstimatedPriceQueryKey>,\n \"queryFn\"\n> & {\n queryFn: (context?: { signal?: AbortSignal }) => Promise<GetEstimatedPriceData>;\n};\n\n/**\n * Build TanStack Query options for {@link getEstimatedPrice}. Disabled until\n * `quantity` and `price` are non-empty, so the estimate does not fire on partial\n * input.\n *\n * @example\n * ```ts\n * useQuery(getEstimatedPriceQueryOptions(config, { symbolId, quantity, positionType, entry: \"open\", price }));\n * ```\n */\nexport function getEstimatedPriceQueryOptions(\n config: Config,\n options: GetEstimatedPriceOptions,\n): GetEstimatedPriceQueryOptions {\n return {\n ...options.query,\n queryKey: getEstimatedPriceQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: (options.query?.enabled ?? true) && options.quantity.length > 0 && options.price.length > 0,\n queryFn: (context) =>\n getEstimatedPrice(config, {\n chainId: options.chainId,\n solverId: options.solverId,\n symbolId: options.symbolId,\n quantity: options.quantity,\n positionType: options.positionType,\n entry: options.entry,\n price: options.price,\n signal: context?.signal,\n }),\n };\n}\n"],"mappings":";;;AAcA,SAAgB,EAA0B,GAAoE;CAC5G,OAAO,CAAC,qBAAqB,EAAmB,CAAO,CAAC;AAC1D;AA6BA,SAAgB,EACd,GACA,GAC+B;CAC/B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAA0B;GAClC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,UAAU,EAAQ,OAAO,WAAW,OAAS,EAAQ,SAAS,SAAS,KAAK,EAAQ,MAAM,SAAS;EACnG,UAAU,MACR,EAAkB,GAAQ;GACxB,SAAS,EAAQ;GACjB,UAAU,EAAQ;GAClB,UAAU,EAAQ;GAClB,UAAU,EAAQ;GAClB,cAAc,EAAQ;GACtB,OAAO,EAAQ;GACf,OAAO,EAAQ;GACf,QAAQ,GAAS;EACnB,CAAC;CACL;AACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EnigmaMarketFundingInfo } from '../types.js';
|
|
2
|
+
/** Fetch Enigma symbol-ID funding through its generated client. @internal */
|
|
3
|
+
export declare function fetchEnigmaFundingInfo(baseURL: string, symbolIds?: readonly number[]): Promise<EnigmaMarketFundingInfo[]>;
|
|
4
|
+
//# sourceMappingURL=enigma-funding-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enigma-funding-info.d.ts","sourceRoot":"","sources":["../../../../src/solvers/funding-info/adapters/enigma-funding-info.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACxD,6EAA6E;AAC7E,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAWpC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getFundingInfo as e } from "../../types/generated/enigma-solver.js";
|
|
2
|
+
import { toMarketFundingInfo as t } from "../to-funding-info.js";
|
|
3
|
+
//#region src/solvers/funding-info/adapters/enigma-funding-info.ts
|
|
4
|
+
async function n(n, r) {
|
|
5
|
+
let i = await e(r ? { symbol_ids: [...r] } : void 0, {
|
|
6
|
+
baseURL: n,
|
|
7
|
+
paramsSerializer: { indexes: null }
|
|
8
|
+
});
|
|
9
|
+
return Object.entries(i.data).flatMap(([e, n]) => {
|
|
10
|
+
let r = Number(e);
|
|
11
|
+
return !Number.isSafeInteger(r) || r <= 0 || !n || typeof n != "object" ? [] : [t(r, n)];
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as fetchEnigmaFundingInfo };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=enigma-funding-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enigma-funding-info.js","names":[],"sources":["../../../../src/solvers/funding-info/adapters/enigma-funding-info.ts"],"sourcesContent":["import { getFundingInfo as requestFundingInfo } from \"../../types/generated/enigma-solver\";\nimport { toMarketFundingInfo } from \"../to-funding-info\";\nimport type { EnigmaMarketFundingInfo } from \"../types\";\n/** Fetch Enigma symbol-ID funding through its generated client. @internal */\nexport async function fetchEnigmaFundingInfo(\n baseURL: string,\n symbolIds?: readonly number[],\n): Promise<EnigmaMarketFundingInfo[]> {\n const response = await requestFundingInfo(symbolIds ? { symbol_ids: [...symbolIds] } : undefined, {\n baseURL,\n // The solver accepts repeated keys, not Axios's default bracketed arrays.\n paramsSerializer: { indexes: null },\n });\n return Object.entries(response.data).flatMap(([key, raw]) => {\n const symbolId = Number(key);\n if (!Number.isSafeInteger(symbolId) || symbolId <= 0 || !raw || typeof raw !== \"object\") return [];\n return [toMarketFundingInfo(symbolId, raw)];\n });\n}\n"],"mappings":";;;AAIA,eAAsB,EACpB,GACA,GACoC;CACpC,IAAM,IAAW,MAAM,EAAmB,IAAY,EAAE,YAAY,CAAC,GAAG,CAAS,EAAE,IAAI,KAAA,GAAW;EAChG;EAEA,kBAAkB,EAAE,SAAS,KAAK;CACpC,CAAC;CACD,OAAO,OAAO,QAAQ,EAAS,IAAI,EAAE,SAAS,CAAC,GAAK,OAAS;EAC3D,IAAM,IAAW,OAAO,CAAG;EAE3B,OADI,CAAC,OAAO,cAAc,CAAQ,KAAK,KAAY,KAAK,CAAC,KAAO,OAAO,KAAQ,WAAiB,CAAC,IAC1F,CAAC,EAAoB,GAAU,CAAG,CAAC;CAC5C,CAAC;AACH"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RasaMarketFundingInfo } from '../types.js';
|
|
2
|
+
/** Fetch Rasa's existing ticker-based funding response. @internal */
|
|
3
|
+
export declare function fetchRasaFundingInfo(baseURL: string, symbols?: readonly string[]): Promise<RasaMarketFundingInfo[]>;
|
|
4
|
+
//# sourceMappingURL=rasa-funding-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rasa-funding-info.d.ts","sourceRoot":"","sources":["../../../../src/solvers/funding-info/adapters/rasa-funding-info.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,qEAAqE;AACrE,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAC1B,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAalC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getFundingInfoGetFundingInfoGet as e } from "../../types/generated/rasa-solver.js";
|
|
2
|
+
import { toFiniteNumber as t } from "@symmio/utils/number";
|
|
3
|
+
//#region src/solvers/funding-info/adapters/rasa-funding-info.ts
|
|
4
|
+
async function n(n, r) {
|
|
5
|
+
let i = await e(r ? { symbols: [...r] } : void 0, {
|
|
6
|
+
baseURL: n,
|
|
7
|
+
paramsSerializer: { indexes: null }
|
|
8
|
+
});
|
|
9
|
+
return Object.entries(i.data).map(([e, n]) => ({
|
|
10
|
+
kind: "rasa",
|
|
11
|
+
symbol: e,
|
|
12
|
+
nextFundingRateLong: t(n.next_funding_rate_long),
|
|
13
|
+
nextFundingRateShort: t(n.next_funding_rate_short),
|
|
14
|
+
nextFundingTime: t(n.next_funding_time),
|
|
15
|
+
epochDurationSeconds: t(n.funding_rate_epoch_duration)
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as fetchRasaFundingInfo };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=rasa-funding-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rasa-funding-info.js","names":[],"sources":["../../../../src/solvers/funding-info/adapters/rasa-funding-info.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport { getFundingInfoGetFundingInfoGet } from \"../../types/generated/rasa-solver\";\nimport type { RasaMarketFundingInfo } from \"../types\";\n/** Fetch Rasa's existing ticker-based funding response. @internal */\nexport async function fetchRasaFundingInfo(\n baseURL: string,\n symbols?: readonly string[],\n): Promise<RasaMarketFundingInfo[]> {\n const response = await getFundingInfoGetFundingInfoGet(symbols ? { symbols: [...symbols] } : undefined, {\n baseURL,\n paramsSerializer: { indexes: null },\n });\n return Object.entries(response.data).map(([symbol, raw]) => ({\n kind: \"rasa\",\n symbol,\n nextFundingRateLong: toFiniteNumber(raw.next_funding_rate_long),\n nextFundingRateShort: toFiniteNumber(raw.next_funding_rate_short),\n nextFundingTime: toFiniteNumber(raw.next_funding_time),\n epochDurationSeconds: toFiniteNumber(raw.funding_rate_epoch_duration),\n }));\n}\n"],"mappings":";;;AAIA,eAAsB,EACpB,GACA,GACkC;CAClC,IAAM,IAAW,MAAM,EAAgC,IAAU,EAAE,SAAS,CAAC,GAAG,CAAO,EAAE,IAAI,KAAA,GAAW;EACtG;EACA,kBAAkB,EAAE,SAAS,KAAK;CACpC,CAAC;CACD,OAAO,OAAO,QAAQ,EAAS,IAAI,EAAE,KAAK,CAAC,GAAQ,QAAU;EAC3D,MAAM;EACN;EACA,qBAAqB,EAAe,EAAI,sBAAsB;EAC9D,sBAAsB,EAAe,EAAI,uBAAuB;EAChE,iBAAiB,EAAe,EAAI,iBAAiB;EACrD,sBAAsB,EAAe,EAAI,2BAA2B;CACtE,EAAE;AACJ"}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
+
import { SymmioSolverKind } from '../../core/chains/types.js';
|
|
1
2
|
import { Config } from '../../core/config/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { ChainIdParameter, Compute } from '../../shared/types/properties.js';
|
|
4
|
+
import { NormalizedFundingInfoByKind } from './types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Parameters for {@link getFundingInfo}.
|
|
7
|
+
* @example const parameters: GetFundingInfoParameters = { chainId: 42161, symbolIds: [117, 185] };
|
|
6
8
|
*/
|
|
7
|
-
export type GetFundingInfoParameters = Compute<
|
|
8
|
-
/**
|
|
9
|
+
export type GetFundingInfoParameters<K extends SymmioSolverKind = SymmioSolverKind> = Compute<ChainIdParameter & {
|
|
10
|
+
/** Select a solver; a literal narrows the returned rows. */
|
|
11
|
+
solverId?: K;
|
|
12
|
+
/** Enigma only: restrict the result to these symbol IDs. Omit to fetch every market (the endpoint default). */
|
|
13
|
+
symbolIds?: readonly number[];
|
|
14
|
+
/** Rasa ticker filter. Only valid for a Rasa solver. */
|
|
9
15
|
symbols?: readonly string[];
|
|
10
16
|
}>;
|
|
11
|
-
/** Return type of {@link getFundingInfo}: one entry per market. */
|
|
12
|
-
export type GetFundingInfoReturnType = MarketFundingInfo[];
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* Funding observations keyed by Enigma symbol ID or Rasa ticker, with per-epoch fractional rates.
|
|
19
|
+
* @example const rows: GetFundingInfoReturnType = await getFundingInfo(config, { symbolIds: [117] });
|
|
20
|
+
*/
|
|
21
|
+
export type GetFundingInfoReturnType<K extends SymmioSolverKind = SymmioSolverKind> = NormalizedFundingInfoByKind[K][];
|
|
22
|
+
/**
|
|
23
|
+
* Fetch per-market funding rates from Enigma `/funding-info` or Rasa `/get_funding_info`
|
|
15
24
|
* endpoint. Returns the next-epoch long/short funding rate, next funding time,
|
|
16
|
-
* and epoch length for every market (or only the requested `symbols`). The
|
|
25
|
+
* and epoch length for every market (or only the requested Enigma `symbolIds` or Rasa `symbols`). The
|
|
17
26
|
* solver base URL is resolved from `config` per call, so multiple chains never
|
|
18
27
|
* clobber each other.
|
|
19
28
|
*
|
|
@@ -21,17 +30,17 @@ export type GetFundingInfoReturnType = MarketFundingInfo[];
|
|
|
21
30
|
* reports them (multiply by `100` for a percentage); no scaling is applied.
|
|
22
31
|
*
|
|
23
32
|
* @param config - The SDK config.
|
|
24
|
-
* @param parameters - Optional chain
|
|
33
|
+
* @param parameters - Optional chain, solver and solver-specific filter.
|
|
25
34
|
* @returns Normalized funding info, one {@link MarketFundingInfo} per market.
|
|
26
35
|
* @throws {SymmApiError} when the API request fails.
|
|
27
|
-
* @throws {SymmError} when the chain is unsupported.
|
|
36
|
+
* @throws {SymmError} when the chain is unsupported or a filter targets the wrong solver (INVALID_FUNDING_FILTER).
|
|
28
37
|
*
|
|
29
38
|
* @example
|
|
30
39
|
* ```ts
|
|
31
|
-
* const funding = await getFundingInfo(config);
|
|
32
|
-
* const btc = funding.find((f) => f.
|
|
40
|
+
* const funding = await getFundingInfo(config, { solverId: "enigma" });
|
|
41
|
+
* const btc = funding.find((f) => f.symbolId === 1);
|
|
33
42
|
* console.log(btc?.nextFundingRateLong); // 0.0001 → 0.01%
|
|
34
43
|
* ```
|
|
35
44
|
*/
|
|
36
|
-
export declare function getFundingInfo(config: Config, parameters?: GetFundingInfoParameters): Promise<GetFundingInfoReturnType
|
|
45
|
+
export declare function getFundingInfo<K extends SymmioSolverKind = SymmioSolverKind>(config: Config, parameters?: GetFundingInfoParameters<K>): Promise<GetFundingInfoReturnType<K>>;
|
|
37
46
|
//# sourceMappingURL=get-funding-info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-funding-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/get-funding-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"get-funding-info.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/get-funding-info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAG/E,OAAO,KAAK,EAAqB,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE9E;;;GAGG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,OAAO,CAC3F,gBAAgB,GAAG;IACjB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,+GAA+G;IAC/G,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,wDAAwD;IACxD,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;AAEvH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAChF,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,wBAAwB,CAAC,CAAC,CAAM,GAC3C,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CA4CtC"}
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { fetchEnigmaFundingInfo as n } from "./adapters/enigma-funding-info.js";
|
|
3
|
+
import { fetchRasaFundingInfo as r } from "./adapters/rasa-funding-info.js";
|
|
4
4
|
import { isAxiosError as i } from "axios";
|
|
5
5
|
//#region src/solvers/funding-info/get-funding-info.ts
|
|
6
|
-
async function a(
|
|
7
|
-
|
|
8
|
-
chainId:
|
|
9
|
-
solverId:
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
async function o(a, o) {
|
|
6
|
+
async function a(a, o = {}) {
|
|
7
|
+
let s = a.getSolver({
|
|
8
|
+
chainId: o.chainId,
|
|
9
|
+
solverId: o.solverId
|
|
10
|
+
});
|
|
13
11
|
try {
|
|
14
|
-
let e
|
|
15
|
-
|
|
12
|
+
let e;
|
|
13
|
+
switch (s.id) {
|
|
14
|
+
case "enigma":
|
|
15
|
+
if (o.symbols !== void 0) throw new t("validation", "INVALID_FUNDING_FILTER", "Enigma funding accepts symbolIds, not ticker symbols.");
|
|
16
|
+
e = await n(s.url, o.symbolIds);
|
|
17
|
+
break;
|
|
18
|
+
case "rasa":
|
|
19
|
+
if (o.symbolIds !== void 0) throw new t("validation", "INVALID_FUNDING_FILTER", "Rasa funding accepts ticker symbols, not symbolIds.");
|
|
20
|
+
e = await r(s.url, o.symbols);
|
|
21
|
+
break;
|
|
22
|
+
default: {
|
|
23
|
+
let e = s.id;
|
|
24
|
+
throw new t("api", "UNSUPPORTED_BY_SOLVER", `Funding info is not supported by solver kind "${e}".`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
16
28
|
} catch (n) {
|
|
17
29
|
throw n instanceof t ? n : i(n) ? e.fromAxios(n, {
|
|
18
30
|
code: "FETCH_FUNDING_INFO_FAILED",
|
|
19
|
-
baseURL:
|
|
31
|
+
baseURL: s.url
|
|
20
32
|
}) : new t("api", "FETCH_FUNDING_INFO_FAILED", `Failed to fetch funding info: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
|
|
21
33
|
}
|
|
22
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-funding-info.js","names":[],"sources":["../../../src/solvers/funding-info/get-funding-info.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type {
|
|
1
|
+
{"version":3,"file":"get-funding-info.js","names":[],"sources":["../../../src/solvers/funding-info/get-funding-info.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { SymmioSolverKind } from \"../../core/chains/types\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { fetchEnigmaFundingInfo } from \"./adapters/enigma-funding-info\";\nimport { fetchRasaFundingInfo } from \"./adapters/rasa-funding-info\";\nimport type { MarketFundingInfo, NormalizedFundingInfoByKind } from \"./types\";\n\n/**\n * Parameters for {@link getFundingInfo}.\n * @example const parameters: GetFundingInfoParameters = { chainId: 42161, symbolIds: [117, 185] };\n */\nexport type GetFundingInfoParameters<K extends SymmioSolverKind = SymmioSolverKind> = Compute<\n ChainIdParameter & {\n /** Select a solver; a literal narrows the returned rows. */\n solverId?: K;\n /** Enigma only: restrict the result to these symbol IDs. Omit to fetch every market (the endpoint default). */\n symbolIds?: readonly number[];\n /** Rasa ticker filter. Only valid for a Rasa solver. */\n symbols?: readonly string[];\n }\n>;\n\n/**\n * Funding observations keyed by Enigma symbol ID or Rasa ticker, with per-epoch fractional rates.\n * @example const rows: GetFundingInfoReturnType = await getFundingInfo(config, { symbolIds: [117] });\n */\nexport type GetFundingInfoReturnType<K extends SymmioSolverKind = SymmioSolverKind> = NormalizedFundingInfoByKind[K][];\n\n/**\n * Fetch per-market funding rates from Enigma `/funding-info` or Rasa `/get_funding_info`\n * endpoint. Returns the next-epoch long/short funding rate, next funding time,\n * and epoch length for every market (or only the requested Enigma `symbolIds` or Rasa `symbols`). The\n * solver base URL is resolved from `config` per call, so multiple chains never\n * clobber each other.\n *\n * Rates are surfaced as plain per-epoch decimal fractions exactly as the solver\n * reports them (multiply by `100` for a percentage); no scaling is applied.\n *\n * @param config - The SDK config.\n * @param parameters - Optional chain, solver and solver-specific filter.\n * @returns Normalized funding info, one {@link MarketFundingInfo} per market.\n * @throws {SymmApiError} when the API request fails.\n * @throws {SymmError} when the chain is unsupported or a filter targets the wrong solver (INVALID_FUNDING_FILTER).\n *\n * @example\n * ```ts\n * const funding = await getFundingInfo(config, { solverId: \"enigma\" });\n * const btc = funding.find((f) => f.symbolId === 1);\n * console.log(btc?.nextFundingRateLong); // 0.0001 → 0.01%\n * ```\n */\nexport async function getFundingInfo<K extends SymmioSolverKind = SymmioSolverKind>(\n config: Config,\n parameters: GetFundingInfoParameters<K> = {},\n): Promise<GetFundingInfoReturnType<K>> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n try {\n let rows: MarketFundingInfo[];\n switch (solver.id) {\n case \"enigma\":\n if (parameters.symbols !== undefined)\n throw new SymmError(\n \"validation\",\n \"INVALID_FUNDING_FILTER\",\n \"Enigma funding accepts symbolIds, not ticker symbols.\",\n );\n rows = await fetchEnigmaFundingInfo(solver.url, parameters.symbolIds);\n break;\n case \"rasa\":\n if (parameters.symbolIds !== undefined)\n throw new SymmError(\n \"validation\",\n \"INVALID_FUNDING_FILTER\",\n \"Rasa funding accepts ticker symbols, not symbolIds.\",\n );\n rows = await fetchRasaFundingInfo(solver.url, parameters.symbols);\n break;\n default: {\n const unreachable: never = solver.id;\n throw new SymmError(\n \"api\",\n \"UNSUPPORTED_BY_SOLVER\",\n `Funding info is not supported by solver kind \"${unreachable}\".`,\n );\n }\n }\n return rows as GetFundingInfoReturnType<K>;\n } catch (err) {\n if (err instanceof SymmError) throw err;\n if (isAxiosError(err))\n throw SymmApiError.fromAxios(err, { code: \"FETCH_FUNDING_INFO_FAILED\", baseURL: solver.url });\n throw new SymmError(\n \"api\",\n \"FETCH_FUNDING_INFO_FAILED\",\n `Failed to fetch funding info: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;AAqDA,eAAsB,EACpB,GACA,IAA0C,CAAC,GACL;CACtC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAC9F,IAAI;EACF,IAAI;EACJ,QAAQ,EAAO,IAAf;GACE,KAAK;IACH,IAAI,EAAW,YAAY,KAAA,GACzB,MAAM,IAAI,EACR,cACA,0BACA,uDACF;IACF,IAAO,MAAM,EAAuB,EAAO,KAAK,EAAW,SAAS;IACpE;GACF,KAAK;IACH,IAAI,EAAW,cAAc,KAAA,GAC3B,MAAM,IAAI,EACR,cACA,0BACA,qDACF;IACF,IAAO,MAAM,EAAqB,EAAO,KAAK,EAAW,OAAO;IAChE;GACF,SAAS;IACP,IAAM,IAAqB,EAAO;IAClC,MAAM,IAAI,EACR,OACA,yBACA,iDAAiD,EAAY,GAC/D;GACF;EACF;EACA,OAAO;CACT,SAAS,GAAK;EAIZ,MAHI,aAAe,IAAiB,IAChC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAA6B,SAAS,EAAO;EAAI,CAAC,IACxF,IAAI,EACR,OACA,6BACA,iCAAiC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAChF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
|
+
import { SymmioSolverKind } from '../../core/chains/types.js';
|
|
1
2
|
import { Config } from '../../core/config/index.js';
|
|
2
3
|
import { Compute, ConfigKeyParameter } from '../../shared/types/properties.js';
|
|
3
4
|
import { QueryParameter, SymmioQueryOptions } from '../../shared/types/query.js';
|
|
4
5
|
import { GetFundingInfoParameters, GetFundingInfoReturnType } from './get-funding-info.js';
|
|
5
6
|
/** Data resolved by the {@link getFundingInfoQueryOptions} query. */
|
|
6
|
-
export type GetFundingInfoData = GetFundingInfoReturnType
|
|
7
|
-
/**
|
|
7
|
+
export type GetFundingInfoData<K extends SymmioSolverKind = SymmioSolverKind> = GetFundingInfoReturnType<K>;
|
|
8
|
+
/**
|
|
9
|
+
* Build a funding cache key including the solver-specific filter and deployment identity.
|
|
10
|
+
* @param options - Optional deployment, solver and symbol IDs/tickers; query overrides are excluded.
|
|
11
|
+
* @returns A stable query-key tuple.
|
|
12
|
+
* @throws Does not throw for valid options.
|
|
13
|
+
* @example getFundingInfoQueryKey({ symbolIds: [117, 185] });
|
|
14
|
+
*/
|
|
8
15
|
export declare function getFundingInfoQueryKey(options?: Compute<GetFundingInfoParameters & ConfigKeyParameter>): readonly ["getFundingInfo", Record<string, unknown>];
|
|
9
16
|
/** Query-key type produced by {@link getFundingInfoQueryKey}. */
|
|
10
17
|
export type GetFundingInfoQueryKey = ReturnType<typeof getFundingInfoQueryKey>;
|
|
11
18
|
/** Options accepted by {@link getFundingInfoQueryOptions}. */
|
|
12
|
-
export type GetFundingInfoOptions = Compute<GetFundingInfoParameters & QueryParameter<GetFundingInfoData
|
|
19
|
+
export type GetFundingInfoOptions<K extends SymmioSolverKind = SymmioSolverKind> = Compute<GetFundingInfoParameters<K> & QueryParameter<GetFundingInfoData<K>, Error, GetFundingInfoData<K>, GetFundingInfoQueryKey>>;
|
|
13
20
|
/** TanStack Query options returned by {@link getFundingInfoQueryOptions}. */
|
|
14
|
-
export type GetFundingInfoQueryOptions = SymmioQueryOptions<GetFundingInfoData
|
|
21
|
+
export type GetFundingInfoQueryOptions<K extends SymmioSolverKind = SymmioSolverKind> = SymmioQueryOptions<GetFundingInfoData<K>, Error, GetFundingInfoData<K>, GetFundingInfoQueryKey>;
|
|
15
22
|
/**
|
|
16
23
|
* Build TanStack Query options for {@link getFundingInfo}.
|
|
17
24
|
*
|
|
18
25
|
* @param config - The SDK config.
|
|
19
|
-
* @param options - Query parameters (optional `chainId` / `symbols`) and TanStack overrides.
|
|
26
|
+
* @param options - Query parameters (optional `chainId`, `solverId`, `symbolIds` / `symbols`) and TanStack overrides.
|
|
27
|
+
* @throws {SymmError} When configuration cannot be resolved; the query function propagates action errors.
|
|
20
28
|
* @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.
|
|
21
29
|
*
|
|
22
30
|
* @example
|
|
@@ -24,5 +32,5 @@ export type GetFundingInfoQueryOptions = SymmioQueryOptions<GetFundingInfoData,
|
|
|
24
32
|
* useQuery(getFundingInfoQueryOptions(config, {}));
|
|
25
33
|
* ```
|
|
26
34
|
*/
|
|
27
|
-
export declare function getFundingInfoQueryOptions(config: Config, options?: GetFundingInfoOptions): GetFundingInfoQueryOptions
|
|
35
|
+
export declare function getFundingInfoQueryOptions<K extends SymmioSolverKind = SymmioSolverKind>(config: Config, options?: GetFundingInfoOptions<K>): GetFundingInfoQueryOptions<K>;
|
|
28
36
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAAkB,KAAK,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAElH,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,wBAAwB,CAAC
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/funding-info/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAAkB,KAAK,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAElH,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAE5G;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,OAAO,CAAC,wBAAwB,GAAG,kBAAkB,CAAM,wDAE1G;AAED,iEAAiE;AACjE,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE/E,8DAA8D;AAC9D,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,OAAO,CACxF,wBAAwB,CAAC,CAAC,CAAC,GACzB,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAC9F,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,kBAAkB,CACxG,kBAAkB,CAAC,CAAC,CAAC,EACrB,KAAK,EACL,kBAAkB,CAAC,CAAC,CAAC,EACrB,sBAAsB,CACvB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EACtF,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,qBAAqB,CAAC,CAAC,CAAM,GACrC,0BAA0B,CAAC,CAAC,CAAC,CAgB/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/funding-info/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport { getFundingInfo, type GetFundingInfoParameters, type GetFundingInfoReturnType } from \"./get-funding-info\";\n\n/** Data resolved by the {@link getFundingInfoQueryOptions} query. */\nexport type GetFundingInfoData = GetFundingInfoReturnType
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/funding-info/query.ts"],"sourcesContent":["import type { SymmioSolverKind } from \"../../core/chains/types\";\nimport type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport { getFundingInfo, type GetFundingInfoParameters, type GetFundingInfoReturnType } from \"./get-funding-info\";\n\n/** Data resolved by the {@link getFundingInfoQueryOptions} query. */\nexport type GetFundingInfoData<K extends SymmioSolverKind = SymmioSolverKind> = GetFundingInfoReturnType<K>;\n\n/**\n * Build a funding cache key including the solver-specific filter and deployment identity.\n * @param options - Optional deployment, solver and symbol IDs/tickers; query overrides are excluded.\n * @returns A stable query-key tuple.\n * @throws Does not throw for valid options.\n * @example getFundingInfoQueryKey({ symbolIds: [117, 185] });\n */\nexport function getFundingInfoQueryKey(options: Compute<GetFundingInfoParameters & ConfigKeyParameter> = {}) {\n return [\"getFundingInfo\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getFundingInfoQueryKey}. */\nexport type GetFundingInfoQueryKey = ReturnType<typeof getFundingInfoQueryKey>;\n\n/** Options accepted by {@link getFundingInfoQueryOptions}. */\nexport type GetFundingInfoOptions<K extends SymmioSolverKind = SymmioSolverKind> = Compute<\n GetFundingInfoParameters<K> &\n QueryParameter<GetFundingInfoData<K>, Error, GetFundingInfoData<K>, GetFundingInfoQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getFundingInfoQueryOptions}. */\nexport type GetFundingInfoQueryOptions<K extends SymmioSolverKind = SymmioSolverKind> = SymmioQueryOptions<\n GetFundingInfoData<K>,\n Error,\n GetFundingInfoData<K>,\n GetFundingInfoQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getFundingInfo}.\n *\n * @param config - The SDK config.\n * @param options - Query parameters (optional `chainId`, `solverId`, `symbolIds` / `symbols`) and TanStack overrides.\n * @throws {SymmError} When configuration cannot be resolved; the query function propagates action errors.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(getFundingInfoQueryOptions(config, {}));\n * ```\n */\nexport function getFundingInfoQueryOptions<K extends SymmioSolverKind = SymmioSolverKind>(\n config: Config,\n options: GetFundingInfoOptions<K> = {},\n): GetFundingInfoQueryOptions<K> {\n return {\n ...options.query,\n queryKey: getFundingInfoQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () =>\n getFundingInfo<K>(config, {\n chainId: options.chainId,\n solverId: options.solverId,\n symbolIds: options.symbolIds,\n symbols: options.symbols,\n }),\n };\n}\n"],"mappings":";;;AAiBA,SAAgB,EAAuB,IAAkE,CAAC,GAAG;CAC3G,OAAO,CAAC,kBAAkB,EAAmB,CAAO,CAAC;AACvD;AAgCA,SAAgB,EACd,GACA,IAAoC,CAAC,GACN;CAC/B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAuB;GAC/B,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eACE,EAAkB,GAAQ;GACxB,SAAS,EAAQ;GACjB,UAAU,EAAQ;GAClB,WAAW,EAAQ;GACnB,SAAS,EAAQ;EACnB,CAAC;CACL;AACF"}
|