@symmio/trading-react 3.3.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.
Files changed (38) hide show
  1. package/dist/estimated-price/use-estimated-price.js +2 -2
  2. package/dist/estimated-price/use-estimated-price.js.map +1 -1
  3. package/dist/funding-info/use-funding-info.d.ts +10 -7
  4. package/dist/funding-info/use-funding-info.d.ts.map +1 -1
  5. package/dist/funding-info/use-funding-info.js.map +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +111 -109
  9. package/dist/market-info/use-market-info.d.ts +3 -0
  10. package/dist/market-info/use-market-info.d.ts.map +1 -1
  11. package/dist/market-info/use-market-info.js.map +1 -1
  12. package/dist/notional-cap/index.d.ts +1 -0
  13. package/dist/notional-cap/index.d.ts.map +1 -1
  14. package/dist/notional-cap/use-notional-cap-all.d.ts +1 -1
  15. package/dist/notional-cap/use-notional-cap-all.js.map +1 -1
  16. package/dist/notional-cap/use-notional-cap-page.d.ts +39 -0
  17. package/dist/notional-cap/use-notional-cap-page.d.ts.map +1 -0
  18. package/dist/notional-cap/use-notional-cap-page.js +32 -0
  19. package/dist/notional-cap/use-notional-cap-page.js.map +1 -0
  20. package/dist/pools/index.d.ts +1 -0
  21. package/dist/pools/index.d.ts.map +1 -1
  22. package/dist/pools/index.js +9 -8
  23. package/dist/pools/use-listing-markets.d.ts +2 -0
  24. package/dist/pools/use-listing-markets.d.ts.map +1 -1
  25. package/dist/pools/use-listing-markets.js.map +1 -1
  26. package/dist/pools/use-pool-transactions.d.ts +13 -5
  27. package/dist/pools/use-pool-transactions.d.ts.map +1 -1
  28. package/dist/pools/use-pool-transactions.js +1 -1
  29. package/dist/pools/use-pool-transactions.js.map +1 -1
  30. package/dist/pools/use-token-price.d.ts +50 -0
  31. package/dist/pools/use-token-price.d.ts.map +1 -0
  32. package/dist/pools/use-token-price.js +28 -0
  33. package/dist/pools/use-token-price.js.map +1 -0
  34. package/dist/quotes/use-close-quote-group.d.ts +7 -0
  35. package/dist/quotes/use-close-quote-group.d.ts.map +1 -1
  36. package/dist/quotes/use-close-quote-group.js +20 -19
  37. package/dist/quotes/use-close-quote-group.js.map +1 -1
  38. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"use-notional-cap-all.js","names":[],"sources":["../../src/notional-cap/use-notional-cap-all.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getNotionalCapAllQueryOptions,\n type ConfigParameter,\n type GetNotionalCapAllOptions,\n type GetNotionalCapAllReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { DEFAULT_NOTIONAL_CAP_POLLING_MS } from \"./use-notional-cap-by-symbol-id\";\n\n/**\n * Parameters for {@link useNotionalCapAll}: the core query options plus an\n * optional `config` and a `pollingInterval` knob layered on top of\n * `query.refetchInterval`.\n */\nexport type UseNotionalCapAllParameters = GetNotionalCapAllOptions &\n ConfigParameter & {\n /**\n * Polling cadence in milliseconds. Defaults to\n * {@link DEFAULT_NOTIONAL_CAP_POLLING_MS}. Pass `false` to disable polling.\n */\n pollingInterval?: number | false;\n };\n\n/** Return type of {@link useNotionalCapAll}. */\nexport type UseNotionalCapAllReturnType = UseQueryResult<GetNotionalCapAllReturnType, SymmioRequestError>;\n\n/**\n * Read every market's notional cap in one solver call. Surfaces the aggregate\n * `totalOpenInterest` / `totalUsed` plus the per-symbol rows.\n *\n * Polls every {@link DEFAULT_NOTIONAL_CAP_POLLING_MS} by default; pass\n * `pollingInterval` to change or disable.\n *\n * @example\n * ```tsx\n * const { data } = useNotionalCapAll();\n * console.log(data?.totalOpenInterest, data?.symbols.length);\n * ```\n */\nexport function useNotionalCapAll(parameters: UseNotionalCapAllParameters = {}): UseNotionalCapAllReturnType {\n const { pollingInterval = DEFAULT_NOTIONAL_CAP_POLLING_MS, query, ...rest } = parameters;\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getNotionalCapAllQueryOptions(config, {\n ...rest,\n chainId: rest.chainId ?? chainId,\n query: {\n refetchInterval: pollingInterval === false ? false : pollingInterval,\n ...query,\n },\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseNotionalCapAllReturnType;\n}\n"],"mappings":";;;;;;;;AA6CA,SAAgB,EAAkB,IAA0C,CAAC,GAAgC;CAC3G,IAAM,EAAE,qBAAkB,GAAiC,UAAO,GAAG,MAAS,GACxE,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA8B,GAAQ;EACpD,GAAG;EACH,SAAS,EAAK,WAAW;EACzB,OAAO;GACL,iBAAiB,MAAoB,KAAQ,KAAQ;GACrD,GAAG;EACL;CACF,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-notional-cap-all.js","names":[],"sources":["../../src/notional-cap/use-notional-cap-all.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getNotionalCapAllQueryOptions,\n type ConfigParameter,\n type GetNotionalCapAllOptions,\n type GetNotionalCapAllReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { DEFAULT_NOTIONAL_CAP_POLLING_MS } from \"./use-notional-cap-by-symbol-id\";\n\n/**\n * Parameters for {@link useNotionalCapAll}: the core query options plus an\n * optional `config` and a `pollingInterval` knob layered on top of\n * `query.refetchInterval`.\n */\nexport type UseNotionalCapAllParameters = GetNotionalCapAllOptions &\n ConfigParameter & {\n /**\n * Polling cadence in milliseconds. Defaults to\n * {@link DEFAULT_NOTIONAL_CAP_POLLING_MS}. Pass `false` to disable polling.\n */\n pollingInterval?: number | false;\n };\n\n/** Return type of {@link useNotionalCapAll}. */\nexport type UseNotionalCapAllReturnType = UseQueryResult<GetNotionalCapAllReturnType, SymmioRequestError>;\n\n/**\n * Read every market's notional cap across all solver pages. Surfaces the aggregate\n * `totalOpenInterest` / `totalUsed` plus the per-symbol rows.\n *\n * Polls every {@link DEFAULT_NOTIONAL_CAP_POLLING_MS} by default; pass\n * `pollingInterval` to change or disable.\n *\n * @example\n * ```tsx\n * const { data } = useNotionalCapAll();\n * console.log(data?.totalOpenInterest, data?.symbols.length);\n * ```\n */\nexport function useNotionalCapAll(parameters: UseNotionalCapAllParameters = {}): UseNotionalCapAllReturnType {\n const { pollingInterval = DEFAULT_NOTIONAL_CAP_POLLING_MS, query, ...rest } = parameters;\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getNotionalCapAllQueryOptions(config, {\n ...rest,\n chainId: rest.chainId ?? chainId,\n query: {\n refetchInterval: pollingInterval === false ? false : pollingInterval,\n ...query,\n },\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseNotionalCapAllReturnType;\n}\n"],"mappings":";;;;;;;;AA6CA,SAAgB,EAAkB,IAA0C,CAAC,GAAgC;CAC3G,IAAM,EAAE,qBAAkB,GAAiC,UAAO,GAAG,MAAS,GACxE,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA8B,GAAQ;EACpD,GAAG;EACH,SAAS,EAAK,WAAW;EACzB,OAAO;GACL,iBAAiB,MAAoB,KAAQ,KAAQ;GACrD,GAAG;EACL;CACF,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,39 @@
