@symmio/trading-react 1.1.0 → 3.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 (543) hide show
  1. package/dist/account-layer/index.d.ts +1 -0
  2. package/dist/account-layer/index.d.ts.map +1 -1
  3. package/dist/account-layer/index.js +26 -25
  4. package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts +53 -0
  5. package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -0
  6. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +49 -0
  7. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -0
  8. package/dist/account-layer/use-deposit-and-allocate.d.ts +4 -2
  9. package/dist/account-layer/use-deposit-and-allocate.d.ts.map +1 -1
  10. package/dist/account-layer/use-deposit-and-allocate.js +17 -15
  11. package/dist/account-layer/use-deposit-and-allocate.js.map +1 -1
  12. package/dist/account-layer/use-edit-account-name.d.ts.map +1 -1
  13. package/dist/account-layer/use-edit-account-name.js +14 -14
  14. package/dist/account-layer/use-edit-account-name.js.map +1 -1
  15. package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.d.ts +1 -1
  16. package/dist/account-layer/use-virtual-accounts-addresses-of-sub-account.js.map +1 -1
  17. package/dist/candles/index.d.ts +5 -0
  18. package/dist/candles/index.d.ts.map +1 -0
  19. package/dist/candles/index.js +5 -0
  20. package/dist/candles/use-binance-candle-source.d.ts +27 -0
  21. package/dist/candles/use-binance-candle-source.d.ts.map +1 -0
  22. package/dist/candles/use-binance-candle-source.js +24 -0
  23. package/dist/candles/use-binance-candle-source.js.map +1 -0
  24. package/dist/candles/use-candle-stream.d.ts +65 -0
  25. package/dist/candles/use-candle-stream.d.ts.map +1 -0
  26. package/dist/candles/use-candle-stream.js +44 -0
  27. package/dist/candles/use-candle-stream.js.map +1 -0
  28. package/dist/candles/use-candles.d.ts +40 -0
  29. package/dist/candles/use-candles.d.ts.map +1 -0
  30. package/dist/candles/use-candles.js +22 -0
  31. package/dist/candles/use-candles.js.map +1 -0
  32. package/dist/candles/use-tradingview-datafeed.d.ts +31 -0
  33. package/dist/candles/use-tradingview-datafeed.d.ts.map +1 -0
  34. package/dist/candles/use-tradingview-datafeed.js +21 -0
  35. package/dist/candles/use-tradingview-datafeed.js.map +1 -0
  36. package/dist/index.d.ts +125 -21
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +201 -113
  39. package/dist/instant-layer/index.d.ts +4 -0
  40. package/dist/instant-layer/index.d.ts.map +1 -1
  41. package/dist/instant-layer/index.js +10 -6
  42. package/dist/instant-layer/use-instant-close-auto.d.ts.map +1 -1
  43. package/dist/instant-layer/use-instant-close-auto.js +12 -11
  44. package/dist/instant-layer/use-instant-close-auto.js.map +1 -1
  45. package/dist/instant-layer/use-instant-close-bulk-auto.d.ts.map +1 -1
  46. package/dist/instant-layer/use-instant-close-bulk-auto.js +12 -11
  47. package/dist/instant-layer/use-instant-close-bulk-auto.js.map +1 -1
  48. package/dist/instant-layer/use-instant-close-bulk.d.ts.map +1 -1
  49. package/dist/instant-layer/use-instant-close-bulk.js +12 -11
  50. package/dist/instant-layer/use-instant-close-bulk.js.map +1 -1
  51. package/dist/instant-layer/use-instant-close.d.ts.map +1 -1
  52. package/dist/instant-layer/use-instant-close.js +12 -11
  53. package/dist/instant-layer/use-instant-close.js.map +1 -1
  54. package/dist/instant-layer/use-instant-open-auto.d.ts.map +1 -1
  55. package/dist/instant-layer/use-instant-open-auto.js +12 -11
  56. package/dist/instant-layer/use-instant-open-auto.js.map +1 -1
  57. package/dist/instant-layer/use-instant-open-fees.d.ts +43 -0
  58. package/dist/instant-layer/use-instant-open-fees.d.ts.map +1 -0
  59. package/dist/instant-layer/use-instant-open-fees.js +111 -0
  60. package/dist/instant-layer/use-instant-open-fees.js.map +1 -0
  61. package/dist/instant-layer/use-instant-open-with-tpsl.d.ts.map +1 -1
  62. package/dist/instant-layer/use-instant-open-with-tpsl.js +34 -31
  63. package/dist/instant-layer/use-instant-open-with-tpsl.js.map +1 -1
  64. package/dist/instant-layer/use-instant-open.d.ts +23 -18
  65. package/dist/instant-layer/use-instant-open.d.ts.map +1 -1
  66. package/dist/instant-layer/use-instant-open.js +12 -11
  67. package/dist/instant-layer/use-instant-open.js.map +1 -1
  68. package/dist/instant-layer/use-instant-opens.d.ts +6 -6
  69. package/dist/instant-layer/use-instant-opens.d.ts.map +1 -1
  70. package/dist/instant-layer/use-instant-opens.js.map +1 -1
  71. package/dist/instant-layer/use-instant-trade-required-selectors.d.ts +25 -0
  72. package/dist/instant-layer/use-instant-trade-required-selectors.d.ts.map +1 -0
  73. package/dist/instant-layer/use-instant-trade-required-selectors.js +13 -0
  74. package/dist/instant-layer/use-instant-trade-required-selectors.js.map +1 -0
  75. package/dist/instant-layer/use-limit-close-auto.d.ts +30 -0
  76. package/dist/instant-layer/use-limit-close-auto.d.ts.map +1 -0
  77. package/dist/instant-layer/use-limit-close-auto.js +33 -0
  78. package/dist/instant-layer/use-limit-close-auto.js.map +1 -0
  79. package/dist/instant-layer/use-limit-open-auto.d.ts +30 -0
  80. package/dist/instant-layer/use-limit-open-auto.d.ts.map +1 -0
  81. package/dist/instant-layer/use-limit-open-auto.js +33 -0
  82. package/dist/instant-layer/use-limit-open-auto.js.map +1 -0
  83. package/dist/inventory/index.d.ts +3 -0
  84. package/dist/inventory/index.d.ts.map +1 -0
  85. package/dist/inventory/index.js +3 -0
  86. package/dist/inventory/use-inventory-tvl-history.d.ts +27 -0
  87. package/dist/inventory/use-inventory-tvl-history.d.ts.map +1 -0
  88. package/dist/inventory/use-inventory-tvl-history.js +28 -0
  89. package/dist/inventory/use-inventory-tvl-history.js.map +1 -0
  90. package/dist/inventory/use-inventory-tvl.d.ts +23 -0
  91. package/dist/inventory/use-inventory-tvl.d.ts.map +1 -0
  92. package/dist/inventory/use-inventory-tvl.js +27 -0
  93. package/dist/inventory/use-inventory-tvl.js.map +1 -0
  94. package/dist/margin/index.d.ts +1 -0
  95. package/dist/margin/index.d.ts.map +1 -1
  96. package/dist/margin/use-account-margin-risk.d.ts +68 -0
  97. package/dist/margin/use-account-margin-risk.d.ts.map +1 -0
  98. package/dist/margin/use-account-margin-risk.js +31 -0
  99. package/dist/margin/use-account-margin-risk.js.map +1 -0
  100. package/dist/margin/use-available-instant-open-margin.d.ts +27 -7
  101. package/dist/margin/use-available-instant-open-margin.d.ts.map +1 -1
  102. package/dist/margin/use-available-instant-open-margin.js +117 -46
  103. package/dist/margin/use-available-instant-open-margin.js.map +1 -1
  104. package/dist/market-info/use-market-info.d.ts +13 -13
  105. package/dist/market-info/use-market-info.d.ts.map +1 -1
  106. package/dist/market-info/use-market-info.js.map +1 -1
  107. package/dist/markets/use-markets.d.ts +14 -8
  108. package/dist/markets/use-markets.d.ts.map +1 -1
  109. package/dist/markets/use-markets.js.map +1 -1
  110. package/dist/muon/index.d.ts +2 -0
  111. package/dist/muon/index.d.ts.map +1 -1
  112. package/dist/muon/use-force-close-price-sig.d.ts +34 -0
  113. package/dist/muon/use-force-close-price-sig.d.ts.map +1 -0
  114. package/dist/muon/use-force-close-price-sig.js +31 -0
  115. package/dist/muon/use-force-close-price-sig.js.map +1 -0
  116. package/dist/muon/use-send-quote-upnl-sig.d.ts +30 -0
  117. package/dist/muon/use-send-quote-upnl-sig.d.ts.map +1 -0
  118. package/dist/muon/use-send-quote-upnl-sig.js +28 -0
  119. package/dist/muon/use-send-quote-upnl-sig.js.map +1 -0
  120. package/dist/notifications/use-search-notifications.d.ts +12 -12
  121. package/dist/notifications/use-search-notifications.d.ts.map +1 -1
  122. package/dist/notifications/use-search-notifications.js.map +1 -1
  123. package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts +7 -7
  124. package/dist/notional-cap/use-notional-cap-by-symbol-id.d.ts.map +1 -1
  125. package/dist/notional-cap/use-notional-cap-by-symbol-id.js.map +1 -1
  126. package/dist/orderbook/index.d.ts +5 -0
  127. package/dist/orderbook/index.d.ts.map +1 -0
  128. package/dist/orderbook/index.js +5 -0
  129. package/dist/orderbook/use-binance-orderbook-source.d.ts +28 -0
  130. package/dist/orderbook/use-binance-orderbook-source.d.ts.map +1 -0
  131. package/dist/orderbook/use-binance-orderbook-source.js +26 -0
  132. package/dist/orderbook/use-binance-orderbook-source.js.map +1 -0
  133. package/dist/orderbook/use-live-orderbook.d.ts +104 -0
  134. package/dist/orderbook/use-live-orderbook.d.ts.map +1 -0
  135. package/dist/orderbook/use-live-orderbook.js +77 -0
  136. package/dist/orderbook/use-live-orderbook.js.map +1 -0
  137. package/dist/orderbook/use-orderbook-stream.d.ts +73 -0
  138. package/dist/orderbook/use-orderbook-stream.d.ts.map +1 -0
  139. package/dist/orderbook/use-orderbook-stream.js +49 -0
  140. package/dist/orderbook/use-orderbook-stream.js.map +1 -0
  141. package/dist/orderbook/use-orderbook.d.ts +35 -0
  142. package/dist/orderbook/use-orderbook.d.ts.map +1 -0
  143. package/dist/orderbook/use-orderbook.js +22 -0
  144. package/dist/orderbook/use-orderbook.js.map +1 -0
  145. package/dist/pools/index.d.ts +30 -0
  146. package/dist/pools/index.d.ts.map +1 -0
  147. package/dist/pools/index.js +30 -0
  148. package/dist/pools/use-add-market.d.ts +57 -0
  149. package/dist/pools/use-add-market.d.ts.map +1 -0
  150. package/dist/pools/use-add-market.js +30 -0
  151. package/dist/pools/use-add-market.js.map +1 -0
  152. package/dist/pools/use-authenticate-listing.d.ts +45 -0
  153. package/dist/pools/use-authenticate-listing.d.ts.map +1 -0
  154. package/dist/pools/use-authenticate-listing.js +30 -0
  155. package/dist/pools/use-authenticate-listing.js.map +1 -0
  156. package/dist/pools/use-cancel-withdraw.d.ts +47 -0
  157. package/dist/pools/use-cancel-withdraw.d.ts.map +1 -0
  158. package/dist/pools/use-cancel-withdraw.js +30 -0
  159. package/dist/pools/use-cancel-withdraw.js.map +1 -0
  160. package/dist/pools/use-claim-history.d.ts +25 -0
  161. package/dist/pools/use-claim-history.d.ts.map +1 -0
  162. package/dist/pools/use-claim-history.js +27 -0
  163. package/dist/pools/use-claim-history.js.map +1 -0
  164. package/dist/pools/use-claim-profit.d.ts +53 -0
  165. package/dist/pools/use-claim-profit.d.ts.map +1 -0
  166. package/dist/pools/use-claim-profit.js +30 -0
  167. package/dist/pools/use-claim-profit.js.map +1 -0
  168. package/dist/pools/use-deposit-address.d.ts +43 -0
  169. package/dist/pools/use-deposit-address.d.ts.map +1 -0
  170. package/dist/pools/use-deposit-address.js +28 -0
  171. package/dist/pools/use-deposit-address.js.map +1 -0
  172. package/dist/pools/use-listing-config.d.ts +28 -0
  173. package/dist/pools/use-listing-config.d.ts.map +1 -0
  174. package/dist/pools/use-listing-config.js +27 -0
  175. package/dist/pools/use-listing-config.js.map +1 -0
  176. package/dist/pools/use-listing-market-config-projection.d.ts +66 -0
  177. package/dist/pools/use-listing-market-config-projection.d.ts.map +1 -0
  178. package/dist/pools/use-listing-market-config-projection.js +57 -0
  179. package/dist/pools/use-listing-market-config-projection.js.map +1 -0
  180. package/dist/pools/use-listing-market-config.d.ts +49 -0
  181. package/dist/pools/use-listing-market-config.d.ts.map +1 -0
  182. package/dist/pools/use-listing-market-config.js +28 -0
  183. package/dist/pools/use-listing-market-config.js.map +1 -0
  184. package/dist/pools/use-listing-market-detail.d.ts +29 -0
  185. package/dist/pools/use-listing-market-detail.d.ts.map +1 -0
  186. package/dist/pools/use-listing-market-detail.js +27 -0
  187. package/dist/pools/use-listing-market-detail.js.map +1 -0
  188. package/dist/pools/use-listing-markets.d.ts +32 -0
  189. package/dist/pools/use-listing-markets.d.ts.map +1 -0
  190. package/dist/pools/use-listing-markets.js +27 -0
  191. package/dist/pools/use-listing-markets.js.map +1 -0
  192. package/dist/pools/use-listing-status.d.ts +29 -0
  193. package/dist/pools/use-listing-status.d.ts.map +1 -0
  194. package/dist/pools/use-listing-status.js +28 -0
  195. package/dist/pools/use-listing-status.js.map +1 -0
  196. package/dist/pools/use-pool-quotes.d.ts +26 -0
  197. package/dist/pools/use-pool-quotes.d.ts.map +1 -0
  198. package/dist/pools/use-pool-quotes.js +27 -0
  199. package/dist/pools/use-pool-quotes.js.map +1 -0
  200. package/dist/pools/use-pool-reward-chart.d.ts +32 -0
  201. package/dist/pools/use-pool-reward-chart.d.ts.map +1 -0
  202. package/dist/pools/use-pool-reward-chart.js +28 -0
  203. package/dist/pools/use-pool-reward-chart.js.map +1 -0
  204. package/dist/pools/use-pool-total-reward.d.ts +27 -0
  205. package/dist/pools/use-pool-total-reward.d.ts.map +1 -0
  206. package/dist/pools/use-pool-total-reward.js +28 -0
  207. package/dist/pools/use-pool-total-reward.js.map +1 -0
  208. package/dist/pools/use-pool-trade-history.d.ts +26 -0
  209. package/dist/pools/use-pool-trade-history.d.ts.map +1 -0
  210. package/dist/pools/use-pool-trade-history.js +27 -0
  211. package/dist/pools/use-pool-trade-history.js.map +1 -0
  212. package/dist/pools/use-pool-transactions.d.ts +23 -0
  213. package/dist/pools/use-pool-transactions.d.ts.map +1 -0
  214. package/dist/pools/use-pool-transactions.js +27 -0
  215. package/dist/pools/use-pool-transactions.js.map +1 -0
  216. package/dist/pools/use-refund-market.d.ts +51 -0
  217. package/dist/pools/use-refund-market.d.ts.map +1 -0
  218. package/dist/pools/use-refund-market.js +30 -0
  219. package/dist/pools/use-refund-market.js.map +1 -0
  220. package/dist/pools/use-retry-listing-info.d.ts +23 -0
  221. package/dist/pools/use-retry-listing-info.d.ts.map +1 -0
  222. package/dist/pools/use-retry-listing-info.js +27 -0
  223. package/dist/pools/use-retry-listing-info.js.map +1 -0
  224. package/dist/pools/use-retry-listing.d.ts +46 -0
  225. package/dist/pools/use-retry-listing.d.ts.map +1 -0
  226. package/dist/pools/use-retry-listing.js +30 -0
  227. package/dist/pools/use-retry-listing.js.map +1 -0
  228. package/dist/pools/use-supports-listing-service.d.ts +21 -0
  229. package/dist/pools/use-supports-listing-service.d.ts.map +1 -0
  230. package/dist/pools/use-supports-listing-service.js +13 -0
  231. package/dist/pools/use-supports-listing-service.js.map +1 -0
  232. package/dist/pools/use-update-listing-market-config.d.ts +60 -0
  233. package/dist/pools/use-update-listing-market-config.d.ts.map +1 -0
  234. package/dist/pools/use-update-listing-market-config.js +30 -0
  235. package/dist/pools/use-update-listing-market-config.js.map +1 -0
  236. package/dist/pools/use-user-listing-markets.d.ts +40 -0
  237. package/dist/pools/use-user-listing-markets.d.ts.map +1 -0
  238. package/dist/pools/use-user-listing-markets.js +28 -0
  239. package/dist/pools/use-user-listing-markets.js.map +1 -0
  240. package/dist/pools/use-user-profit.d.ts +39 -0
  241. package/dist/pools/use-user-profit.d.ts.map +1 -0
  242. package/dist/pools/use-user-profit.js +28 -0
  243. package/dist/pools/use-user-profit.js.map +1 -0
  244. package/dist/pools/use-user-reward-chart.d.ts +28 -0
  245. package/dist/pools/use-user-reward-chart.d.ts.map +1 -0
  246. package/dist/pools/use-user-reward-chart.js +28 -0
  247. package/dist/pools/use-user-reward-chart.js.map +1 -0
  248. package/dist/pools/use-user-total-reward.d.ts +30 -0
  249. package/dist/pools/use-user-total-reward.d.ts.map +1 -0
  250. package/dist/pools/use-user-total-reward.js +28 -0
  251. package/dist/pools/use-user-total-reward.js.map +1 -0
  252. package/dist/pools/use-user-transactions.d.ts +24 -0
  253. package/dist/pools/use-user-transactions.d.ts.map +1 -0
  254. package/dist/pools/use-user-transactions.js +27 -0
  255. package/dist/pools/use-user-transactions.js.map +1 -0
  256. package/dist/pools/use-weekly-listing-limit.d.ts +28 -0
  257. package/dist/pools/use-weekly-listing-limit.d.ts.map +1 -0
  258. package/dist/pools/use-weekly-listing-limit.js +28 -0
  259. package/dist/pools/use-weekly-listing-limit.js.map +1 -0
  260. package/dist/pools/use-withdraw-lp.d.ts +52 -0
  261. package/dist/pools/use-withdraw-lp.d.ts.map +1 -0
  262. package/dist/pools/use-withdraw-lp.js +30 -0
  263. package/dist/pools/use-withdraw-lp.js.map +1 -0
  264. package/dist/price-service/index.d.ts +8 -0
  265. package/dist/price-service/index.d.ts.map +1 -1
  266. package/dist/price-service/index.js +17 -9
  267. package/dist/price-service/use-binance-health.d.ts +16 -0
  268. package/dist/price-service/use-binance-health.d.ts.map +1 -0
  269. package/dist/price-service/use-binance-health.js +27 -0
  270. package/dist/price-service/use-binance-health.js.map +1 -0
  271. package/dist/price-service/use-binance-premium-index.d.ts +24 -0
  272. package/dist/price-service/use-binance-premium-index.d.ts.map +1 -0
  273. package/dist/price-service/use-binance-premium-index.js +27 -0
  274. package/dist/price-service/use-binance-premium-index.js.map +1 -0
  275. package/dist/price-service/use-binance-prices.d.ts +54 -0
  276. package/dist/price-service/use-binance-prices.d.ts.map +1 -0
  277. package/dist/price-service/use-binance-prices.js +57 -0
  278. package/dist/price-service/use-binance-prices.js.map +1 -0
  279. package/dist/price-service/use-binance-symbols-info.d.ts +18 -0
  280. package/dist/price-service/use-binance-symbols-info.d.ts.map +1 -0
  281. package/dist/price-service/use-binance-symbols-info.js +27 -0
  282. package/dist/price-service/use-binance-symbols-info.js.map +1 -0
  283. package/dist/price-service/use-enigma-price-by-market-id.d.ts +7 -1
  284. package/dist/price-service/use-enigma-price-by-market-id.d.ts.map +1 -1
  285. package/dist/price-service/use-enigma-price-by-market-id.js +1 -1
  286. package/dist/price-service/use-enigma-price-by-market-id.js.map +1 -1
  287. package/dist/price-service/use-mark-prices.d.ts +25 -0
  288. package/dist/price-service/use-mark-prices.d.ts.map +1 -0
  289. package/dist/price-service/use-mark-prices.js +27 -0
  290. package/dist/price-service/use-mark-prices.js.map +1 -0
  291. package/dist/price-service/use-price-by-market-id.d.ts +53 -0
  292. package/dist/price-service/use-price-by-market-id.d.ts.map +1 -0
  293. package/dist/price-service/use-price-by-market-id.js +33 -0
  294. package/dist/price-service/use-price-by-market-id.js.map +1 -0
  295. package/dist/price-service/use-price-by-name.d.ts +48 -0
  296. package/dist/price-service/use-price-by-name.d.ts.map +1 -0
  297. package/dist/price-service/use-price-by-name.js +23 -0
  298. package/dist/price-service/use-price-by-name.js.map +1 -0
  299. package/dist/price-service/use-prices.d.ts +87 -0
  300. package/dist/price-service/use-prices.d.ts.map +1 -0
  301. package/dist/price-service/use-prices.js +77 -0
  302. package/dist/price-service/use-prices.js.map +1 -0
  303. package/dist/provider/symmio-provider.d.ts +8 -2
  304. package/dist/provider/symmio-provider.d.ts.map +1 -1
  305. package/dist/provider/symmio-provider.js +19 -19
  306. package/dist/provider/symmio-provider.js.map +1 -1
  307. package/dist/quotes/confirm-hold.d.ts +121 -0
  308. package/dist/quotes/confirm-hold.d.ts.map +1 -0
  309. package/dist/quotes/confirm-hold.js +59 -0
  310. package/dist/quotes/confirm-hold.js.map +1 -0
  311. package/dist/quotes/index.d.ts +14 -0
  312. package/dist/quotes/index.d.ts.map +1 -1
  313. package/dist/quotes/use-account-upnl.d.ts +66 -0
  314. package/dist/quotes/use-account-upnl.d.ts.map +1 -0
  315. package/dist/quotes/use-account-upnl.js +73 -0
  316. package/dist/quotes/use-account-upnl.js.map +1 -0
  317. package/dist/quotes/use-close-quote-group.d.ts +126 -0
  318. package/dist/quotes/use-close-quote-group.d.ts.map +1 -0
  319. package/dist/quotes/use-close-quote-group.js +172 -0
  320. package/dist/quotes/use-close-quote-group.js.map +1 -0
  321. package/dist/quotes/use-cool-downs-of-ma.d.ts +26 -0
  322. package/dist/quotes/use-cool-downs-of-ma.d.ts.map +1 -0
  323. package/dist/quotes/use-cool-downs-of-ma.js +27 -0
  324. package/dist/quotes/use-cool-downs-of-ma.js.map +1 -0
  325. package/dist/quotes/use-force-cancel-close-request.d.ts +27 -0
  326. package/dist/quotes/use-force-cancel-close-request.d.ts.map +1 -0
  327. package/dist/quotes/use-force-cancel-close-request.js +41 -0
  328. package/dist/quotes/use-force-cancel-close-request.js.map +1 -0
  329. package/dist/quotes/use-force-cancel-quote.d.ts +26 -0
  330. package/dist/quotes/use-force-cancel-quote.d.ts.map +1 -0
  331. package/dist/quotes/use-force-cancel-quote.js +42 -0
  332. package/dist/quotes/use-force-cancel-quote.js.map +1 -0
  333. package/dist/quotes/use-force-close-eligibility.d.ts +30 -0
  334. package/dist/quotes/use-force-close-eligibility.d.ts.map +1 -0
  335. package/dist/quotes/use-force-close-eligibility.js +39 -0
  336. package/dist/quotes/use-force-close-eligibility.js.map +1 -0
  337. package/dist/quotes/use-force-close-params.d.ts +22 -0
  338. package/dist/quotes/use-force-close-params.d.ts.map +1 -0
  339. package/dist/quotes/use-force-close-params.js +27 -0
  340. package/dist/quotes/use-force-close-params.js.map +1 -0
  341. package/dist/quotes/use-force-close.d.ts +30 -0
  342. package/dist/quotes/use-force-close.d.ts.map +1 -0
  343. package/dist/quotes/use-force-close.js +38 -0
  344. package/dist/quotes/use-force-close.js.map +1 -0
  345. package/dist/quotes/use-grouped-quotes.d.ts +50 -10
  346. package/dist/quotes/use-grouped-quotes.d.ts.map +1 -1
  347. package/dist/quotes/use-grouped-quotes.js +40 -14
  348. package/dist/quotes/use-grouped-quotes.js.map +1 -1
  349. package/dist/quotes/use-grouping-isolation.d.ts +35 -0
  350. package/dist/quotes/use-grouping-isolation.d.ts.map +1 -0
  351. package/dist/quotes/use-grouping-isolation.js +39 -0
  352. package/dist/quotes/use-grouping-isolation.js.map +1 -0
  353. package/dist/quotes/use-limit-orders.d.ts +62 -0
  354. package/dist/quotes/use-limit-orders.d.ts.map +1 -0
  355. package/dist/quotes/use-limit-orders.js +82 -0
  356. package/dist/quotes/use-limit-orders.js.map +1 -0
  357. package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
  358. package/dist/quotes/use-managed-quotes.js +198 -166
  359. package/dist/quotes/use-managed-quotes.js.map +1 -1
  360. package/dist/quotes/use-party-a-open-positions.d.ts +26 -6
  361. package/dist/quotes/use-party-a-open-positions.d.ts.map +1 -1
  362. package/dist/quotes/use-party-a-open-positions.js +32 -12
  363. package/dist/quotes/use-party-a-open-positions.js.map +1 -1
  364. package/dist/quotes/use-quote-funding.d.ts +2 -2
  365. package/dist/quotes/use-quote-funding.js.map +1 -1
  366. package/dist/quotes/use-quote-group-funding-history.d.ts +70 -0
  367. package/dist/quotes/use-quote-group-funding-history.d.ts.map +1 -0
  368. package/dist/quotes/use-quote-group-funding-history.js +38 -0
  369. package/dist/quotes/use-quote-group-funding-history.js.map +1 -0
  370. package/dist/quotes/use-quote-group-funding.d.ts +67 -0
  371. package/dist/quotes/use-quote-group-funding.d.ts.map +1 -0
  372. package/dist/quotes/use-quote-group-funding.js +26 -0
  373. package/dist/quotes/use-quote-group-funding.js.map +1 -0
  374. package/dist/quotes/use-quote-group-margin-risk.d.ts +111 -0
  375. package/dist/quotes/use-quote-group-margin-risk.d.ts.map +1 -0
  376. package/dist/quotes/use-quote-group-margin-risk.js +63 -0
  377. package/dist/quotes/use-quote-group-margin-risk.js.map +1 -0
  378. package/dist/quotes/use-quote-upnl-and-pnl.d.ts +4 -3
  379. package/dist/quotes/use-quote-upnl-and-pnl.d.ts.map +1 -1
  380. package/dist/quotes/use-quote-upnl-and-pnl.js +2 -1
  381. package/dist/quotes/use-quote-upnl-and-pnl.js.map +1 -1
  382. package/dist/quotes/use-quotes-funding.d.ts +46 -10
  383. package/dist/quotes/use-quotes-funding.d.ts.map +1 -1
  384. package/dist/quotes/use-quotes-funding.js +44 -42
  385. package/dist/quotes/use-quotes-funding.js.map +1 -1
  386. package/dist/quotes/use-request-to-cancel-close-request.d.ts +27 -0
  387. package/dist/quotes/use-request-to-cancel-close-request.d.ts.map +1 -0
  388. package/dist/quotes/use-request-to-cancel-close-request.js +41 -0
  389. package/dist/quotes/use-request-to-cancel-close-request.js.map +1 -0
  390. package/dist/quotes/use-request-to-cancel-quote.d.ts +32 -0
  391. package/dist/quotes/use-request-to-cancel-quote.d.ts.map +1 -0
  392. package/dist/quotes/use-request-to-cancel-quote.js +42 -0
  393. package/dist/quotes/use-request-to-cancel-quote.js.map +1 -0
  394. package/dist/rasa-solver/index.d.ts +7 -0
  395. package/dist/rasa-solver/index.d.ts.map +1 -0
  396. package/dist/rasa-solver/use-error-message.d.ts +14 -0
  397. package/dist/rasa-solver/use-error-message.d.ts.map +1 -0
  398. package/dist/rasa-solver/use-error-message.js +27 -0
  399. package/dist/rasa-solver/use-error-message.js.map +1 -0
  400. package/dist/rasa-solver/use-party-a-upnl.d.ts +14 -0
  401. package/dist/rasa-solver/use-party-a-upnl.d.ts.map +1 -0
  402. package/dist/rasa-solver/use-party-a-upnl.js +27 -0
  403. package/dist/rasa-solver/use-party-a-upnl.js.map +1 -0
  404. package/dist/rasa-solver/use-solver-balance-info.d.ts +14 -0
  405. package/dist/rasa-solver/use-solver-balance-info.d.ts.map +1 -0
  406. package/dist/rasa-solver/use-solver-balance-info.js +27 -0
  407. package/dist/rasa-solver/use-solver-balance-info.js.map +1 -0
  408. package/dist/rasa-solver/use-solver-open-interest.d.ts +14 -0
  409. package/dist/rasa-solver/use-solver-open-interest.d.ts.map +1 -0
  410. package/dist/rasa-solver/use-solver-open-interest.js +27 -0
  411. package/dist/rasa-solver/use-solver-open-interest.js.map +1 -0
  412. package/dist/rasa-solver/use-solver-price-range.d.ts +14 -0
  413. package/dist/rasa-solver/use-solver-price-range.d.ts.map +1 -0
  414. package/dist/rasa-solver/use-solver-price-range.js +27 -0
  415. package/dist/rasa-solver/use-solver-price-range.js.map +1 -0
  416. package/dist/rasa-solver/use-solver-readiness.d.ts +13 -0
  417. package/dist/rasa-solver/use-solver-readiness.d.ts.map +1 -0
  418. package/dist/rasa-solver/use-solver-readiness.js +27 -0
  419. package/dist/rasa-solver/use-solver-readiness.js.map +1 -0
  420. package/dist/revenue-records/index.d.ts +2 -0
  421. package/dist/revenue-records/index.d.ts.map +1 -0
  422. package/dist/revenue-records/use-revenue-records.d.ts +25 -0
  423. package/dist/revenue-records/use-revenue-records.d.ts.map +1 -0
  424. package/dist/revenue-records/use-revenue-records.js +27 -0
  425. package/dist/revenue-records/use-revenue-records.js.map +1 -0
  426. package/dist/solvers/index.d.ts +3 -0
  427. package/dist/solvers/index.d.ts.map +1 -0
  428. package/dist/solvers/use-solver-capabilities.d.ts +31 -0
  429. package/dist/solvers/use-solver-capabilities.d.ts.map +1 -0
  430. package/dist/solvers/use-solver-capabilities.js +30 -0
  431. package/dist/solvers/use-solver-capabilities.js.map +1 -0
  432. package/dist/solvers/use-solver-revenue.d.ts +28 -0
  433. package/dist/solvers/use-solver-revenue.d.ts.map +1 -0
  434. package/dist/solvers/use-solver-revenue.js +27 -0
  435. package/dist/solvers/use-solver-revenue.js.map +1 -0
  436. package/dist/symbols/index.d.ts +2 -0
  437. package/dist/symbols/index.d.ts.map +1 -0
  438. package/dist/symbols/use-symbols.d.ts +25 -0
  439. package/dist/symbols/use-symbols.d.ts.map +1 -0
  440. package/dist/symbols/use-symbols.js +27 -0
  441. package/dist/symbols/use-symbols.js.map +1 -0
  442. package/dist/tpsl/apply-tpsl-search-snapshot.d.ts +33 -0
  443. package/dist/tpsl/apply-tpsl-search-snapshot.d.ts.map +1 -0
  444. package/dist/tpsl/apply-tpsl-search-snapshot.js +51 -0
  445. package/dist/tpsl/apply-tpsl-search-snapshot.js.map +1 -0
  446. package/dist/tpsl/await-tpsl-confirmation.d.ts +77 -0
  447. package/dist/tpsl/await-tpsl-confirmation.d.ts.map +1 -0
  448. package/dist/tpsl/await-tpsl-confirmation.js +42 -0
  449. package/dist/tpsl/await-tpsl-confirmation.js.map +1 -0
  450. package/dist/tpsl/index.d.ts +11 -0
  451. package/dist/tpsl/index.d.ts.map +1 -1
  452. package/dist/tpsl/invalidate-tpsl.d.ts +23 -0
  453. package/dist/tpsl/invalidate-tpsl.d.ts.map +1 -0
  454. package/dist/tpsl/invalidate-tpsl.js +14 -0
  455. package/dist/tpsl/invalidate-tpsl.js.map +1 -0
  456. package/dist/tpsl/match-tpsl-notification.d.ts +27 -0
  457. package/dist/tpsl/match-tpsl-notification.d.ts.map +1 -0
  458. package/dist/tpsl/match-tpsl-notification.js +22 -0
  459. package/dist/tpsl/match-tpsl-notification.js.map +1 -0
  460. package/dist/tpsl/run-with-concurrency.d.ts +20 -0
  461. package/dist/tpsl/run-with-concurrency.d.ts.map +1 -0
  462. package/dist/tpsl/run-with-concurrency.js +15 -0
  463. package/dist/tpsl/run-with-concurrency.js.map +1 -0
  464. package/dist/tpsl/settled-side.d.ts +31 -0
  465. package/dist/tpsl/settled-side.d.ts.map +1 -0
  466. package/dist/tpsl/settled-side.js +21 -0
  467. package/dist/tpsl/settled-side.js.map +1 -0
  468. package/dist/tpsl/tpsl-fallback-poll.d.ts +74 -0
  469. package/dist/tpsl/tpsl-fallback-poll.d.ts.map +1 -0
  470. package/dist/tpsl/tpsl-fallback-poll.js +101 -0
  471. package/dist/tpsl/tpsl-fallback-poll.js.map +1 -0
  472. package/dist/tpsl/tpsl-store.d.ts +98 -2
  473. package/dist/tpsl/tpsl-store.d.ts.map +1 -1
  474. package/dist/tpsl/tpsl-store.js +111 -63
  475. package/dist/tpsl/tpsl-store.js.map +1 -1
  476. package/dist/tpsl/use-delete-quote-group-tpsl.d.ts +165 -0
  477. package/dist/tpsl/use-delete-quote-group-tpsl.d.ts.map +1 -0
  478. package/dist/tpsl/use-delete-quote-group-tpsl.js +247 -0
  479. package/dist/tpsl/use-delete-quote-group-tpsl.js.map +1 -0
  480. package/dist/tpsl/use-delete-quote-tpsl.d.ts.map +1 -1
  481. package/dist/tpsl/use-delete-quote-tpsl.js +11 -10
  482. package/dist/tpsl/use-delete-quote-tpsl.js.map +1 -1
  483. package/dist/tpsl/use-quote-group-tpsl-editor.d.ts +66 -0
  484. package/dist/tpsl/use-quote-group-tpsl-editor.d.ts.map +1 -0
  485. package/dist/tpsl/use-quote-group-tpsl-editor.js +78 -0
  486. package/dist/tpsl/use-quote-group-tpsl-editor.js.map +1 -0
  487. package/dist/tpsl/use-quote-group-tpsl.d.ts +74 -0
  488. package/dist/tpsl/use-quote-group-tpsl.d.ts.map +1 -0
  489. package/dist/tpsl/use-quote-group-tpsl.js +67 -0
  490. package/dist/tpsl/use-quote-group-tpsl.js.map +1 -0
  491. package/dist/tpsl/use-quote-tpsl.d.ts +18 -2
  492. package/dist/tpsl/use-quote-tpsl.d.ts.map +1 -1
  493. package/dist/tpsl/use-quote-tpsl.js +32 -24
  494. package/dist/tpsl/use-quote-tpsl.js.map +1 -1
  495. package/dist/tpsl/use-search-tpsl-orders.d.ts +30 -0
  496. package/dist/tpsl/use-search-tpsl-orders.d.ts.map +1 -0
  497. package/dist/tpsl/use-search-tpsl-orders.js +27 -0
  498. package/dist/tpsl/use-search-tpsl-orders.js.map +1 -0
  499. package/dist/tpsl/use-set-quote-group-tpsl.d.ts +234 -0
  500. package/dist/tpsl/use-set-quote-group-tpsl.d.ts.map +1 -0
  501. package/dist/tpsl/use-set-quote-group-tpsl.js +358 -0
  502. package/dist/tpsl/use-set-quote-group-tpsl.js.map +1 -0
  503. package/dist/tpsl/use-set-quote-tpsl.d.ts +4 -4
  504. package/dist/tpsl/use-set-quote-tpsl.d.ts.map +1 -1
  505. package/dist/tpsl/use-set-quote-tpsl.js +15 -12
  506. package/dist/tpsl/use-set-quote-tpsl.js.map +1 -1
  507. package/dist/tpsl/use-tpsl-supported.d.ts +22 -0
  508. package/dist/tpsl/use-tpsl-supported.d.ts.map +1 -0
  509. package/dist/tpsl/use-tpsl-supported.js +16 -0
  510. package/dist/tpsl/use-tpsl-supported.js.map +1 -0
  511. package/dist/tpsl/use-watch-tpsl-accounts.d.ts +33 -0
  512. package/dist/tpsl/use-watch-tpsl-accounts.d.ts.map +1 -0
  513. package/dist/tpsl/use-watch-tpsl-accounts.js +44 -0
  514. package/dist/tpsl/use-watch-tpsl-accounts.js.map +1 -0
  515. package/dist/trade-volume/index.d.ts +2 -0
  516. package/dist/trade-volume/index.d.ts.map +1 -0
  517. package/dist/trade-volume/use-trade-volume.d.ts +26 -0
  518. package/dist/trade-volume/use-trade-volume.d.ts.map +1 -0
  519. package/dist/trade-volume/use-trade-volume.js +27 -0
  520. package/dist/trade-volume/use-trade-volume.js.map +1 -0
  521. package/dist/utils/index.d.ts +1 -0
  522. package/dist/utils/index.d.ts.map +1 -1
  523. package/dist/utils/invalidate-account-balances.d.ts +36 -0
  524. package/dist/utils/invalidate-account-balances.d.ts.map +1 -0
  525. package/dist/utils/invalidate-account-balances.js +10 -0
  526. package/dist/utils/invalidate-account-balances.js.map +1 -0
  527. package/dist/websocket/use-notifications.d.ts +3 -1
  528. package/dist/websocket/use-notifications.d.ts.map +1 -1
  529. package/dist/websocket/use-notifications.js +22 -20
  530. package/dist/websocket/use-notifications.js.map +1 -1
  531. package/dist/withdraw/index.d.ts +1 -0
  532. package/dist/withdraw/index.d.ts.map +1 -1
  533. package/dist/withdraw/use-initiate-withdraw.d.ts +1 -1
  534. package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
  535. package/dist/withdraw/use-request-cancel-withdraw.d.ts +4 -2
  536. package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
  537. package/dist/withdraw/use-request-cancel-withdraw.js +15 -13
  538. package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
  539. package/dist/withdraw/use-withdraw.d.ts +67 -0
  540. package/dist/withdraw/use-withdraw.d.ts.map +1 -0
  541. package/dist/withdraw/use-withdraw.js +49 -0
  542. package/dist/withdraw/use-withdraw.js.map +1 -0
  543. package/package.json +18 -2
