@symmio/trading-react 0.1.1 → 1.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 (221) hide show
  1. package/README.md +2 -2
  2. package/dist/account-layer/index.d.ts +28 -28
  3. package/dist/account-layer/index.js +29 -0
  4. package/dist/account-layer/use-account-balance-info.d.ts +16 -5
  5. package/dist/account-layer/use-account-balance-info.d.ts.map +1 -1
  6. package/dist/account-layer/use-account-balance-info.js +21 -9
  7. package/dist/account-layer/use-account-balance-info.js.map +1 -1
  8. package/dist/account-layer/use-account-balance-of.d.ts +16 -5
  9. package/dist/account-layer/use-account-balance-of.d.ts.map +1 -1
  10. package/dist/account-layer/use-account-balance-of.js +20 -9
  11. package/dist/account-layer/use-account-balance-of.js.map +1 -1
  12. package/dist/account-layer/use-add-margin.d.ts +2 -2
  13. package/dist/account-layer/use-allocate.d.ts +2 -2
  14. package/dist/account-layer/use-create-sub-accounts.d.ts +2 -2
  15. package/dist/account-layer/use-deallocate.d.ts +2 -2
  16. package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
  17. package/dist/account-layer/use-deposit-and-allocate.d.ts +2 -2
  18. package/dist/account-layer/use-deposit.d.ts +5 -3
  19. package/dist/account-layer/use-deposit.d.ts.map +1 -1
  20. package/dist/account-layer/use-deposit.js +17 -15
  21. package/dist/account-layer/use-deposit.js.map +1 -1
  22. package/dist/account-layer/use-edit-account-name.d.ts +2 -2
  23. package/dist/account-layer/use-predicted-next-virtual-account.d.ts +1 -1
  24. package/dist/account-layer/use-remove-margin.d.ts +2 -2
  25. package/dist/account-layer/use-simulate-add-margin.d.ts +1 -1
  26. package/dist/account-layer/use-simulate-allocate.d.ts +1 -1
  27. package/dist/account-layer/use-simulate-create-sub-accounts.d.ts +1 -1
  28. package/dist/account-layer/use-simulate-deallocate.d.ts +1 -1
  29. package/dist/account-layer/use-simulate-delete-sub-account.d.ts +1 -1
  30. package/dist/account-layer/use-simulate-deposit-and-allocate.d.ts +1 -1
  31. package/dist/account-layer/use-simulate-deposit.d.ts +1 -1
  32. package/dist/account-layer/use-simulate-edit-account-name.d.ts +1 -1
  33. package/dist/account-layer/use-simulate-remove-margin.d.ts +1 -1
  34. package/dist/account-layer/use-sub-account-virtual-nonce.d.ts +1 -1
  35. package/dist/account-layer/use-sub-account.d.ts +1 -1
  36. package/dist/account-layer/use-sub-accounts-count-of-user.d.ts +1 -1
  37. package/dist/account-layer/use-user-sub-accounts-addresses.d.ts +1 -1
  38. package/dist/account-layer/use-user-sub-accounts.d.ts +1 -1
  39. package/dist/account-layer/use-virtual-account.d.ts +1 -1
  40. package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.d.ts +1 -1
  41. package/dist/balance-history/index.d.ts +3 -3
  42. package/dist/balance-history/use-balance-history.d.ts +1 -1
  43. package/dist/balance-history/use-deposit-history.d.ts +1 -1
  44. package/dist/balance-history/use-withdraw-history.d.ts +1 -1
  45. package/dist/collateral/index.d.ts +4 -4
  46. package/dist/collateral/use-approve-collateral.d.ts +2 -2
  47. package/dist/collateral/use-collateral-allowance.d.ts +1 -1
  48. package/dist/collateral/use-collateral-balance.d.ts +1 -1
  49. package/dist/collateral/use-simulate-approve-collateral.d.ts +1 -1
  50. package/dist/error-codes/index.d.ts +2 -2
  51. package/dist/error-codes/use-solver-error-codes.d.ts +1 -1
  52. package/dist/error-codes/use-solver-error-message.d.ts +1 -1
  53. package/dist/errors/index.d.ts +3 -3
  54. package/dist/errors/index.js +3 -0
  55. package/dist/errors/normalize-symm-error.d.ts +1 -1
  56. package/dist/errors/symmio-request-error.d.ts +1 -1
  57. package/dist/estimated-price/index.d.ts +2 -0
  58. package/dist/estimated-price/index.d.ts.map +1 -0
  59. package/dist/estimated-price/use-debounced-value.d.ts +9 -0
  60. package/dist/estimated-price/use-debounced-value.d.ts.map +1 -0
  61. package/dist/estimated-price/use-debounced-value.js +18 -0
  62. package/dist/estimated-price/use-debounced-value.js.map +1 -0
  63. package/dist/estimated-price/use-estimated-price.d.ts +46 -0
  64. package/dist/estimated-price/use-estimated-price.d.ts.map +1 -0
  65. package/dist/estimated-price/use-estimated-price.js +31 -0
  66. package/dist/estimated-price/use-estimated-price.js.map +1 -0
  67. package/dist/fees/index.d.ts +1 -1
  68. package/dist/fees/index.js +2 -0
  69. package/dist/fees/use-fee-for-user.d.ts +1 -1
  70. package/dist/funding-info/index.d.ts +2 -0
  71. package/dist/funding-info/index.d.ts.map +1 -0
  72. package/dist/funding-info/use-funding-info.d.ts +25 -0
  73. package/dist/funding-info/use-funding-info.d.ts.map +1 -0
  74. package/dist/funding-info/use-funding-info.js +27 -0
  75. package/dist/funding-info/use-funding-info.js.map +1 -0
  76. package/dist/index.d.ts +45 -24
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +120 -113
  79. package/dist/instant-layer/index.d.ts +14 -13
  80. package/dist/instant-layer/index.d.ts.map +1 -1
  81. package/dist/instant-layer/index.js +15 -0
  82. package/dist/instant-layer/use-delegation-expiry.d.ts +1 -1
  83. package/dist/instant-layer/use-grant-delegation.d.ts +2 -2
  84. package/dist/instant-layer/use-instant-close-auto.d.ts +1 -1
  85. package/dist/instant-layer/use-instant-close-bulk-auto.d.ts +1 -1
  86. package/dist/instant-layer/use-instant-close-bulk.d.ts +1 -1
  87. package/dist/instant-layer/use-instant-close.d.ts +1 -1
  88. package/dist/instant-layer/use-instant-closes.d.ts +1 -1
  89. package/dist/instant-layer/use-instant-open-auto.d.ts +1 -1
  90. package/dist/instant-layer/use-instant-open-quote-id.d.ts +1 -1
  91. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts +55 -0
  92. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -0
  93. package/dist/instant-layer/use-instant-open-with-tpsl.js +64 -0
  94. package/dist/instant-layer/use-instant-open-with-tpsl.js.map +1 -0
  95. package/dist/instant-layer/use-instant-open.d.ts +1 -1
  96. package/dist/instant-layer/use-instant-opens.d.ts +1 -1
  97. package/dist/instant-layer/use-is-delegation-active.d.ts +1 -1
  98. package/dist/instant-layer/use-simulate-grant-delegation.d.ts +1 -1
  99. package/dist/locked-params/index.d.ts +1 -1
  100. package/dist/locked-params/use-locked-params.d.ts +1 -1
  101. package/dist/margin/index.d.ts +2 -0
  102. package/dist/margin/index.d.ts.map +1 -0
  103. package/dist/margin/use-available-instant-open-margin.d.ts +51 -0
  104. package/dist/margin/use-available-instant-open-margin.d.ts.map +1 -0
  105. package/dist/margin/use-available-instant-open-margin.js +66 -0
  106. package/dist/margin/use-available-instant-open-margin.js.map +1 -0
  107. package/dist/market-info/index.d.ts +2 -0
  108. package/dist/market-info/index.d.ts.map +1 -0
  109. package/dist/market-info/use-market-info.d.ts +28 -0
  110. package/dist/market-info/use-market-info.d.ts.map +1 -0
  111. package/dist/market-info/use-market-info.js +27 -0
  112. package/dist/market-info/use-market-info.js.map +1 -0
  113. package/dist/markets/index.d.ts +2 -2
  114. package/dist/markets/index.js +3 -0
  115. package/dist/markets/use-markets.d.ts +1 -1
  116. package/dist/markets/use-onchain-contract-markets.d.ts +1 -1
  117. package/dist/muon/index.d.ts +10 -10
  118. package/dist/muon/use-deallocate-upnl-sig.d.ts +1 -1
  119. package/dist/muon/use-muon-party-a-overview.d.ts +1 -1
  120. package/dist/muon/use-muon-price-range.d.ts +1 -1
  121. package/dist/muon/use-muon-price.d.ts +1 -1
  122. package/dist/muon/use-muon-settle-upnl.d.ts +1 -1
  123. package/dist/muon/use-muon-upnl-a-with-symbol-price.d.ts +1 -1
  124. package/dist/muon/use-muon-upnl-a.d.ts +1 -1
  125. package/dist/muon/use-muon-upnl-b.d.ts +1 -1
  126. package/dist/muon/use-muon-upnl-with-symbol-price.d.ts +1 -1
  127. package/dist/muon/use-muon-upnl.d.ts +1 -1
  128. package/dist/notifications/index.d.ts +1 -1
  129. package/dist/notifications/use-search-notifications.d.ts +1 -1
  130. package/dist/notional-cap/index.d.ts +3 -3
  131. package/dist/notional-cap/use-notional-cap-all.d.ts +1 -1
  132. package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts +1 -1
  133. package/dist/notional-cap/use-open-interest-by-symbol-id.d.ts +1 -1
  134. package/dist/price-service/index.d.ts +8 -8
  135. package/dist/price-service/index.js +9 -0
  136. package/dist/price-service/use-enigma-price-by-market-id.d.ts +1 -1
  137. package/dist/price-service/use-enigma-price-by-name.d.ts +1 -1
  138. package/dist/price-service/use-enigma-price-service-health.d.ts +1 -1
  139. package/dist/price-service/use-enigma-price-service-metadata.d.ts +1 -1
  140. package/dist/price-service/use-enigma-price-service-prices-by-addresses.d.ts +1 -1
  141. package/dist/price-service/use-enigma-price-service-prices-by-names.d.ts +1 -1
  142. package/dist/price-service/use-enigma-price-service-symbols-info.d.ts +1 -1
  143. package/dist/price-service/use-enigma-prices.d.ts +1 -1
  144. package/dist/provider/index.d.ts +3 -3
  145. package/dist/provider/index.js +4 -0
  146. package/dist/provider/symmio-provider.d.ts +14 -5
  147. package/dist/provider/symmio-provider.d.ts.map +1 -1
  148. package/dist/provider/symmio-provider.js +2 -2
  149. package/dist/provider/symmio-provider.js.map +1 -1
  150. package/dist/quotes/index.d.ts +15 -15
  151. package/dist/quotes/use-account-liquidation-price.d.ts +4 -7
  152. package/dist/quotes/use-account-liquidation-price.d.ts.map +1 -1
  153. package/dist/quotes/use-account-liquidation-price.js.map +1 -1
  154. package/dist/quotes/use-grouped-quotes.d.ts +1 -1
  155. package/dist/quotes/use-managed-quotes.d.ts +1 -1
  156. package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
  157. package/dist/quotes/use-managed-quotes.js +131 -128
  158. package/dist/quotes/use-managed-quotes.js.map +1 -1
  159. package/dist/quotes/use-party-a-open-positions.d.ts +4 -4
  160. package/dist/quotes/use-party-a-open-positions.js.map +1 -1
  161. package/dist/quotes/use-party-a-pending-quotes.d.ts +1 -1
  162. package/dist/quotes/use-quote-events-by-type.d.ts +1 -1
  163. package/dist/quotes/use-quote-funding.d.ts +1 -1
  164. package/dist/quotes/use-quote-history.d.ts +1 -1
  165. package/dist/quotes/use-quote-price-history.d.ts +1 -1
  166. package/dist/quotes/use-quote.d.ts +1 -1
  167. package/dist/quotes/use-quotes-funding.d.ts +1 -1
  168. package/dist/quotes/use-subgraph-query.d.ts +1 -1
  169. package/dist/tpsl/index.d.ts +8 -7
  170. package/dist/tpsl/index.d.ts.map +1 -1
  171. package/dist/tpsl/tpsl-store.d.ts +84 -0
  172. package/dist/tpsl/tpsl-store.d.ts.map +1 -0
  173. package/dist/tpsl/tpsl-store.js +154 -0
  174. package/dist/tpsl/tpsl-store.js.map +1 -0
  175. package/dist/tpsl/use-delete-quote-tpsl.d.ts +15 -0
  176. package/dist/tpsl/use-delete-quote-tpsl.d.ts.map +1 -0
  177. package/dist/tpsl/use-delete-quote-tpsl.js +31 -0
  178. package/dist/tpsl/use-delete-quote-tpsl.js.map +1 -0
  179. package/dist/tpsl/use-quote-tpsl.d.ts +19 -20
  180. package/dist/tpsl/use-quote-tpsl.d.ts.map +1 -1
  181. package/dist/tpsl/use-quote-tpsl.js +24 -53
  182. package/dist/tpsl/use-quote-tpsl.js.map +1 -1
  183. package/dist/tpsl/use-set-quote-tpsl.d.ts +11 -10
  184. package/dist/tpsl/use-set-quote-tpsl.d.ts.map +1 -1
  185. package/dist/tpsl/use-set-quote-tpsl.js +18 -22
  186. package/dist/tpsl/use-set-quote-tpsl.js.map +1 -1
  187. package/dist/tpsl/use-tpsl-config.d.ts +1 -1
  188. package/dist/tpsl/use-tpsl-signing-spec.d.ts +1 -1
  189. package/dist/tpsl/use-watch-tpsl-notifications.d.ts +1 -1
  190. package/dist/transactions/index.d.ts +3 -3
  191. package/dist/transactions/index.js +3 -0
  192. package/dist/transactions/resolve-write-result.d.ts +1 -1
  193. package/dist/transfers/index.d.ts +1 -1
  194. package/dist/transfers/use-transfer-history.d.ts +1 -1
  195. package/dist/utils/index.d.ts +1 -1
  196. package/dist/wallet/index.d.ts +4 -4
  197. package/dist/wallet/index.js +5 -0
  198. package/dist/wallet/use-connect-wallet.d.ts +1 -1
  199. package/dist/wallet/use-switch-to-symmio-chain.d.ts +1 -1
  200. package/dist/websocket/index.d.ts +1 -1
  201. package/dist/websocket/is-settle-notification.d.ts +15 -0
  202. package/dist/websocket/is-settle-notification.d.ts.map +1 -0
  203. package/dist/websocket/is-settle-notification.js +15 -0
  204. package/dist/websocket/is-settle-notification.js.map +1 -0
  205. package/dist/websocket/use-notifications.d.ts +1 -1
  206. package/dist/withdraw/index.d.ts +10 -10
  207. package/dist/withdraw/use-finalize-withdraw-request.d.ts +2 -2
  208. package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
  209. package/dist/withdraw/use-last-withdraw-request-id.d.ts +1 -1
  210. package/dist/withdraw/use-pending-withdraw-requests.d.ts +1 -1
  211. package/dist/withdraw/use-request-cancel-withdraw.d.ts +2 -2
  212. package/dist/withdraw/use-simulate-finalize-withdraw-request.d.ts +1 -1
  213. package/dist/withdraw/use-simulate-initiate-withdraw.d.ts +1 -1
  214. package/dist/withdraw/use-simulate-request-cancel-withdraw.d.ts +1 -1
  215. package/dist/withdraw/use-withdraw-requests.d.ts +1 -1
  216. package/dist/withdraw/use-withdrawable-time.d.ts +1 -1
  217. package/package.json +11 -10
  218. package/dist/tpsl/tpsl-confirming.d.ts +0 -36
  219. package/dist/tpsl/tpsl-confirming.d.ts.map +0 -1
  220. package/dist/tpsl/tpsl-confirming.js +0 -28
  221. package/dist/tpsl/tpsl-confirming.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteTpSlQueryKey,\n getQuoteTpSlQueryOptions,\n type ConfigParameter,\n type GetQuoteTpSlOptions,\n type QuoteTpSl,\n type QuoteTpSlRow,\n type TpSlNotification,\n} from \"@symmio/trading-core\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useEffect, useMemo } from \"react\";\nimport type { Address } 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 { toQuoteTpSl } from \"./to-quote-tpsl\";\nimport {\n clearTpSlConfirmingSide,\n EMPTY_TPSL_CONFIRMING,\n getTpSlConfirmingQueryKey,\n type TpSlConfirming,\n} from \"./tpsl-confirming\";\nimport { useWatchTpSlNotifications } from \"./use-watch-tpsl-notifications\";\n\n/** Parameters for {@link useQuoteTpSl}. */\nexport type UseQuoteTpSlParameters = GetQuoteTpSlOptions &\n ConfigParameter & {\n /**\n * SubAccount address — when provided, the hook also subscribes to the\n * TP/SL WebSocket and reconciles the snapshot (`confirming` → `new`)\n * without manual polling. Omit to skip WS (REST-only).\n */\n account?: Address;\n };\n\n/** Return type of {@link useQuoteTpSl}. */\nexport type UseQuoteTpSlReturnType = UseQueryResult<QuoteTpSl, SymmioRequestError> & {\n /** The unfiltered conditional-order rows returned by the handler. */\n rows: QuoteTpSlRow[] | undefined;\n};\n\n/**\n * Read the TP/SL snapshot for one on-chain quote.\n *\n * The query caches the **raw handler rows** (every state — `pending` / `new` /\n * `triggered` / `canceled` / `killed`); the hook returns a folded\n * {@link QuoteTpSl} via {@link toQuoteTpSl}.\n *\n * State machine — when a POST just landed (via\n * {@link useSetQuoteTpSl}) the shared \"confirming\" slot is set for the\n * submitted sides; this hook overlays `tpState` / `slState = \"confirming\"`\n * until a matching WebSocket `report` arrives with `successful: true`. On\n * that report the slot is cleared and the rows query is invalidated, so the\n * fresh snapshot flips the side to `new` (active).\n */\nexport function useQuoteTpSl(parameters: UseQuoteTpSlParameters): UseQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const defaultChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? defaultChainId;\n const queryClient = useQueryClient();\n const configKey = config.getChainConfigKey(chainId);\n\n const options = getQuoteTpSlQueryOptions(config, { ...parameters, chainId });\n const queryResult = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n });\n\n const rowsKey = getQuoteTpSlQueryKey({ ...parameters, chainId, configKey });\n const confirmingKey = getTpSlConfirmingQueryKey({ chainId, quoteId: parameters.quoteId, configKey });\n\n const confirmingQuery = useQuery<TpSlConfirming>({\n queryKey: confirmingKey,\n queryFn: () => queryClient.getQueryData<TpSlConfirming>(confirmingKey) ?? EMPTY_TPSL_CONFIRMING,\n initialData: EMPTY_TPSL_CONFIRMING,\n staleTime: Infinity,\n gcTime: Infinity,\n });\n const confirming = confirmingQuery.data ?? EMPTY_TPSL_CONFIRMING;\n\n const folded = useMemo(() => {\n if (!queryResult.data) return undefined;\n const snapshot = toQuoteTpSl(queryResult.data);\n return applyConfirmingOverlay(snapshot, confirming);\n }, [queryResult.data, confirming]);\n\n const wsAccount = parameters.account;\n const matchQuoteId = parameters.quoteId;\n const rowsKeySerialized = JSON.stringify(rowsKey);\n\n useWatchTpSlNotifications({\n account: wsAccount,\n enabled: Boolean(wsAccount) && matchQuoteId > 0n,\n onNotification: (notification) => {\n if (!matchesQuote(notification, matchQuoteId)) return;\n if (notification.successful) {\n const side =\n notification.conditionalOrderType === \"take_profit\"\n ? \"tp\"\n : notification.conditionalOrderType === \"stop_loss\"\n ? \"sl\"\n : null;\n if (side && (notification.state === \"new\" || notification.state === \"edit\")) {\n clearTpSlConfirmingSide(queryClient, confirmingKey, side);\n }\n }\n void queryClient.invalidateQueries({ queryKey: rowsKey });\n },\n });\n\n useEffect(() => {\n void rowsKeySerialized;\n }, [rowsKeySerialized]);\n\n const result = { ...queryResult, data: folded, rows: queryResult.data } as unknown as UseQuoteTpSlReturnType;\n return result;\n}\n\nfunction matchesQuote(notification: TpSlNotification, quoteId: bigint): boolean {\n return notification.quoteId === Number(quoteId);\n}\n\n/**\n * If a side is awaiting WS confirmation, override its state to `confirming`\n * (the row snapshot may or may not have caught up yet — either way, \"await\n * WS\" takes precedence over what the REST rows report).\n */\nfunction applyConfirmingOverlay(snapshot: QuoteTpSl, confirming: TpSlConfirming): QuoteTpSl {\n if (!confirming.tp && !confirming.sl) return snapshot;\n return {\n ...snapshot,\n tpState: confirming.tp ? \"confirming\" : snapshot.tpState,\n slState: confirming.sl ? \"confirming\" : snapshot.slState,\n };\n}\n"],"mappings":";;;;;;;;;;;AA0DA,SAAgB,EAAa,GAA4D;CACvF,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAChC,IAAc,EAAe,GAC7B,IAAY,EAAO,kBAAkB,CAAO,GAE5C,IAAU,EAAyB,GAAQ;EAAE,GAAG;EAAY;CAAQ,CAAC,GACrE,IAAc,EAAS;EAC3B,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC,GAEK,IAAU,EAAqB;EAAE,GAAG;EAAY;EAAS;CAAU,CAAC,GACpE,IAAgB,EAA0B;EAAE;EAAS,SAAS,EAAW;EAAS;CAAU,CAAC,GAS7F,IAPkB,EAAyB;EAC/C,UAAU;EACV,eAAe,EAAY,aAA6B,CAAa,KAAK;EAC1E,aAAa;EACb,WAAW;EACX,QAAQ;CACV,CACmB,EAAgB,QAAQ,GAErC,IAAS,QAAc;EACtB,MAAY,MAEjB,OAAO,EADU,EAAY,EAAY,IACX,GAAU,CAAU;CACpD,GAAG,CAAC,EAAY,MAAM,CAAU,CAAC,GAE3B,IAAY,EAAW,SACvB,IAAe,EAAW,SAC1B,IAAoB,KAAK,UAAU,CAAO;CA2BhD,OAzBA,EAA0B;EACxB,SAAS;EACT,SAAS,EAAQ,KAAc,IAAe;EAC9C,iBAAiB,MAAiB;GAC3B,MAAa,GAAc,CAAY,GAC5C;QAAI,EAAa,YAAY;KAC3B,IAAM,IACJ,EAAa,yBAAyB,gBAClC,OACA,EAAa,yBAAyB,cACpC,OACA;KACR,AAAI,MAAS,EAAa,UAAU,SAAS,EAAa,UAAU,WAClE,EAAwB,GAAa,GAAe,CAAI;IAE5D;IACA,EAAiB,kBAAkB,EAAE,UAAU,EAAQ,CAAC;GADxD;EAEF;CACF,CAAC,GAED,QAAgB,CAEhB,GAAG,CAAC,CAAiB,CAAC,GAGf;EADU,GAAG;EAAa,MAAM;EAAQ,MAAM,EAAY;CAC1D;AACT;AAEA,SAAS,EAAa,GAAgC,GAA0B;CAC9E,OAAO,EAAa,YAAY,OAAO,CAAO;AAChD;AAOA,SAAS,EAAuB,GAAqB,GAAuC;CAE1F,OADI,CAAC,EAAW,MAAM,CAAC,EAAW,KAAW,IACtC;EACL,GAAG;EACH,SAAS,EAAW,KAAK,eAAe,EAAS;EACjD,SAAS,EAAW,KAAK,eAAe,EAAS;CACnD;AACF"}
