@symmio/trading-react 0.1.0 → 0.2.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 (188) hide show
  1. package/README.md +47 -0
  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 +1 -1
  5. package/dist/account-layer/use-account-balance-of.d.ts +1 -1
  6. package/dist/account-layer/use-add-margin.d.ts +2 -2
  7. package/dist/account-layer/use-allocate.d.ts +2 -2
  8. package/dist/account-layer/use-create-sub-accounts.d.ts +2 -2
  9. package/dist/account-layer/use-deallocate.d.ts +2 -2
  10. package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
  11. package/dist/account-layer/use-deposit-and-allocate.d.ts +2 -2
  12. package/dist/account-layer/use-deposit.d.ts +2 -2
  13. package/dist/account-layer/use-edit-account-name.d.ts +2 -2
  14. package/dist/account-layer/use-predicted-next-virtual-account.d.ts +1 -1
  15. package/dist/account-layer/use-remove-margin.d.ts +2 -2
  16. package/dist/account-layer/use-simulate-add-margin.d.ts +1 -1
  17. package/dist/account-layer/use-simulate-allocate.d.ts +1 -1
  18. package/dist/account-layer/use-simulate-create-sub-accounts.d.ts +1 -1
  19. package/dist/account-layer/use-simulate-deallocate.d.ts +1 -1
  20. package/dist/account-layer/use-simulate-delete-sub-account.d.ts +1 -1
  21. package/dist/account-layer/use-simulate-deposit-and-allocate.d.ts +1 -1
  22. package/dist/account-layer/use-simulate-deposit.d.ts +1 -1
  23. package/dist/account-layer/use-simulate-edit-account-name.d.ts +1 -1
  24. package/dist/account-layer/use-simulate-remove-margin.d.ts +1 -1
  25. package/dist/account-layer/use-sub-account-virtual-nonce.d.ts +1 -1
  26. package/dist/account-layer/use-sub-account.d.ts +1 -1
  27. package/dist/account-layer/use-sub-accounts-count-of-user.d.ts +1 -1
  28. package/dist/account-layer/use-user-sub-accounts-addresses.d.ts +1 -1
  29. package/dist/account-layer/use-user-sub-accounts.d.ts +1 -1
  30. package/dist/account-layer/use-virtual-account.d.ts +1 -1
  31. package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.d.ts +1 -1
  32. package/dist/balance-history/index.d.ts +3 -3
  33. package/dist/balance-history/use-balance-history.d.ts +1 -1
  34. package/dist/balance-history/use-deposit-history.d.ts +1 -1
  35. package/dist/balance-history/use-withdraw-history.d.ts +1 -1
  36. package/dist/collateral/index.d.ts +4 -4
  37. package/dist/collateral/use-approve-collateral.d.ts +2 -2
  38. package/dist/collateral/use-collateral-allowance.d.ts +1 -1
  39. package/dist/collateral/use-collateral-balance.d.ts +1 -1
  40. package/dist/collateral/use-simulate-approve-collateral.d.ts +1 -1
  41. package/dist/error-codes/index.d.ts +2 -2
  42. package/dist/error-codes/use-solver-error-codes.d.ts +1 -1
  43. package/dist/error-codes/use-solver-error-message.d.ts +1 -1
  44. package/dist/errors/index.d.ts +3 -3
  45. package/dist/errors/index.js +3 -0
  46. package/dist/errors/normalize-symm-error.d.ts +1 -1
  47. package/dist/errors/symmio-request-error.d.ts +1 -1
  48. package/dist/fees/index.d.ts +1 -1
  49. package/dist/fees/index.js +2 -0
  50. package/dist/fees/use-fee-for-user.d.ts +1 -1
  51. package/dist/funding-info/index.d.ts +2 -0
  52. package/dist/funding-info/index.d.ts.map +1 -0
  53. package/dist/funding-info/use-funding-info.d.ts +25 -0
  54. package/dist/funding-info/use-funding-info.d.ts.map +1 -0
  55. package/dist/funding-info/use-funding-info.js +27 -0
  56. package/dist/funding-info/use-funding-info.js.map +1 -0
  57. package/dist/index.d.ts +40 -24
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +74 -69
  60. package/dist/instant-layer/index.d.ts +14 -13
  61. package/dist/instant-layer/index.d.ts.map +1 -1
  62. package/dist/instant-layer/index.js +15 -0
  63. package/dist/instant-layer/use-delegation-expiry.d.ts +1 -1
  64. package/dist/instant-layer/use-grant-delegation.d.ts +2 -2
  65. package/dist/instant-layer/use-instant-close-auto.d.ts +1 -1
  66. package/dist/instant-layer/use-instant-close-bulk-auto.d.ts +1 -1
  67. package/dist/instant-layer/use-instant-close-bulk.d.ts +1 -1
  68. package/dist/instant-layer/use-instant-close.d.ts +1 -1
  69. package/dist/instant-layer/use-instant-closes.d.ts +1 -1
  70. package/dist/instant-layer/use-instant-open-auto.d.ts +1 -1
  71. package/dist/instant-layer/use-instant-open-quote-id.d.ts +1 -1
  72. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts +55 -0
  73. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -0
  74. package/dist/instant-layer/use-instant-open-with-tpsl.js +56 -0
  75. package/dist/instant-layer/use-instant-open-with-tpsl.js.map +1 -0
  76. package/dist/instant-layer/use-instant-open.d.ts +1 -1
  77. package/dist/instant-layer/use-instant-opens.d.ts +1 -1
  78. package/dist/instant-layer/use-is-delegation-active.d.ts +1 -1
  79. package/dist/instant-layer/use-simulate-grant-delegation.d.ts +1 -1
  80. package/dist/locked-params/index.d.ts +1 -1
  81. package/dist/locked-params/use-locked-params.d.ts +1 -1
  82. package/dist/market-info/index.d.ts +2 -0
  83. package/dist/market-info/index.d.ts.map +1 -0
  84. package/dist/market-info/use-market-info.d.ts +28 -0
  85. package/dist/market-info/use-market-info.d.ts.map +1 -0
  86. package/dist/market-info/use-market-info.js +27 -0
  87. package/dist/market-info/use-market-info.js.map +1 -0
  88. package/dist/markets/index.d.ts +2 -2
  89. package/dist/markets/index.js +3 -0
  90. package/dist/markets/use-markets.d.ts +1 -1
  91. package/dist/markets/use-onchain-contract-markets.d.ts +1 -1
  92. package/dist/muon/index.d.ts +10 -10
  93. package/dist/muon/use-deallocate-upnl-sig.d.ts +1 -1
  94. package/dist/muon/use-muon-party-a-overview.d.ts +1 -1
  95. package/dist/muon/use-muon-price-range.d.ts +1 -1
  96. package/dist/muon/use-muon-price.d.ts +1 -1
  97. package/dist/muon/use-muon-settle-upnl.d.ts +1 -1
  98. package/dist/muon/use-muon-upnl-a-with-symbol-price.d.ts +1 -1
  99. package/dist/muon/use-muon-upnl-a.d.ts +1 -1
  100. package/dist/muon/use-muon-upnl-b.d.ts +1 -1
  101. package/dist/muon/use-muon-upnl-with-symbol-price.d.ts +1 -1
  102. package/dist/muon/use-muon-upnl.d.ts +1 -1
  103. package/dist/notifications/index.d.ts +1 -1
  104. package/dist/notifications/use-search-notifications.d.ts +1 -1
  105. package/dist/notional-cap/index.d.ts +3 -3
  106. package/dist/notional-cap/use-notional-cap-all.d.ts +1 -1
  107. package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts +1 -1
  108. package/dist/notional-cap/use-open-interest-by-symbol-id.d.ts +1 -1
  109. package/dist/price-service/index.d.ts +8 -8
  110. package/dist/price-service/index.js +9 -0
  111. package/dist/price-service/use-enigma-price-by-market-id.d.ts +1 -1
  112. package/dist/price-service/use-enigma-price-by-name.d.ts +1 -1
  113. package/dist/price-service/use-enigma-price-service-health.d.ts +1 -1
  114. package/dist/price-service/use-enigma-price-service-metadata.d.ts +1 -1
  115. package/dist/price-service/use-enigma-price-service-prices-by-addresses.d.ts +1 -1
  116. package/dist/price-service/use-enigma-price-service-prices-by-names.d.ts +1 -1
  117. package/dist/price-service/use-enigma-price-service-symbols-info.d.ts +1 -1
  118. package/dist/price-service/use-enigma-prices.d.ts +1 -1
  119. package/dist/provider/index.d.ts +3 -3
  120. package/dist/provider/index.js +4 -0
  121. package/dist/quotes/index.d.ts +15 -15
  122. package/dist/quotes/use-account-liquidation-price.d.ts +4 -7
  123. package/dist/quotes/use-account-liquidation-price.d.ts.map +1 -1
  124. package/dist/quotes/use-account-liquidation-price.js.map +1 -1
  125. package/dist/quotes/use-grouped-quotes.d.ts +1 -1
  126. package/dist/quotes/use-managed-quotes.d.ts +1 -1
  127. package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
  128. package/dist/quotes/use-managed-quotes.js +125 -122
  129. package/dist/quotes/use-managed-quotes.js.map +1 -1
  130. package/dist/quotes/use-party-a-open-positions.d.ts +4 -4
  131. package/dist/quotes/use-party-a-open-positions.js.map +1 -1
  132. package/dist/quotes/use-party-a-pending-quotes.d.ts +1 -1
  133. package/dist/quotes/use-quote-events-by-type.d.ts +1 -1
  134. package/dist/quotes/use-quote-funding.d.ts +1 -1
  135. package/dist/quotes/use-quote-history.d.ts +1 -1
  136. package/dist/quotes/use-quote-price-history.d.ts +1 -1
  137. package/dist/quotes/use-quote.d.ts +1 -1
  138. package/dist/quotes/use-quotes-funding.d.ts +1 -1
  139. package/dist/quotes/use-subgraph-query.d.ts +1 -1
  140. package/dist/tpsl/index.d.ts +8 -7
  141. package/dist/tpsl/index.d.ts.map +1 -1
  142. package/dist/tpsl/tpsl-store.d.ts +84 -0
  143. package/dist/tpsl/tpsl-store.d.ts.map +1 -0
  144. package/dist/tpsl/tpsl-store.js +154 -0
  145. package/dist/tpsl/tpsl-store.js.map +1 -0
  146. package/dist/tpsl/use-delete-quote-tpsl.d.ts +15 -0
  147. package/dist/tpsl/use-delete-quote-tpsl.d.ts.map +1 -0
  148. package/dist/tpsl/use-delete-quote-tpsl.js +31 -0
  149. package/dist/tpsl/use-delete-quote-tpsl.js.map +1 -0
  150. package/dist/tpsl/use-quote-tpsl.d.ts +19 -20
  151. package/dist/tpsl/use-quote-tpsl.d.ts.map +1 -1
  152. package/dist/tpsl/use-quote-tpsl.js +24 -53
  153. package/dist/tpsl/use-quote-tpsl.js.map +1 -1
  154. package/dist/tpsl/use-set-quote-tpsl.d.ts +11 -10
  155. package/dist/tpsl/use-set-quote-tpsl.d.ts.map +1 -1
  156. package/dist/tpsl/use-set-quote-tpsl.js +18 -22
  157. package/dist/tpsl/use-set-quote-tpsl.js.map +1 -1
  158. package/dist/tpsl/use-tpsl-config.d.ts +1 -1
  159. package/dist/tpsl/use-tpsl-signing-spec.d.ts +1 -1
  160. package/dist/tpsl/use-watch-tpsl-notifications.d.ts +1 -1
  161. package/dist/transactions/index.d.ts +3 -3
  162. package/dist/transactions/index.js +3 -0
  163. package/dist/transactions/resolve-write-result.d.ts +1 -1
  164. package/dist/transfers/index.d.ts +1 -1
  165. package/dist/transfers/use-transfer-history.d.ts +1 -1
  166. package/dist/utils/index.d.ts +1 -1
  167. package/dist/wallet/index.d.ts +4 -4
  168. package/dist/wallet/index.js +5 -0
  169. package/dist/wallet/use-connect-wallet.d.ts +1 -1
  170. package/dist/wallet/use-switch-to-symmio-chain.d.ts +1 -1
  171. package/dist/websocket/index.d.ts +1 -1
  172. package/dist/websocket/use-notifications.d.ts +1 -1
  173. package/dist/withdraw/index.d.ts +10 -10
  174. package/dist/withdraw/use-finalize-withdraw-request.d.ts +2 -2
  175. package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
  176. package/dist/withdraw/use-last-withdraw-request-id.d.ts +1 -1
  177. package/dist/withdraw/use-pending-withdraw-requests.d.ts +1 -1
  178. package/dist/withdraw/use-request-cancel-withdraw.d.ts +2 -2
  179. package/dist/withdraw/use-simulate-finalize-withdraw-request.d.ts +1 -1
  180. package/dist/withdraw/use-simulate-initiate-withdraw.d.ts +1 -1
  181. package/dist/withdraw/use-simulate-request-cancel-withdraw.d.ts +1 -1
  182. package/dist/withdraw/use-withdraw-requests.d.ts +1 -1
  183. package/dist/withdraw/use-withdrawable-time.d.ts +1 -1
  184. package/package.json +8 -6
  185. package/dist/tpsl/tpsl-confirming.d.ts +0 -36
  186. package/dist/tpsl/tpsl-confirming.d.ts.map +0 -1
  187. package/dist/tpsl/tpsl-confirming.js +0 -28
  188. package/dist/tpsl/tpsl-confirming.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { ConfigParameter, GetEnigmaPriceServiceSymbolsInfoOptions, GetEnigmaPriceServiceSymbolsInfoReturnType } 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 useEnigmaPriceServiceSymbolsInfo}: chain id, TanStack