1
+ import { ConfigParameter, GetNotionalCapPageOptions, GetNotionalCapPageReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Parameters for {@link useNotionalCapPage}: the core query options plus an
6
+ * optional `config` and a `pollingInterval` knob layered on top of
7
+ * `query.refetchInterval`.
8
+ * @example const parameters: UseNotionalCapPageParameters = { offset: 100, pollingInterval: false };
9
+ */
10
+ export type UseNotionalCapPageParameters = GetNotionalCapPageOptions & ConfigParameter & {
11
+ /**
12
+ * Polling cadence in milliseconds. Defaults to
13
+ * {@link DEFAULT_NOTIONAL_CAP_POLLING_MS}. Pass `false` to disable polling.
14
+ */
15
+ pollingInterval?: number | false;
16
+ };
17
+ /**
18
+ * Query state for a cap page, including normalized SDK errors and refetch state.
19
+ * @example const result: UseNotionalCapPageReturnType = useNotionalCapPage({ limit: 50 });
20
+ */
21
+ export type UseNotionalCapPageReturnType = UseQueryResult<GetNotionalCapPageReturnType, SymmioRequestError>;
22
+ /**
23
+ * Read one page of market notional caps. Surfaces the page-only
24
+ * `totalOpenInterest` / `totalUsed` plus the per-symbol rows.
25
+ *
26
+ * Polls every {@link DEFAULT_NOTIONAL_CAP_POLLING_MS} by default; pass
27
+ * `pollingInterval` to change or disable.
28
+ *
29
+ * @param parameters - Page limits, deployment, config and query overrides.
30
+ * @returns Query state containing one page of numeric-dollar caps.
31
+ * @throws {SymmioRequestError} Action failures are normalized in query error state.
32
+ * @example
33
+ * ```tsx
34
+ * const { data } = useNotionalCapPage({ limit: 100, offset: 100 });
35
+ * console.log(data?.totalOpenInterest, data?.symbols.length);
36
+ * ```
37
+ */
38
+ export declare function useNotionalCapPage(parameters?: UseNotionalCapPageParameters): UseNotionalCapPageReturnType;
39
+ //# sourceMappingURL=use-notional-cap-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notional-cap-page.d.ts","sourceRoot":"","sources":["../../src/notional-cap/use-notional-cap-page.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,yBAAyB,GAClE,eAAe,GAAG;IAChB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAClC,CAAC;AAEJ;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,cAAc,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC;AAE5G;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CAuB9G"}
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { DEFAULT_NOTIONAL_CAP_POLLING_MS as r } from "./use-notional-cap-by-symbol-id.js";
6
+ import { getNotionalCapPageQueryOptions as i } from "@symmio/trading-core";
7
+ import { useQuery as a } from "@tanstack/react-query";
8
+ //#region src/notional-cap/use-notional-cap-page.ts
9
+ function o(o = {}) {
10
+ let { pollingInterval: s = r, query: c, ...l } = o, u = t(o), d = e(), f = i(u, {
11
+ ...l,
12
+ chainId: l.chainId ?? d,
13
+ query: {
14
+ refetchInterval: s === !1 ? !1 : s,
15
+ ...c
16
+ }
17
+ });
18
+ return a({
19
+ ...f,
20
+ queryFn: async () => {
21
+ try {
22
+ return await f.queryFn();
23
+ } catch (e) {
24
+ throw n(e);
25
+ }
26
+ }
27
+ });
28
+ }
29
+ //#endregion
30
+ export { o as useNotionalCapPage };
31
+
32
+ //# sourceMappingURL=use-notional-cap-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notional-cap-page.js","names":[],"sources":["../../src/notional-cap/use-notional-cap-page.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getNotionalCapPageQueryOptions,\n type ConfigParameter,\n type GetNotionalCapPageOptions,\n type GetNotionalCapPageReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { DEFAULT_NOTIONAL_CAP_POLLING_MS } from \"./use-notional-cap-by-symbol-id\";\n\n/**\n * Parameters for {@link useNotionalCapPage}: the core query options plus an\n * optional `config` and a `pollingInterval` knob layered on top of\n * `query.refetchInterval`.\n * @example const parameters: UseNotionalCapPageParameters = { offset: 100, pollingInterval: false };\n */\nexport type UseNotionalCapPageParameters = GetNotionalCapPageOptions &\n ConfigParameter & {\n /**\n * Polling cadence in milliseconds. Defaults to\n * {@link DEFAULT_NOTIONAL_CAP_POLLING_MS}. Pass `false` to disable polling.\n */\n pollingInterval?: number | false;\n };\n\n/**\n * Query state for a cap page, including normalized SDK errors and refetch state.\n * @example const result: UseNotionalCapPageReturnType = useNotionalCapPage({ limit: 50 });\n */\nexport type UseNotionalCapPageReturnType = UseQueryResult<GetNotionalCapPageReturnType, SymmioRequestError>;\n\n/**\n * Read one page of market notional caps. Surfaces the page-only\n * `totalOpenInterest` / `totalUsed` plus the per-symbol rows.\n *\n * Polls every {@link DEFAULT_NOTIONAL_CAP_POLLING_MS} by default; pass\n * `pollingInterval` to change or disable.\n *\n * @param parameters - Page limits, deployment, config and query overrides.\n * @returns Query state containing one page of numeric-dollar caps.\n * @throws {SymmioRequestError} Action failures are normalized in query error state.\n * @example\n * ```tsx\n * const { data } = useNotionalCapPage({ limit: 100, offset: 100 });\n * console.log(data?.totalOpenInterest, data?.symbols.length);\n * ```\n */\nexport function useNotionalCapPage(parameters: UseNotionalCapPageParameters = {}): UseNotionalCapPageReturnType {\n const { pollingInterval = DEFAULT_NOTIONAL_CAP_POLLING_MS, query, ...rest } = parameters;\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getNotionalCapPageQueryOptions(config, {\n ...rest,\n chainId: rest.chainId ?? chainId,\n query: {\n refetchInterval: pollingInterval === false ? false : pollingInterval,\n ...query,\n },\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseNotionalCapPageReturnType;\n}\n"],"mappings":";;;;;;;;AAoDA,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,EAAE,qBAAkB,GAAiC,UAAO,GAAG,MAAS,GACxE,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA+B,GAAQ;EACrD,GAAG;EACH,SAAS,EAAK,WAAW;EACzB,OAAO;GACL,iBAAiB,MAAoB,KAAQ,KAAQ;GACrD,GAAG;EACL;CACF,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -19,6 +19,7 @@ export * from './use-refund-market.js';
19
19
  export * from './use-retry-listing.js';
20
20
  export * from './use-retry-listing-info.js';
21
21
  export * from './use-supports-listing-service.js';
22
+ export * from './use-token-price.js';
22
23
  export * from './use-update-listing-market-config.js';
23
24
  export * from './use-user-listing-markets.js';
24
25
  export * from './use-user-profit.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pools/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pools/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC"}
@@ -20,11 +20,12 @@ import { useRefundMarket as v } from "./use-refund-market.js";
20
20
  import { useRetryListing as y } from "./use-retry-listing.js";
21
21
  import { useRetryListingInfo as b } from "./use-retry-listing-info.js";
22
22
  import { useSupportsListingService as x } from "./use-supports-listing-service.js";
23
- import { useUpdateListingMarketConfig as S } from "./use-update-listing-market-config.js";
24
- import { useUserListingMarkets as C } from "./use-user-listing-markets.js";
25
- import { useUserRewardChart as w } from "./use-user-reward-chart.js";
26
- import { useUserTotalReward as T } from "./use-user-total-reward.js";
27
- import { useUserTransactions as E } from "./use-user-transactions.js";
28
- import { useWeeklyListingLimit as D } from "./use-weekly-listing-limit.js";
29
- import { useWithdrawLp as O } from "./use-withdraw-lp.js";
30
- export { e as useAddMarket, t as useAuthenticateListing, n as useCancelWithdraw, r as useClaimHistory, i as useClaimProfit, a as useDepositAddress, o as useListingConfig, s as useListingMarketConfig, u as useListingMarketConfigProjection, c as useListingMarketDetail, d as useListingMarkets, f as useListingStatus, p as usePoolQuotes, m as usePoolRewardChart, h as usePoolTotalReward, g as usePoolTradeHistory, _ as usePoolTransactions, v as useRefundMarket, y as useRetryListing, b as useRetryListingInfo, x as useSupportsListingService, S as useUpdateListingMarketConfig, C as useUserListingMarkets, l as useUserProfit, w as useUserRewardChart, T as useUserTotalReward, E as useUserTransactions, D as useWeeklyListingLimit, O as useWithdrawLp };
23
+ import { useTokenPrice as S } from "./use-token-price.js";
24
+ import { useUpdateListingMarketConfig as C } from "./use-update-listing-market-config.js";
25
+ import { useUserListingMarkets as w } from "./use-user-listing-markets.js";
26
+ import { useUserRewardChart as T } from "./use-user-reward-chart.js";
27
+ import { useUserTotalReward as E } from "./use-user-total-reward.js";
28
+ import { useUserTransactions as D } from "./use-user-transactions.js";
29
+ import { useWeeklyListingLimit as O } from "./use-weekly-listing-limit.js";
30
+ import { useWithdrawLp as k } from "./use-withdraw-lp.js";
31
+ export { e as useAddMarket, t as useAuthenticateListing, n as useCancelWithdraw, r as useClaimHistory, i as useClaimProfit, a as useDepositAddress, o as useListingConfig, s as useListingMarketConfig, u as useListingMarketConfigProjection, c as useListingMarketDetail, d as useListingMarkets, f as useListingStatus, p as usePoolQuotes, m as usePoolRewardChart, h as usePoolTotalReward, g as usePoolTradeHistory, _ as usePoolTransactions, v as useRefundMarket, y as useRetryListing, b as useRetryListingInfo, x as useSupportsListingService, S as useTokenPrice, C as useUpdateListingMarketConfig, w as useUserListingMarkets, l as useUserProfit, T as useUserRewardChart, E as useUserTotalReward, D as useUserTransactions, O as useWeeklyListingLimit, k as useWithdrawLp };
@@ -13,6 +13,8 @@ export type UseListingMarketsReturnType = UseQueryResult<GetListingMarketsReturn
13
13
  * parameter and the hook refetches under a new query key rather than filtering
14
14
  * an already-fetched page in the client. Pass
15
15
  * `marketStatus: ListingMarketStatus.LISTED` to see only tradable markets.
16
+ * Use `isLocked: false` for unlocked markets, `true` for locked markets, or
17
+ * omit it for both. The filter is included in the query key.
16
18
  *
17
19
  * Every money and rate field on a row is a `bigint` at `LISTING_VALUE_DECIMALS`
18
20
  * (18); `null` means the service reported no value, not zero. Errors are
@@ -1 +1 @@
1
- {"version":3,"file":"use-listing-markets.d.ts","sourceRoot":"","sources":["../../src/pools/use-listing-markets.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,kGAAkG;AAClG,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAAG,eAAe,CAAC;AAErF,iFAAiF;AACjF,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,GAAE,2BAAgC,GAAG,2BAA2B,CAkB3G"}
1
+ {"version":3,"file":"use-listing-markets.d.ts","sourceRoot":"","sources":["../../src/pools/use-listing-markets.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,kGAAkG;AAClG,MAAM,MAAM,2BAA2B,GAAG,wBAAwB,GAAG,eAAe,CAAC;AAErF,iFAAiF;AACjF,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,GAAE,2BAAgC,GAAG,2BAA2B,CAkB3G"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-listing-markets.js","names":[],"sources":["../../src/pools/use-listing-markets.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getListingMarketsQueryOptions,\n type ConfigParameter,\n type GetListingMarketsOptions,\n type GetListingMarketsReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useListingMarkets}: the core query options plus an optional `config`. */\nexport type UseListingMarketsParameters = GetListingMarketsOptions & ConfigParameter;\n\n/** Return type of {@link useListingMarkets}: one page of the listing catalog. */\nexport type UseListingMarketsReturnType = UseQueryResult<GetListingMarketsReturnType, SymmioRequestError>;\n\n/**\n * Read a page of the permissionless-listing market catalog — the data behind a\n * pools list.\n *\n * Search, filtering, sorting, and pagination are all server-side: change a\n * parameter and the hook refetches under a new query key rather than filtering\n * an already-fetched page in the client. Pass\n * `marketStatus: ListingMarketStatus.LISTED` to see only tradable markets.\n *\n * Every money and rate field on a row is a `bigint` at `LISTING_VALUE_DECIMALS`\n * (18); `null` means the service reported no value, not zero. Errors are\n * normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data, isPending } = useListingMarkets({\n * marketStatus: ListingMarketStatus.LISTED,\n * sortBy: \"tvl\",\n * limit: 25,\n * offset: page * 25,\n * });\n * ```\n */\nexport function useListingMarkets(parameters: UseListingMarketsParameters = {}): UseListingMarketsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getListingMarketsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseListingMarketsReturnType;\n}\n"],"mappings":";;;;;;;AA2CA,SAAgB,EAAkB,IAA0C,CAAC,GAAgC;CAC3G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA8B,GAAQ;EACpD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-listing-markets.js","names":[],"sources":["../../src/pools/use-listing-markets.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getListingMarketsQueryOptions,\n type ConfigParameter,\n type GetListingMarketsOptions,\n type GetListingMarketsReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useListingMarkets}: the core query options plus an optional `config`. */\nexport type UseListingMarketsParameters = GetListingMarketsOptions & ConfigParameter;\n\n/** Return type of {@link useListingMarkets}: one page of the listing catalog. */\nexport type UseListingMarketsReturnType = UseQueryResult<GetListingMarketsReturnType, SymmioRequestError>;\n\n/**\n * Read a page of the permissionless-listing market catalog — the data behind a\n * pools list.\n *\n * Search, filtering, sorting, and pagination are all server-side: change a\n * parameter and the hook refetches under a new query key rather than filtering\n * an already-fetched page in the client. Pass\n * `marketStatus: ListingMarketStatus.LISTED` to see only tradable markets.\n * Use `isLocked: false` for unlocked markets, `true` for locked markets, or\n * omit it for both. The filter is included in the query key.\n *\n * Every money and rate field on a row is a `bigint` at `LISTING_VALUE_DECIMALS`\n * (18); `null` means the service reported no value, not zero. Errors are\n * normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data, isPending } = useListingMarkets({\n * marketStatus: ListingMarketStatus.LISTED,\n * sortBy: \"tvl\",\n * limit: 25,\n * offset: page * 25,\n * });\n * ```\n */\nexport function useListingMarkets(parameters: UseListingMarketsParameters = {}): UseListingMarketsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getListingMarketsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseListingMarketsReturnType;\n}\n"],"mappings":";;;;;;;AA6CA,SAAgB,EAAkB,IAA0C,CAAC,GAAgC;CAC3G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA8B,GAAQ;EACpD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -6,18 +6,26 @@ export type UsePoolTransactionsParameters = GetPoolTransactionsOptions & ConfigP
6
6
  /** Return type of {@link usePoolTransactions}: one page of transaction rows. */
