@orderly.network/ui-orders 2.8.5 → 2.8.6

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
@@ -1,12 +1,12 @@
1
1
  import React2, { forwardRef, useMemo, useEffect, useRef, useImperativeHandle, useCallback, useState, createContext, memo, useContext } from 'react';
2
- import { useSymbolsInfo, useOrderStream, useLocalStorage, utils, useThrottledCallback, useMutation, useSWRConfig, useAccount, unstable_serialize, useMemoizedFn, getMinNotional, findTPSLFromOrder, findTPSLOrderPriceFromOrder, useMaxQty, useConfig, useOrderEntity, useReferralInfo, useLeverageBySymbol } from '@orderly.network/hooks';
2
+ import { useSymbolsInfo, useOrderStream, useLocalStorage, utils, useThrottledCallback, useMutation, useSWRConfig, useAccount, unstable_serialize, useMemoizedFn, getMinNotional, findTPSLFromOrder, findTPSLOrderPriceFromOrder, useMaxQty, useConfig, useTpslPriceChecker, useOrderEntity, useReferralInfo, useLeverageBySymbol } from '@orderly.network/hooks';
3
3
  import { useTranslation, Trans, i18n } from '@orderly.network/i18n';
4
4
  import { OrderStatus, AlgoOrderRootType, AlgoOrderType, OrderSide, OrderType, EMPTY_LIST } from '@orderly.network/types';
5
5
  import { formatSymbol, Decimal, commify, commifyOptional, getTrailingStopPrice, formatNum } from '@orderly.network/utils';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import { usePagination, modal, Text, Button, ThrottledButton, CloseIcon, cn, Flex, Input, inputFormatter, Slider, DataFilter, TableFeatures, Grid, Picker, ListView, Tabs, TabPanel, Badge, Tooltip, EditIcon, toast as toast$1, Popover, PopoverRoot, PopoverTrigger, PopoverContent, Divider, ShareIcon, CheckIcon, Statistic, SimpleDialog, useModal, Checkbox } from '@orderly.network/ui';
8
8
  import { useDataTap, useOrderEntryFormErrorMsg } from '@orderly.network/react-app';
9
- import { PositionTPSLPopover, PositionTPSLSheet } from '@orderly.network/ui-tpsl';
9
+ import { PositionTPSLPopover, CloseToLiqPriceIcon, PositionTPSLSheet } from '@orderly.network/ui-tpsl';
10
10
  import { format, subDays, differenceInDays } from 'date-fns';
11
11
  import { SharePnLDialogId } from '@orderly.network/ui-share';
12
12
  import { AuthGuardDataTable } from '@orderly.network/ui-connector';
@@ -370,7 +370,7 @@ var init_bracketOrderPrice = __esm({
370
370
  }
371
371
  return utils.findTPSLFromOrder(props.order.child_orders[0]);
372
372
  }, [props.order]);
373
- const { pnl, roi } = calcBracketRoiAndPnL(order);
373
+ const { pnl } = calcBracketRoiAndPnL(order);
374
374
  if (!tp_trigger_price && !sl_trigger_price) {
375
375
  return "--";
376
376
  }