1
+ {"version":3,"file":"use-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteTpSlQueryOptions,\n type ConfigParameter,\n type GetQuoteTpSlOptions,\n type TpSlNotification,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport type { Address } 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 { useTpSlRecord, useTpSlStore, type TpSlRecord } from \"./tpsl-store\";\nimport { useWatchTpSlNotifications } from \"./use-watch-tpsl-notifications\";\n\n/** Parameters for {@link useQuoteTpSl}. */\nexport type UseQuoteTpSlParameters = Omit<GetQuoteTpSlOptions, \"quoteId\"> &\n ConfigParameter & {\n /**\n * Quote id — accepts either the on-chain `quoteId` or the hedger\n * `tempQuoteId`. Whichever is passed, the hook resolves to the same\n * shared record via the store's id index.\n */\n quoteId: bigint;\n /**\n * SubAccount address — when provided, the hook also subscribes to the\n * TP/SL WebSocket and reconciles the record without manual polling.\n */\n account?: Address;\n };\n\n/** Return type of {@link useQuoteTpSl}. */\nexport type UseQuoteTpSlReturnType = UseQueryResult<TpSlRecord, SymmioRequestError>;\n\n/**\n * Read the folded TP/SL snapshot for one quote. Pass either the on-chain\n * `quoteId` or the hedger `tempQuoteId` — the store keeps a single record per\n * quote indexed under every id it has learned for that quote, so both callers\n * get the same object.\n *\n * The `confirming` overlay (\"POST accepted, awaiting handler\") is merged into\n * `tpState` / `slState` at read time — a side flagged as confirming reports\n * state `\"confirming\"` regardless of what the row set says.\n */\nexport function useQuoteTpSl(parameters: UseQuoteTpSlParameters): UseQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const defaultChainId = useSymmioChainId();\n const chainId = parameters.chainId ?? defaultChainId;\n\n const record = useTpSlRecord(parameters.quoteId);\n const options = getQuoteTpSlQueryOptions(config, {\n ...parameters,\n chainId,\n quoteId: parameters.quoteId,\n });\n // Re-fetch is driven by TanStack Query cache: mutations invalidate `rowsKey`,\n // which triggers a refetch here so the store record picks up the newly\n // committed tp/sl values. (An earlier version gated on `record === undefined`\n // to avoid a duplicate fetch when the on-chain quoteId first appeared, but\n // that also swallowed post-mutation invalidations — leaving the box stuck on\n // the old values.)\n const queryResult = useQuery({\n ...options,\n queryFn: async () => {\n try {\n const rows = await options.queryFn();\n useTpSlStore.getState().setRows(parameters.quoteId, rows);\n return rows;\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n });\n\n useWatchTpSlNotifications({\n account: parameters.account,\n enabled: Boolean(parameters.account) && parameters.quoteId !== 0n,\n onNotification: (notification) => {\n if (notification.primaryIdentifier !== 0 && notification.secondaryIdentifier !== 0) {\n useTpSlStore.getState().link(BigInt(notification.primaryIdentifier), BigInt(notification.secondaryIdentifier));\n }\n if (!matchesQuote(notification, parameters.quoteId)) return;\n useTpSlStore.getState().applyNotification(parameters.quoteId, notification);\n },\n });\n\n return {\n query: queryResult,\n data: record,\n } as unknown as UseQuoteTpSlReturnType;\n}\n\n/**\n * True when the notification and the caller address the same store record.\n * Uses the store's id index — every id linked to the same record maps to\n * the same object, so reference equality decides the match.\n */\nfunction matchesQuote(notification: TpSlNotification, quoteId: bigint): boolean {\n const store = useTpSlStore.getState();\n const target = store.get(quoteId);\n if (!target) {\n // No record yet for the target — fall back to raw-id compare so the\n // first \"seed\" frame still matches.\n return (\n notification.primaryIdentifier === Number(quoteId) ||\n notification.secondaryIdentifier === Number(quoteId) ||\n notification.quoteId === Number(quoteId)\n );\n }\n if (notification.primaryIdentifier !== 0 && store.get(BigInt(notification.primaryIdentifier)) === target) return true;\n if (notification.secondaryIdentifier !== 0 && store.get(BigInt(notification.secondaryIdentifier)) === target)\n return true;\n return false;\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAgB,EAAa,GAA4D;CACvF,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAiB,EAAiB,GAClC,IAAU,EAAW,WAAW,GAEhC,IAAS,EAAc,EAAW,OAAO,GACzC,IAAU,EAAyB,GAAQ;EAC/C,GAAG;EACH;EACA,SAAS,EAAW;CACtB,CAAC,GAOK,IAAc,EAAS;EAC3B,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,IAAM,IAAO,MAAM,EAAQ,QAAQ;IAEnC,OADA,EAAa,SAAS,EAAE,QAAQ,EAAW,SAAS,CAAI,GACjD;GACT,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAcD,OAZA,EAA0B;EACxB,SAAS,EAAW;EACpB,SAAS,EAAQ,EAAW,WAAY,EAAW,YAAY;EAC/D,iBAAiB,MAAiB;GAChC,AAAI,EAAa,sBAAsB,KAAK,EAAa,wBAAwB,KAC/E,EAAa,SAAS,EAAE,KAAK,OAAO,EAAa,iBAAiB,GAAG,OAAO,EAAa,mBAAmB,CAAC,GAE1G,EAAa,GAAc,EAAW,OAAO,KAClD,EAAa,SAAS,EAAE,kBAAkB,EAAW,SAAS,CAAY;EAC5E;CACF,CAAC,GAEM;EACL,OAAO;EACP,MAAM;CACR;AACF;AAOA,SAAS,EAAa,GAAgC,GAA0B;CAC9E,IAAM,IAAQ,EAAa,SAAS,GAC9B,IAAS,EAAM,IAAI,CAAO;CAahC,OAZK,IASD,EAAa,sBAAsB,KAAK,EAAM,IAAI,OAAO,EAAa,iBAAiB,CAAC,MAAM,KAC9F,EAAa,wBAAwB,KAAK,EAAM,IAAI,OAAO,EAAa,mBAAmB,CAAC,MAAM,IANlG,EAAa,sBAAsB,OAAO,CAAO,KACjD,EAAa,wBAAwB,OAAO,CAAO,KACnD,EAAa,YAAY,OAAO,CAAO;AAO7C"}
@@ -1,22 +1,23 @@
1
1
  import { ConfigParameter, SetQuoteTpSlParameters, SetQuoteTpSlReturnType } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /** Parameters for {@link useSetQuoteTpSl}. */
