@symmio/trading-react 3.0.0 → 3.0.1-staging-20260926093035

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 (47) hide show
  1. package/dist/estimated-price/use-estimated-price.d.ts +6 -3
  2. package/dist/estimated-price/use-estimated-price.d.ts.map +1 -1
  3. package/dist/estimated-price/use-estimated-price.js +12 -9
  4. package/dist/estimated-price/use-estimated-price.js.map +1 -1
  5. package/dist/index.d.ts +7 -7
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +169 -166
  8. package/dist/instant-layer/get-instant-open-funding-error.d.ts +5 -0
  9. package/dist/instant-layer/get-instant-open-funding-error.d.ts.map +1 -0
  10. package/dist/instant-layer/get-instant-open-funding-error.js +15 -0
  11. package/dist/instant-layer/get-instant-open-funding-error.js.map +1 -0
  12. package/dist/instant-layer/index.d.ts +2 -0
  13. package/dist/instant-layer/index.d.ts.map +1 -1
  14. package/dist/instant-layer/index.js +15 -13
  15. package/dist/instant-layer/use-instant-close-fees.d.ts +46 -0
  16. package/dist/instant-layer/use-instant-close-fees.d.ts.map +1 -0
  17. package/dist/instant-layer/use-instant-close-fees.js +83 -0
  18. package/dist/instant-layer/use-instant-close-fees.js.map +1 -0
  19. package/dist/instant-layer/use-instant-open-auto.d.ts +5 -0
  20. package/dist/instant-layer/use-instant-open-auto.d.ts.map +1 -1
  21. package/dist/instant-layer/use-instant-open-auto.js.map +1 -1
  22. package/dist/instant-layer/use-instant-open-fees.d.ts +33 -10
  23. package/dist/instant-layer/use-instant-open-fees.d.ts.map +1 -1
  24. package/dist/instant-layer/use-instant-open-fees.js +22 -98
  25. package/dist/instant-layer/use-instant-open-fees.js.map +1 -1
  26. package/dist/instant-layer/use-instant-open-inputs.d.ts +35 -0
  27. package/dist/instant-layer/use-instant-open-inputs.d.ts.map +1 -0
  28. package/dist/instant-layer/use-instant-open-inputs.js +134 -0
  29. package/dist/instant-layer/use-instant-open-inputs.js.map +1 -0
  30. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts +6 -0
  31. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -1
  32. package/dist/instant-layer/use-instant-open-with-tpsl.js.map +1 -1
  33. package/dist/instant-layer/use-prepare-instant-open-params.d.ts +69 -0
  34. package/dist/instant-layer/use-prepare-instant-open-params.d.ts.map +1 -0
  35. package/dist/instant-layer/use-prepare-instant-open-params.js +36 -0
  36. package/dist/instant-layer/use-prepare-instant-open-params.js.map +1 -0
  37. package/dist/margin/use-available-instant-open-margin.d.ts +3 -2
  38. package/dist/margin/use-available-instant-open-margin.d.ts.map +1 -1
  39. package/dist/margin/use-available-instant-open-margin.js +0 -1
  40. package/dist/margin/use-available-instant-open-margin.js.map +1 -1
  41. package/dist/solvers/index.d.ts +1 -0
  42. package/dist/solvers/index.d.ts.map +1 -1
  43. package/dist/solvers/use-solver-info.d.ts +14 -0
  44. package/dist/solvers/use-solver-info.d.ts.map +1 -0
  45. package/dist/solvers/use-solver-info.js +27 -0
  46. package/dist/solvers/use-solver-info.js.map +1 -0
  47. package/package.json +2 -2