@@ -2130,6 +2130,12 @@ var init_tpslTriggerPrice = __esm({
2130
2130
  init_tpslOrderRowContext();
2131
2131
  OrderTriggerPrice = () => {
2132
2132
  const { sl_trigger_price, tp_trigger_price, order, position } = useTPSLOrderRowContext();
2133
+ const positionSide = position?.position_qty && position.position_qty > 0 ? OrderSide.BUY : OrderSide.SELL;
2134
+ const slPriceError = useTpslPriceChecker({
2135
+ slPrice: sl_trigger_price?.toString() ?? void 0,
2136
+ liqPrice: position?.est_liq_price ?? null,
2137
+ side: positionSide
2138
+ });
2133
2139
  return /* @__PURE__ */ jsx(
2134
2140
  TPSLTriggerPrice,
2135
2141
  {
@@ -2138,6 +2144,7 @@ var init_tpslTriggerPrice = __esm({
2138
2144
  direction: "column",
2139
2145
  order,
2140
2146
  position,
2147
+ slPriceError,
2141
2148
  tooltip: true
2142
2149
  }
2143
2150
  );
@@ -2227,15 +2234,24 @@ var init_tpslTriggerPrice = __esm({
2227
2234
  Text.numeral,
2228
2235
  {
2229
2236
  className: cn(
2230
- "oui-text-trade-loss oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12"
2237
+ "oui-text-trade-loss oui-gap-0 oui-decoration-white/20 oui-border-b oui-border-dashed oui-border-base-contrast-12",
2238
+ "oui-flex oui-items-center"
2231
2239
  ),
2240
+ as: "div",
2232
2241
  rule: "price",
2233
2242
  dp: symbolInfo[order.symbol]("quote_dp", 2),
2234
2243
  children: props.stopLossPrice,
2235
2244
  prefix: !props.takeProfitPrice || direction === "column" ? /* @__PURE__ */ jsxs("span", { className: "oui-text-base-contrast-54", children: [
2236
2245
  `${t("tpsl.sl")} -`,
2237
2246
  "\xA0"
2238
- ] }) : ""
2247
+ ] }) : "",
2248
+ suffix: /* @__PURE__ */ jsx(
2249
+ CloseToLiqPriceIcon,
2250
+ {
2251
+ slPriceError: props.slPriceError,
2252
+ className: "oui-ml-1"
2253
+ }
2254
+ )
2239
2255
  },
2240
2256
  "sl"
2241
2257
  )
@@ -2247,7 +2263,13 @@ var init_tpslTriggerPrice = __esm({
2247
2263
  children.splice(1, 0, /* @__PURE__ */ jsx("span", { children: "/" }, "split"));
2248
2264
  }
2249
2265
  return children;
2250
- }, [props.takeProfitPrice, props.stopLossPrice, order?.symbol, t]);
2266
+ }, [
2267
+ props.takeProfitPrice,
2268
+ props.stopLossPrice,
2269
+ order?.symbol,
2270
+ t,
2271
+ props.slPriceError
2272
+ ]);
2251
2273
  const content = /* @__PURE__ */ jsx(
2252
2274
  "div",
2253
2275
  {
@@ -3414,8 +3436,14 @@ var init_items = __esm({
3414
3436
  );
3415
3437
  };
3416
3438
  SLTrigger = (props) => {
3417
- const { sl_trigger_price, slPnL } = useTPSLOrderRowContext();
3439
+ const { sl_trigger_price, slPnL, position: item } = useTPSLOrderRowContext();
3418
3440
  const { t } = useTranslation();
3441
+ const side2 = (item?.position_qty ?? 0) > 0 ? OrderSide.BUY : OrderSide.SELL;
3442
+ const slPriceError = useTpslPriceChecker({
3443
+ slPrice: sl_trigger_price?.toString() ?? void 0,
3444
+ liqPrice: item?.est_liq_price ?? null,
3445
+ side: side2
3446
+ });
3419
3447
  return /* @__PURE__ */ jsx(
3420
3448
  Statistic,
3421
3449
  {
@@ -3448,10 +3476,15 @@ var init_items = __esm({
3448
3476
  Text.numeral,
3449
3477
  {
3450
3478
  dp: props.quote_dp,
3479
+ as: "div",
3451
3480
  rm: Decimal.ROUND_DOWN,
3452
3481
  color: "sell",
3453
3482
  padding: false,
3454
- className: sl_trigger_price ? "oui-border-b oui-border-dashed oui-border-base-contrast-12" : void 0,
3483
+ suffix: /* @__PURE__ */ jsx(CloseToLiqPriceIcon, { slPriceError }),
3484
+ className: cn(
3485
+ sl_trigger_price ? "oui-border-b oui-border-dashed oui-border-base-contrast-12" : void 0,
3486
+ "oui-flex oui-items-center"
3487
+ ),
3455
3488
  children: sl_trigger_price ?? "--"
3456
3489
  }
3457
3490
  )
@@ -4540,7 +4573,7 @@ var init_editSheet_ui = __esm({
4540
4573
  const { t } = useTranslation();
4541
4574
  const { getErrorMsg } = useOrderEntryFormErrorMsg(errors);
4542
4575
  const disabled = !props.isChanged || Object.keys(errors).length > 0 || // when activated price is not empty, the activated price input should not be empty
4543
- item.activated_price && !formattedOrder.activated_price;
4576
+ !!item.activated_price && !formattedOrder.activated_price;
4544
4577
  const header = /* @__PURE__ */ jsx(EditSheetHeader, { item });
4545
4578
  const lastPrice = /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", children: [
4546
4579
  /* @__PURE__ */ jsx(Text, { children: t("common.lastPrice") }),