@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.mjs CHANGED
@@ -278,8 +278,7 @@ var FundingFeeHistoryUI = ({ total, symbol, start_t, end_t }) => {
278
278
  });
279
279
  }, [setSize]);
280
280
  const flattenData = useMemo(() => {
281
- if (!Array.isArray(data))
282
- return [];
281
+ if (!Array.isArray(data)) return [];
283
282
  return data.flat().map((item) => {
284
283
  return {
285
284
  ...item,
@@ -363,7 +362,7 @@ var FundingFeeLabelButton = ({ label, tooltip, size }) => {
363
362
  const { t } = useTranslation();
364
363
  return /* @__PURE__ */ jsxs("div", { className: "oui-flex oui-items-center oui-gap-1", children: [
365
364
  /* @__PURE__ */ jsx("span", { children: label }),
366
- /* @__PURE__ */ jsx(
365
+ tooltip && /* @__PURE__ */ jsx(
367
366
  "button",
368
367
  {
369
368
  className: "oui-flex oui-items-center",
@@ -384,14 +383,10 @@ var FundingFeeLabelButton = ({ label, tooltip, size }) => {
384
383
  )
385
384
  ] });
386
385
  };
387
- var FundingFeeLabel = ({
388
- label,
389
- tooltip,
390
- size
391
- }) => {
386
+ var FundingFeeLabel = ({ label, tooltip, size }) => {
392
387
  return /* @__PURE__ */ jsxs("div", { className: "oui-flex oui-items-center oui-gap-1", children: [
393
388
  /* @__PURE__ */ jsx("span", { children: label }),
394
- /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx("div", { className: "oui-w-64", children: tooltip }), children: /* @__PURE__ */ jsx(
389
+ tooltip && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx("div", { className: "oui-w-64", children: tooltip }), children: /* @__PURE__ */ jsx(
395
390
  ExclamationFillIcon,
396
391
  {
397
392
  className: "oui-cursor-pointer oui-text-base-contrast-54",
@@ -413,14 +408,7 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
413
408
  }
414
409
  },
415
410
  {
416
- title: /* @__PURE__ */ jsx(
417
- FundingFeeLabel,
418
- {
419
- label: t("funding.fundingRate"),
420
- tooltip: t("positions.fundingRate.tooltip"),
421
- size: 12
422
- }
423
- ),
411
+ title: /* @__PURE__ */ jsx(FundingFeeLabel, { label: t("funding.fundingRate"), size: 12 }),
424
412
  dataIndex: "funding_rate",
425
413
  formatter: (value) => new Decimal(value).mul(100).toString(),
426
414
  render: (value) => {
@@ -436,7 +424,14 @@ var HistoryDataListView = ({ isLoading, data, loadMore }) => {
436
424
  render: (value) => /* @__PURE__ */ jsx("span", { children: value })
437
425
  },
438
426
  {
439
- title: `${t("funding.fundingFee")} (USDC)`,
427
+ title: /* @__PURE__ */ jsx(
428
+ FundingFeeLabel,
429
+ {
430
+ label: t("common.amount"),
431
+ tooltip: t("positions.fundingRate.tooltip"),
432
+ size: 12
433
+ }
434
+ ),
440
435
  dataIndex: "funding_fee",
441
436
  render: (value) => {
442
437
  return /* @__PURE__ */ jsx(Text.numeral, { rule: "price", coloring: true, showIdentifier: true, ignoreDP: true, children: value });
@@ -482,29 +477,30 @@ var FundingFeeItem = ({ item }) => {
482
477
  /* @__PURE__ */ jsx(
483
478
  Statistic,
484
479
  {
485
- label: /* @__PURE__ */ jsx(
486
- FundingFeeLabelButton,
487
- {
488
- label: t("funding.fundingRate"),
489
- tooltip: t("positions.fundingRate.tooltip"),
490
- size: 12
491
- }
492
- ),
480
+ label: /* @__PURE__ */ jsx(FundingFeeLabelButton, { label: t("funding.fundingRate"), size: 12 }),
493
481
  classNames: {
494
482
  label: "oui-text-2xs"
495
483
  },
496
484
  valueProps: {
497
485
  ignoreDP: true,
498
- rule: "percentages",
499
- className: "oui-text-xs"
486
+ as: "div",
487
+ className: "oui-text-xs",
488
+ suffix: "%"
500
489
  },
501
- children: item.funding_rate
490
+ children: new Decimal(item.funding_rate).mul(100).toNumber()
502
491
  }
503
492
  ),
504
493
  /* @__PURE__ */ jsx(
505
494
  Statistic,
506
495
  {
507
- label: t("common.amount"),
496
+ label: /* @__PURE__ */ jsx(
497
+ FundingFeeLabelButton,
498
+ {
499
+ label: t("common.amount"),
500
+ tooltip: t("positions.fundingRate.tooltip"),
501
+ size: 12
502
+ }
503
+ ),
508
504
  className: "oui-items-end",
509
505
  classNames: {
510
506
  label: "oui-text-2xs"
@@ -897,12 +893,9 @@ var groupDataByAccount = (data, options) => {
897
893
  var TRADING_POSITIONS_SORT_STORAGE_KEY = "orderly_trading_positions_sort";
898
894
  var LIQ_DISTANCE_THRESHOLD = 10;
899
895
  var compareValues = (aValue, bValue) => {
900
- if (aValue == null && bValue == null)
901
- return 0;
902
- if (aValue == null)
903
- return 1;
904
- if (bValue == null)
905
- return -1;
896
+ if (aValue == null && bValue == null) return 0;
897
+ if (aValue == null) return 1;
898
+ if (bValue == null) return -1;
906
899
  const aStr = String(aValue).trim();
907
900
  const bStr = String(bValue).trim();
908
901
  const aNum = Number(aStr);
@@ -1225,42 +1218,35 @@ var useReversePositionScript = (options) => {
1225
1218
  });
1226
1219
  const rawPositionRows = useDataTap(positionData?.rows, { fallbackData: [] });
1227
1220
  const unrealizedPnL = useMemo(() => {
1228
- if (!rawPositionRows || !symbol)
1229
- return position?.unrealized_pnl;
1221
+ if (!rawPositionRows || !symbol) return position?.unrealized_pnl;
1230
1222
  const currentPosition = rawPositionRows.find(
1231
1223
  (p) => p.symbol === symbol && p.position_qty !== 0
1232
1224
  );
1233
1225
  return currentPosition?.unrealized_pnl ?? position?.unrealized_pnl;
1234
1226
  }, [rawPositionRows, symbol]);
1235
1227
  const baseMin = useMemo(() => {
1236
- if (!symbolInfo)
1237
- return 0;
1228
+ if (!symbolInfo) return 0;
1238
1229
  return symbolInfo("base_min") || 0;
1239
1230
  }, [symbolInfo]);
1240
1231
  const baseMax = useMemo(() => {
1241
- if (!symbolInfo)
1242
- return 0;
1232
+ if (!symbolInfo) return 0;
1243
1233
  return symbolInfo("base_max") || 0;
1244
1234
  }, [symbolInfo]);
1245
1235
  const baseDp = useMemo(() => {
1246
- if (!symbolInfo)
1247
- return 6;
1236
+ if (!symbolInfo) return 6;
1248
1237
  return symbolInfo("base_dp") || 6;
1249
1238
  }, [symbolInfo]);
1250
1239
  const positionQty = useMemo(() => {
1251
- if (!position)
1252
- return 0;
1240
+ if (!position) return 0;
1253
1241
  return Math.abs(position.position_qty);
1254
1242
  }, [position]);
1255
1243
  const isLong = useMemo(() => {
1256
- if (!position)
1257
- return false;
1244
+ if (!position) return false;
1258
1245
  return position.position_qty > 0;
1259
1246
  }, [position]);
1260
1247
  const reverseQty = positionQty;
1261
1248
  const validationError = useMemo(() => {
1262
- if (!position || !symbolInfo)
1263
- return null;
1249
+ if (!position || !symbolInfo) return null;
1264
1250
  if (baseMin > 0 && reverseQty < baseMin) {
1265
1251
  return "belowMin";
1266
1252
  }
@@ -2336,8 +2322,7 @@ var PartialTPSL = (props) => {
2336
2322
  });
2337
2323
  const child = useMemo(() => {
2338
2324
  const children = [];
2339
- if (!order?.symbol)
2340
- return /* @__PURE__ */ jsx(AddIcon, { positionType: PositionType.PARTIAL });
2325
+ if (!order?.symbol) return /* @__PURE__ */ jsx(AddIcon, { positionType: PositionType.PARTIAL });
2341
2326
  if (tpTriggerPrice) {
2342
2327
  children.push(
2343
2328
  /* @__PURE__ */ jsx(
@@ -2581,8 +2566,7 @@ var TPSLTriggerPrice = (props) => {
2581
2566
  const { t } = useTranslation();
2582
2567
  const pnl = useMemo(() => {
2583
2568
  const msgs = [];
2584
- if (!props.tooltip || !order || !position)
2585
- return;
2569
+ if (!props.tooltip || !order || !position) return;
2586
2570
  let quantity = order.quantity;
2587
2571
  if (quantity === 0) {
2588
2572
  if (order.child_orders[0].type === "CLOSE_POSITION") {
@@ -2632,8 +2616,7 @@ var TPSLTriggerPrice = (props) => {
2632
2616
  ]);
2633
2617
  const child = useMemo(() => {
2634
2618
  const children = [];
2635
- if (!order?.symbol)
2636
- return /* @__PURE__ */ jsx(AddIcon, { positionType: PositionType.FULL });
2619
+ if (!order?.symbol) return /* @__PURE__ */ jsx(AddIcon, { positionType: PositionType.FULL });
2637
2620
  if (props.takeProfitPrice) {
2638
2621
  children.push(
2639
2622
  /* @__PURE__ */ jsx(
@@ -2924,7 +2907,19 @@ var useColumn = (config) => {
2924
2907
  Tooltip,
2925
2908
  {
2926
2909
  className: "oui-max-w-[280px] oui-bg-base-8 oui-p-3 oui-text-2xs oui-text-base-contrast-54",
2927
- content: t("positions.column.liqPrice.tooltip"),
2910
+ content: /* @__PURE__ */ jsxs("div", { children: [
2911
+ /* @__PURE__ */ jsx("div", { className: "oui-text-pretty", children: t("common.liquidationPrice.tooltip") }),
2912
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
2913
+ "a",
2914
+ {
2915
+ href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/liquidations",
2916
+ target: "_blank",
2917
+ rel: "noopener noreferrer",
2918
+ className: "oui-text-primary oui-underline",
2919
+ children: t("common.liquidationPrice.tooltip.learnMore")
2920
+ }
2921
+ ) })
2922
+ ] }),
2928
2923
  children: /* @__PURE__ */ jsx(Text, { children: t("positions.column.liqPrice") })
2929
2924
  }
2930
2925
  ),
@@ -3273,10 +3268,8 @@ var LiqPrice = (props) => {
3273
3268
  const liqPrice = useMemo(() => {
3274
3269
  const estLiqPrice = item.est_liq_price;
3275
3270
  const markPrice = item.mark_price;
3276
- if (!estLiqPrice || estLiqPrice <= 0)
3277
- return "-";
3278
- if (!markPrice || markPrice === 0)
3279
- return "-";
3271
+ if (!estLiqPrice || estLiqPrice <= 0) return "-";
3272
+ if (!markPrice || markPrice === 0) return "-";
3280
3273
  if (Math.abs(estLiqPrice - markPrice) / markPrice >= LIQ_DISTANCE_THRESHOLD) {
3281
3274
  return "-";
3282
3275
  }
@@ -3746,8 +3739,7 @@ var usePositionHistoryColumn = (props) => {
3746
3739
  dataIndex: "netPnL",
3747
3740
  width: 140,
3748
3741
  onSort: (a, b) => {
3749
- if (a.netPnL == null || b.netPnL == null)
3750
- return -1;
3742
+ if (a.netPnL == null || b.netPnL == null) return -1;
3751
3743
  return (a.netPnL ?? 0) - (b.netPnL ?? 0);
3752
3744
  },
3753
3745
  render: (_, record) => /* @__PURE__ */ jsxs(Flex, { gapX: 1, children: [
@@ -3991,8 +3983,7 @@ var NetPnL = (props) => {
3991
3983
  children: netPnl ?? "--"
3992
3984
  }
3993
3985
  );
3994
- if (record.netPnL == null)
3995
- return text();
3986
+ if (record.netPnL == null) return text();
3996
3987
  return /* @__PURE__ */ jsx(
3997
3988
  Tooltip,
3998
3989
  {
@@ -4050,15 +4041,13 @@ var LeverageDisplay2 = ({ symbol }) => {
4050
4041
  return /* @__PURE__ */ jsx(Text.numeral, { dp: 0, size: "2xs", unit: "X", children: leverage });
4051
4042
  };
4052
4043
  function offsetStartOfDay(date) {
4053
- if (date == null)
4054
- return date;
4044
+ if (date == null) return date;
4055
4045
  const newDate = new Date(date);
4056
4046
  newDate.setHours(0, 0, 0, 0);
4057
4047
  return newDate;
4058
4048
  }
4059
4049
  function offsetEndOfDay(date) {
4060
- if (date == null)
4061
- return date;
4050
+ if (date == null) return date;
4062
4051
  const newDate = new Date(date);
4063
4052
  newDate.setHours(23, 59, 59, 999);
4064
4053
  return newDate;
@@ -4123,8 +4112,7 @@ var usePositionHistoryScript = (props) => {
4123
4112
  setPage(1);
4124
4113
  }, [status, side, dateRange, filterDays, symbol]);
4125
4114
  const filterData = useMemo(() => {
4126
- if (data == null)
4127
- return data;
4115
+ if (data == null) return data;
4128
4116
  return data.filter((item) => {
4129
4117
  const sideFilter = side === "all" /* all */ ? true : item.side.toLowerCase() === side.toLowerCase();
4130
4118
  const statusFilter = status === "all" /* all */ ? true : item.position_status.toLowerCase() === status.toLowerCase();
@@ -5025,12 +5013,10 @@ var Body2 = (props) => {
5025
5013
  const position = props.item.positions_by_perp?.[0];
5026
5014
  const { t } = useTranslation();
5027
5015
  const mr = useMemo(() => {
5028
- if (isNaN(props.item?.margin_ratio))
5029
- return "--";
5016
+ if (isNaN(props.item?.margin_ratio)) return "--";
5030
5017
  return `${new Decimal(props.item.margin_ratio).mul(100).todp(2, Decimal.ROUND_DOWN).toNumber()}%`;
5031
5018
  }, [props.item?.margin_ratio]);
5032
- if (!position)
5033
- return null;
5019
+ if (!position) return null;
5034
5020
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", width: "100%", gap: 1, children: [
5035
5021
  /* @__PURE__ */ jsxs(Flex, { gap: 2, width: "100%", children: [
5036
5022
  /* @__PURE__ */ jsx(
@@ -5433,8 +5419,7 @@ var useFilter2 = () => {
5433
5419
  };
5434
5420
  };
5435
5421
  var generateKeyFun = (args) => (pageIndex, previousPageData) => {
5436
- if (previousPageData && !previousPageData.rows?.length)
5437
- return null;
5422
+ if (previousPageData && !previousPageData.rows?.length) return null;
5438
5423
  const { symbol, size = 10, page, end_t, start_t } = args;
5439
5424
  const search = new URLSearchParams([
5440
5425
  ["size", size.toString()],
@@ -5490,8 +5475,7 @@ var useCloseAllPositionsScript = (options) => {
5490
5475
  const { tracking } = useTrack();
5491
5476
  const [positionsData] = usePositionStream(symbol);
5492
5477
  const openPositions = useMemo(() => {
5493
- if (!positionsData?.rows)
5494
- return [];
5478
+ if (!positionsData?.rows) return [];
5495
5479
  return positionsData.rows.filter(
5496
5480
  (position) => position.position_qty !== 0 && position.position_qty !== void 0
5497
5481
  );
@@ -5504,8 +5488,7 @@ var useCloseAllPositionsScript = (options) => {
5504
5488
  "POST"
5505
5489
  );
5506
5490
  const closeAllPositions = useCallback(async () => {
5507
- if (!hasOpenPositions)
5508
- return;
5491
+ if (!hasOpenPositions) return;
5509
5492
  try {
5510
5493
  const closePromises = openPositions.map(
5511
5494
  (position) => {
@@ -5572,5 +5555,5 @@ registerSimpleDialog(MarketCloseConfirmID, MarketCloseConfirm, {
5572
5555
  });
5573
5556
 
5574
5557
  export { CloseAllPositions, CloseAllPositionsWidget, CombinePositionsWidget, FundingFeeButton, FundingFeeHistoryUI, Liquidation, LiquidationWidget, MarketCloseConfirmID, MobileLiquidation, MobileLiquidationWidget, MobilePositionHistory, MobilePositionHistoryWidget, MobilePositionsWidget, OrderInfoCard, PositionHistory, PositionHistoryWidget, PositionsTabName, PositionsWidget, ReversePosition, ReversePositionDialogId, ReversePositionWidget, sortList, useCloseAllPositionsScript, useLiquidationScript, usePositionHistoryScript, usePositionsRowContext, useReversePositionEnabled, useReversePositionScript, useSort, useTabSort };
5575
- //# sourceMappingURL=out.js.map
5558
+ //# sourceMappingURL=index.mjs.map
5576
5559
  //# sourceMappingURL=index.mjs.map