@orderly.network/hooks 1.1.3-alpha.8 → 1.1.3
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 +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +68 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -39
- 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
|
|
28
|
+
declare const _default: "1.1.3";
|
|
29
29
|
|
|
30
30
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
31
31
|
formatter?: (data: any) => T;
|
|
@@ -118,7 +118,11 @@ interface OrderlyConfigContextState {
|
|
|
118
118
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
119
119
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
declare enum WsNetworkStatus {
|
|
122
|
+
Connected = "connected",
|
|
123
|
+
Unstable = "unstable",
|
|
124
|
+
Disconnected = "disconnected"
|
|
125
|
+
}
|
|
122
126
|
declare function useWsStatus(): WsNetworkStatus;
|
|
123
127
|
|
|
124
128
|
interface StatusContextState {
|
|
@@ -185,7 +189,7 @@ type OrderbookOptions = {
|
|
|
185
189
|
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
186
190
|
asks: OrderBookItem[];
|
|
187
191
|
bids: OrderBookItem[];
|
|
188
|
-
markPrice:
|
|
192
|
+
markPrice: number;
|
|
189
193
|
middlePrice: number[];
|
|
190
194
|
onDepthChange?: undefined;
|
|
191
195
|
depth?: undefined;
|
|
@@ -240,7 +244,7 @@ type UseOrderEntryReturn = {
|
|
|
240
244
|
metaState: UseOrderEntryMetaState;
|
|
241
245
|
symbolConfig: API.SymbolExt;
|
|
242
246
|
};
|
|
243
|
-
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type"
|
|
247
|
+
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type">> & {};
|
|
244
248
|
/**
|
|
245
249
|
* Create Order
|
|
246
250
|
* @example
|
|
@@ -302,7 +306,9 @@ declare const useMarkets: (type: MarketsType) => readonly [_orderly_network_type
|
|
|
302
306
|
|
|
303
307
|
declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
304
308
|
|
|
305
|
-
declare const useMarkPrice: (symbol: string) =>
|
|
309
|
+
declare const useMarkPrice: (symbol: string) => {
|
|
310
|
+
data: number;
|
|
311
|
+
};
|
|
306
312
|
|
|
307
313
|
declare const useIndexPrice: (symbol: string) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
308
314
|
|
|
@@ -512,6 +518,8 @@ declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?
|
|
|
512
518
|
|
|
513
519
|
declare function useMediaQuery(query: string): boolean;
|
|
514
520
|
|
|
521
|
+
declare const cleanStringStyle: (str: string | number) => string;
|
|
522
|
+
|
|
515
523
|
/** @hidden */
|
|
516
524
|
declare const useWooSwapQuery: () => {
|
|
517
525
|
query: (inputs: any) => Promise<any> | undefined;
|
|
@@ -537,4 +545,4 @@ declare const useCrossSwap: () => any;
|
|
|
537
545
|
/** @hidden */
|
|
538
546
|
declare const useSwap: () => any;
|
|
539
547
|
|
|
540
|
-
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, 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, useWsStatus, _default as version };
|
|
548
|
+
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderParams, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, WsNetworkStatus, 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
|
|
28
|
+
declare const _default: "1.1.3";
|
|
29
29
|
|
|
30
30
|
type useQueryOptions<T> = SWRConfiguration & {
|
|
31
31
|
formatter?: (data: any) => T;
|
|
@@ -118,7 +118,11 @@ interface OrderlyConfigContextState {
|
|
|
118
118
|
declare const OrderlyContext: react.Context<OrderlyConfigContextState>;
|
|
119
119
|
declare const OrderlyProvider: react.Provider<OrderlyConfigContextState>;
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
declare enum WsNetworkStatus {
|
|
122
|
+
Connected = "connected",
|
|
123
|
+
Unstable = "unstable",
|
|
124
|
+
Disconnected = "disconnected"
|
|
125
|
+
}
|
|
122
126
|
declare function useWsStatus(): WsNetworkStatus;
|
|
123
127
|
|
|
124
128
|
interface StatusContextState {
|
|
@@ -185,7 +189,7 @@ type OrderbookOptions = {
|
|
|
185
189
|
declare const useOrderbookStream: (symbol: string, initial?: OrderbookData, options?: OrderbookOptions) => ({
|
|
186
190
|
asks: OrderBookItem[];
|
|
187
191
|
bids: OrderBookItem[];
|
|
188
|
-
markPrice:
|
|
192
|
+
markPrice: number;
|
|
189
193
|
middlePrice: number[];
|
|
190
194
|
onDepthChange?: undefined;
|
|
191
195
|
depth?: undefined;
|
|
@@ -240,7 +244,7 @@ type UseOrderEntryReturn = {
|
|
|
240
244
|
metaState: UseOrderEntryMetaState;
|
|
241
245
|
symbolConfig: API.SymbolExt;
|
|
242
246
|
};
|
|
243
|
-
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type"
|
|
247
|
+
type OrderParams = Required<Pick<OrderEntity, "side" | "order_type" | "symbol">> & Partial<Omit<OrderEntity, "side" | "symbol" | "order_type">> & {};
|
|
244
248
|
/**
|
|
245
249
|
* Create Order
|
|
246
250
|
* @example
|
|
@@ -302,7 +306,9 @@ declare const useMarkets: (type: MarketsType) => readonly [_orderly_network_type
|
|
|
302
306
|
|
|
303
307
|
declare const useMarkPricesStream: () => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
304
308
|
|
|
305
|
-
declare const useMarkPrice: (symbol: string) =>
|
|
309
|
+
declare const useMarkPrice: (symbol: string) => {
|
|
310
|
+
data: number;
|
|
311
|
+
};
|
|
306
312
|
|
|
307
313
|
declare const useIndexPrice: (symbol: string) => swr_subscription.SWRSubscriptionResponse<any, any>;
|
|
308
314
|
|
|
@@ -512,6 +518,8 @@ declare const useSymbolPriceRange: (symbol: string, side: "BUY" | "SELL", price?
|
|
|
512
518
|
|
|
513
519
|
declare function useMediaQuery(query: string): boolean;
|
|
514
520
|
|
|
521
|
+
declare const cleanStringStyle: (str: string | number) => string;
|
|
522
|
+
|
|
515
523
|
/** @hidden */
|
|
516
524
|
declare const useWooSwapQuery: () => {
|
|
517
525
|
query: (inputs: any) => Promise<any> | undefined;
|
|
@@ -537,4 +545,4 @@ declare const useCrossSwap: () => any;
|
|
|
537
545
|
/** @hidden */
|
|
538
546
|
declare const useSwap: () => any;
|
|
539
547
|
|
|
540
|
-
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, 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, useWsStatus, _default as version };
|
|
548
|
+
export { ConfigProviderProps, Favorite, FavoriteTab, MarketsType, OrderParams, OrderlyConfigContextState, OrderlyConfigProvider, OrderlyContext, OrderlyProvider, Recent, StatusContext, StatusContextState, StatusProvider, UseOrderEntryMetaState, WalletConnectorContext, WsNetworkStatus, 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
|
@@ -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
|
|
31
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.1.3";
|
|
32
32
|
}
|
|
33
|
-
var version_default = "1.1.3
|
|
33
|
+
var version_default = "1.1.3";
|
|
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,10 +457,16 @@ var useWS = () => {
|
|
|
457
457
|
});
|
|
458
458
|
return ws;
|
|
459
459
|
};
|
|
460
|
+
var WsNetworkStatus = /* @__PURE__ */ ((WsNetworkStatus2) => {
|
|
461
|
+
WsNetworkStatus2["Connected"] = "connected";
|
|
462
|
+
WsNetworkStatus2["Unstable"] = "unstable";
|
|
463
|
+
WsNetworkStatus2["Disconnected"] = "disconnected";
|
|
464
|
+
return WsNetworkStatus2;
|
|
465
|
+
})(WsNetworkStatus || {});
|
|
460
466
|
function useWsStatus() {
|
|
461
467
|
const ws = useWS();
|
|
462
468
|
const [wsStatus, setWsStatus] = React.useState(
|
|
463
|
-
ws.client.public.readyState ? "connected" : "disconnected"
|
|
469
|
+
ws.client.public.readyState ? "connected" /* Connected */ : "disconnected" /* Disconnected */
|
|
464
470
|
);
|
|
465
471
|
const connectCount = React.useRef(0);
|
|
466
472
|
React.useEffect(() => {
|
|
@@ -470,16 +476,16 @@ function useWsStatus() {
|
|
|
470
476
|
switch (type) {
|
|
471
477
|
case "open":
|
|
472
478
|
connectCount.current = 0;
|
|
473
|
-
setWsStatus("connected");
|
|
479
|
+
setWsStatus("connected" /* Connected */);
|
|
474
480
|
break;
|
|
475
481
|
case "close":
|
|
476
482
|
connectCount.current = 0;
|
|
477
|
-
setWsStatus("disconnected");
|
|
483
|
+
setWsStatus("disconnected" /* Disconnected */);
|
|
478
484
|
break;
|
|
479
485
|
case "reconnecting":
|
|
480
486
|
connectCount.current++;
|
|
481
|
-
if (connectCount.current >=
|
|
482
|
-
setWsStatus("unstable");
|
|
487
|
+
if (connectCount.current >= 3) {
|
|
488
|
+
setWsStatus("unstable" /* Unstable */);
|
|
483
489
|
}
|
|
484
490
|
break;
|
|
485
491
|
}
|
|
@@ -507,7 +513,8 @@ var usePrivateDataObserver = (options) => {
|
|
|
507
513
|
"positions"
|
|
508
514
|
);
|
|
509
515
|
map.forEach((getKey, key) => {
|
|
510
|
-
if (orderStatus === "history" && key === "orders" || orderStatus === "positions" && key === "orders:NEW" || key.includes(
|
|
516
|
+
if (orderStatus === "history" && key === "orders" || orderStatus === "positions" && key === "orders:NEW" || key.includes("INCOMPLETE") || // always update pending list
|
|
517
|
+
key.includes(orderStatus)) {
|
|
511
518
|
mutate2(
|
|
512
519
|
useSWRInfinite.unstable_serialize((index, prevData) => [
|
|
513
520
|
getKey(index, prevData),
|
|
@@ -704,16 +711,18 @@ var useWalletConnector = () => {
|
|
|
704
711
|
};
|
|
705
712
|
var useMarkPrice = (symbol) => {
|
|
706
713
|
const ws = useWS();
|
|
707
|
-
|
|
714
|
+
const [price, setPrice] = React.useState(0);
|
|
715
|
+
React.useEffect(() => {
|
|
708
716
|
const unsubscribe = ws.subscribe(`${symbol}@markprice`, {
|
|
709
717
|
onMessage: (message) => {
|
|
710
|
-
|
|
718
|
+
setPrice(message.price);
|
|
711
719
|
}
|
|
712
720
|
});
|
|
713
721
|
return () => {
|
|
714
722
|
unsubscribe?.();
|
|
715
723
|
};
|
|
716
|
-
});
|
|
724
|
+
}, [symbol]);
|
|
725
|
+
return { data: price };
|
|
717
726
|
};
|
|
718
727
|
var useIndexPrice = (symbol) => {
|
|
719
728
|
symbol = symbol.replace("PERP", "SPOT");
|
|
@@ -879,7 +888,7 @@ var reduceItems = (depth, level, data, asks = false) => {
|
|
|
879
888
|
const result = [];
|
|
880
889
|
if (typeof depth !== "undefined") {
|
|
881
890
|
const prices = /* @__PURE__ */ new Map();
|
|
882
|
-
for (let i = 0; i <
|
|
891
|
+
for (let i = 0; i < data.length; i++) {
|
|
883
892
|
const [price, quantity] = data[i];
|
|
884
893
|
if (isNaN(price) || isNaN(quantity))
|
|
885
894
|
continue;
|
|
@@ -1117,6 +1126,7 @@ var useOrderbookStream = (symbol, initial = INIT_DATA, options) => {
|
|
|
1117
1126
|
var needNumberOnlyFields = [
|
|
1118
1127
|
"order_quantity",
|
|
1119
1128
|
"order_price",
|
|
1129
|
+
"trigger_price",
|
|
1120
1130
|
"total"
|
|
1121
1131
|
];
|
|
1122
1132
|
var cleanStringStyle = (str) => {
|
|
@@ -1201,13 +1211,13 @@ function quantityInputHandle(inputs) {
|
|
|
1201
1211
|
}
|
|
1202
1212
|
if (values.order_type === types.OrderType.MARKET || values.order_type === types.OrderType.STOP_MARKET) {
|
|
1203
1213
|
const price = markPrice;
|
|
1204
|
-
values.total = quantity.mul(price).todp(2).
|
|
1214
|
+
values.total = quantity.mul(price).todp(2).toString();
|
|
1205
1215
|
}
|
|
1206
1216
|
if (values.order_type === types.OrderType.LIMIT || values.order_type === types.OrderType.STOP_LIMIT) {
|
|
1207
1217
|
if (values.order_price) {
|
|
1208
1218
|
const price = Number(values.order_price);
|
|
1209
1219
|
const total = quantity.mul(price);
|
|
1210
|
-
values.total = total.todp(2).
|
|
1220
|
+
values.total = total.todp(2).toString();
|
|
1211
1221
|
} else {
|
|
1212
1222
|
values.total = "";
|
|
1213
1223
|
}
|
|
@@ -1236,13 +1246,13 @@ function totalInputHandle(inputs) {
|
|
|
1236
1246
|
const totalDP = total.dp();
|
|
1237
1247
|
if (totalDP > config.quoteDP) {
|
|
1238
1248
|
total = total.toDecimalPlaces(config.quoteDP);
|
|
1239
|
-
values.total = total.
|
|
1249
|
+
values.total = total.toString();
|
|
1240
1250
|
}
|
|
1241
1251
|
const quantity = total.div(price);
|
|
1242
1252
|
return [
|
|
1243
1253
|
{
|
|
1244
1254
|
...values,
|
|
1245
|
-
order_quantity: quantity.toDecimalPlaces(Math.min(config.baseDP, quantity.dp())).
|
|
1255
|
+
order_quantity: quantity.toDecimalPlaces(Math.min(config.baseDP, quantity.dp())).toString()
|
|
1246
1256
|
},
|
|
1247
1257
|
input,
|
|
1248
1258
|
value,
|
|
@@ -1710,7 +1720,8 @@ var useOrderStream = (params) => {
|
|
|
1710
1720
|
// onError: (err) => {
|
|
1711
1721
|
// console.error("fetch failed::::", err);
|
|
1712
1722
|
// },
|
|
1713
|
-
formatter: (data) => data
|
|
1723
|
+
formatter: (data) => data,
|
|
1724
|
+
revalidateOnFocus: false
|
|
1714
1725
|
});
|
|
1715
1726
|
const flattenOrders = React.useMemo(() => {
|
|
1716
1727
|
if (!ordersResponse.data) {
|
|
@@ -2345,7 +2356,7 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2345
2356
|
const diffOrderEntry = (prev, current) => {
|
|
2346
2357
|
if (!prev)
|
|
2347
2358
|
return null;
|
|
2348
|
-
let key, value;
|
|
2359
|
+
let key, value, preValue;
|
|
2349
2360
|
const keys = Object.keys(current);
|
|
2350
2361
|
for (let i = 0; i < keys.length; i++) {
|
|
2351
2362
|
const k = keys[i];
|
|
@@ -2356,12 +2367,13 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2356
2367
|
if (preveValue !== currentValue) {
|
|
2357
2368
|
key = k;
|
|
2358
2369
|
value = currentValue;
|
|
2370
|
+
preValue = preveValue;
|
|
2359
2371
|
break;
|
|
2360
2372
|
}
|
|
2361
2373
|
}
|
|
2362
2374
|
if (!key)
|
|
2363
2375
|
return null;
|
|
2364
|
-
return { key, value };
|
|
2376
|
+
return { key, value, preValue };
|
|
2365
2377
|
};
|
|
2366
2378
|
const maxQty = useMaxQty(symbol, sideValue, isReduceOnly);
|
|
2367
2379
|
const parseString2Number = (order3, key) => {
|
|
@@ -2372,12 +2384,34 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2372
2384
|
}
|
|
2373
2385
|
order3[key] = order3[key].replace(/,/g, "");
|
|
2374
2386
|
};
|
|
2387
|
+
const needParse = React.useMemo(() => {
|
|
2388
|
+
if (typeof symbolOrOrder === "string") {
|
|
2389
|
+
return null;
|
|
2390
|
+
}
|
|
2391
|
+
return ramda.pick([
|
|
2392
|
+
"order_price",
|
|
2393
|
+
"side",
|
|
2394
|
+
"order_quantity",
|
|
2395
|
+
"visible_quantity",
|
|
2396
|
+
"order_type",
|
|
2397
|
+
"order_type_ext",
|
|
2398
|
+
"symbol",
|
|
2399
|
+
"total",
|
|
2400
|
+
"reduce_only",
|
|
2401
|
+
"trigger_price"
|
|
2402
|
+
])(
|
|
2403
|
+
//@ts-ignore
|
|
2404
|
+
symbolOrOrder
|
|
2405
|
+
);
|
|
2406
|
+
}, [symbolOrOrder]);
|
|
2375
2407
|
const parsedData = React.useMemo(() => {
|
|
2376
2408
|
if (typeof symbolOrOrder === "string") {
|
|
2377
2409
|
return null;
|
|
2378
2410
|
}
|
|
2379
2411
|
if (typeof symbolOrOrder.order_quantity === "string") {
|
|
2380
2412
|
parseString2Number(symbolOrOrder, "order_quantity");
|
|
2413
|
+
} else if (typeof symbolOrOrder.order_quantity === "number") {
|
|
2414
|
+
symbolOrOrder.order_quantity = new utils.Decimal(symbolOrOrder.order_quantity).toDecimalPlaces(baseDP).toString();
|
|
2381
2415
|
}
|
|
2382
2416
|
if (typeof symbolOrOrder.order_price === "string") {
|
|
2383
2417
|
parseString2Number(symbolOrOrder, "order_price");
|
|
@@ -2388,11 +2422,18 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2388
2422
|
if (typeof symbolOrOrder.trigger_price === "string") {
|
|
2389
2423
|
parseString2Number(symbolOrOrder, "trigger_price");
|
|
2390
2424
|
}
|
|
2391
|
-
if (typeof symbolOrOrder.order_quantity === "number") {
|
|
2392
|
-
symbolOrOrder.order_quantity = new utils.Decimal(symbolOrOrder.order_quantity).toDecimalPlaces(baseDP).toString();
|
|
2393
|
-
}
|
|
2394
2425
|
return symbolOrOrder;
|
|
2395
|
-
}, [
|
|
2426
|
+
}, [
|
|
2427
|
+
needParse?.order_price,
|
|
2428
|
+
needParse?.order_quantity,
|
|
2429
|
+
needParse?.total,
|
|
2430
|
+
needParse?.trigger_price,
|
|
2431
|
+
needParse?.order_type,
|
|
2432
|
+
needParse?.order_type_ext,
|
|
2433
|
+
needParse?.symbol,
|
|
2434
|
+
needParse?.reduce_only,
|
|
2435
|
+
needParse?.side
|
|
2436
|
+
]);
|
|
2396
2437
|
const createOrder = (values) => {
|
|
2397
2438
|
if (!values.symbol) {
|
|
2398
2439
|
throw new types.SDKError("symbol is error");
|
|
@@ -2514,19 +2555,7 @@ function useOrderEntry(symbolOrOrder, sideOrOptions, reduceOnly, options) {
|
|
|
2514
2555
|
prevOrderData.current = parsedData;
|
|
2515
2556
|
orderDataCache.current = values;
|
|
2516
2557
|
return values;
|
|
2517
|
-
}, [
|
|
2518
|
-
parsedData?.order_price,
|
|
2519
|
-
parsedData?.side,
|
|
2520
|
-
parsedData?.order_quantity,
|
|
2521
|
-
parsedData?.visible_quantity,
|
|
2522
|
-
parsedData?.order_type,
|
|
2523
|
-
parsedData?.order_type_ext,
|
|
2524
|
-
parsedData?.symbol,
|
|
2525
|
-
parsedData?.total,
|
|
2526
|
-
parsedData?.reduce_only,
|
|
2527
|
-
parsedData?.trigger_price,
|
|
2528
|
-
markPrice
|
|
2529
|
-
]);
|
|
2558
|
+
}, [parsedData, markPrice]);
|
|
2530
2559
|
React.useEffect(() => {
|
|
2531
2560
|
if (!markPrice)
|
|
2532
2561
|
return;
|
|
@@ -4054,7 +4083,7 @@ var woofiDexCrossChainRouterAbi = [
|
|
|
4054
4083
|
var nativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
4055
4084
|
var isNativeTokenChecker = (address) => address === nativeTokenAddress;
|
|
4056
4085
|
var useChains = (networkId, options = {}) => {
|
|
4057
|
-
const { pick:
|
|
4086
|
+
const { pick: pick4, crossEnabled, wooSwapEnabled, ...swrOptions } = options;
|
|
4058
4087
|
const { configStore } = React.useContext(OrderlyContext);
|
|
4059
4088
|
const field = options?.pick;
|
|
4060
4089
|
const filterFun = React.useRef(options?.filter);
|
|
@@ -5283,6 +5312,8 @@ exports.OrderlyProvider = OrderlyProvider;
|
|
|
5283
5312
|
exports.StatusContext = StatusContext;
|
|
5284
5313
|
exports.StatusProvider = StatusProvider;
|
|
5285
5314
|
exports.WalletConnectorContext = WalletConnectorContext;
|
|
5315
|
+
exports.WsNetworkStatus = WsNetworkStatus;
|
|
5316
|
+
exports.cleanStringStyle = cleanStringStyle;
|
|
5286
5317
|
exports.useAccount = useAccount;
|
|
5287
5318
|
exports.useAccountInfo = useAccountInfo;
|
|
5288
5319
|
exports.useAccountInstance = useAccountInstance;
|