6
6
  * `query` overrides, plus an optional `config`.
@@ -1,5 +1,5 @@
1
1
  import { ConfigParameter, EnigmaPriceTick, SocketStatus } from '@symmio/trading-core';
2
- import { SymmioRequestError } from '../errors/symmio-request-error';
2
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
3
3
  /**
4
4
  * Parameters for {@link useEnigmaPrices}.
5
5
  */
@@ -1,4 +1,4 @@
1
- export { SymmioProvider, type SymmioProviderProps } from './symmio-provider';
2
- export { useSymmioChainId } from './use-symmio-chain-id';
3
- export { useSymmioConfig, type UseSymmioConfigParameters } from './use-symmio-config';
1
+ export { SymmioProvider, type SymmioProviderProps } from './symmio-provider.js';
2
+ export { useSymmioChainId } from './use-symmio-chain-id.js';
3
+ export { useSymmioConfig, type UseSymmioConfigParameters } from './use-symmio-config.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import { SymmioProvider as e } from "./symmio-provider.js";
2
+ import { useSymmioChainId as t } from "./use-symmio-chain-id.js";
3
+ import { useSymmioConfig as n } from "./use-symmio-config.js";
4
+ export { e as SymmioProvider, t as useSymmioChainId, n as useSymmioConfig };
@@ -1,16 +1,16 @@
1
- export * from './optimistic-quotes-store';
2
- export * from './use-account-liquidation-price';
3
- export * from './use-grouped-quotes';
4
- export * from './use-managed-quotes';
5
- export * from './use-party-a-open-positions';
6
- export * from './use-party-a-pending-quotes';
7
- export * from './use-quote';
8
- export * from './use-quote-events-by-type';
9
- export * from './use-quote-funding';
10
- export * from './use-quote-history';
11
- export * from './use-quote-platform-fee';
12
- export * from './use-quote-price-history';
13
- export * from './use-quote-upnl-and-pnl';
14
- export * from './use-quotes-funding';
15
- export * from './use-subgraph-query';
1
+ export * from './optimistic-quotes-store.js';
2
+ export * from './use-account-liquidation-price.js';
3
+ export * from './use-grouped-quotes.js';
4
+ export * from './use-managed-quotes.js';
5
+ export * from './use-party-a-open-positions.js';
6
+ export * from './use-party-a-pending-quotes.js';
7
+ export * from './use-quote.js';
8
+ export * from './use-quote-events-by-type.js';
9
+ export * from './use-quote-funding.js';
10
+ export * from './use-quote-history.js';
11
+ export * from './use-quote-platform-fee.js';
12
+ export * from './use-quote-price-history.js';
13
+ export * from './use-quote-upnl-and-pnl.js';
14
+ export * from './use-quotes-funding.js';
15
+ export * from './use-subgraph-query.js';
16
16
  //# sourceMappingURL=index.d.ts.map
