@orderly.network/hooks 0.0.9 → 0.0.10

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.
package/dist/index.mjs CHANGED
@@ -1,21 +1,20 @@
1
- import React, { createContext, useContext, useCallback, useState, useEffect, useRef, useMemo } from 'react';
1
+ import React, { createContext, useContext, useCallback, useState, useEffect, useMemo } from 'react';
2
2
  import useSWR from 'swr';
3
3
  export { default as useSWR } from 'swr';
4
- import { WebSocketClient, WS, get, post } from '@orderly.network/net';
4
+ import { WebSocketClient, WS, get, post, del } from '@orderly.network/net';
5
5
  import useSWRMutation from 'swr/mutation';
6
- import { SimpleDI, Account, getMockSigner } from '@orderly.network/core';
7
6
  import useConstant from 'use-constant';
8
7
  export { default as useConstant } from 'use-constant';
9
- import { useObservable, useEventCallback } from 'rxjs-hooks';
8
+ import { SimpleDI, Account, getMockSigner } from '@orderly.network/core';
9
+ import { useObservable } from 'rxjs-hooks';
10
10
  export { useEventCallback, useObservable } from 'rxjs-hooks';
11
11
  import { AccountStatusEnum, SystemStateEnum, ExchangeStatusEnum, OrderSide, OrderType } from '@orderly.network/types';
12
12
  import { BehaviorSubject, merge } from 'rxjs';
13
- import { map, combineLatestWith, startWith, debounceTime, switchMap, scan, withLatestFrom } from 'rxjs/operators';
14
- import { compose, defaultTo, head, last, pathOr, pick, propOr } from 'ramda';
13
+ import { map } from 'rxjs/operators';
14
+ import { compose, defaultTo, head, last, pathOr, propOr } from 'ramda';
15
+ import useSWRSubscription from 'swr/subscription';
15
16
  import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
16
- import { useFormik } from 'formik';
17
17
  import { positions, account, order } from '@orderly.network/futures';
18
- import useSWRSubscription from 'swr/subscription';
19
18
  import useSWRInfinite from 'swr/infinite';
20
19
 
21
20
  var __defProp = Object.defineProperty;
@@ -96,26 +95,52 @@ var useQuery = (query, options) => {
96
95
  swrOptions
97
96
  );
98
97
  };
98
+ var useAccountInstance = () => {
99
+ const { configStore, keyStore, walletAdapter } = useContext(OrderlyContext);
100
+ if (!configStore)
101
+ throw new Error("configStore is not defined, please use OrderlyProvider");
102
+ if (!keyStore) {
103
+ throw new Error(
104
+ "keyStore is not defined, please use OrderlyProvider and provide keyStore"
105
+ );
106
+ }
107
+ const account4 = useConstant(() => {
108
+ let account5 = SimpleDI.get("account");
109
+ if (!account5) {
110
+ account5 = new Account(configStore, keyStore, walletAdapter);
111
+ SimpleDI.registerByName("account", account5);
112
+ }
113
+ return account5;
114
+ });
115
+ return account4;
116
+ };
117
+
118
+ // src/useMutation.ts
99
119
  var fetcher2 = (url, options) => {
100
120
  return post(url, options.arg.data, {
101
121
  headers: __spreadValues({}, options.arg.signature)
102
122
  });
103
123
  };