@@ -0,0 +1,83 @@
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 { useFeeForUser as r } from "../fees/use-fee-for-user.js";
6
+ import { useMarkets as i } from "../markets/use-markets.js";
7
+ import { usePriceByName as a } from "../price-service/use-price-by-name.js";
8
+ import { useSolverInfo as o } from "../solvers/use-solver-info.js";
9
+ import { getInstantCloseFeesQueryOptions as s } from "@symmio/trading-core";
10
+ import { useQuery as c } from "@tanstack/react-query";
11
+ //#region src/instant-layer/use-instant-close-fees.ts
12
+ function l(l) {
13
+ let u = t(l), d = e(), f = l.chainId ?? d, { subAccountAddress: p, market: m, quantity: h, openedAt: g, now: _, solverId: v } = l, y = (l.query?.enabled ?? !0) && h.length > 0, b = u.getSolver({
14
+ chainId: f,
15
+ solverId: v
16
+ }).id === "enigma", x = i({
17
+ config: l.config,
18
+ chainId: f,
19
+ solverId: v,
20
+ query: {
21
+ enabled: y,
22
+ staleTime: 3e5
23
+ }
24
+ }).data?.find((e) => e.symbolId === m.id), S = m.name ?? x?.name, C = m.pricePrecision ?? x?.pricePrecision, w = m.quantityPrecision ?? x?.quantityPrecision, T = m.hedgerFeeOpen ?? x?.hedgerFeeOpen, E = m.hedgerFeeClose ?? x?.hedgerFeeClose, D = x?.kind === "enigma" ? x : void 0, O = m.hedgerFeeCloseEarlyRate ?? D?.hedgerFeeCloseEarlyRate ?? E, k = m.hedgerFeeCloseEarlyThreshold ?? D?.hedgerFeeCloseEarlyThreshold ?? 0, A = m.hedgerFeeCloseStandardThreshold ?? D?.hedgerFeeCloseStandardThreshold ?? 0, j = r({
25
+ config: l.config,
26
+ chainId: f,
27
+ user: p,
28
+ symbolId: BigInt(m.id),
29
+ query: {
30
+ enabled: y && l.feeRates === void 0,
31
+ staleTime: 3e5
32
+ }
33
+ }), M = l.feeRates ?? j.data, N = o({
34
+ config: l.config,
35
+ chainId: f,
36
+ solverId: v,
37
+ query: { enabled: y && b && l.solverInfo === void 0 }
38
+ }), P = b ? l.solverInfo ?? N.data ?? (N.isError ? {} : void 0) : void 0, F = !b || P !== void 0, I = a({
39
+ name: S,
40
+ solverId: v,
41
+ enabled: y && l.markPrice === void 0
42
+ }), L = l.markPrice ?? I.markPrice ?? void 0, R = y && S !== void 0 && C !== void 0 && w !== void 0 && M !== void 0 && L !== void 0 && (!b || T !== void 0 && E !== void 0) && F, z = s(u, {
43
+ subAccountAddress: p,
44
+ solverId: v,
45
+ chainId: f,
46
+ market: {
47
+ id: m.id,
48
+ name: S,
49
+ pricePrecision: C,
50
+ quantityPrecision: w,
51
+ hedgerFeeOpen: T,
52
+ hedgerFeeClose: E,
53
+ hedgerFeeCloseEarlyRate: O,
54
+ hedgerFeeCloseEarlyThreshold: k,
55
+ hedgerFeeCloseStandardThreshold: A
56
+ },
57
+ quantity: h,
58
+ openedAt: g,
59
+ now: _,
60
+ markPrice: L,
61
+ feeRates: M,
62
+ solverInfo: P,
63
+ query: {
64
+ ...l.query,
65
+ enabled: R,
66
+ placeholderData: (e) => e
67
+ }
68
+ });
69
+ return c({
70
+ ...z,
71
+ queryFn: async () => {
72
+ try {
73
+ return await z.queryFn();
74
+ } catch (e) {
75
+ throw n(e);
76
+ }
77
+ }
78
+ });
79
+ }
80
+ //#endregion
81
+ export { l as useInstantCloseFees };
82
+
83
+ //# sourceMappingURL=use-instant-close-fees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-instant-close-fees.js","names":[],"sources":["../../src/instant-layer/use-instant-close-fees.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantCloseFeesQueryOptions,\n type ConfigParameter,\n type GetInstantCloseFeesOptions,\n type GetInstantCloseFeesReturnType,\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 { useFeeForUser } from \"../fees/use-fee-for-user\";\nimport { useMarkets } from \"../markets/use-markets\";\nimport { usePriceByName } from \"../price-service/use-price-by-name\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useSolverInfo } from \"../solvers/use-solver-info\";\n\n/**\n * Parameters for {@link useInstantCloseFees}: the close intent\n * (`subAccountAddress`, `market`, `quantity`, `openedAt`, optional pre-fetched\n * data, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseInstantCloseFeesParameters = GetInstantCloseFeesOptions & ConfigParameter;\n\n/** Return type of {@link useInstantCloseFees}. */\nexport type UseInstantCloseFeesReturnType = UseQueryResult<GetInstantCloseFeesReturnType, SymmioRequestError>;\n\n/**\n * Preview every fee closing a position pays **right now** — the platform close\n * fee plus, on lowcap (Enigma), the holding-time solver close fee and the flat\n * static close leg. Read-only; nothing is signed. This is the close-flow\n * counterpart of `useInstantOpenFees`, which deliberately previews only the\n * open-side legs: the honest close cost exists only at close time, where the\n * notional and the decaying solver rate are real.\n *\n * Wraps `getInstantCloseFees`, but **pre-fetches every input through its own\n * cached queries and passes them in as prefills**, so the query function is\n * pure math with zero network hops: market metadata (`useMarkets`), on-chain\n * fee rates (`useFeeForUser`), and the solver's static fees (`useSolverInfo`)\n * are slow-moving and cached for minutes; the mark price rides the shared\n * price stream. Previous data is kept while inputs move, so a mark-price tick\n * updates the numbers in place.\n *\n * The holding time is stamped each time the query function runs, so a refetch\n * after the position ages re-prices the decaying solver close fee; pass `now`\n * for a deterministic preview. Narrow on `kind` to reach the lowcap-only legs\n * (`closeSolverFee`, `closeSolverFeeRate`, `holdingSeconds`,\n * `staticSolverFeeClose`).\n *\n * @example\n * ```tsx\n * const { data: fees } = useInstantCloseFees({\n * subAccountAddress: partyA,\n * market: { id: symbolId },\n * quantity: quantityToClose,\n * openedAt: position.createTimestamp,\n * });\n * // fees?.totalFee; fees?.kind === \"enigma\" && fees.closeSolverFee\n * ```\n */\nexport function useInstantCloseFees(parameters: UseInstantCloseFeesParameters): UseInstantCloseFeesReturnType {\n const config = useSymmioConfig(parameters);\n const contextChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? contextChainId;\n const { subAccountAddress, market, quantity, openedAt, now, solverId } = parameters;\n const enabled = (parameters.query?.enabled ?? true) && quantity.length > 0;\n\n /** The solver close-fee schedule and the static leg exist only on lowcap (Enigma) solvers. */\n const isLowcap = config.getSolver({ chainId, solverId }).id === \"enigma\";\n\n // Market metadata — slow-moving; dedupes with any other useMarkets on the page.\n const marketsQuery = useMarkets({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled, staleTime: 300_000 },\n });\n const resolvedMarket = marketsQuery.data?.find((entry) => entry.symbolId === market.id);\n const marketName = market.name ?? resolvedMarket?.name;\n const pricePrecision = market.pricePrecision ?? resolvedMarket?.pricePrecision;\n const quantityPrecision = market.quantityPrecision ?? resolvedMarket?.quantityPrecision;\n const hedgerFeeOpen = market.hedgerFeeOpen ?? resolvedMarket?.hedgerFeeOpen;\n const hedgerFeeClose = market.hedgerFeeClose ?? resolvedMarket?.hedgerFeeClose;\n\n // Time-decaying close-fee rates ride the same `useMarkets` read — they are\n // Enigma-only fields on `EnigmaMarket`, so narrow on `kind` before reading.\n const resolvedEnigmaMarket = resolvedMarket?.kind === \"enigma\" ? resolvedMarket : undefined;\n const hedgerFeeCloseEarlyRate =\n market.hedgerFeeCloseEarlyRate ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyRate ?? hedgerFeeClose;\n const hedgerFeeCloseEarlyThreshold =\n market.hedgerFeeCloseEarlyThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyThreshold ?? 0;\n const hedgerFeeCloseStandardThreshold =\n market.hedgerFeeCloseStandardThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseStandardThreshold ?? 0;\n\n // On-chain platform fee rates — contract state, changes rarely; cached hard.\n const feeQuery = useFeeForUser({\n config: parameters.config,\n chainId,\n user: subAccountAddress,\n symbolId: BigInt(market.id),\n query: { enabled: enabled && parameters.feeRates === undefined, staleTime: 300_000 },\n });\n const feeRates = parameters.feeRates ?? feeQuery.data;\n\n // Static close fee from the solver's `/info` config — lowcap only. Fail-soft:\n // an unreachable `/info` prices the static leg at \"0\" instead of blocking the\n // preview (mirrors the action's own resolver).\n const solverInfoQuery = useSolverInfo({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled: enabled && isLowcap && parameters.solverInfo === undefined },\n });\n const solverInfo = !isLowcap\n ? undefined\n : (parameters.solverInfo ?? solverInfoQuery.data ?? (solverInfoQuery.isError ? {} : undefined));\n const solverInfoSettled = !isLowcap || solverInfo !== undefined;\n\n // Mark price — caller's cache-hot value wins; otherwise the shared stream.\n const priceQuery = usePriceByName({\n name: marketName,\n solverId,\n enabled: enabled && parameters.markPrice === undefined,\n });\n const markPrice = parameters.markPrice ?? priceQuery.markPrice ?? undefined;\n\n // Every prefill present → the query function is pure math, zero fetches.\n const ready =\n enabled &&\n marketName !== undefined &&\n pricePrecision !== undefined &&\n quantityPrecision !== undefined &&\n feeRates !== undefined &&\n markPrice !== undefined &&\n (!isLowcap || (hedgerFeeOpen !== undefined && hedgerFeeClose !== undefined)) &&\n solverInfoSettled;\n\n const options = getInstantCloseFeesQueryOptions(config, {\n subAccountAddress,\n solverId,\n chainId,\n market: {\n id: market.id,\n name: marketName,\n pricePrecision,\n quantityPrecision,\n hedgerFeeOpen,\n hedgerFeeClose,\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold,\n hedgerFeeCloseStandardThreshold,\n },\n quantity,\n openedAt,\n now,\n markPrice,\n feeRates,\n solverInfo,\n query: {\n ...parameters.query,\n enabled: ready,\n // The mark price ticks often; keep showing the previous numbers while\n // the pure recompute runs instead of flashing a loader.\n placeholderData: (previous: GetInstantCloseFeesReturnType | undefined) => previous,\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 UseInstantCloseFeesReturnType;\n}\n"],"mappings":";;;;;;;;;;;AA6DA,SAAgB,EAAoB,GAA0E;CAC5G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAChC,EAAE,sBAAmB,WAAQ,aAAU,aAAU,QAAK,gBAAa,GACnE,KAAW,EAAW,OAAO,WAAW,OAAS,EAAS,SAAS,GAGnE,IAAW,EAAO,UAAU;EAAE;EAAS;CAAS,CAAC,EAAE,OAAO,UAS1D,IANe,EAAW;EAC9B,QAAQ,EAAW;EACnB;EACA;EACA,OAAO;GAAE;GAAS,WAAW;EAAQ;CACvC,CACuB,EAAa,MAAM,MAAM,MAAU,EAAM,aAAa,EAAO,EAAE,GAChF,IAAa,EAAO,QAAQ,GAAgB,M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AGT,kBAAkB,MAAwD;EAC5E;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"}
@@ -17,6 +17,11 @@ export type UseInstantOpenAutoReturnType = UseMutationResult<InstantOpenReturnTy
17
17
  * submit — use {@link useInstantOpen} after calling
18
18
  * `prepareInstantOpenParams(config, …)` directly.
19
19
  *
20
+ * Funding is a one-of on the variables: a typed `initialMargin`, or
21
+ * `fund: { mode: "full-balance", balance }` (lowcap only) to deploy the whole
22
+ * balance into the position's VA with the quantity sized down to fit it —
23
+ * see `FullBalanceFunding` in `@symmio/trading-core`.
24
+ *
20
25
  * @example