7
7
  export type UsePoolTransactionsReturnType = UseQueryResult<GetPoolTransactionsReturnType, SymmioRequestError>;
8
8
  /**
9
- * Read a pool's deposit and withdrawal history — refunded deposits included.
9
+ * Read pool deposit and withdrawal history — refunded deposits included —
10
+ * newest first.
10
11
  *
11
- * Pool-wide by default: every LP's rows, not just the connected wallet's. Pass
12
- * `walletAddress` to narrow it to one wallet.
12
+ * Public and unscoped by default: every LP's rows on **every** pool, not just
13
+ * the connected wallet's. Narrow it with `tokenAddress` (one pool),
14
+ * `marketChainId`, `walletAddress`, `transactionType` and `transactionStatus`;
15
+ * each row names its own pool (`tokenAddress`, `chainId`). The service fixes the
16
+ * order newest first and takes no sort parameter.
13
17
  *
14
18
  * `count` is the total across all pages, so it is what a pager should divide —
15
19
  * not `items.length`. Errors are normalized to {@link SymmioRequestError}.
16
20
  *
17
21
  * @example
18
22
  * ```tsx
19
- * const { data } = usePoolTransactions({ marketAddress, size: 25, start: page * 25 });
23
+ * // One pool, 25 rows a page.
24
+ * const { data } = usePoolTransactions({ tokenAddress, size: 25, start: page * 25 });
25
+ *
26
+ * // The latest activity across every pool.
27
+ * const { data: latest } = usePoolTransactions();
20
28
  * ```
21
29
  */
22
- export declare function usePoolTransactions(parameters: UsePoolTransactionsParameters): UsePoolTransactionsReturnType;
30
+ export declare function usePoolTransactions(parameters?: UsePoolTransactionsParameters): UsePoolTransactionsReturnType;
23
31
  //# sourceMappingURL=use-pool-transactions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-pool-transactions.d.ts","sourceRoot":"","sources":["../../src/pools/use-pool-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,oGAAoG;AACpG,MAAM,MAAM,6BAA6B,GAAG,0BAA0B,GAAG,eAAe,CAAC;AAEzF,gFAAgF;AAChF,MAAM,MAAM,6BAA6B,GAAG,cAAc,CAAC,6BAA6B,EAAE,kBAAkB,CAAC,CAAC;AAE9G;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,6BAA6B,GAAG,6BAA6B,CAkB5G"}