@@ -0,0 +1,27 @@
1
+ import { ForceCancelCloseRequestParameters } from '@symmio/trading-core';
2
+ import { UseMutationResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ import { WriteParameters, WriteResult } from '../transactions/index.js';
5
+ /** Parameters for {@link useForceCancelCloseRequest}. */
6
+ export type UseForceCancelCloseRequestParameters = WriteParameters;
7
+ /** Result returned by the {@link useForceCancelCloseRequest} mutation. */
8
+ export type ForceCancelCloseRequestResult = WriteResult;
9
+ /** Return type of {@link useForceCancelCloseRequest}. */
10
+ export type UseForceCancelCloseRequestReturnType = UseMutationResult<ForceCancelCloseRequestResult, SymmioRequestError, ForceCancelCloseRequestParameters>;
11
+ /**
12
+ * Force-cancel a stalled pending close (`forceCancelCloseRequest`, routed through
13
+ * the AccountLayer `_call` proxy). Only valid once the quote is
14
+ * `CANCEL_CLOSE_PENDING` (partyA already called `requestToCancelCloseRequest` and
15
+ * partyB never acted) **and** the force-cancel-close cooldown has elapsed — see
16
+ * {@link useCoolDownsOfMA} (index 2) plus the quote's `statusModifyTimestamp`. The
17
+ * quote returns to `OPENED`. On success (after the receipt) the subaccount's
18
+ * open-positions read is invalidated.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const { mutate } = useForceCancelCloseRequest();
23
+ * mutate({ account: "0xsub…", quoteId: 42n });
24
+ * ```
25
+ */
26
+ export declare function useForceCancelCloseRequest(parameters?: UseForceCancelCloseRequestParameters): UseForceCancelCloseRequestReturnType;
27
+ //# sourceMappingURL=use-force-cancel-close-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-cancel-close-request.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-cancel-close-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,iCAAiC,EACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F,yDAAyD;AACzD,MAAM,MAAM,oCAAoC,GAAG,eAAe,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,MAAM,6BAA6B,GAAG,WAAW,CAAC;AAExD,yDAAyD;AACzD,MAAM,MAAM,oCAAoC,GAAG,iBAAiB,CAClE,6BAA6B,EAC7B,kBAAkB,EAClB,iCAAiC,CAClC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,oCAAyC,GACpD,oCAAoC,CAmCtC"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
6
+ import { predicateMatch as i } from "../utils/predicate-match.js";
7
+ import { forceCancelCloseRequestMutationOptions as a, getPartyAOpenPositionsQueryKey as o } from "@symmio/trading-core";
8
+ import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
9
+ //#region src/quotes/use-force-cancel-close-request.ts
10
+ function l(l = {}) {
11
+ let u = t(l), d = e(), f = c(), p = a(u);
12
+ return s({
13
+ mutationKey: p.mutationKey,
14
+ mutationFn: async (e) => {
15
+ try {
16
+ let t = e.chainId ?? d;
17
+ return r(u, await p.mutationFn({
18
+ account: e.account,
19
+ quoteId: e.quoteId,
20
+ from: e.from,
21
+ simulateBeforeWrite: e.simulateBeforeWrite,
22
+ chainId: t
23
+ }), {
24
+ chainId: t,
25
+ waitForReceipt: l.waitForReceipt,
26
+ confirmations: l.confirmations
27
+ });
28
+ } catch (e) {
29
+ throw n(e);
30
+ }
31
+ },
32
+ onSuccess: (e, t) => {
33
+ let n = { partyA: t.account };
34
+ f.invalidateQueries({ predicate: i(o, n) });
35
+ }
36
+ });
37
+ }
38
+ //#endregion
39
+ export { l as useForceCancelCloseRequest };
40
+
41
+ //# sourceMappingURL=use-force-cancel-close-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-cancel-close-request.js","names":[],"sources":["../../src/quotes/use-force-cancel-close-request.ts"],"sourcesContent":["\"use client\";\n\nimport {\n forceCancelCloseRequestMutationOptions,\n getPartyAOpenPositionsQueryKey,\n type ForceCancelCloseRequestParameters,\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 { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/** Parameters for {@link useForceCancelCloseRequest}. */\nexport type UseForceCancelCloseRequestParameters = WriteParameters;\n\n/** Result returned by the {@link useForceCancelCloseRequest} mutation. */\nexport type ForceCancelCloseRequestResult = WriteResult;\n\n/** Return type of {@link useForceCancelCloseRequest}. */\nexport type UseForceCancelCloseRequestReturnType = UseMutationResult<\n ForceCancelCloseRequestResult,\n SymmioRequestError,\n ForceCancelCloseRequestParameters\n>;\n\n/**\n * Force-cancel a stalled pending close (`forceCancelCloseRequest`, routed through\n * the AccountLayer `_call` proxy). Only valid once the quote is\n * `CANCEL_CLOSE_PENDING` (partyA already called `requestToCancelCloseRequest` and\n * partyB never acted) **and** the force-cancel-close cooldown has elapsed — see\n * {@link useCoolDownsOfMA} (index 2) plus the quote's `statusModifyTimestamp`. The\n * quote returns to `OPENED`. On success (after the receipt) the subaccount's\n * open-positions read is invalidated.\n *\n * @example\n * ```tsx\n * const { mutate } = useForceCancelCloseRequest();\n * mutate({ account: \"0xsub…\", quoteId: 42n });\n * ```\n */\nexport function useForceCancelCloseRequest(\n parameters: UseForceCancelCloseRequestParameters = {},\n): UseForceCancelCloseRequestReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = forceCancelCloseRequestMutationOptions(config);\n\n return useMutation<ForceCancelCloseRequestResult, SymmioRequestError, ForceCancelCloseRequestParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({\n account: variables.account,\n quoteId: variables.quoteId,\n from: variables.from,\n simulateBeforeWrite: variables.simulateBeforeWrite,\n chainId: resolvedChainId,\n });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n // The force-cancel returns the position to OPENED — refetch the owning\n // partyA's open positions so the status updates.\n const partial = { partyA: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAOpenPositionsQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA2CA,SAAgB,EACd,IAAmD,CAAC,GACd;CACtC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAuC,CAAM;CAE1D,OAAO,EAAkG;EACvG,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAQ7C,OAAO,EAAmB,GAAQ,MAPf,EAAK,WAAW;KACjC,SAAS,EAAU;KACnB,SAAS,EAAU;KACnB,MAAM,EAAU;KAChB,qBAAqB,EAAU;KAC/B,SAAS;IACX,CAAC,GACuC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAGjC,IAAM,IAAU,EAAE,QAAQ,EAAU,QAAQ;GAC5C,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC;EAC3G;CACF,CAAC;AACH"}
@@ -0,0 +1,26 @@
1
+ import { ForceCancelQuoteParameters } from '@symmio/trading-core';
2
+ import { UseMutationResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ import { WriteParameters, WriteResult } from '../transactions/index.js';
5
+ /** Parameters for {@link useForceCancelQuote}. */
6
+ export type UseForceCancelQuoteParameters = WriteParameters;
7
+ /** Result returned by the {@link useForceCancelQuote} mutation. */
8
+ export type ForceCancelQuoteResult = WriteResult;
9
+ /** Return type of {@link useForceCancelQuote}. */
10
+ export type UseForceCancelQuoteReturnType = UseMutationResult<ForceCancelQuoteResult, SymmioRequestError, ForceCancelQuoteParameters>;
11
+ /**
12
+ * Force-cancel a stalled quote (`forceCancelQuote`, routed through the
13
+ * AccountLayer `_call` proxy). Only valid once the quote is `CANCEL_PENDING`
14
+ * (partyA already called `requestToCancelQuote` on a `LOCKED` order) **and** the
15
+ * force-cancel cooldown has elapsed — see {@link useCoolDownsOfMA} (index 1) plus
16
+ * the quote's `statusModifyTimestamp`. On success (after the receipt) the
17
+ * subaccount's pending-quotes reads are invalidated so the order drops out.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * const { mutate } = useForceCancelQuote();
22
+ * mutate({ account: "0xsub…", quoteId: 42n });
23
+ * ```
24
+ */
25
+ export declare function useForceCancelQuote(parameters?: UseForceCancelQuoteParameters): UseForceCancelQuoteReturnType;
26
+ //# sourceMappingURL=use-force-cancel-quote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-cancel-quote.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-cancel-quote.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC;AAE5D,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAEjD,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,iBAAiB,CAC3D,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,CAC3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,6BAAkC,GAAG,6BAA6B,CAkDjH"}
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
6
+ import { predicateMatch as i } from "../utils/predicate-match.js";
7
+ import { invalidateAccountBalances as a } from "../utils/invalidate-account-balances.js";
8
+ import { forceCancelQuoteMutationOptions as o, getPartyAOpenPositionsQueryKey as s, getPartyAPendingQuotesQueryKey as c, getPendingQuotesQueryKey as l, getQuoteQueryKey as u } from "@symmio/trading-core";
9
+ import { useMutation as d, useQueryClient as f } from "@tanstack/react-query";
10
+ //#region src/quotes/use-force-cancel-quote.ts
11
+ function p(p = {}) {
12
+ let m = t(p), h = e(), g = f(), _ = o(m);
13
+ return d({
14
+ mutationKey: _.mutationKey,
15
+ mutationFn: async (e) => {
16
+ try {
17
+ let t = e.chainId ?? h;
18
+ return r(m, await _.mutationFn({
19
+ account: e.account,
20
+ quoteId: e.quoteId,
21
+ from: e.from,
22
+ simulateBeforeWrite: e.simulateBeforeWrite,
23
+ chainId: t
24
+ }), {
25
+ chainId: t,
26
+ waitForReceipt: p.waitForReceipt,
27
+ confirmations: p.confirmations
28
+ });
29
+ } catch (e) {
30
+ throw n(e);
31
+ }
32
+ },
33
+ onSuccess: (e, t) => {
34
+ let n = { partyA: t.account };
35
+ g.invalidateQueries({ predicate: i(l, n) }), g.invalidateQueries({ predicate: i(c, n) }), g.invalidateQueries({ predicate: i(s, n) }), g.invalidateQueries({ predicate: i(u, { quoteId: t.quoteId }) }), a(g, { configKey: m.getChainConfigKey(t.chainId ?? h) });
36
+ }
37
+ });
38
+ }
39
+ //#endregion
40
+ export { p as useForceCancelQuote };
41
+
42
+ //# sourceMappingURL=use-force-cancel-quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-cancel-quote.js","names":[],"sources":["../../src/quotes/use-force-cancel-quote.ts"],"sourcesContent":["\"use client\";\n\nimport {\n forceCancelQuoteMutationOptions,\n getPartyAOpenPositionsQueryKey,\n getPartyAPendingQuotesQueryKey,\n getPendingQuotesQueryKey,\n getQuoteQueryKey,\n type ForceCancelQuoteParameters,\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 { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { invalidateAccountBalances, predicateMatch } from \"../utils\";\n\n/** Parameters for {@link useForceCancelQuote}. */\nexport type UseForceCancelQuoteParameters = WriteParameters;\n\n/** Result returned by the {@link useForceCancelQuote} mutation. */\nexport type ForceCancelQuoteResult = WriteResult;\n\n/** Return type of {@link useForceCancelQuote}. */\nexport type UseForceCancelQuoteReturnType = UseMutationResult<\n ForceCancelQuoteResult,\n SymmioRequestError,\n ForceCancelQuoteParameters\n>;\n\n/**\n * Force-cancel a stalled quote (`forceCancelQuote`, routed through the\n * AccountLayer `_call` proxy). Only valid once the quote is `CANCEL_PENDING`\n * (partyA already called `requestToCancelQuote` on a `LOCKED` order) **and** the\n * force-cancel cooldown has elapsed — see {@link useCoolDownsOfMA} (index 1) plus\n * the quote's `statusModifyTimestamp`. On success (after the receipt) the\n * subaccount's pending-quotes reads are invalidated so the order drops out.\n *\n * @example\n * ```tsx\n * const { mutate } = useForceCancelQuote();\n * mutate({ account: \"0xsub…\", quoteId: 42n });\n * ```\n */\nexport function useForceCancelQuote(parameters: UseForceCancelQuoteParameters = {}): UseForceCancelQuoteReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = forceCancelQuoteMutationOptions(config);\n\n return useMutation<ForceCancelQuoteResult, SymmioRequestError, ForceCancelQuoteParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({\n account: variables.account,\n quoteId: variables.quoteId,\n from: variables.from,\n simulateBeforeWrite: variables.simulateBeforeWrite,\n chainId: resolvedChainId,\n });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n // The force-cancelled quote leaves the pending set — refetch the pending\n // reads (full quotes + ids), the open positions for this partyA, and the\n // quote's own `getQuote` hydration (the read carrying `quoteStatus`) after the\n // receipt, so managed-quotes drops the now-terminal quote.\n const partial = { partyA: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingQuotesQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAPendingQuotesQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAOpenPositionsQueryKey, partial) });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getQuoteQueryKey, { quoteId: variables.quoteId }),\n });\n /**\n * A force-cancel refunds the open trading fee and releases both parties'\n * pending locked balances in the same transaction, so every balance read is now\n * stale.\n */\n invalidateAccountBalances(queryClient, {\n configKey: config.getChainConfigKey(variables.chainId ?? chainId),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;;AA6CA,SAAgB,EAAoB,IAA4C,CAAC,GAAkC;CACjH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAgC,CAAM;CAEnD,OAAO,EAAoF;EACzF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAQ7C,OAAO,EAAmB,GAAQ,MAPf,EAAK,WAAW;KACjC,SAAS,EAAU;KACnB,SAAS,EAAU;KACnB,MAAM,EAAU;KAChB,qBAAqB,EAAU;KAC/B,SAAS;IACX,CAAC,GACuC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAKjC,IAAM,IAAU,EAAE,QAAQ,EAAU,QAAQ;GAY5C,AAXA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA0B,CAAO,EAAE,CAAC,GACnG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC,GACzG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC,GACzG,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAkB,EAAE,SAAS,EAAU,QAAQ,CAAC,EAC5E,CAAC,GAMD,EAA0B,GAAa,EACrC,WAAW,EAAO,kBAAkB,EAAU,WAAW,CAAO,EAClE,CAAC;EACH;CACF,CAAC;AACH"}
@@ -0,0 +1,30 @@
1
+ import { ConfigParameter, ForceCloseEligibility, Quote } from '@symmio/trading-core';
2
+ /** The quote fields {@link useForceCloseEligibility} needs. */
3
+ export type ForceCloseEligibilityQuote = Pick<Quote, "quoteStatus" | "orderType" | "statusModifyTimestamp" | "deadline" | "symbolId">;
4
+ /** Parameters for {@link useForceCloseEligibility}. */
5
+ export type UseForceCloseEligibilityParameters = ConfigParameter & {
6
+ /** The quote (or a subset with the needed fields) to gate. */
7
+ quote?: ForceCloseEligibilityQuote;
8
+ };
9
+ /** Return type of {@link useForceCloseEligibility}. */
10
+ export type UseForceCloseEligibilityReturnType = ForceCloseEligibility & {
11
+ /** `true` while the force-close params are loading (eligibility not yet known). */
12
+ isLoading: boolean;
13
+ };
14
+ /**
15
+ * Live force-close eligibility for a quote — the button gate + cooldown
16
+ * countdown. Reads the market's force-close params ({@link useForceCloseParams})
17
+ * and runs the pure `checkForceCloseEligibility` against a 1-second clock, so
18
+ * `cooldownRemaining` ticks down and `eligible` flips on the moment the cooldown
19
+ * elapses, without a manual refresh. Send with {@link useForceClose}.
20
+ *
21
+ * Force close is a limit-order feature (majors / rasa), so it is never eligible
22
+ * on a solver that does not support limit orders.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * const { eligible, reason, cooldownRemaining } = useForceCloseEligibility({ quote });
27
+ * ```
28
+ */
29
+ export declare function useForceCloseEligibility(parameters?: UseForceCloseEligibilityParameters): UseForceCloseEligibilityReturnType;
30
+ //# sourceMappingURL=use-force-close-eligibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-close-eligibility.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-close-eligibility.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,KAAK,EACX,MAAM,sBAAsB,CAAC;AAK9B,+DAA+D;AAC/D,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,KAAK,EACL,aAAa,GAAG,WAAW,GAAG,uBAAuB,GAAG,UAAU,GAAG,UAAU,CAChF,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAAG;IACjE,8DAA8D;IAC9D,KAAK,CAAC,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,qBAAqB,GAAG;IACvE,mFAAmF;IACnF,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAIF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,kCAAuC,GAClD,kCAAkC,CA8BpC"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { useSupportsLimitOrder as e } from "../solvers/use-solver-capabilities.js";
3
+ import { useForceCloseParams as t } from "./use-force-close-params.js";
4
+ import { checkForceCloseEligibility as n } from "@symmio/trading-core";
5
+ import { useEffect as r, useMemo as i, useState as a } from "react";
6
+ //#region src/quotes/use-force-close-eligibility.ts
7
+ var o = {
8
+ eligible: !1,
9
+ cooldownRemaining: 0n
10
+ };
11
+ function s(s = {}) {
12
+ let { quote: c, config: l } = s, u = e({ config: l }), d = t({
13
+ symbolId: c?.symbolId ?? 0n,
14
+ config: l,
15
+ query: { enabled: c !== void 0 }
16
+ }), f = d.data, [p, m] = a(() => BigInt(Math.floor(Date.now() / 1e3)));
17
+ return r(() => {
18
+ let e = setInterval(() => m(BigInt(Math.floor(Date.now() / 1e3))), 1e3);
19
+ return () => clearInterval(e);
20
+ }, []), {
21
+ ...i(() => !u || !c || !f ? o : n({
22
+ quote: c,
23
+ firstCooldown: f.firstCooldown,
24
+ secondCooldown: f.secondCooldown,
25
+ minSigPeriod: f.minSigPeriod,
26
+ now: p
27
+ }), [
28
+ u,
29
+ c,
30
+ f,
31
+ p
32
+ ]),
33
+ isLoading: d.isLoading
34
+ };
35
+ }
36
+ //#endregion
37
+ export { s as useForceCloseEligibility };
38
+
39
+ //# sourceMappingURL=use-force-close-eligibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-close-eligibility.js","names":[],"sources":["../../src/quotes/use-force-close-eligibility.ts"],"sourcesContent":["\"use client\";\n\nimport {\n checkForceCloseEligibility,\n type ConfigParameter,\n type ForceCloseEligibility,\n type Quote,\n} from \"@symmio/trading-core\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useSupportsLimitOrder } from \"../solvers/use-solver-capabilities\";\nimport { useForceCloseParams } from \"./use-force-close-params\";\n\n/** The quote fields {@link useForceCloseEligibility} needs. */\nexport type ForceCloseEligibilityQuote = Pick<\n Quote,\n \"quoteStatus\" | \"orderType\" | \"statusModifyTimestamp\" | \"deadline\" | \"symbolId\"\n>;\n\n/** Parameters for {@link useForceCloseEligibility}. */\nexport type UseForceCloseEligibilityParameters = ConfigParameter & {\n /** The quote (or a subset with the needed fields) to gate. */\n quote?: ForceCloseEligibilityQuote;\n};\n\n/** Return type of {@link useForceCloseEligibility}. */\nexport type UseForceCloseEligibilityReturnType = ForceCloseEligibility & {\n /** `true` while the force-close params are loading (eligibility not yet known). */\n isLoading: boolean;\n};\n\nconst NOT_ELIGIBLE: ForceCloseEligibility = { eligible: false, cooldownRemaining: 0n };\n\n/**\n * Live force-close eligibility for a quote — the button gate + cooldown\n * countdown. Reads the market's force-close params ({@link useForceCloseParams})\n * and runs the pure `checkForceCloseEligibility` against a 1-second clock, so\n * `cooldownRemaining` ticks down and `eligible` flips on the moment the cooldown\n * elapses, without a manual refresh. Send with {@link useForceClose}.\n *\n * Force close is a limit-order feature (majors / rasa), so it is never eligible\n * on a solver that does not support limit orders.\n *\n * @example\n * ```tsx\n * const { eligible, reason, cooldownRemaining } = useForceCloseEligibility({ quote });\n * ```\n */\nexport function useForceCloseEligibility(\n parameters: UseForceCloseEligibilityParameters = {},\n): UseForceCloseEligibilityReturnType {\n const { quote, config } = parameters;\n const supportsLimit = useSupportsLimitOrder({ config });\n /** `0n` is a placeholder that is never fetched — the query stays disabled until a quote is present. */\n const paramsQuery = useForceCloseParams({\n symbolId: quote?.symbolId ?? 0n,\n config,\n query: { enabled: quote !== undefined },\n });\n const params = paramsQuery.data;\n\n const [nowSec, setNowSec] = useState(() => BigInt(Math.floor(Date.now() / 1000)));\n useEffect(() => {\n const id = setInterval(() => setNowSec(BigInt(Math.floor(Date.now() / 1000))), 1000);\n return () => clearInterval(id);\n }, []);\n\n const eligibility = useMemo<ForceCloseEligibility>(() => {\n // Force close only exists on limit-supporting solvers — never eligible otherwise.\n if (!supportsLimit || !quote || !params) return NOT_ELIGIBLE;\n return checkForceCloseEligibility({\n quote,\n firstCooldown: params.firstCooldown,\n secondCooldown: params.secondCooldown,\n minSigPeriod: params.minSigPeriod,\n now: nowSec,\n });\n }, [supportsLimit, quote, params, nowSec]);\n\n return { ...eligibility, isLoading: paramsQuery.isLoading };\n}\n"],"mappings":";;;;;;AA8BA,IAAM,IAAsC;CAAE,UAAU;CAAO,mBAAmB;AAAG;AAiBrF,SAAgB,EACd,IAAiD,CAAC,GACd;CACpC,IAAM,EAAE,UAAO,cAAW,GACpB,IAAgB,EAAsB,EAAE,UAAO,CAAC,GAEhD,IAAc,EAAoB;EACtC,UAAU,GAAO,YAAY;EAC7B;EACA,OAAO,EAAE,SAAS,MAAU,KAAA,EAAU;CACxC,CAAC,GACK,IAAS,EAAY,MAErB,CAAC,GAAQ,KAAa,QAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,CAAC,CAAC;CAkBhF,OAjBA,QAAgB;EACd,IAAM,IAAK,kBAAkB,EAAU,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,CAAC,CAAC,GAAG,GAAI;EACnF,aAAa,cAAc,CAAE;CAC/B,GAAG,CAAC,CAAC,GAcE;EAAE,GAZW,QAEd,CAAC,KAAiB,CAAC,KAAS,CAAC,IAAe,IACzC,EAA2B;GAChC;GACA,eAAe,EAAO;GACtB,gBAAgB,EAAO;GACvB,cAAc,EAAO;GACrB,KAAK;EACP,CAAC,GACA;GAAC;GAAe;GAAO;GAAQ;EAAM,CAE5B;EAAa,WAAW,EAAY;CAAU;AAC5D"}
@@ -0,0 +1,22 @@
1
+ import { ConfigParameter, GetForceCloseParamsData, GetForceCloseParamsOptions } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /** Parameters for {@link useForceCloseParams}: the core options (`symbolId`, chain id) plus an optional `config`. */
5
+ export type UseForceCloseParamsParameters = GetForceCloseParamsOptions & ConfigParameter;
6
+ /** Return type of {@link useForceCloseParams}. */
7
+ export type UseForceCloseParamsReturnType = UseQueryResult<GetForceCloseParamsData, SymmioRequestError>;
8
+ /**
9
+ * Read the protocol force-close params (cooldowns, price penalty, min signature
10
+ * period, and the symbol's gap ratio) for a market — the inputs to the
11
+ * force-close eligibility gate and price checks. These change rarely, so a long
12
+ * `staleTime` fits. `symbolId` is required; while it is still loading, pass a
13
+ * placeholder and gate with `query.enabled`. Errors are normalized to
14
+ * {@link SymmioRequestError}.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const { data: params } = useForceCloseParams({ symbolId: 1n });
19
+ * ```
20
+ */
21
+ export declare function useForceCloseParams(parameters: UseForceCloseParamsParameters): UseForceCloseParamsReturnType;
22
+ //# sourceMappingURL=use-force-close-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-close-params.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-close-params.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,qHAAqH;AACrH,MAAM,MAAM,6BAA6B,GAAG,0BAA0B,GAAG,eAAe,CAAC;AAEzF,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,cAAc,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC;AAExG;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,6BAA6B,GAAG,6BAA6B,CAkB5G"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { getForceCloseParamsQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/quotes/use-force-close-params.ts
8
+ function a(a) {
9
+ let o = t(a), s = e(), c = r(o, {
10
+ ...a,
11
+ chainId: a.chainId ?? s
12
+ });
13
+ return i({
14
+ ...c,
15
+ queryFn: async () => {
16
+ try {
17
+ return await c.queryFn();
18
+ } catch (e) {
19
+ throw n(e);
20
+ }
21
+ }
22
+ });
23
+ }
24
+ //#endregion
25
+ export { a as useForceCloseParams };
26
+
27
+ //# sourceMappingURL=use-force-close-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-close-params.js","names":[],"sources":["../../src/quotes/use-force-close-params.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getForceCloseParamsQueryOptions,\n type ConfigParameter,\n type GetForceCloseParamsData,\n type GetForceCloseParamsOptions,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useForceCloseParams}: the core options (`symbolId`, chain id) plus an optional `config`. */\nexport type UseForceCloseParamsParameters = GetForceCloseParamsOptions & ConfigParameter;\n\n/** Return type of {@link useForceCloseParams}. */\nexport type UseForceCloseParamsReturnType = UseQueryResult<GetForceCloseParamsData, SymmioRequestError>;\n\n/**\n * Read the protocol force-close params (cooldowns, price penalty, min signature\n * period, and the symbol's gap ratio) for a market — the inputs to the\n * force-close eligibility gate and price checks. These change rarely, so a long\n * `staleTime` fits. `symbolId` is required; while it is still loading, pass a\n * placeholder and gate with `query.enabled`. Errors are normalized to\n * {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data: params } = useForceCloseParams({ symbolId: 1n });\n * ```\n */\nexport function useForceCloseParams(parameters: UseForceCloseParamsParameters): UseForceCloseParamsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getForceCloseParamsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseForceCloseParamsReturnType;\n}\n"],"mappings":";;;;;;;AAiCA,SAAgB,EAAoB,GAA0E;CAC5G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAgC,GAAQ;EACtD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,30 @@
1
+ import { ForceCloseAutoParameters } from '@symmio/trading-core';
2
+ import { UseMutationResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ import { WriteParameters, WriteResult } from '../transactions/index.js';
5
+ /** Parameters for {@link useForceClose}. */
6
+ export type UseForceCloseParameters = WriteParameters;
7
+ /** Result returned by the {@link useForceClose} mutation. */
8
+ export type ForceCloseResult = WriteResult;
9
+ /** Return type of {@link useForceClose}. */
10
+ export type UseForceCloseReturnType = UseMutationResult<ForceCloseResult, SymmioRequestError, ForceCloseAutoParameters>;
11
+ /**
12
+ * Force-close a stalled `CLOSE_PENDING` **limit** position end-to-end from just a
13
+ * `quoteId` (`forceCloseAuto`): read the quote + force-close params, gate on
14
+ * eligibility, find a price window from reference candles, fetch the Muon
15
+ * `HighLowPriceSig`, preflight the gap, and send `forceClosePosition` through the
16
+ * AccountLayer `_call` proxy. On success (after the receipt) the subaccount's
17
+ * open-positions read is invalidated so the row updates.
18
+ *
19
+ * Throws (normalized) on ineligibility (`FORCE_CLOSE_NOT_ELIGIBLE`), the market
20
+ * not having hit the price (`FORCE_CLOSE_PRICE_NOT_REACHED`), or a contract
21
+ * revert. Gate the button first with {@link useForceCloseEligibility}.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * const forceClose = useForceClose();
26
+ * forceClose.mutate({ account: "0xsub…", quoteId: 42n });
27
+ * ```
28
+ */
29
+ export declare function useForceClose(parameters?: UseForceCloseParameters): UseForceCloseReturnType;
30
+ //# sourceMappingURL=use-force-close.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-close.d.ts","sourceRoot":"","sources":["../../src/quotes/use-force-close.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAEtD,6DAA6D;AAC7D,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAE3C,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,wBAAwB,CAAC,CAAC;AAExH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,UAAU,GAAE,uBAA4B,GAAG,uBAAuB,CA6B/F"}
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
6
+ import { predicateMatch as i } from "../utils/predicate-match.js";
7
+ import { forceCloseAutoMutationOptions as a, getPartyAOpenPositionsQueryKey as o } from "@symmio/trading-core";
8
+ import { useMutation as s, useQueryClient as c } from "@tanstack/react-query";
9
+ //#region src/quotes/use-force-close.ts
10
+ function l(l = {}) {
11
+ let u = t(l), d = e(), f = c(), p = a(u);
12
+ return s({
13
+ mutationKey: p.mutationKey,
14
+ mutationFn: async (e) => {
15
+ try {
16
+ let t = e.chainId ?? d;
17
+ return r(u, await p.mutationFn({
18
+ ...e,
19
+ chainId: t
20
+ }), {
21
+ chainId: t,
22
+ waitForReceipt: l.waitForReceipt,
23
+ confirmations: l.confirmations
24
+ });
25
+ } catch (e) {
26
+ throw n(e);
27
+ }
28
+ },
29
+ onSuccess: (e, t) => {
30
+ let n = { partyA: t.account };
31
+ f.invalidateQueries({ predicate: i(o, n) });
32
+ }
33
+ });
34
+ }
35
+ //#endregion
36
+ export { l as useForceClose };
37
+
38
+ //# sourceMappingURL=use-force-close.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-force-close.js","names":[],"sources":["../../src/quotes/use-force-close.ts"],"sourcesContent":["\"use client\";\n\nimport {\n forceCloseAutoMutationOptions,\n getPartyAOpenPositionsQueryKey,\n type ForceCloseAutoParameters,\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 { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/** Parameters for {@link useForceClose}. */\nexport type UseForceCloseParameters = WriteParameters;\n\n/** Result returned by the {@link useForceClose} mutation. */\nexport type ForceCloseResult = WriteResult;\n\n/** Return type of {@link useForceClose}. */\nexport type UseForceCloseReturnType = UseMutationResult<ForceCloseResult, SymmioRequestError, ForceCloseAutoParameters>;\n\n/**\n * Force-close a stalled `CLOSE_PENDING` **limit** position end-to-end from just a\n * `quoteId` (`forceCloseAuto`): read the quote + force-close params, gate on\n * eligibility, find a price window from reference candles, fetch the Muon\n * `HighLowPriceSig`, preflight the gap, and send `forceClosePosition` through the\n * AccountLayer `_call` proxy. On success (after the receipt) the subaccount's\n * open-positions read is invalidated so the row updates.\n *\n * Throws (normalized) on ineligibility (`FORCE_CLOSE_NOT_ELIGIBLE`), the market\n * not having hit the price (`FORCE_CLOSE_PRICE_NOT_REACHED`), or a contract\n * revert. Gate the button first with {@link useForceCloseEligibility}.\n *\n * @example\n * ```tsx\n * const forceClose = useForceClose();\n * forceClose.mutate({ account: \"0xsub…\", quoteId: 42n });\n * ```\n */\nexport function useForceClose(parameters: UseForceCloseParameters = {}): UseForceCloseReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = forceCloseAutoMutationOptions(config);\n\n return useMutation<ForceCloseResult, SymmioRequestError, ForceCloseAutoParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n // The force-close transitions the position — refetch the owning partyA's\n // open positions so the status updates.\n const partial = { partyA: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPartyAOpenPositionsQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA0CA,SAAgB,EAAc,IAAsC,CAAC,GAA4B;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAA8B,CAAM;CAEjD,OAAO,EAA4E;EACjF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GAGjC,IAAM,IAAU,EAAE,QAAQ,EAAU,QAAQ;GAC5C,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC;EAC3G;CACF,CAAC;AACH"}
@@ -1,4 +1,5 @@
1
- import { GroupQuotesOptions, QuoteGroup, QuoteGroupingStrategy, UnifiedQuote } from '@symmio/trading-core';
1
+ import { SubAccountIsolationType, GroupQuotesOptions, QuoteGroup, QuoteGroupingStrategy, UnifiedQuote } from '@symmio/trading-core';
2
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
2
3
  import { UseManagedQuotesParameters, UseManagedQuotesResult } from './use-managed-quotes.js';
3
4
  /**
4
5
  * Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}
@@ -6,10 +7,14 @@ import { UseManagedQuotesParameters, UseManagedQuotesResult } from './use-manage
6
7
  */
7
8
  export interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {
8
9
  /**
9
- * How to fold active positions into groups — a {@link SubAccountIsolationType}
10
- * (the built-in strategies) or a custom `{ keyOf }`. Defaults to
11
- * `MARKET_DIRECTION` (one group per market + side, the lowcap default).
10
+ * How to fold active positions into groups. The only
11
+ * {@link SubAccountIsolationType} accepted is `MARKET_DIRECTION` (one group per
12
+ * market + side), which is also the default — grouped positions are defined for
13
+ * that isolation alone. Passing any other isolation type throws
14
+ * `UNSUPPORTED_GROUPING_ISOLATION`; pass a custom `{ keyOf }` to fold on another
15
+ * dimension (`keyQuoteByMarket` / `keyQuotePerQuote` cover the common cases).
12
16
  *
17
+ * A custom `{ keyOf }` also opts out of the sub-account isolation check below.
13
18
  * Passing a fresh `{ keyOf }` object every render recomputes the groups every
14
19
  * render; memoize a custom strategy if that matters.
15
20
  */
@@ -19,13 +24,32 @@ export interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {
19
24
  }
20
25
  /**
21
26
  * Value returned by {@link useGroupedQuotes} — the full {@link useManagedQuotes}
22
- * result, plus the grouped positions and the flat pending orders.
27
+ * result, plus the grouped positions, the flat pending orders, and the
28
+ * isolation check that decides whether grouping applies at all.
23
29
  */
24
30
  export interface UseGroupedQuotesResult extends UseManagedQuotesResult {
25
- /** Active positions folded into {@link QuoteGroup}s under `strategy`, newest-first. */
31
+ /**
32
+ * Active positions folded into {@link QuoteGroup}s under `strategy`,
33
+ * newest-first. Always empty while {@link isGroupingSupported} is `false`.
34
+ */
26
35
  groups: QuoteGroup[];
27
36
  /** Resting/pending limit orders, kept flat (never grouped). */
28
37
  pending: UnifiedQuote[];
38
+ /**
39
+ * Isolation type of the sub-account owning `partyA` (resolved through the
40
+ * Virtual Account's parent when `partyA` is a VA). `undefined` while the read
41
+ * is in flight, when `partyA` is neither a sub-account nor a VA, and when a
42
+ * custom `{ keyOf }` strategy skipped the lookup.
43
+ */
44
+ isolationType?: SubAccountIsolationType;
45
+ /**
46
+ * `false` only when the owning sub-account's isolation is **known** and is not
47
+ * `MARKET_DIRECTION`. `true` while the isolation is unresolved, so a consumer
48
+ * gating on it never flashes an error state during the read.
49
+ */
50
+ isGroupingSupported: boolean;
51
+ /** The rejection behind `isGroupingSupported: false`; `null` otherwise. */
52
+ groupingError: SymmioRequestError | null;
29
53
  }
30
54
  /**
31
55
  * Managed quotes for one sub-account, folded into grouped positions.
@@ -36,19 +60,35 @@ export interface UseGroupedQuotesResult extends UseManagedQuotesResult {
36
60
  * Pending limit orders are returned flat in `pending` — the grouped-positions vs
37
61
  * open-orders split. The full flat list stays available on `quotes`.
38
62
  *
63
+ * **Grouping is a `MARKET_DIRECTION`-only feature.** It is the one isolation
64
+ * where a market + side cohort is a real on-chain unit (the AccountLayer
65
+ * allocates one Virtual Account per market + direction), so folding that cohort
66
+ * into a single row aggregates values that belong together — and group-level
67
+ * actions (group close, group TP/SL) act on quotes that really share a VA. This
68
+ * hook therefore resolves the isolation of the sub-account owning `partyA`
69
+ * (walking up from a Virtual Account to its parent when needed) and, when that
70
+ * isolation is anything else, returns **no groups** together with
71
+ * `isGroupingSupported: false` and a `groupingError` instead of silently folding
72
+ * unrelated positions. `quotes` and `pending` are untouched, so a consumer can
73
+ * still render flat rows for those accounts. The lookup is skipped for a custom
74
+ * `{ keyOf }` strategy — that caller has opted out of isolation-based grouping.
75
+ *
39
76
  * All grouping is pure and runs in a `useMemo`, so the heavy work is the
40
77
  * underlying reads, not the fold.
41
78
  *
42
79
  * @param parameters - Managed-quotes parameters plus `strategy` / `groupSort`.
43
- * @returns The managed-quotes result extended with `groups` and `pending`.
80
+ * @returns The managed-quotes result extended with `groups`, `pending`, and the isolation check.
81
+ * @throws {SymmError} `UNSUPPORTED_GROUPING_ISOLATION` when `strategy` is an
82
+ * isolation type other than `MARKET_DIRECTION`.
44
83
  *
45
84
  * @example
46
85
  * ```tsx
47
- * const { groups, pending, isLoading } = useGroupedQuotes({ partyA });
86
+ * const { groups, pending, isGroupingSupported, groupingError } = useGroupedQuotes({ partyA });
87
+ * if (!isGroupingSupported) return <FlatPositions rows={pending} note={groupingError?.message} />;
48
88
  * // groups[0].metrics.openQuantity, groups[0].metrics.weightedOpenPrice, …
49
89
  *
50
- * // group by market instead of market + side:
51
- * useGroupedQuotes({ partyA, strategy: SubAccountIsolationType.MARKET });
90
+ * // fold on another dimension — opts out of the isolation check:
91
+ * useGroupedQuotes({ partyA, strategy: { keyOf: keyQuoteByMarket } });
52
92
  * ```
53
93
  */
54
94
  export declare function useGroupedQuotes(parameters: UseGroupedQuotesParameters): UseGroupedQuotesResult;
@@ -1 +1 @@
1
- {"version":3,"file":"use-grouped-quotes.d.ts","sourceRoot":"","sources":["../../src/quotes/use-grouped-quotes.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAoB,KAAK,0BAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEtH;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,0BAA0B;IAC5E;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,0FAA0F;IAC1F,SAAS,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IACpE,uFAAuF;IACvF,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,+DAA+D;IAC/D,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,sBAAsB,CAW/F"}
1
+ {"version":3,"file":"use-grouped-quotes.d.ts","sourceRoot":"","sources":["../../src/quotes/use-grouped-quotes.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,uBAAuB,EAEvB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAoB,KAAK,0BAA0B,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAKtH;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,0BAA0B;IAC5E;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,0FAA0F;IAC1F,SAAS,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IACpE;;;OAGG;IACH,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,+DAA+D;IAC/D,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC;;;;OAIG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAC7B,2EAA2E;IAC3E,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,sBAAsB,CAwD/F"}
@@ -1,21 +1,47 @@
1
1
  "use client";
2
- import { useManagedQuotes as e } from "./use-managed-quotes.js";
3
- import { SubAccountIsolationType as t, groupQuotes as n, partitionQuotes as r } from "@symmio/trading-core";
4
- import { useMemo as i } from "react";
2
+ import { normalizeSymmError as e } from "../errors/normalize-symm-error.js";
3
+ import { useManagedQuotes as t } from "./use-managed-quotes.js";
4
+ import { useGroupingIsolation as n } from "./use-grouping-isolation.js";
5
+ import { SubAccountIsolationType as r, assertQuoteGroupingSupported as i, groupQuotes as a, partitionQuotes as o, supportsQuoteGrouping as s } from "@symmio/trading-core";
6
+ import { useEffect as c, useMemo as l, useRef as u } from "react";
5
7
  //#region src/quotes/use-grouped-quotes.ts
6
- function a(a) {
7
- let { strategy: o = t.MARKET_DIRECTION, groupSort: s, ...c } = a, l = e(c), { positions: u, pending: d } = i(() => r(l.quotes), [l.quotes]), f = i(() => n(u, o, s ? { sort: s } : void 0), [
8
- u,
9
- o,
10
- s
11
- ]);
12
- return {
13
- ...l,
14
- groups: f,
15
- pending: d
8
+ var d = [];
9
+ function f(f) {
10
+ let { strategy: p = r.MARKET_DIRECTION, groupSort: m, ...h } = f, g = t(h), _ = typeof p != "object", v = n({
11
+ account: f.partyA,
12
+ chainId: f.chainId,
13
+ enabled: _ && (f.enabled ?? !0)
14
+ }), y = !_ || v === void 0 || s(v), b = l(() => {
15
+ if (v === void 0 || y) return null;
16
+ try {
17
+ return i(v), null;
18
+ } catch (t) {
19
+ return e(t);
20
+ }
21
+ }, [v, y]), { positions: x, pending: S } = l(() => o(g.quotes), [g.quotes]), C = l(() => (typeof p != "object" && i(p), y ? a(x, p, m ? { sort: m } : void 0) : d), [
22
+ x,
23
+ p,
24
+ m,
25
+ y
26
+ ]), w = u(void 0);
27
+ return c(() => {
28
+ if (!b || process.env.NODE_ENV === "production") return;
29
+ let e = `${f.partyA}:${v}`;
30
+ w.current !== e && (w.current = e, console.warn(`[useGroupedQuotes] ${b.message} No groups are returned; read \`quotes\` instead.`));
31
+ }, [
32
+ b,
33
+ v,
34
+ f.partyA
35
+ ]), {
36
+ ...g,
37
+ groups: C,
38
+ pending: S,
39
+ isolationType: v,
40
+ isGroupingSupported: y,
41
+ groupingError: b
16
42
  };
17
43
  }
18
44
  //#endregion
19
- export { a as useGroupedQuotes };
45
+ export { f as useGroupedQuotes };
20
46
 
21
47
  //# sourceMappingURL=use-grouped-quotes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-grouped-quotes.js","names":[],"sources":["../../src/quotes/use-grouped-quotes.ts"],"sourcesContent":["\"use client\";\n\nimport {\n groupQuotes,\n partitionQuotes,\n SubAccountIsolationType,\n type GroupQuotesOptions,\n type QuoteGroup,\n type QuoteGroupingStrategy,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { useManagedQuotes, type UseManagedQuotesParameters, type UseManagedQuotesResult } from \"./use-managed-quotes\";\n\n/**\n * Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}\n * accepts, plus how to fold the resulting positions into groups.\n */\nexport interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {\n /**\n * How to fold active positions into groups — a {@link SubAccountIsolationType}\n * (the built-in strategies) or a custom `{ keyOf }`. Defaults to\n * `MARKET_DIRECTION` (one group per market + side, the lowcap default).\n *\n * Passing a fresh `{ keyOf }` object every render recomputes the groups every\n * render; memoize a custom strategy if that matters.\n */\n strategy?: QuoteGroupingStrategy;\n /** Optional group-ordering override forwarded to `groupQuotes` (default newest-first). */\n groupSort?: GroupQuotesOptions[\"sort\"];\n}\n\n/**\n * Value returned by {@link useGroupedQuotes} — the full {@link useManagedQuotes}\n * result, plus the grouped positions and the flat pending orders.\n */\nexport interface UseGroupedQuotesResult extends UseManagedQuotesResult {\n /** Active positions folded into {@link QuoteGroup}s under `strategy`, newest-first. */\n groups: QuoteGroup[];\n /** Resting/pending limit orders, kept flat (never grouped). */\n pending: UnifiedQuote[];\n}\n\n/**\n * Managed quotes for one sub-account, folded into grouped positions.\n *\n * Reads every quote source via {@link useManagedQuotes}, splits the merged list\n * into active positions and pending orders (`partitionQuotes`), then folds the\n * positions into {@link QuoteGroup}s under the chosen `strategy` (`groupQuotes`).\n * Pending limit orders are returned flat in `pending` — the grouped-positions vs\n * open-orders split. The full flat list stays available on `quotes`.\n *\n * All grouping is pure and runs in a `useMemo`, so the heavy work is the\n * underlying reads, not the fold.\n *\n * @param parameters - Managed-quotes parameters plus `strategy` / `groupSort`.\n * @returns The managed-quotes result extended with `groups` and `pending`.\n *\n * @example\n * ```tsx\n * const { groups, pending, isLoading } = useGroupedQuotes({ partyA });\n * // groups[0].metrics.openQuantity, groups[0].metrics.weightedOpenPrice, …\n *\n * // group by market instead of market + side:\n * useGroupedQuotes({ partyA, strategy: SubAccountIsolationType.MARKET });\n * ```\n */\nexport function useGroupedQuotes(parameters: UseGroupedQuotesParameters): UseGroupedQuotesResult {\n const { strategy = SubAccountIsolationType.MARKET_DIRECTION, groupSort, ...managedParameters } = parameters;\n const managed = useManagedQuotes(managedParameters);\n\n const { positions, pending } = useMemo(() => partitionQuotes(managed.quotes), [managed.quotes]);\n const groups = useMemo(\n () => groupQuotes(positions, strategy, groupSort ? { sort: groupSort } : undefined),\n [positions, strategy, groupSort],\n );\n\n return { ...managed, groups, pending };\n}\n"],"mappings":";;;;;AAmEA,SAAgB,EAAiB,GAAgE;CAC/F,IAAM,EAAE,cAAW,EAAwB,kBAAkB,cAAW,GAAG,MAAsB,GAC3F,IAAU,EAAiB,CAAiB,GAE5C,EAAE,cAAW,eAAY,QAAc,EAAgB,EAAQ,MAAM,GAAG,CAAC,EAAQ,MAAM,CAAC,GACxF,IAAS,QACP,EAAY,GAAW,GAAU,IAAY,EAAE,MAAM,EAAU,IAAI,KAAA,CAAS,GAClF;EAAC;EAAW;EAAU;CAAS,CACjC;CAEA,OAAO;EAAE,GAAG;EAAS;EAAQ;CAAQ;AACvC"}
1
+ {"version":3,"file":"use-grouped-quotes.js","names":[],"sources":["../../src/quotes/use-grouped-quotes.ts"],"sourcesContent":["\"use client\";\n\nimport {\n assertQuoteGroupingSupported,\n groupQuotes,\n partitionQuotes,\n SubAccountIsolationType,\n supportsQuoteGrouping,\n type GroupQuotesOptions,\n type QuoteGroup,\n type QuoteGroupingStrategy,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useGroupingIsolation } from \"./use-grouping-isolation\";\nimport { useManagedQuotes, type UseManagedQuotesParameters, type UseManagedQuotesResult } from \"./use-managed-quotes\";\n\n/** Stable empty result for the guarded case, so `groups` keeps its identity across renders. */\nconst NO_GROUPS: QuoteGroup[] = [];\n\n/**\n * Parameters for {@link useGroupedQuotes}. Everything {@link useManagedQuotes}\n * accepts, plus how to fold the resulting positions into groups.\n */\nexport interface UseGroupedQuotesParameters extends UseManagedQuotesParameters {\n /**\n * How to fold active positions into groups. The only\n * {@link SubAccountIsolationType} accepted is `MARKET_DIRECTION` (one group per\n * market + side), which is also the default — grouped positions are defined for\n * that isolation alone. Passing any other isolation type throws\n * `UNSUPPORTED_GROUPING_ISOLATION`; pass a custom `{ keyOf }` to fold on another\n * dimension (`keyQuoteByMarket` / `keyQuotePerQuote` cover the common cases).\n *\n * A custom `{ keyOf }` also opts out of the sub-account isolation check below.\n * Passing a fresh `{ keyOf }` object every render recomputes the groups every\n * render; memoize a custom strategy if that matters.\n */\n strategy?: QuoteGroupingStrategy;\n /** Optional group-ordering override forwarded to `groupQuotes` (default newest-first). */\n groupSort?: GroupQuotesOptions[\"sort\"];\n}\n\n/**\n * Value returned by {@link useGroupedQuotes} — the full {@link useManagedQuotes}\n * result, plus the grouped positions, the flat pending orders, and the\n * isolation check that decides whether grouping applies at all.\n */\nexport interface UseGroupedQuotesResult extends UseManagedQuotesResult {\n /**\n * Active positions folded into {@link QuoteGroup}s under `strategy`,\n * newest-first. Always empty while {@link isGroupingSupported} is `false`.\n */\n groups: QuoteGroup[];\n /** Resting/pending limit orders, kept flat (never grouped). */\n pending: UnifiedQuote[];\n /**\n * Isolation type of the sub-account owning `partyA` (resolved through the\n * Virtual Account's parent when `partyA` is a VA). `undefined` while the read\n * is in flight, when `partyA` is neither a sub-account nor a VA, and when a\n * custom `{ keyOf }` strategy skipped the lookup.\n */\n isolationType?: SubAccountIsolationType;\n /**\n * `false` only when the owning sub-account's isolation is **known** and is not\n * `MARKET_DIRECTION`. `true` while the isolation is unresolved, so a consumer\n * gating on it never flashes an error state during the read.\n */\n isGroupingSupported: boolean;\n /** The rejection behind `isGroupingSupported: false`; `null` otherwise. */\n groupingError: SymmioRequestError | null;\n}\n\n/**\n * Managed quotes for one sub-account, folded into grouped positions.\n *\n * Reads every quote source via {@link useManagedQuotes}, splits the merged list\n * into active positions and pending orders (`partitionQuotes`), then folds the\n * positions into {@link QuoteGroup}s under the chosen `strategy` (`groupQuotes`).\n * Pending limit orders are returned flat in `pending` — the grouped-positions vs\n * open-orders split. The full flat list stays available on `quotes`.\n *\n * **Grouping is a `MARKET_DIRECTION`-only feature.** It is the one isolation\n * where a market + side cohort is a real on-chain unit (the AccountLayer\n * allocates one Virtual Account per market + direction), so folding that cohort\n * into a single row aggregates values that belong together — and group-level\n * actions (group close, group TP/SL) act on quotes that really share a VA. This\n * hook therefore resolves the isolation of the sub-account owning `partyA`\n * (walking up from a Virtual Account to its parent when needed) and, when that\n * isolation is anything else, returns **no groups** together with\n * `isGroupingSupported: false` and a `groupingError` instead of silently folding\n * unrelated positions. `quotes` and `pending` are untouched, so a consumer can\n * still render flat rows for those accounts. The lookup is skipped for a custom\n * `{ keyOf }` strategy — that caller has opted out of isolation-based grouping.\n *\n * All grouping is pure and runs in a `useMemo`, so the heavy work is the\n * underlying reads, not the fold.\n *\n * @param parameters - Managed-quotes parameters plus `strategy` / `groupSort`.\n * @returns The managed-quotes result extended with `groups`, `pending`, and the isolation check.\n * @throws {SymmError} `UNSUPPORTED_GROUPING_ISOLATION` when `strategy` is an\n * isolation type other than `MARKET_DIRECTION`.\n *\n * @example\n * ```tsx\n * const { groups, pending, isGroupingSupported, groupingError } = useGroupedQuotes({ partyA });\n * if (!isGroupingSupported) return <FlatPositions rows={pending} note={groupingError?.message} />;\n * // groups[0].metrics.openQuantity, groups[0].metrics.weightedOpenPrice, …\n *\n * // fold on another dimension — opts out of the isolation check:\n * useGroupedQuotes({ partyA, strategy: { keyOf: keyQuoteByMarket } });\n * ```\n */\nexport function useGroupedQuotes(parameters: UseGroupedQuotesParameters): UseGroupedQuotesResult {\n const { strategy = SubAccountIsolationType.MARKET_DIRECTION, groupSort, ...managedParameters } = parameters;\n const managed = useManagedQuotes(managedParameters);\n\n /**\n * The sub-account check only applies to isolation-backed grouping; a custom\n * `{ keyOf }` groups on the consumer's own dimension, so no on-chain isolation\n * can contradict it and no read is worth firing.\n */\n const isIsolationStrategy = typeof strategy !== \"object\";\n const isolationType = useGroupingIsolation({\n account: parameters.partyA,\n chainId: parameters.chainId,\n enabled: isIsolationStrategy && (parameters.enabled ?? true),\n });\n\n /**\n * Unresolved isolation reads as supported — never flash a failure while loading.\n * A custom `{ keyOf }` strategy opted out of the isolation gate entirely, so it\n * is always supported regardless of any isolation the lookup might surface.\n */\n const isGroupingSupported =\n !isIsolationStrategy || isolationType === undefined || supportsQuoteGrouping(isolationType);\n\n const groupingError = useMemo<SymmioRequestError | null>(() => {\n if (isolationType === undefined || isGroupingSupported) return null;\n try {\n assertQuoteGroupingSupported(isolationType);\n return null;\n } catch (err) {\n return normalizeSymmError(err);\n }\n }, [isolationType, isGroupingSupported]);\n\n const { positions, pending } = useMemo(() => partitionQuotes(managed.quotes), [managed.quotes]);\n const groups = useMemo(() => {\n /** An unsupported `strategy` is a caller bug — throw even when the guard already blanked the groups. */\n if (typeof strategy !== \"object\") assertQuoteGroupingSupported(strategy);\n if (!isGroupingSupported) return NO_GROUPS;\n return groupQuotes(positions, strategy, groupSort ? { sort: groupSort } : undefined);\n }, [positions, strategy, groupSort, isGroupingSupported]);\n\n /**\n * Blanked groups are easy to misread as \"no positions\", so say why once per\n * account — in development only, and keyed so a re-render never re-logs.\n */\n const warnedRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!groupingError || process.env.NODE_ENV === \"production\") return;\n const key = `${parameters.partyA}:${isolationType}`;\n if (warnedRef.current === key) return;\n warnedRef.current = key;\n console.warn(`[useGroupedQuotes] ${groupingError.message} No groups are returned; read \\`quotes\\` instead.`);\n }, [groupingError, isolationType, parameters.partyA]);\n\n return { ...managed, groups, pending, isolationType, isGroupingSupported, groupingError };\n}\n"],"mappings":";;;;;;;AAoBA,IAAM,IAA0B,CAAC;AA8FjC,SAAgB,EAAiB,GAAgE;CAC/F,IAAM,EAAE,cAAW,EAAwB,kBAAkB,cAAW,GAAG,MAAsB,GAC3F,IAAU,EAAiB,CAAiB,GAO5C,IAAsB,OAAO,KAAa,UAC1C,IAAgB,EAAqB;EACzC,SAAS,EAAW;EACpB,SAAS,EAAW;EACpB,SAAS,MAAwB,EAAW,WAAW;CACzD,CAAC,GAOK,IACJ,CAAC,KAAuB,MAAkB,KAAA,KAAa,EAAsB,CAAa,GAEtF,IAAgB,QAAyC;EAC7D,IAAI,MAAkB,KAAA,KAAa,GAAqB,OAAO;EAC/D,IAAI;GAEF,OADA,EAA6B,CAAa,GACnC;EACT,SAAS,GAAK;GACZ,OAAO,EAAmB,CAAG;EAC/B;CACF,GAAG,CAAC,GAAe,CAAmB,CAAC,GAEjC,EAAE,cAAW,eAAY,QAAc,EAAgB,EAAQ,MAAM,GAAG,CAAC,EAAQ,MAAM,CAAC,GACxF,IAAS,SAET,OAAO,KAAa,YAAU,EAA6B,CAAQ,GAClE,IACE,EAAY,GAAW,GAAU,IAAY,EAAE,MAAM,EAAU,IAAI,KAAA,CAAS,IADlD,IAEhC;EAAC;EAAW;EAAU;EAAW;CAAmB,CAAC,GAMlD,IAAY,EAA2B,KAAA,CAAS;CAStD,OARA,QAAgB;EACd,IAAI,CAAC,KAAA,QAAA,IAAA,aAA0C,cAAc;EAC7D,IAAM,IAAM,GAAG,EAAW,OAAO,GAAG;EAChC,EAAU,YAAY,MAC1B,EAAU,UAAU,GACpB,QAAQ,KAAK,sBAAsB,EAAc,QAAQ,kDAAkD;CAC7G,GAAG;EAAC;EAAe;EAAe,EAAW;CAAM,CAAC,GAE7C;EAAE,GAAG;EAAS;EAAQ;EAAS;EAAe;EAAqB;CAAc;AAC1F"}