21
26
  * ```tsx
22
27
  * const { mutateAsync } = useInstantOpenAuto();
@@ -1 +1 @@
1
- {"version":3,"file":"use-instant-open-auto.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-auto.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAE3D,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,CAC1D,qBAAqB,EACrB,kBAAkB,EAClB,4BAA4B,CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CA2B9G"}
1
+ {"version":3,"file":"use-instant-open-auto.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-auto.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAE3D,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,iBAAiB,CAC1D,qBAAqB,EACrB,kBAAkB,EAClB,4BAA4B,CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,4BAAiC,GAAG,4BAA4B,CA2B9G"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-instant-open-auto.js","names":[],"sources":["../../src/instant-layer/use-instant-open-auto.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantOpensQueryKey,\n instantOpenAutoMutationOptions,\n type ConfigParameter,\n type InstantOpenReturnType,\n type PrepareInstantOpenParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } 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 { invalidateAccountBalances, predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useInstantOpenAuto}.\n */\nexport type UseInstantOpenAutoParameters = ConfigParameter;\n\n/** Return type of {@link useInstantOpenAuto}. */\nexport type UseInstantOpenAutoReturnType = UseMutationResult<\n InstantOpenReturnType,\n SymmioRequestError,\n PrepareInstantOpenParameters\n>;\n\n/**\n * Open a lowcap instant position via the wizard `instantOpenAuto` action.\n *\n * Friendly default: accepts the minimal trade intent and lets the SDK fetch\n * market metadata, mark price, locked params, and fee rates. Pre-fill any\n * optional field on the variables (e.g. cache-hot `markPrice`) to skip its\n * fetch. For full control — inspect / mutate resolved params between fetch and\n * submit — use {@link useInstantOpen} after calling\n * `prepareInstantOpenParams(config, …)` directly.\n *\n * @example\n * ```tsx\n * const { mutateAsync } = useInstantOpenAuto();\n * await mutateAsync({\n * walletAddress, sessionKeyAddress, signTypedData,\n * marketId: 1, positionType: \"LONG\",\n * userInput: \"100\", leverage: 5, slippage: 1,\n * });\n * ```\n */\nexport function useInstantOpenAuto(parameters: UseInstantOpenAutoParameters = {}): UseInstantOpenAutoReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const base = instantOpenAutoMutationOptions(config);\n\n return useMutation<InstantOpenReturnType, SymmioRequestError, PrepareInstantOpenParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({ ...variables, chainId: variables.chainId ?? chainId });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n /**\n * A freshly submitted instant-open exists on the hedger but not in any\n * cached read yet. Invalidate the instant-opens feed so it refetches and\n * the optimistic row appears immediately — without waiting for a poll.\n */\n const configKey = config.getChainConfigKey(variables.chainId ?? chainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantOpensQueryKey, { configKey }) });\n /** The open locks margin and charges a fee — every balance read on this chain is now suspect. */\n invalidateAccountBalances(queryClient, { configKey });\n },\n });\n}\n"],"mappings":";;;;;;;;;AAgDA,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAO,EAA+B,CAAM;CAElD,OAAO,EAAqF;EAC1F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS,EAAU,WAAW;IAAQ,CAAC;GACtF,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAMjC,IAAM,IAAY,EAAO,kBAAkB,EAAU,WAAW,CAAO;GAGvE,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAyB,EAAE,aAAU,CAAC,EAAE,CAAC,GAExG,EAA0B,GAAa,EAAE,aAAU,CAAC;EACtD;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-instant-open-auto.js","names":[],"sources":["../../src/instant-layer/use-instant-open-auto.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantOpensQueryKey,\n instantOpenAutoMutationOptions,\n type ConfigParameter,\n type InstantOpenReturnType,\n type PrepareInstantOpenParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } 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 { invalidateAccountBalances, predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useInstantOpenAuto}.\n */\nexport type UseInstantOpenAutoParameters = ConfigParameter;\n\n/** Return type of {@link useInstantOpenAuto}. */\nexport type UseInstantOpenAutoReturnType = UseMutationResult<\n InstantOpenReturnType,\n SymmioRequestError,\n PrepareInstantOpenParameters\n>;\n\n/**\n * Open a lowcap instant position via the wizard `instantOpenAuto` action.\n *\n * Friendly default: accepts the minimal trade intent and lets the SDK fetch\n * market metadata, mark price, locked params, and fee rates. Pre-fill any\n * optional field on the variables (e.g. cache-hot `markPrice`) to skip its\n * fetch. For full control — inspect / mutate resolved params between fetch and\n * submit — use {@link useInstantOpen} after calling\n * `prepareInstantOpenParams(config, …)` directly.\n *\n * Funding is a one-of on the variables: a typed `initialMargin`, or\n * `fund: { mode: \"full-balance\", balance }` (lowcap only) to deploy the whole\n * balance into the position's VA with the quantity sized down to fit it —\n * see `FullBalanceFunding` in `@symmio/trading-core`.\n *\n * @example\n * ```tsx\n * const { mutateAsync } = useInstantOpenAuto();\n * await mutateAsync({\n * walletAddress, sessionKeyAddress, signTypedData,\n * marketId: 1, positionType: \"LONG\",\n * userInput: \"100\", leverage: 5, slippage: 1,\n * });\n * ```\n */\nexport function useInstantOpenAuto(parameters: UseInstantOpenAutoParameters = {}): UseInstantOpenAutoReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const base = instantOpenAutoMutationOptions(config);\n\n return useMutation<InstantOpenReturnType, SymmioRequestError, PrepareInstantOpenParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n return await base.mutationFn({ ...variables, chainId: variables.chainId ?? chainId });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n /**\n * A freshly submitted instant-open exists on the hedger but not in any\n * cached read yet. Invalidate the instant-opens feed so it refetches and\n * the optimistic row appears immediately — without waiting for a poll.\n */\n const configKey = config.getChainConfigKey(variables.chainId ?? chainId);\n void queryClient.invalidateQueries({ predicate: predicateMatch(getInstantOpensQueryKey, { configKey }) });\n /** The open locks margin and charges a fee — every balance read on this chain is now suspect. */\n invalidateAccountBalances(queryClient, { configKey });\n },\n });\n}\n"],"mappings":";;;;;;;;;AAqDA,SAAgB,EAAmB,IAA2C,CAAC,GAAiC;CAC9G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAO,EAA+B,CAAM;CAElD,OAAO,EAAqF;EAC1F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,OAAO,MAAM,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS,EAAU,WAAW;IAAQ,CAAC;GACtF,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAMjC,IAAM,IAAY,EAAO,kBAAkB,EAAU,WAAW,CAAO;GAGvE,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAyB,EAAE,aAAU,CAAC,EAAE,CAAC,GAExG,EAA0B,GAAa,EAAE,aAAU,CAAC;EACtD;CACF,CAAC;AACH"}
@@ -3,13 +3,18 @@ import { UseQueryResult } from '@tanstack/react-query';
3
3
  import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useInstantOpenFees}: the trade intent
6
- * (`subAccountAddress`, `market`, `positionType`, `initialMargin`,
7
- * `leverage`, optional `slippage` / pre-fetched data, TanStack `query`
8
- * overrides) plus an optional `config`.
6
+ * (`subAccountAddress`, `market`, `positionType`, `initialMargin` **or**
7
+ * `fund` for a full-balance preview, `leverage`, optional `slippage` /
8
+ * pre-fetched data, TanStack `query` overrides) plus an optional `config`.
9
9
  */
10
10
  export type UseInstantOpenFeesParameters = GetInstantOpenFeesOptions & ConfigParameter;
11
11
  /** Return type of {@link useInstantOpenFees}. */
