@orderly.network/hooks 0.0.77 → 0.0.79
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.js +25 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import useConstant from 'use-constant';
|
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
8
|
import { SimpleDI, Account, EventEmitter, utils } from '@orderly.network/core';
|
|
9
9
|
import { AccountStatusEnum, OrderSide, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, OrderStatus as OrderStatus$1, WS_WalletStatusEnum, OrderType } from '@orderly.network/types';
|
|
10
|
-
import useSWRSubscription from 'swr/subscription';
|
|
11
10
|
import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
|
|
11
|
+
import useSWRSubscription from 'swr/subscription';
|
|
12
12
|
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick } from 'ramda';
|
|
13
13
|
import { positions, account, order } from '@orderly.network/futures';
|
|
14
14
|
import useSWRInfinite from 'swr/infinite';
|
|
@@ -481,30 +481,31 @@ var useTickerStream = (symbol) => {
|
|
|
481
481
|
revalidateOnFocus: false
|
|
482
482
|
}
|
|
483
483
|
);
|
|
484
|
+
const [ticker, setTicker] = useState();
|
|
484
485
|
const ws = useWS();
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
// onUnsubscribe: () => {
|
|
496
|
-
// return "markprices";
|
|
497
|
-
// },
|
|
498
|
-
// onError: (error: any) => {
|
|
499
|
-
//
|
|
500
|
-
// },
|
|
486
|
+
useEffect(() => {
|
|
487
|
+
const unsubscribe = ws.subscribe(
|
|
488
|
+
// { event: "subscribe", topic: "markprices" },
|
|
489
|
+
`${symbol}@ticker`,
|
|
490
|
+
{
|
|
491
|
+
onMessage: (message) => {
|
|
492
|
+
if (message.symbol !== symbol)
|
|
493
|
+
return;
|
|
494
|
+
setTicker(message);
|
|
501
495
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
496
|
+
// onUnsubscribe: () => {
|
|
497
|
+
// return "markprices";
|
|
498
|
+
// },
|
|
499
|
+
// onError: (error: any) => {
|
|
500
|
+
//
|
|
501
|
+
// },
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
return () => {
|
|
505
|
+
setTicker(void 0);
|
|
506
|
+
unsubscribe?.();
|
|
507
|
+
};
|
|
508
|
+
}, [symbol]);
|
|
508
509
|
const value = useMemo(() => {
|
|
509
510
|
if (!info)
|
|
510
511
|
return null;
|
|
@@ -524,7 +525,7 @@ var useTickerStream = (symbol) => {
|
|
|
524
525
|
config["change"] = new Decimal(ticker.close).minus(ticker.open).div(ticker.open).toNumber();
|
|
525
526
|
}
|
|
526
527
|
return config;
|
|
527
|
-
}, [info, ticker]);
|
|
528
|
+
}, [info, symbol, ticker]);
|
|
528
529
|
return value;
|
|
529
530
|
};
|
|
530
531
|
var useMarkPrice = (symbol) => {
|