@orderly.network/hooks 1.1.4-rc.8 → 1.1.4

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 (475) hide show
  1. package/esm/configProvider.d.ts +17 -0
  2. package/esm/configProvider.d.ts.map +1 -0
  3. package/esm/configProvider.js +54 -0
  4. package/esm/dataProvider.d.ts +10 -0
  5. package/esm/dataProvider.d.ts.map +1 -0
  6. package/esm/dataProvider.js +29 -0
  7. package/esm/index.d.ts +33 -0
  8. package/esm/index.d.ts.map +1 -0
  9. package/esm/index.js +30 -0
  10. package/esm/middleware/signatureMiddleware.d.ts +3 -0
  11. package/esm/middleware/signatureMiddleware.d.ts.map +1 -0
  12. package/esm/middleware/signatureMiddleware.js +32 -0
  13. package/esm/orderly/orderlyHooks.d.ts +30 -0
  14. package/esm/orderly/orderlyHooks.d.ts.map +1 -0
  15. package/esm/orderly/orderlyHooks.js +27 -0
  16. package/esm/orderly/useAccountInfo.d.ts +3 -0
  17. package/esm/orderly/useAccountInfo.d.ts.map +1 -0
  18. package/esm/orderly/useAccountInfo.js +4 -0
  19. package/esm/orderly/useChain.d.ts +6 -0
  20. package/esm/orderly/useChain.d.ts.map +1 -0
  21. package/esm/orderly/useChain.js +22 -0
  22. package/esm/orderly/useChains.d.ts +34 -0
  23. package/esm/orderly/useChains.d.ts.map +1 -0
  24. package/esm/orderly/useChains.js +159 -0
  25. package/esm/orderly/useCollateral.d.ts +16 -0
  26. package/esm/orderly/useCollateral.d.ts.map +1 -0
  27. package/esm/orderly/useCollateral.js +72 -0
  28. package/esm/orderly/useDeposit.d.ts +38 -0
  29. package/esm/orderly/useDeposit.d.ts.map +1 -0
  30. package/esm/orderly/useDeposit.js +270 -0
  31. package/esm/orderly/useFundingRate.d.ts +11 -0
  32. package/esm/orderly/useFundingRate.d.ts.map +1 -0
  33. package/esm/orderly/useFundingRate.js +40 -0
  34. package/esm/orderly/useFundingRates.d.ts +2 -0
  35. package/esm/orderly/useFundingRates.d.ts.map +1 -0
  36. package/esm/orderly/useFundingRates.js +21 -0
  37. package/esm/orderly/useHoldingStream.d.ts +7 -0
  38. package/esm/orderly/useHoldingStream.d.ts.map +1 -0
  39. package/esm/orderly/useHoldingStream.js +47 -0
  40. package/esm/orderly/useIndexPrice.d.ts +2 -0
  41. package/esm/orderly/useIndexPrice.d.ts.map +1 -0
  42. package/esm/orderly/useIndexPrice.js +17 -0
  43. package/esm/orderly/useLeverage.d.ts +2 -0
  44. package/esm/orderly/useLeverage.d.ts.map +1 -0
  45. package/esm/orderly/useLeverage.js +34 -0
  46. package/esm/orderly/useMarginRatio.d.ts +7 -0
  47. package/esm/orderly/useMarginRatio.d.ts.map +1 -0
  48. package/esm/orderly/useMarginRatio.js +41 -0
  49. package/esm/orderly/useMarkPrice.d.ts +4 -0
  50. package/esm/orderly/useMarkPrice.d.ts.map +1 -0
  51. package/esm/orderly/useMarkPrice.js +29 -0
  52. package/esm/orderly/useMarkPricesStream.d.ts +2 -0
  53. package/esm/orderly/useMarkPricesStream.d.ts.map +1 -0
  54. package/esm/orderly/useMarkPricesStream.js +26 -0
  55. package/esm/orderly/useMarketTradeStream.d.ts +9 -0
  56. package/esm/orderly/useMarketTradeStream.d.ts.map +1 -0
  57. package/esm/orderly/useMarketTradeStream.js +51 -0
  58. package/esm/orderly/useMarkets.d.ts +36 -0
  59. package/esm/orderly/useMarkets.d.ts.map +1 -0
  60. package/esm/orderly/useMarkets.js +240 -0
  61. package/esm/orderly/useMarketsStream.d.ts +5 -0
  62. package/esm/orderly/useMarketsStream.d.ts.map +1 -0
  63. package/esm/orderly/useMarketsStream.js +57 -0
  64. package/esm/orderly/useMaxQty.d.ts +3 -0
  65. package/esm/orderly/useMaxQty.d.ts.map +1 -0
  66. package/esm/orderly/useMaxQty.js +114 -0
  67. package/esm/orderly/useOpenInterest.d.ts +2 -0
  68. package/esm/orderly/useOpenInterest.d.ts.map +1 -0
  69. package/esm/orderly/useOpenInterest.js +15 -0
  70. package/esm/orderly/useOrderEntry.d.ts +63 -0
  71. package/esm/orderly/useOrderEntry.d.ts.map +1 -0
  72. package/esm/orderly/useOrderEntry.js +504 -0
  73. package/esm/orderly/useOrderStream.d.ts +38 -0
  74. package/esm/orderly/useOrderStream.d.ts.map +1 -0
  75. package/esm/orderly/useOrderStream.js +180 -0
  76. package/esm/orderly/useOrderbookStream.d.ts +53 -0
  77. package/esm/orderly/useOrderbookStream.d.ts.map +1 -0
  78. package/esm/orderly/useOrderbookStream.js +309 -0
  79. package/esm/orderly/usePositionStream.d.ts +25 -0
  80. package/esm/orderly/usePositionStream.d.ts.map +1 -0
  81. package/esm/orderly/usePositionStream.js +232 -0
  82. package/esm/orderly/usePrivateDataObserver.d.ts +5 -0
  83. package/esm/orderly/usePrivateDataObserver.d.ts.map +1 -0
  84. package/esm/orderly/usePrivateDataObserver.js +126 -0
  85. package/esm/orderly/useSettleSubscription.d.ts +4 -0
  86. package/esm/orderly/useSettleSubscription.d.ts.map +1 -0
  87. package/esm/orderly/useSettleSubscription.js +20 -0
  88. package/esm/orderly/useSymbolPriceRange.d.ts +13 -0
  89. package/esm/orderly/useSymbolPriceRange.d.ts.map +1 -0
  90. package/esm/orderly/useSymbolPriceRange.js +39 -0
  91. package/esm/orderly/useSymbolsInfo.d.ts +2 -0
  92. package/esm/orderly/useSymbolsInfo.d.ts.map +1 -0
  93. package/esm/orderly/useSymbolsInfo.js +33 -0
  94. package/esm/orderly/useTickerStream.d.ts +3 -0
  95. package/esm/orderly/useTickerStream.d.ts.map +1 -0
  96. package/esm/orderly/useTickerStream.js +86 -0
  97. package/esm/orderly/useWalletSubscription.d.ts +4 -0
  98. package/esm/orderly/useWalletSubscription.d.ts.map +1 -0
  99. package/esm/orderly/useWalletSubscription.js +20 -0
  100. package/esm/orderly/useWithdraw.d.ts +14 -0
  101. package/esm/orderly/useWithdraw.d.ts.map +1 -0
  102. package/esm/orderly/useWithdraw.js +64 -0
  103. package/esm/orderlyContext.d.ts +17 -0
  104. package/esm/orderlyContext.d.ts.map +1 -0
  105. package/esm/orderlyContext.js +5 -0
  106. package/esm/services/dataCenter.d.ts +2 -0
  107. package/esm/services/dataCenter.d.ts.map +1 -0
  108. package/esm/services/dataCenter.js +13 -0
  109. package/esm/services/painter/backgroundPaint.d.ts +9 -0
  110. package/esm/services/painter/backgroundPaint.d.ts.map +1 -0
  111. package/esm/services/painter/backgroundPaint.js +41 -0
  112. package/esm/services/painter/basePaint.d.ts +90 -0
  113. package/esm/services/painter/basePaint.d.ts.map +1 -0
  114. package/esm/services/painter/basePaint.js +6 -0
  115. package/esm/services/painter/dataPaint.d.ts +16 -0
  116. package/esm/services/painter/dataPaint.d.ts.map +1 -0
  117. package/esm/services/painter/dataPaint.js +195 -0
  118. package/esm/services/painter/layout.config.d.ts +3 -0
  119. package/esm/services/painter/layout.config.d.ts.map +1 -0
  120. package/esm/services/painter/layout.config.js +52 -0
  121. package/esm/services/painter/painter.d.ts +12 -0
  122. package/esm/services/painter/painter.d.ts.map +1 -0
  123. package/esm/services/painter/painter.js +37 -0
  124. package/esm/services/painter/resource.d.ts +7 -0
  125. package/esm/services/painter/resource.d.ts.map +1 -0
  126. package/esm/services/painter/resource.js +15 -0
  127. package/esm/statusProvider.d.ts +8 -0
  128. package/esm/statusProvider.d.ts.map +1 -0
  129. package/esm/statusProvider.js +8 -0
  130. package/esm/unuse/apiPrefixMiddleware.d.ts +3 -0
  131. package/esm/unuse/apiPrefixMiddleware.d.ts.map +1 -0
  132. package/esm/unuse/apiPrefixMiddleware.js +29 -0
  133. package/esm/unuse/fn.d.ts +2 -0
  134. package/esm/unuse/fn.d.ts.map +1 -0
  135. package/esm/unuse/fn.js +6 -0
  136. package/esm/unuse/useBalance.d.ts +2 -0
  137. package/esm/unuse/useBalance.d.ts.map +1 -0
  138. package/esm/unuse/useBalance.js +12 -0
  139. package/esm/unuse/useFetures.d.ts +11 -0
  140. package/esm/unuse/useFetures.d.ts.map +1 -0
  141. package/esm/unuse/useFetures.js +39 -0
  142. package/esm/unuse/useRunOnce.d.ts +7 -0
  143. package/esm/unuse/useRunOnce.d.ts.map +1 -0
  144. package/esm/unuse/useRunOnce.js +17 -0
  145. package/esm/unuse/useSyncEnd.d.ts +2 -0
  146. package/esm/unuse/useSyncEnd.d.ts.map +1 -0
  147. package/esm/unuse/useSyncEnd.js +10 -0
  148. package/esm/unuse/useTokenInfo.d.ts +2 -0
  149. package/esm/unuse/useTokenInfo.d.ts.map +1 -0
  150. package/esm/unuse/useTokenInfo.js +20 -0
  151. package/esm/unuse/useUnsettlementPnL.d.ts +2 -0
  152. package/esm/unuse/useUnsettlementPnL.d.ts.map +1 -0
  153. package/esm/unuse/useUnsettlementPnL.js +20 -0
  154. package/esm/useAccount.d.ts +8 -0
  155. package/esm/useAccount.d.ts.map +1 -0
  156. package/esm/useAccount.js +59 -0
  157. package/esm/useAccountInstance.d.ts +3 -0
  158. package/esm/useAccountInstance.d.ts.map +1 -0
  159. package/esm/useAccountInstance.js +23 -0
  160. package/esm/useBoolean.d.ts +6 -0
  161. package/esm/useBoolean.d.ts.map +1 -0
  162. package/esm/useBoolean.js +8 -0
  163. package/esm/useConfig.d.ts +3 -0
  164. package/esm/useConfig.d.ts.map +1 -0
  165. package/esm/useConfig.js +12 -0
  166. package/esm/useEventEmitter.d.ts +3 -0
  167. package/esm/useEventEmitter.d.ts.map +1 -0
  168. package/esm/useEventEmitter.js +12 -0
  169. package/esm/useLazyQuery.d.ts +13 -0
  170. package/esm/useLazyQuery.d.ts.map +1 -0
  171. package/esm/useLazyQuery.js +35 -0
  172. package/esm/useLocalStorage.d.ts +2 -0
  173. package/esm/useLocalStorage.d.ts.map +1 -0
  174. package/esm/useLocalStorage.js +74 -0
  175. package/esm/useMediaQuery.d.ts +2 -0
  176. package/esm/useMediaQuery.d.ts.map +1 -0
  177. package/esm/useMediaQuery.js +36 -0
  178. package/esm/useMutation.d.ts +10 -0
  179. package/esm/useMutation.d.ts.map +1 -0
  180. package/esm/useMutation.js +64 -0
  181. package/esm/useObserve.d.ts +6 -0
  182. package/esm/useObserve.d.ts.map +1 -0
  183. package/esm/useObserve.js +8 -0
  184. package/esm/useParamsCheck.d.ts +4 -0
  185. package/esm/useParamsCheck.d.ts.map +1 -0
  186. package/esm/useParamsCheck.js +14 -0
  187. package/esm/usePoster.d.ts +14 -0
  188. package/esm/usePoster.d.ts.map +1 -0
  189. package/esm/usePoster.js +52 -0
  190. package/esm/usePreloadData.d.ts +5 -0
  191. package/esm/usePreloadData.d.ts.map +1 -0
  192. package/esm/usePreloadData.js +14 -0
  193. package/esm/usePrivateInfiniteQuery.d.ts +5 -0
  194. package/esm/usePrivateInfiniteQuery.d.ts.map +1 -0
  195. package/esm/usePrivateInfiniteQuery.js +25 -0
  196. package/esm/usePrivateQuery.d.ts +10 -0
  197. package/esm/usePrivateQuery.d.ts.map +1 -0
  198. package/esm/usePrivateQuery.js +26 -0
  199. package/esm/useQuery.d.ts +10 -0
  200. package/esm/useQuery.d.ts.map +1 -0
  201. package/esm/useQuery.js +20 -0
  202. package/esm/useSessionStorage.d.ts +2 -0
  203. package/esm/useSessionStorage.d.ts.map +1 -0
  204. package/esm/useSessionStorage.js +60 -0
  205. package/esm/useWS.d.ts +3 -0
  206. package/esm/useWS.d.ts.map +1 -0
  207. package/esm/useWS.js +51 -0
  208. package/esm/useWsStatus.d.ts +7 -0
  209. package/esm/useWsStatus.d.ts.map +1 -0
  210. package/esm/useWsStatus.js +41 -0
  211. package/esm/utils/createGetter.d.ts +4 -0
  212. package/esm/utils/createGetter.d.ts.map +1 -0
  213. package/esm/utils/createGetter.js +21 -0
  214. package/esm/utils/createOrder.d.ts +56 -0
  215. package/esm/utils/createOrder.d.ts.map +1 -0
  216. package/esm/utils/createOrder.js +324 -0
  217. package/esm/utils/fetcher.d.ts +6 -0
  218. package/esm/utils/fetcher.d.ts.map +1 -0
  219. package/esm/utils/fetcher.js +2 -0
  220. package/esm/utils/json.d.ts +2 -0
  221. package/esm/utils/json.d.ts.map +1 -0
  222. package/esm/utils/json.js +8 -0
  223. package/esm/utils/orderEntryHelper.d.ts +25 -0
  224. package/esm/utils/orderEntryHelper.d.ts.map +1 -0
  225. package/esm/utils/orderEntryHelper.js +242 -0
  226. package/esm/utils/parseHolding.d.ts +9 -0
  227. package/esm/utils/parseHolding.d.ts.map +1 -0
  228. package/esm/utils/parseHolding.js +21 -0
  229. package/esm/version.d.ts +10 -0
  230. package/esm/version.d.ts.map +1 -0
  231. package/esm/version.js +6 -0
  232. package/esm/walletConnectorContext.d.ts +30 -0
  233. package/esm/walletConnectorContext.d.ts.map +1 -0
  234. package/esm/walletConnectorContext.js +5 -0
  235. package/lib/configProvider.d.ts +17 -0
  236. package/lib/configProvider.d.ts.map +1 -0
  237. package/lib/configProvider.js +82 -0
  238. package/lib/dataProvider.d.ts +10 -0
  239. package/lib/dataProvider.d.ts.map +1 -0
  240. package/lib/dataProvider.js +34 -0
  241. package/lib/index.d.ts +33 -0
  242. package/lib/index.d.ts.map +1 -0
  243. package/lib/index.js +88 -0
  244. package/lib/middleware/signatureMiddleware.d.ts +3 -0
  245. package/lib/middleware/signatureMiddleware.d.ts.map +1 -0
  246. package/lib/middleware/signatureMiddleware.js +36 -0
  247. package/lib/orderly/orderlyHooks.d.ts +30 -0
  248. package/lib/orderly/orderlyHooks.d.ts.map +1 -0
  249. package/lib/orderly/orderlyHooks.js +58 -0
  250. package/lib/orderly/useAccountInfo.d.ts +3 -0
  251. package/lib/orderly/useAccountInfo.d.ts.map +1 -0
  252. package/lib/orderly/useAccountInfo.js +8 -0
  253. package/lib/orderly/useChain.d.ts +6 -0
  254. package/lib/orderly/useChain.d.ts.map +1 -0
  255. package/lib/orderly/useChain.js +26 -0
  256. package/lib/orderly/useChains.d.ts +34 -0
  257. package/lib/orderly/useChains.d.ts.map +1 -0
  258. package/lib/orderly/useChains.js +166 -0
  259. package/lib/orderly/useCollateral.d.ts +16 -0
  260. package/lib/orderly/useCollateral.d.ts.map +1 -0
  261. package/lib/orderly/useCollateral.js +76 -0
  262. package/lib/orderly/useDeposit.d.ts +38 -0
  263. package/lib/orderly/useDeposit.d.ts.map +1 -0
  264. package/lib/orderly/useDeposit.js +274 -0
  265. package/lib/orderly/useFundingRate.d.ts +11 -0
  266. package/lib/orderly/useFundingRate.d.ts.map +1 -0
  267. package/lib/orderly/useFundingRate.js +44 -0
  268. package/lib/orderly/useFundingRates.d.ts +2 -0
  269. package/lib/orderly/useFundingRates.d.ts.map +1 -0
  270. package/lib/orderly/useFundingRates.js +25 -0
  271. package/lib/orderly/useHoldingStream.d.ts +7 -0
  272. package/lib/orderly/useHoldingStream.d.ts.map +1 -0
  273. package/lib/orderly/useHoldingStream.js +54 -0
  274. package/lib/orderly/useIndexPrice.d.ts +2 -0
  275. package/lib/orderly/useIndexPrice.d.ts.map +1 -0
  276. package/lib/orderly/useIndexPrice.js +24 -0
  277. package/lib/orderly/useLeverage.d.ts +2 -0
  278. package/lib/orderly/useLeverage.d.ts.map +1 -0
  279. package/lib/orderly/useLeverage.js +38 -0
  280. package/lib/orderly/useMarginRatio.d.ts +7 -0
  281. package/lib/orderly/useMarginRatio.d.ts.map +1 -0
  282. package/lib/orderly/useMarginRatio.js +45 -0
  283. package/lib/orderly/useMarkPrice.d.ts +4 -0
  284. package/lib/orderly/useMarkPrice.d.ts.map +1 -0
  285. package/lib/orderly/useMarkPrice.js +33 -0
  286. package/lib/orderly/useMarkPricesStream.d.ts +2 -0
  287. package/lib/orderly/useMarkPricesStream.d.ts.map +1 -0
  288. package/lib/orderly/useMarkPricesStream.js +33 -0
  289. package/lib/orderly/useMarketTradeStream.d.ts +9 -0
  290. package/lib/orderly/useMarketTradeStream.d.ts.map +1 -0
  291. package/lib/orderly/useMarketTradeStream.js +55 -0
  292. package/lib/orderly/useMarkets.d.ts +36 -0
  293. package/lib/orderly/useMarkets.d.ts.map +1 -0
  294. package/lib/orderly/useMarkets.js +244 -0
  295. package/lib/orderly/useMarketsStream.d.ts +5 -0
  296. package/lib/orderly/useMarketsStream.d.ts.map +1 -0
  297. package/lib/orderly/useMarketsStream.js +64 -0
  298. package/lib/orderly/useMaxQty.d.ts +3 -0
  299. package/lib/orderly/useMaxQty.d.ts.map +1 -0
  300. package/lib/orderly/useMaxQty.js +118 -0
  301. package/lib/orderly/useOpenInterest.d.ts +2 -0
  302. package/lib/orderly/useOpenInterest.d.ts.map +1 -0
  303. package/lib/orderly/useOpenInterest.js +22 -0
  304. package/lib/orderly/useOrderEntry.d.ts +63 -0
  305. package/lib/orderly/useOrderEntry.d.ts.map +1 -0
  306. package/lib/orderly/useOrderEntry.js +508 -0
  307. package/lib/orderly/useOrderStream.d.ts +38 -0
  308. package/lib/orderly/useOrderStream.d.ts.map +1 -0
  309. package/lib/orderly/useOrderStream.js +187 -0
  310. package/lib/orderly/useOrderbookStream.d.ts +53 -0
  311. package/lib/orderly/useOrderbookStream.d.ts.map +1 -0
  312. package/lib/orderly/useOrderbookStream.js +315 -0
  313. package/lib/orderly/usePositionStream.d.ts +25 -0
  314. package/lib/orderly/usePositionStream.d.ts.map +1 -0
  315. package/lib/orderly/usePositionStream.js +236 -0
  316. package/lib/orderly/usePrivateDataObserver.d.ts +5 -0
  317. package/lib/orderly/usePrivateDataObserver.d.ts.map +1 -0
  318. package/lib/orderly/usePrivateDataObserver.js +130 -0
  319. package/lib/orderly/useSettleSubscription.d.ts +4 -0
  320. package/lib/orderly/useSettleSubscription.d.ts.map +1 -0
  321. package/lib/orderly/useSettleSubscription.js +27 -0
  322. package/lib/orderly/useSymbolPriceRange.d.ts +13 -0
  323. package/lib/orderly/useSymbolPriceRange.d.ts.map +1 -0
  324. package/lib/orderly/useSymbolPriceRange.js +43 -0
  325. package/lib/orderly/useSymbolsInfo.d.ts +2 -0
  326. package/lib/orderly/useSymbolsInfo.d.ts.map +1 -0
  327. package/lib/orderly/useSymbolsInfo.js +37 -0
  328. package/lib/orderly/useTickerStream.d.ts +3 -0
  329. package/lib/orderly/useTickerStream.d.ts.map +1 -0
  330. package/lib/orderly/useTickerStream.js +90 -0
  331. package/lib/orderly/useWalletSubscription.d.ts +4 -0
  332. package/lib/orderly/useWalletSubscription.d.ts.map +1 -0
  333. package/lib/orderly/useWalletSubscription.js +27 -0
  334. package/lib/orderly/useWithdraw.d.ts +14 -0
  335. package/lib/orderly/useWithdraw.d.ts.map +1 -0
  336. package/lib/orderly/useWithdraw.js +68 -0
  337. package/lib/orderlyContext.d.ts +17 -0
  338. package/lib/orderlyContext.d.ts.map +1 -0
  339. package/lib/orderlyContext.js +8 -0
  340. package/lib/services/dataCenter.d.ts +2 -0
  341. package/lib/services/dataCenter.d.ts.map +1 -0
  342. package/lib/services/dataCenter.js +15 -0
  343. package/lib/services/painter/backgroundPaint.d.ts +9 -0
  344. package/lib/services/painter/backgroundPaint.d.ts.map +1 -0
  345. package/lib/services/painter/backgroundPaint.js +45 -0
  346. package/lib/services/painter/basePaint.d.ts +90 -0
  347. package/lib/services/painter/basePaint.d.ts.map +1 -0
  348. package/lib/services/painter/basePaint.js +10 -0
  349. package/lib/services/painter/dataPaint.d.ts +16 -0
  350. package/lib/services/painter/dataPaint.d.ts.map +1 -0
  351. package/lib/services/painter/dataPaint.js +199 -0
  352. package/lib/services/painter/layout.config.d.ts +3 -0
  353. package/lib/services/painter/layout.config.d.ts.map +1 -0
  354. package/lib/services/painter/layout.config.js +55 -0
  355. package/lib/services/painter/painter.d.ts +12 -0
  356. package/lib/services/painter/painter.d.ts.map +1 -0
  357. package/lib/services/painter/painter.js +41 -0
  358. package/lib/services/painter/resource.d.ts +7 -0
  359. package/lib/services/painter/resource.d.ts.map +1 -0
  360. package/lib/services/painter/resource.js +19 -0
  361. package/lib/statusProvider.d.ts +8 -0
  362. package/lib/statusProvider.d.ts.map +1 -0
  363. package/lib/statusProvider.js +12 -0
  364. package/lib/unuse/apiPrefixMiddleware.d.ts +3 -0
  365. package/lib/unuse/apiPrefixMiddleware.d.ts.map +1 -0
  366. package/lib/unuse/apiPrefixMiddleware.js +33 -0
  367. package/lib/unuse/fn.d.ts +2 -0
  368. package/lib/unuse/fn.d.ts.map +1 -0
  369. package/lib/unuse/fn.js +9 -0
  370. package/lib/unuse/useBalance.d.ts +2 -0
  371. package/lib/unuse/useBalance.d.ts.map +1 -0
  372. package/lib/unuse/useBalance.js +19 -0
  373. package/lib/unuse/useFetures.d.ts +11 -0
  374. package/lib/unuse/useFetures.d.ts.map +1 -0
  375. package/lib/unuse/useFetures.js +43 -0
  376. package/lib/unuse/useRunOnce.d.ts +7 -0
  377. package/lib/unuse/useRunOnce.d.ts.map +1 -0
  378. package/lib/unuse/useRunOnce.js +21 -0
  379. package/lib/unuse/useSyncEnd.d.ts +2 -0
  380. package/lib/unuse/useSyncEnd.d.ts.map +1 -0
  381. package/lib/unuse/useSyncEnd.js +14 -0
  382. package/lib/unuse/useTokenInfo.d.ts +2 -0
  383. package/lib/unuse/useTokenInfo.d.ts.map +1 -0
  384. package/lib/unuse/useTokenInfo.js +24 -0
  385. package/lib/unuse/useUnsettlementPnL.d.ts +2 -0
  386. package/lib/unuse/useUnsettlementPnL.d.ts.map +1 -0
  387. package/lib/unuse/useUnsettlementPnL.js +24 -0
  388. package/lib/useAccount.d.ts +8 -0
  389. package/lib/useAccount.d.ts.map +1 -0
  390. package/lib/useAccount.js +63 -0
  391. package/lib/useAccountInstance.d.ts +3 -0
  392. package/lib/useAccountInstance.d.ts.map +1 -0
  393. package/lib/useAccountInstance.js +30 -0
  394. package/lib/useBoolean.d.ts +6 -0
  395. package/lib/useBoolean.d.ts.map +1 -0
  396. package/lib/useBoolean.js +12 -0
  397. package/lib/useConfig.d.ts +3 -0
  398. package/lib/useConfig.d.ts.map +1 -0
  399. package/lib/useConfig.js +16 -0
  400. package/lib/useEventEmitter.d.ts +3 -0
  401. package/lib/useEventEmitter.d.ts.map +1 -0
  402. package/lib/useEventEmitter.js +19 -0
  403. package/lib/useLazyQuery.d.ts +13 -0
  404. package/lib/useLazyQuery.d.ts.map +1 -0
  405. package/lib/useLazyQuery.js +42 -0
  406. package/lib/useLocalStorage.d.ts +2 -0
  407. package/lib/useLocalStorage.d.ts.map +1 -0
  408. package/lib/useLocalStorage.js +78 -0
  409. package/lib/useMediaQuery.d.ts +2 -0
  410. package/lib/useMediaQuery.d.ts.map +1 -0
  411. package/lib/useMediaQuery.js +40 -0
  412. package/lib/useMutation.d.ts +10 -0
  413. package/lib/useMutation.d.ts.map +1 -0
  414. package/lib/useMutation.js +71 -0
  415. package/lib/useObserve.d.ts +6 -0
  416. package/lib/useObserve.d.ts.map +1 -0
  417. package/lib/useObserve.js +12 -0
  418. package/lib/useParamsCheck.d.ts +4 -0
  419. package/lib/useParamsCheck.d.ts.map +1 -0
  420. package/lib/useParamsCheck.js +18 -0
  421. package/lib/usePoster.d.ts +14 -0
  422. package/lib/usePoster.d.ts.map +1 -0
  423. package/lib/usePoster.js +56 -0
  424. package/lib/usePreloadData.d.ts +5 -0
  425. package/lib/usePreloadData.d.ts.map +1 -0
  426. package/lib/usePreloadData.js +18 -0
  427. package/lib/usePrivateInfiniteQuery.d.ts +5 -0
  428. package/lib/usePrivateInfiniteQuery.d.ts.map +1 -0
  429. package/lib/usePrivateInfiniteQuery.js +32 -0
  430. package/lib/usePrivateQuery.d.ts +10 -0
  431. package/lib/usePrivateQuery.d.ts.map +1 -0
  432. package/lib/usePrivateQuery.js +33 -0
  433. package/lib/useQuery.d.ts +10 -0
  434. package/lib/useQuery.d.ts.map +1 -0
  435. package/lib/useQuery.js +27 -0
  436. package/lib/useSessionStorage.d.ts +2 -0
  437. package/lib/useSessionStorage.d.ts.map +1 -0
  438. package/lib/useSessionStorage.js +64 -0
  439. package/lib/useWS.d.ts +3 -0
  440. package/lib/useWS.d.ts.map +1 -0
  441. package/lib/useWS.js +58 -0
  442. package/lib/useWsStatus.d.ts +7 -0
  443. package/lib/useWsStatus.d.ts.map +1 -0
  444. package/lib/useWsStatus.js +45 -0
  445. package/lib/utils/createGetter.d.ts +4 -0
  446. package/lib/utils/createGetter.d.ts.map +1 -0
  447. package/lib/utils/createGetter.js +25 -0
  448. package/lib/utils/createOrder.d.ts +56 -0
  449. package/lib/utils/createOrder.d.ts.map +1 -0
  450. package/lib/utils/createOrder.js +337 -0
  451. package/lib/utils/fetcher.d.ts +6 -0
  452. package/lib/utils/fetcher.d.ts.map +1 -0
  453. package/lib/utils/fetcher.js +6 -0
  454. package/lib/utils/json.d.ts +2 -0
  455. package/lib/utils/json.d.ts.map +1 -0
  456. package/lib/utils/json.js +12 -0
  457. package/lib/utils/orderEntryHelper.d.ts +25 -0
  458. package/lib/utils/orderEntryHelper.d.ts.map +1 -0
  459. package/lib/utils/orderEntryHelper.js +250 -0
  460. package/lib/utils/parseHolding.d.ts +9 -0
  461. package/lib/utils/parseHolding.d.ts.map +1 -0
  462. package/lib/utils/parseHolding.js +25 -0
  463. package/lib/version.d.ts +10 -0
  464. package/lib/version.d.ts.map +1 -0
  465. package/lib/version.js +8 -0
  466. package/lib/walletConnectorContext.d.ts +30 -0
  467. package/lib/walletConnectorContext.d.ts.map +1 -0
  468. package/lib/walletConnectorContext.js +9 -0
  469. package/package.json +18 -13
  470. package/dist/index.d.mts +0 -559
  471. package/dist/index.d.ts +0 -559
  472. package/dist/index.js +0 -5449
  473. package/dist/index.js.map +0 -1
  474. package/dist/index.mjs +0 -5365
  475. package/dist/index.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarketTradeStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarketTradeStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI7C,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,oBAAoB,WACvB,MAAM,YACL,wBAAwB;;;CA8DlC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { useWS } from "../useWS";