1
+ {"version":3,"file":"use-pool-transactions.d.ts","sourceRoot":"","sources":["../../src/pools/use-pool-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,oGAAoG;AACpG,MAAM,MAAM,6BAA6B,GAAG,0BAA0B,GAAG,eAAe,CAAC;AAEzF,gFAAgF;AAChF,MAAM,MAAM,6BAA6B,GAAG,cAAc,CAAC,6BAA6B,EAAE,kBAAkB,CAAC,CAAC;AAE9G;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,6BAAkC,GAAG,6BAA6B,CAkBjH"}
@@ -5,7 +5,7 @@ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
5
  import { getPoolTransactionsQueryOptions as r } from "@symmio/trading-core";
6
6
  import { useQuery as i } from "@tanstack/react-query";
7
7
  //#region src/pools/use-pool-transactions.ts
8
- function a(a) {
8
+ function a(a = {}) {
9
9
  let o = t(a), s = e(), c = r(o, {
10
10
  ...a,
11
11
  chainId: a.chainId ?? s
@@ -1 +1 @@
1
- {"version":3,"file":"use-pool-transactions.js","names":[],"sources":["../../src/pools/use-pool-transactions.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getPoolTransactionsQueryOptions,\n type ConfigParameter,\n type GetPoolTransactionsOptions,\n type GetPoolTransactionsReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link usePoolTransactions}: the core query options plus an optional `config`. */\nexport type UsePoolTransactionsParameters = GetPoolTransactionsOptions & ConfigParameter;\n\n/** Return type of {@link usePoolTransactions}: one page of transaction rows. */\nexport type UsePoolTransactionsReturnType = UseQueryResult<GetPoolTransactionsReturnType, SymmioRequestError>;\n\n/**\n * Read a pool's deposit and withdrawal history — refunded deposits included.\n *\n * Pool-wide by default: every LP's rows, not just the connected wallet's. Pass\n * `walletAddress` to narrow it to one wallet.\n *\n * `count` is the total across all pages, so it is what a pager should divide —\n * not `items.length`. Errors are normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data } = usePoolTransactions({ marketAddress, size: 25, start: page * 25 });\n * ```\n */\nexport function usePoolTransactions(parameters: UsePoolTransactionsParameters): UsePoolTransactionsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getPoolTransactionsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UsePoolTransactionsReturnType;\n}\n"],"mappings":";;;;;;;AAkCA,SAAgB,EAAoB,GAA0E;CAC5G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAgC,GAAQ;EACtD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-pool-transactions.js","names":[],"sources":["../../src/pools/use-pool-transactions.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getPoolTransactionsQueryOptions,\n type ConfigParameter,\n type GetPoolTransactionsOptions,\n type GetPoolTransactionsReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link usePoolTransactions}: the core query options plus an optional `config`. */\nexport type UsePoolTransactionsParameters = GetPoolTransactionsOptions & ConfigParameter;\n\n/** Return type of {@link usePoolTransactions}: one page of transaction rows. */\nexport type UsePoolTransactionsReturnType = UseQueryResult<GetPoolTransactionsReturnType, SymmioRequestError>;\n\n/**\n * Read pool deposit and withdrawal history — refunded deposits included —\n * newest first.\n *\n * Public and unscoped by default: every LP's rows on **every** pool, not just\n * the connected wallet's. Narrow it with `tokenAddress` (one pool),\n * `marketChainId`, `walletAddress`, `transactionType` and `transactionStatus`;\n * each row names its own pool (`tokenAddress`, `chainId`). The service fixes the\n * order newest first and takes no sort parameter.\n *\n * `count` is the total across all pages, so it is what a pager should divide —\n * not `items.length`. Errors are normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * // One pool, 25 rows a page.\n * const { data } = usePoolTransactions({ tokenAddress, size: 25, start: page * 25 });\n *\n * // The latest activity across every pool.\n * const { data: latest } = usePoolTransactions();\n * ```\n */\nexport function usePoolTransactions(parameters: UsePoolTransactionsParameters = {}): UsePoolTransactionsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getPoolTransactionsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UsePoolTransactionsReturnType;\n}\n"],"mappings":";;;;;;;AA0CA,SAAgB,EAAoB,IAA4C,CAAC,GAAkC;CACjH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAgC,GAAQ;EACtD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,50 @@
1
+ import { ConfigParameter, GetTokenPriceOptions, GetTokenPriceReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /** Parameters for {@link useTokenPrice}: the core query options plus an optional `config`. */
5
+ export type UseTokenPriceParameters = GetTokenPriceOptions & ConfigParameter;
6
+ /** Return type of {@link useTokenPrice}: the token's pre-listing price estimate. */
7
+ export type UseTokenPriceReturnType = UseQueryResult<GetTokenPriceReturnType, SymmioRequestError>;
8
+ /**
9
+ * Read a pre-listing **price estimate** for a token — what the Price Service
10
+ * thinks one unit is worth in USD, before (or regardless of whether) the token
11
+ * is listed as a pool. The read a create-pool form shows next to the address
12
+ * the user just pasted.
13
+ *
14
+ * This is an authed read: it takes a Bearer `accessToken` from
15
+ * {@link useAuthenticateListing}, the token's `chain` by vendor name
16
+ * (`TokenPriceChain`, not a numeric chain id), and its `tokenAddress`. The
17
+ * token and the address both gate the query: until the `accessToken` **and**
18
+ * the `tokenAddress` are non-empty strings the hook stays idle
19
+ * (`enabled: false`) rather than firing an incomplete or unauthenticated
20
+ * request, so it can be mounted before sign-in or before an address is typed.
21
+ *
22
+ * The figure is an **estimate**, not a mark or trade price: the backend caches
23
+ * it for about five minutes and rate-limits the endpoint, so the query defaults
24
+ * to a five-minute `staleTime` / `gcTime` and the same inputs inside that
25
+ * window are served from the cache with no refetch. Render it with a `~` and
26
+ * do not poll — pass `query.staleTime` only if you really need it fresher.
27
+ * Enigma-only; errors are normalized to {@link SymmioRequestError}, with a
28
+ * `401` meaning the token is bad or expired.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * const login = useAuthenticateListing();
33
+ * const [token, setToken] = useState("");
34
+ * const [address, setAddress] = useState("");
35
+ *
36
+ * const { data, isPending } = useTokenPrice({
37
+ * accessToken: token,
38
+ * chain: TokenPriceChain.ARC,
39
+ * tokenAddress: address,
40
+ * });
41
+ *
42
+ * // sign in first, then feed the token to the hook:
43
+ * login.mutate({}, { onSuccess: (result) => setToken(result.accessToken) });
44
+ *
45
+ * // the estimate, once the user has pasted an address:
46
+ * data ? `~$${data.price}` : "—";
47
+ * ```
48
+ */
49
+ export declare function useTokenPrice(parameters: UseTokenPriceParameters): UseTokenPriceReturnType;
50
+ //# sourceMappingURL=use-token-price.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-token-price.d.ts","sourceRoot":"","sources":["../../src/pools/use-token-price.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,8FAA8F;AAC9F,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAE7E,oFAAoF;AACpF,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;AAElG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,uBAAuB,GAAG,uBAAuB,CAoB1F"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { getTokenPriceQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/pools/use-token-price.ts
8
+ function a(a) {
9
+ let o = t(a), s = e(), c = r(o, {
10
+ ...a,
11
+ chainId: a.chainId ?? s
12
+ });
13
+ return i({
14
+ ...c,
15
+ enabled: (a.query?.enabled ?? !0) && a.accessToken.length > 0 && a.tokenAddress.length > 0,
16
+ queryFn: async () => {
17
+ try {
18
+ return await c.queryFn();
19
+ } catch (e) {
20
+ throw n(e);
21
+ }
22
+ }
23
+ });
24
+ }
25
+ //#endregion
26
+ export { a as useTokenPrice };
27
+
28
+ //# sourceMappingURL=use-token-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-token-price.js","names":[],"sources":["../../src/pools/use-token-price.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getTokenPriceQueryOptions,\n type ConfigParameter,\n type GetTokenPriceOptions,\n type GetTokenPriceReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useTokenPrice}: the core query options plus an optional `config`. */\nexport type UseTokenPriceParameters = GetTokenPriceOptions & ConfigParameter;\n\n/** Return type of {@link useTokenPrice}: the token's pre-listing price estimate. */\nexport type UseTokenPriceReturnType = UseQueryResult<GetTokenPriceReturnType, SymmioRequestError>;\n\n/**\n * Read a pre-listing **price estimate** for a token — what the Price Service\n * thinks one unit is worth in USD, before (or regardless of whether) the token\n * is listed as a pool. The read a create-pool form shows next to the address\n * the user just pasted.\n *\n * This is an authed read: it takes a Bearer `accessToken` from\n * {@link useAuthenticateListing}, the token's `chain` by vendor name\n * (`TokenPriceChain`, not a numeric chain id), and its `tokenAddress`. The\n * token and the address both gate the query: until the `accessToken` **and**\n * the `tokenAddress` are non-empty strings the hook stays idle\n * (`enabled: false`) rather than firing an incomplete or unauthenticated\n * request, so it can be mounted before sign-in or before an address is typed.\n *\n * The figure is an **estimate**, not a mark or trade price: the backend caches\n * it for about five minutes and rate-limits the endpoint, so the query defaults\n * to a five-minute `staleTime` / `gcTime` and the same inputs inside that\n * window are served from the cache with no refetch. Render it with a `~` and\n * do not poll — pass `query.staleTime` only if you really need it fresher.\n * Enigma-only; errors are normalized to {@link SymmioRequestError}, with a\n * `401` meaning the token is bad or expired.\n *\n * @example\n * ```tsx\n * const login = useAuthenticateListing();\n * const [token, setToken] = useState(\"\");\n * const [address, setAddress] = useState(\"\");\n *\n * const { data, isPending } = useTokenPrice({\n * accessToken: token,\n * chain: TokenPriceChain.ARC,\n * tokenAddress: address,\n * });\n *\n * // sign in first, then feed the token to the hook:\n * login.mutate({}, { onSuccess: (result) => setToken(result.accessToken) });\n *\n * // the estimate, once the user has pasted an address:\n * data ? `~$${data.price}` : \"—\";\n * ```\n */\nexport function useTokenPrice(parameters: UseTokenPriceParameters): UseTokenPriceReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getTokenPriceQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n enabled:\n (parameters.query?.enabled ?? true) && parameters.accessToken.length > 0 && parameters.tokenAddress.length > 0,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseTokenPriceReturnType;\n}\n"],"mappings":";;;;;;;AA6DA,SAAgB,EAAc,GAA8D;CAC1F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA0B,GAAQ;EAChD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,UACG,EAAW,OAAO,WAAW,OAAS,EAAW,YAAY,SAAS,KAAK,EAAW,aAAa,SAAS;EAC/G,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -42,6 +42,13 @@ export interface CloseQuoteGroupParameters {
42
42
  markPrice?: string;
43
43
  /** Delegated session key to submit the closes from, when delegation is active. */
44
44
  from?: Address;
45
+ /**
46
+ * Check that the signer holds the `requestToClosePosition` delegation before
47
+ * any close is signed. Defaults to `true`; a run that fails it reports
48
+ * `INSTANT_SIGNER_NOT_DELEGATED` in its summary's `error`. Pass `false` when
49
+ * your UI already gates the close on delegation.
50
+ */
51
+ preflightDelegation?: boolean;
45
52
  /**
46
53
  * Account whose live notification stream reports the close fills — pass the
47
54
  * **sub-account** when closing Virtual Account quotes (the VA frames arrive
@@ -1 +1 @@
1
- {"version":3,"file":"use-close-quote-group.d.ts","sourceRoot":"","sources":["../../src/quotes/use-close-quote-group.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,eAAe,EAEpB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAgBzE;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnF,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,mDAAmD;I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IACvB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,sEAAsE;IACtE,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,sEAAsE;IACtE,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAa3D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CAoM9G"}
@@ -65,42 +65,42 @@ function y(y = {}) {
65
65
  steps: [],
66
66
  error: n(/* @__PURE__ */ Error("A group close is already in flight."))
67
67
  };
68
- let { group: t, targetQuantity: r, minAcceptableQuoteValue: a, slippage: d, markPrice: f, from: p, notificationsAccount: m } = e, h = e.chainId ?? x, _ = c(l(t.quotes, a), r);
69
- if (!_.feasible) return A({
68
+ let { group: t, targetQuantity: r, minAcceptableQuoteValue: a, slippage: d, markPrice: f, from: p, preflightDelegation: m, notificationsAccount: h } = e, _ = e.chainId ?? x, v = c(l(t.quotes, a), r);
69
+ if (!v.feasible) return A({
70
70
  status: "failed",
71
71
  steps: [],
72
72
  closedQuantity: 0n,
73
73
  targetQuantity: r,
74
- planFailure: _
74
+ planFailure: v
75
75
  }), {
76
76
  ok: !1,
77
77
  closedQuantity: 0n,
78
78
  steps: [],
79
- planFailure: _
79
+ planFailure: v
80
80
  };
81
- let v = new Map(t.quotes.map((e) => [e.key, e])), y = _.allocations.map((e) => ({
81
+ let y = new Map(t.quotes.map((e) => [e.key, e])), C = v.allocations.map((e) => ({
82
82
  key: e.key,
83
- quoteId: v.get(e.key).quoteId,
83
+ quoteId: y.get(e.key).quoteId,
84
84
  closeQuantity: e.closeQuantity,
85
85
  kind: e.kind,
86
86
  status: "queued"
87
87
  }));
88
88
  E.current = !0;
89
- let C = v.get(y[0].key);
90
- k.current = h, O(m ?? C.vaAddress ?? C.partyA), A({
89
+ let w = y.get(C[0].key);
90
+ k.current = _, O(h ?? w.vaAddress ?? w.partyA), A({
91
91
  status: "closing",
92
- steps: y.map((e) => ({
92
+ steps: C.map((e) => ({
93
93
  ...e,
94
94
  status: "closing"
95
95
  })),
96
96
  closedQuantity: 0n,
97
97
  targetQuantity: r
98
98
  });
99
- let w = s(b);
99
+ let D = s(b);
100
100
  try {
101
- await w.mutationFn({
102
- orders: y.map((e) => {
103
- let t = v.get(e.key);
101
+ await D.mutationFn({
102
+ orders: C.map((e) => {
103
+ let t = y.get(e.key);
104
104
  return {
105
105
  partyA: t.vaAddress ?? t.partyA,
106
106
  market: { id: Number(t.symbolId) },
@@ -112,7 +112,8 @@ function y(y = {}) {
112
112
  };
113
113
  }),
114
114
  from: p,
115
- chainId: h
115
+ preflightDelegation: m,
116
+ chainId: _
116
117
  });
117
118
  } catch (e) {
118
119
  let t = n(e), r = T.current;
@@ -134,11 +135,11 @@ function y(y = {}) {
134
135
  } finally {
135
136
  E.current = !1;
136
137
  }
137
- let D = b.getChainConfigKey(h);
138
- S.invalidateQueries({ predicate: i(o, { configKey: D }) });
139
- let j = T.current;
140
- return j.status === "closing" && j.steps.every((e) => e.status === "closed") && A({
141
- ...j,
138
+ let j = b.getChainConfigKey(_);
139
+ S.invalidateQueries({ predicate: i(o, { configKey: j }) });
140
+ let M = T.current;
141
+ return M.status === "closing" && M.steps.every((e) => e.status === "closed") && A({
142
+ ...M,
142
143
  status: "success"
143
144
  }), {
144
145
  ok: !0,
@@ -1 +1 @@
1
- {"version":3,"file":"use-close-quote-group.js","names":[],"sources":["../../src/quotes/use-close-quote-group.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantClosesQueryKey,\n instantCloseBulkAutoMutationOptions,\n NotificationType,\n planGroupClose,\n toGroupCloseCandidates,\n type ConfigParameter,\n type Notification,\n type PlanGroupCloseFailure,\n type QuoteGroup,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { Address } from \"viem\";\nimport { formatUnits } from \"viem\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { predicateMatch } from \"../utils\";\nimport { useNotifications } from \"../websocket/use-notifications\";\n\n/** Decimal places of an 18-decimal-wei fixed-point value. */\nconst WEI_DECIMALS = 18;\n\n/**\n * Solver `lastSeenAction` values that report a close **fill** — the moment a\n * close is actually done (mirrors the core notification classifier's fill set;\n * the request-stage actions are deliberately not here).\n */\nconst CLOSE_FILL_ACTIONS = new Set([\"FillMarketOrderInstantClose\", \"FillLimitOrderClose\"]);\n\n/**\n * Lifecycle of one child close inside a group close:\n * `queued` → `closing` (submitted in the bulk request, awaiting its close-fill\n * notification) → `closed` (fill notification received), or `failed` (the bulk\n * submit or the close itself errored).\n */\nexport type CloseQuoteGroupStepStatus = \"queued\" | \"closing\" | \"closed\" | \"failed\";\n\n/** Live state of one child close inside a group close run. */\nexport interface CloseQuoteGroupStep {\n /** Child identity (`UnifiedQuote.key`). */\n key: string;\n /** On-chain quote id of the child. */\n quoteId: bigint;\n /** Planned close amount, wei. */\n closeQuantity: bigint;\n /** `full` when the child closes entirely, `partial` otherwise. */\n kind: \"full\" | \"partial\";\n /** Current lifecycle stage of this child close. */\n status: CloseQuoteGroupStepStatus;\n /** Normalized error, when `status` is `failed`. */\n error?: SymmioRequestError;\n}\n\n/** Overall lifecycle of a group close run. */\nexport type CloseQuoteGroupStatus = \"idle\" | \"closing\" | \"success\" | \"failed\";\n\n/** Inputs for one {@link UseCloseQuoteGroupReturnType.close} run. */\nexport interface CloseQuoteGroupParameters {\n /** The group whose children are being closed. */\n group: QuoteGroup;\n /** Exact total quantity to close across the group, wei. */\n targetQuantity: bigint;\n /**\n * The symbol's `minAcceptableQuoteValue` (wei) — the dust floor a partially\n * closed child must keep. Read it from the market info of the group's symbol.\n */\n minAcceptableQuoteValue: bigint;\n /** Slippage tolerance percent forwarded to every child close (e.g. `5`). */\n slippage: number;\n /** Pre-fetched mark price (decimal string) forwarded to every child close. */\n markPrice?: string;\n /** Delegated session key to submit the closes from, when delegation is active. */\n from?: Address;\n /**\n * Account whose live notification stream reports the close fills — pass the\n * **sub-account** when closing Virtual Account quotes (the VA frames arrive\n * on its owning sub-account's stream). Defaults to the first child's\n * `vaAddress ?? partyA`.\n */\n notificationsAccount?: Address;\n /** Chain override; defaults to the connected chain. */\n chainId?: number;\n}\n\n/**\n * Submission outcome of one {@link UseCloseQuoteGroupReturnType.close} run.\n * Resolves when the bulk request carrying every child close has been\n * **submitted** — settlement is confirmed asynchronously per child (its\n * close-fill notification), tracked via `status` / `steps` /\n * `progressPercent` on the hook.\n */\nexport interface CloseQuoteGroupSummary {\n /** `true` when every planned child close was submitted successfully. */\n ok: boolean;\n /** Σ quantity already confirmed closed at resolve time, wei. */\n closedQuantity: bigint;\n /** Per-child final states. Empty when planning already failed. */\n steps: CloseQuoteGroupStep[];\n /** Present when the plan itself was infeasible — nothing was closed. */\n planFailure?: PlanGroupCloseFailure;\n /** The error that stopped the run, when `ok` is `false` and a close failed. */\n error?: SymmioRequestError;\n}\n\n/** Return type of {@link useCloseQuoteGroup}. */\nexport interface UseCloseQuoteGroupReturnType {\n /** Plan and execute a group close. Resolves with the run's summary (never rejects). */\n close: (parameters: CloseQuoteGroupParameters) => Promise<CloseQuoteGroupSummary>;\n /** Clear the run state back to `idle`. No-op while a run is in flight. */\n reset: () => void;\n /** Overall run lifecycle. */\n status: CloseQuoteGroupStatus;\n /** `true` while a run is in flight. */\n isClosing: boolean;\n /** Quantity-weighted completion, `0`–`100` (2-decimal resolution). */\n progressPercent: number;\n /** Σ quantity closed so far in the current/last run, wei. */\n closedQuantity: bigint;\n /** The run's target, wei (`0` while idle). */\n targetQuantity: bigint;\n /** Per-child close states of the current/last run, in execution order. */\n steps: CloseQuoteGroupStep[];\n /** Planning failure of the last run, when the plan was infeasible. */\n planFailure?: PlanGroupCloseFailure;\n /** The error that stopped the last run, when a child close failed. */\n error?: SymmioRequestError;\n}\n\n/** Parameters for {@link useCloseQuoteGroup}. */\nexport type UseCloseQuoteGroupParameters = ConfigParameter;\n\ninterface RunState {\n status: CloseQuoteGroupStatus;\n steps: CloseQuoteGroupStep[];\n closedQuantity: bigint;\n targetQuantity: bigint;\n planFailure?: PlanGroupCloseFailure;\n error?: SymmioRequestError;\n}\n\nconst IDLE: RunState = { status: \"idle\", steps: [], closedQuantity: 0n, targetQuantity: 0n };\n\n/**\n * Close an exact quantity across a grouped position, child by child.\n *\n * The run first plans the allocation with `planGroupClose` (largest child\n * first; every partially closed child keeps at least the symbol's\n * `minAcceptableQuoteValue`; the plan sums to the target exactly or fails\n * without closing anything). It then submits **every allocation in one bulk\n * request** (`instantCloseBulkAuto` — n operations, one endpoint call). A\n * submitted child stays `closing` until its close settles: the hook watches\n * the account's live notifications and flips the child to `closed` — advancing\n * `closedQuantity` / `progressPercent` — when its **close fill** frame arrives\n * (`lastSeenAction: FillMarketOrderInstantClose` / `FillLimitOrderClose` with\n * `success`); `status` becomes `success` once every child confirms, and a\n * `failed` frame fails that step and the run. A rejected bulk submit fails the\n * whole run at once.\n *\n * @example\n * ```tsx\n * const { close, status, progressPercent, steps } = useCloseQuoteGroup();\n * const summary = await close({\n * group, targetQuantity: parseUnits(\"2.8\", 18),\n * minAcceptableQuoteValue: market.minAcceptableQuoteValue, slippage: 5,\n * });\n * if (!summary.ok) showError(summary.planFailure ?? summary.error);\n * ```\n */\nexport function useCloseQuoteGroup(parameters: UseCloseQuoteGroupParameters = {}): UseCloseQuoteGroupReturnType {\n const config = useSymmioConfig(parameters);\n const connectedChainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const [state, setState] = useState<RunState>(IDLE);\n /** Mirror of `state` for the notification callback and the submit loop (single source). */\n const runRef = useRef<RunState>(IDLE);\n const inFlight = useRef(false);\n /** Account whose notification stream confirms the run's closes. */\n const [watchAccount, setWatchAccount] = useState<Address>();\n const watchChainIdRef = useRef<number | undefined>(undefined);\n\n const commit = useCallback((next: RunState) => {\n runRef.current = next;\n setState(next);\n }, []);\n\n /**\n * Settlement tracking: a submitted child is finished when its close **fill**\n * notification arrives — `lastSeenAction` of `FillMarketOrderInstantClose`\n * (or `FillLimitOrderClose`) with a `success` status. That flips the step to\n * `closed` and advances progress; the run finishes (`success`) once every\n * step is closed. A `failed` frame for the quote marks the step (and run)\n * failed instead. Request-stage frames (`InstantRequestToClosePosition`, …)\n * are ignored.\n */\n const onNotification = useCallback(\n (notification: Notification) => {\n const run = runRef.current;\n const index = run.steps.findIndex(\n (step) => step.status === \"closing\" && String(step.quoteId) === notification.quoteId,\n );\n if (index < 0) return;\n\n const isCloseFill =\n notification.type === NotificationType.SUCCESS &&\n notification.lastSeenAction !== null &&\n CLOSE_FILL_ACTIONS.has(notification.lastSeenAction);\n const isFailure = notification.type === NotificationType.FAILED;\n if (!isCloseFill && !isFailure) return;\n\n const steps = [...run.steps];\n let closedQuantity = run.closedQuantity;\n if (isCloseFill) {\n const step = { ...steps[index]!, status: \"closed\" as const };\n closedQuantity += step.closeQuantity;\n steps[index] = step;\n const allClosed = steps.every((entry) => entry.status === \"closed\");\n const status = run.status === \"closing\" && allClosed ? \"success\" : run.status;\n commit({ ...run, steps, closedQuantity, status });\n return;\n }\n const error = normalizeSymmError(new Error(notification.failureMessage ?? \"Close failed on the solver.\"));\n steps[index] = { ...steps[index]!, status: \"failed\", error };\n commit({ ...run, steps, status: \"failed\", error });\n },\n [commit],\n );\n\n useNotifications({\n account: watchAccount,\n chainId: watchChainIdRef.current,\n config: parameters.config,\n // Listen while any submitted child still awaits its settle notifications —\n // even after a later submit failed, the earlier closes keep confirming.\n enabled: Boolean(watchAccount) && state.steps.some((step) => step.status === \"closing\"),\n onNotification,\n });\n\n const close = useCallback(\n async (runParameters: CloseQuoteGroupParameters): Promise<CloseQuoteGroupSummary> => {\n if (inFlight.current || runRef.current.steps.some((step) => step.status === \"closing\")) {\n return {\n ok: false,\n closedQuantity: 0n,\n steps: [],\n error: normalizeSymmError(new Error(\"A group close is already in flight.\")),\n };\n }\n\n const { group, targetQuantity, minAcceptableQuoteValue, slippage, markPrice, from, notificationsAccount } =\n runParameters;\n const chainId = runParameters.chainId ?? connectedChainId;\n\n const candidates = toGroupCloseCandidates(group.quotes, minAcceptableQuoteValue);\n const plan = planGroupClose(candidates, targetQuantity);\n if (!plan.feasible) {\n commit({ status: \"failed\", steps: [], closedQuantity: 0n, targetQuantity, planFailure: plan });\n return { ok: false, closedQuantity: 0n, steps: [], planFailure: plan };\n }\n\n const childByKey = new Map<string, UnifiedQuote>(group.quotes.map((quote) => [quote.key, quote]));\n const steps: CloseQuoteGroupStep[] = plan.allocations.map((allocation) => ({\n key: allocation.key,\n // The planner only emits candidates built from anchored children, so the id is present.\n quoteId: childByKey.get(allocation.key)!.quoteId!,\n closeQuantity: allocation.closeQuantity,\n kind: allocation.kind,\n status: \"queued\",\n }));\n\n inFlight.current = true;\n const firstChild = childByKey.get(steps[0]!.key)!;\n watchChainIdRef.current = chainId;\n setWatchAccount(notificationsAccount ?? firstChild.vaAddress ?? firstChild.partyA);\n\n // Every allocation submits in ONE bulk round-trip, so all steps go `closing` together.\n commit({\n status: \"closing\",\n steps: steps.map((step) => ({ ...step, status: \"closing\" as const })),\n closedQuantity: 0n,\n targetQuantity,\n });\n\n const base = instantCloseBulkAutoMutationOptions(config);\n try {\n await base.mutationFn({\n orders: steps.map((step) => {\n const child = childByKey.get(step.key)!;\n return {\n partyA: child.vaAddress ?? child.partyA,\n market: { id: Number(child.symbolId) },\n positionType: child.positionType,\n quoteId: step.quoteId,\n quantityToClose: formatUnits(step.closeQuantity, WEI_DECIMALS),\n slippage,\n markPrice,\n };\n }),\n from,\n chainId,\n });\n } catch (err) {\n const error = normalizeSymmError(err);\n const run = runRef.current;\n commit({\n ...run,\n status: \"failed\",\n steps: run.steps.map((step) =>\n step.status === \"closing\" ? { ...step, status: \"failed\" as const, error } : step,\n ),\n error,\n });\n return { ok: false, closedQuantity: runRef.current.closedQuantity, steps: [...runRef.current.steps], error };\n } finally {\n inFlight.current = false;\n }\n\n // Surface the fresh closing rows immediately, exactly like the single-close hook.\n const configKey = config.getChainConfigKey(chainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantClosesQueryKey, { configKey }) });\n\n // Submitted. Completion is notification-driven; fast fills may already have\n // finished the run while the request was in flight.\n const run = runRef.current;\n if (run.status === \"closing\" && run.steps.every((step) => step.status === \"closed\")) {\n commit({ ...run, status: \"success\" });\n }\n return { ok: true, closedQuantity: runRef.current.closedQuantity, steps: [...runRef.current.steps] };\n },\n [commit, config, connectedChainId, queryClient],\n );\n\n const reset = useCallback(() => {\n if (inFlight.current) return;\n watchChainIdRef.current = undefined;\n setWatchAccount(undefined);\n commit(IDLE);\n }, [commit]);\n\n const progressPercent = useMemo(() => {\n if (state.targetQuantity <= 0n) return 0;\n return Number((state.closedQuantity * 10_000n) / state.targetQuantity) / 100;\n }, [state.closedQuantity, state.targetQuantity]);\n\n return {\n close,\n reset,\n status: state.status,\n isClosing: state.status === \"closing\",\n progressPercent,\n closedQuantity: state.closedQuantity,\n targetQuantity: state.targetQuantity,\n steps: state.steps,\n planFailure: state.planFailure,\n error: state.error,\n };\n}\n"],"mappings":";;;;;;;;;;;AA0BA,IAAM,IAAe,IAOf,IAAqB,IAAI,IAAI,CAAC,+BAA+B,qBAAqB,CAAC,GAiHnF,IAAiB;CAAE,QAAQ;CAAQ,OAAO,CAAC;CAAG,gBAAgB;CAAI,gBAAgB;AAAG;AA4B3F,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAmB,EAAiB,GACpC,IAAc,EAAe,GAC7B,CAAC,GAAO,KAAY,EAAmB,CA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AAgB,EAAM,cAAc,CAAC;CAE/C,OAAO;EACL;EACA;EACA,QAAQ,EAAM;EACd,WAAW,EAAM,WAAW;EAC5B;EACA,gBAAgB,EAAM;EACtB,gBAAgB,EAAM;EACtB,OAAO,EAAM;EACb,aAAa,EAAM;EACnB,OAAO,EAAM;CACf;AACF"}
1
+ {"version":3,"file":"use-close-quote-group.js","names":[],"sources":["../../src/quotes/use-close-quote-group.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantClosesQueryKey,\n instantCloseBulkAutoMutationOptions,\n NotificationType,\n planGroupClose,\n toGroupCloseCandidates,\n type ConfigParameter,\n type Notification,\n type PlanGroupCloseFailure,\n type QuoteGroup,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { Address } from \"viem\";\nimport { formatUnits } from \"viem\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { predicateMatch } from \"../utils\";\nimport { useNotifications } from \"../websocket/use-notifications\";\n\n/** Decimal places of an 18-decimal-wei fixed-point value. */\nconst WEI_DECIMALS = 18;\n\n/**\n * Solver `lastSeenAction` values that report a close **fill** — the moment a\n * close is actually done (mirrors the core notification classifier's fill set;\n * the request-stage actions are deliberately not here).\n */\nconst CLOSE_FILL_ACTIONS = new Set([\"FillMarketOrderInstantClose\", \"FillLimitOrderClose\"]);\n\n/**\n * Lifecycle of one child close inside a group close:\n * `queued` → `closing` (submitted in the bulk request, awaiting its close-fill\n * notification) → `closed` (fill notification received), or `failed` (the bulk\n * submit or the close itself errored).\n */\nexport type CloseQuoteGroupStepStatus = \"queued\" | \"closing\" | \"closed\" | \"failed\";\n\n/** Live state of one child close inside a group close run. */\nexport interface CloseQuoteGroupStep {\n /** Child identity (`UnifiedQuote.key`). */\n key: string;\n /** On-chain quote id of the child. */\n quoteId: bigint;\n /** Planned close amount, wei. */\n closeQuantity: bigint;\n /** `full` when the child closes entirely, `partial` otherwise. */\n kind: \"full\" | \"partial\";\n /** Current lifecycle stage of this child close. */\n status: CloseQuoteGroupStepStatus;\n /** Normalized error, when `status` is `failed`. */\n error?: SymmioRequestError;\n}\n\n/** Overall lifecycle of a group close run. */\nexport type CloseQuoteGroupStatus = \"idle\" | \"closing\" | \"success\" | \"failed\";\n\n/** Inputs for one {@link UseCloseQuoteGroupReturnType.close} run. */\nexport interface CloseQuoteGroupParameters {\n /** The group whose children are being closed. */\n group: QuoteGroup;\n /** Exact total quantity to close across the group, wei. */\n targetQuantity: bigint;\n /**\n * The symbol's `minAcceptableQuoteValue` (wei) — the dust floor a partially\n * closed child must keep. Read it from the market info of the group's symbol.\n */\n minAcceptableQuoteValue: bigint;\n /** Slippage tolerance percent forwarded to every child close (e.g. `5`). */\n slippage: number;\n /** Pre-fetched mark price (decimal string) forwarded to every child close. */\n markPrice?: string;\n /** Delegated session key to submit the closes from, when delegation is active. */\n from?: Address;\n /**\n * Check that the signer holds the `requestToClosePosition` delegation before\n * any close is signed. Defaults to `true`; a run that fails it reports\n * `INSTANT_SIGNER_NOT_DELEGATED` in its summary's `error`. Pass `false` when\n * your UI already gates the close on delegation.\n */\n preflightDelegation?: boolean;\n /**\n * Account whose live notification stream reports the close fills — pass the\n * **sub-account** when closing Virtual Account quotes (the VA frames arrive\n * on its owning sub-account's stream). Defaults to the first child's\n * `vaAddress ?? partyA`.\n */\n notificationsAccount?: Address;\n /** Chain override; defaults to the connected chain. */\n chainId?: number;\n}\n\n/**\n * Submission outcome of one {@link UseCloseQuoteGroupReturnType.close} run.\n * Resolves when the bulk request carrying every child close has been\n * **submitted** — settlement is confirmed asynchronously per child (its\n * close-fill notification), tracked via `status` / `steps` /\n * `progressPercent` on the hook.\n */\nexport interface CloseQuoteGroupSummary {\n /** `true` when every planned child close was submitted successfully. */\n ok: boolean;\n /** Σ quantity already confirmed closed at resolve time, wei. */\n closedQuantity: bigint;\n /** Per-child final states. Empty when planning already failed. */\n steps: CloseQuoteGroupStep[];\n /** Present when the plan itself was infeasible — nothing was closed. */\n planFailure?: PlanGroupCloseFailure;\n /** The error that stopped the run, when `ok` is `false` and a close failed. */\n error?: SymmioRequestError;\n}\n\n/** Return type of {@link useCloseQuoteGroup}. */\nexport interface UseCloseQuoteGroupReturnType {\n /** Plan and execute a group close. Resolves with the run's summary (never rejects). */\n close: (parameters: CloseQuoteGroupParameters) => Promise<CloseQuoteGroupSummary>;\n /** Clear the run state back to `idle`. No-op while a run is in flight. */\n reset: () => void;\n /** Overall run lifecycle. */\n status: CloseQuoteGroupStatus;\n /** `true` while a run is in flight. */\n isClosing: boolean;\n /** Quantity-weighted completion, `0`–`100` (2-decimal resolution). */\n progressPercent: number;\n /** Σ quantity closed so far in the current/last run, wei. */\n closedQuantity: bigint;\n /** The run's target, wei (`0` while idle). */\n targetQuantity: bigint;\n /** Per-child close states of the current/last run, in execution order. */\n steps: CloseQuoteGroupStep[];\n /** Planning failure of the last run, when the plan was infeasible. */\n planFailure?: PlanGroupCloseFailure;\n /** The error that stopped the last run, when a child close failed. */\n error?: SymmioRequestError;\n}\n\n/** Parameters for {@link useCloseQuoteGroup}. */\nexport type UseCloseQuoteGroupParameters = ConfigParameter;\n\ninterface RunState {\n status: CloseQuoteGroupStatus;\n steps: CloseQuoteGroupStep[];\n closedQuantity: bigint;\n targetQuantity: bigint;\n planFailure?: PlanGroupCloseFailure;\n error?: SymmioRequestError;\n}\n\nconst IDLE: RunState = { status: \"idle\", steps: [], closedQuantity: 0n, targetQuantity: 0n };\n\n/**\n * Close an exact quantity across a grouped position, child by child.\n *\n * The run first plans the allocation with `planGroupClose` (largest child\n * first; every partially closed child keeps at least the symbol's\n * `minAcceptableQuoteValue`; the plan sums to the target exactly or fails\n * without closing anything). It then submits **every allocation in one bulk\n * request** (`instantCloseBulkAuto` — n operations, one endpoint call). A\n * submitted child stays `closing` until its close settles: the hook watches\n * the account's live notifications and flips the child to `closed` — advancing\n * `closedQuantity` / `progressPercent` — when its **close fill** frame arrives\n * (`lastSeenAction: FillMarketOrderInstantClose` / `FillLimitOrderClose` with\n * `success`); `status` becomes `success` once every child confirms, and a\n * `failed` frame fails that step and the run. A rejected bulk submit fails the\n * whole run at once.\n *\n * @example\n * ```tsx\n * const { close, status, progressPercent, steps } = useCloseQuoteGroup();\n * const summary = await close({\n * group, targetQuantity: parseUnits(\"2.8\", 18),\n * minAcceptableQuoteValue: market.minAcceptableQuoteValue, slippage: 5,\n * });\n * if (!summary.ok) showError(summary.planFailure ?? summary.error);\n * ```\n */\nexport function useCloseQuoteGroup(parameters: UseCloseQuoteGroupParameters = {}): UseCloseQuoteGroupReturnType {\n const config = useSymmioConfig(parameters);\n const connectedChainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const [state, setState] = useState<RunState>(IDLE);\n /** Mirror of `state` for the notification callback and the submit loop (single source). */\n const runRef = useRef<RunState>(IDLE);\n const inFlight = useRef(false);\n /** Account whose notification stream confirms the run's closes. */\n const [watchAccount, setWatchAccount] = useState<Address>();\n const watchChainIdRef = useRef<number | undefined>(undefined);\n\n const commit = useCallback((next: RunState) => {\n runRef.current = next;\n setState(next);\n }, []);\n\n /**\n * Settlement tracking: a submitted child is finished when its close **fill**\n * notification arrives — `lastSeenAction` of `FillMarketOrderInstantClose`\n * (or `FillLimitOrderClose`) with a `success` status. That flips the step to\n * `closed` and advances progress; the run finishes (`success`) once every\n * step is closed. A `failed` frame for the quote marks the step (and run)\n * failed instead. Request-stage frames (`InstantRequestToClosePosition`, …)\n * are ignored.\n */\n const onNotification = useCallback(\n (notification: Notification) => {\n const run = runRef.current;\n const index = run.steps.findIndex(\n (step) => step.status === \"closing\" && String(step.quoteId) === notification.quoteId,\n );\n if (index < 0) return;\n\n const isCloseFill =\n notification.type === NotificationType.SUCCESS &&\n notification.lastSeenAction !== null &&\n CLOSE_FILL_ACTIONS.has(notification.lastSeenAction);\n const isFailure = notification.type === NotificationType.FAILED;\n if (!isCloseFill && !isFailure) return;\n\n const steps = [...run.steps];\n let closedQuantity = run.closedQuantity;\n if (isCloseFill) {\n const step = { ...steps[index]!, status: \"closed\" as const };\n closedQuantity += step.closeQuantity;\n steps[index] = step;\n const allClosed = steps.every((entry) => entry.status === \"closed\");\n const status = run.status === \"closing\" && allClosed ? \"success\" : run.status;\n commit({ ...run, steps, closedQuantity, status });\n return;\n }\n const error = normalizeSymmError(new Error(notification.failureMessage ?? \"Close failed on the solver.\"));\n steps[index] = { ...steps[index]!, status: \"failed\", error };\n commit({ ...run, steps, status: \"failed\", error });\n },\n [commit],\n );\n\n useNotifications({\n account: watchAccount,\n chainId: watchChainIdRef.current,\n config: parameters.config,\n // Listen while any submitted child still awaits its settle notifications —\n // even after a later submit failed, the earlier closes keep confirming.\n enabled: Boolean(watchAccount) && state.steps.some((step) => step.status === \"closing\"),\n onNotification,\n });\n\n const close = useCallback(\n async (runParameters: CloseQuoteGroupParameters): Promise<CloseQuoteGroupSummary> => {\n if (inFlight.current || runRef.current.steps.some((step) => step.status === \"closing\")) {\n return {\n ok: false,\n closedQuantity: 0n,\n steps: [],\n error: normalizeSymmError(new Error(\"A group close is already in flight.\")),\n };\n }\n\n const {\n group,\n targetQuantity,\n minAcceptableQuoteValue,\n slippage,\n markPrice,\n from,\n preflightDelegation,\n notificationsAccount,\n } = runParameters;\n const chainId = runParameters.chainId ?? connectedChainId;\n\n const candidates = toGroupCloseCandidates(group.quotes, minAcceptableQuoteValue);\n const plan = planGroupClose(candidates, targetQuantity);\n if (!plan.feasible) {\n commit({ status: \"failed\", steps: [], closedQuantity: 0n, targetQuantity, planFailure: plan });\n return { ok: false, closedQuantity: 0n, steps: [], planFailure: plan };\n }\n\n const childByKey = new Map<string, UnifiedQuote>(group.quotes.map((quote) => [quote.key, quote]));\n const steps: CloseQuoteGroupStep[] = plan.allocations.map((allocation) => ({\n key: allocation.key,\n // The planner only emits candidates built from anchored children, so the id is present.\n quoteId: childByKey.get(allocation.key)!.quoteId!,\n closeQuantity: allocation.closeQuantity,\n kind: allocation.kind,\n status: \"queued\",\n }));\n\n inFlight.current = true;\n const firstChild = childByKey.get(steps[0]!.key)!;\n watchChainIdRef.current = chainId;\n setWatchAccount(notificationsAccount ?? firstChild.vaAddress ?? firstChild.partyA);\n\n // Every allocation submits in ONE bulk round-trip, so all steps go `closing` together.\n commit({\n status: \"closing\",\n steps: steps.map((step) => ({ ...step, status: \"closing\" as const })),\n closedQuantity: 0n,\n targetQuantity,\n });\n\n const base = instantCloseBulkAutoMutationOptions(config);\n try {\n await base.mutationFn({\n orders: steps.map((step) => {\n const child = childByKey.get(step.key)!;\n return {\n partyA: child.vaAddress ?? child.partyA,\n market: { id: Number(child.symbolId) },\n positionType: child.positionType,\n quoteId: step.quoteId,\n quantityToClose: formatUnits(step.closeQuantity, WEI_DECIMALS),\n slippage,\n markPrice,\n };\n }),\n from,\n preflightDelegation,\n chainId,\n });\n } catch (err) {\n const error = normalizeSymmError(err);\n const run = runRef.current;\n commit({\n ...run,\n status: \"failed\",\n steps: run.steps.map((step) =>\n step.status === \"closing\" ? { ...step, status: \"failed\" as const, error } : step,\n ),\n error,\n });\n return { ok: false, closedQuantity: runRef.current.closedQuantity, steps: [...runRef.current.steps], error };\n } finally {\n inFlight.current = false;\n }\n\n // Surface the fresh closing rows immediately, exactly like the single-close hook.\n const configKey = config.getChainConfigKey(chainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantClosesQueryKey, { configKey }) });\n\n // Submitted. Completion is notification-driven; fast fills may already have\n // finished the run while the request was in flight.\n const run = runRef.current;\n if (run.status === \"closing\" && run.steps.every((step) => step.status === \"closed\")) {\n commit({ ...run, status: \"success\" });\n }\n return { ok: true, closedQuantity: runRef.current.closedQuantity, steps: [...runRef.current.steps] };\n },\n [commit, config, connectedChainId, queryClient],\n );\n\n const reset = useCallback(() => {\n if (inFlight.current) return;\n watchChainIdRef.current = undefined;\n setWatchAccount(undefined);\n commit(IDLE);\n }, [commit]);\n\n const progressPercent = useMemo(() => {\n if (state.targetQuantity <= 0n) return 0;\n return Number((state.closedQuantity * 10_000n) / state.targetQuantity) / 100;\n }, [state.closedQuantity, state.targetQuantity]);\n\n return {\n close,\n reset,\n status: state.status,\n isClosing: state.status === \"closing\",\n progressPercent,\n closedQuantity: state.closedQuantity,\n targetQuantity: state.targetQuantity,\n steps: state.steps,\n planFailure: state.planFailure,\n error: state.error,\n };\n}\n"],"mappings":";;;;;;;;;;;AA0BA,IAAM,IAAe,IAOf,IAAqB,IAAI,IAAI,CAAC,+BAA+B,qBAAqB,CAAC,GAwHnF,IAAiB;CAAE,QAAQ;CAAQ,OAAO,CAAC;CAAG,gBAAgB;CAAI,gBAAgB;AAAG;AA4B3F,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAmB,EAAiB,GACpC,IAAc,EAAe,GAC7B,CAAC,GAAO,KAAY,EAAmB,CAAI,GAE3C,IAAS,EAAiB,CAAI,GAC9B,IAAW,EAAO,EAAK,GAEvB,CAAC,GAAc,KAAmB,EAAkB,GACpD,IAAkB,EAA2B,KAAA,CAAS,GAEtD,IAAS,GAAa,MAAmB;EAE7C,AADA,EAAO,UAAU,GACjB,EAAS,CAAI;CACf,GAAG,CAAC,CAAC,GAWC,IAAiB,GACpB,MAA+B;EAC9B,IAAM,IAAM,EAAO,SACb,IAAQ,EAAI,MAAM,WACrB,MAAS,EAAK,WAAW,aAAa,OAAO,EAAK,OAAO,MAAM,EAAa,OAC/E;EACA,IAAI,IAAQ,GAAG;EAEf,IAAM,IACJ,EAAa,SAAS,EAAiB,WACvC,EAAa,mBAAmB,QAChC,EAAmB,IAAI,EAAa,cAAc,GAC9C,IAAY,EAAa,SAAS,EAAiB;EACzD,IAAI,CAAC,KAAe,CAAC,GAAW;EAEhC,IAAM,IAAQ,CAAC,GAAG,EA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ACrB;EAGA,IAAM,IAAY,EAAO,kBAAkB,CAAO;EAClD,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA0B,EAAE,aAAU,CAAC,EAAE,CAAC;EAIzG,IAAM,IAAM,EAAO;EAInB,OAHI,EAAI,WAAW,aAAa,EAAI,MAAM,OAAO,MAAS,EAAK,WAAW,QAAQ,KAChF,EAAO;GAAE,GAAG;GAAK,QAAQ;EAAU,CAAC,GAE/B;GAAE,IAAI;GAAM,gBAAgB,EAAO,QAAQ;GAAgB,OAAO,CAAC,GAAG,EAAO,QAAQ,KAAK;EAAE;CACrG,GACA;EAAC;EAAQ;EAAQ;EAAkB;CAAW,CAChD,GAEM,IAAQ,QAAkB;EAC1B,EAAS,YACb,EAAgB,UAAU,KAAA,GAC1B,EAAgB,KAAA,CAAS,GACzB,EAAO,CAAI;CACb,GAAG,CAAC,CAAM,CAAC,GAEL,IAAkB,QAClB,EAAM,kBAAkB,KAAW,IAChC,OAAQ,EAAM,iBAAiB,SAAW,EAAM,cAAc,IAAI,KACxE,CAAC,EAAM,gBAAgB,EAAM,cAAc,CAAC;CAE/C,OAAO;EACL;EACA;EACA,QAAQ,EAAM;EACd,WAAW,EAAM,WAAW;EAC5B;EACA,gBAAgB,EAAM;EACtB,gBAAgB,EAAM;EACtB,OAAO,EAAM;EACb,aAAa,EAAM;EACnB,OAAO,EAAM;CACf;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symmio/trading-react",
3
- "version": "3.3.0",
3
+ "version": "4.0.0",
4
4
  "description": "React adapter for the SYMMIO SDK. Hooks, providers, and React-bound ergonomics on top of @symmio/trading-core.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/SYMM-IO/Trading-SDK/tree/main/packages/trading-react#readme",
@@ -91,7 +91,7 @@
91
91
  "@tanstack/react-query": "^5.100.0",
92
92
  "decimal.js": "^10.4.3",
93
93
  "zustand": "^5.0.0",
94
- "@symmio/trading-core": "^3.4.0"
94
+ "@symmio/trading-core": "^4.0.0"
95
95
  },
96
96
  "peerDependencies": {
97
97
  "react": "^19.0.0",
@@ -117,8 +117,8 @@
117
117
  "vite-plugin-dts": "^5.0.0",
118
118
  "vitest": "^4.1.10",
119
119
  "wagmi": "^3.4.2",
120
- "@symmio/eslint-config": "^1.0.0",
121
- "@symmio/typescript-config": "^1.0.0"
120
+ "@symmio/typescript-config": "^1.0.0",
121
+ "@symmio/eslint-config": "^1.0.0"
122
122
  },
123
123
  "scripts": {
124
124
  "build": "vite build && node ../../scripts/fix-dts-extensions.mjs dist",