@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 @@
1
+ {"version":3,"file":"use-quote-group-funding.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-group-funding.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,EAAE,eAAe;IAC/G,6CAA6C;IAC7C,KAAK,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gDAAgD;IAChD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,4FAA4F;IAC5F,IAAI,EAAE,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrC,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,8BAA8B,GAAG,8BAA8B,CAiB/G"}
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { useQuotesFunding as e } from "./use-quotes-funding.js";
3
+ import { aggregateGroupFunding as t } from "@symmio/trading-core";
4
+ import { useMemo as n } from "react";
5
+ //#region src/quotes/use-quote-group-funding.ts
6
+ function r(r) {
7
+ let { group: i, ...a } = r, o = i.quotes, s = e({
8
+ quotes: o,
9
+ ...a
10
+ }), c = s.rows, l = n(() => t(o, c.filter((e) => e !== null)), [o, c]);
11
+ return n(() => ({
12
+ funding: l,
13
+ rows: c,
14
+ isLoading: s.isLoading,
15
+ error: s.error
16
+ }), [
17
+ l,
18
+ c,
19
+ s.isLoading,
20
+ s.error
21
+ ]);
22
+ }
23
+ //#endregion
24
+ export { r as useQuoteGroupFunding };
25
+
26
+ //# sourceMappingURL=use-quote-group-funding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-quote-group-funding.js","names":[],"sources":["../../src/quotes/use-quote-group-funding.ts"],"sourcesContent":["\"use client\";\n\nimport {\n aggregateGroupFunding,\n type ConfigParameter,\n type GetQuoteFundingOptions,\n type QuoteFundingData,\n type QuoteGroup,\n type QuoteGroupFunding,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useQuotesFunding } from \"./use-quotes-funding\";\n\n/**\n * Parameters for {@link useQuoteGroupFunding}.\n */\nexport interface UseQuoteGroupFundingParameters extends Omit<GetQuoteFundingOptions, \"quoteIds\">, ConfigParameter {\n /** The group to read settled funding for. */\n group: QuoteGroup;\n}\n\n/**\n * Return type of {@link useQuoteGroupFunding}.\n */\nexport interface UseQuoteGroupFundingReturnType {\n /** Aggregated settled funding for the group. */\n funding: QuoteGroupFunding;\n /** Funding row per child quote, aligned 1:1 with `group.quotes`; `null` when unresolved. */\n rows: Array<QuoteFundingData | null>;\n /** `true` while the underlying subgraph query is loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Read the settled funding of a whole {@link QuoteGroup} — the group-level\n * counterpart of `useQuoteFunding`.\n *\n * Every child quote's funding is fetched in one subgraph round-trip via\n * {@link useQuotesFunding}, then folded by core's pure `aggregateGroupFunding`.\n * All arithmetic lives in core; this hook only wires the read to the fold and\n * memoizes the result, so the returned object is referentially stable while the\n * group and its rows are unchanged.\n *\n * **Sign convention** — `funding.netReceived = received − paid`, so a **positive**\n * value means the group has **earned** funding and a negative one means it has\n * **paid** for it. This matches {@link QuoteFundingData} and the uPnL folds, so\n * \"green = income\" coloring renders it as-is; it is the inverse of the\n * cost-positive on-chain `int256`.\n *\n * **Check `funding.isComplete` before presenting the total as final.**\n * `netReceived` is always the sum over the children that resolved, i.e. a lower\n * bound while the subgraph is still indexing (`funding.missingQuoteIds`\n * non-empty). An all-optimistic or empty group reports `isComplete: false` with\n * `netReceived: 0n`, so treat `isComplete: false` as \"funding unknown\", not as\n * \"no funding\".\n *\n * **Settled to date only** — these totals cover funding the protocol has already\n * charged and the analytics subgraph has indexed. Funding accrued since a\n * quote's last funding charge is not indexed anywhere and is therefore not\n * included.\n *\n * @param parameters - The group to read, plus optional chain/query/config overrides.\n * @returns The aggregated group funding, the per-child rows, and query state.\n *\n * @example\n * ```tsx\n * function GroupedPositionCard({ group }: { group: QuoteGroup }) {\n * const { funding, isLoading } = useQuoteGroupFunding({ group });\n *\n * if (isLoading || !funding.isComplete) return <FundingSkeleton />;\n *\n * // Already income-positive: `netReceived > 0n` means the group EARNED funding.\n * return <Money amount={funding.netReceived} label=\"Funding\" />;\n * }\n * ```\n */\nexport function useQuoteGroupFunding(parameters: UseQuoteGroupFundingParameters): UseQuoteGroupFundingReturnType {\n const { group, ...rest } = parameters;\n const quotes = group.quotes;\n\n /** One batched round-trip for the whole group; de-duping and off-chain skipping live there. */\n const batch = useQuotesFunding({ quotes, ...rest });\n const rows = batch.rows;\n\n const funding = useMemo(() => {\n const resolvedRows = rows.filter((row): row is QuoteFundingData => row !== null);\n return aggregateGroupFunding(quotes, resolvedRows);\n }, [quotes, rows]);\n\n return useMemo(\n () => ({ funding, rows, isLoading: batch.isLoading, error: batch.error }),\n [funding, rows, batch.isLoading, batch.error],\n );\n}\n"],"mappings":";;;;;AA+EA,SAAgB,EAAqB,GAA4E;CAC/G,IAAM,EAAE,UAAO,GAAG,MAAS,GACrB,IAAS,EAAM,QAGf,IAAQ,EAAiB;EAAE;EAAQ,GAAG;CAAK,CAAC,GAC5C,IAAO,EAAM,MAEb,IAAU,QAEP,EAAsB,GADR,EAAK,QAAQ,MAAiC,MAAQ,IACtC,CAAY,GAChD,CAAC,GAAQ,CAAI,CAAC;CAEjB,OAAO,SACE;EAAE;EAAS;EAAM,WAAW,EAAM;EAAW,OAAO,EAAM;CAAM,IACvE;EAAC;EAAS;EAAM,EAAM;EAAW,EAAM;CAAK,CAC9C;AACF"}
@@ -0,0 +1,111 @@
1
+ import { ConfigParameter, MarginRiskMetrics, QuoteGroup, QuoteGroupUpnl } from '@symmio/trading-core';
2
+ import { Address } from 'viem';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Parameters for {@link useQuoteGroupMarginRisk}.
6
+ */
7
+ export interface UseQuoteGroupMarginRiskParameters extends ConfigParameter {
8
+ /** The merged position to describe. */
9
+ group: QuoteGroup;
10
+ /**
11
+ * Mark price override, 18-decimal wei. Omit to subscribe to the group's
12
+ * market. Pass it when the surrounding screen already holds the price, so the
13
+ * two do not open separate subscriptions or disagree by a tick.
14
+ */
15
+ markPrice?: bigint;
16
+ /**
17
+ * Account override; defaults to the group's resolved Virtual Account. The uPnL
18
+ * fold narrows to this account's children too, so `equity` stays consistent.
19
+ */
20
+ account?: Address;
21
+ /**
22
+ * Refetch the balance when an open/close settles on-chain.
23
+ * @default true
24
+ */
25
+ live?: boolean;
26
+ /** Optional override; defaults to the connected chain. */
27
+ chainId?: number;
28
+ /**
29
+ * Run the underlying reads only when `true` — gate a panel that is collapsed.
30
+ * @default true
31
+ */
32
+ enabled?: boolean;
33
+ }
34
+ /**
35
+ * Return type of {@link useQuoteGroupMarginRisk}.
36
+ */
37
+ export interface UseQuoteGroupMarginRiskReturnType {
38
+ /**
39
+ * Margin & risk for the group's liquidation domain. `undefined` while the
40
+ * balance read is in flight, **or** whenever the group spans several accounts
41
+ * ({@link isMultiAccount}) — blending liquidation domains is never correct.
42
+ */
43
+ metrics?: MarginRiskMetrics;
44
+ /**
45
+ * The group's aggregated unrealized PnL at {@link markPrice}. Check
46
+ * `upnl.isComplete` before presenting anything derived from it as final.
47
+ */
48
+ upnl: QuoteGroupUpnl;
49
+ /** Liquidation price of the resolved account, wei. `0n` when unavailable. */
50
+ liquidationPrice: bigint;
51
+ /** The mark price actually used, wei; `undefined` before the first tick. */
52
+ markPrice?: bigint;
53
+ /** The account {@link metrics} and {@link liquidationPrice} describe. */
54
+ account?: Address;
55
+ /** Distinct liquidation domains among the group's children (`vaAddress ?? partyA`). */
56
+ accounts: Address[];
57
+ /**
58
+ * `true` when the group's children live in more than one account. Each is
59
+ * liquidated independently, so {@link metrics} is suppressed — fan out with
60
+ * `useAccountMarginRisk` over {@link accounts} instead.
61
+ */
62
+ isMultiAccount: boolean;
63
+ /** `true` while the balance, positions, or price reads are loading. */
64
+ isLoading: boolean;
65
+ /** Normalized request error, when one occurred. */
66
+ error: SymmioRequestError | null;
67
+ }
68
+ /**
69
+ * Margin and liquidation-risk state of a merged position — the group-level
70
+ * counterpart of `useAccountMarginRisk`.
71
+ *
72
+ * Resolves the group's Virtual Account, folds its children's unrealized PnL
73
+ * against the mark price with core's `aggregateGroupUpnl`, and runs both through
74
+ * `calculateMarginRisk`. The account's liquidation price comes from the existing
75
+ * `useAccountLiquidationPrice`. All arithmetic lives in core; this hook only
76
+ * wires the reads to the folds.
77
+ *
78
+ * **Mark price**: injected wins. Pass `markPrice` (wei) and no price
79
+ * subscription is opened; omit it and the hook subscribes to the group's market.
80
+ *
81
+ * **One liquidation domain per result.** A group normally maps 1:1 to a Virtual
82
+ * Account, because the built-in grouping strategies mirror the sub-account's
83
+ * on-chain isolation type. When it does not — a custom `keyOf`, or grouping by
84
+ * `MARKET` an account isolated by `MARKET_DIRECTION` — `isMultiAccount` is `true`
85
+ * and `metrics` is withheld rather than blended: an account at 2% buffer averaged
86
+ * with one at 200% reads as safe while the first is about to be liquidated.
87
+ *
88
+ * **Equity is exact only when the group covers the account's whole book.**
89
+ * `equity = allocatedBalance + upnl` mixes an account-wide balance with the
90
+ * group's uPnL. That is the same figure the reference app shows, and it is exact
91
+ * whenever the grouping strategy matches the sub-account's isolation type. Group
92
+ * a `MARKET`-isolated account by `MARKET_DIRECTION` and each group is a *subset*
93
+ * of its account, which understates equity — the hook cannot detect that without
94
+ * a second read, so it is stated rather than guessed at.
95
+ *
96
+ * @param parameters - The group, plus optional price/account/chain/config overrides.
97
+ * @returns The group's metrics, uPnL, liquidation price, and query state.
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * function GroupRisk({ group }: { group: QuoteGroup }) {
102
+ * const { metrics, upnl, liquidationPrice } = useQuoteGroupMarginRisk({ group });
103
+ * if (!metrics) return <Skeleton />;
104
+ * // The three margin rows are uPnL-independent — render them even while
105
+ * // `upnl.isComplete` is false; gate only equity and the buffer on it.
106
+ * return <MarginRows metrics={metrics} live={upnl.isComplete} liq={liquidationPrice} />;
107
+ * }
108
+ * ```
109
+ */
110
+ export declare function useQuoteGroupMarginRisk(parameters: UseQuoteGroupMarginRiskParameters): UseQuoteGroupMarginRiskReturnType;
111
+ //# sourceMappingURL=use-quote-group-margin-risk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-quote-group-margin-risk.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-group-margin-risk.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAKzE;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,eAAe;IACxE,uCAAuC;IACvC,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;OAIG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,IAAI,EAAE,cAAc,CAAC;IACrB,6EAA6E;IAC7E,gBAAgB,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uFAAuF;IACvF,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iCAAiC,GAC5C,iCAAiC,CA8FnC"}
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ import { useAccountLiquidationPrice as e } from "./use-account-liquidation-price.js";
3
+ import { useAccountMarginRisk as t } from "../margin/use-account-margin-risk.js";
4
+ import { useEnigmaPriceByMarketId as n } from "../price-service/use-enigma-price-by-market-id.js";
5
+ import { aggregateGroupUpnl as r, decimalPriceToWei as i } from "@symmio/trading-core";
6
+ import { useMemo as a } from "react";
7
+ //#region src/quotes/use-quote-group-margin-risk.ts
8
+ function o(o) {
9
+ let { group: s, markPrice: c, live: l = !0, chainId: u, enabled: d = !0, config: f } = o, p = s.quotes, m = a(() => {
10
+ let e = /* @__PURE__ */ new Set(), t = [];
11
+ for (let n of p) {
12
+ let r = n.vaAddress ?? n.partyA, i = r.toLowerCase();
13
+ e.has(i) || (e.add(i), t.push(r));
14
+ }
15
+ return t;
16
+ }, [p]), h = m.length > 1, g = o.account ?? s.vaAddress ?? m[0], _ = a(() => {
17
+ if (g === void 0) return p;
18
+ let e = g.toLowerCase();
19
+ return p.filter((t) => (t.vaAddress ?? t.partyA).toLowerCase() === e);
20
+ }, [p, g]), v = s.by.symbolId ?? p[0]?.symbolId, y = n({
21
+ marketId: v ?? 0n,
22
+ enabled: d && c === void 0 && v !== void 0,
23
+ chainId: u,
24
+ config: f
25
+ }), b = c ?? i(y.markPrice ?? ""), x = a(() => r(_, b), [_, b]), S = t({
26
+ account: h ? void 0 : g,
27
+ upnl: x.upnl,
28
+ live: l,
29
+ chainId: u,
30
+ config: f
31
+ }), C = e({
32
+ account: g,
33
+ chainId: u,
34
+ config: f
35
+ }), w = c === void 0 && y.isLoading;
36
+ return a(() => ({
37
+ metrics: h ? void 0 : S.metrics,
38
+ upnl: x,
39
+ liquidationPrice: C.liquidationPrice,
40
+ markPrice: b,
41
+ account: g,
42
+ accounts: m,
43
+ isMultiAccount: h,
44
+ isLoading: S.isLoading || C.isLoading || w,
45
+ error: S.error
46
+ }), [
47
+ S.metrics,
48
+ S.isLoading,
49
+ S.error,
50
+ x,
51
+ C.liquidationPrice,
52
+ C.isLoading,
53
+ b,
54
+ g,
55
+ m,
56
+ h,
57
+ w
58
+ ]);
59
+ }
60
+ //#endregion
61
+ export { o as useQuoteGroupMarginRisk };
62
+
63
+ //# sourceMappingURL=use-quote-group-margin-risk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-quote-group-margin-risk.js","names":[],"sources":["../../src/quotes/use-quote-group-margin-risk.ts"],"sourcesContent":["\"use client\";\n\nimport {\n aggregateGroupUpnl,\n decimalPriceToWei,\n type ConfigParameter,\n type MarginRiskMetrics,\n type QuoteGroup,\n type QuoteGroupUpnl,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport type { Address } from \"viem\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useAccountMarginRisk } from \"../margin/use-account-margin-risk\";\nimport { useEnigmaPriceByMarketId } from \"../price-service/use-enigma-price-by-market-id\";\nimport { useAccountLiquidationPrice } from \"./use-account-liquidation-price\";\n\n/**\n * Parameters for {@link useQuoteGroupMarginRisk}.\n */\nexport interface UseQuoteGroupMarginRiskParameters extends ConfigParameter {\n /** The merged position to describe. */\n group: QuoteGroup;\n /**\n * Mark price override, 18-decimal wei. Omit to subscribe to the group's\n * market. Pass it when the surrounding screen already holds the price, so the\n * two do not open separate subscriptions or disagree by a tick.\n */\n markPrice?: bigint;\n /**\n * Account override; defaults to the group's resolved Virtual Account. The uPnL\n * fold narrows to this account's children too, so `equity` stays consistent.\n */\n account?: Address;\n /**\n * Refetch the balance when an open/close settles on-chain.\n * @default true\n */\n live?: boolean;\n /** Optional override; defaults to the connected chain. */\n chainId?: number;\n /**\n * Run the underlying reads only when `true` — gate a panel that is collapsed.\n * @default true\n */\n enabled?: boolean;\n}\n\n/**\n * Return type of {@link useQuoteGroupMarginRisk}.\n */\nexport interface UseQuoteGroupMarginRiskReturnType {\n /**\n * Margin & risk for the group's liquidation domain. `undefined` while the\n * balance read is in flight, **or** whenever the group spans several accounts\n * ({@link isMultiAccount}) — blending liquidation domains is never correct.\n */\n metrics?: MarginRiskMetrics;\n /**\n * The group's aggregated unrealized PnL at {@link markPrice}. Check\n * `upnl.isComplete` before presenting anything derived from it as final.\n */\n upnl: QuoteGroupUpnl;\n /** Liquidation price of the resolved account, wei. `0n` when unavailable. */\n liquidationPrice: bigint;\n /** The mark price actually used, wei; `undefined` before the first tick. */\n markPrice?: bigint;\n /** The account {@link metrics} and {@link liquidationPrice} describe. */\n account?: Address;\n /** Distinct liquidation domains among the group's children (`vaAddress ?? partyA`). */\n accounts: Address[];\n /**\n * `true` when the group's children live in more than one account. Each is\n * liquidated independently, so {@link metrics} is suppressed — fan out with\n * `useAccountMarginRisk` over {@link accounts} instead.\n */\n isMultiAccount: boolean;\n /** `true` while the balance, positions, or price reads are loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Margin and liquidation-risk state of a merged position — the group-level\n * counterpart of `useAccountMarginRisk`.\n *\n * Resolves the group's Virtual Account, folds its children's unrealized PnL\n * against the mark price with core's `aggregateGroupUpnl`, and runs both through\n * `calculateMarginRisk`. The account's liquidation price comes from the existing\n * `useAccountLiquidationPrice`. All arithmetic lives in core; this hook only\n * wires the reads to the folds.\n *\n * **Mark price**: injected wins. Pass `markPrice` (wei) and no price\n * subscription is opened; omit it and the hook subscribes to the group's market.\n *\n * **One liquidation domain per result.** A group normally maps 1:1 to a Virtual\n * Account, because the built-in grouping strategies mirror the sub-account's\n * on-chain isolation type. When it does not — a custom `keyOf`, or grouping by\n * `MARKET` an account isolated by `MARKET_DIRECTION` — `isMultiAccount` is `true`\n * and `metrics` is withheld rather than blended: an account at 2% buffer averaged\n * with one at 200% reads as safe while the first is about to be liquidated.\n *\n * **Equity is exact only when the group covers the account's whole book.**\n * `equity = allocatedBalance + upnl` mixes an account-wide balance with the\n * group's uPnL. That is the same figure the reference app shows, and it is exact\n * whenever the grouping strategy matches the sub-account's isolation type. Group\n * a `MARKET`-isolated account by `MARKET_DIRECTION` and each group is a *subset*\n * of its account, which understates equity — the hook cannot detect that without\n * a second read, so it is stated rather than guessed at.\n *\n * @param parameters - The group, plus optional price/account/chain/config overrides.\n * @returns The group's metrics, uPnL, liquidation price, and query state.\n *\n * @example\n * ```tsx\n * function GroupRisk({ group }: { group: QuoteGroup }) {\n * const { metrics, upnl, liquidationPrice } = useQuoteGroupMarginRisk({ group });\n * if (!metrics) return <Skeleton />;\n * // The three margin rows are uPnL-independent — render them even while\n * // `upnl.isComplete` is false; gate only equity and the buffer on it.\n * return <MarginRows metrics={metrics} live={upnl.isComplete} liq={liquidationPrice} />;\n * }\n * ```\n */\nexport function useQuoteGroupMarginRisk(\n parameters: UseQuoteGroupMarginRiskParameters,\n): UseQuoteGroupMarginRiskReturnType {\n const { group, markPrice: markPriceOverride, live = true, chainId, enabled = true, config } = parameters;\n const quotes = group.quotes;\n\n /** One entry per liquidation domain the children live in, in first-appearance order. */\n const accounts = useMemo(() => {\n const seen = new Set<string>();\n const result: Address[] = [];\n for (const quote of quotes) {\n const address = quote.vaAddress ?? quote.partyA;\n const key = address.toLowerCase();\n if (seen.has(key)) continue;\n seen.add(key);\n result.push(address);\n }\n return result;\n }, [quotes]);\n\n const isMultiAccount = accounts.length > 1;\n const account = parameters.account ?? group.vaAddress ?? accounts[0];\n\n /**\n * Narrowing to the resolved account is what keeps `equity` honest: without it\n * an `account` override would fold every child's uPnL against one account's\n * balance.\n */\n const children = useMemo(() => {\n if (account === undefined) return quotes;\n const target = account.toLowerCase();\n return quotes.filter((quote) => (quote.vaAddress ?? quote.partyA).toLowerCase() === target);\n }, [quotes, account]);\n\n /** `by.symbolId` is unset under a custom `keyOf`; the children still carry the market. */\n const symbolId = group.by.symbolId ?? quotes[0]?.symbolId;\n\n const priceQuery = useEnigmaPriceByMarketId({\n marketId: symbolId ?? 0n,\n enabled: enabled && markPriceOverride === undefined && symbolId !== undefined,\n chainId,\n config,\n });\n\n /**\n * `decimalPriceToWei` returns `undefined` rather than `0n` for a feed that has\n * not ticked — a fabricated `0n` would report a total loss.\n */\n const markPrice = markPriceOverride ?? decimalPriceToWei(priceQuery.markPrice ?? \"\");\n\n const upnl = useMemo(() => aggregateGroupUpnl(children, markPrice), [children, markPrice]);\n\n const risk = useAccountMarginRisk({\n /** A blended multi-account figure would be misleading, so do not even read for it. */\n account: isMultiAccount ? undefined : account,\n upnl: upnl.upnl,\n live,\n chainId,\n config,\n });\n\n const liquidation = useAccountLiquidationPrice({ account, chainId, config });\n\n const isPriceLoading = markPriceOverride === undefined && priceQuery.isLoading;\n\n return useMemo(\n () => ({\n /**\n * Withheld explicitly, not merely by leaving the read idle: suppressing a\n * blended cross-account figure is this hook's contract, so it must not\n * depend on how the account hook happens to behave without an account.\n */\n metrics: isMultiAccount ? undefined : risk.metrics,\n upnl,\n liquidationPrice: liquidation.liquidationPrice,\n markPrice,\n account,\n accounts,\n isMultiAccount,\n isLoading: risk.isLoading || liquidation.isLoading || isPriceLoading,\n error: risk.error,\n }),\n [\n risk.metrics,\n risk.isLoading,\n risk.error,\n upnl,\n liquidation.liquidationPrice,\n liquidation.isLoading,\n markPrice,\n account,\n accounts,\n isMultiAccount,\n isPriceLoading,\n ],\n );\n}\n"],"mappings":";;;;;;;AA6HA,SAAgB,EACd,GACmC;CACnC,IAAM,EAAE,UAAO,WAAW,GAAmB,UAAO,IAAM,YAAS,aAAU,IAAM,cAAW,GACxF,IAAS,EAAM,QAGf,IAAW,QAAc;EAC7B,IAAM,oBAAO,IAAI,IAAY,GACvB,IAAoB,CAAC;EAC3B,KAAK,IAAM,KAAS,GAAQ;GAC1B,IAAM,IAAU,EAAM,aAAa,EAAM,QACnC,IAAM,EAAQ,YAAY;GAC5B,EAAK,IAAI,CAAG,MAChB,EAAK,IAAI,CAAG,GACZ,EAAO,KAAK,CAAO;EACrB;EACA,OAAO;CACT,GAAG,CAAC,CAAM,CAAC,GAEL,IAAiB,EAAS,SAAS,GACnC,IAAU,EAAW,WAAW,EAAM,aAAa,EAAS,IAO5D,IAAW,QAAc;EAC7B,IAAI,MAAY,KAAA,GAAW,OAAO;EAClC,IAAM,IAAS,EAAQ,YAAY;EACnC,OAAO,EAAO,QAAQ,OAAW,EAAM,aAAa,EAAM,QAAQ,YAAY,MAAM,CAAM;CAC5F,GAAG,CAAC,GAAQ,CAAO,CAAC,GAGd,IAAW,EAAM,GAAG,YAAY,EAAO,IAAI,UAE3C,IAAa,EAAyB;EAC1C,UAAU,KAAY;EACtB,SAAS,KAAW,MAAsB,KAAA,KAAa,MAAa,KAAA;EACpE;EACA;CACF,CAAC,GAMK,IAAY,KAAqB,EAAkB,EAAW,aAAa,EAAE,GAE7E,IAAO,QAAc,EAAmB,GAAU,CAAS,GAAG,CAAC,GAAU,CAAS,CAAC,GAEnF,IAAO,EAAqB;EAEhC,SAAS,IAAiB,KAAA,IAAY;EACtC,MAAM,EAAK;EACX;EACA;EACA;CACF,CAAC,GAEK,IAAc,EAA2B;EAAE;EAAS;EAAS;CAAO,CAAC,GAErE,IAAiB,MAAsB,KAAA,KAAa,EAAW;CAErE,OAAO,SACE;EAML,SAAS,IAAiB,KAAA,IAAY,EAAK;EAC3C;EACA,kBAAkB,EAAY;EAC9B;EACA;EACA;EACA;EACA,WAAW,EAAK,aAAa,EAAY,aAAa;EACtD,OAAO,EAAK;CACd,IACA;EACE,EAAK;EACL,EAAK;EACL,EAAK;EACL;EACA,EAAY;EACZ,EAAY;EACZ;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
@@ -21,9 +21,10 @@ export interface UseQuoteUpnlAndPnlReturnType extends CalculateQuoteUpnlReturnTy
21
21
  * Compute unrealized PNL (open size, vs mark) and realized PNL (closed size,
22
22
  * vs the quote's recorded close price) for a single {@link UnifiedQuote}.
23
23
  *
24
- * Mark price is resolved live via {@link useEnigmaPriceByMarketId} on the
25
- * quote's `symbolId`. UPNL stays `"0"` until the first tick for that market
26
- * arrives.
24
+ * Mark price is resolved live via {@link usePriceByMarketId} on the quote's
25
+ * `symbolId` — from whichever price provider serves the chain's resolved solver
26
+ * (Enigma on lowcap chains, Binance on majors chains). UPNL stays `"0"` until
27
+ * the first tick for that market arrives.
27
28
  *
28
29
  * @example
29
30
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"use-quote-upnl-and-pnl.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,eAAe;IACnE,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,4BAA4B,EAAE,2BAA2B;IAC7G,gFAAgF;IAChF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;CACpB;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,4BAA4B,GAAG,4BAA4B,CAkDzG"}
1
+ {"version":3,"file":"use-quote-upnl-and-pnl.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAI9B;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,eAAe;IACnE,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,4BAA4B,EAAE,2BAA2B;IAC7G,gFAAgF;IAChF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;CACpB;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,4BAA4B,GAAG,4BAA4B,CAmDzG"}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useEnigmaPriceByMarketId as e } from "../price-service/use-enigma-price-by-market-id.js";
2
+ import { usePriceByMarketId as e } from "../price-service/use-price-by-market-id.js";
3
3
  import { calculateQuoteLeverage as t, calculateQuotePnl as n, calculateQuoteUpnl as r } from "@symmio/trading-core";
