@orderly.network/ui-positions 2.8.10-alpha.0 → 2.8.11-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.js +65 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -82
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -284,8 +284,7 @@ var FundingFeeHistoryUI = ({ total, symbol, start_t, end_t }) => {
|
|
|
284
284
|
});
|
|
285
285
|
}, [setSize]);
|
|
286
286
|
const flattenData = React2.useMemo(() => {
|
|
287
|
-
if (!Array.isArray(data))
|
|
288
|
-
return [];
|
|
287
|
+
if (!Array.isArray(data)) return [];
|
|
289
288
|
return data.flat().map((item) => {
|
|
290
289
|
return {
|
|
291
290
|
...item,
|
|
@@ -369,7 +368,7 @@ var FundingFeeLabelButton = ({ label, tooltip, size }) => {
|
|
|
369
368
|
const { t } = i18n.useTranslation();
|
|
370
369
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-1", children: [
|
|
371
370
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
372
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
371
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
373
372
|
"button",
|
|
374
373
|
{
|
|
375
374
|
className: "oui-flex oui-items-center",
|
|
@@ -390,14 +389,10 @@ var FundingFeeLabelButton = ({ label, tooltip, size }) => {
|
|
|
390
389
|
)
|
|
391
390
|
] });
|
|
392
391
|
};
|
|
393
|
-
var FundingFeeLabel = ({
|
|
394
|
-
label,
|
|
395
|
-
tooltip,
|
|
396
|
-
size
|
|
397
|
-
}) => {
|
|
392
|
+
var FundingFeeLabel = ({ label, tooltip, size }) => {
|
|
398
393
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-items-center oui-gap-1", children: [
|
|
399
394
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
400
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-w-64", children: tooltip }), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
395
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { content: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-w-64", children: tooltip }), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
401
396
|
ui.ExclamationFillIcon,
|
|
402
397
|
{
|
|
403
398
|
className: "oui-cursor-pointer oui-text-base-contrast-54",
|
|
@@ -419,14 +414,7 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
|
|
|
419
414
|
}
|
|
420
415
|
},
|
|
421
416
|
{
|
|
422
|
-
title: /* @__PURE__ */ jsxRuntime.jsx(
|
|
423
|
-
FundingFeeLabel,
|
|
424
|
-
{
|
|
425
|
-
label: t("funding.fundingRate"),
|
|
426
|
-
tooltip: t("positions.fundingRate.tooltip"),
|
|
427
|
-
size: 12
|
|
428
|
-
}
|
|
429
|
-
),
|
|
417
|
+
title: /* @__PURE__ */ jsxRuntime.jsx(FundingFeeLabel, { label: t("funding.fundingRate"), size: 12 }),
|
|
430
418
|
dataIndex: "funding_rate",
|
|
431
419
|
formatter: (value) => new utils.Decimal(value).mul(100).toString(),
|
|
432
420
|
render: (value) => {
|
|
@@ -442,7 +430,14 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
|
|
|
442
430
|
render: (value) => /* @__PURE__ */ jsxRuntime.jsx("span", { children: value })
|
|
443
431
|
},
|
|
444
432
|
{
|
|
445
|
-
title:
|
|
433
|
+
title: /* @__PURE__ */ jsxRuntime.jsx(
|
|
434
|
+
FundingFeeLabel,
|
|
435
|
+
{
|
|
436
|
+
label: t("common.amount"),
|
|
437
|
+
tooltip: t("positions.fundingRate.tooltip"),
|
|
438
|
+
size: 12
|
|
439
|
+
}
|
|
440
|
+
),
|
|
446
441
|
dataIndex: "funding_fee",
|
|
447
442
|
render: (value) => {
|
|
448
443
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text.numeral, { rule: "price", coloring: true, showIdentifier: true, ignoreDP: true, children: value });
|
|
@@ -488,29 +483,30 @@ var FundingFeeItem = ({ item }) => {
|
|
|
488
483
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
489
484
|
ui.Statistic,
|
|
490
485
|
{
|
|
491
|
-
label: /* @__PURE__ */ jsxRuntime.jsx(
|
|
492
|
-
FundingFeeLabelButton,
|
|
493
|
-
{
|
|
494
|
-
label: t("funding.fundingRate"),
|
|
495
|
-
tooltip: t("positions.fundingRate.tooltip"),
|
|
496
|
-
size: 12
|
|
497
|
-
}
|
|
498
|
-
),
|
|
486
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(FundingFeeLabelButton, { label: t("funding.fundingRate"), size: 12 }),
|
|
499
487
|
classNames: {
|
|
500
488
|
label: "oui-text-2xs"
|
|
501
489
|
},
|
|
502
490
|
valueProps: {
|
|
503
491
|
ignoreDP: true,
|
|
504
|
-
|
|
505
|
-
className: "oui-text-xs"
|
|
492
|
+
as: "div",
|
|
493
|
+
className: "oui-text-xs",
|
|
494
|
+
suffix: "%"
|
|
506
495
|
},
|
|
507
|
-
children: item.funding_rate
|
|
496
|
+
children: new utils.Decimal(item.funding_rate).mul(100).toNumber()
|
|
508
497
|
}
|
|
509
498
|
),
|
|
510
499
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
511
500
|
ui.Statistic,
|
|
512
501
|
{
|
|
513
|
-
label:
|
|
502
|
+
label: /* @__PURE__ */ jsxRuntime.jsx(
|
|
503
|
+
FundingFeeLabelButton,
|
|
504
|
+
{
|
|
505
|
+
label: t("common.amount"),
|
|
506
|
+
tooltip: t("positions.fundingRate.tooltip"),
|
|
507
|
+
size: 12
|
|
508
|
+
}
|
|
509
|
+
),
|
|
514
510
|
className: "oui-items-end",
|
|
515
511
|
classNames: {
|
|
516
512
|
label: "oui-text-2xs"
|
|
@@ -903,12 +899,9 @@ var groupDataByAccount = (data, options) => {
|
|
|
903
899
|
var TRADING_POSITIONS_SORT_STORAGE_KEY = "orderly_trading_positions_sort";
|
|
904
900
|
var LIQ_DISTANCE_THRESHOLD = 10;
|
|
905
901
|
var compareValues = (aValue, bValue) => {
|
|
906
|
-
if (aValue == null && bValue == null)
|
|
907
|
-
|
|
908
|
-
if (
|
|
909
|
-
return 1;
|
|
910
|
-
if (bValue == null)
|
|
911
|
-
return -1;
|
|
902
|
+
if (aValue == null && bValue == null) return 0;
|
|
903
|
+
if (aValue == null) return 1;
|
|
904
|
+
if (bValue == null) return -1;
|
|
912
905
|
const aStr = String(aValue).trim();
|
|
913
906
|
const bStr = String(bValue).trim();
|
|
914
907
|
const aNum = Number(aStr);
|
|
@@ -1231,42 +1224,35 @@ var useReversePositionScript = (options) => {
|
|
|
1231
1224
|
});
|
|
1232
1225
|
const rawPositionRows = reactApp.useDataTap(positionData?.rows, { fallbackData: [] });
|
|
1233
1226
|
const unrealizedPnL = React2.useMemo(() => {
|
|
1234
|
-
if (!rawPositionRows || !symbol)
|
|
1235
|
-
return position?.unrealized_pnl;
|
|
1227
|
+
if (!rawPositionRows || !symbol) return position?.unrealized_pnl;
|
|
1236
1228
|
const currentPosition = rawPositionRows.find(
|
|
1237
1229
|
(p) => p.symbol === symbol && p.position_qty !== 0
|
|
1238
1230
|
);
|
|
1239
1231
|
return currentPosition?.unrealized_pnl ?? position?.unrealized_pnl;
|
|
1240
1232
|
}, [rawPositionRows, symbol]);
|
|
1241
1233
|
const baseMin = React2.useMemo(() => {
|
|
1242
|
-
if (!symbolInfo)
|
|
1243
|
-
return 0;
|
|
1234
|
+
if (!symbolInfo) return 0;
|
|
1244
1235
|
return symbolInfo("base_min") || 0;
|
|
1245
1236
|
}, [symbolInfo]);
|
|
1246
1237
|
const baseMax = React2.useMemo(() => {
|
|
1247
|
-
if (!symbolInfo)
|
|
1248
|
-
return 0;
|
|
1238
|
+
if (!symbolInfo) return 0;
|
|
1249
1239
|
return symbolInfo("base_max") || 0;
|
|
1250
1240
|
}, [symbolInfo]);
|
|
1251
1241
|
const baseDp = React2.useMemo(() => {
|
|
1252
|
-
if (!symbolInfo)
|
|
1253
|
-
return 6;
|
|
1242
|
+
if (!symbolInfo) return 6;
|
|
1254
1243
|
return symbolInfo("base_dp") || 6;
|
|
1255
1244
|
}, [symbolInfo]);
|
|
1256
1245
|
const positionQty = React2.useMemo(() => {
|
|
1257
|
-
if (!position)
|
|
1258
|
-
return 0;
|
|
1246
|
+
if (!position) return 0;
|
|
1259
1247
|
return Math.abs(position.position_qty);
|
|
1260
1248
|
}, [position]);
|
|
1261
1249
|
const isLong = React2.useMemo(() => {
|
|
1262
|
-
if (!position)
|
|
1263
|
-
return false;
|
|
1250
|
+
if (!position) return false;
|
|
1264
1251
|
return position.position_qty > 0;
|
|
1265
1252
|
}, [position]);
|
|
1266
1253
|
const reverseQty = positionQty;
|
|
1267
1254
|
const validationError = React2.useMemo(() => {
|
|
1268
|
-
if (!position || !symbolInfo)
|
|
1269
|
-
return null;
|
|
1255
|
+
if (!position || !symbolInfo) return null;
|
|
1270
1256
|
if (baseMin > 0 && reverseQty < baseMin) {
|
|
1271
1257
|
return "belowMin";
|
|
1272
1258
|
}
|
|
@@ -2342,8 +2328,7 @@ var PartialTPSL = (props) => {
|
|
|
2342
2328
|
});
|
|
2343
2329
|
const child = React2.useMemo(() => {
|
|
2344
2330
|
const children = [];
|
|
2345
|
-
if (!order?.symbol)
|
|
2346
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { positionType: types.PositionType.PARTIAL });
|
|
2331
|
+
if (!order?.symbol) return /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { positionType: types.PositionType.PARTIAL });
|
|
2347
2332
|
if (tpTriggerPrice) {
|
|
2348
2333
|
children.push(
|
|
2349
2334
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2587,8 +2572,7 @@ var TPSLTriggerPrice = (props) => {
|
|
|
2587
2572
|
const { t } = i18n.useTranslation();
|
|
2588
2573
|
const pnl = React2.useMemo(() => {
|
|
2589
2574
|
const msgs = [];
|
|
2590
|
-
if (!props.tooltip || !order || !position)
|
|
2591
|
-
return;
|
|
2575
|
+
if (!props.tooltip || !order || !position) return;
|
|
2592
2576
|
let quantity = order.quantity;
|
|
2593
2577
|
if (quantity === 0) {
|
|
2594
2578
|
if (order.child_orders[0].type === "CLOSE_POSITION") {
|
|
@@ -2638,8 +2622,7 @@ var TPSLTriggerPrice = (props) => {
|
|
|
2638
2622
|
]);
|
|
2639
2623
|
const child = React2.useMemo(() => {
|
|
2640
2624
|
const children = [];
|
|
2641
|
-
if (!order?.symbol)
|
|
2642
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { positionType: types.PositionType.FULL });
|
|
2625
|
+
if (!order?.symbol) return /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { positionType: types.PositionType.FULL });
|
|
2643
2626
|
if (props.takeProfitPrice) {
|
|
2644
2627
|
children.push(
|
|
2645
2628
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2930,7 +2913,19 @@ var useColumn = (config) => {
|
|
|
2930
2913
|
ui.Tooltip,
|
|
2931
2914
|
{
|
|
2932
2915
|
className: "oui-max-w-[280px] oui-bg-base-8 oui-p-3 oui-text-2xs oui-text-base-contrast-54",
|
|
2933
|
-
content:
|
|
2916
|
+
content: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2917
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-pretty", children: t("common.liquidationPrice.tooltip") }),
|
|
2918
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2919
|
+
"a",
|
|
2920
|
+
{
|
|
2921
|
+
href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/liquidations",
|
|
2922
|
+
target: "_blank",
|
|
2923
|
+
rel: "noopener noreferrer",
|
|
2924
|
+
className: "oui-text-primary oui-underline",
|
|
2925
|
+
children: t("common.liquidationPrice.tooltip.learnMore")
|
|
2926
|
+
}
|
|
2927
|
+
) })
|
|
2928
|
+
] }),
|
|
2934
2929
|
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: t("positions.column.liqPrice") })
|
|
2935
2930
|
}
|
|
2936
2931
|
),
|
|
@@ -3279,10 +3274,8 @@ var LiqPrice = (props) => {
|
|
|
3279
3274
|
const liqPrice = React2.useMemo(() => {
|
|
3280
3275
|
const estLiqPrice = item.est_liq_price;
|
|
3281
3276
|
const markPrice = item.mark_price;
|
|
3282
|
-
if (!estLiqPrice || estLiqPrice <= 0)
|
|
3283
|
-
|
|
3284
|
-
if (!markPrice || markPrice === 0)
|
|
3285
|
-
return "-";
|
|
3277
|
+
if (!estLiqPrice || estLiqPrice <= 0) return "-";
|
|
3278
|
+
if (!markPrice || markPrice === 0) return "-";
|
|
3286
3279
|
if (Math.abs(estLiqPrice - markPrice) / markPrice >= LIQ_DISTANCE_THRESHOLD) {
|
|
3287
3280
|
return "-";
|
|
3288
3281
|
}
|
|
@@ -3752,8 +3745,7 @@ var usePositionHistoryColumn = (props) => {
|
|
|
3752
3745
|
dataIndex: "netPnL",
|
|
3753
3746
|
width: 140,
|
|
3754
3747
|
onSort: (a, b) => {
|
|
3755
|
-
if (a.netPnL == null || b.netPnL == null)
|
|
3756
|
-
return -1;
|
|
3748
|
+
if (a.netPnL == null || b.netPnL == null) return -1;
|
|
3757
3749
|
return (a.netPnL ?? 0) - (b.netPnL ?? 0);
|
|
3758
3750
|
},
|
|
3759
3751
|
render: (_, record) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gapX: 1, children: [
|
|
@@ -3997,8 +3989,7 @@ var NetPnL = (props) => {
|
|
|
3997
3989
|
children: netPnl ?? "--"
|
|
3998
3990
|
}
|
|
3999
3991
|
);
|
|
4000
|
-
if (record.netPnL == null)
|
|
4001
|
-
return text();
|
|
3992
|
+
if (record.netPnL == null) return text();
|
|
4002
3993
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4003
3994
|
ui.Tooltip,
|
|
4004
3995
|
{
|
|
@@ -4056,15 +4047,13 @@ var LeverageDisplay2 = ({ symbol }) => {
|
|
|
4056
4047
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text.numeral, { dp: 0, size: "2xs", unit: "X", children: leverage });
|
|
4057
4048
|
};
|
|
4058
4049
|
function offsetStartOfDay(date) {
|
|
4059
|
-
if (date == null)
|
|
4060
|
-
return date;
|
|
4050
|
+
if (date == null) return date;
|
|
4061
4051
|
const newDate = new Date(date);
|
|
4062
4052
|
newDate.setHours(0, 0, 0, 0);
|
|
4063
4053
|
return newDate;
|
|
4064
4054
|
}
|
|
4065
4055
|
function offsetEndOfDay(date) {
|
|
4066
|
-
if (date == null)
|
|
4067
|
-
return date;
|
|
4056
|
+
if (date == null) return date;
|
|
4068
4057
|
const newDate = new Date(date);
|
|
4069
4058
|
newDate.setHours(23, 59, 59, 999);
|
|
4070
4059
|
return newDate;
|
|
@@ -4129,8 +4118,7 @@ var usePositionHistoryScript = (props) => {
|
|
|
4129
4118
|
setPage(1);
|
|
4130
4119
|
}, [status, side, dateRange, filterDays, symbol]);
|
|
4131
4120
|
const filterData = React2.useMemo(() => {
|
|
4132
|
-
if (data == null)
|
|
4133
|
-
return data;
|
|
4121
|
+
if (data == null) return data;
|
|
4134
4122
|
return data.filter((item) => {
|
|
4135
4123
|
const sideFilter = side === "all" /* all */ ? true : item.side.toLowerCase() === side.toLowerCase();
|
|
4136
4124
|
const statusFilter = status === "all" /* all */ ? true : item.position_status.toLowerCase() === status.toLowerCase();
|
|
@@ -5031,12 +5019,10 @@ var Body2 = (props) => {
|
|
|
5031
5019
|
const position = props.item.positions_by_perp?.[0];
|
|
5032
5020
|
const { t } = i18n.useTranslation();
|
|
5033
5021
|
const mr = React2.useMemo(() => {
|
|
5034
|
-
if (isNaN(props.item?.margin_ratio))
|
|
5035
|
-
return "--";
|
|
5022
|
+
if (isNaN(props.item?.margin_ratio)) return "--";
|
|
5036
5023
|
return `${new utils.Decimal(props.item.margin_ratio).mul(100).todp(2, utils.Decimal.ROUND_DOWN).toNumber()}%`;
|
|
5037
5024
|
}, [props.item?.margin_ratio]);
|
|
5038
|
-
if (!position)
|
|
5039
|
-
return null;
|
|
5025
|
+
if (!position) return null;
|
|
5040
5026
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", width: "100%", gap: 1, children: [
|
|
5041
5027
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, width: "100%", children: [
|
|
5042
5028
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5439,8 +5425,7 @@ var useFilter2 = () => {
|
|
|
5439
5425
|
};
|
|
5440
5426
|
};
|
|
5441
5427
|
var generateKeyFun = (args) => (pageIndex, previousPageData) => {
|
|
5442
|
-
if (previousPageData && !previousPageData.rows?.length)
|
|
5443
|
-
return null;
|
|
5428
|
+
if (previousPageData && !previousPageData.rows?.length) return null;
|
|
5444
5429
|
const { symbol, size = 10, page, end_t, start_t } = args;
|
|
5445
5430
|
const search = new URLSearchParams([
|
|
5446
5431
|
["size", size.toString()],
|
|
@@ -5496,8 +5481,7 @@ var useCloseAllPositionsScript = (options) => {
|
|
|
5496
5481
|
const { tracking } = hooks.useTrack();
|
|
5497
5482
|
const [positionsData] = hooks.usePositionStream(symbol);
|
|
5498
5483
|
const openPositions = React2.useMemo(() => {
|
|
5499
|
-
if (!positionsData?.rows)
|
|
5500
|
-
return [];
|
|
5484
|
+
if (!positionsData?.rows) return [];
|
|
5501
5485
|
return positionsData.rows.filter(
|
|
5502
5486
|
(position) => position.position_qty !== 0 && position.position_qty !== void 0
|
|
5503
5487
|
);
|
|
@@ -5510,8 +5494,7 @@ var useCloseAllPositionsScript = (options) => {
|
|
|
5510
5494
|
"POST"
|
|
5511
5495
|
);
|
|
5512
5496
|
const closeAllPositions = React2.useCallback(async () => {
|
|
5513
|
-
if (!hasOpenPositions)
|
|
5514
|
-
return;
|
|
5497
|
+
if (!hasOpenPositions) return;
|
|
5515
5498
|
try {
|
|
5516
5499
|
const closePromises = openPositions.map(
|
|
5517
5500
|
(position) => {
|
|
@@ -5607,5 +5590,5 @@ exports.useReversePositionEnabled = useReversePositionEnabled;
|
|
|
5607
5590
|
exports.useReversePositionScript = useReversePositionScript;
|
|
5608
5591
|
exports.useSort = useSort;
|
|
5609
5592
|
exports.useTabSort = useTabSort;
|
|
5610
|
-
//# sourceMappingURL=
|
|
5593
|
+
//# sourceMappingURL=index.js.map
|
|
5611
5594
|
//# sourceMappingURL=index.js.map
|