@orderly.network/hooks 1.0.14 → 1.0.15
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 +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +136 -231
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -232
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
package/dist/index.mjs
CHANGED
|
@@ -7,12 +7,14 @@ import useConstant4 from 'use-constant';
|
|
|
7
7
|
export { default as useConstant } from 'use-constant';
|
|
8
8
|
import { SimpleDI, Account, EventEmitter, DefaultConfigStore, LocalStorageStore, EtherAdapter, utils } from '@orderly.network/core';
|
|
9
9
|
import { AccountStatusEnum, OrderStatus, OrderSide, chainsInfoMap, ARBITRUM_TESTNET_CHAINID, ARBITRUM_MAINNET_CHAINID, WS_WalletStatusEnum, OrderType } from '@orderly.network/types';
|
|
10
|
-
import useSWRInfinite from 'swr/infinite';
|
|
10
|
+
import useSWRInfinite, { unstable_serialize } from 'swr/infinite';
|
|
11
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
12
|
+
export * from 'use-debounce';
|
|
13
|
+
import { jsx } from 'react/jsx-runtime';
|
|
11
14
|
import { Decimal, zero, getPrecisionByNumber, timeConvertString } from '@orderly.network/utils';
|
|
12
15
|
import useSWRSubscription from 'swr/subscription';
|
|
13
16
|
import { pathOr, propOr, compose, head, prop, mergeDeepRight, pick, min } from 'ramda';
|
|
14
17
|
import { positions, account, order } from '@orderly.network/perp';
|
|
15
|
-
export * from 'use-debounce';
|
|
16
18
|
import { createClient } from '@layerzerolabs/scan-client';
|
|
17
19
|
|
|
18
20
|
// src/useQuery.ts
|
|
@@ -174,7 +176,6 @@ var signatureMiddleware = (useSWRNext) => {
|
|
|
174
176
|
url
|
|
175
177
|
};
|
|
176
178
|
const signature = await signer.sign(payload);
|
|
177
|
-
console.log("signature:", fullUrl);
|
|
178
179
|
return fetcher3(fullUrl, {
|
|
179
180
|
headers: {
|
|
180
181
|
...signature,
|
|
@@ -259,8 +260,16 @@ var usePrivateInfiniteQuery = (getKey, options) => {
|
|
|
259
260
|
const account5 = useAccount();
|
|
260
261
|
const middleware = Array.isArray(restOptions?.use) ? restOptions?.use ?? [] : [];
|
|
261
262
|
const result = useSWRInfinite(
|
|
262
|
-
(pageIndex, previousPageData) =>
|
|
263
|
-
|
|
263
|
+
(pageIndex, previousPageData) => {
|
|
264
|
+
const queryKey = getKey(pageIndex, previousPageData);
|
|
265
|
+
if (account5.state.status < AccountStatusEnum.EnableTrading || !queryKey) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
return [queryKey, account5.state.accountId];
|
|
269
|
+
},
|
|
270
|
+
(url, init) => {
|
|
271
|
+
return get(url, init, formatter);
|
|
272
|
+
},
|
|
264
273
|
{
|
|
265
274
|
...restOptions,
|
|
266
275
|
use: [signatureMiddleware, ...middleware]
|
|
@@ -423,12 +432,113 @@ var useWS = () => {
|
|
|
423
432
|
websocketClient.openPrivate(nextState.accountId);
|
|
424
433
|
}
|
|
425
434
|
});
|
|
435
|
+
if (typeof window !== "undefined") {
|
|
436
|
+
window["__Orderly_WS"] = websocketClient;
|
|
437
|
+
}
|
|
426
438
|
SimpleDI.registerByName(WS_NAME, websocketClient);
|
|
427
439
|
}
|
|
428
440
|
return websocketClient;
|
|
429
441
|
});
|
|
430
442
|
return ws;
|
|
431
443
|
};
|
|
444
|
+
var usePrivateDataObserver = () => {
|
|
445
|
+
const ws = useWS();
|
|
446
|
+
const { mutate: mutate2 } = useSWRConfig();
|
|
447
|
+
const ee = useEventEmitter();
|
|
448
|
+
const { state } = useAccount();
|
|
449
|
+
const updateOrders = useDebouncedCallback(() => {
|
|
450
|
+
mutate2(
|
|
451
|
+
unstable_serialize(() => [
|
|
452
|
+
`/v1/orders?size=100&page=1&status=${OrderStatus.INCOMPLETE}`,
|
|
453
|
+
state.accountId
|
|
454
|
+
])
|
|
455
|
+
);
|
|
456
|
+
mutate2(
|
|
457
|
+
unstable_serialize(() => [
|
|
458
|
+
`/v1/orders?size=100&page=1&status=${OrderStatus.NEW}`,
|
|
459
|
+
state.accountId
|
|
460
|
+
])
|
|
461
|
+
);
|
|
462
|
+
}, 500);
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
if (!state.accountId)
|
|
465
|
+
return;
|
|
466
|
+
const unsubscribe = ws.privateSubscribe("executionreport", {
|
|
467
|
+
onMessage: (data) => {
|
|
468
|
+
updateOrders();
|
|
469
|
+
ee.emit("orders:changed", data);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return () => unsubscribe?.();
|
|
473
|
+
}, [state.accountId]);
|
|
474
|
+
useEffect(() => {
|
|
475
|
+
if (!state.accountId)
|
|
476
|
+
return;
|
|
477
|
+
const key = ["/v1/positions", state.accountId];
|
|
478
|
+
const unsubscribe = ws.privateSubscribe("position", {
|
|
479
|
+
onMessage: (data) => {
|
|
480
|
+
const { positions: nextPostions } = data;
|
|
481
|
+
mutate2(
|
|
482
|
+
key,
|
|
483
|
+
(prevPositions) => {
|
|
484
|
+
if (!!prevPositions) {
|
|
485
|
+
return {
|
|
486
|
+
...prevPositions,
|
|
487
|
+
rows: prevPositions.rows.map((row) => {
|
|
488
|
+
const item = nextPostions.find(
|
|
489
|
+
(item2) => item2.symbol === row.symbol
|
|
490
|
+
);
|
|
491
|
+
if (item) {
|
|
492
|
+
return {
|
|
493
|
+
symbol: item.symbol,
|
|
494
|
+
position_qty: item.positionQty,
|
|
495
|
+
cost_position: item.costPosition,
|
|
496
|
+
last_sum_unitary_funding: item.lastSumUnitaryFunding,
|
|
497
|
+
pending_long_qty: item.pendingLongQty,
|
|
498
|
+
pending_short_qty: item.pendingShortQty,
|
|
499
|
+
settle_price: item.settlePrice,
|
|
500
|
+
average_open_price: item.averageOpenPrice,
|
|
501
|
+
unsettled_pnl: item.unsettledPnl,
|
|
502
|
+
mark_price: item.markPrice,
|
|
503
|
+
est_liq_price: item.estLiqPrice,
|
|
504
|
+
timestamp: Date.now(),
|
|
505
|
+
imr: item.imr,
|
|
506
|
+
mmr: item.mmr,
|
|
507
|
+
IMR_withdraw_orders: item.imrwithOrders,
|
|
508
|
+
MMR_with_orders: item.mmrwithOrders,
|
|
509
|
+
pnl_24_h: item.pnl24H,
|
|
510
|
+
fee_24_h: item.fee24H
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
return row;
|
|
514
|
+
})
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
revalidate: false
|
|
520
|
+
}
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
return () => {
|
|
525
|
+
unsubscribe?.();
|
|
526
|
+
};
|
|
527
|
+
}, [state.accountId]);
|
|
528
|
+
};
|
|
529
|
+
var DataCenterContext = createContext(
|
|
530
|
+
{}
|
|
531
|
+
);
|
|
532
|
+
var DataCenterProvider = ({ children }) => {
|
|
533
|
+
const { error, done } = usePreLoadData();
|
|
534
|
+
usePrivateDataObserver();
|
|
535
|
+
if (error) {
|
|
536
|
+
return /* @__PURE__ */ jsx("div", { children: "Data load failed" });
|
|
537
|
+
}
|
|
538
|
+
if (!done)
|
|
539
|
+
return null;
|
|
540
|
+
return /* @__PURE__ */ jsx(DataCenterContext.Provider, { value: {}, children });
|
|
541
|
+
};
|
|
432
542
|
var OrderlyConfigProvider = (props) => {
|
|
433
543
|
const [account5, setAccount] = React.useState(null);
|
|
434
544
|
const {
|
|
@@ -466,7 +576,7 @@ var OrderlyConfigProvider = (props) => {
|
|
|
466
576
|
if (!account5) {
|
|
467
577
|
return null;
|
|
468
578
|
}
|
|
469
|
-
return /* @__PURE__ */
|
|
579
|
+
return /* @__PURE__ */ jsx(
|
|
470
580
|
OrderlyProvider,
|
|
471
581
|
{
|
|
472
582
|
value: {
|
|
@@ -476,9 +586,9 @@ var OrderlyConfigProvider = (props) => {
|
|
|
476
586
|
networkId,
|
|
477
587
|
enableSwapDeposit
|
|
478
588
|
// apiBaseUrl,
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
589
|
+
},
|
|
590
|
+
children: /* @__PURE__ */ jsx(DataCenterProvider, { children: props.children })
|
|
591
|
+
}
|
|
482
592
|
);
|
|
483
593
|
};
|
|
484
594
|
var WalletConnectorContext = createContext({});
|
|
@@ -1100,7 +1210,7 @@ var usePositionStream = (symbol, options) => {
|
|
|
1100
1210
|
} = usePrivateQuery(`/v1/positions`, {
|
|
1101
1211
|
// revalidateOnFocus: false,
|
|
1102
1212
|
// revalidateOnReconnect: false,
|
|
1103
|
-
// dedupingInterval:
|
|
1213
|
+
// dedupingInterval: 200,
|
|
1104
1214
|
// keepPreviousData: false,
|
|
1105
1215
|
// revalidateIfStale: true,
|
|
1106
1216
|
...options,
|
|
@@ -1108,10 +1218,6 @@ var usePositionStream = (symbol, options) => {
|
|
|
1108
1218
|
onError: (err) => {
|
|
1109
1219
|
}
|
|
1110
1220
|
});
|
|
1111
|
-
usePositionUpdateStream((positions2) => {
|
|
1112
|
-
console.log("position message", positions2);
|
|
1113
|
-
updatePositions();
|
|
1114
|
-
});
|
|
1115
1221
|
const { data: markPrices } = useMarkPricesStream();
|
|
1116
1222
|
const formatedPositions = useMemo(() => {
|
|
1117
1223
|
if (!data?.rows || !symbolInfo || !accountInfo)
|
|
@@ -1260,41 +1366,6 @@ var pathOr_unsettledPnLPathOr = pathOr(0, [
|
|
|
1260
1366
|
"aggregated",
|
|
1261
1367
|
"unsettledPnL"
|
|
1262
1368
|
]);
|
|
1263
|
-
var usePositionUpdateStream = (callback) => {
|
|
1264
|
-
const ws = useWS();
|
|
1265
|
-
const positionList = useRef({});
|
|
1266
|
-
return useSWRSubscription("positionUpdate", (key, { next }) => {
|
|
1267
|
-
const unsubscribe = ws.privateSubscribe(
|
|
1268
|
-
// { event: "subscribe", topic: "markprices" },
|
|
1269
|
-
"position",
|
|
1270
|
-
{
|
|
1271
|
-
onMessage: (message) => {
|
|
1272
|
-
const { positions: positions2 } = message;
|
|
1273
|
-
let update = false;
|
|
1274
|
-
for (const p in positions2) {
|
|
1275
|
-
const { symbol, positionQty } = positions2[p];
|
|
1276
|
-
if (positionList.current[symbol] !== positionQty) {
|
|
1277
|
-
update = true;
|
|
1278
|
-
positionList.current[symbol] = positionQty;
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
if (update) {
|
|
1282
|
-
callback(positions2.current);
|
|
1283
|
-
}
|
|
1284
|
-
next(null, positionList);
|
|
1285
|
-
},
|
|
1286
|
-
// onUnsubscribe: () => {
|
|
1287
|
-
// return "markprices";
|
|
1288
|
-
// },
|
|
1289
|
-
onError: (error) => {
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
);
|
|
1293
|
-
return () => {
|
|
1294
|
-
unsubscribe?.();
|
|
1295
|
-
};
|
|
1296
|
-
});
|
|
1297
|
-
};
|
|
1298
1369
|
var useHoldingStream = () => {
|
|
1299
1370
|
const ws = useWS();
|
|
1300
1371
|
const { data, isLoading, mutate: mutate2 } = usePrivateQuery(
|
|
@@ -1346,10 +1417,15 @@ var useHoldingStream = () => {
|
|
|
1346
1417
|
};
|
|
1347
1418
|
var useOrderStream = (params) => {
|
|
1348
1419
|
const { status, symbol, side, size = 100 } = params;
|
|
1349
|
-
const ws = useWS();
|
|
1350
1420
|
const { data: markPrices = {} } = useMarkPricesStream();
|
|
1351
|
-
const [doCancelOrder] = useMutation(
|
|
1352
|
-
|
|
1421
|
+
const [doCancelOrder, { error: cancelOrderError }] = useMutation(
|
|
1422
|
+
"/v1/order",
|
|
1423
|
+
"DELETE"
|
|
1424
|
+
);
|
|
1425
|
+
const [doUpdateOrder, { error: updateOrderError }] = useMutation(
|
|
1426
|
+
"/v1/order",
|
|
1427
|
+
"PUT"
|
|
1428
|
+
);
|
|
1353
1429
|
const ordersResponse = usePrivateInfiniteQuery(
|
|
1354
1430
|
(pageIndex, previousPageData) => {
|
|
1355
1431
|
if (previousPageData && !previousPageData.rows?.length)
|
|
@@ -1372,9 +1448,9 @@ var useOrderStream = (params) => {
|
|
|
1372
1448
|
{
|
|
1373
1449
|
initialSize: 1,
|
|
1374
1450
|
// revalidateFirstPage: false,
|
|
1375
|
-
onError: (err) => {
|
|
1376
|
-
|
|
1377
|
-
},
|
|
1451
|
+
// onError: (err) => {
|
|
1452
|
+
// console.error("fetch failed::::", err);
|
|
1453
|
+
// },
|
|
1378
1454
|
formatter: (data) => data
|
|
1379
1455
|
}
|
|
1380
1456
|
);
|
|
@@ -1391,68 +1467,7 @@ var useOrderStream = (params) => {
|
|
|
1391
1467
|
}, [ordersResponse.data, markPrices]);
|
|
1392
1468
|
const total = useMemo(() => {
|
|
1393
1469
|
return ordersResponse.data?.[0]?.meta?.total || 0;
|
|
1394
|
-
}, [ordersResponse.data]);
|
|
1395
|
-
useEffect(() => {
|
|
1396
|
-
const unsubscribe = ws.privateSubscribe(
|
|
1397
|
-
{
|
|
1398
|
-
id: "executionreport_orders",
|
|
1399
|
-
event: "subscribe",
|
|
1400
|
-
topic: "executionreport",
|
|
1401
|
-
ts: Date.now()
|
|
1402
|
-
},
|
|
1403
|
-
{
|
|
1404
|
-
onMessage: (data) => {
|
|
1405
|
-
const { status: status2, orderId, timestamp } = data;
|
|
1406
|
-
ordersResponse.mutate((prevData) => {
|
|
1407
|
-
const newOrder = {
|
|
1408
|
-
order_id: data.orderId,
|
|
1409
|
-
symbol: data.symbol,
|
|
1410
|
-
created_time: data.timestamp,
|
|
1411
|
-
quantity: data.quantity,
|
|
1412
|
-
side: data.side,
|
|
1413
|
-
executed: data.totalExecutedQuantity,
|
|
1414
|
-
price: data.price
|
|
1415
|
-
};
|
|
1416
|
-
const dataList = prevData?.map((item) => item.rows)?.flat() || [];
|
|
1417
|
-
if (status2 === OrderStatus.NEW) {
|
|
1418
|
-
if (!prevData) {
|
|
1419
|
-
return {
|
|
1420
|
-
meta: {
|
|
1421
|
-
total: 1,
|
|
1422
|
-
records_per_page: size,
|
|
1423
|
-
current_page: 1
|
|
1424
|
-
},
|
|
1425
|
-
rows: [newOrder]
|
|
1426
|
-
};
|
|
1427
|
-
}
|
|
1428
|
-
const total2 = (prevData?.[0]?.meta?.total || 0) + 1;
|
|
1429
|
-
const isNew = !dataList.find((item) => item.order_id === orderId);
|
|
1430
|
-
if (isNew) {
|
|
1431
|
-
const list = [newOrder, ...dataList];
|
|
1432
|
-
return rePageData(list, total2, size);
|
|
1433
|
-
}
|
|
1434
|
-
return prevData;
|
|
1435
|
-
}
|
|
1436
|
-
if (status2 === OrderStatus.CANCELLED || status2 === OrderStatus.FILLED) {
|
|
1437
|
-
const total2 = (prevData?.[0]?.meta?.total || 0) - 1;
|
|
1438
|
-
const list = dataList.filter(
|
|
1439
|
-
(order2) => order2.order_id !== orderId
|
|
1440
|
-
);
|
|
1441
|
-
return rePageData(list, total2, size);
|
|
1442
|
-
}
|
|
1443
|
-
if (status2 === OrderStatus.PARTIAL_FILLED) {
|
|
1444
|
-
return editPageData(dataList, newOrder);
|
|
1445
|
-
}
|
|
1446
|
-
if (status2 === OrderStatus.REPLACED) {
|
|
1447
|
-
return editPageData(dataList, newOrder);
|
|
1448
|
-
}
|
|
1449
|
-
return prevData;
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
);
|
|
1454
|
-
return () => unsubscribe();
|
|
1455
|
-
}, []);
|
|
1470
|
+
}, [ordersResponse.data?.[0]?.meta?.total]);
|
|
1456
1471
|
const cancelAllOrders = useCallback(() => {
|
|
1457
1472
|
}, [ordersResponse.data]);
|
|
1458
1473
|
const updateOrder = useCallback((orderId, order2) => {
|
|
@@ -1479,44 +1494,14 @@ var useOrderStream = (params) => {
|
|
|
1479
1494
|
loadMore,
|
|
1480
1495
|
cancelAllOrders,
|
|
1481
1496
|
updateOrder,
|
|
1482
|
-
cancelOrder
|
|
1497
|
+
cancelOrder,
|
|
1498
|
+
errors: {
|
|
1499
|
+
cancelOrder: cancelOrderError,
|
|
1500
|
+
updateOrder: updateOrderError
|
|
1501
|
+
}
|
|
1483
1502
|
}
|
|
1484
1503
|
];
|
|
1485
1504
|
};
|
|
1486
|
-
function rePageData(list, total, pageSize) {
|
|
1487
|
-
const newData = [];
|
|
1488
|
-
let rows = [];
|
|
1489
|
-
let current_page = 0;
|
|
1490
|
-
for (let i = 0; i < list.length; i++) {
|
|
1491
|
-
rows.push(list[i]);
|
|
1492
|
-
if ((i + 1) % pageSize === 0 || i === list.length - 1) {
|
|
1493
|
-
newData.push({
|
|
1494
|
-
meta: {
|
|
1495
|
-
records_per_page: pageSize,
|
|
1496
|
-
total,
|
|
1497
|
-
current_page: current_page + 1
|
|
1498
|
-
},
|
|
1499
|
-
rows: [...rows]
|
|
1500
|
-
});
|
|
1501
|
-
rows = [];
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
return newData;
|
|
1505
|
-
}
|
|
1506
|
-
function editPageData(list, newOrder) {
|
|
1507
|
-
const newData = list.map((item) => {
|
|
1508
|
-
return {
|
|
1509
|
-
...item,
|
|
1510
|
-
rows: item.rows.map((row) => {
|
|
1511
|
-
if (row.order_id === newOrder.order_id) {
|
|
1512
|
-
return { ...row, newOrder };
|
|
1513
|
-
}
|
|
1514
|
-
return row;
|
|
1515
|
-
})
|
|
1516
|
-
};
|
|
1517
|
-
});
|
|
1518
|
-
return newData;
|
|
1519
|
-
}
|
|
1520
1505
|
|
|
1521
1506
|
// src/orderly/useCollateral.ts
|
|
1522
1507
|
var positionsPath = pathOr([], [0, "rows"]);
|
|
@@ -1575,33 +1560,7 @@ var useMaxQty = (symbol, side, reduceOnly = false) => {
|
|
|
1575
1560
|
const symbolInfo = useSymbolsInfo();
|
|
1576
1561
|
const { totalCollateral } = useCollateral();
|
|
1577
1562
|
const { data: markPrices } = useMarkPricesStream();
|
|
1578
|
-
const {
|
|
1579
|
-
data: orders,
|
|
1580
|
-
error,
|
|
1581
|
-
mutate: updateOrder
|
|
1582
|
-
} = usePrivateQuery(`/v1/orders?status=NEW&size=99`, {
|
|
1583
|
-
formatter: (data) => data.rows,
|
|
1584
|
-
onError: (err) => {
|
|
1585
|
-
}
|
|
1586
|
-
});
|
|
1587
|
-
const ws = useWS();
|
|
1588
|
-
useEffect(() => {
|
|
1589
|
-
const unsubscribe = ws.privateSubscribe(
|
|
1590
|
-
{
|
|
1591
|
-
id: "executionreport_orders",
|
|
1592
|
-
event: "subscribe",
|
|
1593
|
-
topic: "executionreport",
|
|
1594
|
-
ts: Date.now()
|
|
1595
|
-
},
|
|
1596
|
-
{
|
|
1597
|
-
onMessage: (data) => {
|
|
1598
|
-
console.log("refresh orders", data);
|
|
1599
|
-
updateOrder();
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
);
|
|
1603
|
-
return () => unsubscribe();
|
|
1604
|
-
}, []);
|
|
1563
|
+
const [orders] = useOrderStream({ status: OrderStatus.NEW });
|
|
1605
1564
|
const maxQty = useMemo(() => {
|
|
1606
1565
|
if (!symbol)
|
|
1607
1566
|
return 0;
|
|
@@ -3634,59 +3593,6 @@ var useSettleSubscription = (options) => {
|
|
|
3634
3593
|
return () => unsubscribe();
|
|
3635
3594
|
});
|
|
3636
3595
|
};
|
|
3637
|
-
var usePrivateDataObserver = () => {
|
|
3638
|
-
const ws = useWS();
|
|
3639
|
-
const { mutate: mutate2 } = useSWRConfig();
|
|
3640
|
-
const { state } = useAccount();
|
|
3641
|
-
useEffect(() => {
|
|
3642
|
-
if (!state.accountId)
|
|
3643
|
-
return;
|
|
3644
|
-
const key = ["/v1/positions", state.accountId];
|
|
3645
|
-
const unsubscribe = ws.privateSubscribe("position", {
|
|
3646
|
-
onMessage: (data) => {
|
|
3647
|
-
const { positions: nextPostions } = data;
|
|
3648
|
-
mutate2(key, (prevPositions) => {
|
|
3649
|
-
if (!!prevPositions) {
|
|
3650
|
-
return {
|
|
3651
|
-
...prevPositions,
|
|
3652
|
-
rows: prevPositions.rows.map((row) => {
|
|
3653
|
-
const item = nextPostions.find(
|
|
3654
|
-
(item2) => item2.symbol === row.symbol
|
|
3655
|
-
);
|
|
3656
|
-
if (item) {
|
|
3657
|
-
return {
|
|
3658
|
-
symbol: item.symbol,
|
|
3659
|
-
position_qty: item.positionQty,
|
|
3660
|
-
cost_position: item.costPosition,
|
|
3661
|
-
last_sum_unitary_funding: item.lastSumUnitaryFunding,
|
|
3662
|
-
pending_long_qty: item.pendingLongQty,
|
|
3663
|
-
pending_short_qty: item.pendingShortQty,
|
|
3664
|
-
settle_price: item.settlePrice,
|
|
3665
|
-
average_open_price: item.averageOpenPrice,
|
|
3666
|
-
unsettled_pnl: item.unsettledPnl,
|
|
3667
|
-
mark_price: item.markPrice,
|
|
3668
|
-
est_liq_price: item.estLiqPrice,
|
|
3669
|
-
timestamp: Date.now(),
|
|
3670
|
-
imr: item.imr,
|
|
3671
|
-
mmr: item.mmr,
|
|
3672
|
-
IMR_withdraw_orders: item.imrwithOrders,
|
|
3673
|
-
MMR_with_orders: item.mmrwithOrders,
|
|
3674
|
-
pnl_24_h: item.pnl24H,
|
|
3675
|
-
fee_24_h: item.fee24H
|
|
3676
|
-
};
|
|
3677
|
-
}
|
|
3678
|
-
return row;
|
|
3679
|
-
})
|
|
3680
|
-
};
|
|
3681
|
-
}
|
|
3682
|
-
});
|
|
3683
|
-
}
|
|
3684
|
-
});
|
|
3685
|
-
return () => {
|
|
3686
|
-
unsubscribe?.();
|
|
3687
|
-
};
|
|
3688
|
-
}, [state.accountId]);
|
|
3689
|
-
};
|
|
3690
3596
|
var useWooSwapQuery = () => {
|
|
3691
3597
|
const { configStore } = useContext(OrderlyContext);
|
|
3692
3598
|
const account5 = useAccountInstance();
|