4
4
  import { useMemo as i } from "react";
5
5
  //#region src/quotes/use-quote-upnl-and-pnl.ts
@@ -22,6 +22,7 @@ function o(o) {
22
22
  let e = s.initialLockedValues ?? s.lockedValues, i = t({
23
23
  quantity: s.quantity,
24
24
  requestedOpenPrice: s.requestedOpenPrice,
25
+ openedPrice: s.openedPrice,
25
26
  lockedValues: e
26
27
  }), o = s.closedAmount ?? 0n, l = c.markPrice, { upnl: u, upnlPercent: d } = l ? r({
27
28
  markPrice: l,
@@ -1 +1 @@
1
- {"version":3,"file":"use-quote-upnl-and-pnl.js","names":[],"sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateQuoteLeverage,\n calculateQuotePnl,\n calculateQuoteUpnl,\n type CalculateQuotePnlReturnType,\n type CalculateQuoteUpnlReturnType,\n type ConfigParameter,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { useEnigmaPriceByMarketId } from \"../price-service/use-enigma-price-by-market-id\";\n\n/**\n * Parameters for {@link useQuoteUpnlAndPnl}.\n */\nexport interface UseQuoteUpnlAndPnlParameters extends ConfigParameter {\n /** Unified quote to compute UPNL + realized PNL for. */\n quote?: UnifiedQuote;\n}\n\n/**\n * Return type of {@link useQuoteUpnlAndPnl}.\n */\nexport interface UseQuoteUpnlAndPnlReturnType extends CalculateQuoteUpnlReturnType, CalculateQuotePnlReturnType {\n /** Mark price used in the calc, decimal string. `null` until the first tick. */\n markPrice: string | null;\n /** Leverage derived from the quote's locked-margin breakdown, decimal string. */\n leverage: string;\n /** `true` while markets or mark-price are resolving. */\n isLoading: boolean;\n}\n\nconst EMPTY: UseQuoteUpnlAndPnlReturnType = {\n upnl: \"0\",\n upnlPercent: \"0\",\n pnl: \"0\",\n pnlPercent: \"0\",\n markPrice: null,\n leverage: \"0\",\n isLoading: false,\n};\n\n/**\n * Compute unrealized PNL (open size, vs mark) and realized PNL (closed size,\n * vs the quote's recorded close price) for a single {@link UnifiedQuote}.\n *\n * Mark price is resolved live via {@link useEnigmaPriceByMarketId} on the\n * quote's `symbolId`. UPNL stays `\"0\"` until the first tick for that market\n * arrives.\n *\n * @example\n * ```tsx\n * const { upnl, upnlPercent, pnl, pnlPercent, markPrice } = useQuoteUpnlAndPnl({ quote });\n * ```\n */\nexport function useQuoteUpnlAndPnl(parameters: UseQuoteUpnlAndPnlParameters): UseQuoteUpnlAndPnlReturnType {\n const { quote } = parameters;\n\n const priceQuery = useEnigmaPriceByMarketId({\n marketId: quote?.symbolId ?? 0n,\n enabled: quote !== undefined,\n });\n\n return useMemo(() => {\n if (!quote) return EMPTY;\n\n const lockedValuesForLeverage = quote.initialLockedValues ?? quote.lockedValues;\n const leverage = calculateQuoteLeverage({\n quantity: quote.quantity,\n requestedOpenPrice: quote.requestedOpenPrice,\n lockedValues: lockedValuesForLeverage,\n });\n\n const closedAmount = quote.closedAmount ?? 0n;\n const markPrice = priceQuery.markPrice;\n\n const { upnl, upnlPercent } = markPrice\n ? calculateQuoteUpnl({\n markPrice,\n positionType: quote.positionType,\n quantity: quote.quantity,\n closedAmount,\n openedPrice: quote.openedPrice ?? 0n,\n leverage,\n })\n : { upnl: \"0\", upnlPercent: \"0\" };\n\n const { pnl, pnlPercent } = calculateQuotePnl({\n positionType: quote.positionType,\n closedAmount,\n closedPrice: quote.avgClosedPrice ?? 0n,\n openedPrice: quote.openedPrice ?? 0n,\n leverage,\n });\n\n return {\n upnl,\n upnlPercent,\n pnl,\n pnlPercent,\n markPrice,\n leverage,\n isLoading: priceQuery.isLoading,\n };\n }, [quote, priceQuery.markPrice, priceQuery.isLoading]);\n}\n"],"mappings":";;;;;AAkCA,IAAM,IAAsC;CAC1C,MAAM;CACN,aAAa;CACb,KAAK;CACL,YAAY;CACZ,WAAW;CACX,UAAU;CACV,WAAW;AACb;AAeA,SAAgB,EAAmB,GAAwE;CACzG,IAAM,EAAE,aAAU,GAEZ,IAAa,EAAyB;EAC1C,UAAU,GAAO,YAAY;EAC7B,SAAS,MAAU,KAAA;CACrB,CAAC;CAED,OAAO,QAAc;EACnB,IAAI,CAAC,GAAO,OAAO;EAEnB,IAAM,IAA0B,EAAM,uBAAuB,EAAM,cAC7D,IAAW,EAAuB;GACtC,UAAU,EAAM;GAChB,oBAAoB,EAAM;GAC1B,cAAc;EAChB,CAAC,GAEK,IAAe,EAAM,gBAAgB,IACrC,IAAY,EAAW,WAEvB,EAAE,SAAM,mBAAgB,IAC1B,EAAmB;GACjB;GACA,cAAc,EAAM;GACpB,UAAU,EAAM;GAChB;GACA,aAAa,EAAM,eAAe;GAClC;EACF,CAAC,IACD;GAAE,MAAM;GAAK,aAAa;EAAI,GAE5B,EAAE,QAAK,kBAAe,EAAkB;GAC5C,cAAc,EAAM;GACpB;GACA,aAAa,EAAM,kBAAkB;GACrC,aAAa,EAAM,eAAe;GAClC;EACF,CAAC;EAED,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,EAAW;EACxB;CACF,GAAG;EAAC;EAAO,EAAW;EAAW,EAAW;CAAS,CAAC;AACxD"}
1
+ {"version":3,"file":"use-quote-upnl-and-pnl.js","names":[],"sources":["../../src/quotes/use-quote-upnl-and-pnl.ts"],"sourcesContent":["\"use client\";\n\nimport {\n calculateQuoteLeverage,\n calculateQuotePnl,\n calculateQuoteUpnl,\n type CalculateQuotePnlReturnType,\n type CalculateQuoteUpnlReturnType,\n type ConfigParameter,\n type UnifiedQuote,\n} from \"@symmio/trading-core\";\nimport { useMemo } from \"react\";\nimport { usePriceByMarketId } from \"../price-service/use-price-by-market-id\";\n\n/**\n * Parameters for {@link useQuoteUpnlAndPnl}.\n */\nexport interface UseQuoteUpnlAndPnlParameters extends ConfigParameter {\n /** Unified quote to compute UPNL + realized PNL for. */\n quote?: UnifiedQuote;\n}\n\n/**\n * Return type of {@link useQuoteUpnlAndPnl}.\n */\nexport interface UseQuoteUpnlAndPnlReturnType extends CalculateQuoteUpnlReturnType, CalculateQuotePnlReturnType {\n /** Mark price used in the calc, decimal string. `null` until the first tick. */\n markPrice: string | null;\n /** Leverage derived from the quote's locked-margin breakdown, decimal string. */\n leverage: string;\n /** `true` while markets or mark-price are resolving. */\n isLoading: boolean;\n}\n\nconst EMPTY: UseQuoteUpnlAndPnlReturnType = {\n upnl: \"0\",\n upnlPercent: \"0\",\n pnl: \"0\",\n pnlPercent: \"0\",\n markPrice: null,\n leverage: \"0\",\n isLoading: false,\n};\n\n/**\n * Compute unrealized PNL (open size, vs mark) and realized PNL (closed size,\n * vs the quote's recorded close price) for a single {@link UnifiedQuote}.\n *\n * Mark price is resolved live via {@link usePriceByMarketId} on the quote's\n * `symbolId` — from whichever price provider serves the chain's resolved solver\n * (Enigma on lowcap chains, Binance on majors chains). UPNL stays `\"0\"` until\n * the first tick for that market arrives.\n *\n * @example\n * ```tsx\n * const { upnl, upnlPercent, pnl, pnlPercent, markPrice } = useQuoteUpnlAndPnl({ quote });\n * ```\n */\nexport function useQuoteUpnlAndPnl(parameters: UseQuoteUpnlAndPnlParameters): UseQuoteUpnlAndPnlReturnType {\n const { quote } = parameters;\n\n const priceQuery = usePriceByMarketId({\n marketId: quote?.symbolId ?? 0n,\n enabled: quote !== undefined,\n });\n\n return useMemo(() => {\n if (!quote) return EMPTY;\n\n const lockedValuesForLeverage = quote.initialLockedValues ?? quote.lockedValues;\n const leverage = calculateQuoteLeverage({\n quantity: quote.quantity,\n requestedOpenPrice: quote.requestedOpenPrice,\n openedPrice: quote.openedPrice,\n lockedValues: lockedValuesForLeverage,\n });\n\n const closedAmount = quote.closedAmount ?? 0n;\n const markPrice = priceQuery.markPrice;\n\n const { upnl, upnlPercent } = markPrice\n ? calculateQuoteUpnl({\n markPrice,\n positionType: quote.positionType,\n quantity: quote.quantity,\n closedAmount,\n openedPrice: quote.openedPrice ?? 0n,\n leverage,\n })\n : { upnl: \"0\", upnlPercent: \"0\" };\n\n const { pnl, pnlPercent } = calculateQuotePnl({\n positionType: quote.positionType,\n closedAmount,\n closedPrice: quote.avgClosedPrice ?? 0n,\n openedPrice: quote.openedPrice ?? 0n,\n leverage,\n });\n\n return {\n upnl,\n upnlPercent,\n pnl,\n pnlPercent,\n markPrice,\n leverage,\n isLoading: priceQuery.isLoading,\n };\n }, [quote, priceQuery.markPrice, priceQuery.isLoading]);\n}\n"],"mappings":";;;;;AAkCA,IAAM,IAAsC;CAC1C,MAAM;CACN,aAAa;CACb,KAAK;CACL,YAAY;CACZ,WAAW;CACX,UAAU;CACV,WAAW;AACb;AAgBA,SAAgB,EAAmB,GAAwE;CACzG,IAAM,EAAE,aAAU,GAEZ,IAAa,EAAmB;EACpC,UAAU,GAAO,YAAY;EAC7B,SAAS,MAAU,KAAA;CACrB,CAAC;CAED,OAAO,QAAc;EACnB,IAAI,CAAC,GAAO,OAAO;EAEnB,IAAM,IAA0B,EAAM,uBAAuB,EAAM,cAC7D,IAAW,EAAuB;GACtC,UAAU,EAAM;GAChB,oBAAoB,EAAM;GAC1B,aAAa,EAAM;GACnB,cAAc;EAChB,CAAC,GAEK,IAAe,EAAM,gBAAgB,IACrC,IAAY,EAAW,WAEvB,EAAE,SAAM,mBAAgB,IAC1B,EAAmB;GACjB;GACA,cAAc,EAAM;GACpB,UAAU,EAAM;GAChB;GACA,aAAa,EAAM,eAAe;GAClC;EACF,CAAC,IACD;GAAE,MAAM;GAAK,aAAa;EAAI,GAE5B,EAAE,QAAK,kBAAe,EAAkB;GAC5C,cAAc,EAAM;GACpB;GACA,aAAa,EAAM,kBAAkB;GACrC,aAAa,EAAM,eAAe;GAClC;EACF,CAAC;EAED,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,EAAW;EACxB;CACF,GAAG;EAAC;EAAO,EAAW;EAAW,EAAW;CAAS,CAAC;AACxD"}
@@ -11,8 +11,9 @@ export interface QuotesFundingInputQuote {
11
11
  export interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions, "quoteIds">, ConfigParameter {
12
12
  /**
13
13
  * Quotes (or quote-id-bearing rows) to read funding for. Off-chain rows
14
- * (`quoteId === undefined`) are silently skipped. All resolved on-chain ids
15
- * are fetched in a single subgraph round-trip.
14
+ * (`quoteId === undefined`) are silently skipped. The resolved on-chain ids are
15
+ * de-duplicated and fetched in a single subgraph round-trip, so listing the
16
+ * same quote twice costs one request and contributes to the sums once.
16
17
  */
17
18
  quotes: readonly QuotesFundingInputQuote[];
18
19
  }
@@ -20,15 +21,35 @@ export interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions,
20
21
  * Return type of {@link useQuotesFunding}.
21
22
  */
22
23
  export interface UseQuotesFundingReturnType {
23
- /** Funding row per input quote, in input order. `null` for off-chain rows or ids the subgraph hasn't surfaced yet. */
24
+ /**
25
+ * Funding row per input quote, aligned 1:1 with `quotes` and in input order —
26
+ * `rows.length === quotes.length` on every path, including while loading and
27
+ * when nothing on-chain was requested. An entry is `null` for an off-chain row
28
+ * (no `quoteId`) or for an id the subgraph has not surfaced yet.
29
+ */
24
30
  rows: Array<QuoteFundingData | null>;
25
- /** Σ paid across resolved rows (wei). */
31
+ /**
32
+ * Σ funding paid across the resolved rows (wei). Summed over the **distinct**
33
+ * on-chain ids, so a quote listed twice contributes once.
34
+ */
26
35
  paid: bigint;
27
- /** Σ received across resolved rows (wei). */
36
+ /**
37
+ * Σ funding received across the resolved rows (wei). Summed over the
38
+ * **distinct** on-chain ids, so a quote listed twice contributes once.
39
+ */
28
40
  received: bigint;
29
- /** Σ net (paid − received) across resolved rows (wei). */
30
- net: bigint;
31
- /** Subset of input ids the subgraph has not yet returned (indexing lag). */
41
+ /**
42
+ * Σ `received − paid` across the resolved rows (wei). **Positive = the position
43
+ * earned funding**; negative = it paid for it. A lower bound while
44
+ * `missingQuoteIds` is non-empty.
45
+ */
46
+ netReceived: bigint;
47
+ /**
48
+ * Requested on-chain ids that have no funding row yet. While the query is in
49
+ * flight — and if it fails — this is **every** requested id, since nothing has
50
+ * resolved; once it settles it is the subset the subgraph did not return
51
+ * (indexing lag). Always empty when no on-chain ids were requested.
52
+ */
32
53
  missingQuoteIds: bigint[];
33
54
  /** `true` while the underlying subgraph query is loading. */
34
55
  isLoading: boolean;
@@ -41,11 +62,26 @@ export interface UseQuotesFundingReturnType {
41
62
  *
42
63
  * The hook is the canonical entry point for both single-quote details panels
43
64
  * ({@link useQuoteFunding} delegates here with a 1-element list) and grouped
44
- * quote cards (which want `Σ net`). Off-chain rows are skipped silently.
65
+ * quote cards (which want `Σ netReceived`). Off-chain rows are skipped silently,
66
+ * and duplicate ids are fetched — and summed — exactly once.
67
+ *
68
+ * **Sign convention** — `netReceived = received − paid`, the P&L perspective, so
69
+ * a **positive** value means the position **earned** funding. This matches
70
+ * `QuoteFundingData.netReceived` and the uPnL folds, and is the inverse of the
71
+ * cost-positive on-chain `int256`. A "green = income" UI renders it directly.
72
+ *
73
+ * **Settled to date only** — the totals cover funding the protocol has already
74
+ * charged and the analytics subgraph has indexed. Funding accrued since a
75
+ * quote's last funding charge is not indexed anywhere and is therefore not
76
+ * included.
77
+ *
78
+ * @param parameters - The quotes to read funding for, plus optional chain/config overrides.
79
+ * @returns Per-quote rows aligned with `quotes`, the aggregate sums, and query state.
45
80
  *
46
81
  * @example
47
82
  * ```tsx
48
- * const { rows, net, isLoading } = useQuotesFunding({ quotes: group.quotes });
83
+ * const { rows, netReceived, missingQuoteIds, isLoading } = useQuotesFunding({ quotes: group.quotes });
84
+ * // `netReceived > 0n` → the position earned funding across the resolved rows.
49
85
  * ```
50
86
  */
51
87
  export declare function useQuotesFunding(parameters: UseQuotesFundingParameters): UseQuotesFundingReturnType;
@@ -1 +1 @@
1
- {"version":3,"file":"use-quotes-funding.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quotes-funding.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,0EAA0E;AAC1E,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,EAAE,eAAe;IAC3G;;;;OAIG;IACH,MAAM,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,sHAAsH;IACtH,IAAI,EAAE,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrC,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,0BAA0B,CA6EnG"}
1
+ {"version":3,"file":"use-quotes-funding.d.ts","sourceRoot":"","sources":["../../src/quotes/use-quotes-funding.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,0EAA0E;AAC1E,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,CAAC,EAAE,eAAe;IAC3G;;;;;OAKG;IACH,MAAM,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,IAAI,EAAE,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,0BAA0B,GAAG,0BAA0B,CAgGnG"}
@@ -6,75 +6,77 @@ import { getQuoteFundingQueryOptions as r } from "@symmio/trading-core";
6
6
  import { useMemo as i } from "react";
7
7
  import { useQuery as a } from "@tanstack/react-query";
8
8
  //#region src/quotes/use-quotes-funding.ts
9
- var o = {
10
- rows: [],
11
- paid: 0n,
12
- received: 0n,
13
- net: 0n,
14
- missingQuoteIds: [],
15
- isLoading: !1,
16
- error: null
17
- };
18
- function s(s) {
19
- let { quotes: c, ...l } = s, u = t(s), d = e(), f = i(() => {
9
+ function o(o) {
10
+ let { quotes: s, ...c } = o, l = t(o), u = e(), d = i(() => {
20
11
  let e = /* @__PURE__ */ new Set(), t = [];
21
- for (let n of c) {
12
+ for (let n of s) {
22
13
  if (n.quoteId === void 0) continue;
23
14
  let r = n.quoteId.toString();
24
15
  e.has(r) || (e.add(r), t.push(n.quoteId));
25
16
  }
26
17
  return t;
27
- }, [c]), p = r(u, {
28
- ...l,
29
- chainId: l.chainId ?? d,
30
- quoteIds: f
31
- }), m = a({
32
- ...p,
18
+ }, [s]), f = r(l, {
19
+ ...c,
20
+ chainId: c.chainId ?? u,
21
+ quoteIds: d
22
+ }), p = a({
23
+ ...f,
33
24
  queryFn: async () => {
34
25
  try {
35
- return await p.queryFn();
26
+ return await f.queryFn();
36
27
  } catch (e) {
37
28
  throw n(e);
38
29
  }
39
30
  }
40
31
  });
41
32
  return i(() => {
42
- if (f.length === 0) return o;
43
- let e = m.data;
44
- if (!e) return {
45
- rows: c.map(() => null),
33
+ if (d.length === 0) return {
34
+ rows: s.map(() => null),
46
35
  paid: 0n,
47
36
  received: 0n,
48
- net: 0n,
37
+ netReceived: 0n,
49
38
  missingQuoteIds: [],
50
- isLoading: m.isLoading,
51
- error: m.error ?? null
39
+ isLoading: !1,
40
+ error: null
41
+ };
42
+ let e = p.data;
43
+ if (!e) return {
44
+ rows: s.map(() => null),
45
+ paid: 0n,
46
+ received: 0n,
47
+ netReceived: 0n,
48
+ missingQuoteIds: [...d],
49
+ isLoading: p.isLoading,
50
+ error: p.error ?? null
52
51
  };
53
52
  let t = /* @__PURE__ */ new Map();
54
- for (let n of e.rows) t.set(n.quoteId.toString(), n);
55
- let n = 0n, r = 0n, i = 0n;
53
+ for (let n of e.rows) {
54
+ let e = n.quoteId.toString();
55
+ t.has(e) || t.set(e, n);
56
+ }
57
+ let n = 0n, r = 0n;
58
+ for (let e of d) {
59
+ let i = t.get(e.toString());
60
+ i !== void 0 && (n += i.paid, r += i.received);
61
+ }
56
62
  return {
57
- rows: c.map((e) => {
58
- if (e.quoteId === void 0) return null;
59
- let a = t.get(e.quoteId.toString()) ?? null;
60
- return a && (n += a.paid, r += a.received, i += a.net), a;
61
- }),
63
+ rows: s.map((e) => e.quoteId === void 0 ? null : t.get(e.quoteId.toString()) ?? null),
62
64
  paid: n,
63
65
  received: r,
64
- net: i,
66
+ netReceived: r - n,
65
67
  missingQuoteIds: e.missingQuoteIds,
66
- isLoading: m.isLoading,
67
- error: m.error ?? null
68
+ isLoading: p.isLoading,
69
+ error: p.error ?? null
68
70
  };
69
71
  }, [
70
- f,
71
- c,
72
- m.data,
73
- m.isLoading,
74
- m.error
72
+ d,
73
+ s,
74
+ p.data,
75
+ p.isLoading,
76
+ p.error
75
77
  ]);
76
78
  }
77
79
  //#endregion
78
- export { s as useQuotesFunding };
80
+ export { o as useQuotesFunding };
79
81
 
80
82
  //# sourceMappingURL=use-quotes-funding.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-quotes-funding.js","names":[],"sources":["../../src/quotes/use-quotes-funding.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteFundingQueryOptions,\n type ConfigParameter,\n type GetQuoteFundingOptions,\n type QuoteFundingData,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Minimum quote shape `useQuotesFunding` needs: just the on-chain id. */\nexport interface QuotesFundingInputQuote {\n /** On-chain quote id. Off-chain (pending) rows pass `undefined` and are skipped. */\n quoteId?: bigint;\n}\n\n/**\n * Parameters for {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions, \"quoteIds\">, ConfigParameter {\n /**\n * Quotes (or quote-id-bearing rows) to read funding for. Off-chain rows\n * (`quoteId === undefined`) are silently skipped. All resolved on-chain ids\n * are fetched in a single subgraph round-trip.\n */\n quotes: readonly QuotesFundingInputQuote[];\n}\n\n/**\n * Return type of {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingReturnType {\n /** Funding row per input quote, in input order. `null` for off-chain rows or ids the subgraph hasn't surfaced yet. */\n rows: Array<QuoteFundingData | null>;\n /** Σ paid across resolved rows (wei). */\n paid: bigint;\n /** Σ received across resolved rows (wei). */\n received: bigint;\n /** Σ net (paid − received) across resolved rows (wei). */\n net: bigint;\n /** Subset of input ids the subgraph has not yet returned (indexing lag). */\n missingQuoteIds: bigint[];\n /** `true` while the underlying subgraph query is loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\nconst EMPTY: UseQuotesFundingReturnType = {\n rows: [],\n paid: 0n,\n received: 0n,\n net: 0n,\n missingQuoteIds: [],\n isLoading: false,\n error: null,\n};\n\n/**\n * Batch-read funding totals for a list of quotes from the analytics subgraph in\n * a single round-trip and aggregate them into running sums for the group.\n *\n * The hook is the canonical entry point for both single-quote details panels\n * ({@link useQuoteFunding} delegates here with a 1-element list) and grouped\n * quote cards (which want `Σ net`). Off-chain rows are skipped silently.\n *\n * @example\n * ```tsx\n * const { rows, net, isLoading } = useQuotesFunding({ quotes: group.quotes });\n * ```\n */\nexport function useQuotesFunding(parameters: UseQuotesFundingParameters): UseQuotesFundingReturnType {\n const { quotes, ...rest } = parameters;\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const onchainQuoteIds = useMemo(() => {\n const seen = new Set<string>();\n const ids: bigint[] = [];\n for (const quote of quotes) {\n if (quote.quoteId === undefined) continue;\n const key = quote.quoteId.toString();\n if (seen.has(key)) continue;\n seen.add(key);\n ids.push(quote.quoteId);\n }\n return ids;\n }, [quotes]);\n\n const options = getQuoteFundingQueryOptions(config, {\n ...rest,\n chainId: rest.chainId ?? chainId,\n quoteIds: onchainQuoteIds,\n });\n\n const query = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<{ rows: QuoteFundingData[]; missingQuoteIds: bigint[] }, SymmioRequestError>;\n\n return useMemo(() => {\n if (onchainQuoteIds.length === 0) return EMPTY;\n const data = query.data;\n if (!data) {\n return {\n rows: quotes.map(() => null),\n paid: 0n,\n received: 0n,\n net: 0n,\n missingQuoteIds: [],\n isLoading: query.isLoading,\n error: query.error ?? null,\n };\n }\n\n const byQuoteId = new Map<string, QuoteFundingData>();\n for (const row of data.rows) byQuoteId.set(row.quoteId.toString(), row);\n\n let paid = 0n;\n let received = 0n;\n let net = 0n;\n const rows = quotes.map((quote) => {\n if (quote.quoteId === undefined) return null;\n const row = byQuoteId.get(quote.quoteId.toString()) ?? null;\n if (row) {\n paid += row.paid;\n received += row.received;\n net += row.net;\n }\n return row;\n });\n\n return {\n rows,\n paid,\n received,\n net,\n missingQuoteIds: data.missingQuoteIds,\n isLoading: query.isLoading,\n error: query.error ?? null,\n };\n }, [onchainQuoteIds, quotes, query.data, query.isLoading, query.error]);\n}\n"],"mappings":";;;;;;;;AAqDA,IAAM,IAAoC;CACxC,MAAM,CAAC;CACP,MAAM;CACN,UAAU;CACV,KAAK;CACL,iBAAiB,CAAC;CAClB,WAAW;CACX,OAAO;AACT;AAeA,SAAgB,EAAiB,GAAoE;CACnG,IAAM,EAAE,WAAQ,GAAG,MAAS,GACtB,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAkB,QAAc;EACpC,IAAM,oBAAO,IAAI,IAAY,GACvB,IAAgB,CAAC;EACvB,KAAK,IAAM,KAAS,GAAQ;GAC1B,IAAI,EAAM,YAAY,KAAA,GAAW;GACjC,IAAM,IAAM,EAAM,QAAQ,SAAS;GAC/B,EAAK,IAAI,CAAG,MAChB,EAAK,IAAI,CAAG,GACZ,EAAI,KAAK,EAAM,OAAO;EACxB;EACA,OAAO;CACT,GAAG,CAAC,CAAM,CAAC,GAEL,IAAU,EAA4B,GAAQ;EAClD,GAAG;EACH,SAAS,EAAK,WAAW;EACzB,UAAU;CACZ,CAAC,GAEK,IAAQ,EAAS;EACrB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAED,OAAO,QAAc;EACnB,IAAI,EAAgB,WAAW,GAAG,OAAO;EACzC,IAAM,IAAO,EAAM;EACnB,IAAI,CAAC,GACH,OAAO;GACL,MAAM,EAAO,UAAU,IAAI;GAC3B,MAAM;GACN,UAAU;GACV,KAAK;GACL,iBAAiB,CAAC;GAClB,WAAW,EAAM;GACjB,OAAO,EAAM,SAAS;EACxB;EAGF,IAAM,oBAAY,IAAI,IAA8B;EACpD,KAAK,IAAM,KAAO,EAAK,MAAM,EAAU,IAAI,EAAI,QAAQ,SAAS,GAAG,CAAG;EAEtE,IAAI,IAAO,IACP,IAAW,IACX,IAAM;EAYV,OAAO;GACL,MAZW,EAAO,KAAK,MAAU;IACjC,IAAI,EAAM,YAAY,KAAA,GAAW,OAAO;IACxC,IAAM,IAAM,EAAU,IAAI,EAAM,QAAQ,SAAS,CAAC,KAAK;IAMvD,OALI,MACF,KAAQ,EAAI,MACZ,KAAY,EAAI,UAChB,KAAO,EAAI,MAEN;GACT,CAGE;GACA;GACA;GACA;GACA,iBAAiB,EAAK;GACtB,WAAW,EAAM;GACjB,OAAO,EAAM,SAAS;EACxB;CACF,GAAG;EAAC;EAAiB;EAAQ,EAAM;EAAM,EAAM;EAAW,EAAM;CAAK,CAAC;AACxE"}
1
+ {"version":3,"file":"use-quotes-funding.js","names":[],"sources":["../../src/quotes/use-quotes-funding.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getQuoteFundingQueryOptions,\n type ConfigParameter,\n type GetQuoteFundingOptions,\n type QuoteFundingData,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\n\n/** Minimum quote shape `useQuotesFunding` needs: just the on-chain id. */\nexport interface QuotesFundingInputQuote {\n /** On-chain quote id. Off-chain (pending) rows pass `undefined` and are skipped. */\n quoteId?: bigint;\n}\n\n/**\n * Parameters for {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingParameters extends Omit<GetQuoteFundingOptions, \"quoteIds\">, ConfigParameter {\n /**\n * Quotes (or quote-id-bearing rows) to read funding for. Off-chain rows\n * (`quoteId === undefined`) are silently skipped. The resolved on-chain ids are\n * de-duplicated and fetched in a single subgraph round-trip, so listing the\n * same quote twice costs one request and contributes to the sums once.\n */\n quotes: readonly QuotesFundingInputQuote[];\n}\n\n/**\n * Return type of {@link useQuotesFunding}.\n */\nexport interface UseQuotesFundingReturnType {\n /**\n * Funding row per input quote, aligned 1:1 with `quotes` and in input order —\n * `rows.length === quotes.length` on every path, including while loading and\n * when nothing on-chain was requested. An entry is `null` for an off-chain row\n * (no `quoteId`) or for an id the subgraph has not surfaced yet.\n */\n rows: Array<QuoteFundingData | null>;\n /**\n * Σ funding paid across the resolved rows (wei). Summed over the **distinct**\n * on-chain ids, so a quote listed twice contributes once.\n */\n paid: bigint;\n /**\n * Σ funding received across the resolved rows (wei). Summed over the\n * **distinct** on-chain ids, so a quote listed twice contributes once.\n */\n received: bigint;\n /**\n * Σ `received − paid` across the resolved rows (wei). **Positive = the position\n * earned funding**; negative = it paid for it. A lower bound while\n * `missingQuoteIds` is non-empty.\n */\n netReceived: bigint;\n /**\n * Requested on-chain ids that have no funding row yet. While the query is in\n * flight — and if it fails — this is **every** requested id, since nothing has\n * resolved; once it settles it is the subset the subgraph did not return\n * (indexing lag). Always empty when no on-chain ids were requested.\n */\n missingQuoteIds: bigint[];\n /** `true` while the underlying subgraph query is loading. */\n isLoading: boolean;\n /** Normalized request error, when one occurred. */\n error: SymmioRequestError | null;\n}\n\n/**\n * Batch-read funding totals for a list of quotes from the analytics subgraph in\n * a single round-trip and aggregate them into running sums for the group.\n *\n * The hook is the canonical entry point for both single-quote details panels\n * ({@link useQuoteFunding} delegates here with a 1-element list) and grouped\n * quote cards (which want `Σ netReceived`). Off-chain rows are skipped silently,\n * and duplicate ids are fetched — and summed — exactly once.\n *\n * **Sign convention** — `netReceived = received − paid`, the P&L perspective, so\n * a **positive** value means the position **earned** funding. This matches\n * `QuoteFundingData.netReceived` and the uPnL folds, and is the inverse of the\n * cost-positive on-chain `int256`. A \"green = income\" UI renders it directly.\n *\n * **Settled to date only** — the totals cover funding the protocol has already\n * charged and the analytics subgraph has indexed. Funding accrued since a\n * quote's last funding charge is not indexed anywhere and is therefore not\n * included.\n *\n * @param parameters - The quotes to read funding for, plus optional chain/config overrides.\n * @returns Per-quote rows aligned with `quotes`, the aggregate sums, and query state.\n *\n * @example\n * ```tsx\n * const { rows, netReceived, missingQuoteIds, isLoading } = useQuotesFunding({ quotes: group.quotes });\n * // `netReceived > 0n` → the position earned funding across the resolved rows.\n * ```\n */\nexport function useQuotesFunding(parameters: UseQuotesFundingParameters): UseQuotesFundingReturnType {\n const { quotes, ...rest } = parameters;\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n\n const onchainQuoteIds = useMemo(() => {\n const seen = new Set<string>();\n const ids: bigint[] = [];\n for (const quote of quotes) {\n if (quote.quoteId === undefined) continue;\n const key = quote.quoteId.toString();\n if (seen.has(key)) continue;\n seen.add(key);\n ids.push(quote.quoteId);\n }\n return ids;\n }, [quotes]);\n\n const options = getQuoteFundingQueryOptions(config, {\n ...rest,\n chainId: rest.chainId ?? chainId,\n quoteIds: onchainQuoteIds,\n });\n\n const query = useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<{ rows: QuoteFundingData[]; missingQuoteIds: bigint[] }, SymmioRequestError>;\n\n return useMemo(() => {\n /** Nothing on-chain to read: the query is disabled, but `rows` still owes one entry per input quote. */\n if (onchainQuoteIds.length === 0) {\n return {\n rows: quotes.map(() => null),\n paid: 0n,\n received: 0n,\n netReceived: 0n,\n missingQuoteIds: [],\n isLoading: false,\n error: null,\n };\n }\n\n const data = query.data;\n if (!data) {\n return {\n rows: quotes.map(() => null),\n paid: 0n,\n received: 0n,\n netReceived: 0n,\n /** In flight (or failed): nothing resolved, so every requested id is still outstanding. */\n missingQuoteIds: [...onchainQuoteIds],\n isLoading: query.isLoading,\n error: query.error ?? null,\n };\n }\n\n /** First row wins per id — a repeated row for the same quote must not double-count. */\n const byQuoteId = new Map<string, QuoteFundingData>();\n for (const row of data.rows) {\n const key = row.quoteId.toString();\n if (!byQuoteId.has(key)) byQuoteId.set(key, row);\n }\n\n let paid = 0n;\n let received = 0n;\n /** Fold over the de-duped ids, never over `quotes` — the same id listed twice is fetched once and must sum once. */\n for (const quoteId of onchainQuoteIds) {\n const row = byQuoteId.get(quoteId.toString());\n if (row === undefined) continue;\n paid += row.paid;\n received += row.received;\n }\n\n /** Built by lookup afterwards, so the 1:1 alignment with `quotes` is independent of the fold. */\n const rows = quotes.map((quote) =>\n quote.quoteId === undefined ? null : (byQuoteId.get(quote.quoteId.toString()) ?? null),\n );\n\n return {\n rows,\n paid,\n received,\n /** Derived from the sums so the aggregate keeps the row-level `netReceived = received − paid` invariant. */\n netReceived: received - paid,\n missingQuoteIds: data.missingQuoteIds,\n isLoading: query.isLoading,\n error: query.error ?? null,\n };\n }, [onchainQuoteIds, quotes, query.data, query.isLoading, query.error]);\n}\n"],"mappings":";;;;;;;;AAsGA,SAAgB,EAAiB,GAAoE;CACnG,IAAM,EAAE,WAAQ,GAAG,MAAS,GACtB,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAE3B,IAAkB,QAAc;EACpC,IAAM,oBAAO,IAAI,IAAY,GACvB,IAAgB,CAAC;EACvB,KAAK,IAAM,KAAS,GAAQ;GAC1B,IAAI,EAAM,YAAY,KAAA,GAAW;GACjC,IAAM,IAAM,EAAM,QAAQ,SAAS;GAC/B,EAAK,IAAI,CAAG,MAChB,EAAK,IAAI,CAAG,GACZ,EAAI,KAAK,EAAM,OAAO;EACxB;EACA,OAAO;CACT,GAAG,CAAC,CAAM,CAAC,GAEL,IAAU,EAA4B,GAAQ;EAClD,GAAG;EACH,SAAS,EAAK,WAAW;EACzB,UAAU;CACZ,CAAC,GAEK,IAAQ,EAAS;EACrB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAED,OAAO,QAAc;EAEnB,IAAI,EAAgB,WAAW,GAC7B,OAAO;GACL,MAAM,EAAO,UAAU,IAAI;GAC3B,MAAM;GACN,UAAU;GACV,aAAa;GACb,iBAAiB,CAAC;GAClB,WAAW;GACX,OAAO;EACT;EAGF,IAAM,IAAO,EAAM;EACnB,IAAI,CAAC,GACH,OAAO;GACL,MAAM,EAAO,UAAU,IAAI;GAC3B,MAAM;GACN,UAAU;GACV,aAAa;GAEb,iBAAiB,CAAC,GAAG,CAAe;GACpC,WAAW,EAAM;GACjB,OAAO,EAAM,SAAS;EACxB;EAIF,IAAM,oBAAY,IAAI,IAA8B;EACpD,KAAK,IAAM,KAAO,EAAK,MAAM;GAC3B,IAAM,IAAM,EAAI,QAAQ,SAAS;GACjC,AAAK,EAAU,IAAI,CAAG,KAAG,EAAU,IAAI,GAAK,CAAG;EACjD;EAEA,IAAI,IAAO,IACP,IAAW;EAEf,KAAK,IAAM,KAAW,GAAiB;GACrC,IAAM,IAAM,EAAU,IAAI,EAAQ,SAAS,CAAC;GACxC,MAAQ,KAAA,MACZ,KAAQ,EAAI,MACZ,KAAY,EAAI;EAClB;EAOA,OAAO;GACL,MALW,EAAO,KAAK,MACvB,EAAM,YAAY,KAAA,IAAY,OAAQ,EAAU,IAAI,EAAM,QAAQ,SAAS,CAAC,KAAK,IAIjF;GACA;GACA;GAEA,aAAa,IAAW;GACxB,iBAAiB,EAAK;GACtB,WAAW,EAAM;GACjB,OAAO,EAAM,SAAS;EACxB;CACF,GAAG;EAAC;EAAiB;EAAQ,EAAM;EAAM,EAAM;EAAW,EAAM;CAAK,CAAC;AACxE"}
@@ -0,0 +1,27 @@
1
+ import { RequestToCancelCloseRequestParameters } 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 useRequestToCancelCloseRequest}. */
6
+ export type UseRequestToCancelCloseRequestParameters = WriteParameters;
7
+ /** Result returned by the {@link useRequestToCancelCloseRequest} mutation. */
8
+ export type RequestToCancelCloseRequestResult = WriteResult;
9
+ /** Return type of {@link useRequestToCancelCloseRequest}. */
10
+ export type UseRequestToCancelCloseRequestReturnType = UseMutationResult<RequestToCancelCloseRequestResult, SymmioRequestError, RequestToCancelCloseRequestParameters>;
11
+ /**
12
+ * Cancel a pending close (`requestToCancelCloseRequest`, routed through the
13
+ * AccountLayer `_call` proxy) — how a partyA backs out of a resting close (e.g.
14
+ * a limit close) while the quote is `CLOSE_PENDING`. If partyB accepts, the quote
15
+ * returns to `OPENED`; if partyB stalls it enters `CANCEL_CLOSE_PENDING`, which
16
+ * {@link useForceCancelCloseRequest} escalates once the cooldown passes. On
17
+ * success (after the receipt) the subaccount's open-positions read is invalidated
18
+ * so the row's status refreshes.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const { mutate } = useRequestToCancelCloseRequest();
23
+ * mutate({ account: "0xsub…", quoteId: 42n });
24
+ * ```
25
+ */
26
+ export declare function useRequestToCancelCloseRequest(parameters?: UseRequestToCancelCloseRequestParameters): UseRequestToCancelCloseRequestReturnType;
27
+ //# sourceMappingURL=use-request-to-cancel-close-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-to-cancel-close-request.d.ts","sourceRoot":"","sources":["../../src/quotes/use-request-to-cancel-close-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,qCAAqC,EAC3C,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,6DAA6D;AAC7D,MAAM,MAAM,wCAAwC,GAAG,eAAe,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,MAAM,iCAAiC,GAAG,WAAW,CAAC;AAE5D,6DAA6D;AAC7D,MAAM,MAAM,wCAAwC,GAAG,iBAAiB,CACtE,iCAAiC,EACjC,kBAAkB,EAClB,qCAAqC,CACtC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,GAAE,wCAA6C,GACxD,wCAAwC,CAmC1C"}