@orderly.network/ui-positions 2.8.9 → 2.8.10-alpha.0
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 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +77 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { i18n, useTranslation } from '@orderly.network/i18n';
|
|
|
4
4
|
import { OrderSide, OrderType, EMPTY_LIST, AccountStatusEnum, TrackerEventName, OrderStatus, AlgoOrderRootType, PositionType, AlgoOrderType } from '@orderly.network/types';
|
|
5
5
|
import { commifyOptional, Decimal, formatNum, getTimestamp, commify } from '@orderly.network/utils';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { useSymbolsInfo, useMarkPrice,
|
|
7
|
+
import { useLocalStorage, useSymbolsInfo, useMarkPrice, usePositionStream, useSubAccountMutation, usePrivateInfiniteQuery, useBoolean, useSessionStorage, useAccount, usePrivateQuery, useTrack, usePositionClose, useSWR, fetcher, useEventEmitter, useDebouncedCallback, useGetRwaSymbolOpenStatus, useTpslPriceChecker, useConfig, findPositionTPSLFromOrders, findTPSLFromOrder, useReferralInfo, useAccountInfo, useLeverageBySymbol, utils, useMaxLeverage } from '@orderly.network/hooks';
|
|
8
8
|
import { useDataTap, useOrderEntryFormErrorMsg } from '@orderly.network/react-app';
|
|
9
9
|
import { positions, account } from '@orderly.network/perp';
|
|
10
10
|
import { AuthGuardDataTable } from '@orderly.network/ui-connector';
|
|
@@ -895,6 +895,7 @@ var groupDataByAccount = (data, options) => {
|
|
|
895
895
|
|
|
896
896
|
// src/constants.ts
|
|
897
897
|
var TRADING_POSITIONS_SORT_STORAGE_KEY = "orderly_trading_positions_sort";
|
|
898
|
+
var LIQ_DISTANCE_THRESHOLD = 10;
|
|
898
899
|
var compareValues = (aValue, bValue) => {
|
|
899
900
|
if (aValue == null && bValue == null)
|
|
900
901
|
return 0;
|
|
@@ -963,6 +964,8 @@ var OrderInfoCard = ({
|
|
|
963
964
|
qty,
|
|
964
965
|
baseDp,
|
|
965
966
|
estLiqPrice,
|
|
967
|
+
estPnL,
|
|
968
|
+
pnlNotionalDecimalPrecision = 2,
|
|
966
969
|
className
|
|
967
970
|
}) => {
|
|
968
971
|
const { t } = useTranslation();
|
|
@@ -991,6 +994,7 @@ var OrderInfoCard = ({
|
|
|
991
994
|
justify: "between",
|
|
992
995
|
itemAlign: "center",
|
|
993
996
|
width: "100%",
|
|
997
|
+
gap: 1,
|
|
994
998
|
children: [
|
|
995
999
|
/* @__PURE__ */ jsxs(
|
|
996
1000
|
Flex,
|
|
@@ -1020,6 +1024,29 @@ var OrderInfoCard = ({
|
|
|
1020
1024
|
]
|
|
1021
1025
|
}
|
|
1022
1026
|
),
|
|
1027
|
+
estPnL && /* @__PURE__ */ jsxs(
|
|
1028
|
+
Flex,
|
|
1029
|
+
{
|
|
1030
|
+
direction: "row",
|
|
1031
|
+
justify: "between",
|
|
1032
|
+
itemAlign: "center",
|
|
1033
|
+
width: "100%",
|
|
1034
|
+
gap: 1,
|
|
1035
|
+
children: [
|
|
1036
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", intensity: 54, children: t("orderEntry.estPnL") }),
|
|
1037
|
+
/* @__PURE__ */ jsx(
|
|
1038
|
+
Text.pnl,
|
|
1039
|
+
{
|
|
1040
|
+
dp: pnlNotionalDecimalPrecision,
|
|
1041
|
+
coloring: true,
|
|
1042
|
+
size: "sm",
|
|
1043
|
+
weight: "semibold",
|
|
1044
|
+
children: estPnL
|
|
1045
|
+
}
|
|
1046
|
+
)
|
|
1047
|
+
]
|
|
1048
|
+
}
|
|
1049
|
+
),
|
|
1023
1050
|
estLiqPrice && /* @__PURE__ */ jsxs(
|
|
1024
1051
|
Flex,
|
|
1025
1052
|
{
|
|
@@ -1064,7 +1091,9 @@ var ReversePosition = (props) => {
|
|
|
1064
1091
|
reverseQty,
|
|
1065
1092
|
markPrice,
|
|
1066
1093
|
leverage,
|
|
1067
|
-
isLong
|
|
1094
|
+
isLong,
|
|
1095
|
+
unrealizedPnL,
|
|
1096
|
+
pnlNotionalDecimalPrecision
|
|
1068
1097
|
} = displayInfo;
|
|
1069
1098
|
const closeSide = !isLong ? OrderSide.SELL : OrderSide.BUY;
|
|
1070
1099
|
const openSide = isLong ? OrderSide.SELL : OrderSide.BUY;
|
|
@@ -1115,7 +1144,9 @@ var ReversePosition = (props) => {
|
|
|
1115
1144
|
side: closeSide,
|
|
1116
1145
|
leverage,
|
|
1117
1146
|
qty: positionQty,
|
|
1118
|
-
baseDp
|
|
1147
|
+
baseDp,
|
|
1148
|
+
estPnL: unrealizedPnL?.toString(),
|
|
1149
|
+
pnlNotionalDecimalPrecision
|
|
1119
1150
|
}
|
|
1120
1151
|
),
|
|
1121
1152
|
/* @__PURE__ */ jsxs(Flex, { direction: "row", itemAlign: "center", width: "100%", children: [
|
|
@@ -1179,10 +1210,28 @@ var useReversePositionEnabled = () => {
|
|
|
1179
1210
|
var useReversePositionScript = (options) => {
|
|
1180
1211
|
const { position, onSuccess, onError } = options || {};
|
|
1181
1212
|
const { isEnabled, setEnabled } = useReversePositionEnabled();
|
|
1213
|
+
const [pnlNotionalDecimalPrecision] = useLocalStorage(
|
|
1214
|
+
"pnlNotionalDecimalPrecision",
|
|
1215
|
+
2
|
|
1216
|
+
);
|
|
1182
1217
|
const symbolsInfo = useSymbolsInfo();
|
|
1183
1218
|
const symbol = position?.symbol || "";
|
|
1184
1219
|
const { data: symbolMarketPrice } = useMarkPrice(symbol);
|
|
1185
1220
|
const symbolInfo = symbolsInfo?.[symbol];
|
|
1221
|
+
const calcMode = options?.calcMode || "markPrice";
|
|
1222
|
+
const [positionData] = usePositionStream(symbol, {
|
|
1223
|
+
calcMode,
|
|
1224
|
+
includedPendingOrder: false
|
|
1225
|
+
});
|
|
1226
|
+
const rawPositionRows = useDataTap(positionData?.rows, { fallbackData: [] });
|
|
1227
|
+
const unrealizedPnL = useMemo(() => {
|
|
1228
|
+
if (!rawPositionRows || !symbol)
|
|
1229
|
+
return position?.unrealized_pnl;
|
|
1230
|
+
const currentPosition = rawPositionRows.find(
|
|
1231
|
+
(p) => p.symbol === symbol && p.position_qty !== 0
|
|
1232
|
+
);
|
|
1233
|
+
return currentPosition?.unrealized_pnl ?? position?.unrealized_pnl;
|
|
1234
|
+
}, [rawPositionRows, symbol]);
|
|
1186
1235
|
const baseMin = useMemo(() => {
|
|
1187
1236
|
if (!symbolInfo)
|
|
1188
1237
|
return 0;
|
|
@@ -1341,7 +1390,9 @@ var useReversePositionScript = (options) => {
|
|
|
1341
1390
|
reverseQty: new Decimal(reverseQty).todp(baseDp2).toString(),
|
|
1342
1391
|
markPrice: symbolMarketPrice ? new Decimal(symbolMarketPrice).todp(quoteDp).toString() : "--",
|
|
1343
1392
|
leverage,
|
|
1344
|
-
isLong
|
|
1393
|
+
isLong,
|
|
1394
|
+
unrealizedPnL,
|
|
1395
|
+
pnlNotionalDecimalPrecision
|
|
1345
1396
|
};
|
|
1346
1397
|
}, [
|
|
1347
1398
|
position,
|
|
@@ -1349,7 +1400,9 @@ var useReversePositionScript = (options) => {
|
|
|
1349
1400
|
symbolInfo,
|
|
1350
1401
|
positionQty,
|
|
1351
1402
|
reverseQty,
|
|
1352
|
-
isLong
|
|
1403
|
+
isLong,
|
|
1404
|
+
unrealizedPnL,
|
|
1405
|
+
pnlNotionalDecimalPrecision
|
|
1353
1406
|
]);
|
|
1354
1407
|
return {
|
|
1355
1408
|
isEnabled,
|
|
@@ -2878,12 +2931,17 @@ var useColumn = (config) => {
|
|
|
2878
2931
|
width: 100,
|
|
2879
2932
|
onSort: true,
|
|
2880
2933
|
dataIndex: "est_liq_price",
|
|
2881
|
-
render: (value) => {
|
|
2882
|
-
|
|
2934
|
+
render: (value, record) => {
|
|
2935
|
+
const liqPrice = Number(value);
|
|
2936
|
+
const markPrice = record.mark_price;
|
|
2937
|
+
if (liqPrice === 0 || !markPrice || markPrice === 0 || Math.abs(liqPrice - markPrice) / markPrice >= LIQ_DISTANCE_THRESHOLD) {
|
|
2938
|
+
return "--";
|
|
2939
|
+
}
|
|
2940
|
+
return /* @__PURE__ */ jsx(
|
|
2883
2941
|
NumeralWithCtx,
|
|
2884
2942
|
{
|
|
2885
2943
|
rm: Decimal.ROUND_DOWN,
|
|
2886
|
-
className:
|
|
2944
|
+
className: liqPrice > 0 ? "oui-text-warning-light" : "",
|
|
2887
2945
|
children: value ?? "--"
|
|
2888
2946
|
}
|
|
2889
2947
|
);
|
|
@@ -3212,7 +3270,18 @@ var MarkPrice = (props) => {
|
|
|
3212
3270
|
var LiqPrice = (props) => {
|
|
3213
3271
|
const { item } = props;
|
|
3214
3272
|
const { t } = useTranslation();
|
|
3215
|
-
const liqPrice =
|
|
3273
|
+
const liqPrice = useMemo(() => {
|
|
3274
|
+
const estLiqPrice = item.est_liq_price;
|
|
3275
|
+
const markPrice = item.mark_price;
|
|
3276
|
+
if (!estLiqPrice || estLiqPrice <= 0)
|
|
3277
|
+
return "-";
|
|
3278
|
+
if (!markPrice || markPrice === 0)
|
|
3279
|
+
return "-";
|
|
3280
|
+
if (Math.abs(estLiqPrice - markPrice) / markPrice >= LIQ_DISTANCE_THRESHOLD) {
|
|
3281
|
+
return "-";
|
|
3282
|
+
}
|
|
3283
|
+
return estLiqPrice;
|
|
3284
|
+
}, [item.est_liq_price, item.mark_price]);
|
|
3216
3285
|
return /* @__PURE__ */ jsx(
|
|
3217
3286
|
Statistic,
|
|
3218
3287
|
{
|