12
- export type UseInstantOpenFeesReturnType = UseQueryResult<GetInstantOpenFeesReturnType, SymmioRequestError>;
12
+ export type UseInstantOpenFeesReturnType = UseQueryResult<GetInstantOpenFeesReturnType, SymmioRequestError> & {
13
+ /** Synchronous input error. Display before query.error; dependent queries stay disabled. */
14
+ validationError: SymmioRequestError | undefined;
15
+ /** True when all inputs and the current fee preview have settled successfully. */
16
+ isReady: boolean;
17
+ };
13
18
  /**
14
19
  * Preview every fee a new instant-open quote pays — separated by leg plus the
15
20
  * total — before the user submits. Read-only; nothing is signed.
@@ -17,15 +22,33 @@ export type UseInstantOpenFeesReturnType = UseQueryResult<GetInstantOpenFeesRetu
17
22
  * Wraps `getInstantOpenFees`, but **pre-fetches every input through its own
18
23
  * cached queries and passes them in as prefills**, so the query function is
19
24
  * pure math with zero network hops: market metadata (`useMarkets`) and
20
- * on-chain fee rates (`useFeeForUser`) are slow-moving and cached for
21
- * minutes; the mark price rides the shared price stream; the lowcap dry-run
22
- * estimate uses `useEstimatedPrice` (debounced internally). Previous data is
25
+ * on-chain fee rates (`useFeeForUser`) and solver info are cached for minutes.
26
+ * The mark price rides the shared price stream; the lowcap dry-run estimate
27
+ * uses `useEstimatedPrice` (debounced internally). Previous data is
23
28
  * kept while inputs move, so a mark-price tick updates the numbers in place —
24
29
  * it never resets the result to a loading state.
25
30
  *
26
- * The result is a `kind`-discriminated union: both kinds carry the platform
27
- * legs and `totalFee`; an `"enigma"` (lowcap) result adds `openSolverFee`,
28
- * `closeSolverFee`, and `expectedSettlementLoss`.
31
+ * The result is a `kind`-discriminated union of the **open-side** legs: both
32
+ * kinds carry `platformOpenFee`, the sized `quantity`, and `totalFee`; an
33
+ * `"enigma"` (lowcap) result adds `openSolverFee`, `staticSolverFeeOpen`, and
34
+ * `expectedSettlementLoss`. Close fees are charged at close from the position
35
+ * and are deliberately not part of this preview — price them in the close flow
36
+ * with `useInstantCloseFees`, where the notional and holding time are real.
37
+ * `totalFee` includes the settlement provision by default; pass
38
+ * `includeSettlementInTotalFee: false` to sum the fee legs only.
39
+ *
40
+ * With `fund` (`FullBalanceFunding`) instead of `initialMargin`, the
41
+ * preview runs the same probe-and-rescale sizing as the open, so the legs and
42
+ * `quantity` equal what a full-balance open will actually charge and submit —
43
+ * the extra inputs it needs (locked-param percents, market quote constraints)
44
+ * are prefetched here through the same cached queries.
45
+ *
46
+ * With `initialMargin` and `availableBalance`, core automatically uses full-balance
47
+ * sizing when required funding exceeds the raw balance. `data.fundingMode` reports
48
+ * the effective choice; pass the same inputs to preparation and submission.
49
+ * Display `validationError ?? error` and check `isReady` before using the fees
50
+ * for the current input. Input errors are synchronous, including offline.
51
+ * A disabled hook or empty input remains idle without input validation.
29
52
  *
30
53
  * @example
31
54
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"use-instant-open-fees.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-fees.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQzE;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,yBAAyB,GAAG,eAAe,CAAC;AAEvF,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,cAAc,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC;AAE5G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,4BAA4B,GAAG,4BAA4B,CAkJzG"}
1
+ {"version":3,"file":"use-instant-open-fees.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-fees.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;AAGzE;;;;;GAKG;AACH,MAAM,MAAM,4BAA4B,GAAG,yBAAyB,GAAG,eAAe,CAAC;AAEvF,iDAAiD;AACjD,MAAM,MAAM,4BAA4B,GAAG,cAAc,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,GAAG;IAC5G,4FAA4F;IAC5F,eAAe,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAChD,kFAAkF;IAClF,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,4BAA4B,GAAG,4BAA4B,CA2BzG"}
@@ -1,111 +1,35 @@
1
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 { useEstimatedPrice as r } from "../estimated-price/use-estimated-price.js";
6
- import { useFeeForUser as i } from "../fees/use-fee-for-user.js";
7
- import { useMarkets as a } from "../markets/use-markets.js";
8
- import { usePriceByName as o } from "../price-service/use-price-by-name.js";
9
- import { PositionType as s, calculateTradeParams as c, getInstantOpenFeesQueryOptions as l } from "@symmio/trading-core";
10
- import { useMemo as u } from "react";
11
- import { useQuery as d } from "@tanstack/react-query";
2
+ import { normalizeSymmError as e } from "../errors/normalize-symm-error.js";
3
+ import { useInstantOpenInputs as t } from "./use-instant-open-inputs.js";
4
+ import { getInstantOpenFeesQueryOptions as n } from "@symmio/trading-core";
5
+ import { useQuery as r } from "@tanstack/react-query";
12
6
  //#region src/instant-layer/use-instant-open-fees.ts
13
- function f(f) {
14
- let p = t(f), m = e(), h = f.chainId ?? m, { subAccountAddress: g, market: _, positionType: v, initialMargin: y, leverage: b, slippage: x, solverId: S } = f, C = (f.query?.enabled ?? !0) && y.length > 0, w = p.getSolver({
15
- chainId: h,
16
- solverId: S
17
- }).id === "enigma", T = a({
18
- config: f.config,
19
- chainId: h,
20
- solverId: S,
7
+ function i(i) {
8
+ let a = t(i, "fees", i.query?.enabled !== !1), o = n(a.config, {
9
+ ...i,
10
+ ...a.prefills,
21
11
  query: {
22
- enabled: C,
23
- staleTime: 3e5
12
+ ...i.query,
13
+ enabled: a.ready,
14
+ placeholderData: (e) => a.validationError === void 0 ? e : void 0
24
15
  }
25
- }).data?.find((e) => e.symbolId === _.id), E = _.name ?? T?.name, D = _.pricePrecision ?? T?.pricePrecision, O = _.quantityPrecision ?? T?.quantityPrecision, k = _.hedgerFeeOpen ?? T?.hedgerFeeOpen, A = _.hedgerFeeClose ?? T?.hedgerFeeClose, j = T?.kind === "enigma" ? T : void 0, M = _.hedgerFeeCloseEarlyRate ?? j?.hedgerFeeCloseEarlyRate ?? A, N = _.hedgerFeeCloseEarlyThreshold ?? j?.hedgerFeeCloseEarlyThreshold ?? 0, P = _.hedgerFeeCloseStandardThreshold ?? j?.hedgerFeeCloseStandardThreshold ?? 0, F = i({
26
- config: f.config,
27
- chainId: h,
28
- user: g,
29
- symbolId: BigInt(_.id),
30
- query: {
31
- enabled: C && f.feeRates === void 0,
32
- staleTime: 3e5
33
- }
34
- }), I = f.feeRates ?? F.data, L = o({
35
- name: E,
36
- solverId: S,
37
- enabled: C && f.markPrice === void 0
38
- }), R = f.markPrice ?? L.markPrice ?? void 0, z = u(() => !C || !w || R === void 0 || D === void 0 || O === void 0 ? "" : c({
39
- markPrice: R,
40
- slippage: 0,
41
- positionType: v,
42
- userInput: y,
43
- inputField: "PRICE",
44
- leverage: b,
45
- pricePrecision: D,
46
- quantityPrecision: O
47
- })?.quantity ?? "", [
48
- C,
49
- w,
50
- R,
51
- D,
52
- O,
53
- v,
54
- y,
55
- b
56
- ]), B = R === void 0 ? "" : String(Number(R) * (v === s.SHORT ? .5 : 1.5)), V = r({
57
- config: f.config,
58
- chainId: h,
59
- solverId: S,
60
- symbolId: _.id,
61
- quantity: z,
62
- positionType: v,
63
- entry: "open",
64
- price: B,
65
- query: {
66
- enabled: C && w && f.estimatedOpenPrice === void 0 && z.length > 0,
67
- staleTime: 3e4
68
- }
69
- }), H = w ? f.estimatedOpenPrice ?? V.data?.estimatedPrice ?? "0" : void 0, U = !w || f.estimatedOpenPrice !== void 0 || V.isFetched || V.isError, W = C && E !== void 0 && D !== void 0 && O !== void 0 && I !== void 0 && R !== void 0 && (!w || k !== void 0 && A !== void 0) && U, G = l(p, {
70
- subAccountAddress: g,
71
- solverId: S,
72
- chainId: h,
73
- market: {
74
- id: _.id,
75
- name: E,
76
- pricePrecision: D,
77
- quantityPrecision: O,
78
- hedgerFeeOpen: k,
79
- hedgerFeeClose: A,
80
- hedgerFeeCloseEarlyRate: M,
81
- hedgerFeeCloseEarlyThreshold: N,
82
- hedgerFeeCloseStandardThreshold: P
83
- },
84
- positionType: v,
85
- initialMargin: y,
86
- leverage: b,
87
- slippage: x,
88
- markPrice: R,
89
- feeRates: I,
90
- estimatedOpenPrice: H,
91
- query: {
92
- ...f.query,
93
- enabled: W,
94
- placeholderData: (e) => e
95
- }
96
- });
97
- return d({
98
- ...G,
16
+ }), s = r({
17
+ ...o,
99
18
  queryFn: async () => {
100
19
  try {
101
- return await G.queryFn();
102
- } catch (e) {
103
- throw n(e);
20
+ return await o.queryFn();
21
+ } catch (t) {
22
+ throw e(t);
104
23
  }
105
24
  }
106
25
  });
26
+ return {
27
+ ...s,
28
+ validationError: a.validationError,
29
+ isReady: a.ready && s.isSuccess && !s.isFetching && !s.isPlaceholderData
30
+ };
107
31
  }
108
32
  //#endregion
109
- export { f as useInstantOpenFees };
33
+ export { i as useInstantOpenFees };
110
34
 
111
35
  //# sourceMappingURL=use-instant-open-fees.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-instant-open-fees.js","names":[],"sources":["../../src/instant-layer/use-instant-open-fees.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateTradeParams,\n getInstantOpenFeesQueryOptions,\n PositionType,\n type ConfigParameter,\n type GetInstantOpenFeesOptions,\n type GetInstantOpenFeesReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useEstimatedPrice } from \"../estimated-price/use-estimated-price\";\nimport { useFeeForUser } from \"../fees/use-fee-for-user\";\nimport { useMarkets } from \"../markets/use-markets\";\nimport { usePriceByName } from \"../price-service/use-price-by-name\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/**\n * Parameters for {@link useInstantOpenFees}: the trade intent\n * (`subAccountAddress`, `market`, `positionType`, `initialMargin`,\n * `leverage`, optional `slippage` / pre-fetched data, TanStack `query`\n * overrides) plus an optional `config`.\n */\nexport type UseInstantOpenFeesParameters = GetInstantOpenFeesOptions & ConfigParameter;\n\n/** Return type of {@link useInstantOpenFees}. */\nexport type UseInstantOpenFeesReturnType = UseQueryResult<GetInstantOpenFeesReturnType, SymmioRequestError>;\n\n/**\n * Preview every fee a new instant-open quote pays — separated by leg plus the\n * total — before the user submits. Read-only; nothing is signed.\n *\n * Wraps `getInstantOpenFees`, but **pre-fetches every input through its own\n * cached queries and passes them in as prefills**, so the query function is\n * pure math with zero network hops: market metadata (`useMarkets`) and\n * on-chain fee rates (`useFeeForUser`) are slow-moving and cached for\n * minutes; the mark price rides the shared price stream; the lowcap dry-run\n * estimate uses `useEstimatedPrice` (debounced internally). Previous data is\n * kept while inputs move, so a mark-price tick updates the numbers in place —\n * it never resets the result to a loading state.\n *\n * The result is a `kind`-discriminated union: both kinds carry the platform\n * legs and `totalFee`; an `\"enigma\"` (lowcap) result adds `openSolverFee`,\n * `closeSolverFee`, and `expectedSettlementLoss`.\n *\n * @example\n * ```tsx\n * const { data: fees } = useInstantOpenFees({\n * subAccountAddress,\n * market: { id: symbolId },\n * positionType,\n * initialMargin,\n * leverage,\n * });\n * // fees?.totalFee; fees?.kind === \"enigma\" && fees.expectedSettlementLoss\n * ```\n */\nexport function useInstantOpenFees(parameters: UseInstantOpenFeesParameters): UseInstantOpenFeesReturnType {\n const config = useSymmioConfig(parameters);\n const contextChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? contextChainId;\n const { subAccountAddress, market, positionType, initialMargin, leverage, slippage, solverId } = parameters;\n const enabled = (parameters.query?.enabled ?? true) && initialMargin.length > 0;\n\n /** The dry-run estimate exists only on lowcap (Enigma) solvers. */\n const isLowcap = config.getSolver({ chainId, solverId }).id === \"enigma\";\n\n // Market metadata — slow-moving; dedupes with any other useMarkets on the page.\n const marketsQuery = useMarkets({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled, staleTime: 300_000 },\n });\n const resolvedMarket = marketsQuery.data?.find((entry) => entry.symbolId === market.id);\n const marketName = market.name ?? resolvedMarket?.name;\n const pricePrecision = market.pricePrecision ?? resolvedMarket?.pricePrecision;\n const quantityPrecision = market.quantityPrecision ?? resolvedMarket?.quantityPrecision;\n const hedgerFeeOpen = market.hedgerFeeOpen ?? resolvedMarket?.hedgerFeeOpen;\n const hedgerFeeClose = market.hedgerFeeClose ?? resolvedMarket?.hedgerFeeClose;\n\n // Time-decaying close-fee rates ride the same `useMarkets` read — they are\n // Enigma-only fields on `EnigmaMarket`, so narrow on `kind` before reading.\n const resolvedEnigmaMarket = resolvedMarket?.kind === \"enigma\" ? resolvedMarket : undefined;\n const hedgerFeeCloseEarlyRate =\n market.hedgerFeeCloseEarlyRate ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyRate ?? hedgerFeeClose;\n const hedgerFeeCloseEarlyThreshold =\n market.hedgerFeeCloseEarlyThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyThreshold ?? 0;\n const hedgerFeeCloseStandardThreshold =\n market.hedgerFeeCloseStandardThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseStandardThreshold ?? 0;\n\n // On-chain platform fee rates — contract state, changes rarely; cached hard.\n const feeQuery = useFeeForUser({\n config: parameters.config,\n chainId,\n user: subAccountAddress,\n symbolId: BigInt(market.id),\n query: { enabled: enabled && parameters.feeRates === undefined, staleTime: 300_000 },\n });\n const feeRates = parameters.feeRates ?? feeQuery.data;\n\n // Mark price — caller's cache-hot value wins; otherwise the shared stream.\n const priceQuery = usePriceByName({\n name: marketName,\n solverId,\n enabled: enabled && parameters.markPrice === undefined,\n });\n const markPrice = parameters.markPrice ?? priceQuery.markPrice ?? undefined;\n\n // Lowcap dry-run estimate: mark-sized quantity, wide fixed request bound so\n // the solver's price gate never rejects the question. Debounced internally.\n const estimateQuantity = useMemo(() => {\n if (!enabled || !isLowcap || markPrice === undefined) return \"\";\n if (pricePrecision === undefined || quantityPrecision === undefined) return \"\";\n const sized = calculateTradeParams({\n markPrice,\n slippage: 0,\n positionType,\n userInput: initialMargin,\n inputField: \"PRICE\",\n leverage,\n pricePrecision,\n quantityPrecision,\n });\n return sized?.quantity ?? \"\";\n }, [enabled, isLowcap, markPrice, pricePrecision, quantityPrecision, positionType, initialMargin, leverage]);\n const estimateRequestPrice =\n markPrice !== undefined ? String(Number(markPrice) * (positionType === PositionType.SHORT ? 0.5 : 1.5)) : \"\";\n const estimateQuery = useEstimatedPrice({\n config: parameters.config,\n chainId,\n solverId,\n symbolId: market.id,\n quantity: estimateQuantity,\n positionType,\n entry: \"open\",\n price: estimateRequestPrice,\n query: {\n enabled: enabled && isLowcap && parameters.estimatedOpenPrice === undefined && estimateQuantity.length > 0,\n staleTime: 30_000,\n },\n });\n // `\"0\"` is the action's \"no usable estimate\" sentinel: it suppresses the\n // action's own fetch (the input IS supplied) and yields a zero settlement\n // provision — so a solver outage never puts network calls back in queryFn.\n const estimatedOpenPrice = !isLowcap\n ? undefined\n : (parameters.estimatedOpenPrice ?? estimateQuery.data?.estimatedPrice ?? \"0\");\n const estimateSettled =\n !isLowcap || parameters.estimatedOpenPrice !== undefined || estimateQuery.isFetched || estimateQuery.isError;\n\n // Every prefill present → the query function is pure math, zero fetches.\n const ready =\n enabled &&\n marketName !== undefined &&\n pricePrecision !== undefined &&\n quantityPrecision !== undefined &&\n feeRates !== undefined &&\n markPrice !== undefined &&\n (!isLowcap || (hedgerFeeOpen !== undefined && hedgerFeeClose !== undefined)) &&\n estimateSettled;\n\n const options = getInstantOpenFeesQueryOptions(config, {\n subAccountAddress,\n solverId,\n chainId,\n market: {\n id: market.id,\n name: marketName,\n pricePrecision,\n quantityPrecision,\n hedgerFeeOpen,\n hedgerFeeClose,\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold,\n hedgerFeeCloseStandardThreshold,\n },\n positionType,\n initialMargin,\n leverage,\n slippage,\n markPrice,\n feeRates,\n estimatedOpenPrice,\n query: {\n ...parameters.query,\n enabled: ready,\n // Inputs (mark price, estimate) tick often; keep showing the previous\n // numbers while the pure recompute runs instead of flashing a loader.\n placeholderData: (previous: GetInstantOpenFeesReturnType | undefined) => previous,\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 UseInstantOpenFeesReturnType;\n}\n"],"mappings":";;;;;;;;;;;;AA6DA,SAAgB,EAAmB,GAAwE;CACzG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAChC,EAAE,sBAAmB,WAAQ,iBAAc,kBAAe,aAAU,aAAU,gBAAa,GAC3F,KAAW,EAAW,OAAO,WAAW,OAAS,EAAc,SAAS,GAGxE,IAAW,EAAO,UAAU;EAAE;EAAS;CAAS,CAAC,EAAE,OAAO,UAS1D,IANe,EAAW;EAC9B,QAAQ,EAAW;EACnB;EACA;EACA,OAAO;GAAE;GAAS,WAAW;EAAQ;CACvC,CACuB,EAAa,MAAM,MAAM,MAAU,EAAM,aAAa,EAAO,EAAE,GAChF,IAAa,EAAO,QAAQ,GAAgB,MAC5C,IAAiB,EAAO,kBAAkB,GAAgB,gBAC1D,IAAoB,EAAO,qBAAqB,GAAgB,mBAChE,IAAgB,EAAO,iBAAiB,GAAgB,eACxD,IAAiB,EAAO,kBAAkB,GAAgB,gBAI1D,IAAuB,GAAgB,SAAS,WAAW,IAAiB,KAAA,GAC5E,IACJ,EAAO,2BAA2B,GAAsB,2BAA2B,GAC/E,IACJ,EAAO,gCAAgC,GAAsB,gCAAgC,GACzF,IACJ,EAAO,mCAAmC,GAAsB,mCAAmC,GAG/F,IAAW,EAAc;EAC7B,QAAQ,EAAW;EACnB;EACA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A;GACA;GACA;GACA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;GACL,GAAG,EAAW;GACd,SAAS;GAGT,kBAAkB,MAAuD;EAC3E;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-instant-open-fees.js","names":[],"sources":["../../src/instant-layer/use-instant-open-fees.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getInstantOpenFeesQueryOptions,\n type ConfigParameter,\n type GetInstantOpenFeesOptions,\n type GetInstantOpenFeesReturnType,\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 { useInstantOpenInputs } from \"./use-instant-open-inputs\";\n\n/**\n * Parameters for {@link useInstantOpenFees}: the trade intent\n * (`subAccountAddress`, `market`, `positionType`, `initialMargin` **or**\n * `fund` for a full-balance preview, `leverage`, optional `slippage` /\n * pre-fetched data, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseInstantOpenFeesParameters = GetInstantOpenFeesOptions & ConfigParameter;\n\n/** Return type of {@link useInstantOpenFees}. */\nexport type UseInstantOpenFeesReturnType = UseQueryResult<GetInstantOpenFeesReturnType, SymmioRequestError> & {\n /** Synchronous input error. Display before query.error; dependent queries stay disabled. */\n validationError: SymmioRequestError | undefined;\n /** True when all inputs and the current fee preview have settled successfully. */\n isReady: boolean;\n};\n\n/**\n * Preview every fee a new instant-open quote pays — separated by leg plus the\n * total — before the user submits. Read-only; nothing is signed.\n *\n * Wraps `getInstantOpenFees`, but **pre-fetches every input through its own\n * cached queries and passes them in as prefills**, so the query function is\n * pure math with zero network hops: market metadata (`useMarkets`) and\n * on-chain fee rates (`useFeeForUser`) and solver info are cached for minutes.\n * The mark price rides the shared price stream; the lowcap dry-run estimate\n * uses `useEstimatedPrice` (debounced internally). Previous data is\n * kept while inputs move, so a mark-price tick updates the numbers in place —\n * it never resets the result to a loading state.\n *\n * The result is a `kind`-discriminated union of the **open-side** legs: both\n * kinds carry `platformOpenFee`, the sized `quantity`, and `totalFee`; an\n * `\"enigma\"` (lowcap) result adds `openSolverFee`, `staticSolverFeeOpen`, and\n * `expectedSettlementLoss`. Close fees are charged at close from the position\n * and are deliberately not part of this preview — price them in the close flow\n * with `useInstantCloseFees`, where the notional and holding time are real.\n * `totalFee` includes the settlement provision by default; pass\n * `includeSettlementInTotalFee: false` to sum the fee legs only.\n *\n * With `fund` (`FullBalanceFunding`) instead of `initialMargin`, the\n * preview runs the same probe-and-rescale sizing as the open, so the legs and\n * `quantity` equal what a full-balance open will actually charge and submit —\n * the extra inputs it needs (locked-param percents, market quote constraints)\n * are prefetched here through the same cached queries.\n *\n * With `initialMargin` and `availableBalance`, core automatically uses full-balance\n * sizing when required funding exceeds the raw balance. `data.fundingMode` reports\n * the effective choice; pass the same inputs to preparation and submission.\n * Display `validationError ?? error` and check `isReady` before using the fees\n * for the current input. Input errors are synchronous, including offline.\n * A disabled hook or empty input remains idle without input validation.\n *\n * @example\n * ```tsx\n * const { data: fees } = useInstantOpenFees({\n * subAccountAddress,\n * market: { id: symbolId },\n * positionType,\n * initialMargin,\n * leverage,\n * });\n * // fees?.totalFee; fees?.kind === \"enigma\" && fees.expectedSettlementLoss\n * ```\n */\nexport function useInstantOpenFees(parameters: UseInstantOpenFeesParameters): UseInstantOpenFeesReturnType {\n const inputs = useInstantOpenInputs(parameters, \"fees\", parameters.query?.enabled !== false);\n const options = getInstantOpenFeesQueryOptions(inputs.config, {\n ...parameters,\n ...inputs.prefills,\n query: {\n ...parameters.query,\n enabled: inputs.ready,\n placeholderData: (previous) => (inputs.validationError === undefined ? previous : undefined),\n },\n });\n const query = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<GetInstantOpenFeesReturnType, SymmioRequestError>;\n\n return {\n ...query,\n validationError: inputs.validationError,\n isReady: inputs.ready && query.isSuccess && !query.isFetching && !query.isPlaceholderData,\n };\n}\n"],"mappings":";;;;;;AA4EA,SAAgB,EAAmB,GAAwE;CACzG,IAAM,IAAS,EAAqB,GAAY,QAAQ,EAAW,OAAO,YAAY,EAAK,GACrF,IAAU,EAA+B,EAAO,QAAQ;EAC5D,GAAG;EACH,GAAG,EAAO;EACV,OAAO;GACL,GAAG,EAAW;GACd,SAAS,EAAO;GAChB,kBAAkB,MAAc,EAAO,oBAAoB,KAAA,IAAY,IAAW,KAAA;EACpF;CACF,CAAC,GACK,IAAQ,EAAS;EACrB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAED,OAAO;EACL,GAAG;EACH,iBAAiB,EAAO;EACxB,SAAS,EAAO,SAAS,EAAM,aAAa,CAAC,EAAM,cAAc,CAAC,EAAM;CAC1E;AACF"}