2
+ import { useEffect, useState } from "react";
3
+ export const useMarketTradeStream = (symbol, options = {}) => {
4
+ if (!symbol) {
5
+ throw new Error("useTradeStream: symbol is required");
6
+ }
7
+ const [trades, setTrades] = useState([]);
8
+ const [isLoading, setIsLoading] = useState(false);
9
+ const { limit = 50 } = options;
10
+ const ws = useWS();
11
+ useEffect(() => {
12
+ setIsLoading(true);
13
+ setTrades(() => []);
14
+ ws.onceSubscribe({
15
+ id: `${symbol}@trade`,
16
+ event: "request",
17
+ params: {
18
+ type: "trade",
19
+ symbol: symbol,
20
+ limit,
21
+ },
22
+ }, {
23
+ onMessage: (data) => {
24
+ setIsLoading(false);
25
+ setTrades(() => data);
26
+ },
27
+ });
28
+ }, [symbol]);
29
+ useEffect(() => {
30
+ const unsubscript = ws.subscribe({
31
+ id: `${symbol}@trade`,
32
+ event: "subscribe",
33
+ topic: `${symbol}@trade`,
34
+ ts: Date.now(),
35
+ }, {
36
+ onMessage: (data) => {
37
+ setTrades((prev) => {
38
+ const arr = [{ ...data, ts: Date.now() }, ...prev];
39
+ if (arr.length > limit) {
40
+ arr.pop();
41
+ }
42
+ return arr;
43
+ });
44
+ },
45
+ });
46
+ return () => {
47
+ unsubscript?.();
48
+ };
49
+ }, [symbol]);
50
+ return { data: trades, isLoading };
51
+ };
@@ -0,0 +1,36 @@
1
+ import { API } from "@orderly.network/types";
2
+ export declare enum MarketsType {
3
+ FAVORITES = 0,
4
+ RECENT = 1,
5
+ ALL = 2
6
+ }
7
+ export interface FavoriteTab {
8
+ name: string;
9
+ id: number;
10
+ }
11
+ export interface Favorite {
12
+ name: string;
13
+ tabs: FavoriteTab[];
14
+ }
15
+ export interface Recent {
16
+ name: string;
17
+ }
18
+ export declare const useMarkets: (type: MarketsType) => readonly [import("@orderly.network/types").WSMessage.Ticker[], {
19
+ readonly favoriteTabs: FavoriteTab[];
20
+ readonly favorites: {
21
+ tabs: FavoriteTab[];
22
+ name: string;
23
+ }[];
24
+ readonly recent: Recent[];
25
+ readonly addToHistory: (symbol: API.MarketInfoExt) => void;
26
+ readonly updateFavoriteTabs: (tab: FavoriteTab | FavoriteTab[], operator?: {
27
+ add?: boolean;
28
+ update?: boolean;
29
+ delete?: boolean;
30
+ }) => void;
31
+ readonly updateSymbolFavoriteState: (symbol: API.MarketInfoExt, tab: FavoriteTab | FavoriteTab[], del?: boolean) => void;
32
+ readonly pinToTop: (symbol: API.MarketInfoExt) => void;
33
+ readonly getLastSelFavTab: () => FavoriteTab;
34
+ readonly updateSelectedFavoriteTab: (tab: FavoriteTab) => void;
35
+ }];
36
+ //# sourceMappingURL=useMarkets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarkets.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarkets.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI7C,oBAAY,WAAW;IACnB,SAAS,IAAA;IACT,MAAM,IAAA;IACN,GAAG,IAAA;CACN;AAuBD,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,UAAU,SAAU,WAAW;;;;cARlC,MAAM;;;oCAuNkB,IAAI,aAAa;uCAhJd,WAAW,GAAG,WAAW,EAAE,aAAa;QACrE,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,OAAO,CAAC;KACpB;iDAgJ0C,IAAI,aAAa,OAAO,WAAW,GAAG,WAAW,EAAE,QAAO,OAAO;gCAMlF,IAAI,aAAa;;8CA6BH,WAAW;EAsBtD,CAAA"}
@@ -0,0 +1,240 @@
1
+ import { useContext, useMemo, useState } from "react";
2
+ import { useMarketsStream } from "./useMarketsStream";
3
+ import { OrderlyContext } from "../orderlyContext";
4
+ import { useSymbolsInfo } from "./useSymbolsInfo";
5
+ export var MarketsType;
6
+ (function (MarketsType) {
7
+ MarketsType[MarketsType["FAVORITES"] = 0] = "FAVORITES";
8
+ MarketsType[MarketsType["RECENT"] = 1] = "RECENT";
9
+ MarketsType[MarketsType["ALL"] = 2] = "ALL";
10
+ })(MarketsType || (MarketsType = {}));
11
+ export const useMarkets = (type) => {
12
+ const marketsKey = "markets";
13
+ const { data } = useMarketsStream();
14
+ const { configStore } = useContext(OrderlyContext);
15
+ // {"PERP_ETH_USDC": {}, ...}
16
+ const publicInfo = useSymbolsInfo();
17
+ if (!configStore.get(marketsKey)) {
18
+ const jsonStr = localStorage.getItem(marketsKey);
19
+ if (jsonStr) {
20
+ configStore.set(marketsKey, JSON.parse(jsonStr));
21
+ }
22
+ else {
23
+ const defaultTab = { name: "Popular", id: 1 };
24
+ configStore.set(marketsKey, {
25
+ recent: [],
26
+ favorites: [
27
+ { name: "PERP_ETH_USDC", tabs: [{ ...defaultTab }] },
28
+ { name: "PERP_BTC_USDC", tabs: [{ ...defaultTab }] },
29
+ ],
30
+ favoriteTabs: [{ ...defaultTab }],
31
+ lastSelectFavoriteTab: { ...defaultTab }
32
+ });
33
+ }
34
+ }
35
+ const getFavoriteTabs = useMemo(() => {
36
+ // @ts-ignore
37
+ const tabs = configStore.get(marketsKey)["favoriteTabs"];
38
+ return (tabs || [{ name: "Popular", id: 1 }]);
39
+ }, []);
40
+ const getFavorites = useMemo(() => {
41
+ // @ts-ignore
42
+ const curData = (configStore.get(marketsKey)["favorites"] || []);
43
+ const tabs = getFavoriteTabs;
44
+ const result = [];
45
+ for (let index = 0; index < curData.length; index++) {
46
+ const favData = curData[index];
47
+ var favTabs = favData.tabs.filter((tab) => tabs.findIndex((item) => tab.id === item.id) !== -1);
48
+ if (favTabs.length > 0) {
49
+ result.push({ ...favData, tabs: favTabs });
50
+ }
51
+ }
52
+ configStore.set(marketsKey, { ...configStore.getOr(marketsKey, {}), favorites: result });
53
+ // localStorage.setItem(marketsKey, JSON.stringify(configStore.get(marketsKey)));
54
+ return result;
55
+ }, [configStore]);
56
+ const getRecent = useMemo(() => {
57
+ // @ts-ignore
58
+ const curData = configStore.get(marketsKey)["recent"];
59
+ return (curData || []).filter((e) => e);
60
+ }, []);
61
+ const [favoriteTabs, setFavoriteTabs] = useState(getFavoriteTabs);
62
+ const [favorites, setFavorites] = useState(getFavorites);
63
+ const [recent, setRecent] = useState(getRecent);
64
+ const updateFavoriteTabs = (tab, operator) => {
65
+ const saveTabs = (tabs) => {
66
+ setFavoriteTabs(tabs);
67
+ configStore.set(marketsKey, {
68
+ ...configStore.getOr(marketsKey, {}),
69
+ "favoriteTabs": tabs
70
+ });
71
+ };
72
+ if (Array.isArray(tab)) {
73
+ saveTabs(tab);
74
+ return;
75
+ }
76
+ var tabs = [...favoriteTabs];
77
+ const index = tabs.findIndex((item) => item.id === tab.id);
78
+ if (operator?.add) {
79
+ tabs.push(tab);
80
+ }
81
+ else if (operator?.update) {
82
+ if (index !== -1) {
83
+ tabs[index] = tab;
84
+ }
85
+ }
86
+ else if (operator?.delete) {
87
+ if (index !== -1) {
88
+ tabs.splice(index, 1);
89
+ }
90
+ }
91
+ saveTabs(tabs);
92
+ };
93
+ const setRecentData = (symbol) => {
94
+ const curData = [...recent];
95
+ const index = curData.findIndex((item) => item.name == symbol.symbol);
96
+ if (index !== -1) {
97
+ curData.splice(index, 1);
98
+ }
99
+ curData.unshift({ name: symbol.symbol });
100
+ configStore.set(marketsKey, {
101
+ ...configStore.getOr(marketsKey, {}),
102
+ "recent": curData
103
+ });
104
+ setRecent(curData);
105
+ };
106
+ const setFavoritesData = (symbol, tab, remove = false) => {
107
+ const curData = [...favorites];
108
+ const index = curData.findIndex((item) => item.name == symbol.symbol);
109
+ if (index === -1) { // can not find
110
+ if (Array.isArray(tab)) {
111
+ if (tab.length > 0) {
112
+ curData.unshift({ name: symbol.symbol, tabs: tab });
113
+ }
114
+ }
115
+ else {
116
+ if (!remove) {
117
+ // insert
118
+ curData.unshift({ name: symbol.symbol, tabs: [tab] });
119
+ }
120
+ }
121
+ }
122
+ else {
123
+ const favorite = curData[index];
124
+ if (Array.isArray(tab)) {
125
+ if (tab.length === 0) {
126
+ // remove
127
+ curData.splice(index, 1);
128
+ }
129
+ else {
130
+ // overrides
131
+ curData[index] = { ...favorite, tabs: tab };
132
+ }
133
+ }
134
+ else {
135
+ if (remove) {
136
+ const tabs = favorite.tabs.filter((tab) => tab.id != tab.id);
137
+ if (tabs.length === 0) { // del favorite
138
+ curData.splice(index, 1);
139
+ }
140
+ else {
141
+ curData[index] = { ...favorite, tabs };
142
+ }
143
+ }
144
+ else { // insert
145
+ const tabs = favorite.tabs;
146
+ tabs.push(tab);
147
+ curData[index] = { ...favorite, tabs };
148
+ }
149
+ }
150
+ }
151
+ configStore.set(marketsKey, {
152
+ ...configStore.getOr(marketsKey, {}),
153
+ "favorites": curData
154
+ });
155
+ setFavorites(() => curData);
156
+ };
157
+ const getData = (type) => {
158
+ // get data
159
+ const localData = type === MarketsType.FAVORITES ? [...favorites] : [...recent];
160
+ // filter
161
+ const keys = localData.map((item) => item.name);
162
+ const filter = type == MarketsType.ALL ?
163
+ data :
164
+ data?.filter((item) => keys.includes(item.symbol));
165
+ const favoritesData = [...favorites];
166
+ const favoriteKeys = favoritesData.map((item) => item.name);
167
+ if (filter) {
168
+ for (let index = 0; index < filter.length; index++) {
169
+ const element = filter[index];
170
+ const isFavorite = type == MarketsType.FAVORITES ?
171
+ true :
172
+ (favoriteKeys.includes(element.symbol));
173
+ const fIndex = favoritesData.findIndex((item) => item.name === element.symbol);
174
+ const tabs = fIndex === -1 ? [] : favoritesData[fIndex].tabs;
175
+ let imr = undefined;
176
+ if (publicInfo) {
177
+ imr = publicInfo?.[element.symbol]("base_imr");
178
+ }
179
+ filter[index] = {
180
+ ...filter[index],
181
+ // @ts-ignore
182
+ isFavorite,
183
+ tabs,
184
+ leverage: imr ? 1 / imr : undefined
185
+ };
186
+ }
187
+ }
188
+ return filter;
189
+ };
190
+ const addToHistory = (symbol) => {
191
+ setRecentData(symbol);
192
+ };
193
+ const updateSymbolFavoriteState = (symbol, tab, del = false) => {
194
+ setFavoritesData(symbol, tab, del);
195
+ };
196
+ const markets = getData(type);
197
+ const pinToTop = (symbol) => {
198
+ const index = favorites.findIndex((item) => item.name === symbol.symbol);
199
+ if (index !== -1) {
200
+ const element = favorites[index];
201
+ const list = [...favorites];
202
+ list.splice(index, 1);
203
+ list.unshift(element);
204
+ configStore.set(marketsKey, {
205
+ ...configStore.getOr(marketsKey, {}),
206
+ "favorites": list
207
+ });
208
+ setFavorites(list);
209
+ }
210
+ };
211
+ const tabs = useMemo(() => {
212
+ return favoriteTabs;
213
+ }, [favoriteTabs]);
214
+ const getLastSelFavTab = () => {
215
+ // @ts-ignore
216
+ const curData = configStore.get(marketsKey)["lastSelectedFavoriteTab"];
217
+ return (curData || { name: "Popular", id: 1 });
218
+ };
219
+ const updateSelectedFavoriteTab = (tab) => {
220
+ configStore.set(marketsKey, {
221
+ ...configStore.getOr(marketsKey, {}),
222
+ lastSelectedFavoriteTab: tab
223
+ });
224
+ };
225
+ return [
226
+ markets || [],
227
+ {
228
+ favoriteTabs: tabs,
229
+ favorites,
230
+ recent,
231
+ addToHistory,
232
+ // updateFavoriteTabs("tab", operator: {add/update/delete})
233
+ updateFavoriteTabs,
234
+ updateSymbolFavoriteState,
235
+ pinToTop,
236
+ getLastSelFavTab,
237
+ updateSelectedFavoriteTab,
238
+ },
239
+ ];
240
+ };
@@ -0,0 +1,5 @@
1
+ import { WSMessage } from "@orderly.network/types";
2
+ export declare const useMarketsStream: () => {
3
+ data: WSMessage.Ticker[] | null;
4
+ };
5
+ //# sourceMappingURL=useMarketsStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarketsStream.d.ts","sourceRoot":"","sources":["../../src/orderly/useMarketsStream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,eAAO,MAAM,gBAAgB;;CA4D5B,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { useMemo } from "react";
2
+ import { useQuery } from "../useQuery";
3
+ import { useWS } from "../useWS";
4
+ import useSWRSubscription from "swr/subscription";
5
+ import { Decimal } from "@orderly.network/utils";
6
+ export const useMarketsStream = () => {
7
+ // get listing of all markets from /public/info
8
+ const ws = useWS();
9
+ const { data: futures } = useQuery(`/v1/public/futures`, {
10
+ revalidateOnFocus: false,
11
+ });
12
+ const { data: tickers } = useSWRSubscription("tickers", (_, { next }) => {
13
+ const unsubscribe = ws.subscribe(
14
+ // { event: "subscribe", topic: "markprices" },
15
+ "tickers", {
16
+ onMessage: (message) => {
17
+ next(null, message);
18
+ },
19
+ // onUnsubscribe: () => {
20
+ // return "markprices";
21
+ // },
22
+ // onError: (error: any) => {
23
+ //
24
+ // },
25
+ });
26
+ return () => {
27
+ unsubscribe?.();
28
+ };
29
+ });
30
+ const value = useMemo(() => {
31
+ if (!futures)
32
+ return null;
33
+ if (!tickers)
34
+ return futures;
35
+ return futures.map((item) => {
36
+ const ticker = tickers.find((t) => t.symbol === item.symbol);
37
+ if (ticker) {
38
+ const data = {
39
+ ...item,
40
+ ["24h_close"]: ticker.close,
41
+ ["24h_open"]: ticker.open,
42
+ ["24h_volumn"]: ticker.volume,
43
+ change: 0,
44
+ };
45
+ if (ticker.close !== undefined && ticker.open !== undefined) {
46
+ data["change"] = new Decimal(ticker.close)
47
+ .minus(ticker.open)
48
+ .div(ticker.open)
49
+ .toNumber();
50
+ }
51
+ return data;
52
+ }
53
+ return item;
54
+ });
55
+ }, [futures, tickers]);
56
+ return { data: value };
57
+ };
@@ -0,0 +1,3 @@
1
+ import { OrderSide } from "@orderly.network/types";
2
+ export declare const useMaxQty: (symbol: string, side: OrderSide, reduceOnly?: boolean) => number;
3
+ //# sourceMappingURL=useMaxQty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMaxQty.d.ts","sourceRoot":"","sources":["../../src/orderly/useMaxQty.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,SAAS,EAAe,MAAM,wBAAwB,CAAC;AAgB1E,eAAO,MAAM,SAAS,WACZ,MAAM,QACR,SAAS,eACH,OAAO,WAuIpB,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { useMemo } from "react";
2
+ import { OrderSide, OrderStatus } from "@orderly.network/types";
3
+ import { useSymbolsInfo } from "./useSymbolsInfo";
4
+ import { useMarkPricesStream } from "./useMarkPricesStream";
5
+ import { account } from "@orderly.network/perp";
6
+ import { useCollateral } from "./useCollateral";
7
+ import { usePrivateQuery } from "../usePrivateQuery";
8
+ import { usePositionStream } from "./usePositionStream";
9
+ import { pathOr } from "ramda";
10
+ import { useOrderStream } from "./useOrderStream";
11
+ const positionsPath = pathOr([], [0, "rows"]);
12
+ export const useMaxQty = (symbol, side, reduceOnly = false) => {
13
+ const positionsData = usePositionStream();
14
+ // const [orders] = useOrderStream({ status: OrderStatus.NEW });
15
+ const { data: accountInfo } = usePrivateQuery("/v1/client/info");
16
+ const symbolInfo = useSymbolsInfo();
17
+ const { totalCollateral } = useCollateral();
18
+ const { data: markPrices } = useMarkPricesStream();
19
+ const [orders] = useOrderStream({ status: OrderStatus.NEW });
20
+ // const {
21
+ // data: orders,
22
+ // error,
23
+ // mutate: updateOrder,
24
+ // } = usePrivateQuery<API.Order[]>(`/v1/orders?status=NEW&size=99`, {
25
+ // formatter: (data) => data.rows,
26
+ // onError: (err) => { },
27
+ // });
28
+ // const ws = useWS();
29
+ // useEffect(() => {
30
+ // const unsubscribe = ws.privateSubscribe(
31
+ // {
32
+ // id: "executionreport_orders",
33
+ // event: "subscribe",
34
+ // topic: "executionreport",
35
+ // ts: Date.now(),
36
+ // },
37
+ // {
38
+ // onMessage: (data: any) => {
39
+ // console.log("refresh orders", data);
40
+ // updateOrder();
41
+ // },
42
+ // }
43
+ // );
44
+ // return () => unsubscribe();
45
+ // }, []);
46
+ const maxQty = useMemo(() => {
47
+ if (!symbol)
48
+ return 0;
49
+ const positions = positionsPath(positionsData);
50
+ const positionQty = account.getQtyFromPositions(positions, symbol);
51
+ if (reduceOnly) {
52
+ if (positionQty > 0) {
53
+ if (side === OrderSide.BUY) {
54
+ return 0;
55
+ }
56
+ else {
57
+ return Math.abs(positionQty);
58
+ }
59
+ }
60
+ if (positionQty < 0) {
61
+ if (side === OrderSide.BUY) {
62
+ return Math.abs(positionQty);
63
+ }
64
+ else {
65
+ return 0;
66
+ }
67
+ }
68
+ return 0;
69
+ }
70
+ if (!markPrices || !markPrices[symbol] || !orders || !accountInfo)
71
+ return 0;
72
+ const getSymbolInfo = symbolInfo[symbol];
73
+ const filterAlgoOrders = orders.filter((item) => item.algo_order_id === undefined);
74
+ // current symbol buy order quantity
75
+ const buyOrdersQty = account.getQtyFromOrdersBySide(filterAlgoOrders, symbol, OrderSide.BUY);
76
+ // current symbol sell order quantity
77
+ const sellOrdersQty = account.getQtyFromOrdersBySide(filterAlgoOrders, symbol, OrderSide.SELL);
78
+ const otherPositions = positions.filter((item) => item.symbol !== symbol);
79
+ const otherOrders = filterAlgoOrders.filter((item) => item.symbol !== symbol);
80
+ const otherIMs = account.otherIMs({
81
+ orders: otherOrders,
82
+ positions: otherPositions,
83
+ symbolInfo,
84
+ markPrices,
85
+ IMR_Factors: accountInfo.imr_factor,
86
+ maxLeverage: accountInfo.max_leverage,
87
+ });
88
+ return account.maxQty(side, {
89
+ markPrice: markPrices[symbol],
90
+ symbol,
91
+ baseMaxQty: getSymbolInfo("base_max"),
92
+ totalCollateral,
93
+ maxLeverage: accountInfo.max_leverage,
94
+ takerFeeRate: accountInfo.taker_fee_rate,
95
+ baseIMR: getSymbolInfo("base_imr"),
96
+ otherIMs,
97
+ positionQty,
98
+ buyOrdersQty,
99
+ sellOrdersQty,
100
+ IMR_Factor: accountInfo.imr_factor[symbol],
101
+ });
102
+ }, [
103
+ orders,
104
+ positionsData,
105
+ markPrices,
106
+ accountInfo,
107
+ symbolInfo,
108
+ symbol,
109
+ side,
110
+ totalCollateral,
111
+ reduceOnly,
112
+ ]);
113
+ return Math.max(maxQty, 0);
114
+ };
@@ -0,0 +1,2 @@
1
+ export declare const useOpenInterest: (symbol: string) => import("swr/subscription").SWRSubscriptionResponse<any, any>;
2
+ //# sourceMappingURL=useOpenInterest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOpenInterest.d.ts","sourceRoot":"","sources":["../../src/orderly/useOpenInterest.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,WAAY,MAAM,iEAa7C,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { useWS } from "../useWS";
2
+ import useSWRSubscription from "swr/subscription";
3
+ export const useOpenInterest = (symbol) => {
4
+ const ws = useWS();
5
+ return useSWRSubscription(`${symbol}@openinterest`, (key, { next }) => {
6
+ const unsubscribe = ws.subscribe(`${symbol}@openinterest`, {
7
+ onMessage: (message) => {
8
+ next(null, message.openInterest);
9
+ },
10
+ });
11
+ return () => {
12
+ unsubscribe?.();
13
+ };
14
+ });
15
+ };
@@ -0,0 +1,63 @@
1
+ import { API, OrderEntity, OrderSide } from "@orderly.network/types";
2
+ export type UseOrderEntryOptions = {
3
+ commify?: boolean;
4
+ watchOrderbook?: boolean;
5
+ validate?: (data: OrderEntity) => {
6
+ [P in keyof OrderEntity]?: string;
7
+ } | null | undefined;
8
+ };
9
+ export type UseOrderEntryMetaState = {
10
+ errors: {
11
+ [P in keyof OrderEntity]?: {
12
+ type: string;
13
+ message: string;
14
+ };
15
+ } | null | undefined;
16
+ dirty: {
17
+ [P in keyof OrderEntity]?: boolean;
18
+ } | null | undefined;
19
+ submitted: boolean;
20
+ };
21
+ export type UseOrderEntryReturn = {
22
+ maxQty: number;
23
+ freeCollateral: number;
24
+ markPrice: number;
25
+ estLiqPrice?: number | null;
26
+ estLeverage?: number | null;
27
+ onSubmit: (order: OrderEntity) => Promise<any>;
28
+ submit: () => Promise<OrderEntity>;
29
+ submitting: boolean;
30
+ formattedOrder: Partial<OrderEntity>;
31
+ helper: {
32
+ calculate: (values: Partial<OrderEntity>, field: keyof OrderEntity, value: any) => Partial<OrderEntity>;
33
+ validator: (values: Partial<OrderEntity>) => any;
34
+ };
35
+ metaState: UseOrderEntryMetaState;
36
+ symbolConfig: API.SymbolExt;
37
+ };
38
+ export type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type">>;
39
+ /**
40
+ * Create Order
41
+ * @example
42
+ * ```tsx
43
+ * import { useOrderEntry } from "@orderly.network/hooks";
44
+ * import {OrderSide, OrderType} from '@orderly.network/types';
45
+ *
46
+ * const { formattedOrder, onSubmit, helper } = useOrderEntry({
47
+ * symbol: "PERP_ETH_USDC",
48
+ * side: OrderSide.BUY,
49
+ * order_type: OrderType.LIMIT,
50
+ * order_price: 10000,
51
+ * order_quantity: 1,
52
+ * },{
53
+ * // **Note:** it's required
54
+ * watchOrderbook: true,
55
+ * });
56
+ * ```
57
+ */
58
+ export declare function useOrderEntry(order: OrderParams, options?: UseOrderEntryOptions): UseOrderEntryReturn;
59
+ /**
60
+ * @deprecated
61
+ */
62
+ export declare function useOrderEntry(symbol: string, side: OrderSide, reduceOnly: boolean): UseOrderEntryReturn;
63
+ //# sourceMappingURL=useOrderEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOrderEntry.d.ts","sourceRoot":"","sources":["../../src/orderly/useOrderEntry.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,WAAW,EACX,SAAS,EAGV,MAAM,wBAAwB,CAAC;AAkBhC,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,CACT,IAAI,EAAE,WAAW,KACd;SAAG,CAAC,IAAI,MAAM,WAAW,CAAC,CAAC,EAAE,MAAM;KAAE,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EACF;SAAG,CAAC,IAAI,MAAM,WAAW,CAAC,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE;KAAE,GAChE,IAAI,GACJ,SAAS,CAAC;IACd,KAAK,EAAE;SAAG,CAAC,IAAI,MAAM,WAAW,CAAC,CAAC,EAAE,OAAO;KAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACjE,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAEhC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACrC,MAAM,EAAE;QACN,SAAS,EAAE,CACT,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,EAC5B,KAAK,EAAE,MAAM,WAAW,EACxB,KAAK,EAAE,GAAG,KACP,OAAO,CAAC,WAAW,CAAC,CAAC;QAC1B,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC;KAGlD,CAAC;IAEF,SAAS,EAAE,sBAAsB,CAAC;IAClC,YAAY,EAAE,GAAG,CAAC,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAChC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC,CACpD,GACC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,mBAAmB,CAAC;AACvB;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,UAAU,EAAE,OAAO,GAClB,mBAAmB,CAAC"}