@@ -4,7 +4,7 @@ import { Address } from 'viem';
4
4
  * Parameters for {@link useAccountLiquidationPrice}.
5
5
  */
6
6
  export interface UseAccountLiquidationPriceParameters extends ConfigParameter {
7
- /** Account address (a sub-account for Majors, a virtual account for lowcap). */
7
+ /** Account address (virtual account for lowcap). */
8
8
  account?: Address;
9
9
  /** Optional override; defaults to the connected chain. */
10
10
  chainId?: number;
@@ -23,12 +23,9 @@ export interface UseAccountLiquidationPriceReturnType {
23
23
  * info and its open positions from the SYMMIO core and feeding them into
24
24
  * {@link calculateLiquidationPrice}.
25
25
  *
26
- * Works for both a sub-account (Majors) and a virtual account (lowcap) — the
27
- * formula is the same per-account; the only difference is the address you pass.
28
- *
29
- * Net position direction is taken from the first active position. lowcap VAs are
30
- * single-direction by design; for a mixed-direction account the result reflects
31
- * the first position's side only.
26
+ * Net position direction is taken from the first active position. Lowcap virtual
27
+ * accounts are single-direction by design; for a mixed-direction account the
28
+ * result reflects the first position's side only.
32
29
  *
33
30
  * @example
34
31
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"use-account-liquidation-price.d.ts","sourceRoot":"","sources":["../../src/quotes/use-account-liquidation-price.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC;;GAEG;AACH,MAAM,WAAW,oCAAqC,SAAQ,eAAe;IAC3E,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAC;CACpB;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,oCAAyC,GACpD,oCAAoC,CAiCtC"}
1
+ {"version":3,"file":"use-account-liquidation-price.d.ts","sourceRoot":"","sources":["../../src/quotes/use-account-liquidation-price.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIpC;;GAEG;AACH,MAAM,WAAW,oCAAqC,SAAQ,eAAe;IAC3E,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAC;CACpB;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,oCAAyC,GACpD,oCAAoC,CAiCtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-account-liquidation-price.js","names":[],"sources":["../../src/quotes/use-account-liquidation-price.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateLiquidationPrice,\n PositionType,\n type AccountPosition,\n type ConfigParameter,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Address } from \"viem\";\nimport { useAccountBalanceInfo } from \"../account-layer/use-account-balance-info\";\nimport { usePartyAOpenPositions } from \"./use-party-a-open-positions\";\n\n/**\n * Parameters for {@link useAccountLiquidationPrice}.\n */\nexport interface UseAccountLiquidationPriceParameters extends ConfigParameter {\n /** Account address (a sub-account for Majors, a virtual account for lowcap). */\n account?: Address;\n /** Optional override; defaults to the connected chain. */\n chainId?: number;\n}\n\n/**\n * Return type of {@link useAccountLiquidationPrice}.\n */\nexport interface UseAccountLiquidationPriceReturnType {\n /** Liquidation price in 18-decimal-wei collateral units. `0n` when unavailable. */\n liquidationPrice: bigint;\n /** `true` while the underlying balance / positions queries are loading. */\n isLoading: boolean;\n}\n\nconst EMPTY: UseAccountLiquidationPriceReturnType = { liquidationPrice: 0n, isLoading: false };\n\n/**\n * Compute the on-chain liquidation price for an account by reading its balance\n * info and its open positions from the SYMMIO core and feeding them into\n * {@link calculateLiquidationPrice}.\n *\n * Works for both a sub-account (Majors) and a virtual account (lowcap) — the\n * formula is the same per-account; the only difference is the address you pass.\n *\n * Net position direction is taken from the first active position. lowcap VAs are\n * single-direction by design; for a mixed-direction account the result reflects\n * the first position's side only.\n *\n * @example\n * ```tsx\n * const { liquidationPrice, isLoading } = useAccountLiquidationPrice({ account: quote.partyA });\n * ```\n */\nexport function useAccountLiquidationPrice(\n parameters: UseAccountLiquidationPriceParameters = {},\n): UseAccountLiquidationPriceReturnType {\n const { account, chainId, config } = parameters;\n\n const balanceQuery = useAccountBalanceInfo({ account, chainId, config });\n const positionsQuery = usePartyAOpenPositions({ partyA: account, chainId, config });\n\n return useMemo(() => {\n if (!account) return EMPTY;\n const balance = balanceQuery.data;\n const positions = positionsQuery.data;\n if (!balance || !positions || positions.length === 0) {\n return { liquidationPrice: 0n, isLoading: balanceQuery.isLoading || positionsQuery.isLoading };\n }\n\n const firstPosition = positions[0];\n if (!firstPosition) return { liquidationPrice: 0n, isLoading: false };\n\n const accountPositions: AccountPosition[] = positions.map((quote) => ({\n quantity: quote.quantity,\n closedAmount: quote.closedAmount,\n openedPrice: quote.openedPrice,\n }));\n\n const liquidationPrice = calculateLiquidationPrice({\n positions: accountPositions,\n positionType: firstPosition.positionType ?? PositionType.LONG,\n allocatedBalance: balance.allocatedBalance,\n lockedCVA: balance.lockedCVA,\n lockedLF: balance.lockedLF,\n });\n\n return { liquidationPrice, isLoading: false };\n }, [account, balanceQuery.data, balanceQuery.isLoading, positionsQuery.data, positionsQuery.isLoading]);\n}\n"],"mappings":";;;;;;AAiCA,IAAM,IAA8C;CAAE,kBAAkB;CAAI,WAAW;AAAM;AAmB7F,SAAgB,EACd,IAAmD,CAAC,GACd;CACtC,IAAM,EAAE,YAAS,YAAS,cAAW,GAE/B,IAAe,EAAsB;EAAE;EAAS;EAAS;CAAO,CAAC,GACjE,IAAiB,EAAuB;EAAE,QAAQ;EAAS;EAAS;CAAO,CAAC;CAElF,OAAO,QAAc;EACnB,IAAI,CAAC,GAAS,OAAO;EACrB,IAAM,IAAU,EAAa,MACvB,IAAY,EAAe;EACjC,IAAI,CAAC,KAAW,CAAC,KAAa,EAAU,WAAW,GACjD,OAAO;GAAE,kBAAkB;GAAI,WAAW,EAAa,aAAa,EAAe;EAAU;EAG/F,IAAM,IAAgB,EAAU;EAiBhC,OAhBK,IAgBE;GAAE,kBARgB,EAA0B;IACjD,WAP0C,EAAU,KAAK,OAAW;KACpE,UAAU,EAAM;KAChB,cAAc,EAAM;KACpB,aAAa,EAAM;IACrB,EAGa;IACX,cAAc,EAAc,gBAAgB,EAAa;IACzD,kBAAkB,EAAQ;IAC1B,WAAW,EAAQ;IACnB,UAAU,EAAQ;GACpB,CAES;GAAkB,WAAW;EAAM,IAhBjB;GAAE,kBAAkB;GAAI,WAAW;EAAM;CAiBtE,GAAG;EAAC;EAAS,EAAa;EAAM,EAAa;EAAW,EAAe;EAAM,EAAe;CAAS,CAAC;AACxG"}
1
+ {"version":3,"file":"use-account-liquidation-price.js","names":[],"sources":["../../src/quotes/use-account-liquidation-price.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateLiquidationPrice,\n PositionType,\n type AccountPosition,\n type ConfigParameter,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Address } from \"viem\";\nimport { useAccountBalanceInfo } from \"../account-layer/use-account-balance-info\";\nimport { usePartyAOpenPositions } from \"./use-party-a-open-positions\";\n\n/**\n * Parameters for {@link useAccountLiquidationPrice}.\n */\nexport interface UseAccountLiquidationPriceParameters extends ConfigParameter {\n /** Account address (virtual account for lowcap). */\n account?: Address;\n /** Optional override; defaults to the connected chain. */\n chainId?: number;\n}\n\n/**\n * Return type of {@link useAccountLiquidationPrice}.\n */\nexport interface UseAccountLiquidationPriceReturnType {\n /** Liquidation price in 18-decimal-wei collateral units. `0n` when unavailable. */\n liquidationPrice: bigint;\n /** `true` while the underlying balance / positions queries are loading. */\n isLoading: boolean;\n}\n\nconst EMPTY: UseAccountLiquidationPriceReturnType = { liquidationPrice: 0n, isLoading: false };\n\n/**\n * Compute the on-chain liquidation price for an account by reading its balance\n * info and its open positions from the SYMMIO core and feeding them into\n * {@link calculateLiquidationPrice}.\n *\n * Net position direction is taken from the first active position. Lowcap virtual\n * accounts are single-direction by design; for a mixed-direction account the\n * result reflects the first position's side only.\n *\n * @example\n * ```tsx\n * const { liquidationPrice, isLoading } = useAccountLiquidationPrice({ account: quote.partyA });\n * ```\n */\nexport function useAccountLiquidationPrice(\n parameters: UseAccountLiquidationPriceParameters = {},\n): UseAccountLiquidationPriceReturnType {\n const { account, chainId, config } = parameters;\n\n const balanceQuery = useAccountBalanceInfo({ account, chainId, config });\n const positionsQuery = usePartyAOpenPositions({ partyA: account, chainId, config });\n\n return useMemo(() => {\n if (!account) return EMPTY;\n const balance = balanceQuery.data;\n const positions = positionsQuery.data;\n if (!balance || !positions || positions.length === 0) {\n return { liquidationPrice: 0n, isLoading: balanceQuery.isLoading || positionsQuery.isLoading };\n }\n\n const firstPosition = positions[0];\n if (!firstPosition) return { liquidationPrice: 0n, isLoading: false };\n\n const accountPositions: AccountPosition[] = positions.map((quote) => ({\n quantity: quote.quantity,\n closedAmount: quote.closedAmount,\n openedPrice: quote.openedPrice,\n }));\n\n const liquidationPrice = calculateLiquidationPrice({\n positions: accountPositions,\n positionType: firstPosition.positionType ?? PositionType.LONG,\n allocatedBalance: balance.allocatedBalance,\n lockedCVA: balance.lockedCVA,\n lockedLF: balance.lockedLF,\n });\n\n return { liquidationPrice, isLoading: false };\n }, [account, balanceQuery.data, balanceQuery.isLoading, positionsQuery.data, positionsQuery.isLoading]);\n}\n"],"mappings":";;;;;;AAiCA,IAAM,IAA8C;CAAE,kBAAkB;CAAI,WAAW;AAAM;AAgB7F,SAAgB,EACd,IAAmD,CAAC,GACd;CACtC,IAAM,EAAE,YAAS,YAAS,cAAW,GAE/B,IAAe,EAAsB;EAAE;EAAS;EAAS;CAAO,CAAC,GACjE,IAAiB,EAAuB;EAAE,QAAQ;EAAS;EAAS;CAAO,CAAC;CAElF,OAAO,QAAc;EACnB,IAAI,CAAC,GAAS,OAAO;EACrB,IAAM,IAAU,EAAa,MACvB,IAAY,EAAe;EACjC,IAAI,CAAC,KAAW,CAAC,KAAa,EAAU,WAAW,GACjD,OAAO;GAAE,kBAAkB;GAAI,WAAW,EAAa,aAAa,EAAe;EAAU;EAG/F,IAAM,IAAgB,EAAU;EAiBhC,OAhBK,IAgBE;GAAE,kBARgB,EAA0B;IACjD,WAP0C,EAAU,KAAK,OAAW;KACpE,UAAU,EAAM;KAChB,cAAc,EAAM;KACpB,aAAa,EAAM;IACrB,EAGa;IACX,cAAc,EAAc,gBAAgB,EAAa;IACzD,kBAAkB,EAAQ;IAC1B,WAAW,EAAQ;IACnB,UAAU,EAAQ;GACpB,CAES;GAAkB,WAAW;EAAM,IAhBjB;GAAE,kBAAkB;GAAI,WAAW;EAAM;CAiBtE,GAAG;EAAC;EAAS,EAAa;EAAM,EAAa;EAAW,EAAe;EAAM,EAAe;CAAS,CAAC;AACxG"}
@@ -1,5 +1,5 @@
1
1
  import { GroupQuotesOptions, QuoteGroup, QuoteGroupingStrategy, UnifiedQuote } from '@symmio/trading-core';
2
- import { UseManagedQuotesParameters, UseManagedQuotesResult } from './use-managed-quotes';
2
+ import { UseManagedQuotesParameters, UseManagedQuotesResult } from './use-managed-quotes.js';
3
3
  /**
4
4
  * Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}
5
5
  * accepts, plus how to fold the resulting positions into groups.
@@ -1,6 +1,6 @@
1
1
  import { SocketStatus, UnifiedQuote } 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
  * Which underlying quote sources {@link useManagedQuotes} should read. Every
6
6
  * source defaults to `true`; set one to `false` to skip its query/subscription
@@ -1 +1 @@
1
- {"version":3,"file":"use-managed-quotes.d.ts","sourceRoot":"","sources":["../../src/quotes/use-managed-quotes.ts"],"names":[],"mappings":"AAEA,OAAO,EAkBL,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAGhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAqDzE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sGAAsG;IACtG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gGAAgG;IAChG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qFAAqF;IACrF,aAAa,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,qDAAqD;IACrD,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,2GAA2G;IAC3G,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,UAAU,EAAE,OAAO,CAAC;IACpB,0FAA0F;IAC1F,YAAY,EAAE,YAAY,CAAC;IAC3B,qEAAqE;IACrE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,yDAAyD;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,sBAAsB,CAkhB/F"}
1
+ {"version":3,"file":"use-managed-quotes.d.ts","sourceRoot":"","sources":["../../src/quotes/use-managed-quotes.ts"],"names":[],"mappings":"AAEA,OAAO,EAkBL,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAGhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAsDzE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sGAAsG;IACtG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wFAAwF;IACxF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,qFAAqF;IACrF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gGAAgG;IAChG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qFAAqF;IACrF,aAAa,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,qDAAqD;IACrD,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,2GAA2G;IAC3G,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,yEAAyE;IACzE,SAAS,EAAE,OAAO,CAAC;IACnB,iFAAiF;IACjF,UAAU,EAAE,OAAO,CAAC;IACpB,0FAA0F;IAC1F,YAAY,EAAE,YAAY,CAAC;IAC3B,qEAAqE;IACrE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,yDAAyD;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,sBAAsB,CA4hB/F"}
@@ -5,160 +5,163 @@ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
5
  import { predicateMatch as r } from "../utils/predicate-match.js";
6
6
  import { useVirtualAccountsAddressesOfSubAccount as i } from "../account-layer/use-virtual-accounts-addresses-of-sub-account.js";
7
7
  import { useInstantCloses as a } from "../instant-layer/use-instant-closes.js";
8
- import { useInstantOpens as ee } from "../instant-layer/use-instant-opens.js";
9
- import { useOptimisticQuotesStore as te } from "./optimistic-quotes-store.js";
8
+ import { useTpSlStore as ee } from "../tpsl/tpsl-store.js";
9
+ import { useInstantOpens as te } from "../instant-layer/use-instant-opens.js";
10
+ import { useOptimisticQuotesStore as o } from "./optimistic-quotes-store.js";
10
11
  import { useNotifications as ne } from "../websocket/use-notifications.js";
11
- import { QuoteLifecycle as o, classifyQuoteNotificationAction as re, getInstantClosesQueryKey as ie, getInstantOpensQueryKey as s, getPartyAOpenPositionsQueryKey as c, getPartyAOpenPositionsQueryOptions as ae, getPartyAPendingQuotesQueryKey as l, getPartyAPendingQuotesQueryOptions as oe, getPredictedNextVirtualAccountQueryOptions as se, getQuoteQueryKey as ce, getQuoteQueryOptions as le, isolationTypeForSide as ue, reconcileQuotes as de, shouldAccelerateOnchainReads as fe } from "@symmio/trading-core";
12
- import { useCallback as pe, useEffect as u, useMemo as d, useRef as f, useState as me } from "react";
13
- import { getAddress as p } from "viem";
14
- import { useQueries as m, useQueryClient as he } from "@tanstack/react-query";
12
+ import { QuoteLifecycle as s, classifyQuoteNotificationAction as re, getInstantClosesQueryKey as c, getInstantOpensQueryKey as l, getPartyAOpenPositionsQueryKey as u, getPartyAOpenPositionsQueryOptions as ie, getPartyAPendingQuotesQueryKey as ae, getPartyAPendingQuotesQueryOptions as oe, getPredictedNextVirtualAccountQueryOptions as se, getQuoteQueryKey as ce, getQuoteQueryOptions as le, isolationTypeForSide as ue, reconcileQuotes as de, shouldAccelerateOnchainReads as fe } from "@symmio/trading-core";
13
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
14
+ import { getAddress as g } from "viem";
15
+ import { useQueries as _, useQueryClient as pe } from "@tanstack/react-query";
15
16
  //#region src/quotes/use-managed-quotes.ts
16
- var ge = 5e3, _e = 1500, ve = 100, ye = [], be = 250, xe = new Set([
17
- o.OPTIMISTIC,
18
- o.PRICE_FILLED,
19
- o.WRITE_ONCHAIN
20
- ]), Se = new Set([o.WRITE_ONCHAIN_CLOSE, o.CLOSING]);
21
- function h(o) {
22
- let { partyA: h, chainId: Ce, pollingInterval: g, live: _ = !0, enabled: we = !0 } = o, v = t(), Te = e(), y = Ce ?? Te, b = o.includeVirtualAccounts ?? !0, Ee = o.extraAccounts, x = o.sources, S = x?.openPositions ?? !0, C = x?.pendingQuotes ?? !0, w = x?.instantOpens ?? !0, T = x?.instantCloses ?? !0, E = we && !!h, D = E && h ? `${y}:${h.toLowerCase()}` : void 0, [O, De] = me({ vas: [] }), k = O.owner === D ? O.vas : ye, A = he(), j = f(A);
23
- j.current = A;
24
- let Oe = v.getChainConfigKey(y), M = f(Oe);
25
- M.current = Oe;
26
- let N = f(void 0), P = f({
17
+ var me = 5e3, he = 1500, ge = 100, _e = [], ve = 250, ye = new Set([
18
+ s.OPTIMISTIC,
19
+ s.PRICE_FILLED,
20
+ s.WRITE_ONCHAIN
21
+ ]), be = new Set([s.WRITE_ONCHAIN_CLOSE, s.CLOSING]);
22
+ function v(s) {
23
+ let { partyA: v, chainId: xe, pollingInterval: y, live: b = !0, enabled: Se = !0 } = s, x = t(), Ce = e(), S = xe ?? Ce, C = s.includeVirtualAccounts ?? !0, w = s.extraAccounts, T = s.sources, E = T?.openPositions ?? !0, D = T?.pendingQuotes ?? !0, O = T?.instantOpens ?? !0, k = T?.instantCloses ?? !0, A = Se && !!v, j = A && v ? `${S}:${v.toLowerCase()}` : void 0, [we, Te] = h({ vas: [] }), Ee = we.owner === j ? we.vas : _e, De = pe(), M = m(De);
24
+ M.current = De;
25
+ let Oe = x.getChainConfigKey(S), N = m(Oe);
26
+ N.current = Oe;
27
+ let P = m(void 0), F = m({
27
28
  opens: !1,
28
29
  closes: !1
29
- }), F = f(void 0), I = f([]), L = f("closed"), R = te((e) => e.entries), ke = te((e) => e.clearSettled), Ae = _ && L.current === "open", z = g && g > 0 ? g : !1, je = F.current ? fe(F.current) : !1, B = E ? je ? _e : Ae ? z : z || ge : !1, Me = F.current?.quotes, Ne = Me?.some((e) => xe.has(e.lifecycle)) ?? !1, Pe = Me?.some((e) => Se.has(e.lifecycle)) ?? !1, Fe = (e) => !Ae && e ? _e : z, Ie = E && w ? Fe(Ne) : !1, Le = E && T ? Fe(Pe) : !1, V = ee({
30
- partyA: h,
31
- chainId: y,
30
+ }), I = m(void 0), L = m([]), ke = m("closed"), R = o((e) => e.entries), Ae = o((e) => e.clearSettled), je = b && ke.current === "open", z = y && y > 0 ? y : !1, Me = I.current ? fe(I.current) : !1, B = A ? Me ? he : je ? z : z || me : !1, Ne = I.current?.quotes, Pe = Ne?.some((e) => ye.has(e.lifecycle)) ?? !1, Fe = Ne?.some((e) => be.has(e.lifecycle)) ?? !1, Ie = (e) => !je && e ? he : z, Le = A && O ? Ie(Pe) : !1, Re = A && k ? Ie(Fe) : !1, V = te({
31
+ partyA: v,
32
+ chainId: S,
32
33
  query: {
33
- enabled: E && w,
34
- refetchInterval: Ie
34
+ enabled: A && O,
35
+ refetchInterval: Le
35
36
  }
36
37
  }), H = a({
37
- partyA: h,
38
- chainId: y,
38
+ partyA: v,
39
+ chainId: S,
39
40
  query: {
40
- enabled: E && T,
41
- refetchInterval: Le
41
+ enabled: A && k,
42
+ refetchInterval: Re
42
43
  }
43
44
  }), U = i({
44
- subAccount: h,
45
- chainId: y,
45
+ subAccount: v,
46
+ chainId: S,
46
47
  query: {
47
- enabled: E && b,
48
+ enabled: A && C,
48
49
  refetchInterval: B
49
50
  }
50
- }), Re = w ? V.data ?? [] : [], W = m({
51
- queries: Re.map((e) => ({ ...se(v, {
52
- subAccount: h,
53
- chainId: y,
51
+ }), ze = O ? V.data ?? [] : [], W = _({
52
+ queries: ze.map((e) => ({ ...se(x, {
53
+ subAccount: v,
54
+ chainId: S,
54
55
  isolationType: ue(e.positionType),
55
56
  symbolId: BigInt(e.marketId),
56
57
  query: {
57
- enabled: E && b,
58
+ enabled: A && C,
58
59
  refetchInterval: B
59
60
  }
60
61
  }) })),
61
62
  combine: (e) => ({
62
- byTempId: Re.reduce((t, n, r) => {
63
+ byTempId: ze.reduce((t, n, r) => {
63
64
  let i = e[r]?.data;
64
- return i && (t[n.tempQuoteId] = p(i)), t;
65
+ return i && (t[n.tempQuoteId] = g(i)), t;
65
66
  }, {}),
66
67
  addresses: e.map((e) => e.data).filter((e) => !!e),
67
68
  isLoading: e.some((e) => e.isLoading),
68
69
  isFetching: e.some((e) => e.isFetching)
69
70
  })
70
- }), [G, ze] = me([]), { status: K } = ne({
71
- account: h,
72
- chainId: y,
73
- enabled: E && _,
74
- onNotification: pe((e) => {
75
- ze((t) => [...t, e].slice(-ve));
76
- let t = re(e.lastSeenAction), n = P.current;
77
- t === "open" ? n.opens = !0 : (t === "close" || (n.opens = !0), n.closes = !0), N.current && clearTimeout(N.current), N.current = setTimeout(() => {
78
- let e = j.current, t = { configKey: M.current }, { opens: n, closes: i } = P.current;
79
- P.current = {
71
+ }), [G, Be] = h([]), { status: K } = ne({
72
+ account: v,
73
+ chainId: S,
74
+ enabled: A && b,
75
+ onNotification: d((e) => {
76
+ Be((t) => [...t, e].slice(-ge));
77
+ let t = e.tempQuoteId, n = e.quoteId;
78
+ t && n && n !== `${t}` && ee.getState().link(BigInt(t), BigInt(n));
79
+ let i = re(e.lastSeenAction), a = F.current;
80
+ i === "open" ? a.opens = !0 : (i === "close" || (a.opens = !0), a.closes = !0), P.current && clearTimeout(P.current), P.current = setTimeout(() => {
81
+ let e = M.current, t = { configKey: N.current }, { opens: n, closes: i } = F.current;
82
+ F.current = {
80
83
  opens: !1,
81
84
  closes: !1
82
- }, e.invalidateQueries({ predicate: r(c, t) }), e.invalidateQueries({ predicate: r(l, t) }), e.invalidateQueries({ predicate: r(ce, t) }), n && e.invalidateQueries({ predicate: r(s, t) }), i && e.invalidateQueries({ predicate: r(ie, t) });
83
- }, be);
85
+ }, e.invalidateQueries({ predicate: r(u, t) }), e.invalidateQueries({ predicate: r(ae, t) }), e.invalidateQueries({ predicate: r(ce, t) }), n && e.invalidateQueries({ predicate: r(l, t) }), i && e.invalidateQueries({ predicate: r(c, t) });
86
+ }, ve);
84
87
  }, [])
85
88
  });
86
- L.current = K;
87
- let Be = f(!1);
88
- u(() => {
89
- if (!(!_ || K !== "open")) {
90
- if (Be.current) {
91
- let e = j.current, t = { configKey: M.current };
92
- e.invalidateQueries({ predicate: r(c, t) }), e.invalidateQueries({ predicate: r(l, t) }), e.invalidateQueries({ predicate: r(ce, t) }), e.invalidateQueries({ predicate: r(s, t) }), e.invalidateQueries({ predicate: r(ie, t) });
89
+ ke.current = K;
90
+ let Ve = m(!1);
91
+ f(() => {
92
+ if (!(!b || K !== "open")) {
93
+ if (Ve.current) {
94
+ let e = M.current, t = { configKey: N.current };
95
+ e.invalidateQueries({ predicate: r(u, t) }), e.invalidateQueries({ predicate: r(ae, t) }), e.invalidateQueries({ predicate: r(ce, t) }), e.invalidateQueries({ predicate: r(l, t) }), e.invalidateQueries({ predicate: r(c, t) });
93
96
  }
94
- Be.current = !0;
97
+ Ve.current = !0;
95
98
  }
96
- }, [K, _]), u(() => () => {
97
- N.current && clearTimeout(N.current);
99
+ }, [K, b]), f(() => () => {
100
+ P.current && clearTimeout(P.current);
98
101
  }, []);
99
- let q = d(() => {
102
+ let q = p(() => {
100
103
  let e = /* @__PURE__ */ new Set(), t = [];
101
104
  for (let n of G) {
102
105
  if (!n.vaAddress) continue;
103
- let r = p(n.vaAddress), i = r.toLowerCase();
106
+ let r = g(n.vaAddress), i = r.toLowerCase();
104
107
  e.has(i) || (e.add(i), t.push(r));
105
108
  }
106
109
  return t;
107
- }, [G]), J = d(() => {
108
- if (!E || !h) return [];
110
+ }, [G]), J = p(() => {
111
+ if (!A || !v) return [];
109
112
  let e = /* @__PURE__ */ new Set(), t = [], n = (n) => {
110
- let r = p(n), i = r.toLowerCase();
113
+ let r = g(n), i = r.toLowerCase();
111
114
  e.has(i) || (e.add(i), t.push(r));
112
115
  };
113
- if (n(h), b) {
116
+ if (n(v), C) {
114
117
  for (let e of U.data ?? []) n(e);
115
118
  for (let e of W.addresses) n(e);
116
119
  for (let e of q) n(e);
117
- for (let e of k) n(e);
120
+ for (let e of Ee) n(e);
118
121
  }
119
- for (let e of Ee ?? []) n(e);
122
+ for (let e of w ?? []) n(e);
120
123
  return t;
121
124
  }, [
122
- E,
123
- h,
124
- b,
125
+ A,
126
+ v,
127
+ C,
125
128
  U.data,
126
129
  W.addresses,
127
130
  q,
128
- k,
129
- Ee
131
+ Ee,
132
+ w
130
133
  ]);
131
- u(() => {
132
- if (!D) return;
134
+ f(() => {
135
+ if (!j) return;
133
136
  let e = [
134
137
  ...U.data ?? [],
135
138
  ...W.addresses,
136
139
  ...q
137
140
  ];
138
- De((t) => {
139
- let n = t.owner === D ? t.vas : [], r = new Set(n.map((e) => e.toLowerCase())), i = [...n], a = t.owner !== D;
141
+ Te((t) => {
142
+ let n = t.owner === j ? t.vas : [], r = new Set(n.map((e) => e.toLowerCase())), i = [...n], a = t.owner !== j;
140
143
  for (let t of e) {
141
- let e = p(t), n = e.toLowerCase();
144
+ let e = g(t), n = e.toLowerCase();
142
145
  r.has(n) || (r.add(n), i.push(e), a = !0);
143
146
  }
144
147
  return a ? {
145
- owner: D,
148
+ owner: j,
146
149
  vas: i
147
150
  } : t;
148
151
  });
149
152
  }, [
150
- D,
153
+ j,
151
154
  U.data,
152
155
  W.addresses,
153
156
  q
154
157
  ]);
155
- let Y = m({
158
+ let Y = _({
156
159
  queries: J.map((e) => {
157
- let t = ae(v, {
160
+ let t = ie(x, {
158
161
  partyA: e,
159
- chainId: y,
162
+ chainId: S,
160
163
  query: {
161
- enabled: E && S,
164
+ enabled: A && E,
162
165
  refetchInterval: B
163
166
  }
164
167
  });
@@ -180,13 +183,13 @@ function h(o) {
180
183
  error: e.find((e) => e.error)?.error ?? null,
181
184
  refetch: () => e.forEach((e) => e.refetch())
182
185
  })
183
- }), X = m({
186
+ }), X = _({
184
187
  queries: J.map((e) => {
185
- let t = oe(v, {
188
+ let t = oe(x, {
186
189
  partyA: e,
187
- chainId: y,
190
+ chainId: S,
188
191
  query: {
189
- enabled: E && C,
192
+ enabled: A && D,
190
193
  refetchInterval: B
191
194
  }
192
195
  });
@@ -208,13 +211,13 @@ function h(o) {
208
211
  error: e.find((e) => e.error)?.error ?? null,
209
212
  refetch: () => e.forEach((e) => e.refetch())
210
213
  })
211
- }), Z = m({
214
+ }), Z = _({
212
215
  queries: X.ids.map((e) => {
213
- let t = le(v, {
216
+ let t = le(x, {
214
217
  quoteId: e,
215
- chainId: y,
218
+ chainId: S,
216
219
  query: {
217
- enabled: E && C,
220
+ enabled: A && D,
218
221
  refetchInterval: B
219
222
  }
220
223
  });
@@ -235,26 +238,26 @@ function h(o) {
235
238
  isFetching: e.some((e) => e.isFetching),
236
239
  error: e.find((e) => e.error)?.error ?? null
237
240
  })
238
- }), Q = d(() => {
239
- if (!E || !h) return F.current = void 0, I.current = [], {
241
+ }), Q = p(() => {
242
+ if (!A || !v) return I.current = void 0, L.current = [], {
240
243
  quotes: [],
241
244
  links: {},
242
245
  pendingAnchors: []
243
246
  };
244
247
  let e = [...V.data ?? [], ...Object.values(R)], t = de({
245
- partyA: h,
246
- onchainPositions: S ? Y.quotes : [],
247
- onchainPendingQuotes: C ? Z.quotes : [],
248
- instantOpens: w ? e : [],
249
- instantCloses: T ? H.data ?? [] : [],
248
+ partyA: v,
249
+ onchainPositions: E ? Y.quotes : [],
250
+ onchainPendingQuotes: D ? Z.quotes : [],
251
+ instantOpens: O ? e : [],
252
+ instantCloses: k ? H.data ?? [] : [],
250
253
  instantOpenVaByTempId: W.byTempId,
251
254
  notifications: G,
252
- retainedAnchors: I.current
255
+ retainedAnchors: L.current
253
256
  });
254
- return F.current = t, I.current = t.pendingAnchors, t;
257
+ return I.current = t, L.current = t.pendingAnchors, t;
255
258
  }, [
256
- E,
257
- h,
259
+ A,
260
+ v,
258
261
  Y.quotes,
259
262
  Z.quotes,
260
263
  V.data,
@@ -262,38 +265,38 @@ function h(o) {
262
265
  W.byTempId,
263
266
  R,
264
267
  G,
265
- S,
266
- C,
267
- w,
268
- T
269
- ]), $ = d(() => {
268
+ E,
269
+ D,
270
+ O,
271
+ k
272
+ ]), $ = p(() => {
270
273
  let e = {};
271
274
  for (let t of Q.quotes) e[t.key] = t;
272
275
  return e;
273
276
  }, [Q.quotes]);
274
- u(() => {
277
+ f(() => {
275
278
  let e = Object.keys(R).map(Number).filter((e) => {
276
279
  let t = Q.links[e];
277
280
  return t !== void 0 && $[t]?.raw.onchain !== void 0;
278
281
  });
279
- e.length > 0 && ke(e);
282
+ e.length > 0 && Ae(e);
280
283
  }, [
281
284
  Q,
282
285
  $,
283
286
  R,
284
- ke
287
+ Ae
285
288
  ]);
286
- let Ve = E && b && U.isLoading || E && b && W.isLoading || E && S && Y.isLoading || E && C && (X.isLoading || Z.isLoading) || E && w && V.isLoading || E && T && H.isLoading, He = b && (U.isFetching || W.isFetching) || S && Y.isFetching || C && (X.isFetching || Z.isFetching) || w && V.isFetching || T && H.isFetching, Ue = Y.error ?? X.error ?? Z.error ?? U.error ?? V.error ?? H.error ?? null, We = Y.refetch, Ge = X.refetch, Ke = pe(() => {
287
- b && U.refetch(), S && We(), C && Ge(), w && V.refetch(), T && H.refetch();
289
+ let He = A && C && U.isLoading || A && C && W.isLoading || A && E && Y.isLoading || A && D && (X.isLoading || Z.isLoading) || A && O && V.isLoading || A && k && H.isLoading, Ue = C && (U.isFetching || W.isFetching) || E && Y.isFetching || D && (X.isFetching || Z.isFetching) || O && V.isFetching || k && H.isFetching, We = Y.error ?? X.error ?? Z.error ?? U.error ?? V.error ?? H.error ?? null, Ge = Y.refetch, Ke = X.refetch, qe = d(() => {
290
+ C && U.refetch(), E && Ge(), D && Ke(), O && V.refetch(), k && H.refetch();
288
291
  }, [
289
- b,
290
- S,
291
292
  C,
292
- w,
293
- T,
293
+ E,
294
+ D,
295
+ O,
296
+ k,
294
297
  U,
295
- We,
296
298
  Ge,
299
+ Ke,
297
300
  V,
298
301
  H
299
302
  ]);
@@ -301,14 +304,14 @@ function h(o) {
301
304
  quotes: Q.quotes,
302
305
  byKey: $,
303
306
  accounts: J,
304
- isLoading: !!Ve,
305
- isFetching: !!He,
306
- socketStatus: _ ? K : "closed",
307
- error: Ue,
308
- refetch: Ke
307
+ isLoading: !!He,
308
+ isFetching: !!Ue,
309
+ socketStatus: b ? K : "closed",
310
+ error: We,
311
+ refetch: qe
309
312
  };
310
313
  }
311
314
  //#endregion
312
- export { h as useManagedQuotes };
315
+ export { v as useManagedQuotes };
313
316
 
314
317
  //# sourceMappingURL=use-managed-quotes.js.map