@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,30 @@
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 { getSolverCapabilities as n, supportsGroupClose as r, supportsLimitOrder as i } from "@symmio/trading-core";
5
+ //#region src/solvers/use-solver-capabilities.ts
6
+ function a(r = {}) {
7
+ let i = t(r), a = e();
8
+ return n(i, {
9
+ chainId: r.chainId ?? a,
10
+ solverId: r.solverId
11
+ });
12
+ }
13
+ function o(n = {}) {
14
+ let i = t(n), a = e();
15
+ return r(i, {
16
+ chainId: n.chainId ?? a,
17
+ solverId: n.solverId
18
+ });
19
+ }
20
+ function s(n = {}) {
21
+ let r = t(n), a = e();
22
+ return i(r, {
23
+ chainId: n.chainId ?? a,
24
+ solverId: n.solverId
25
+ });
26
+ }
27
+ //#endregion
28
+ export { a as useSolverCapabilities, o as useSupportsGroupClose, s as useSupportsLimitOrder };
29
+
30
+ //# sourceMappingURL=use-solver-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-solver-capabilities.js","names":[],"sources":["../../src/solvers/use-solver-capabilities.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverCapabilities,\n supportsGroupClose,\n supportsLimitOrder,\n type ConfigParameter,\n type SolverCapabilities,\n type SolverId,\n} from \"@symmio/trading-core\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Parameters for {@link useSolverCapabilities} / {@link useSupportsGroupClose}. */\nexport interface UseSolverCapabilitiesParameters extends ConfigParameter {\n /** Chain to check; defaults to the connected chain. */\n chainId?: number;\n /** Solver to check; defaults to the chain's default solver. */\n solverId?: SolverId;\n}\n\n/**\n * Resolve the target solver's {@link SolverCapabilities}. Use it to gate UI on\n * what the solver supports (e.g. hide the group-close flow when unsupported).\n *\n * @example\n * ```tsx\n * const { groupClose } = useSolverCapabilities();\n * if (!groupClose) return null;\n * ```\n */\nexport function useSolverCapabilities(parameters: UseSolverCapabilitiesParameters = {}): SolverCapabilities {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n return getSolverCapabilities(config, { chainId: parameters.chainId ?? chainId, solverId: parameters.solverId });\n}\n\n/**\n * Whether the target solver supports group close (close a market + side cohort\n * in one flow). Shorthand for `useSolverCapabilities().groupClose`; gate the\n * group-close toggle / step on it so rasa (cross-margin) hides it.\n */\nexport function useSupportsGroupClose(parameters: UseSolverCapabilitiesParameters = {}): boolean {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n return supportsGroupClose(config, { chainId: parameters.chainId ?? chainId, solverId: parameters.solverId });\n}\n\n/**\n * Whether the target solver supports limit orders (majors / rasa). Shorthand for\n * `useSolverCapabilities().limitOrder`; gate the limit-order form on it.\n */\nexport function useSupportsLimitOrder(parameters: UseSolverCapabilitiesParameters = {}): boolean {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n return supportsLimitOrder(config, { chainId: parameters.chainId ?? chainId, solverId: parameters.solverId });\n}\n"],"mappings":";;;;;AA+BA,SAAgB,EAAsB,IAA8C,CAAC,GAAuB;CAC1G,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB;CACjC,OAAO,EAAsB,GAAQ;EAAE,SAAS,EAAW,WAAW;EAAS,UAAU,EAAW;CAAS,CAAC;AAChH;AAOA,SAAgB,EAAsB,IAA8C,CAAC,GAAY;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB;CACjC,OAAO,EAAmB,GAAQ;EAAE,SAAS,EAAW,WAAW;EAAS,UAAU,EAAW;CAAS,CAAC;AAC7G;AAMA,SAAgB,EAAsB,IAA8C,CAAC,GAAY;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB;CACjC,OAAO,EAAmB,GAAQ;EAAE,SAAS,EAAW,WAAW;EAAS,UAAU,EAAW;CAAS,CAAC;AAC7G"}
@@ -0,0 +1,28 @@
1
+ import { ConfigParameter, GetSolverRevenueOptions, GetSolverRevenueReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /** Parameters for {@link useSolverRevenue}: the core query options plus an optional `config`. */
5
+ export type UseSolverRevenueParameters = GetSolverRevenueOptions & ConfigParameter;
6
+ /** Return type of {@link useSolverRevenue}: revenue totals for the window. */
7
+ export type UseSolverRevenueReturnType = UseQueryResult<GetSolverRevenueReturnType, SymmioRequestError>;
8
+ /**
9
+ * Read one market's revenue totals from the connected chain's solver.
10
+ *
11
+ * The result splits into a hedger-fee share and a funding share whose sum is
12
+ * `totalRevenue`, all as plain dollar numbers. `recordCount` separates "this
13
+ * window earned nothing" from "there is no data for this window".
14
+ *
15
+ * `symbolId` is required: the current solver generation serves revenue **per
16
+ * market only** — the protocol-wide `/revenue` aggregate no longer exists.
17
+ *
18
+ * Enigma-only; a rasa-kind solver fails with `UNSUPPORTED_BY_SOLVER`. Errors are
19
+ * normalized to {@link SymmioRequestError}.
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * const lifetime = useSolverRevenue({ symbolId: 1 });
24
+ * const day = useSolverRevenue({ symbolId: 1, timeRange: "24h" });
25
+ * ```
26
+ */
27
+ export declare function useSolverRevenue(parameters: UseSolverRevenueParameters): UseSolverRevenueReturnType;
28
+ //# sourceMappingURL=use-solver-revenue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-solver-revenue.d.ts","sourceRoot":"","sources":["../../src/solvers/use-solver-revenue.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,iGAAiG;AACjG,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,GAAG,eAAe,CAAC;AAEnF,8EAA8E;AAC9E,MAAM,MAAM,0BAA0B,GAAG,cAAc,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAExG;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,0BAA0B,CAkBnG"}
@@ -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 { getSolverRevenueQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/solvers/use-solver-revenue.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 useSolverRevenue };
26
+
27
+ //# sourceMappingURL=use-solver-revenue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-solver-revenue.js","names":[],"sources":["../../src/solvers/use-solver-revenue.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverRevenueQueryOptions,\n type ConfigParameter,\n type GetSolverRevenueOptions,\n type GetSolverRevenueReturnType,\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 useSolverRevenue}: the core query options plus an optional `config`. */\nexport type UseSolverRevenueParameters = GetSolverRevenueOptions & ConfigParameter;\n\n/** Return type of {@link useSolverRevenue}: revenue totals for the window. */\nexport type UseSolverRevenueReturnType = UseQueryResult<GetSolverRevenueReturnType, SymmioRequestError>;\n\n/**\n * Read one market's revenue totals from the connected chain's solver.\n *\n * The result splits into a hedger-fee share and a funding share whose sum is\n * `totalRevenue`, all as plain dollar numbers. `recordCount` separates \"this\n * window earned nothing\" from \"there is no data for this window\".\n *\n * `symbolId` is required: the current solver generation serves revenue **per\n * market only** — the protocol-wide `/revenue` aggregate no longer exists.\n *\n * Enigma-only; a rasa-kind solver fails with `UNSUPPORTED_BY_SOLVER`. Errors are\n * normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const lifetime = useSolverRevenue({ symbolId: 1 });\n * const day = useSolverRevenue({ symbolId: 1, timeRange: \"24h\" });\n * ```\n */\nexport function useSolverRevenue(parameters: UseSolverRevenueParameters): UseSolverRevenueReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getSolverRevenueQueryOptions(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 UseSolverRevenueReturnType;\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,EAAiB,GAAoE;CACnG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA6B,GAAQ;EACnD,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,2 @@
1
+ export * from './use-symbols.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { ConfigParameter, GetSymbolsOptions, GetSymbolsReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Parameters for {@link useSymbols}: the core query options plus an optional
6
+ * `config`.
7
+ */
8
+ export type UseSymbolsParameters = GetSymbolsOptions & ConfigParameter;
9
+ /** Return type of {@link useSymbols}. */
10
+ export type UseSymbolsReturnType = UseQueryResult<GetSymbolsReturnType, SymmioRequestError>;
11
+ /**
12
+ * Read the tradable symbol catalogue from the active chain's solver in one call.
13
+ * Surfaces a normalized row per symbol — id, name, precisions, leverage, fees,
14
+ * and per-side trading state — filtered and paged by the given parameters.
15
+ *
16
+ * Does not poll by default; pass `query.refetchInterval` to opt into polling.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const { data } = useSymbols({ search: "BTC" });
21
+ * const btc = data?.find((s) => s.name === "BTCUSDT");
22
+ * ```
23
+ */
24
+ export declare function useSymbols(parameters?: UseSymbolsParameters): UseSymbolsReturnType;
25
+ //# sourceMappingURL=use-symbols.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-symbols.d.ts","sourceRoot":"","sources":["../../src/symbols/use-symbols.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAEvE,yCAAyC;AACzC,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;AAE5F;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,UAAU,GAAE,oBAAyB,GAAG,oBAAoB,CAkBtF"}
@@ -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 { getSymbolsQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/symbols/use-symbols.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 useSymbols };
26
+
27
+ //# sourceMappingURL=use-symbols.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-symbols.js","names":[],"sources":["../../src/symbols/use-symbols.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSymbolsQueryOptions,\n type ConfigParameter,\n type GetSymbolsOptions,\n type GetSymbolsReturnType,\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/**\n * Parameters for {@link useSymbols}: the core query options plus an optional\n * `config`.\n */\nexport type UseSymbolsParameters = GetSymbolsOptions & ConfigParameter;\n\n/** Return type of {@link useSymbols}. */\nexport type UseSymbolsReturnType = UseQueryResult<GetSymbolsReturnType, SymmioRequestError>;\n\n/**\n * Read the tradable symbol catalogue from the active chain's solver in one call.\n * Surfaces a normalized row per symbol — id, name, precisions, leverage, fees,\n * and per-side trading state — filtered and paged by the given parameters.\n *\n * Does not poll by default; pass `query.refetchInterval` to opt into polling.\n *\n * @example\n * ```tsx\n * const { data } = useSymbols({ search: \"BTC\" });\n * const btc = data?.find((s) => s.name === \"BTCUSDT\");\n * ```\n */\nexport function useSymbols(parameters: UseSymbolsParameters = {}): UseSymbolsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getSymbolsQueryOptions(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 UseSymbolsReturnType;\n}\n"],"mappings":";;;;;;;AAoCA,SAAgB,EAAW,IAAmC,CAAC,GAAyB;CACtF,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAuB,GAAQ;EAC7C,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,33 @@
1
+ import { SearchTpSlOrdersReturnType, TpSlConditionalOrderType } from '@symmio/trading-core';
2
+ /** One side of one quote a run is still waiting on. */
3
+ export interface TpSlWaitingSide {
4
+ /** The quote's addressable id — on-chain, or the hedger temp id. */
5
+ quoteId: bigint;
6
+ /** Which side. */
7
+ side: TpSlConditionalOrderType;
8
+ /** What the wait is for: an order appearing, or an order disappearing. */
9
+ intent: "write" | "cancel";
10
+ /** For a cancel, the handler id that must be gone. */
11
+ cohQuoteId?: string;
12
+ }
13
+ /**
14
+ * Fold an account-scoped search response into the shared TP/SL store, on
15
+ * behalf of the sides a run is still waiting on.
16
+ *
17
+ * Three rules keep an account-wide page from doing damage:
18
+ *
19
+ * 1. **Rows are attributed per quote.** `toQuoteTpSl` ignores `quote_id` and
20
+ * folds whatever array it is handed into one pair, so the rows are grouped
21
+ * first — otherwise one leg's stop-loss would land on another leg.
22
+ * 2. **Only the waiting sides are written.** A page that lags on a side nobody
23
+ * asked about must not blank the live order sitting there.
24
+ * 3. **Absence is only meaningful on a complete page.** A truncated response
25
+ * proves nothing about what is missing, so it contributes positive rows only
26
+ * and cancels wait for a clean tick.
27
+ *
28
+ * @param waiting - The sides still confirming, from the run's live step list.
29
+ * @param snapshot - One account's search result.
30
+ * @returns The quote ids that were written.
31
+ */
32
+ export declare function applyTpSlSearchSnapshot(waiting: readonly TpSlWaitingSide[], snapshot: SearchTpSlOrdersReturnType): bigint[];
33
+ //# sourceMappingURL=apply-tpsl-search-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-tpsl-search-snapshot.d.ts","sourceRoot":"","sources":["../../src/tpsl/apply-tpsl-search-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAG/G,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,IAAI,EAAE,wBAAwB,CAAC;IAC/B,0EAA0E;IAC1E,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3B,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,QAAQ,EAAE,0BAA0B,GACnC,MAAM,EAAE,CAkBV"}
@@ -0,0 +1,51 @@
1
+ import { useTpSlStore as e } from "./tpsl-store.js";
2
+ //#region src/tpsl/apply-tpsl-search-snapshot.ts
3
+ function t(e) {
4
+ return e === "take_profit" ? "tp" : "sl";
5
+ }
6
+ function n(n, s) {
7
+ if (n.length === 0) return [];
8
+ let c = e.getState(), l = a(s.orders), u = [];
9
+ for (let [e, a] of o(n)) {
10
+ let n = i(l, e, a), o = a.filter((e) => r(e, n, s.isComplete));
11
+ o.length !== 0 && (c.setRowsForSides(e, n, o.map((e) => t(e.side))), u.push(e));
12
+ }
13
+ return u;
14
+ }
15
+ function r(e, t, n) {
16
+ let r = t.some((t) => t.conditional_order_type === e.side);
17
+ return e.intent === "write" ? r : n ? e.cohQuoteId === void 0 ? !r : !t.some((t) => t.conditional_order_type === e.side && t.coh_quote_id === e.cohQuoteId) : !1;
18
+ }
19
+ function i(t, n, r) {
20
+ let i = t.get(n);
21
+ if (i) return i;
22
+ let a = e.getState(), o = a.get(n);
23
+ for (let [e, n] of t) {
24
+ let t = a.get(e);
25
+ if (o !== void 0 && t !== void 0 && t === o) return n;
26
+ let i = r.map((e) => e.cohQuoteId).filter(Boolean);
27
+ if (i.length > 0 && n.some((e) => i.includes(e.coh_quote_id))) return n;
28
+ }
29
+ return [];
30
+ }
31
+ function a(e) {
32
+ let t = /* @__PURE__ */ new Map();
33
+ for (let n of e) {
34
+ if (n.quote_id === void 0 || n.quote_id === null) continue;
35
+ let e = BigInt(n.quote_id), r = t.get(e);
36
+ r ? r.push(n) : t.set(e, [n]);
37
+ }
38
+ return t;
39
+ }
40
+ function o(e) {
41
+ let t = /* @__PURE__ */ new Map();
42
+ for (let n of e) {
43
+ let e = t.get(n.quoteId);
44
+ e ? e.push(n) : t.set(n.quoteId, [n]);
45
+ }
46
+ return t;
47
+ }
48
+ //#endregion
49
+ export { n as applyTpSlSearchSnapshot };
50
+
51
+ //# sourceMappingURL=apply-tpsl-search-snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-tpsl-search-snapshot.js","names":[],"sources":["../../src/tpsl/apply-tpsl-search-snapshot.ts"],"sourcesContent":["import type { QuoteTpSlRow, SearchTpSlOrdersReturnType, TpSlConditionalOrderType } from \"@symmio/trading-core\";\nimport { useTpSlStore, type TpSlSideKey } from \"./tpsl-store\";\n\n/** One side of one quote a run is still waiting on. */\nexport interface TpSlWaitingSide {\n /** The quote's addressable id — on-chain, or the hedger temp id. */\n quoteId: bigint;\n /** Which side. */\n side: TpSlConditionalOrderType;\n /** What the wait is for: an order appearing, or an order disappearing. */\n intent: \"write\" | \"cancel\";\n /** For a cancel, the handler id that must be gone. */\n cohQuoteId?: string;\n}\n\n/** `tp` / `sl` for a conditional-order type. */\nfunction sideKeyOf(side: TpSlConditionalOrderType): TpSlSideKey {\n return side === \"take_profit\" ? \"tp\" : \"sl\";\n}\n\n/**\n * Fold an account-scoped search response into the shared TP/SL store, on\n * behalf of the sides a run is still waiting on.\n *\n * Three rules keep an account-wide page from doing damage:\n *\n * 1. **Rows are attributed per quote.** `toQuoteTpSl` ignores `quote_id` and\n * folds whatever array it is handed into one pair, so the rows are grouped\n * first — otherwise one leg's stop-loss would land on another leg.\n * 2. **Only the waiting sides are written.** A page that lags on a side nobody\n * asked about must not blank the live order sitting there.\n * 3. **Absence is only meaningful on a complete page.** A truncated response\n * proves nothing about what is missing, so it contributes positive rows only\n * and cancels wait for a clean tick.\n *\n * @param waiting - The sides still confirming, from the run's live step list.\n * @param snapshot - One account's search result.\n * @returns The quote ids that were written.\n */\nexport function applyTpSlSearchSnapshot(\n waiting: readonly TpSlWaitingSide[],\n snapshot: SearchTpSlOrdersReturnType,\n): bigint[] {\n if (waiting.length === 0) return [];\n const store = useTpSlStore.getState();\n const byQuoteId = groupRowsByQuoteId(snapshot.orders);\n const written: bigint[] = [];\n\n for (const [quoteId, sides] of groupWaitingByQuote(waiting)) {\n const rows = rowsForQuote(byQuoteId, quoteId, sides);\n const applicable = sides.filter((entry) => isSideApplicable(entry, rows, snapshot.isComplete));\n if (applicable.length === 0) continue;\n store.setRowsForSides(\n quoteId,\n rows,\n applicable.map((entry) => sideKeyOf(entry.side)),\n );\n written.push(quoteId);\n }\n return written;\n}\n\n/**\n * Whether this tick may speak for a side.\n *\n * A write is applied whenever its row is present — that is the evidence the\n * store's own guard then checks.\n *\n * A cancel is applied only from a complete page on which **this side's** order\n * is gone. The handler id alone cannot decide it: this deployment issues one\n * `coh_quote_id` per quote, so cancelling a take-profit while the stop-loss\n * stays live leaves that id on the surviving row — matching on the id alone\n * would keep the cancel unconfirmed until it timed out, having actually\n * succeeded. Pairing the id with the side keeps the check honest whichever way\n * the handler assigns ids.\n */\nfunction isSideApplicable(entry: TpSlWaitingSide, rows: readonly QuoteTpSlRow[], isComplete: boolean): boolean {\n const present = rows.some((row) => row.conditional_order_type === entry.side);\n if (entry.intent === \"write\") return present;\n if (!isComplete) return false;\n if (entry.cohQuoteId !== undefined) {\n return !rows.some((row) => row.conditional_order_type === entry.side && row.coh_quote_id === entry.cohQuoteId);\n }\n return !present;\n}\n\n/**\n * The rows belonging to one quote.\n *\n * Matched by `quote_id` first, then — for a quote the handler still keys under\n * an id this client has not linked yet — by the handler id a waiting cancel is\n * targeting. Both lookups must resolve to something real; comparing two unknown\n * ids would attribute a foreign row to this leg.\n */\nfunction rowsForQuote(\n byQuoteId: Map<bigint, QuoteTpSlRow[]>,\n quoteId: bigint,\n sides: readonly TpSlWaitingSide[],\n): QuoteTpSlRow[] {\n const direct = byQuoteId.get(quoteId);\n if (direct) return direct;\n const store = useTpSlStore.getState();\n const target = store.get(quoteId);\n for (const [rowQuoteId, rows] of byQuoteId) {\n const linked = store.get(rowQuoteId);\n if (target !== undefined && linked !== undefined && linked === target) return rows;\n const expected = sides.map((entry) => entry.cohQuoteId).filter(Boolean);\n if (expected.length > 0 && rows.some((row) => expected.includes(row.coh_quote_id))) return rows;\n }\n return [];\n}\n\n/** Group a page's rows by their on-chain quote id. */\nfunction groupRowsByQuoteId(rows: readonly QuoteTpSlRow[]): Map<bigint, QuoteTpSlRow[]> {\n const grouped = new Map<bigint, QuoteTpSlRow[]>();\n for (const row of rows) {\n if (row.quote_id === undefined || row.quote_id === null) continue;\n const id = BigInt(row.quote_id);\n const bucket = grouped.get(id);\n if (bucket) bucket.push(row);\n else grouped.set(id, [row]);\n }\n return grouped;\n}\n\n/** Group the waiting sides by the quote they belong to. */\nfunction groupWaitingByQuote(waiting: readonly TpSlWaitingSide[]): Map<bigint, TpSlWaitingSide[]> {\n const grouped = new Map<bigint, TpSlWaitingSide[]>();\n for (const entry of waiting) {\n const bucket = grouped.get(entry.quoteId);\n if (bucket) bucket.push(entry);\n else grouped.set(entry.quoteId, [entry]);\n }\n return grouped;\n}\n"],"mappings":";;AAgBA,SAAS,EAAU,GAA6C;CAC9D,OAAO,MAAS,gBAAgB,OAAO;AACzC;AAqBA,SAAgB,EACd,GACA,GACU;CACV,IAAI,EAAQ,WAAW,GAAG,OAAO,CAAC;CAClC,IAAM,IAAQ,EAAa,SAAS,GAC9B,IAAY,EAAmB,EAAS,MAAM,GAC9C,IAAoB,CAAC;CAE3B,KAAK,IAAM,CAAC,GAAS,MAAU,EAAoB,CAAO,GAAG;EAC3D,IAAM,IAAO,EAAa,GAAW,GAAS,CAAK,GAC7C,IAAa,EAAM,QAAQ,MAAU,EAAiB,GAAO,GAAM,EAAS,UAAU,CAAC;EACzF,EAAW,WAAW,MAC1B,EAAM,gBACJ,GACA,GACA,EAAW,KAAK,MAAU,EAAU,EAAM,IAAI,CAAC,CACjD,GACA,EAAQ,KAAK,CAAO;CACtB;CACA,OAAO;AACT;AAgBA,SAAS,EAAiB,GAAwB,GAA+B,GAA8B;CAC7G,IAAM,IAAU,EAAK,MAAM,MAAQ,EAAI,2BAA2B,EAAM,IAAI;CAM5E,OALI,EAAM,WAAW,UAAgB,IAChC,IACD,EAAM,eAAe,KAAA,IAGlB,CAAC,IAFC,CAAC,EAAK,MAAM,MAAQ,EAAI,2BAA2B,EAAM,QAAQ,EAAI,iBAAiB,EAAM,UAAU,IAFvF;AAK1B;AAUA,SAAS,EACP,GACA,GACA,GACgB;CAChB,IAAM,IAAS,EAAU,IAAI,CAAO;CACpC,IAAI,GAAQ,OAAO;CACnB,IAAM,IAAQ,EAAa,SAAS,GAC9B,IAAS,EAAM,IAAI,CAAO;CAChC,KAAK,IAAM,CAAC,GAAY,MAAS,GAAW;EAC1C,IAAM,IAAS,EAAM,IAAI,CAAU;EACnC,IAAI,MAAW,KAAA,KAAa,MAAW,KAAA,KAAa,MAAW,GAAQ,OAAO;EAC9E,IAAM,IAAW,EAAM,KAAK,MAAU,EAAM,UAAU,EAAE,OAAO,OAAO;EACtE,IAAI,EAAS,SAAS,KAAK,EAAK,MAAM,MAAQ,EAAS,SAAS,EAAI,YAAY,CAAC,GAAG,OAAO;CAC7F;CACA,OAAO,CAAC;AACV;AAGA,SAAS,EAAmB,GAA4D;CACtF,IAAM,oBAAU,IAAI,IAA4B;CAChD,KAAK,IAAM,KAAO,GAAM;EACtB,IAAI,EAAI,aAAa,KAAA,KAAa,EAAI,aAAa,MAAM;EACzD,IAAM,IAAK,OAAO,EAAI,QAAQ,GACxB,IAAS,EAAQ,IAAI,CAAE;EAC7B,AAAI,IAAQ,EAAO,KAAK,CAAG,IACtB,EAAQ,IAAI,GAAI,CAAC,CAAG,CAAC;CAC5B;CACA,OAAO;AACT;AAGA,SAAS,EAAoB,GAAqE;CAChG,IAAM,oBAAU,IAAI,IAA+B;CACnD,KAAK,IAAM,KAAS,GAAS;EAC3B,IAAM,IAAS,EAAQ,IAAI,EAAM,OAAO;EACxC,AAAI,IAAQ,EAAO,KAAK,CAAK,IACxB,EAAQ,IAAI,EAAM,SAAS,CAAC,CAAK,CAAC;CACzC;CACA,OAAO;AACT"}
@@ -0,0 +1,77 @@
1
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
2
+ /**
3
+ * How long a grouped run waits for confirmation before giving up, in
4
+ * milliseconds.
5
+ *
6
+ * Sized to cover both halves of the wait: the report owns the first
7
+ * `TPSL_FALLBACK_POLL_DELAY_MS` (30s) alone, and the fallback sweep then reads
8
+ * the handler every couple of seconds for the remainder. Cutting this short
9
+ * would fail steps the sweep had barely begun to check.
10
+ */
11
+ export declare const DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS = 60000;
12
+ /**
13
+ * How long the fallback refetch gets to land before the run gives up on the
14
+ * steps that are still unconfirmed, in milliseconds.
15
+ */
16
+ export declare const TPSL_CONFIRMATION_REFETCH_GRACE_MS = 5000;
17
+ /** Options for {@link awaitTpSlConfirmation}. */
18
+ export interface AwaitTpSlConfirmationOptions {
19
+ /** Reconcile the run's steps against the store. Called on every store change. */
20
+ settle: () => void;
21
+ /** Whether any step is still waiting. Read straight after `settle`. */
22
+ hasPending: () => boolean;
23
+ /** Refetch the handler's rows — the fallback when no report arrives. */
24
+ onTimeout: () => void;
25
+ /** Give up on whatever is still pending after the fallback had its grace window. */
26
+ onExpire: () => void;
27
+ /**
28
+ * Called once, only when there is genuinely something to wait for. Return a
29
+ * disposer to tear down whatever it started.
30
+ *
31
+ * The seam the fallback sweep hangs off: it starts when the wait starts and
32
+ * is disposed by the same `finish()` that resolves the wait, so it cannot
33
+ * outlive the run — including when the component that began the run has
34
+ * unmounted. Throwing from either the hook or its disposer is swallowed; this
35
+ * function's contract is that it never rejects.
36
+ */
37
+ onWait?: () => (() => void) | void;
38
+ /** Report deadline. Defaults to {@link DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS}. */
39
+ timeoutMs?: number;
40
+ /**
41
+ * Fallback grace window. Defaults to {@link TPSL_CONFIRMATION_REFETCH_GRACE_MS},
42
+ * capped at `timeoutMs` — a caller who only waits a moment for the report
43
+ * does not then wait longer than that for the refetch.
44
+ */
45
+ graceMs?: number;
46
+ }
47
+ /**
48
+ * Resolve once every step of a TP/SL run has been confirmed — or once the run
49
+ * has stopped waiting for the ones that never were.
50
+ *
51
+ * The wait is driven by the shared TP/SL store rather than by a React effect,
52
+ * so it survives the component unmounting mid-run (a trader closing the modal)
53
+ * and still terminates. Two deadlines bound it: at `timeoutMs` the handler's
54
+ * rows are refetched, and `graceMs` later whatever is still pending is failed.
55
+ *
56
+ * @param options - The run's reconcile/pending probes and its two fallbacks.
57
+ * @returns Resolves when nothing is pending. Never rejects.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * await awaitTpSlConfirmation({
62
+ * settle: () => reconcileSteps(),
63
+ * hasPending: () => runRef.current.steps.some((step) => step.status === "confirming"),
64
+ * onTimeout: () => void invalidateTpSlReads(queryClient, ids),
65
+ * onExpire: () => failPendingSteps(),
66
+ * });
67
+ * ```
68
+ */
69
+ export declare function awaitTpSlConfirmation(options: AwaitTpSlConfirmationOptions): Promise<void>;
70
+ /**
71
+ * `SymmioRequestError.code` of a step the handler accepted but never reported
72
+ * on. Distinguishes "we stopped waiting" from "the request was rejected".
73
+ */
74
+ export declare const TPSL_CONFIRMATION_TIMEOUT_CODE = "TPSL_CONFIRMATION_TIMEOUT";
75
+ /** The error a step carries when the handler never confirmed it. */
76
+ export declare function tpslConfirmationTimeoutError(): SymmioRequestError;
77
+ //# sourceMappingURL=await-tpsl-confirmation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"await-tpsl-confirmation.d.ts","sourceRoot":"","sources":["../../src/tpsl/await-tpsl-confirmation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,QAAS,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,kCAAkC,OAAQ,CAAC;AAExD,iDAAiD;AACjD,MAAM,WAAW,4BAA4B;IAC3C,iFAAiF;IACjF,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,uEAAuE;IACvE,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,wEAAwE;IACxE,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,oFAAoF;IACpF,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IACnC,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAqD1F;AAED;;;GAGG;AACH,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E,oEAAoE;AACpE,wBAAgB,4BAA4B,IAAI,kBAAkB,CAMjE"}
@@ -0,0 +1,42 @@
1
+ import { SymmioRequestError as e } from "../errors/symmio-request-error.js";
2
+ import { useTpSlStore as t } from "./tpsl-store.js";
3
+ //#region src/tpsl/await-tpsl-confirmation.ts
4
+ var n = 6e4, r = 5e3;
5
+ function i(e) {
6
+ let { settle: i, hasPending: a, onTimeout: o, onExpire: s, onWait: c, timeoutMs: l = n, graceMs: u = Math.min(r, l) } = e;
7
+ return i(), a() ? new Promise((e) => {
8
+ let n = !1, r, d;
9
+ try {
10
+ d = c?.();
11
+ } catch {
12
+ d = void 0;
13
+ }
14
+ let f = () => {
15
+ if (!n) {
16
+ n = !0, p(), clearTimeout(m), r !== void 0 && clearTimeout(r);
17
+ try {
18
+ d?.();
19
+ } catch {}
20
+ e();
21
+ }
22
+ }, p = t.subscribe(() => {
23
+ i(), a() || f();
24
+ }), m = setTimeout(() => {
25
+ o(), r = setTimeout(() => {
26
+ s(), f();
27
+ }, u);
28
+ }, l);
29
+ }) : Promise.resolve();
30
+ }
31
+ var a = "TPSL_CONFIRMATION_TIMEOUT";
32
+ function o() {
33
+ return new e({
34
+ kind: "sdk",
35
+ code: a,
36
+ message: "The handler never confirmed this order. Check the position's exits before retrying."
37
+ });
38
+ }
39
+ //#endregion
40
+ export { n as DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS, a as TPSL_CONFIRMATION_TIMEOUT_CODE, i as awaitTpSlConfirmation, o as tpslConfirmationTimeoutError };
41
+
42
+ //# sourceMappingURL=await-tpsl-confirmation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"await-tpsl-confirmation.js","names":[],"sources":["../../src/tpsl/await-tpsl-confirmation.ts"],"sourcesContent":["import { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useTpSlStore } from \"./tpsl-store\";\n\n/**\n * How long a grouped run waits for confirmation before giving up, in\n * milliseconds.\n *\n * Sized to cover both halves of the wait: the report owns the first\n * `TPSL_FALLBACK_POLL_DELAY_MS` (30s) alone, and the fallback sweep then reads\n * the handler every couple of seconds for the remainder. Cutting this short\n * would fail steps the sweep had barely begun to check.\n */\nexport const DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS = 60_000;\n\n/**\n * How long the fallback refetch gets to land before the run gives up on the\n * steps that are still unconfirmed, in milliseconds.\n */\nexport const TPSL_CONFIRMATION_REFETCH_GRACE_MS = 5_000;\n\n/** Options for {@link awaitTpSlConfirmation}. */\nexport interface AwaitTpSlConfirmationOptions {\n /** Reconcile the run's steps against the store. Called on every store change. */\n settle: () => void;\n /** Whether any step is still waiting. Read straight after `settle`. */\n hasPending: () => boolean;\n /** Refetch the handler's rows — the fallback when no report arrives. */\n onTimeout: () => void;\n /** Give up on whatever is still pending after the fallback had its grace window. */\n onExpire: () => void;\n /**\n * Called once, only when there is genuinely something to wait for. Return a\n * disposer to tear down whatever it started.\n *\n * The seam the fallback sweep hangs off: it starts when the wait starts and\n * is disposed by the same `finish()` that resolves the wait, so it cannot\n * outlive the run — including when the component that began the run has\n * unmounted. Throwing from either the hook or its disposer is swallowed; this\n * function's contract is that it never rejects.\n */\n onWait?: () => (() => void) | void;\n /** Report deadline. Defaults to {@link DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS}. */\n timeoutMs?: number;\n /**\n * Fallback grace window. Defaults to {@link TPSL_CONFIRMATION_REFETCH_GRACE_MS},\n * capped at `timeoutMs` — a caller who only waits a moment for the report\n * does not then wait longer than that for the refetch.\n */\n graceMs?: number;\n}\n\n/**\n * Resolve once every step of a TP/SL run has been confirmed — or once the run\n * has stopped waiting for the ones that never were.\n *\n * The wait is driven by the shared TP/SL store rather than by a React effect,\n * so it survives the component unmounting mid-run (a trader closing the modal)\n * and still terminates. Two deadlines bound it: at `timeoutMs` the handler's\n * rows are refetched, and `graceMs` later whatever is still pending is failed.\n *\n * @param options - The run's reconcile/pending probes and its two fallbacks.\n * @returns Resolves when nothing is pending. Never rejects.\n *\n * @example\n * ```ts\n * await awaitTpSlConfirmation({\n * settle: () => reconcileSteps(),\n * hasPending: () => runRef.current.steps.some((step) => step.status === \"confirming\"),\n * onTimeout: () => void invalidateTpSlReads(queryClient, ids),\n * onExpire: () => failPendingSteps(),\n * });\n * ```\n */\nexport function awaitTpSlConfirmation(options: AwaitTpSlConfirmationOptions): Promise<void> {\n const {\n settle,\n hasPending,\n onTimeout,\n onExpire,\n onWait,\n timeoutMs = DEFAULT_TPSL_CONFIRMATION_TIMEOUT_MS,\n graceMs = Math.min(TPSL_CONFIRMATION_REFETCH_GRACE_MS, timeoutMs),\n } = options;\n\n settle();\n if (!hasPending()) return Promise.resolve();\n\n return new Promise<void>((resolve) => {\n let settled = false;\n let graceTimer: ReturnType<typeof setTimeout> | undefined;\n\n /** Started only now that the wait is real; disposed on every exit path. */\n let disposeWait: (() => void) | void;\n try {\n disposeWait = onWait?.();\n } catch {\n disposeWait = undefined;\n }\n\n const finish = () => {\n if (settled) return;\n settled = true;\n unsubscribe();\n clearTimeout(deadline);\n if (graceTimer !== undefined) clearTimeout(graceTimer);\n try {\n disposeWait?.();\n } catch {\n // A failing disposer must not turn a resolved wait into a rejection.\n }\n resolve();\n };\n\n const unsubscribe = useTpSlStore.subscribe(() => {\n settle();\n if (!hasPending()) finish();\n });\n\n const deadline = setTimeout(() => {\n onTimeout();\n graceTimer = setTimeout(() => {\n onExpire();\n finish();\n }, graceMs);\n }, timeoutMs);\n });\n}\n\n/**\n * `SymmioRequestError.code` of a step the handler accepted but never reported\n * on. Distinguishes \"we stopped waiting\" from \"the request was rejected\".\n */\nexport const TPSL_CONFIRMATION_TIMEOUT_CODE = \"TPSL_CONFIRMATION_TIMEOUT\";\n\n/** The error a step carries when the handler never confirmed it. */\nexport function tpslConfirmationTimeoutError(): SymmioRequestError {\n return new SymmioRequestError({\n kind: \"sdk\",\n code: TPSL_CONFIRMATION_TIMEOUT_CODE,\n message: \"The handler never confirmed this order. Check the position's exits before retrying.\",\n });\n}\n"],"mappings":";;;AAYA,IAAa,IAAuC,KAMvC,IAAqC;AAuDlD,SAAgB,EAAsB,GAAsD;CAC1F,IAAM,EACJ,WACA,eACA,cACA,aACA,WACA,eAAY,GACZ,aAAU,KAAK,IAAI,GAAoC,CAAS,MAC9D;CAKJ,OAHA,EAAO,GACF,EAAW,IAET,IAAI,SAAe,MAAY;EACpC,IAAI,IAAU,IACV,GAGA;EACJ,IAAI;GACF,IAAc,IAAS;EACzB,QAAQ;GACN,IAAc,KAAA;EAChB;EAEA,IAAM,UAAe;GACf,QAIJ;IAHA,IAAU,IACV,EAAY,GACZ,aAAa,CAAQ,GACjB,MAAe,KAAA,KAAW,aAAa,CAAU;IACrD,IAAI;KACF,IAAc;IAChB,QAAQ,CAER;IACA,EAAQ;GAN6C;EAOvD,GAEM,IAAc,EAAa,gBAAgB;GAE/C,AADA,EAAO,GACF,EAAW,KAAG,EAAO;EAC5B,CAAC,GAEK,IAAW,iBAAiB;GAEhC,AADA,EAAU,GACV,IAAa,iBAAiB;IAE5B,AADA,EAAS,GACT,EAAO;GACT,GAAG,CAAO;EACZ,GAAG,CAAS;CACd,CAAC,IAxCyB,QAAQ,QAAQ;AAyC5C;AAMA,IAAa,IAAiC;AAG9C,SAAgB,IAAmD;CACjE,OAAO,IAAI,EAAmB;EAC5B,MAAM;EACN,MAAM;EACN,SAAS;CACX,CAAC;AACH"}
@@ -1,9 +1,20 @@
1
+ export * from './apply-tpsl-search-snapshot.js';
2
+ export * from './await-tpsl-confirmation.js';
3
+ export * from './invalidate-tpsl.js';
1
4
  export * from './to-quote-tpsl.js';
5
+ export * from './tpsl-fallback-poll.js';
2
6
  export * from './tpsl-store.js';
7
+ export * from './use-delete-quote-group-tpsl.js';
3
8
  export * from './use-delete-quote-tpsl.js';
9
+ export * from './use-quote-group-tpsl.js';
10
+ export * from './use-quote-group-tpsl-editor.js';
4
11
  export * from './use-quote-tpsl.js';
12
+ export * from './use-search-tpsl-orders.js';
13
+ export * from './use-set-quote-group-tpsl.js';
5
14
  export * from './use-set-quote-tpsl.js';
6
15
  export * from './use-tpsl-config.js';
7
16
  export * from './use-tpsl-signing-spec.js';
17
+ export * from './use-tpsl-supported.js';
18
+ export * from './use-watch-tpsl-accounts.js';
8
19
  export * from './use-watch-tpsl-notifications.js';
9
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tpsl/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tpsl/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ /**
3
+ * Refetch the folded TP/SL reads for the given quotes.
4
+ *
5
+ * Call this after a successful set or cancel: the handler's REST rows are the
6
+ * authoritative state, so refetching them overwrites the optimistic
7
+ * `confirming` overlay `markConfirming` left in the store. Without it a box
8
+ * resolves only when the live WebSocket frame arrives — and stays stuck
9
+ * `confirming` (or keeps showing a cancelled value) whenever that frame is
10
+ * missed.
11
+ *
12
+ * The `getQuoteTpSl` query key is matched by **shape**, not through
13
+ * `getQuoteTpSlQueryKey`, because that factory throws on a partial (it
14
+ * stringifies `quoteId`). Only the passed quotes' reads are invalidated, so an
15
+ * unrelated market's TP/SL box is never disturbed.
16
+ *
17
+ * @param queryClient - The active TanStack query client.
18
+ * @param quoteIds - On-chain quote ids whose TP/SL reads should refetch. `0n`
19
+ * sentinels are ignored.
20
+ * @returns Resolves when the matching queries have been marked stale.
21
+ */
22
+ export declare function invalidateTpSlReads(queryClient: QueryClient, quoteIds: readonly bigint[]): Promise<void>;
23
+ //# sourceMappingURL=invalidate-tpsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidate-tpsl.d.ts","sourceRoot":"","sources":["../../src/tpsl/invalidate-tpsl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWxG"}
@@ -0,0 +1,14 @@
1
+ //#region src/tpsl/invalidate-tpsl.ts
2
+ function e(e, t) {
3
+ let n = new Set(t.filter((e) => e !== 0n).map((e) => e.toString()));
4
+ return n.size === 0 ? Promise.resolve() : e.invalidateQueries({ predicate: (e) => {
5
+ let t = e.queryKey;
6
+ if (!Array.isArray(t) || t[0] !== "getQuoteTpSl") return !1;
7
+ let r = t[1];
8
+ return typeof r?.quoteId == "string" && n.has(r.quoteId);
9
+ } });
10
+ }
11
+ //#endregion
12
+ export { e as invalidateTpSlReads };
13
+
14
+ //# sourceMappingURL=invalidate-tpsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidate-tpsl.js","names":[],"sources":["../../src/tpsl/invalidate-tpsl.ts"],"sourcesContent":["import type { QueryClient } from \"@tanstack/react-query\";\n\n/**\n * Refetch the folded TP/SL reads for the given quotes.\n *\n * Call this after a successful set or cancel: the handler's REST rows are the\n * authoritative state, so refetching them overwrites the optimistic\n * `confirming` overlay `markConfirming` left in the store. Without it a box\n * resolves only when the live WebSocket frame arrives — and stays stuck\n * `confirming` (or keeps showing a cancelled value) whenever that frame is\n * missed.\n *\n * The `getQuoteTpSl` query key is matched by **shape**, not through\n * `getQuoteTpSlQueryKey`, because that factory throws on a partial (it\n * stringifies `quoteId`). Only the passed quotes' reads are invalidated, so an\n * unrelated market's TP/SL box is never disturbed.\n *\n * @param queryClient - The active TanStack query client.\n * @param quoteIds - On-chain quote ids whose TP/SL reads should refetch. `0n`\n * sentinels are ignored.\n * @returns Resolves when the matching queries have been marked stale.\n */\nexport function invalidateTpSlReads(queryClient: QueryClient, quoteIds: readonly bigint[]): Promise<void> {\n const ids = new Set(quoteIds.filter((id) => id !== 0n).map((id) => id.toString()));\n if (ids.size === 0) return Promise.resolve();\n return queryClient.invalidateQueries({\n predicate: (query) => {\n const key = query.queryKey;\n if (!Array.isArray(key) || key[0] !== \"getQuoteTpSl\") return false;\n const params = key[1] as { quoteId?: string } | undefined;\n return typeof params?.quoteId === \"string\" && ids.has(params.quoteId);\n },\n });\n}\n"],"mappings":";AAsBA,SAAgB,EAAoB,GAA0B,GAA4C;CACxG,IAAM,IAAM,IAAI,IAAI,EAAS,QAAQ,MAAO,MAAO,EAAE,EAAE,KAAK,MAAO,EAAG,SAAS,CAAC,CAAC;CAEjF,OADI,EAAI,SAAS,IAAU,QAAQ,QAAQ,IACpC,EAAY,kBAAkB,EACnC,YAAY,MAAU;EACpB,IAAM,IAAM,EAAM;EAClB,IAAI,CAAC,MAAM,QAAQ,CAAG,KAAK,EAAI,OAAO,gBAAgB,OAAO;EAC7D,IAAM,IAAS,EAAI;EACnB,OAAO,OAAO,GAAQ,WAAY,YAAY,EAAI,IAAI,EAAO,OAAO;CACtE,EACF,CAAC;AACH"}
@@ -0,0 +1,27 @@
1
+ import { TpSlNotification } from '@symmio/trading-core';
2
+ /**
3
+ * Resolve which of `ids` a TP/SL notification belongs to.
4
+ *
5
+ * A quote is addressable by several ids over its life (the hedger's negative
6
+ * `tempQuoteId` before it anchors, the on-chain `quoteId` after), and the store
7
+ * aliases every id it has learned onto one record. So the match runs through
8
+ * the store's index and compares records by reference — a frame carrying the
9
+ * temp id still lands on a child now addressed by its on-chain id.
10
+ *
11
+ * When the store has no record for a candidate yet (the very first "seed"
12
+ * frame), it falls back to comparing the raw ids on the frame.
13
+ *
14
+ * @param notification - The normalized TP/SL frame.
15
+ * @param ids - Candidate quote ids, in the caller's own order.
16
+ * @returns The first matching id, or `undefined` when the frame is unrelated.
17
+ */
18
+ export declare function matchTpSlNotification(notification: TpSlNotification, ids: readonly (bigint | undefined)[]): bigint | undefined;
19
+ /**
20
+ * Learn the `tempQuoteId ↔ quoteId` pairing a frame carries, so both ids
21
+ * resolve to the same store record from now on. No-op when the frame only
22
+ * carries one identifier.
23
+ *
24
+ * @param notification - The normalized TP/SL frame.
25
+ */
26
+ export declare function linkTpSlNotificationIds(notification: TpSlNotification): void;
27
+ //# sourceMappingURL=match-tpsl-notification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-tpsl-notification.d.ts","sourceRoot":"","sources":["../../src/tpsl/match-tpsl-notification.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,gBAAgB,EAC9B,GAAG,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACnC,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAG5E"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useTpSlStore as e } from "./tpsl-store.js";
3
+ //#region src/tpsl/match-tpsl-notification.ts
4
+ function t(t, n) {
5
+ let r = e.getState();
6
+ for (let e of n) {
7
+ if (e === void 0 || e === 0n) continue;
8
+ let n = r.get(e);
9
+ if (!n) {
10
+ if (t.primaryIdentifier === Number(e) || t.secondaryIdentifier === Number(e) || t.quoteId === Number(e)) return e;
11
+ continue;
12
+ }
13
+ if (t.primaryIdentifier !== 0 && r.get(BigInt(t.primaryIdentifier)) === n || t.secondaryIdentifier !== 0 && r.get(BigInt(t.secondaryIdentifier)) === n) return e;
14
+ }
15
+ }
16
+ function n(t) {
17
+ t.primaryIdentifier === 0 || t.secondaryIdentifier === 0 || e.getState().link(BigInt(t.primaryIdentifier), BigInt(t.secondaryIdentifier));
18
+ }
19
+ //#endregion
20
+ export { n as linkTpSlNotificationIds, t as matchTpSlNotification };
21
+
22
+ //# sourceMappingURL=match-tpsl-notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-tpsl-notification.js","names":[],"sources":["../../src/tpsl/match-tpsl-notification.ts"],"sourcesContent":["\"use client\";\n\nimport type { TpSlNotification } from \"@symmio/trading-core\";\nimport { useTpSlStore } from \"./tpsl-store\";\n\n/**\n * Resolve which of `ids` a TP/SL notification belongs to.\n *\n * A quote is addressable by several ids over its life (the hedger's negative\n * `tempQuoteId` before it anchors, the on-chain `quoteId` after), and the store\n * aliases every id it has learned onto one record. So the match runs through\n * the store's index and compares records by reference — a frame carrying the\n * temp id still lands on a child now addressed by its on-chain id.\n *\n * When the store has no record for a candidate yet (the very first \"seed\"\n * frame), it falls back to comparing the raw ids on the frame.\n *\n * @param notification - The normalized TP/SL frame.\n * @param ids - Candidate quote ids, in the caller's own order.\n * @returns The first matching id, or `undefined` when the frame is unrelated.\n */\nexport function matchTpSlNotification(\n notification: TpSlNotification,\n ids: readonly (bigint | undefined)[],\n): bigint | undefined {\n const store = useTpSlStore.getState();\n for (const id of ids) {\n if (id === undefined || id === 0n) continue;\n const target = store.get(id);\n if (!target) {\n if (\n notification.primaryIdentifier === Number(id) ||\n notification.secondaryIdentifier === Number(id) ||\n notification.quoteId === Number(id)\n ) {\n return id;\n }\n continue;\n }\n if (notification.primaryIdentifier !== 0 && store.get(BigInt(notification.primaryIdentifier)) === target) return id;\n if (notification.secondaryIdentifier !== 0 && store.get(BigInt(notification.secondaryIdentifier)) === target) {\n return id;\n }\n }\n return undefined;\n}\n\n/**\n * Learn the `tempQuoteId ↔ quoteId` pairing a frame carries, so both ids\n * resolve to the same store record from now on. No-op when the frame only\n * carries one identifier.\n *\n * @param notification - The normalized TP/SL frame.\n */\nexport function linkTpSlNotificationIds(notification: TpSlNotification): void {\n if (notification.primaryIdentifier === 0 || notification.secondaryIdentifier === 0) return;\n useTpSlStore.getState().link(BigInt(notification.primaryIdentifier), BigInt(notification.secondaryIdentifier));\n}\n"],"mappings":";;;AAqBA,SAAgB,EACd,GACA,GACoB;CACpB,IAAM,IAAQ,EAAa,SAAS;CACpC,KAAK,IAAM,KAAM,GAAK;EACpB,IAAI,MAAO,KAAA,KAAa,MAAO,IAAI;EACnC,IAAM,IAAS,EAAM,IAAI,CAAE;EAC3B,IAAI,CAAC,GAAQ;GACX,IACE,EAAa,sBAAsB,OAAO,CAAE,KAC5C,EAAa,wBAAwB,OAAO,CAAE,KAC9C,EAAa,YAAY,OAAO,CAAE,GAElC,OAAO;GAET;EACF;EAEA,IADI,EAAa,sBAAsB,KAAK,EAAM,IAAI,OAAO,EAAa,iBAAiB,CAAC,MAAM,KAC9F,EAAa,wBAAwB,KAAK,EAAM,IAAI,OAAO,EAAa,mBAAmB,CAAC,MAAM,GACpG,OAAO;CAEX;AAEF;AASA,SAAgB,EAAwB,GAAsC;CACxE,EAAa,sBAAsB,KAAK,EAAa,wBAAwB,KACjF,EAAa,SAAS,EAAE,KAAK,OAAO,EAAa,iBAAiB,GAAG,OAAO,EAAa,mBAAmB,CAAC;AAC/G"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Run `worker` over `items` with at most `limit` in flight, preserving start
3
+ * order. A `limit` of `1` is a plain sequential loop.
4
+ *
5
+ * The worker is expected to swallow its own errors — this helper has no
6
+ * short-circuit on rejection, because one failed item must never abandon the
7
+ * rest (which is exactly what `Promise.all` over raw promises would do).
8
+ *
9
+ * `shouldStop` is the deliberate exception: it is consulted before each item is
10
+ * picked up, so a caller can abort the remaining work on a condition it decides
11
+ * (for example a wallet signature the user rejected — prompting again for every
12
+ * remaining item is worse than stopping).
13
+ *
14
+ * @param items - Work items.
15
+ * @param limit - Maximum concurrent workers. Values below `1` are treated as `1`.
16
+ * @param worker - Invoked once per item.
17
+ * @param shouldStop - Optional abort predicate, checked before each item starts.
18
+ */
19
+ export declare function runWithConcurrency<T>(items: readonly T[], limit: number, worker: (item: T) => Promise<void>, shouldStop?: () => boolean): Promise<void>;
20
+ //# sourceMappingURL=run-with-concurrency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-with-concurrency.d.ts","sourceRoot":"","sources":["../../src/tpsl/run-with-concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EAClC,UAAU,CAAC,EAAE,MAAM,OAAO,GACzB,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -0,0 +1,15 @@
1
+ //#region src/tpsl/run-with-concurrency.ts
2
+ async function e(e, t, n, r) {
3
+ let i = Math.max(1, Math.trunc(t)), a = 0, o = Array.from({ length: Math.min(i, e.length) }, async () => {
4
+ for (; a < e.length;) {
5
+ if (r?.()) return;
6
+ let t = a;
7
+ a += 1, await n(e[t]);
8
+ }
9
+ });
10
+ await Promise.all(o);
11
+ }
12
+ //#endregion
13
+ export { e as runWithConcurrency };
14
+
15
+ //# sourceMappingURL=run-with-concurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-with-concurrency.js","names":[],"sources":["../../src/tpsl/run-with-concurrency.ts"],"sourcesContent":["/**\n * Run `worker` over `items` with at most `limit` in flight, preserving start\n * order. A `limit` of `1` is a plain sequential loop.\n *\n * The worker is expected to swallow its own errors — this helper has no\n * short-circuit on rejection, because one failed item must never abandon the\n * rest (which is exactly what `Promise.all` over raw promises would do).\n *\n * `shouldStop` is the deliberate exception: it is consulted before each item is\n * picked up, so a caller can abort the remaining work on a condition it decides\n * (for example a wallet signature the user rejected — prompting again for every\n * remaining item is worse than stopping).\n *\n * @param items - Work items.\n * @param limit - Maximum concurrent workers. Values below `1` are treated as `1`.\n * @param worker - Invoked once per item.\n * @param shouldStop - Optional abort predicate, checked before each item starts.\n */\nexport async function runWithConcurrency<T>(\n items: readonly T[],\n limit: number,\n worker: (item: T) => Promise<void>,\n shouldStop?: () => boolean,\n): Promise<void> {\n const size = Math.max(1, Math.trunc(limit));\n let cursor = 0;\n const lanes = Array.from({ length: Math.min(size, items.length) }, async () => {\n while (cursor < items.length) {\n if (shouldStop?.()) return;\n const index = cursor;\n cursor += 1;\n await worker(items[index]!);\n }\n });\n await Promise.all(lanes);\n}\n"],"mappings":";AAkBA,eAAsB,EACpB,GACA,GACA,GACA,GACe;CACf,IAAM,IAAO,KAAK,IAAI,GAAG,KAAK,MAAM,CAAK,CAAC,GACtC,IAAS,GACP,IAAQ,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAM,EAAM,MAAM,EAAE,GAAG,YAAY;EAC7E,OAAO,IAAS,EAAM,SAAQ;GAC5B,IAAI,IAAa,GAAG;GACpB,IAAM,IAAQ;GAEd,AADA,KAAU,GACV,MAAM,EAAO,EAAM,EAAO;EAC5B;CACF,CAAC;CACD,MAAM,QAAQ,IAAI,CAAK;AACzB"}