5
5
  export type UseSetQuoteTpSlParameters = ConfigParameter;
6
6
  /** Return type of {@link useSetQuoteTpSl}. */
7
7
  export type UseSetQuoteTpSlReturnType = UseMutationResult<SetQuoteTpSlReturnType, SymmioRequestError, SetQuoteTpSlParameters>;
8
8
  /**
9
- * Submit a TP/SL order for one on-chain quote. Signs an EIP-712 message with
10
- * the session-key wallet and posts to the handler.
9
+ * Submit a TP/SL order for one quote. Signs an EIP-712 message with the
10
+ * session-key wallet and POSTs to the handler.
11
11
  *
12
12
  * State machine (per side):
13
- * 1. `pending` — POST in flight (`mutation.isPending`).
14
- * 2. `confirming` — POST returned 200; we've written the flag into the shared
15
- * confirming cache slot ({@link getTpSlConfirmingQueryKey}). `useQuoteTpSl`
16
- * overlays this as `tpState` / `slState = "confirming"`.
17
- * 3. `new` — Handler broadcast a `report` with `successful: true`;
18
- * `useQuoteTpSl`'s WS listener clears the confirming flag and invalidates
19
- * the row query, so the fresh snapshot flips the side to active.
13
+ * 1. `pending` — POST in flight (`mutation.isPending`).
14
+ * 2. `confirming` — POST returned 200; the store's `markConfirming` sets
15
+ * `tp/slState` to `"confirming"` and seeds the target trigger price so
16
+ * the UI can render it immediately.
17
+ * 3. `new` — Handler broadcast a `report` with `successful: true`;
18
+ * `useQuoteTpSl`'s WS listener runs `applyNotification`, which flips the
19
+ * side into its wire-reported state and confirms the trigger price from
20
+ * `details.trigger_price`. No REST refetch — the store is authoritative.
20
21
  */
