@orderly.network/ui-tpsl 2.11.3-rc.0 → 2.12.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
@@ -1,15 +1,22 @@
1
1
  import { SDKError, MarginMode, PositionType, AlgoOrderRootType, OrderType, OrderSide, OrderStatus, AlgoOrderType } from '@orderly.network/types';
2
- import { Flex, Input, inputFormatter, cn, Slider, Text, registerSimpleSheet, registerSimpleDialog, useScreen, ScrollArea, DotStatus, Grid, Button, ThrottledButton, Divider, Box, toast, TokenIcon, modal, Tooltip, ExclamationFillIcon, Select, ChevronDownIcon, Badge, textVariants, Checkbox, SimpleDropdownMenu, CaretDownIcon, useModal } from '@orderly.network/ui';
2
+ import { Flex, Input, inputFormatter, cn, Slider, Text, registerSimpleSheet, registerSimpleDialog, useScreen, ScrollArea, DotStatus, Grid, Button, ThrottledButton, Divider, Box, toast, TokenIcon, modal, SymbolBadge as SymbolBadge$1, Tooltip, ExclamationFillIcon, Select, ChevronDownIcon, Badge, textVariants, Checkbox, SimpleDropdownMenu, CaretDownIcon, useModal } from '@orderly.network/ui';
3
3
  import { memo, useRef, useState, useEffect, createContext, useMemo, useContext, Fragment as Fragment$1 } from 'react';
4
- import { utils, useSymbolsInfo, useAccount, useEventEmitter, useLocalStorage, useMarginModeBySymbol, usePositionStream, useEstLiqPriceBySymbol, useTPSLOrder, useTpslPriceChecker, ERROR_MSG_CODES, useMemoizedFn, useOrderEntry, useGetEstLiqPrice, useOrderStream, useSubAccountAlgoOrderStream, findPositionTPSLFromOrders, useMutation, useMarkPrice, useIndexPrice, useLeverageBySymbol, useMaxQty, findTPSLFromOrder, findTPSLOrderPriceFromOrder } from '@orderly.network/hooks';
4
+ import { utils, useSymbolsInfo, useAccount, useEventEmitter, useLocalStorage, useMarginModeBySymbol, usePositionStream, useEstLiqPriceBySymbol, useTPSLOrder, useTpslPriceChecker, ERROR_MSG_CODES, useMemoizedFn, useOrderEntry, useGetEstLiqPrice, useOrderStream, useSubAccountAlgoOrderStream, findPositionTPSLFromOrders, useMutation, useMarkPrice, useIndexPrice, useLeverageBySymbol, useMaxQty, useBadgeBySymbol, useSymbolWithBroker, findTPSLFromOrder, findTPSLOrderPriceFromOrder } from '@orderly.network/hooks';
5
5
  import { useTranslation, i18n, Trans } from '@orderly.network/i18n';
6
6
  import { useOrderEntryFormErrorMsg } from '@orderly.network/react-app';
7
7
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
8
- import { Decimal, checkIsNaN, transSymbolformString, getTPSLDirection, formatNum, todpIfNeed } from '@orderly.network/utils';
8
+ import { Decimal, checkIsNaN, getTPSLDirection, formatNum, todpIfNeed } from '@orderly.network/utils';
9
9
  import { order, positions } from '@orderly.network/perp';
10
10
  import { AuthGuardDataTable } from '@orderly.network/ui-connector';
11
11
 
12
12
  // src/editorPopover.tsx
13
+ var SymbolBadge = (props) => {
14
+ const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(
15
+ props.symbol
16
+ );
17
+ const badge = brokerName ?? brokerId ?? void 0;
18
+ return /* @__PURE__ */ jsx(SymbolBadge$1, { badge, fullName: brokerNameRaw });
19
+ };
13
20
  var OrderInfo = (props) => {
14
21
  const { t } = useTranslation();
15
22
  const { order: order2, symbolLeverage } = props;
@@ -45,10 +52,11 @@ var OrderInfo = (props) => {
45
52
  {
46
53
  className: "oui-whitespace-nowrap oui-break-normal",
47
54
  rule: "symbol",
48
- formatString: "base-type",
55
+ formatString: "base",
49
56
  size: "sm",
50
57
  weight: "semibold",
51
58
  intensity: 98,
59
+ suffix: /* @__PURE__ */ jsx(SymbolBadge, { symbol: symbol ?? "" }),
52
60
  children: symbol
53
61
  }
54
62
  )
@@ -254,6 +262,7 @@ var useTPSLInputRowScript = (props) => {
254
262
  });
255
263
  return roi2 * 100;
256
264
  } catch (error) {
265
+ console.error("error", error);
257
266
  return null;
258
267
  }
259
268
  }, [values, leverage, rootOrderPrice, type, side]);
@@ -830,10 +839,10 @@ var TPSLQuantity = memo((props) => {
830
839
  tooltip: errorMsg,
831
840
  color: errorMsg ? "danger" : void 0,
832
841
  formatters: [
842
+ inputFormatter.decimalPointFormatter,
833
843
  inputFormatter.dpFormatter(props.base_dp),
834
844
  inputFormatter.numberFormatter,
835
- inputFormatter.currencyFormatter,
836
- inputFormatter.decimalPointFormatter
845
+ inputFormatter.currencyFormatter
837
846
  ],
838
847
  onValueChange: (value) => {
839
848
  props.onQuantityChange?.(value);
@@ -1105,6 +1114,7 @@ var TPSL = (props) => {
1105
1114
  props.close?.();
1106
1115
  onComplete?.();
1107
1116
  }).catch((err) => {
1117
+ console.log("--->>>cancel order", err);
1108
1118
  });
1109
1119
  },
1110
1120
  children: t("common.confirm")
@@ -1183,21 +1193,25 @@ var PositionTPSLConfirm = (props) => {
1183
1193
  );
1184
1194
  };