@@ -0,0 +1,35 @@
1
+ import { ConfigParameter, GetInstantOpenFeesParameters } from '@symmio/trading-core';
2
+ /** Shared input orchestration for preparation and fee previews; calculations stay in core. */
3
+ export declare function useInstantOpenInputs(parameters: GetInstantOpenFeesParameters & ConfigParameter, purpose: "prepare" | "fees", queryEnabled?: boolean): {
4
+ config: import('@symmio/trading-core').Config;
5
+ validationError: import('../index.js').SymmioRequestError | undefined;
6
+ ready: boolean;
7
+ prefills: {
8
+ chainId: number;
9
+ market: {
10
+ id: number;
11
+ name: string | undefined;
12
+ pricePrecision: number | undefined;
13
+ quantityPrecision: number | undefined;
14
+ minOpenSolverFeeCap: string | undefined;
15
+ minCloseSolverFeeCap: string | undefined;
16
+ hedgerFeeOpen: string | undefined;
17
+ hedgerFeeClose: string | undefined;
18
+ hedgerFeeCloseEarlyRate: string | undefined;
19
+ hedgerFeeCloseEarlyThreshold: number;
20
+ hedgerFeeCloseStandardThreshold: number;
21
+ minAcceptablePortionLf: string | undefined;
22
+ minAcceptableQuoteValue: string | undefined;
23
+ maxNotionalValue: number | undefined;
24
+ minNotionalValue: string | undefined;
25
+ maxQuantity: string | undefined;
26
+ lotSize: string | undefined;
27
+ };
28
+ markPrice: string | undefined;
29
+ feeRates: import('@symmio/trading-core').FeeForUser | undefined;
30
+ lockedParamPercent: import('@symmio/trading-core').SolverLockedParams | undefined;
31
+ solverInfo: import('@symmio/trading-core').EnigmaSolverInfo | undefined;
32
+ estimatedOpenPrice: string | null | undefined;
33
+ };
34
+ };
35
+ //# sourceMappingURL=use-instant-open-inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-instant-open-inputs.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-inputs.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAY9B,8FAA8F;AAC9F,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,4BAA4B,GAAG,eAAe,EAC1D,OAAO,EAAE,SAAS,GAAG,MAAM,EAC3B,YAAY,UAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6NpB"}
@@ -0,0 +1,134 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as ee } from "../provider/use-symmio-config.js";
4
+ import { useFeeForUser as te } from "../fees/use-fee-for-user.js";
5
+ import { useMarkets as ne } from "../markets/use-markets.js";
6
+ import { usePriceByName as re } from "../price-service/use-price-by-name.js";
7
+ import { useSolverInfo as ie } from "../solvers/use-solver-info.js";
8
+ import { useEstimatedPrice as t } from "../estimated-price/use-estimated-price.js";
9
+ import { useLockedParams as n } from "../locked-params/use-locked-params.js";
10
+ import { getInstantOpenFundingError as r } from "./get-instant-open-funding-error.js";
11
+ import { PositionType as i, calculateTradeParams as a } from "@symmio/trading-core";
12
+ import { useMemo as ae } from "react";
13
+ //#region src/instant-layer/use-instant-open-inputs.ts
14
+ function o(o, s, c = !0) {
15
+ let l = ee(o), u = e(), d = o.chainId ?? u, { subAccountAddress: f, market: p, positionType: m, initialMargin: oe, fund: h, leverage: g, solverId: _ } = o, v = h !== void 0, y = v || o.availableBalance !== void 0, b = s === "prepare" || y, se = s === "prepare" && l.getChainConfig(d).contractsVersion === "0.8.6", x = v ? h.balance : oe ?? "", S = c && x.length > 0, C = l.getSolver({
16
+ chainId: d,
17
+ solverId: _
18
+ }).id === "enigma", w = S ? r({
19
+ ...o,
20
+ isLowcap: C
21
+ }) : void 0, T = S && w === void 0, E = ne({
22
+ config: o.config,
23
+ chainId: d,
24
+ solverId: _,
25
+ query: {
26
+ enabled: T,
27
+ staleTime: 3e5
28
+ }
29
+ }).data?.find((e) => e.symbolId === p.id), D = p.name ?? E?.name, O = p.pricePrecision ?? E?.pricePrecision, k = p.quantityPrecision ?? E?.quantityPrecision, A = p.hedgerFeeOpen ?? E?.hedgerFeeOpen, j = p.hedgerFeeClose ?? E?.hedgerFeeClose, M = p.minOpenSolverFeeCap ?? (E ? E.kind === "enigma" ? E.minOpenSolverFeeCap : "0" : void 0), N = p.minCloseSolverFeeCap ?? (E ? E.kind === "enigma" ? E.minCloseSolverFeeCap : "0" : void 0), ce = !se || M !== void 0 && N !== void 0, P = E?.kind === "enigma" ? E : void 0, le = p.hedgerFeeCloseEarlyRate ?? P?.hedgerFeeCloseEarlyRate ?? j, ue = p.hedgerFeeCloseEarlyThreshold ?? P?.hedgerFeeCloseEarlyThreshold ?? 0, F = p.hedgerFeeCloseStandardThreshold ?? P?.hedgerFeeCloseStandardThreshold ?? 0, I = p.minAcceptablePortionLf ?? E?.minAcceptablePortionLf, L = p.minAcceptableQuoteValue ?? E?.minAcceptableQuoteValue, R = p.maxNotionalValue ?? E?.maxNotionalValue, z = p.minNotionalValue ?? E?.minNotionalValue, B = p.maxQuantity ?? E?.maxQuantity, V = p.lotSize ?? E?.lotSize, H = !y || I !== void 0 && L !== void 0 && R !== void 0 && z !== void 0 && B !== void 0 && V !== void 0, U = o.lockedParamPercent?.cva !== void 0 && o.lockedParamPercent.lf !== void 0 && o.lockedParamPercent.partyAmm !== void 0 && o.lockedParamPercent.partyBmm !== void 0, W = n({
30
+ config: o.config,
31
+ chainId: d,
32
+ solverId: _,
33
+ symbol: D ?? "",
34
+ leverage: g,
35
+ query: {
36
+ enabled: T && b && !U && D !== void 0,
37
+ staleTime: 3e5
38
+ }
39
+ }), G = U ? o.lockedParamPercent : W.data ? {
40
+ cva: W.data.cva ?? "0",
41
+ lf: W.data.lf ?? "0",
42
+ partyAmm: W.data.partyAmm ?? "0",
43
+ partyBmm: W.data.partyBmm ?? "0"
44
+ } : void 0, de = !b || G !== void 0, K = ie({
45
+ config: o.config,
46
+ chainId: d,
47
+ solverId: _,
48
+ query: {
49
+ enabled: T && C && o.solverInfo === void 0,
50
+ staleTime: 3e5,
51
+ retry: !1
52
+ }
53
+ }), q = o.solverInfo ?? K.data ?? (K.isError ? {} : void 0), fe = !C || q !== void 0, pe = te({
54
+ config: o.config,
55
+ chainId: d,
56
+ user: f,
57
+ symbolId: BigInt(p.id),
58
+ query: {
59
+ enabled: T && o.feeRates === void 0,
60
+ staleTime: 3e5
61
+ }
62
+ }), J = o.feeRates ?? pe.data, me = re({
63
+ name: D,
64
+ solverId: _,
65
+ enabled: T && o.markPrice === void 0
66
+ }), Y = o.markPrice ?? me.markPrice ?? void 0, X = ae(() => !T || !C || Y === void 0 || O === void 0 || k === void 0 ? "" : a({
67
+ markPrice: Y,
68
+ slippage: 0,
69
+ positionType: m,
70
+ userInput: x,
71
+ inputField: "PRICE",
72
+ leverage: g,
73
+ pricePrecision: O,
74
+ quantityPrecision: k
75
+ })?.quantity ?? "", [
76
+ T,
77
+ C,
78
+ Y,
79
+ O,
80
+ k,
81
+ m,
82
+ x,
83
+ g
84
+ ]), he = Y === void 0 ? "" : String(Number(Y) * (m === i.SHORT ? .5 : 1.5)), Z = t({
85
+ config: o.config,
86
+ chainId: d,
87
+ solverId: _,
88
+ symbolId: p.id,
89
+ quantity: X,
90
+ positionType: m,
91
+ entry: "open",
92
+ price: he,
93
+ query: {
94
+ enabled: T && C && o.estimatedOpenPrice === void 0 && X.length > 0,
95
+ staleTime: 3e4
96
+ }
97
+ }), ge = C && o.estimatedOpenPrice === void 0 && (Z.isDebouncing || Z.isFetching), Q = !C || o.estimatedOpenPrice !== void 0 || !ge && (Z.isFetched || Z.isError), $ = o.estimatedOpenPrice === void 0 ? Z.data?.estimatedPrice : o.estimatedOpenPrice, _e = !C || !Q ? void 0 : $ && $ !== "0" ? $ : null;
98
+ return {
99
+ config: l,
100
+ validationError: w,
101
+ ready: T && D !== void 0 && O !== void 0 && k !== void 0 && J !== void 0 && Y !== void 0 && de && (!C || A !== void 0 && j !== void 0) && H && ce && fe && Q,
102
+ prefills: {
103
+ chainId: d,
104
+ market: {
105
+ id: p.id,
106
+ name: D,
107
+ pricePrecision: O,
108
+ quantityPrecision: k,
109
+ minOpenSolverFeeCap: M,
110
+ minCloseSolverFeeCap: N,
111
+ hedgerFeeOpen: A,
112
+ hedgerFeeClose: j,
113
+ hedgerFeeCloseEarlyRate: le,
114
+ hedgerFeeCloseEarlyThreshold: ue,
115
+ hedgerFeeCloseStandardThreshold: F,
116
+ minAcceptablePortionLf: I,
117
+ minAcceptableQuoteValue: L,
118
+ maxNotionalValue: R,
119
+ minNotionalValue: z,
120
+ maxQuantity: B,
121
+ lotSize: V
122
+ },
123
+ markPrice: Y,
124
+ feeRates: J,
125
+ lockedParamPercent: G,
126
+ solverInfo: q,
127
+ estimatedOpenPrice: _e
128
+ }
129
+ };
130
+ }
131
+ //#endregion
132
+ export { o as useInstantOpenInputs };
133
+
134
+ //# sourceMappingURL=use-instant-open-inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-instant-open-inputs.js","names":[],"sources":["../../src/instant-layer/use-instant-open-inputs.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateTradeParams,\n PositionType,\n type ConfigParameter,\n type GetInstantOpenFeesParameters,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { useEstimatedPrice } from \"../estimated-price/use-estimated-price\";\nimport { useFeeForUser } from \"../fees/use-fee-for-user\";\nimport { useLockedParams } from \"../locked-params/use-locked-params\";\nimport { useMarkets } from \"../markets/use-markets\";\nimport { usePriceByName } from \"../price-service/use-price-by-name\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { useSolverInfo } from \"../solvers/use-solver-info\";\nimport { getInstantOpenFundingError } from \"./get-instant-open-funding-error\";\n\n/** Shared input orchestration for preparation and fee previews; calculations stay in core. */\nexport function useInstantOpenInputs(\n parameters: GetInstantOpenFeesParameters & ConfigParameter,\n purpose: \"prepare\" | \"fees\",\n queryEnabled = true,\n) {\n const config = useSymmioConfig(parameters);\n const contextChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? contextChainId;\n const { subAccountAddress, market, positionType, initialMargin, fund, leverage, solverId } = parameters;\n const isFullBalance = fund !== undefined;\n const canSizeFullBalance = isFullBalance || parameters.availableBalance !== undefined;\n const needsLockedParams = purpose === \"prepare\" || canSizeFullBalance;\n const needsSolverFeeCaps = purpose === \"prepare\" && config.getChainConfig(chainId).contractsVersion === \"0.8.6\";\n /** The amount driving the sizing math — the typed margin, or the whole balance in full-balance mode. */\n const sizingInput = isFullBalance ? fund.balance : (initialMargin ?? \"\");\n const requested = queryEnabled && sizingInput.length > 0;\n\n /** The dry-run estimate exists only on lowcap (Enigma) solvers. */\n const isLowcap = config.getSolver({ chainId, solverId }).id === \"enigma\";\n const validationError = requested ? getInstantOpenFundingError({ ...parameters, isLowcap }) : undefined;\n const enabled = requested && validationError === undefined;\n\n // Market metadata — slow-moving; dedupes with any other useMarkets on the page.\n const marketsQuery = useMarkets({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled, staleTime: 300_000 },\n });\n const resolvedMarket = marketsQuery.data?.find((entry) => entry.symbolId === market.id);\n const marketName = market.name ?? resolvedMarket?.name;\n const pricePrecision = market.pricePrecision ?? resolvedMarket?.pricePrecision;\n const quantityPrecision = market.quantityPrecision ?? resolvedMarket?.quantityPrecision;\n const hedgerFeeOpen = market.hedgerFeeOpen ?? resolvedMarket?.hedgerFeeOpen;\n const hedgerFeeClose = market.hedgerFeeClose ?? resolvedMarket?.hedgerFeeClose;\n\n const minOpenSolverFeeCap =\n market.minOpenSolverFeeCap ??\n (resolvedMarket ? (resolvedMarket.kind === \"enigma\" ? resolvedMarket.minOpenSolverFeeCap : \"0\") : undefined);\n const minCloseSolverFeeCap =\n market.minCloseSolverFeeCap ??\n (resolvedMarket ? (resolvedMarket.kind === \"enigma\" ? resolvedMarket.minCloseSolverFeeCap : \"0\") : undefined);\n const capsReady = !needsSolverFeeCaps || (minOpenSolverFeeCap !== undefined && minCloseSolverFeeCap !== undefined);\n\n // Time-decaying close-fee rates ride the same `useMarkets` read — Enigma-only\n // fields on `EnigmaMarket`, so narrow on `kind` before reading.\n const resolvedEnigmaMarket = resolvedMarket?.kind === \"enigma\" ? resolvedMarket : undefined;\n const hedgerFeeCloseEarlyRate =\n market.hedgerFeeCloseEarlyRate ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyRate ?? hedgerFeeClose;\n const hedgerFeeCloseEarlyThreshold =\n market.hedgerFeeCloseEarlyThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseEarlyThreshold ?? 0;\n const hedgerFeeCloseStandardThreshold =\n market.hedgerFeeCloseStandardThreshold ?? resolvedEnigmaMarket?.hedgerFeeCloseStandardThreshold ?? 0;\n\n // Quote constraints — explicit or automatic full-balance sizing snaps to the lot grid and checks the\n // published floors; they ride the same `useMarkets` read.\n const minAcceptablePortionLf = market.minAcceptablePortionLf ?? resolvedMarket?.minAcceptablePortionLf;\n const minAcceptableQuoteValue = market.minAcceptableQuoteValue ?? resolvedMarket?.minAcceptableQuoteValue;\n const maxNotionalValue = market.maxNotionalValue ?? resolvedMarket?.maxNotionalValue;\n const minNotionalValue = market.minNotionalValue ?? resolvedMarket?.minNotionalValue;\n const maxQuantity = market.maxQuantity ?? resolvedMarket?.maxQuantity;\n const lotSize = market.lotSize ?? resolvedMarket?.lotSize;\n const constraintsReady =\n !canSizeFullBalance ||\n (minAcceptablePortionLf !== undefined &&\n minAcceptableQuoteValue !== undefined &&\n maxNotionalValue !== undefined &&\n minNotionalValue !== undefined &&\n maxQuantity !== undefined &&\n lotSize !== undefined);\n\n // Preparation always needs locks; the fee preview needs them only for balance sizing.\n const locksPrefilled =\n parameters.lockedParamPercent?.cva !== undefined &&\n parameters.lockedParamPercent.lf !== undefined &&\n parameters.lockedParamPercent.partyAmm !== undefined &&\n parameters.lockedParamPercent.partyBmm !== undefined;\n const lockedParamsQuery = useLockedParams({\n config: parameters.config,\n chainId,\n solverId,\n symbol: marketName ?? \"\",\n leverage,\n query: {\n enabled: enabled && needsLockedParams && !locksPrefilled && marketName !== undefined,\n staleTime: 300_000,\n },\n });\n const lockedParamPercent = locksPrefilled\n ? parameters.lockedParamPercent\n : lockedParamsQuery.data\n ? {\n // The resolver skips its fetch only when all four fields are present —\n // mirror its `\"0\"` defaults for fields the solver omits.\n cva: lockedParamsQuery.data.cva ?? \"0\",\n lf: lockedParamsQuery.data.lf ?? \"0\",\n partyAmm: lockedParamsQuery.data.partyAmm ?? \"0\",\n partyBmm: lockedParamsQuery.data.partyBmm ?? \"0\",\n }\n : undefined;\n const lockedParamsReady = !needsLockedParams || lockedParamPercent !== undefined;\n\n // Static solver fees follow the same cached input path as the other prefills.\n // A failed optional /info read keeps core's existing zero-static-fee fallback.\n const solverInfoQuery = useSolverInfo({\n config: parameters.config,\n chainId,\n solverId,\n query: { enabled: enabled && isLowcap && parameters.solverInfo === undefined, staleTime: 300_000, retry: false },\n });\n const solverInfo = parameters.solverInfo ?? solverInfoQuery.data ?? (solverInfoQuery.isError ? {} : undefined);\n const solverInfoReady = !isLowcap || solverInfo !== undefined;\n\n // On-chain platform fee rates — contract state, changes rarely; cached hard.\n const feeQuery = useFeeForUser({\n config: parameters.config,\n chainId,\n user: subAccountAddress,\n symbolId: BigInt(market.id),\n query: { enabled: enabled && parameters.feeRates === undefined, staleTime: 300_000 },\n });\n const feeRates = parameters.feeRates ?? feeQuery.data;\n\n // Mark price — caller's cache-hot value wins; otherwise the shared stream.\n const priceQuery = usePriceByName({\n name: marketName,\n solverId,\n enabled: enabled && parameters.markPrice === undefined,\n });\n const markPrice = parameters.markPrice ?? priceQuery.markPrice ?? undefined;\n\n // Lowcap dry-run estimate: mark-sized quantity, wide fixed request bound so the\n // solver's price gate never rejects the question. Debounced internally.\n const estimateQuantity = useMemo(() => {\n if (!enabled || !isLowcap || markPrice === undefined) return \"\";\n if (pricePrecision === undefined || quantityPrecision === undefined) return \"\";\n const sized = calculateTradeParams({\n markPrice,\n slippage: 0,\n positionType,\n userInput: sizingInput,\n inputField: \"PRICE\",\n leverage,\n pricePrecision,\n quantityPrecision,\n });\n return sized?.quantity ?? \"\";\n }, [enabled, isLowcap, markPrice, pricePrecision, quantityPrecision, positionType, sizingInput, leverage]);\n const estimateRequestPrice =\n markPrice !== undefined ? String(Number(markPrice) * (positionType === PositionType.SHORT ? 0.5 : 1.5)) : \"\";\n const estimateQuery = useEstimatedPrice({\n config: parameters.config,\n chainId,\n solverId,\n symbolId: market.id,\n quantity: estimateQuantity,\n positionType,\n entry: \"open\",\n price: estimateRequestPrice,\n query: {\n enabled: enabled && isLowcap && parameters.estimatedOpenPrice === undefined && estimateQuantity.length > 0,\n staleTime: 30_000,\n },\n });\n // undefined = pending, string = available, null = settled but unavailable.\n // Pass null through to core so a failed cached request is not fetched again.\n const estimateUpdating =\n isLowcap && parameters.estimatedOpenPrice === undefined && (estimateQuery.isDebouncing || estimateQuery.isFetching);\n const estimateSettled =\n !isLowcap ||\n parameters.estimatedOpenPrice !== undefined ||\n (!estimateUpdating && (estimateQuery.isFetched || estimateQuery.isError));\n const resolvedEstimate =\n parameters.estimatedOpenPrice !== undefined ? parameters.estimatedOpenPrice : estimateQuery.data?.estimatedPrice;\n const estimatedOpenPrice =\n !isLowcap || !estimateSettled ? undefined : resolvedEstimate && resolvedEstimate !== \"0\" ? resolvedEstimate : null;\n\n // Every prefill present → the query function is pure, zero fetches.\n const ready =\n enabled &&\n marketName !== undefined &&\n pricePrecision !== undefined &&\n quantityPrecision !== undefined &&\n feeRates !== undefined &&\n markPrice !== undefined &&\n lockedParamsReady &&\n (!isLowcap || (hedgerFeeOpen !== undefined && hedgerFeeClose !== undefined)) &&\n constraintsReady &&\n capsReady &&\n solverInfoReady &&\n estimateSettled;\n\n return {\n config,\n validationError,\n ready,\n prefills: {\n chainId,\n market: {\n id: market.id,\n name: marketName,\n pricePrecision,\n quantityPrecision,\n minOpenSolverFeeCap,\n minCloseSolverFeeCap,\n hedgerFeeOpen,\n hedgerFeeClose,\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold,\n hedgerFeeCloseStandardThreshold,\n minAcceptablePortionLf,\n minAcceptableQuoteValue,\n maxNotionalValue,\n minNotionalValue,\n maxQuantity,\n lotSize,\n },\n markPrice,\n feeRates,\n lockedParamPercent,\n solverInfo,\n estimatedOpenPrice,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,SAAgB,EACd,GACA,GACA,IAAe,IACf;CACA,IAAM,IAAS,GAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAChC,EAAE,sBAAmB,WAAQ,iBAAc,mBAAe,SAAM,aAAU,gBAAa,GACvF,IAAgB,MAAS,KAAA,GACzB,IAAqB,KAAiB,EAAW,qBAAqB,KAAA,GACtE,IAAoB,MAAY,aAAa,GAC7C,KAAqB,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stantOpenWithTpSlReturnType = UseMutationResult<UseInstantOpenW
39
39
  * `tempQuoteId`. Web layer just wires inputs; all mutation logic (both legs +
40
40
  * cache invalidation + confirming-slot write) lives in the SDK.