21
22
  export declare function useSetQuoteTpSl(parameters?: UseSetQuoteTpSlParameters): UseSetQuoteTpSlReturnType;
22
23
  //# sourceMappingURL=use-set-quote-tpsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-set-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAExD,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CACvD,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAE,yBAA8B,GAAG,yBAAyB,CA+BrG"}
1
+ {"version":3,"file":"use-set-quote-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAExD,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,CACvD,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,CACvB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,GAAE,yBAA8B,GAAG,yBAAyB,CAgCrG"}
@@ -2,42 +2,38 @@
2
2
  import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
3
  import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
4
  import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
- import { getTpSlConfirmingQueryKey as r, markTpSlConfirming as i } from "./tpsl-confirming.js";
6
- import { getQuoteTpSlQueryKey as a, setQuoteTpSlMutationOptions as o } from "@symmio/trading-core";
7
- import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
5
+ import { useTpSlStore as r } from "./tpsl-store.js";
6
+ import { setQuoteTpSlMutationOptions as i } from "@symmio/trading-core";
7
+ import { useMutation as a } from "@tanstack/react-query";
8
8
  //#region src/tpsl/use-set-quote-tpsl.ts
9
- function l(l = {}) {
10
- let u = t(l), d = e(), f = c(), p = o(u);
11
- return s({
12
- mutationKey: p.mutationKey,
9
+ function o(o = {}) {
10
+ let s = t(o), c = e(), l = i(s), u = r((e) => e.markConfirming);
11
+ return a({
12
+ mutationKey: l.mutationKey,
13
13
  mutationFn: async (e) => {
14
14
  try {
15
- return await p.mutationFn({
15
+ return await l.mutationFn({
16
16
  ...e,
17
- chainId: e.chainId ?? d
17
+ chainId: e.chainId ?? c
18
18
  });
19
19
  } catch (e) {
20
20
  throw n(e);
21
21
  }
22
22
  },
23
23
  onSuccess: (e, t) => {
24
- let n = t.chainId ?? d, o = u.getChainConfigKey(n), s = a({
25
- chainId: n,
26
- quoteId: t.quoteId,
27
- configKey: o
24
+ t.tp && u(t.quoteId, "tp", {
25
+ price: t.tp.triggerPrice,
26
+ priceType: t.tp.priceType,
27
+ cohQuoteId: e.cohQuoteId
28
+ }), t.sl && u(t.quoteId, "sl", {
29
+ price: t.sl.triggerPrice,
30
+ priceType: t.sl.priceType,
31
+ cohQuoteId: e.cohQuoteId
28
32
  });
29
- i(f, r({
30
- chainId: n,
31
- quoteId: t.quoteId,
32
- configKey: o
33
- }), {
34
- tp: !!t.tp,
35
- sl: !!t.sl
36
- }), f.invalidateQueries({ queryKey: s });
37
33
  }
38
34
  });
39
35
  }
40
36
  //#endregion
41
- export { l as useSetQuoteTpSl };
37
+ export { o as useSetQuoteTpSl };
42
38
 
43
39
  //# sourceMappingURL=use-set-quote-tpsl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-set-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteTpSlQueryKey,\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\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 { getTpSlConfirmingQueryKey, markTpSlConfirming } from \"./tpsl-confirming\";\n\n/** Parameters for {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlReturnType = UseMutationResult<\n SetQuoteTpSlReturnType,\n SymmioRequestError,\n SetQuoteTpSlParameters\n>;\n\n/**\n * Submit a TP/SL order for one on-chain quote. Signs an EIP-712 message with\n * the session-key wallet and posts to the handler.\n *\n * State machine (per side):\n * 1. `pending` — POST in flight (`mutation.isPending`).\n * 2. `confirming` — POST returned 200; we've written the flag into the shared\n * confirming cache slot ({@link getTpSlConfirmingQueryKey}). `useQuoteTpSl`\n * overlays this as `tpState` / `slState = \"confirming\"`.\n * 3. `new` — Handler broadcast a `report` with `successful: true`;\n * `useQuoteTpSl`'s WS listener clears the confirming flag and invalidates\n * the row query, so the fresh snapshot flips the side to active.\n */\nexport function useSetQuoteTpSl(parameters: UseSetQuoteTpSlParameters = {}): UseSetQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const base = setQuoteTpSlMutationOptions(config);\n\n return useMutation<SetQuoteTpSlReturnType, SymmioRequestError, SetQuoteTpSlParameters>({\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 const resolvedChainId = variables.chainId ?? chainId;\n const configKey = config.getChainConfigKey(resolvedChainId);\n const rowsKey = getQuoteTpSlQueryKey({ chainId: resolvedChainId, quoteId: variables.quoteId, configKey });\n const confirmingKey = getTpSlConfirmingQueryKey({\n chainId: resolvedChainId,\n quoteId: variables.quoteId,\n configKey,\n });\n markTpSlConfirming(queryClient, confirmingKey, {\n tp: Boolean(variables.tp),\n sl: Boolean(variables.sl),\n });\n void queryClient.invalidateQueries({ queryKey: rowsKey });\n },\n });\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgB,EAAgB,IAAwC,CAAC,GAA8B;CACrG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAO,EAA4B,CAAM;CAE/C,OAAO,EAAgF;EACrF,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;GACjC,IAAM,IAAkB,EAAU,WAAW,GACvC,IAAY,EAAO,kBAAkB,CAAe,GACpD,IAAU,EAAqB;IAAE,SAAS;IAAiB,SAAS,EAAU;IAAS;GAAU,CAAC;GAUxG,AAJA,EAAmB,GALG,EAA0B;IAC9C,SAAS;IACT,SAAS,EAAU;IACnB;GACF,CACgC,GAAe;IAC7C,IAAI,EAAQ,EAAU;IACtB,IAAI,EAAQ,EAAU;GACxB,CAAC,GACD,EAAiB,kBAAkB,EAAE,UAAU,EAAQ,CAAC;EAC1D;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-set-quote-tpsl.js","names":[],"sources":["../../src/tpsl/use-set-quote-tpsl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n setQuoteTpSlMutationOptions,\n type ConfigParameter,\n type SetQuoteTpSlParameters,\n type SetQuoteTpSlReturnType,\n} from \"@symmio/trading-core\";\nimport { useMutation, 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 { useTpSlStore } from \"./tpsl-store\";\n\n/** Parameters for {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlParameters = ConfigParameter;\n\n/** Return type of {@link useSetQuoteTpSl}. */\nexport type UseSetQuoteTpSlReturnType = UseMutationResult<\n SetQuoteTpSlReturnType,\n SymmioRequestError,\n SetQuoteTpSlParameters\n>;\n\n/**\n * Submit a TP/SL order for one quote. Signs an EIP-712 message with the\n * session-key wallet and POSTs to the handler.\n *\n * State machine (per side):\n * 1. `pending` — POST in flight (`mutation.isPending`).\n * 2. `confirming` — POST returned 200; the store's `markConfirming` sets\n * `tp/slState` to `\"confirming\"` and seeds the target trigger price so\n * the UI can render it immediately.\n * 3. `new` — Handler broadcast a `report` with `successful: true`;\n * `useQuoteTpSl`'s WS listener runs `applyNotification`, which flips the\n * side into its wire-reported state and confirms the trigger price from\n * `details.trigger_price`. No REST refetch — the store is authoritative.\n */\nexport function useSetQuoteTpSl(parameters: UseSetQuoteTpSlParameters = {}): UseSetQuoteTpSlReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const base = setQuoteTpSlMutationOptions(config);\n const markConfirming = useTpSlStore((state) => state.markConfirming);\n\n return useMutation<SetQuoteTpSlReturnType, SymmioRequestError, SetQuoteTpSlParameters>({\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 if (variables.tp) {\n markConfirming(variables.quoteId, \"tp\", {\n price: variables.tp.triggerPrice,\n priceType: variables.tp.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n if (variables.sl) {\n markConfirming(variables.quoteId, \"sl\", {\n price: variables.sl.triggerPrice,\n priceType: variables.sl.priceType,\n cohQuoteId: result.cohQuoteId,\n });\n }\n },\n });\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgB,EAAgB,IAAwC,CAAC,GAA8B;CACrG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAO,EAA4B,CAAM,GACzC,IAAiB,GAAc,MAAU,EAAM,cAAc;CAEnE,OAAO,EAAgF;EACrF,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,GAAQ,MAAc;GAQhC,AAPI,EAAU,MACZ,EAAe,EAAU,SAAS,MAAM;IACtC,OAAO,EAAU,GAAG;IACpB,WAAW,EAAU,GAAG;IACxB,YAAY,EAAO;GACrB,CAAC,GAEC,EAAU,MACZ,EAAe,EAAU,SAAS,MAAM;IACtC,OAAO,EAAU,GAAG;IACpB,WAAW,EAAU,GAAG;IACxB,YAAY,EAAO;GACrB,CAAC;EAEL;CACF,CAAC;AACH"}
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetTpSlConfigOptions, GetTpSlConfigReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /** Parameters for {@link useTpSlConfig}. */
5
5
  export type UseTpSlConfigParameters = GetTpSlConfigOptions & ConfigParameter;
6
6
  /** Return type of {@link useTpSlConfig}. */
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetTpSlSigningSpecOptions, GetTpSlSigningSpecReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /** Parameters for {@link useTpSlSigningSpec}. */
5
5
  export type UseTpSlSigningSpecParameters = GetTpSlSigningSpecOptions & ConfigParameter;
6
6
  /** Return type of {@link useTpSlSigningSpec}. */
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, SocketStatus, TpSlNotification } from '@symmio/trading-core';
2
2
  import { Address } from 'viem';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useWatchTpSlNotifications}.
6
6
  */
@@ -1,4 +1,4 @@
1
- export * from './resolve-write-result';
2
- export * from './use-transactions-store';
3
- export * from './write-types';
1
+ export * from './resolve-write-result.js';
2
+ export * from './use-transactions-store.js';
3
+ export * from './write-types.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { resolveWriteResult as e } from "./resolve-write-result.js";
2
+ import { useTransactionsStore as t } from "./use-transactions-store.js";
3
+ export { e as resolveWriteResult, t as useTransactionsStore };
@@ -1,6 +1,6 @@
1
1
  import { Config } from '@symmio/trading-core';
2
2
  import { Hash } from 'viem';
3
- import { WriteResult } from './write-types';
3
+ import { WriteResult } from './write-types.js';
4
4
  /**
5
5
  * Options for {@link resolveWriteResult}.
6
6
  */
@@ -1,2 +1,2 @@
1
- export * from './use-transfer-history';
1
+ export * from './use-transfer-history.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetTransferHistoryOptions, GetTransferHistoryReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useTransferHistory}: the core query options (accounts,
6
6
  * direction, paging, time range, chain id, TanStack `query` overrides) plus an
@@ -1,2 +1,2 @@
1
- export { predicateMatch } from './predicate-match';
1
+ export { predicateMatch } from './predicate-match.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- export * from './use-connect-wallet';
2
- export * from './use-disconnect-wallet';
3
- export * from './use-switch-to-symmio-chain';
4
- export * from './use-wallet-account';
1
+ export * from './use-connect-wallet.js';
2
+ export * from './use-disconnect-wallet.js';
3
+ export * from './use-switch-to-symmio-chain.js';
4
+ export * from './use-wallet-account.js';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { useConnectWallet as e } from "./use-connect-wallet.js";
2
+ import { useDisconnectWallet as t } from "./use-disconnect-wallet.js";
3
+ import { useSwitchToSymmioChain as n } from "./use-switch-to-symmio-chain.js";
4
+ import { useWalletAccount as r } from "./use-wallet-account.js";
5
+ export { e as useConnectWallet, t as useDisconnectWallet, n as useSwitchToSymmioChain, r as useWalletAccount };
@@ -1,5 +1,5 @@
1
1
  import { Connector } from 'wagmi';
2
- import { SymmioRequestError } from '../errors/symmio-request-error';
2
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
3
3
  /**
4
4
  * Result shape returned by {@link useConnectWallet}.
5
5
  */
@@ -1,4 +1,4 @@
1
- import { SymmioRequestError } from '../errors/symmio-request-error';
1
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
2
2
  /**
3
3
  * Result shape returned by {@link useSwitchToSymmioChain}.
4
4
  */
@@ -1,2 +1,2 @@
1
- export { useNotifications, type UseNotificationsParameters, type UseNotificationsReturnType, } from './use-notifications';
1
+ export { useNotifications, type UseNotificationsParameters, type UseNotificationsReturnType, } from './use-notifications.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Notification } from '@symmio/trading-core';
2
+ /**
3
+ * `true` when a notification marks an on-chain settle — a `SUCCESS` frame whose
4
+ * `lastSeenAction` is an open-anchor or close-fill. Live balance reads refetch
5
+ * on exactly these.
6
+ */
7
+ export declare function isSettleNotification(notification: Notification): boolean;
8
+ /**
9
+ * Delays (ms) at which a live balance read refetches after a settle
10
+ * notification. The on-chain read lags the anchor block, so a single immediate
11
+ * read often returns the pre-settle value; a short spaced burst lets the updated
12
+ * balance land without a manual refresh.
13
+ */
14
+ export declare const SETTLE_REFETCH_DELAYS_MS: readonly [0, 2000, 5000];
15
+ //# sourceMappingURL=is-settle-notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-settle-notification.d.ts","sourceRoot":"","sources":["../../src/websocket/is-settle-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAU3E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAMxE;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,0BAA2B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { NotificationType as e } from "@symmio/trading-core";
2
+ //#region src/websocket/is-settle-notification.ts
3
+ var t = new Set(["SendQuoteTransaction", "FillMarketOrderInstantClose"]);
4
+ function n(n) {
5
+ return n.type === e.SUCCESS && n.lastSeenAction !== null && t.has(n.lastSeenAction);
6
+ }
7
+ var r = [
8
+ 0,
9
+ 2e3,
10
+ 5e3
11
+ ];
12
+ //#endregion
13
+ export { r as SETTLE_REFETCH_DELAYS_MS, n as isSettleNotification };
14
+
15
+ //# sourceMappingURL=is-settle-notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-settle-notification.js","names":[],"sources":["../../src/websocket/is-settle-notification.ts"],"sourcesContent":["import { NotificationType, type Notification } from \"@symmio/trading-core\";\n\n/**\n * Solver actions that mean a position settled on-chain — an open anchored\n * (margin locked) or a close filled (PnL realized, margin unlocked). These are\n * the frames that move a subaccount's balance; the earlier request / price-fill\n * frames do not. Mirrors core's `OPEN_ANCHOR_ACTIONS` ∪ `CLOSE_FILL_ACTIONS`.\n */\nconst SETTLE_ACTIONS = new Set<string>([\"SendQuoteTransaction\", \"FillMarketOrderInstantClose\"]);\n\n/**\n * `true` when a notification marks an on-chain settle — a `SUCCESS` frame whose\n * `lastSeenAction` is an open-anchor or close-fill. Live balance reads refetch\n * on exactly these.\n */\nexport function isSettleNotification(notification: Notification): boolean {\n return (\n notification.type === NotificationType.SUCCESS &&\n notification.lastSeenAction !== null &&\n SETTLE_ACTIONS.has(notification.lastSeenAction)\n );\n}\n\n/**\n * Delays (ms) at which a live balance read refetches after a settle\n * notification. The on-chain read lags the anchor block, so a single immediate\n * read often returns the pre-settle value; a short spaced burst lets the updated\n * balance land without a manual refresh.\n */\nexport const SETTLE_REFETCH_DELAYS_MS = [0, 2000, 5000] as const;\n"],"mappings":";;AAQA,IAAM,IAAiB,IAAI,IAAY,CAAC,wBAAwB,6BAA6B,CAAC;AAO9F,SAAgB,EAAqB,GAAqC;CACxE,OACE,EAAa,SAAS,EAAiB,WACvC,EAAa,mBAAmB,QAChC,EAAe,IAAI,EAAa,cAAc;AAElD;AAQA,IAAa,IAA2B;CAAC;CAAG;CAAM;AAAI"}
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, Notification, SocketStatus } from '@symmio/trading-core';
2
2
  import { Address } from 'viem';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useNotifications}.
6
6
  */
@@ -1,11 +1,11 @@
1
- export * from './use-finalize-withdraw-request';
2
- export * from './use-initiate-withdraw';
3
- export * from './use-last-withdraw-request-id';
4
- export * from './use-pending-withdraw-requests';
5
- export * from './use-request-cancel-withdraw';
6
- export * from './use-simulate-finalize-withdraw-request';
7
- export * from './use-simulate-initiate-withdraw';
8
- export * from './use-simulate-request-cancel-withdraw';
9
- export * from './use-withdraw-requests';
10
- export * from './use-withdrawable-time';
1
+ export * from './use-finalize-withdraw-request.js';
2
+ export * from './use-initiate-withdraw.js';
3
+ export * from './use-last-withdraw-request-id.js';
4
+ export * from './use-pending-withdraw-requests.js';
5
+ export * from './use-request-cancel-withdraw.js';
6
+ export * from './use-simulate-finalize-withdraw-request.js';
7
+ export * from './use-simulate-initiate-withdraw.js';
8
+ export * from './use-simulate-request-cancel-withdraw.js';
9
+ export * from './use-withdraw-requests.js';
10
+ export * from './use-withdrawable-time.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { FinalizeWithdrawRequestParameters } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
4
- import { WriteParameters, WriteResult } from '../transactions';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ import { WriteParameters, WriteResult } from '../transactions/index.js';
5
5
  /**
6
6
  * Parameters for {@link useFinalizeWithdrawRequest}.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import { InitiateWithdrawParameters } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
4
- import { WriteParameters, WriteResult } from '../transactions';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ import { WriteParameters, WriteResult } from '../transactions/index.js';
5
5
  /**
6
6
  * Parameters for {@link useInitiateWithdraw}.
7
7
  */
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetLastWithdrawRequestIdOptions, GetLastWithdrawRequestIdReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useLastWithdrawRequestId}: the core query options (user,
6
6
  * chain id, TanStack `query` overrides) plus an optional `config`.
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetPendingWithdrawRequestsOptions, GetPendingWithdrawRequestsReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link usePendingWithdrawRequests}: the core query options (user,
6
6
  * pagination, chain id, TanStack `query` overrides) plus an optional `config`.