1185
1195
  const isPositionTPSL = _isPositionTPSL;
1196
+ const displaySymbol = useSymbolWithBroker(symbol);
1186
1197
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1187
- isEditing && /* @__PURE__ */ jsx(Text, { as: "div", size: "2xs", intensity: 80, className: "oui-mb-3", children: t("tpsl.agreement", { symbol: transSymbolformString(symbol) }) }),
1198
+ isEditing && /* @__PURE__ */ jsx(Text, { as: "div", size: "2xs", intensity: 80, className: "oui-mb-3", children: t("tpsl.agreement", { symbol: displaySymbol }) }),
1188
1199
  /* @__PURE__ */ jsxs(Flex, { pb: 4, children: [
1189
- /* @__PURE__ */ jsx(Box, { grow: true, children: /* @__PURE__ */ jsx(
1190
- Text.formatted,
1191
- {
1192
- rule: "symbol",
1193
- formatString: "base-type",
1194
- size: "base",
1195
- showIcon: true,
1196
- as: "div",
1197
- intensity: 80,
1198
- children: symbol
1199
- }
1200
- ) }),
1200
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", itemAlign: "start", gap: 1, grow: true, children: [
1201
+ /* @__PURE__ */ jsx(Box, { grow: true, children: /* @__PURE__ */ jsx(
1202
+ Text.formatted,
1203
+ {
1204
+ rule: "symbol",
1205
+ formatString: "base",
1206
+ size: "base",
1207
+ showIcon: true,
1208
+ as: "div",
1209
+ intensity: 80,
1210
+ children: symbol
1211
+ }
1212
+ ) }),
1213
+ /* @__PURE__ */ jsx(SymbolBadge, { symbol })
1214
+ ] }),
1201
1215
  /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
1202
1216
  isPositionTPSL && /* @__PURE__ */ jsx(Badge, { size: "xs", color: "primary", children: t("common.position") }),
1203
1217
  /* @__PURE__ */ jsx(TPSLOrderType, { tpPrice, slPrice }),
@@ -1394,6 +1408,7 @@ var useTPSLBuilder = (options) => {
1394
1408
  });
1395
1409
  const isSlPriceWarning = slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
1396
1410
  const setQuantity = (value) => {
1411
+ console.log("------>>>>>setQuantity", value);
1397
1412
  setValue("quantity", value);
1398
1413
  };
1399
1414
  const setOrderPrice = (name, value) => {
@@ -1952,6 +1967,8 @@ var useTPSLAdvanced = (props) => {
1952
1967
  helper.validate(isSlPriceError ? slPriceError : void 0).then(() => {
1953
1968
  props.onSubmit(formattedOrder);
1954
1969
  }).catch((err) => {
1970
+ console.log("metaState", metaState);
1971
+ console.log("err", err);
1955
1972
  });
1956
1973
  };
1957
1974
  return {
@@ -2617,6 +2634,7 @@ var TPSLDetailUI = (props) => {
2617
2634
  symbolInfo
2618
2635
  } = props;
2619
2636
  const { estLiqPrice } = useTPSLDetailContext();
2637
+ console.log("----- position", position);
2620
2638
  return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(ScrollArea, { className: cn(isMobile && "oui-h-[calc(100vh-100px)]"), children: [
2621
2639
  /* @__PURE__ */ jsx(
2622
2640
  OrderInfo,
@@ -3163,7 +3181,7 @@ var TPSLSimpleDialogUI = (props) => {
3163
3181
  TPSLQuantity,
3164
3182
  {
3165
3183
  maxQty: props.maxQty,
3166
- quantity: Number(props.orderQuantity ?? props.maxQty),
3184
+ quantity: props.orderQuantity ?? props.maxQty,
3167
3185
  baseTick: props.symbolInfo("base_tick"),
3168
3186
  base_dp: props.symbolInfo("base_dp"),
3169
3187
  base: props.symbolInfo("base"),
@@ -3225,6 +3243,7 @@ var TPSLSimpleDialogUI = (props) => {
3225
3243
  var TPSLSimpleDialogWidget = (props) => {
3226
3244
  const { close, onComplete, showAdvancedTPSLDialog } = props;
3227
3245
  const state = useTPSLSimpleDialog(props);
3246
+ console.log("------>>>>>TPSLSimpleDialogWidget", state);
3228
3247
  return /* @__PURE__ */ jsx(
3229
3248
  TPSLSimpleDialogUI,
3230
3249
  {
@@ -3632,6 +3651,7 @@ var EditBracketOrderUI = (props) => {
3632
3651
  props.onSubmit().then(() => {
3633
3652
  props.onClose?.();
3634
3653
  }).catch((err) => {
3654
+ console.log("--->>>cancel order", err);
3635
3655
  });
3636
3656
  },
3637
3657
  children: t("common.confirm")