41
41
  *
42
+ * Funding follows the `PrepareInstantOpenParameters` one-of: a typed
43
+ * `initialMargin`, or `fund: { mode: "full-balance", balance }` (lowcap only)
44
+ * to deploy the whole balance. In full-balance mode the submitted quantity is
45
+ * the SDK-rescaled one — take the TP/SL `quantity` from `useInstantOpenFees`
46
+ * (its `quantity` field) rather than re-deriving it from the typed margin.
47
+ *
42
48
  * @example
43
49
  * ```tsx
44
50
  * const open = useInstantOpenWithTpSl();
@@ -1 +1 @@
1
- {"version":3,"file":"use-instant-open-with-tpsl.d.ts","sourceRoot":"","sources":["../../src/instant-layer/use-instant-open-with-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAMzE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,+BAAgC,SAAQ,4BAA4B;IACnF,IAAI,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;CAC5D;AAED,sEAAsE;AACtE,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,qBAAqB,CAAC;IACnC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,mFAAmF;IACnF,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC;AAED,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAA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AACrD,MAAM,MAAM,gCAAgC,GAAG,iBAAiB,CAC9D,0BAA0B,EAC1B,kBAAkB,EAClB,+BAA+B,CAChC,GAAG;IACF,+DAA+D;IAC/D,KAAK,EAAE,2BAA2B,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,GAAE,gCAAqC,GAChD,gCAAgC,CAqFlC"}