@@ -1,7 +1,7 @@
1
1
  import { RequestCancelWithdrawParameters } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
4
- import { WriteParameters, WriteResult } from '../transactions';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ import { WriteParameters, WriteResult } from '../transactions/index.js';
5
5
  /**
6
6
  * Parameters for {@link useRequestCancelWithdraw}.
7
7
  */
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, SimulateFinalizeWithdrawRequestParameters, SimulateFinalizeWithdrawRequestReturnType } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useSimulateFinalizeWithdrawRequest}: an optional `config` override. The dry-run's
6
6
  * inputs are passed as the mutation `variables`.
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, SimulateInitiateWithdrawParameters, SimulateInitiateWithdrawReturnType } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useSimulateInitiateWithdraw}: an optional `config` override. The dry-run's
6
6
  * inputs are passed as the mutation `variables`.
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, SimulateRequestCancelWithdrawParameters, SimulateRequestCancelWithdrawReturnType } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useSimulateRequestCancelWithdraw}: an optional `config` override. The dry-run's
6
6
  * inputs are passed as the mutation `variables`.
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetWithdrawRequestsOptions, GetWithdrawRequestsReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useWithdrawRequest}: the core query options (user, request
6
6
  * id, chain id, TanStack `query` overrides) plus an optional `config`.
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetWithdrawableTimeOptions, GetWithdrawableTimeReturnType } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
- import { SymmioRequestError } from '../errors/symmio-request-error';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /**
5
5
  * Parameters for {@link useWithdrawableTime}: the core query options (user, chain
6
6
  * id, TanStack `query` overrides) plus an optional `config`.
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@symmio/trading-react",
3
- "version": "0.1.1",
3
+ "version": "1.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
- "homepage": "https://github.com/SYMM-IO/SYMM-Frontier/tree/main/packages/trading-react#readme",
6
+ "homepage": "https://github.com/SYMM-IO/Trading-SDK/tree/main/packages/trading-react#readme",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/SYMM-IO/SYMM-Frontier.git",
9
+ "url": "git+https://github.com/SYMM-IO/Trading-SDK.git",
10
10
  "directory": "packages/trading-react"
11
11
  },
12
- "bugs": "https://github.com/SYMM-IO/SYMM-Frontier/issues",
12
+ "bugs": "https://github.com/SYMM-IO/Trading-SDK/issues",
13
13
  "type": "module",
14
14
  "sideEffects": false,
15
15
  "main": "./dist/index.js",
@@ -71,7 +71,7 @@
71
71
  "@tanstack/react-query": "^5.100.0",
72
72
  "decimal.js": "^10.4.3",
73
73
  "zustand": "^5.0.0",
74
- "@symmio/trading-core": "^0.1.1"
74
+ "@symmio/trading-core": "^1.0.0"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "react": "^19.0.0",
@@ -86,7 +86,7 @@
86
86
  "@types/react": "^19.2.14",
87
87
  "@types/react-dom": "^19.2.3",
88
88
  "@vitejs/plugin-react": "^6.0.1",
89
- "@wagmi/connectors": "^8.0.0",
89
+ "@vitest/coverage-v8": "^4.1.10",
90
90
  "eslint": "^9.39.4",
91
91
  "happy-dom": "^16.0.0",
92
92
  "react": "^19.2.5",
@@ -95,18 +95,19 @@
95
95
  "viem": "^2.49.0",
96
96
  "vite": "^8.0.10",
97
97
  "vite-plugin-dts": "^5.0.0",
98
- "vitest": "^4.1.6",
98
+ "vitest": "^4.1.10",
99
99
  "wagmi": "^3.4.2",
100
- "@symmio/eslint-config": "^0.1.1",
101
- "@symmio/typescript-config": "^0.1.1"
100
+ "@symmio/eslint-config": "^1.0.0",
101
+ "@symmio/typescript-config": "^1.0.0"
102
102
  },
103
103
  "scripts": {
104
- "build": "vite build",
104
+ "build": "vite build && node ../../scripts/fix-dts-extensions.mjs dist",
105
105
  "dev": "vite build --watch",
106
106
  "lint": "eslint . --max-warnings 0",
107
107
  "check-types": "tsc --noEmit",
108
108
  "test": "vitest run --project unit",
109
109
  "test:watch": "vitest --project unit",
110
+ "test:coverage": "vitest run --project unit --coverage",
110
111
  "test:integration": "vitest run --project integration"
111
112
  }
112
113
  }
@@ -1,36 +0,0 @@
1
- import { QueryClient } from '@tanstack/react-query';
2
- /** Per-side flags marking "POST accepted, waiting for WS confirmation". */
3
- export interface TpSlConfirming {
4
- tp: boolean;
5
- sl: boolean;
6
- }
7
- /** Empty snapshot — nothing awaiting confirmation. */
8
- export declare const EMPTY_TPSL_CONFIRMING: TpSlConfirming;
9
- /**
10
- * Query key for the shared "confirming" slot used to bridge
11
- * {@link useSetQuoteTpSl} and {@link useQuoteTpSl}.
12
- *
13
- * The set-mutation writes `{tp,sl}` here on POST 200; the read-hook overlays
14
- * `confirming` onto the folded snapshot until a matching WS report clears the
15
- * flag.
16
- */
17
- export declare function getTpSlConfirmingQueryKey(parameters: {
18
- chainId: number;
19
- quoteId: bigint;
20
- configKey: string;
21
- }): readonly [string, {
22
- chainId: number;
23
- quoteId: string;
24
- configKey: string;
25
- }];
26
- /**
27
- * Mark one or both sides as awaiting WS confirmation. Merges with any existing
28
- * flags so an in-flight SL doesn't clear a TP that's still waiting.
29
- */
30
- export declare function markTpSlConfirming(queryClient: QueryClient, key: ReturnType<typeof getTpSlConfirmingQueryKey>, sides: Partial<TpSlConfirming>): void;
31
- /**
32
- * Clear one side's confirming flag (called on a matching successful WS
33
- * frame). Leaves the other side untouched.
34
- */
35
- export declare function clearTpSlConfirmingSide(queryClient: QueryClient, key: ReturnType<typeof getTpSlConfirmingQueryKey>, side: "tp" | "sl"): void;
36
- //# sourceMappingURL=tpsl-confirming.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tpsl-confirming.d.ts","sourceRoot":"","sources":["../../src/tpsl/tpsl-confirming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;CACb;AAED,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,EAAE,cAAyC,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,SAAS,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAK7E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,EACjD,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAC7B,IAAI,CAKN;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,EACjD,IAAI,EAAE,IAAI,GAAG,IAAI,GAChB,IAAI,CAKN"}
@@ -1,28 +0,0 @@
1
- //#region src/tpsl/tpsl-confirming.ts
2
- var e = {
3
- tp: !1,
4
- sl: !1
5
- };
6
- function t(e) {
7
- return ["tpsl-confirming", {
8
- chainId: e.chainId,
9
- quoteId: e.quoteId.toString(),
10
- configKey: e.configKey
11
- }];
12
- }
13
- function n(e, t, n) {
14
- e.setQueryData(t, (e) => ({
15
- tp: n.tp ?? e?.tp ?? !1,
16
- sl: n.sl ?? e?.sl ?? !1
17
- }));
18
- }
19
- function r(t, n, r) {
20
- t.setQueryData(n, (t) => !t || !t[r] ? t ?? e : {
21
- ...t,
22
- [r]: !1
23
- });
24
- }
25
- //#endregion
26
- export { e as EMPTY_TPSL_CONFIRMING, r as clearTpSlConfirmingSide, t as getTpSlConfirmingQueryKey, n as markTpSlConfirming };
27
-
28
- //# sourceMappingURL=tpsl-confirming.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tpsl-confirming.js","names":[],"sources":["../../src/tpsl/tpsl-confirming.ts"],"sourcesContent":["import type { QueryClient } from \"@tanstack/react-query\";\n\n/** Per-side flags marking \"POST accepted, waiting for WS confirmation\". */\nexport interface TpSlConfirming {\n tp: boolean;\n sl: boolean;\n}\n\n/** Empty snapshot — nothing awaiting confirmation. */\nexport const EMPTY_TPSL_CONFIRMING: TpSlConfirming = { tp: false, sl: false };\n\n/**\n * Query key for the shared \"confirming\" slot used to bridge\n * {@link useSetQuoteTpSl} and {@link useQuoteTpSl}.\n *\n * The set-mutation writes `{tp,sl}` here on POST 200; the read-hook overlays\n * `confirming` onto the folded snapshot until a matching WS report clears the\n * flag.\n */\nexport function getTpSlConfirmingQueryKey(parameters: {\n chainId: number;\n quoteId: bigint;\n configKey: string;\n}): readonly [string, { chainId: number; quoteId: string; configKey: string }] {\n return [\n \"tpsl-confirming\",\n { chainId: parameters.chainId, quoteId: parameters.quoteId.toString(), configKey: parameters.configKey },\n ] as const;\n}\n\n/**\n * Mark one or both sides as awaiting WS confirmation. Merges with any existing\n * flags so an in-flight SL doesn't clear a TP that's still waiting.\n */\nexport function markTpSlConfirming(\n queryClient: QueryClient,\n key: ReturnType<typeof getTpSlConfirmingQueryKey>,\n sides: Partial<TpSlConfirming>,\n): void {\n queryClient.setQueryData<TpSlConfirming>(key, (prev) => ({\n tp: sides.tp ?? prev?.tp ?? false,\n sl: sides.sl ?? prev?.sl ?? false,\n }));\n}\n\n/**\n * Clear one side's confirming flag (called on a matching successful WS\n * frame). Leaves the other side untouched.\n */\nexport function clearTpSlConfirmingSide(\n queryClient: QueryClient,\n key: ReturnType<typeof getTpSlConfirmingQueryKey>,\n side: \"tp\" | \"sl\",\n): void {\n queryClient.setQueryData<TpSlConfirming>(key, (prev) => {\n if (!prev || !prev[side]) return prev ?? EMPTY_TPSL_CONFIRMING;\n return { ...prev, [side]: false };\n });\n}\n"],"mappings":";AASA,IAAa,IAAwC;CAAE,IAAI;CAAO,IAAI;AAAM;AAU5E,SAAgB,EAA0B,GAIqC;CAC7E,OAAO,CACL,mBACA;EAAE,SAAS,EAAW;EAAS,SAAS,EAAW,QAAQ,SAAS;EAAG,WAAW,EAAW;CAAU,CACzG;AACF;AAMA,SAAgB,EACd,GACA,GACA,GACM;CACN,EAAY,aAA6B,IAAM,OAAU;EACvD,IAAI,EAAM,MAAM,GAAM,MAAM;EAC5B,IAAI,EAAM,MAAM,GAAM,MAAM;CAC9B,EAAE;AACJ;AAMA,SAAgB,EACd,GACA,GACA,GACM;CACN,EAAY,aAA6B,IAAM,MACzC,CAAC,KAAQ,CAAC,EAAK,KAAc,KAAQ,IAClC;EAAE,GAAG;GAAO,IAAO;CAAM,CACjC;AACH"}