104
- var useMutation = (url, options) => {
124
+ var deleteFetcher = (url, options) => {
125
+ return del(url, options.arg.data, {
126
+ headers: __spreadValues({}, options.arg.signature)
127
+ });
128
+ };
129
+ var useMutation = (url, options, method = "POST") => {
105
130
  const { apiBaseUrl } = useContext(OrderlyContext);
106
131
  if (!url.startsWith("http")) {
107
132
  url = `${apiBaseUrl}${url}`;
108
133
  }
109
- let account3 = SimpleDI.get("account");
110
- const signer = account3.signer;
134
+ const account4 = useAccountInstance();
135
+ const signer = account4.signer;
111
136
  const { trigger, data, error, reset, isMutating } = useSWRMutation(
112
137
  url,
113
- fetcher2,
138
+ method === "POST" ? fetcher2 : deleteFetcher,
114
139
  options
115
140
  );
116
141
  const mutation = (data2) => __async(void 0, null, function* () {
117
142
  const payload = {
118
- method: "POST",
143
+ method,
119
144
  url,
120
145
  data: data2
121
146
  };
@@ -123,26 +148,28 @@ var useMutation = (url, options) => {
123
148
  return trigger({
124
149
  data: data2,
125
150
  signature: __spreadProps(__spreadValues({}, signature), {
126
- "orderly-account-id": account3.accountId
151
+ "orderly-account-id": account4.accountId
127
152
  })
128
153
  });
129
154
  });
130
- return {
155
+ return [
131
156
  mutation,
132
- data,
133
- error,
134
- reset,
135
- isMutating
136
- };
157
+ {
158
+ data,
159
+ error,
160
+ reset,
161
+ isMutating
162
+ }
163
+ ];
137
164
  };
138
165
  var signatureMiddleware = (useSWRNext) => {
139
166
  const { apiBaseUrl } = useContext(OrderlyContext);
140
167
  return (key, fetcher4, config) => {
141
168
  try {
142
169
  const extendedFetcher = (url) => __async(void 0, null, function* () {
143
- let account3 = SimpleDI.get("account");
170
+ let account4 = SimpleDI.get("account");
144
171
  let fullUrl = `${apiBaseUrl}${url}`;
145
- const signer = account3.signer;
172
+ const signer = account4.signer;
146
173
  const payload = {
147
174
  method: "GET",
148
175
  url: fullUrl
@@ -150,7 +177,7 @@ var signatureMiddleware = (useSWRNext) => {
150
177
  const signature = yield signer.sign(payload);
151
178
  return fetcher4(fullUrl, {
152
179
  headers: __spreadProps(__spreadValues({}, signature), {
153
- "orderly-account-id": account3.accountId
180
+ "orderly-account-id": account4.accountId
154
181
  })
155
182
  });
156
183
  });
@@ -162,7 +189,13 @@ var signatureMiddleware = (useSWRNext) => {
162
189
  };
163
190
  };
164
191
  var useAccount = () => {
165
- const { configStore, keyStore, walletAdapter } = useContext(OrderlyContext);
192
+ const {
193
+ configStore,
194
+ keyStore,
195
+ walletAdapter,
196
+ onWalletConnect,
197
+ onWalletDisconnect
198
+ } = useContext(OrderlyContext);
166
199
  if (!configStore)
167
200
  throw new Error("configStore is not defined, please use OrderlyProvider");
168
201
  if (!keyStore) {
@@ -170,39 +203,58 @@ var useAccount = () => {
170
203
  "keyStore is not defined, please use OrderlyProvider and provide keyStore"
171
204
  );
172
205
  }
173
- const account3 = useConstant(() => {
174
- let account4 = SimpleDI.get("account");
175
- if (!account4) {
176
- account4 = new Account(configStore, keyStore, walletAdapter);
177
- SimpleDI.registerByName("account", account4);
206
+ const account4 = useConstant(() => {
207
+ let account5 = SimpleDI.get("account");
208
+ if (!account5) {
209
+ account5 = new Account(configStore, keyStore, walletAdapter);
210
+ SimpleDI.registerByName("account", account5);
178
211
  }
179
- return account4;
212
+ return account5;
180
213
  });
181
214
  const state = useObservable(
182
- () => account3.state$,
183
- account3.stateValue
215
+ () => account4.state$,
216
+ account4.stateValue
184
217
  );
185
218
  const login = useCallback(
186
219
  (address) => {
187
- account3.login(address);
220
+ account4.login(address);
188
221
  },
189
- [account3]
222
+ [account4]
223
+ );
224
+ const createOrderlyKey = useCallback(
225
+ (remember) => __async(void 0, null, function* () {
226
+ return account4.createOrderlyKey(remember ? 365 : 30);
227
+ }),
228
+ [account4]
190
229
  );
230
+ const createAccount = useCallback(() => __async(void 0, null, function* () {
231
+ return account4.createAccount();
232
+ }), [account4]);
233
+ const connect = useCallback(() => __async(void 0, null, function* () {
234
+ return onWalletConnect == null ? void 0 : onWalletConnect();
235
+ }), [account4]);
236
+ const disconnect = useCallback(() => __async(void 0, null, function* () {
237
+ return onWalletDisconnect == null ? void 0 : onWalletDisconnect();
238
+ }), [account4]);
191
239
  return {
192
240
  // account: state!,
193
- account: account3,
241
+ account: account4,
194
242
  state,
195
243
  // info: {},
196
- login
244
+ login,
245
+ createOrderlyKey,
246
+ createAccount,
247
+ disconnect,
248
+ connect
197
249
  };
198
250
  };
199
251
  var usePrivateQuery = (query, options) => {
200
252
  var _b;
201
253
  const _a = options || {}, { formatter } = _a, swrOptions = __objRest(_a, ["formatter"]);
202
- const account3 = useAccount();
254
+ const account4 = useAccount();
203
255
  const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_b = options == null ? void 0 : options.use) != null ? _b : [] : [];
204
256
  return useSWR(
205
- () => account3.state.status >= AccountStatusEnum.SignedIn ? query : null,
257
+ () => account4.state.status >= AccountStatusEnum.EnableTrading ? query : null,
206
258
  // query,
207
259
  (url, init) => {
208
260
  return fetcher(url, init, { formatter });
@@ -289,7 +341,7 @@ var useWebSocketClient = () => {
289
341
  let websocketClient = SimpleDI.get(WS_NAME);
290
342
  if (!websocketClient) {
291
343
  websocketClient = new WebSocketClient({
292
- accountId: "0x47ab075adca7dfe9dd206eb7c50a10f7b99f4f08fa6c3abd4c170d438e15093b",
344
+ accountId: "OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY",
293
345
  networkId: "testnet",
294
346
  onSigntureRequest: (accountId) => __async(void 0, null, function* () {
295
347
  const signer = getMockSigner();
@@ -304,28 +356,6 @@ var useWebSocketClient = () => {
304
356
  });
305
357
  return ws;
306
358
  };
307
- var useAccountInstance = () => {
308
- const { configStore, keyStore } = useContext(OrderlyContext);
309
- if (!configStore)
310
- throw new Error("configStore is not defined, please use OrderlyProvider");
311
- if (!keyStore) {
312
- throw new Error(
313
- "keyStore is not defined, please use OrderlyProvider and provide keyStore"
314
- );
315
- }
316
- const account3 = useConstant(() => {
317
- let account4 = SimpleDI.get("account");
318
- if (!account4) {
319
- account4 = new Account(configStore, keyStore);
320
- SimpleDI.registerByName("account", account4);
321
- }
322
- return account4;
323
- });
324
- console.log("account instance ======>>>>>", account3);
325
- return account3;
326
- };
327
-
328
- // src/provider/dataProvider.tsx
329
359
  var DataSourceContext = createContext({});
330
360
  var DataSourceProvider = (props) => {
331
361
  console.log("render DataSourceProvider");
@@ -338,12 +368,13 @@ var WS_NAME2 = "nativeWebsocketClient";
338
368
  var useWS = () => {
339
369
  const ws = useConstant(() => {
340
370
  let websocketClient = SimpleDI.get(WS_NAME2);
371
+ const account4 = SimpleDI.get(Account.instanceName);
341
372
  if (!websocketClient) {
342
373
  websocketClient = new WS({
343
- accountId: "0x47ab075adca7dfe9dd206eb7c50a10f7b99f4f08fa6c3abd4c170d438e15093b",
374
+ // accountId: "OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY",
344
375
  networkId: "testnet",
345
376
  onSigntureRequest: (accountId) => __async(void 0, null, function* () {
346
- const signer = getMockSigner();
377
+ const signer = account4.signer;
347
378
  const timestamp = (/* @__PURE__ */ new Date()).getTime();
348
379
  const result = yield signer.signText(timestamp.toString());
349
380
  return __spreadProps(__spreadValues({}, result), { timestamp });
@@ -360,34 +391,69 @@ var useTickerStream = (symbol) => {
360
391
  throw new Error("useFuturesForSymbol requires a symbol");
361
392
  }
362
393
  const { data: info } = useQuery(`/public/futures/${symbol}`);
363
- const ws = useWebSocketClient();
364
- const ticker = useObservable(
365
- (_, input$) => input$.pipe(
366
- map(([config]) => config),
367
- combineLatestWith(ws.observe(`${symbol}@ticker`).pipe(startWith({}))),
368
- map(([config, ticker2]) => {
369
- if (!config)
370
- return config;
371
- if (ticker2.close !== void 0) {
372
- config["24h_close"] = ticker2.close;
373
- }
374
- if (ticker2.open !== void 0) {
375
- config["24h_open"] = ticker2.open;
376
- }
377
- if (ticker2.volume !== void 0) {
378
- config["24h_volumn"] = ticker2.volume;
379
- }
380
- if (ticker2.close !== void 0 && ticker2.open !== void 0) {
381
- config["change"] = new Decimal(ticker2.close).minus(ticker2.open).div(ticker2.open).toNumber();
394
+ const ws = useWS();
395
+ const { data: ticker } = useSWRSubscription(
396
+ `${symbol}@ticker`,
397
+ (key, { next }) => {
398
+ const unsubscribe = ws.subscribe(
399
+ // { event: "subscribe", topic: "markprices" },
400
+ `${symbol}@ticker`,
401
+ {
402
+ onMessage: (message) => {
403
+ next(null, message);
404
+ }
405
+ // onUnsubscribe: () => {
406
+ // return "markprices";
407
+ // },
408
+ // onError: (error: any) => {
409
+ // console.log("error", error);
410
+ // },
382
411
  }
383
- return config;
384
- })
385
- ),
386
- null,
387
- [info]
412
+ );
413
+ return () => {
414
+ console.log("unsubscribe!!!!!!!");
415
+ unsubscribe == null ? void 0 : unsubscribe();
416
+ };
417
+ }
388
418
  );
389
- return ticker;
419
+ const value = useMemo(() => {
420
+ if (!info)
421
+ return null;
422
+ if (!ticker)
423
+ return info;
424
+ const config = __spreadValues({}, info);
425
+ if (ticker.close !== void 0) {
426
+ config["24h_close"] = ticker.close;
427
+ }
428
+ if (ticker.open !== void 0) {
429
+ config["24h_open"] = ticker.open;
430
+ }
431
+ if (ticker.volume !== void 0) {
432
+ config["24h_volumn"] = ticker.volume;
433
+ }
434
+ if (ticker.close !== void 0 && ticker.open !== void 0) {
435
+ config["change"] = new Decimal(ticker.close).minus(ticker.open).div(ticker.open).toNumber();
436
+ }
437
+ return config;
438
+ }, [info, ticker]);
439
+ return value;
390
440
  };
441
+ var useMarkPrice = (symbol) => {
442
+ const ws = useWS();
443
+ return useSWRSubscription(`${symbol}@markprice`, (key, { next }) => {
444
+ const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
445
+ onMessage: (message) => {
446
+ next(null, message.price);
447
+ }
448
+ });
449
+ return () => {
450
+ console.log("unsubscribe useMarkPrice !!!!!!!");
451
+ unsubscribe == null ? void 0 : unsubscribe();
452
+ };
453
+ });
454
+ };
455
+
456
+ // src/orderly/useOrderbookStream.ts
391
457
  compose(defaultTo(0), head, last, pathOr([], ["asks"]));
392
458
  pathOr(0, ["bids", 0, 0]);
393
459
  var paddingFn = (len) => Array(len).fill([Number.NaN, Number.NaN, Number.NaN]);
@@ -400,7 +466,13 @@ var reduceItems = (depth, level, data) => {
400
466
  const result = [];
401
467
  for (let i = 0; i < data.length; i++) {
402
468
  const [price, quantity] = data[i];
403
- result.push([price, quantity, quantity + (i > 0 ? result[i - 1][2] : 0)]);
469
+ if (isNaN(price) || isNaN(quantity))
470
+ continue;
471
+ result.push([
472
+ price,
473
+ quantity,
474
+ quantity + (result.length > 0 ? result[result.length - 1][2] : 0)
475
+ ]);
404
476
  if (i + 1 >= level) {
405
477
  break;
406
478
  }
@@ -446,21 +518,22 @@ var mergeOrderbook = (data, update) => {
446
518
  bids: mergeItems(data.bids, update.bids).sort(bidsSortFn)
447
519
  };
448
520
  };
449
- var useOrderbook = (symbol, initial = { asks: [], bids: [] }, options) => {
521
+ var useOrderbookStream = (symbol, initial = { asks: [], bids: [] }, options) => {
450
522
  if (!symbol) {
451
- throw new Error("useOrderbook requires a symbol");
523
+ throw new Error("useOrderbookStream requires a symbol");
452
524
  }
525
+ const [requestData, setRequestData] = useState(null);
453
526
  const [data, setData] = useState(initial);
527
+ const [isLoading, setIsLoading] = useState(true);
454
528
  const [depth, setDepth] = useState(1e-3);
455
529
  const [level, setLevel] = useState(() => {
456
530
  var _a;
457
531
  return (_a = options == null ? void 0 : options.level) != null ? _a : 10;
458
532
  });
459
- const ws = useWebSocketClient();
460
- const orderbookSubscriberRef = useRef();
533
+ const ws = useWS();
461
534
  const ticker = useTickerStream(symbol);
462
- const orderbookRequest$ = useMemo(() => {
463
- return ws.observe(
535
+ useEffect(() => {
536
+ ws.onceSubscribe(
464
537
  {
465
538
  event: "request",
466
539
  params: {
@@ -468,66 +541,52 @@ var useOrderbook = (symbol, initial = { asks: [], bids: [] }, options) => {
468
541
  symbol
469
542
  }
470
543
  },
471
- void 0,
472
- (message) => message.event === "request"
473
- );
474
- }, [symbol]);
475
- const orderbookUpdate$ = useMemo(() => {
476
- return ws.observe(`${symbol}@orderbookupdate`, () => ({
477
- event: "subscribe",
478
- topic: `${symbol}@orderbookupdate`
479
- })).pipe(
480
- startWith({ asks: [], bids: [] })
481
- // filter((message: any) => !!message.success)
544
+ {
545
+ onMessage: (message) => {
546
+ console.log("orderbook request message", message);
547
+ if (!!message) {
548
+ const reduceOrderbookData = reduceOrderbook(depth, level, message);
549
+ setRequestData(reduceOrderbookData);
550
+ setData(reduceOrderbookData);
551
+ }
552
+ setIsLoading(false);
553
+ }
554
+ }
482
555
  );
556
+ return () => {
557
+ setRequestData(null);
558
+ };
483
559
  }, [symbol]);
484
- const orderbookOptions$ = useConstant(() => {
485
- return new BehaviorSubject({
486
- depth: 1e-3,
487
- level: 10
488
- });
489
- });
490
- const markPrice = useObservable(
491
- (_, input$) => input$.pipe(
492
- debounceTime(200),
493
- switchMap(([symbol2]) => {
494
- return ws.observe(`${symbol2}@markprice`).pipe(map((data2) => data2.price));
495
- })
496
- ),
497
- 0,
498
- [symbol]
499
- );
560
+ const { data: markPrice } = useMarkPrice(symbol);
500
561
  useEffect(() => {
501
- if (orderbookSubscriberRef.current) {
502
- orderbookSubscriberRef.current.unsubscribe();
503
- }
504
- orderbookSubscriberRef.current = merge(orderbookRequest$, orderbookUpdate$).pipe(
505
- // tap((data) => console.log(data)),
506
- map(
507
- (data2) => pick(["asks", "bids"], data2)
508
- ),
509
- scan((acc, curr) => {
510
- if (!acc.asks && !acc.bids) {
511
- return curr;
562
+ if (!requestData)
563
+ return;
564
+ const subscription = ws.subscribe(
565
+ {
566
+ event: "subscribe",
567
+ topic: `${symbol}@orderbookupdate`
568
+ },
569
+ {
570
+ onMessage: (message) => {
571
+ setData((data2) => {
572
+ const mergedData = !message.asks && !message.bids ? data2 : mergeOrderbook(data2, message);
573
+ const reducedData = reduceOrderbook(depth, level, mergedData);
574
+ return reducedData;
575
+ });
512
576
  }
513
- return mergeOrderbook(acc, curr);
514
- }),
515
- map((data2) => reduceOrderbook(depth, level, data2))
516
- ).subscribe((data2) => {
517
- setData(data2);
518
- });
519
- }, [orderbookRequest$, orderbookUpdate$]);
577
+ }
578
+ );
579
+ return () => {
580
+ subscription == null ? void 0 : subscription();
581
+ };
582
+ }, [symbol, requestData]);
520
583
  const onDepthChange = useCallback((depth2) => {
521
584
  console.log("Orderbook depth has changed:", depth2);
522
- orderbookOptions$.next(__spreadProps(__spreadValues({}, orderbookOptions$.value), {
523
- depth: depth2
524
- // level,
525
- }));
526
585
  }, []);
527
586
  const middlePrice = useMemo(() => {
528
587
  let asksFrist = 0, bidsFirst = 0;
529
588
  if (data.asks.length > 0) {
530
- asksFrist = data.asks[data.bids.length - 1][0];
589
+ asksFrist = data.asks[data.asks.length - 1][0];
531
590
  }
532
591
  if (data.bids.length > 0) {
533
592
  bidsFirst = data.bids[0][0];
@@ -538,7 +597,7 @@ var useOrderbook = (symbol, initial = { asks: [], bids: [] }, options) => {
538
597
  }, [ticker, data]);
539
598
  return [
540
599
  __spreadProps(__spreadValues({}, data), { markPrice, middlePrice }),
541
- { onDepthChange, depth }
600
+ { onDepthChange, depth, isLoading }
542
601
  ];
543
602
  };
544
603
 
@@ -642,14 +701,15 @@ function orderEntityFormatHandle(baseTick, quoteTick) {
642
701
  }
643
702
  function priceInputHandle(inputs) {
644
703
  const [values, input, value, markPrice, config] = inputs;
704
+ console.log("priceInputHandle", inputs);
645
705
  if (value === "") {
646
706
  return [__spreadProps(__spreadValues({}, values), { total: "" }), input, value, markPrice, config];
647
707
  }
648
708
  const price = new Decimal(value);
649
709
  const priceDP = price.dp();
710
+ console.log("priceInputHandle", priceDP, config.quoteDP);
650
711
  if (priceDP > config.quoteDP) {
651
- price.toDecimalPlaces(config.quoteDP);
652
- values.order_price = price.toNumber();
712
+ values.order_price = price.toDecimalPlaces(config.quoteDP).toString();
653
713
  }
654
714
  price.toDecimalPlaces(Math.min(priceDP, config.quoteDP));
655
715
  if (!values.order_quantity) {
@@ -657,9 +717,10 @@ function priceInputHandle(inputs) {
657
717
  }
658
718
  const total = price.mul(values.order_quantity);
659
719
  const quantityDP = total.dp();
660
- total.toDecimalPlaces(Math.min(quantityDP, config.baseDP));
661
720
  return [
662
- __spreadProps(__spreadValues({}, values), { total: total.toNumber() }),
721
+ __spreadProps(__spreadValues({}, values), {
722
+ total: total.toDecimalPlaces(Math.min(quantityDP, config.baseDP)).toString()
723
+ }),
663
724
  input,
664
725
  value,
665
726
  markPrice,
@@ -683,10 +744,9 @@ function quantityInputHandle(inputs) {
683
744
  }
684
745
  const total = quantity.mul(price);
685
746
  const totalDP = total.dp();
686
- total.todp(Math.min(config.quoteDP, totalDP));
687
747
  return [
688
748
  __spreadProps(__spreadValues({}, values), {
689
- total: total.toNumber()
749
+ total: total.todp(Math.min(config.quoteDP, totalDP)).toNumber()
690
750
  }),
691
751
  input,
692
752
  value,
@@ -762,25 +822,12 @@ var useFundingRates = () => {
762
822
  );
763
823
  return createGetter(data);
764
824
  };
765
- var useMarkPricesSubject = () => {
766
- const ws = useWebSocketClient();
767
- return useConstant(
768
- () => ws.observe("markprices").pipe(
769
- map((data) => {
770
- const prices = {};
771
- data.forEach((item) => {
772
- prices[item.symbol] = item.price;
773
- });
774
- return prices;
775
- })
776
- )
777
- );
778
- };
779
825
  var useMarkPricesStream = () => {
780
826
  const ws = useWS();
781
827
  return useSWRSubscription("markPrices", (key, { next }) => {
782
- const unsubscribe = ws.subscription(
783
- { event: "subscribe", topic: "markprices" },
828
+ const unsubscribe = ws.subscribe(
829
+ // { event: "subscribe", topic: "markprices" },
830
+ "markprices",
784
831
  {
785
832
  onMessage: (message) => {
786
833
  const data = /* @__PURE__ */ Object.create(null);
@@ -790,9 +837,9 @@ var useMarkPricesStream = () => {
790
837
  }
791
838
  next(null, data);
792
839
  },
793
- onUnsubscribe: () => {
794
- return "markprices";
795
- },
840
+ // onUnsubscribe: () => {
841
+ // return "markprices";
842
+ // },
796
843
  onError: (error) => {
797
844
  console.log("error", error);
798
845
  }
@@ -800,36 +847,34 @@ var useMarkPricesStream = () => {
800
847
  );
801
848
  return () => {
802
849
  console.log("unsubscribe!!!!!!!");
803
- console.log("unsubscribe", unsubscribe);
804
850
  unsubscribe == null ? void 0 : unsubscribe();
805
851
  };
806
852
  });
807
853
  };
808
854
  var usePositionStream = (symbol, options) => {
809
- useState(false);
810
855
  const [visibledSymbol, setVisibleSymbol] = useState(
811
856
  symbol
812
857
  );
813
858
  const symbolInfo = useSymbolsInfo();
814
859
  const { data: accountInfo } = usePrivateQuery("/client/info");
815
- const { mutation } = useMutation("/order");
816
860
  const fundingRates = useFundingRates();
817
- useMarkPricesSubject();
818
- const { data, error, isLoading } = usePrivateQuery(
819
- `/positions`,
820
- __spreadProps(__spreadValues({}, options), {
821
- formatter: (data2) => data2,
822
- onError: (err) => {
823
- console.log("usePositionStream error", err);
824
- }
825
- })
826
- );
861
+ const { data, error } = usePrivateQuery(`/positions`, __spreadProps(__spreadValues({}, options), {
862
+ formatter: (data2) => data2,
863
+ onError: (err) => {
864
+ console.log("usePositionStream error", err);
865
+ }
866
+ }));
827
867
  const { data: markPrices } = useMarkPricesStream();
828
868
  const formatedPositions = useMemo(() => {
829
869
  if (!(data == null ? void 0 : data.rows) || !symbolInfo || !accountInfo)
830
870
  return null;
831
871
  let totalCollateral = 0;
832
- return data.rows.map((item) => {
872
+ const filteredData = typeof symbol === "undefined" || symbol === "" ? data.rows.filter((item) => {
873
+ return item.position_qty !== 0;
874
+ }) : data.rows.filter((item) => {
875
+ return item.symbol === symbol && item.position_qty !== 0;
876
+ });
877
+ return filteredData.map((item) => {
833
878
  const price = propOr(
834
879
  item.mark_price,
835
880
  item.symbol,
@@ -865,7 +910,7 @@ var usePositionStream = (symbol, options) => {
865
910
  })
866
911
  });
867
912
  });
868
- }, [data == null ? void 0 : data.rows, symbolInfo, accountInfo, markPrices]);
913
+ }, [data == null ? void 0 : data.rows, symbolInfo, accountInfo, markPrices, symbol]);
869
914
  const aggregatedData = useMemo(() => {
870
915
  const aggregatedData2 = {
871
916
  unsettledPnL: NaN,
@@ -893,18 +938,11 @@ var usePositionStream = (symbol, options) => {
893
938
  const showSymbol = useCallback((symbol2) => {
894
939
  setVisibleSymbol(symbol2);
895
940
  }, []);
896
- const onClosePosition = useCallback(
897
- (order2) => {
898
- return mutation(order2).finally(() => {
899
- });
900
- },
901
- []
902
- );
903
941
  return [
904
942
  { rows: formatedPositions, aggregated: aggregatedData },
905
943
  createGetter(data, 1),
906
944
  {
907
- close: onClosePosition,
945
+ // close: onClosePosition,
908
946
  loading: false,
909
947
  showSymbol,
910
948
  error,
@@ -919,7 +957,8 @@ var usePositionStream = (symbol, options) => {
919
957
  };
920
958
  var totalUnsettlementPnLPath = pathOr(0, [0, "aggregated", "unsettledPnL"]);
921
959
  var positionsPath = pathOr([], [0, "rows"]);
922
- var useCollateral = (dp = 6) => {
960
+ var useCollateral = (options = { dp: 6 }) => {
961
+ const { dp } = options;
923
962
  const positions2 = usePositionStream();
924
963
  const { data: orders } = usePrivateQuery(`/orders`);
925
964
  const { data: accountInfo } = usePrivateQuery("/client/info");
@@ -1073,7 +1112,7 @@ var BaseOrderCreator = class {
1073
1112
  baseOrder(data) {
1074
1113
  const order2 = {
1075
1114
  // symbol: data.symbol,
1076
- order_type: !!data.order_type_ext ? data.order_type_ext : data.order_type,
1115
+ order_type: data.order_type === OrderType.LIMIT ? !!data.order_type_ext ? data.order_type_ext : data.order_type : data.order_type,
1077
1116
  side: data.side,
1078
1117
  // reduce_only: data.reduce_only,
1079
1118
  order_quantity: data.order_quantity
@@ -1086,25 +1125,41 @@ var BaseOrderCreator = class {
1086
1125
  baseValidate(values, configs) {
1087
1126
  const errors = {};
1088
1127
  const { maxQty } = configs;
1128
+ console.log("baseValidate", values, configs);
1089
1129
  const { order_quantity, total } = values;
1090
1130
  if (!order_quantity) {
1091
- errors.order_quantity = "quantity is required";
1131
+ errors.order_quantity = {
1132
+ type: "required",
1133
+ message: "quantity is required"
1134
+ };
1092
1135
  } else {
1093
1136
  const { base_max, base_min } = configs.symbol;
1094
1137
  const qty = new Decimal(order_quantity);
1095
1138
  if (qty.lt(base_min)) {
1096
- errors.order_quantity = `quantity must be greater than ${base_min}`;
1139
+ errors.order_quantity = {
1140
+ type: "min",
1141
+ message: `quantity must be greater than ${base_min}`
1142
+ };
1097
1143
  } else if (qty.gt(maxQty)) {
1098
- errors.order_quantity = `quantity must be less than ${base_max}`;
1144
+ errors.order_quantity = {
1145
+ type: "max",
1146
+ message: `quantity must be less than ${maxQty}`
1147
+ };
1099
1148
  }
1100
1149
  }
1101
1150
  if (!!total) {
1102
1151
  const { quote_max, quote_min } = configs.symbol;
1103
1152
  const totalNumber = new Decimal(total);
1104
1153
  if (totalNumber.lt(quote_min)) {
1105
- errors.total = `Quantity should be greater than ${quote_min}`;
1154
+ errors.total = {
1155
+ type: "min",
1156
+ message: `Quantity should be greater or equal than ${quote_min}`
1157
+ };
1106
1158
  } else if (totalNumber.gt(quote_max)) {
1107
- errors.total = `Quantity should be less or equal than ${quote_max}`;
1159
+ errors.total = {
1160
+ type: "max",
1161
+ message: `Quantity should be less or equal than ${quote_max}`
1162
+ };
1108
1163
  }
1109
1164
  }
1110
1165
  return Promise.resolve(errors);
@@ -1120,7 +1175,10 @@ var LimitOrderCreator = class extends BaseOrderCreator {
1120
1175
  return this.baseValidate(values, config).then((errors) => {
1121
1176
  const { order_price } = values;
1122
1177
  if (!order_price) {
1123
- errors.order_price = "price is required";
1178
+ errors.order_price = {
1179
+ type: "required",
1180
+ message: "price is required"
1181
+ };
1124
1182
  } else {
1125
1183
  const price = new Decimal(order_price);
1126
1184
  const { symbol } = config;
@@ -1128,9 +1186,15 @@ var LimitOrderCreator = class extends BaseOrderCreator {
1128
1186
  const maxPriceNumber = maxPrice(config.markPrice, price_range);
1129
1187
  const minPriceNumber = minPrice(config.markPrice, price_range);
1130
1188
  if (price.lt(minPriceNumber)) {
1131
- errors.order_price = `price must be greater than ${minPriceNumber}`;
1189
+ errors.order_price = {
1190
+ type: "min",
1191
+ message: `price must be greater than ${minPriceNumber}`
1192
+ };
1132
1193
  } else if (price.gt(maxPriceNumber)) {
1133
- errors.order_price = `price must be less than ${maxPriceNumber}`;
1194
+ errors.order_price = {
1195
+ type: "max",
1196
+ message: `price must be less than ${maxPriceNumber}`
1197
+ };
1134
1198
  }
1135
1199
  }
1136
1200
  return errors;
@@ -1139,7 +1203,9 @@ var LimitOrderCreator = class extends BaseOrderCreator {
1139
1203
  };
1140
1204
  var MarketOrderCreator = class extends BaseOrderCreator {
1141
1205
  create(values) {
1142
- return __spreadValues({}, this.baseOrder(values));
1206
+ const data = this.baseOrder(values);
1207
+ delete data["order_price"];
1208
+ return __spreadValues({}, data);
1143
1209
  }
1144
1210
  validate(values, configs) {
1145
1211
  return this.baseValidate(values, configs);
@@ -1163,8 +1229,8 @@ var GeneralOrderCreator = class extends BaseOrderCreator {
1163
1229
  }
1164
1230
  };
1165
1231
  var OrderFactory = class {
1166
- static create(type2) {
1167
- switch (type2) {
1232
+ static create(type) {
1233
+ switch (type) {
1168
1234
  case OrderType.LIMIT:
1169
1235
  return new LimitOrderCreator();
1170
1236
  case OrderType.MARKET:
@@ -1182,8 +1248,8 @@ var OrderFactory = class {
1182
1248
  };
1183
1249
 
1184
1250
  // src/orderly/useOrderEntry.ts
1185
- var useOrderEntry = (symbol, initialValue = {}, options) => {
1186
- const { mutation } = useMutation("/order");
1251
+ var useOrderEntry = (symbol, side, reduceOnly = false, options) => {
1252
+ const [mutation] = useMutation("/order");
1187
1253
  const { freeCollateral } = useCollateral();
1188
1254
  const symbolInfo = useSymbolsInfo();
1189
1255
  const tokenInfo = useTokenInfo();
@@ -1194,97 +1260,29 @@ var useOrderEntry = (symbol, initialValue = {}, options) => {
1194
1260
  const quoteDP = useMemo(() => {
1195
1261
  return tokenInfo.USDC("decimals", 0);
1196
1262
  }, [tokenInfo]);
1197
- const [valuesUpdate, [orderExtraValues]] = useEventCallback(
1198
- (event$, state$) => {
1199
- return event$.pipe(
1200
- withLatestFrom(state$),
1201
- map(([event, state]) => {
1202
- const { field, value } = event;
1203
- console.log("orderExtraValues", field, value);
1204
- return [__spreadProps(__spreadValues({}, state[0]), { [field]: value })];
1205
- })
1206
- );
1207
- },
1208
- [
1209
- {
1210
- order_type: OrderType.MARKET,
1211
- side: OrderSide.BUY,
1212
- reduce_only: false
1213
- }
1214
- ]
1215
- );
1216
- const ws = useWebSocketClient();
1217
- const markPrice = useObservable(
1218
- (_, input$) => input$.pipe(
1219
- switchMap(([symbol2]) => {
1220
- return ws.observe(`${symbol2}@markprice`).pipe(
1221
- map((data) => data.price)
1222
- // takeWhile(() => type === OrderType.MARKET)
1223
- );
1224
- })
1225
- ),
1226
- 0,
1227
- [symbol]
1228
- );
1229
- const formik = useFormik({
1230
- initialValues: __spreadValues({
1231
- // order_type: OrderType.MARKET,
1232
- // side: OrderSide.BUY,
1233
- order_quantity: "",
1234
- total: "",
1235
- order_price: "",
1236
- visible_quantity: 1
1237
- }, initialValue),
1238
- validate: (values) => {
1239
- const creator = OrderFactory.create(orderExtraValues.order_type);
1240
- return creator == null ? void 0 : creator.validate(values, {
1241
- symbol: symbolInfo[symbol](),
1242
- token: tokenInfo[symbol](),
1243
- maxQty,
1244
- markPrice
1245
- });
1246
- },
1247
- onSubmit: (values) => {
1248
- console.log(values);
1249
- }
1250
- });
1263
+ const { data: markPrice } = useMarkPrice(symbol);
1251
1264
  const maxQty = useMaxQty(
1252
1265
  symbol,
1253
- orderExtraValues.side,
1254
- orderExtraValues.reduce_only
1266
+ side,
1267
+ // orderExtraValues.reduce_only
1268
+ reduceOnly
1255
1269
  );
1256
- const formFieldds = useMemo(() => {
1257
- return ["order_quantity", "order_price", "total"];
1258
- }, []);
1259
- const setValue = (field, value) => {
1260
- if (formFieldds.indexOf(field) < 0) {
1261
- valuesUpdate({ field, value });
1262
- return;
1263
- }
1264
- const fieldHandler = getCalculateHandler(field);
1265
- const newValues = compose(
1266
- head,
1267
- orderEntityFormatHandle(),
1268
- fieldHandler,
1269
- baseInputHandle
1270
- )([
1271
- __spreadValues(__spreadValues({}, formik.values), orderExtraValues),
1272
- field,
1273
- value,
1274
- markPrice,
1275
- { baseDP, quoteDP }
1276
- ]);
1277
- formik.setValues(newValues, true);
1278
- };
1279
1270
  const onSubmit = (values) => {
1280
- values = values || formik.values;
1281
- if (typeof values.order_type === "undefined" || values.order_type !== OrderType.MARKET && values.order_type !== OrderType.LIMIT) {
1271
+ if (!values || typeof values.order_type === "undefined" || values.order_type !== OrderType.MARKET && values.order_type !== OrderType.LIMIT) {
1282
1272
  throw new Error("order_type is error");
1283
1273
  }
1284
- return Promise.resolve().then(() => {
1285
- const orderCreator = OrderFactory.create(
1286
- !!values.order_type_ext ? values.order_type_ext : values.order_type
1287
- );
1274
+ const orderCreator = OrderFactory.create(
1275
+ !!values.order_type_ext ? values.order_type_ext : values.order_type
1276
+ );
1277
+ if (!orderCreator) {
1278
+ return Promise.reject(new Error("orderCreator is null"));
1279
+ }
1280
+ return orderCreator == null ? void 0 : orderCreator.validate(values, {
1281
+ symbol: symbolInfo[symbol](),
1282
+ token: tokenInfo[symbol](),
1283
+ maxQty,
1284
+ markPrice
1285
+ }).then(() => {
1288
1286
  if (!orderCreator) {
1289
1287
  throw new Error("orderCreator is null");
1290
1288
  }
@@ -1292,31 +1290,43 @@ var useOrderEntry = (symbol, initialValue = {}, options) => {
1292
1290
  throw new Error("symbol is null");
1293
1291
  }
1294
1292
  const data = orderCreator.create(values);
1295
- console.log("orderentry data:::", data);
1296
- formik.setSubmitting(true);
1297
1293
  return mutation(__spreadProps(__spreadValues({}, data), {
1298
1294
  symbol
1299
- })).finally(() => {
1300
- formik.setSubmitting(false);
1301
- });
1295
+ }));
1296
+ });
1297
+ };
1298
+ const calculate = useCallback(
1299
+ (values, field, value) => {
1300
+ console.log("calculate", values, field, value, markPrice);
1301
+ const fieldHandler = getCalculateHandler(field);
1302
+ const newValues = compose(
1303
+ head,
1304
+ orderEntityFormatHandle(),
1305
+ fieldHandler,
1306
+ baseInputHandle
1307
+ )([values, field, value, markPrice, { baseDP, quoteDP }]);
1308
+ return newValues;
1309
+ },
1310
+ [markPrice]
1311
+ );
1312
+ const validator = (values) => {
1313
+ const creator = OrderFactory.create(values.order_type);
1314
+ return creator == null ? void 0 : creator.validate(values, {
1315
+ symbol: symbolInfo[symbol](),
1316
+ token: tokenInfo[symbol](),
1317
+ maxQty,
1318
+ markPrice
1302
1319
  });
1303
1320
  };
1304
- useEffect(() => {
1305
- formik.resetForm();
1306
- }, [symbol]);
1307
1321
  return {
1308
1322
  maxQty,
1309
- // formState,
1310
- values: __spreadValues(__spreadValues({}, formik.values), orderExtraValues),
1311
- errors: formik.errors,
1312
1323
  freeCollateral,
1313
1324
  markPrice,
1314
- setValue,
1315
1325
  onSubmit,
1316
- isSubmitting: formik.isSubmitting,
1317
- resetForm: formik.resetForm,
1318
- validateForm: formik.validateForm,
1319
- submitCount: formik.submitCount,
1326
+ helper: {
1327
+ calculate,
1328
+ validator
1329
+ },
1320
1330
  symbolConfig: symbolInfo[symbol]()
1321
1331
  };
1322
1332
  };
@@ -1359,35 +1369,49 @@ var useAccountInfo = () => {
1359
1369
  return usePrivateQuery("/client/info");
1360
1370
  };
1361
1371
  var useMarketsStream = () => {
1362
- const ws = useWebSocketClient();
1363
- const { data } = useQuery(`/public/futures`);
1364
- const value = useObservable(
1365
- (_, input$) => ws.observe("tickers").pipe(
1366
- startWith([]),
1367
- withLatestFrom(input$.pipe(map((args) => args[0]))),
1368
- map((args) => {
1369
- if (args[0].length === 0) {
1370
- return args[1];
1372
+ const ws = useWS();
1373
+ const { data: futures } = useQuery(`/public/futures`);
1374
+ const { data: tickers } = useSWRSubscription("tickers", (_, { next }) => {
1375
+ const unsubscribe = ws.subscribe(
1376
+ // { event: "subscribe", topic: "markprices" },
1377
+ "tickers",
1378
+ {
1379
+ onMessage: (message) => {
1380
+ next(null, message);
1371
1381
  }
1372
- return args[1].map((item) => {
1373
- const ticker = args[0].find(
1374
- (t) => t.symbol === item.symbol
1375
- );
1376
- if (ticker) {
1377
- return __spreadProps(__spreadValues({}, item), {
1378
- ["24h_close"]: ticker.close,
1379
- ["24h_open"]: ticker.open,
1380
- ["24h_volumn"]: ticker.volume,
1381
- change: 0
1382
- });
1383
- }
1384
- return item;
1382
+ // onUnsubscribe: () => {
1383
+ // return "markprices";
1384
+ // },
1385
+ // onError: (error: any) => {
1386
+ // console.log("error", error);
1387
+ // },
1388
+ }
1389
+ );
1390
+ return () => {
1391
+ console.log("unsubscribe!!!!!!!");
1392
+ unsubscribe == null ? void 0 : unsubscribe();
1393
+ };
1394
+ });
1395
+ const value = useMemo(() => {
1396
+ if (!futures)
1397
+ return null;
1398
+ if (!tickers)
1399
+ return futures;
1400
+ return futures.map((item) => {
1401
+ const ticker = tickers.find(
1402
+ (t) => t.symbol === item.symbol
1403
+ );
1404
+ if (ticker) {
1405
+ return __spreadProps(__spreadValues({}, item), {
1406
+ ["24h_close"]: ticker.close,
1407
+ ["24h_open"]: ticker.open,
1408
+ ["24h_volumn"]: ticker.volume,
1409
+ change: 0
1385
1410
  });
1386
- })
1387
- ),
1388
- null,
1389
- [data]
1390
- );
1411
+ }
1412
+ return item;
1413
+ });
1414
+ }, [futures, tickers]);
1391
1415
  return { data: value };
1392
1416
  };
1393
1417
  var useFundingRate = (symbol) => {
@@ -1428,10 +1452,10 @@ var useFundingRate = (symbol) => {
1428
1452
  var fetcher3 = (url, init) => get(url, init);
1429
1453
  var usePrivateInfiniteQuery = (getKey, options) => {
1430
1454
  var _a;
1431
- const account3 = useAccount();
1455
+ const account4 = useAccount();
1432
1456
  const middleware = Array.isArray(options == null ? void 0 : options.use) ? (_a = options == null ? void 0 : options.use) != null ? _a : [] : [];
1433
1457
  const result = useSWRInfinite(
1434
- (pageIndex, previousPageData) => account3.state.status >= AccountStatusEnum.SignedIn ? getKey(pageIndex, previousPageData) : null,
1458
+ (pageIndex, previousPageData) => account4.state.status >= AccountStatusEnum.EnableTrading ? getKey(pageIndex, previousPageData) : null,
1435
1459
  fetcher3,
1436
1460
  __spreadProps(__spreadValues({}, options), {
1437
1461
  use: [signatureMiddleware, ...middleware]
@@ -1476,7 +1500,6 @@ var useOrderStream = ({
1476
1500
  if (!res.data) {
1477
1501
  return null;
1478
1502
  }
1479
- console.log("orders:::", markPrices);
1480
1503
  return (_a = res.data) == null ? void 0 : _a.flat().map((item) => {
1481
1504
  var _a2;
1482
1505
  return __spreadProps(__spreadValues({}, item), {
@@ -1506,6 +1529,77 @@ var useOrderStream = ({
1506
1529
  ];
1507
1530
  };
1508
1531
 
1532
+ // src/orderly/useTradeStream.ts
1533
+ var useTradeStream = (symbol) => {
1534
+ if (!symbol) {
1535
+ throw new Error("useTradeStream: symbol is required");
1536
+ }
1537
+ const { data, isLoading } = useQuery(
1538
+ `/public/market_trades?symbol=${symbol}&limit=20`
1539
+ );
1540
+ return { data, isLoading };
1541
+ };
1542
+ var useMarginRatio = () => {
1543
+ const [{ rows }] = usePositionStream();
1544
+ const { data: markPrices } = useMarkPricesStream();
1545
+ const { totalCollateral } = useCollateral();
1546
+ const marginRatio = useMemo(() => {
1547
+ const ratio = account.totalMarginRatio({
1548
+ totalCollateral,
1549
+ markPrices,
1550
+ positions: rows != null ? rows : []
1551
+ });
1552
+ return ratio;
1553
+ }, [rows, markPrices, totalCollateral]);
1554
+ return marginRatio;
1555
+ };
1556
+ var useChains = (networkId, options) => {
1557
+ const field = options == null ? void 0 : options.pick;
1558
+ const { data } = useSWR(
1559
+ "https://fi-api.woo.org/swap_support",
1560
+ (url) => fetch(url).then((res) => res.json()),
1561
+ {
1562
+ revalidateOnFocus: false,
1563
+ revalidateOnReconnect: false
1564
+ }
1565
+ );
1566
+ const chains = useMemo(() => {
1567
+ if (!data || !data.data)
1568
+ return data;
1569
+ let arr = [];
1570
+ Object.keys(data.data).forEach((key) => {
1571
+ const item = data.data[key];
1572
+ arr.push(__spreadProps(__spreadValues({}, item), {
1573
+ name: key
1574
+ }));
1575
+ });
1576
+ if (networkId === "mainnet") {
1577
+ arr = arr.filter((item) => item.network_infos.mainnet);
1578
+ }
1579
+ if (networkId === "testnet") {
1580
+ arr = arr.filter((item) => !item.network_infos.mainnet);
1581
+ }
1582
+ if (typeof (options == null ? void 0 : options.filter) === "function") {
1583
+ arr = arr.filter(options.filter);
1584
+ }
1585
+ if (typeof field !== "undefined") {
1586
+ return arr.map((item) => {
1587
+ return item[field];
1588
+ });
1589
+ }
1590
+ return arr;
1591
+ }, [data, networkId, field, options]);
1592
+ const findByChainId = useCallback(
1593
+ (chainId) => {
1594
+ if (!data || !data.data)
1595
+ return void 0;
1596
+ return data.data[chainId];
1597
+ },
1598
+ [data]
1599
+ );
1600
+ return [chains, { findByChainId }];
1601
+ };
1602
+
1509
1603
  // src/apis/index.ts
1510
1604
  var apis_exports = {};
1511
1605
  __export(apis_exports, {
@@ -1540,6 +1634,6 @@ var useFundingRate2 = (symbol) => {
1540
1634
  return useQuery(`/public/funding_rate`);
1541
1635
  };
1542
1636
 
1543
- export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAppState, useCollateral, useFetures, useFundingRate, useMarkPricesStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbook, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradingView, useWS, useWebSocketClient };
1637
+ export { DataSourceProvider, OrderStatus, OrderlyContext, OrderlyProvider, apis_exports as apis, useAccount, useAccountInfo, useAppState, useChains, useCollateral, useFetures, useFundingRate, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketsStream, useMaxQty, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePrivateObserve, usePrivateQuery, useQuery, useSymbolsInfo, useTickerStream, useTokenInfo, useTopicObserve, useTradeStream, useTradingView, useWS, useWebSocketClient };
1544
1638
  //# sourceMappingURL=out.js.map
1545
1639
  //# sourceMappingURL=index.mjs.map