@orderly.network/hooks 1.1.3-alpha.0 → 1.1.3-alpha.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.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +149 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +146 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ declare global {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
declare const _default: "1.1.3-alpha.
|
|
28
|
+
declare const _default: "1.1.3-alpha.10";
|
|
29
29
|
|
|
30
30
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
31
31
|
formatter?: (data: any) => T;
|
|
@@ -118,6 +118,15 @@ interface OrderlyConfigContextState {
|
|
|
118
118
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
119
119
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
120
120
|
|
|
121
|
+
type WsNetworkStatus = "connected" | "unstable" | "disconnected";
|
|
122
|
+
declare function useWsStatus(): WsNetworkStatus;
|
|
123
|
+
|
|
124
|
+
interface StatusContextState {
|
|
125
|
+
ws?: WsNetworkStatus;
|
|
126
|
+
}
|
|
127
|
+
declare const StatusContext: react.Context<StatusContextState>;
|
|
128
|
+
declare const StatusProvider: React.FC<PropsWithChildren>;
|
|
129
|
+
|
|
121
130
|
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
122
131
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
123
132
|
}[R];
|
|
@@ -503,6 +512,8 @@ declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?
|
|
|
503
512
|
|
|
504
513
|
declare function useMediaQuery(query: string): boolean;
|
|
505
514
|
|
|
515
|
+
declare const cleanStringStyle: (str: string | number) => string;
|
|
516
|
+
|
|
506
517
|
/** @hidden */
|
|
507
518
|
declare const useWooSwapQuery: () => {
|
|
508
519
|
query: (inputs: any) => Promise<any> | undefined;
|
|
@@ -528,4 +539,4 @@ declare const useCrossSwap: () => any;
|
|
|
528
539
|
/** @hidden */
|
|
529
540
|
declare const useSwap: () => any;
|
|
530
541
|
|
|
531
|
-
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, UseOrderEntryMetaState, WalletConnectorContext, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, _default as version };
|
|
542
|
+
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, cleanStringStyle, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, useWsStatus, _default as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare global {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
declare const _default: "1.1.3-alpha.
|
|
28
|
+
declare const _default: "1.1.3-alpha.10";
|
|
29
29
|
|
|
30
30
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
31
31
|
formatter?: (data: any) => T;
|
|
@@ -118,6 +118,15 @@ interface OrderlyConfigContextState {
|
|
|
118
118
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
119
119
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
120
120
|
|
|
121
|
+
type WsNetworkStatus = "connected" | "unstable" | "disconnected";
|
|
122
|
+
declare function useWsStatus(): WsNetworkStatus;
|
|
123
|
+
|
|
124
|
+
interface StatusContextState {
|
|
125
|
+
ws?: WsNetworkStatus;
|
|
126
|
+
}
|
|
127
|
+
declare const StatusContext: react.Context<StatusContextState>;
|
|
128
|
+
declare const StatusProvider: React.FC<PropsWithChildren>;
|
|
129
|
+
|
|
121
130
|
type RequireAtLeastOne<T, R extends keyof T = keyof T> = Omit<T, R> & {
|
|
122
131
|
[K in R]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<R, K>>>;
|
|
123
132
|
}[R];
|
|
@@ -503,6 +512,8 @@ declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?
|
|
|
503
512
|
|
|
504
513
|
declare function useMediaQuery(query: string): boolean;
|
|
505
514
|
|
|
515
|
+
declare const cleanStringStyle: (str: string | number) => string;
|
|
516
|
+
|
|
506
517
|
/** @hidden */
|
|
507
518
|
declare const useWooSwapQuery: () => {
|
|
508
519
|
query: (inputs: any) => Promise<any> | undefined;
|
|
@@ -528,4 +539,4 @@ declare const useCrossSwap: () => any;
|
|
|
528
539
|
/** @hidden */
|
|
529
540
|
declare const useSwap: () => any;
|
|
530
541
|
|
|
531
|
-
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, UseOrderEntryMetaState, WalletConnectorContext, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, _default as version };
|
|
542
|
+
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, cleanStringStyle, useAccount, useAccountInfo, useAccountInstance, useBoolean, useChain, useChains, useCollateral, useConfig, useCrossSwap, useDeposit, useEventEmitter, useFundingRate, useHoldingStream, useIndexPrice, useLazyQuery, useLeverage, useLocalStorage, useMarginRatio, useMarkPrice, useMarkPricesStream, useMarketTradeStream, useMarkets, useMarketsStream, useMaxQty, useMediaQuery, useMutation, useOrderEntry, useOrderStream, useOrderbookStream, usePositionStream, usePreLoadData, usePrivateDataObserver, usePrivateInfiniteQuery, usePrivateQuery, useQuery, useSessionStorage, useSettleSubscription, useSwap, useSymbolPriceRange, useSymbolsInfo, useTickerStream, useWS, useWalletConnector, useWalletSubscription, useWithdraw, useWooCrossSwapQuery, useWooSwapQuery, useWsStatus, _default as version };
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,8 @@ var useConstant4 = require('use-constant');
|
|
|
8
8
|
var core = require('@orderly.network/core');
|
|
9
9
|
var types = require('@orderly.network/types');
|
|
10
10
|
var useSWRInfinite = require('swr/infinite');
|
|
11
|
-
var useDebounce = require('use-debounce');
|
|
12
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
+
var useDebounce = require('use-debounce');
|
|
13
13
|
var utils = require('@orderly.network/utils');
|
|
14
14
|
var useSWRSubscription = require('swr/subscription');
|
|
15
15
|
var ramda = require('ramda');
|
|
@@ -28,9 +28,9 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
|
|
|
28
28
|
// src/version.ts
|
|
29
29
|
if (typeof window !== "undefined") {
|
|
30
30
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
31
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.1.3-alpha.
|
|
31
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.1.3-alpha.10";
|
|
32
32
|
}
|
|
33
|
-
var version_default = "1.1.3-alpha.
|
|
33
|
+
var version_default = "1.1.3-alpha.10";
|
|
34
34
|
var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
|
|
35
35
|
var OrderlyContext = React.createContext({
|
|
36
36
|
// configStore: new MemoryConfigStore(),
|
|
@@ -457,6 +457,44 @@ var useWS = () => {
|
|
|
457
457
|
});
|
|
458
458
|
return ws;
|
|
459
459
|
};
|
|
460
|
+
function useWsStatus() {
|
|
461
|
+
const ws = useWS();
|
|
462
|
+
const [wsStatus, setWsStatus] = React.useState(
|
|
463
|
+
ws.client.public.readyState ? "connected" : "disconnected"
|
|
464
|
+
);
|
|
465
|
+
const connectCount = React.useRef(0);
|
|
466
|
+
React.useEffect(() => {
|
|
467
|
+
ws.on("status:change", (status) => {
|
|
468
|
+
const { type, isPrivate } = status;
|
|
469
|
+
if (!isPrivate) {
|
|
470
|
+
switch (type) {
|
|
471
|
+
case "open":
|
|
472
|
+
connectCount.current = 0;
|
|
473
|
+
setWsStatus("connected");
|
|
474
|
+
break;
|
|
475
|
+
case "close":
|
|
476
|
+
connectCount.current = 0;
|
|
477
|
+
setWsStatus("disconnected");
|
|
478
|
+
break;
|
|
479
|
+
case "reconnecting":
|
|
480
|
+
connectCount.current++;
|
|
481
|
+
if (connectCount.current >= 2) {
|
|
482
|
+
setWsStatus("unstable");
|
|
483
|
+
}
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
return () => ws.off("websocket:status", () => {
|
|
489
|
+
});
|
|
490
|
+
}, []);
|
|
491
|
+
return wsStatus;
|
|
492
|
+
}
|
|
493
|
+
var StatusContext = React.createContext({});
|
|
494
|
+
var StatusProvider = (props) => {
|
|
495
|
+
const wsStatus = useWsStatus();
|
|
496
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StatusContext.Provider, { value: { ws: wsStatus }, children: props.children });
|
|
497
|
+
};
|
|
460
498
|
var usePrivateDataObserver = (options) => {
|
|
461
499
|
const ws = useWS();
|
|
462
500
|
const { mutate: mutate2 } = useSWR.useSWRConfig();
|
|
@@ -464,13 +502,19 @@ var usePrivateDataObserver = (options) => {
|
|
|
464
502
|
const { state } = useAccount();
|
|
465
503
|
const updateOrders = useDebounce.useDebouncedCallback((data) => {
|
|
466
504
|
const map = options.getKeysMap("orders");
|
|
505
|
+
const orderStatus = getSessionStorage(
|
|
506
|
+
"orderly_order_status",
|
|
507
|
+
"positions"
|
|
508
|
+
);
|
|
467
509
|
map.forEach((getKey, key) => {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
510
|
+
if (orderStatus === "history" && key === "orders" || orderStatus === "positions" && key === "orders:NEW" || key.includes(orderStatus)) {
|
|
511
|
+
mutate2(
|
|
512
|
+
useSWRInfinite.unstable_serialize((index, prevData) => [
|
|
513
|
+
getKey(index, prevData),
|
|
514
|
+
state.accountId
|
|
515
|
+
])
|
|
516
|
+
);
|
|
517
|
+
}
|
|
474
518
|
});
|
|
475
519
|
}, 500);
|
|
476
520
|
React.useEffect(() => {
|
|
@@ -491,7 +535,9 @@ var usePrivateDataObserver = (options) => {
|
|
|
491
535
|
onMessage: (data) => {
|
|
492
536
|
updateOrders(data);
|
|
493
537
|
if (Array.isArray(data)) {
|
|
494
|
-
data.forEach(
|
|
538
|
+
data.forEach(
|
|
539
|
+
(item) => ee.emit("orders:changed", { ...item, status: item.algoStatus })
|
|
540
|
+
);
|
|
495
541
|
} else {
|
|
496
542
|
ee.emit("orders:changed", { ...data, status: data.algoStatus });
|
|
497
543
|
}
|
|
@@ -554,6 +600,17 @@ var usePrivateDataObserver = (options) => {
|
|
|
554
600
|
};
|
|
555
601
|
}, [state.accountId]);
|
|
556
602
|
};
|
|
603
|
+
var getSessionStorage = (key, initialValue) => {
|
|
604
|
+
if (typeof window === "undefined") {
|
|
605
|
+
return initialValue;
|
|
606
|
+
}
|
|
607
|
+
try {
|
|
608
|
+
const item = window.sessionStorage.getItem(key);
|
|
609
|
+
return item ? parseJSON(item) : initialValue;
|
|
610
|
+
} catch (error) {
|
|
611
|
+
return initialValue;
|
|
612
|
+
}
|
|
613
|
+
};
|
|
557
614
|
var DataCenterContext = React.createContext(
|
|
558
615
|
{}
|
|
559
616
|
);
|
|
@@ -594,6 +651,11 @@ var OrderlyConfigProvider = (props) => {
|
|
|
594
651
|
enableSwapDeposit,
|
|
595
652
|
contracts
|
|
596
653
|
} = props;
|
|
654
|
+
if (typeof configStore !== "undefined" && !configStore.get("brokerId")) {
|
|
655
|
+
throw new types.SDKError(
|
|
656
|
+
"if configStore is provided, brokerId is required in configStore"
|
|
657
|
+
);
|
|
658
|
+
}
|
|
597
659
|
const innerConfigStore = useConstant4__default.default(() => {
|
|
598
660
|
return configStore || new core.DefaultConfigStore({ brokerId, networkId });
|
|
599
661
|
});
|
|
@@ -632,7 +694,7 @@ var OrderlyConfigProvider = (props) => {
|
|
|
632
694
|
enableSwapDeposit
|
|
633
695
|
// apiBaseUrl,
|
|
634
696
|
},
|
|
635
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DataCenterProvider, { children: props.children })
|
|
697
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(StatusProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DataCenterProvider, { children: props.children }) })
|
|
636
698
|
}
|
|
637
699
|
);
|
|
638
700
|
};
|
|
@@ -817,7 +879,7 @@ var reduceItems = (depth, level, data, asks = false) => {
|
|
|
817
879
|
const result = [];
|
|
818
880
|
if (typeof depth !== "undefined") {
|
|
819
881
|
const prices = /* @__PURE__ */ new Map();
|
|
820
|
-
for (let i = 0; i <
|
|
882
|
+
for (let i = 0; i < data.length; i++) {
|
|
821
883
|
const [price, quantity] = data[i];
|
|
822
884
|
if (isNaN(price) || isNaN(quantity))
|
|
823
885
|
continue;
|
|
@@ -1055,6 +1117,7 @@ var useOrderbookStream = (symbol, initial = INIT_DATA, options) => {
|
|
|
1055
1117
|
var needNumberOnlyFields = [
|
|
1056
1118
|
"order_quantity",
|
|
1057
1119
|
"order_price",
|
|
1120
|
+
"trigger_price",
|
|
1058
1121
|
"total"
|
|
1059
1122
|
];
|
|
1060
1123
|
var cleanStringStyle = (str) => {
|
|
@@ -1636,7 +1699,10 @@ var useOrderStream = (params) => {
|
|
|
1636
1699
|
return `/v1/orders?${search.toString()}`;
|
|
1637
1700
|
};
|
|
1638
1701
|
React.useEffect(() => {
|
|
1639
|
-
const
|
|
1702
|
+
const formatKey = (value) => value ? `:${value}` : "";
|
|
1703
|
+
const key = `orders${formatKey(status)}${formatKey(symbol)}${formatKey(
|
|
1704
|
+
side
|
|
1705
|
+
)}`;
|
|
1640
1706
|
regesterKeyHandler(key, getKey);
|
|
1641
1707
|
}, [status, symbol, side]);
|
|
1642
1708
|
const ordersResponse = usePrivateInfiniteQuery(getKey, {
|
|
@@ -1672,55 +1738,61 @@ var useOrderStream = (params) => {
|
|
|
1672
1738
|
}, [ordersResponse.data?.[0]?.meta?.total]);
|
|
1673
1739
|
const cancelAllOrders = React.useCallback(() => {
|
|
1674
1740
|
}, [ordersResponse.data]);
|
|
1675
|
-
const _updateOrder = React.useCallback(
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1741
|
+
const _updateOrder = React.useCallback(
|
|
1742
|
+
(orderId, order3, type) => {
|
|
1743
|
+
switch (type) {
|
|
1744
|
+
case "algoOrder":
|
|
1745
|
+
return doUpdateAlgoOrder({
|
|
1746
|
+
order_id: orderId,
|
|
1747
|
+
price: order3["order_price"],
|
|
1748
|
+
quantity: order3["order_quantity"],
|
|
1749
|
+
trigger_price: order3["trigger_price"]
|
|
1750
|
+
});
|
|
1751
|
+
default:
|
|
1752
|
+
return doUpdateOrder({ ...order3, order_id: orderId });
|
|
1753
|
+
}
|
|
1754
|
+
},
|
|
1755
|
+
[]
|
|
1756
|
+
);
|
|
1688
1757
|
const updateOrder = React.useCallback((orderId, order3) => {
|
|
1689
1758
|
return _updateOrder(orderId, order3, "normalOrder");
|
|
1690
1759
|
}, []);
|
|
1691
1760
|
const updateAlgoOrder = React.useCallback((orderId, order3) => {
|
|
1692
1761
|
return _updateOrder(orderId, order3, "algoOrder");
|
|
1693
1762
|
}, []);
|
|
1694
|
-
const _cancelOrder = React.useCallback(
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1763
|
+
const _cancelOrder = React.useCallback(
|
|
1764
|
+
(orderId, type, symbol2) => {
|
|
1765
|
+
switch (type) {
|
|
1766
|
+
case "algoOrder":
|
|
1767
|
+
return doCanceAlgolOrder(null, {
|
|
1768
|
+
// @ts-ignore
|
|
1769
|
+
order_id: orderId,
|
|
1770
|
+
symbol: symbol2,
|
|
1771
|
+
source: `SDK${version_default}`
|
|
1772
|
+
}).then((res) => {
|
|
1773
|
+
if (res.success) {
|
|
1774
|
+
ordersResponse.mutate();
|
|
1775
|
+
return res;
|
|
1776
|
+
} else {
|
|
1777
|
+
throw new Error(res.message);
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
default:
|
|
1781
|
+
return doCancelOrder(null, {
|
|
1782
|
+
order_id: orderId,
|
|
1783
|
+
symbol: symbol2,
|
|
1784
|
+
source: `SDK_${version_default}`
|
|
1785
|
+
}).then((res) => {
|
|
1786
|
+
if (res.success) {
|
|
1787
|
+
return res;
|
|
1788
|
+
} else {
|
|
1789
|
+
throw new Error(res.message);
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
},
|
|
1794
|
+
[]
|
|
1795
|
+
);
|
|
1724
1796
|
const cancelOrder = React.useCallback((orderId, symbol2) => {
|
|
1725
1797
|
return _cancelOrder(orderId, "normalOrder", symbol2);
|
|
1726
1798
|
}, []);
|
|
@@ -2293,21 +2365,32 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2293
2365
|
return { key, value };
|
|
2294
2366
|
};
|
|
2295
2367
|
const maxQty = useMaxQty(symbol, sideValue, isReduceOnly);
|
|
2368
|
+
const parseString2Number = (order3, key) => {
|
|
2369
|
+
if (typeof order3[key] !== "string")
|
|
2370
|
+
return;
|
|
2371
|
+
if (order3[key] && order3[key].startsWith(".")) {
|
|
2372
|
+
order3[key] = `0${order3[key]}`;
|
|
2373
|
+
}
|
|
2374
|
+
order3[key] = order3[key].replace(/,/g, "");
|
|
2375
|
+
};
|
|
2296
2376
|
const parsedData = React.useMemo(() => {
|
|
2297
2377
|
if (typeof symbolOrOrder === "string") {
|
|
2298
2378
|
return null;
|
|
2299
2379
|
}
|
|
2300
2380
|
if (typeof symbolOrOrder.order_quantity === "string") {
|
|
2301
|
-
symbolOrOrder
|
|
2302
|
-
/,/g,
|
|
2303
|
-
""
|
|
2304
|
-
);
|
|
2381
|
+
parseString2Number(symbolOrOrder, "order_quantity");
|
|
2305
2382
|
}
|
|
2306
2383
|
if (typeof symbolOrOrder.order_price === "string") {
|
|
2307
|
-
symbolOrOrder
|
|
2384
|
+
parseString2Number(symbolOrOrder, "order_price");
|
|
2308
2385
|
}
|
|
2309
2386
|
if (typeof symbolOrOrder.total === "string") {
|
|
2310
|
-
symbolOrOrder
|
|
2387
|
+
parseString2Number(symbolOrOrder, "total");
|
|
2388
|
+
}
|
|
2389
|
+
if (typeof symbolOrOrder.trigger_price === "string") {
|
|
2390
|
+
parseString2Number(symbolOrOrder, "trigger_price");
|
|
2391
|
+
}
|
|
2392
|
+
if (typeof symbolOrOrder.trigger_price === "string") {
|
|
2393
|
+
symbolOrOrder.trigger_price = symbolOrOrder.trigger_price.replace(/,/g, "");
|
|
2311
2394
|
}
|
|
2312
2395
|
if (typeof symbolOrOrder.order_quantity === "number") {
|
|
2313
2396
|
symbolOrOrder.order_quantity = new utils.Decimal(symbolOrOrder.order_quantity).toDecimalPlaces(baseDP).toString();
|
|
@@ -5201,7 +5284,10 @@ exports.MarketsType = MarketsType;
|
|
|
5201
5284
|
exports.OrderlyConfigProvider = OrderlyConfigProvider;
|
|
5202
5285
|
exports.OrderlyContext = OrderlyContext;
|
|
5203
5286
|
exports.OrderlyProvider = OrderlyProvider;
|
|
5287
|
+
exports.StatusContext = StatusContext;
|
|
5288
|
+
exports.StatusProvider = StatusProvider;
|
|
5204
5289
|
exports.WalletConnectorContext = WalletConnectorContext;
|
|
5290
|
+
exports.cleanStringStyle = cleanStringStyle;
|
|
5205
5291
|
exports.useAccount = useAccount;
|
|
5206
5292
|
exports.useAccountInfo = useAccountInfo;
|
|
5207
5293
|
exports.useAccountInstance = useAccountInstance;
|
|
@@ -5249,6 +5335,7 @@ exports.useWalletSubscription = useWalletSubscription;
|
|
|
5249
5335
|
exports.useWithdraw = useWithdraw;
|
|
5250
5336
|
exports.useWooCrossSwapQuery = useWooCrossSwapQuery;
|
|
5251
5337
|
exports.useWooSwapQuery = useWooSwapQuery;
|
|
5338
|
+
exports.useWsStatus = useWsStatus;
|
|
5252
5339
|
exports.version = version_default;
|
|
5253
5340
|
Object.keys(useDebounce).forEach(function (k) {
|
|
5254
5341
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|