@orderly.network/ui-tpsl 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.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +209 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +211 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { utils, useSymbolsInfo, usePositionStream, useLocalStorage, useTPSLOrder, useMemoizedFn, useOrderEntry, useOrderStream, findPositionTPSLFromOrders, useMutation, useMarkPrice, useIndexPrice, useLeverageBySymbol, findTPSLFromOrder, findTPSLOrderPriceFromOrder } from '@orderly.network/hooks';
|
|
1
|
+
import { utils, useSymbolsInfo, usePositionStream, useLocalStorage, useEstLiqPriceBySymbol, useTPSLOrder, useTpslPriceChecker, ERROR_MSG_CODES, useMemoizedFn, useOrderEntry, useOrderStream, findPositionTPSLFromOrders, useMutation, useMarkPrice, useIndexPrice, useLeverageBySymbol, useMaxQty, findTPSLFromOrder, findTPSLOrderPriceFromOrder } from '@orderly.network/hooks';
|
|
2
2
|
import { useTranslation, i18n, Trans } from '@orderly.network/i18n';
|
|
3
3
|
import { SDKError, AlgoOrderRootType, PositionType, OrderType, OrderSide, OrderStatus, AlgoOrderType } from '@orderly.network/types';
|
|
4
|
-
import { Flex, Input, inputFormatter, cn, Slider, Text, registerSimpleSheet, registerSimpleDialog, useScreen, ScrollArea, Grid, Button, ThrottledButton, Divider, Box, toast, TokenIcon, modal, Tooltip, ExclamationFillIcon, Select, ChevronDownIcon, Badge, textVariants, Checkbox, SimpleDropdownMenu, CaretDownIcon, useModal } from '@orderly.network/ui';
|
|
4
|
+
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';
|
|
5
|
+
import { memo, useRef, useState, useEffect, createContext, useMemo, useContext, Fragment as Fragment$1 } from 'react';
|
|
5
6
|
import { useOrderEntryFormErrorMsg } from '@orderly.network/react-app';
|
|
6
7
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
7
|
-
import { memo, useRef, useState, useEffect, createContext, useMemo, Fragment as Fragment$1, useContext } from 'react';
|
|
8
8
|
import { Decimal, checkIsNaN, transSymbolformString, 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';
|
|
@@ -122,6 +122,19 @@ var OrderInfo = (props) => {
|
|
|
122
122
|
children: markPrice?.data
|
|
123
123
|
}
|
|
124
124
|
)
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-text-base-contrast-36", children: [
|
|
127
|
+
/* @__PURE__ */ jsx(Text, { size: "2xs", children: t("positions.column.liqPrice") }),
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
129
|
+
Text.numeral,
|
|
130
|
+
{
|
|
131
|
+
rule: "price",
|
|
132
|
+
className: "oui-text-warning",
|
|
133
|
+
size: "2xs",
|
|
134
|
+
dp: props.quoteDP ?? 2,
|
|
135
|
+
children: props.estLiqPrice ?? "--"
|
|
136
|
+
}
|
|
137
|
+
)
|
|
125
138
|
] })
|
|
126
139
|
]
|
|
127
140
|
}
|
|
@@ -489,10 +502,15 @@ var PriceInput = (props) => {
|
|
|
489
502
|
value: props.value,
|
|
490
503
|
color: props.error ? "danger" : void 0,
|
|
491
504
|
classNames: {
|
|
492
|
-
input:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
505
|
+
input: cn(
|
|
506
|
+
"oui-text-2xs placeholder:oui-text-2xs",
|
|
507
|
+
props.classNames?.input
|
|
508
|
+
),
|
|
509
|
+
prefix: cn(
|
|
510
|
+
"oui-text-base-contrast-54 oui-text-2xs",
|
|
511
|
+
props.classNames?.prefix
|
|
512
|
+
),
|
|
513
|
+
root: cn("oui-w-full", props.classNames?.root)
|
|
496
514
|
},
|
|
497
515
|
onValueChange: props.onValueChange,
|
|
498
516
|
onFocus: () => {
|
|
@@ -549,7 +567,10 @@ var TPSLInputRowUI = (props) => {
|
|
|
549
567
|
onValueChange: (value) => {
|
|
550
568
|
props.onChange(`${props.type}_trigger_price`, value);
|
|
551
569
|
},
|
|
552
|
-
quote_dp: props.quote_dp
|
|
570
|
+
quote_dp: props.quote_dp,
|
|
571
|
+
classNames: {
|
|
572
|
+
root: props.inputWarnNode ? "oui-outline-warning-darken focus-within:oui-outline-warning-darken" : void 0
|
|
573
|
+
}
|
|
553
574
|
}
|
|
554
575
|
),
|
|
555
576
|
/* @__PURE__ */ jsx(
|
|
@@ -568,6 +589,7 @@ var TPSLInputRowUI = (props) => {
|
|
|
568
589
|
]
|
|
569
590
|
}
|
|
570
591
|
),
|
|
592
|
+
props.inputWarnNode,
|
|
571
593
|
/* @__PURE__ */ jsxs(
|
|
572
594
|
Flex,
|
|
573
595
|
{
|
|
@@ -866,7 +888,23 @@ var TPSL = (props) => {
|
|
|
866
888
|
const { errors, validated } = props.metaState;
|
|
867
889
|
const { t } = useTranslation();
|
|
868
890
|
const { isMobile } = useScreen();
|
|
891
|
+
const tpErrors = useMemo(() => {
|
|
892
|
+
if (!errors)
|
|
893
|
+
return null;
|
|
894
|
+
const { sl_trigger_price, ...rest } = errors;
|
|
895
|
+
return rest;
|
|
896
|
+
}, [errors]);
|
|
897
|
+
const slErrors = useMemo(() => {
|
|
898
|
+
if (!errors)
|
|
899
|
+
return null;
|
|
900
|
+
const { tp_trigger_price, ...rest } = errors;
|
|
901
|
+
return rest;
|
|
902
|
+
}, [errors]);
|
|
869
903
|
const { getErrorMsg } = useOrderEntryFormErrorMsg(errors);
|
|
904
|
+
const { getErrorMsg: getSlPriceErrorMsg } = useOrderEntryFormErrorMsg(
|
|
905
|
+
props.slPriceError
|
|
906
|
+
);
|
|
907
|
+
const isSlPriceWarning = props.slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
|
|
870
908
|
if (!position) {
|
|
871
909
|
return null;
|
|
872
910
|
}
|
|
@@ -896,6 +934,7 @@ var TPSL = (props) => {
|
|
|
896
934
|
{
|
|
897
935
|
baseDP: symbolInfo("base_dp"),
|
|
898
936
|
quoteDP: symbolInfo("quote_dp"),
|
|
937
|
+
estLiqPrice: props.estLiqPrice,
|
|
899
938
|
classNames: {
|
|
900
939
|
root: "oui-mb-3",
|
|
901
940
|
container: "oui-gap-x-[30px]"
|
|
@@ -927,7 +966,14 @@ var TPSL = (props) => {
|
|
|
927
966
|
}
|
|
928
967
|
}
|
|
929
968
|
),
|
|
930
|
-
TPSL_OrderEntity.position_type === PositionType.FULL && /* @__PURE__ */ jsx(
|
|
969
|
+
TPSL_OrderEntity.position_type === PositionType.FULL && /* @__PURE__ */ jsx(
|
|
970
|
+
DotStatus,
|
|
971
|
+
{
|
|
972
|
+
color: "warning",
|
|
973
|
+
size: "xs",
|
|
974
|
+
label: t("tpsl.positionType.full.tips.market")
|
|
975
|
+
}
|
|
976
|
+
)
|
|
931
977
|
]
|
|
932
978
|
}
|
|
933
979
|
),
|
|
@@ -958,7 +1004,7 @@ var TPSL = (props) => {
|
|
|
958
1004
|
order_type: TPSL_OrderEntity.tp_order_type ?? OrderType.MARKET
|
|
959
1005
|
},
|
|
960
1006
|
hideOrderPrice: TPSL_OrderEntity.position_type === PositionType.FULL,
|
|
961
|
-
errors: validated ?
|
|
1007
|
+
errors: validated ? tpErrors : null,
|
|
962
1008
|
disableOrderTypeSelector: isEditing,
|
|
963
1009
|
quote_dp: symbolInfo("quote_dp"),
|
|
964
1010
|
positionType: TPSL_OrderEntity.position_type ?? PositionType.PARTIAL,
|
|
@@ -971,6 +1017,16 @@ var TPSL = (props) => {
|
|
|
971
1017
|
/* @__PURE__ */ jsx(
|
|
972
1018
|
TPSLInputRowWidget,
|
|
973
1019
|
{
|
|
1020
|
+
inputWarnNode: isSlPriceWarning && /* @__PURE__ */ jsx(
|
|
1021
|
+
DotStatus,
|
|
1022
|
+
{
|
|
1023
|
+
color: "warning",
|
|
1024
|
+
label: getSlPriceErrorMsg("sl_trigger_price"),
|
|
1025
|
+
classNames: {
|
|
1026
|
+
root: "oui-mt-1"
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
974
1030
|
symbol: position.symbol,
|
|
975
1031
|
rootOrderPrice: position.average_open_price.toString(),
|
|
976
1032
|
type: "sl",
|
|
@@ -985,7 +1041,7 @@ var TPSL = (props) => {
|
|
|
985
1041
|
order_type: TPSL_OrderEntity.sl_order_type ?? OrderType.MARKET
|
|
986
1042
|
},
|
|
987
1043
|
hideOrderPrice: TPSL_OrderEntity.position_type === PositionType.FULL,
|
|
988
|
-
errors: validated ?
|
|
1044
|
+
errors: validated ? slErrors : null,
|
|
989
1045
|
quote_dp: symbolInfo("quote_dp"),
|
|
990
1046
|
positionType: TPSL_OrderEntity.position_type ?? PositionType.PARTIAL,
|
|
991
1047
|
disableOrderTypeSelector: isEditing,
|
|
@@ -1269,6 +1325,7 @@ var useTPSLBuilder = (options) => {
|
|
|
1269
1325
|
const [{ rows: positions }] = usePositionStream();
|
|
1270
1326
|
const [needConfirm] = useLocalStorage("orderly_order_confirm", true);
|
|
1271
1327
|
const position = positions.find((item) => item.symbol === symbol);
|
|
1328
|
+
const estLiqPrice = useEstLiqPriceBySymbol(symbol);
|
|
1272
1329
|
useEffect(() => {
|
|
1273
1330
|
if (!position) {
|
|
1274
1331
|
options.close?.();
|
|
@@ -1303,6 +1360,12 @@ var useTPSLBuilder = (options) => {
|
|
|
1303
1360
|
isEditing
|
|
1304
1361
|
}
|
|
1305
1362
|
);
|
|
1363
|
+
const slPriceError = useTpslPriceChecker({
|
|
1364
|
+
slPrice: tpslOrder.sl_trigger_price?.toString() ?? void 0,
|
|
1365
|
+
liqPrice: estLiqPrice ?? null,
|
|
1366
|
+
side: tpslOrder.side
|
|
1367
|
+
});
|
|
1368
|
+
const isSlPriceWarning = slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
|
|
1306
1369
|
const setQuantity = (value) => {
|
|
1307
1370
|
setValue("quantity", value);
|
|
1308
1371
|
};
|
|
@@ -1448,7 +1511,9 @@ var useTPSLBuilder = (options) => {
|
|
|
1448
1511
|
};
|
|
1449
1512
|
const onSubmit = async () => {
|
|
1450
1513
|
try {
|
|
1451
|
-
const validOrder = await validate(
|
|
1514
|
+
const validOrder = await validate(
|
|
1515
|
+
isSlPriceWarning ? void 0 : slPriceError
|
|
1516
|
+
);
|
|
1452
1517
|
if (validOrder) {
|
|
1453
1518
|
if (!needConfirm) {
|
|
1454
1519
|
return submit({ accountId: position?.account_id }).then(() => true).catch((err) => {
|
|
@@ -1481,6 +1546,8 @@ var useTPSLBuilder = (options) => {
|
|
|
1481
1546
|
setOrderPrice,
|
|
1482
1547
|
// needConfirm,
|
|
1483
1548
|
onSubmit,
|
|
1549
|
+
slPriceError,
|
|
1550
|
+
estLiqPrice,
|
|
1484
1551
|
metaState,
|
|
1485
1552
|
errors,
|
|
1486
1553
|
status: {
|
|
@@ -1554,6 +1621,8 @@ var PositionTPSLSheet = (props) => {
|
|
|
1554
1621
|
var TPSLAdvancedUI = (props) => {
|
|
1555
1622
|
const { t } = useTranslation();
|
|
1556
1623
|
const { errors, validated } = props.metaState;
|
|
1624
|
+
const { getErrorMsg } = useOrderEntryFormErrorMsg(props.slPriceError);
|
|
1625
|
+
const isSlPriceWarning = props.slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
|
|
1557
1626
|
const {
|
|
1558
1627
|
formattedOrder,
|
|
1559
1628
|
setValue: setOrderValue,
|
|
@@ -1628,6 +1697,7 @@ var TPSLAdvancedUI = (props) => {
|
|
|
1628
1697
|
order: formattedOrder,
|
|
1629
1698
|
baseDP: symbolInfo.base_dp,
|
|
1630
1699
|
quoteDP: symbolInfo.quote_dp,
|
|
1700
|
+
estLiqPrice: props.estLiqPrice ?? void 0,
|
|
1631
1701
|
symbolLeverage: props.symbolLeverage
|
|
1632
1702
|
}
|
|
1633
1703
|
) }),
|
|
@@ -1730,6 +1800,14 @@ var TPSLAdvancedUI = (props) => {
|
|
|
1730
1800
|
values: slValues,
|
|
1731
1801
|
hideOrderPrice: formattedOrder.position_type === PositionType.FULL,
|
|
1732
1802
|
errors: validated ? errors : null,
|
|
1803
|
+
inputWarnNode: isSlPriceWarning && /* @__PURE__ */ jsx(
|
|
1804
|
+
DotStatus,
|
|
1805
|
+
{
|
|
1806
|
+
color: "warning",
|
|
1807
|
+
size: "xs",
|
|
1808
|
+
label: getErrorMsg("sl_trigger_price")
|
|
1809
|
+
}
|
|
1810
|
+
),
|
|
1733
1811
|
quote_dp: symbolInfo.quote_dp,
|
|
1734
1812
|
positionType: formattedOrder.position_type ?? PositionType.PARTIAL,
|
|
1735
1813
|
onChange: (key, value) => {
|
|
@@ -1829,8 +1907,14 @@ var useTPSLAdvanced = (props) => {
|
|
|
1829
1907
|
tp_offset_percentage: order2.tp_offset_percentage
|
|
1830
1908
|
}
|
|
1831
1909
|
});
|
|
1910
|
+
const slPriceError = useTpslPriceChecker({
|
|
1911
|
+
slPrice: formattedOrder.sl_trigger_price,
|
|
1912
|
+
liqPrice: state.estLiqPrice,
|
|
1913
|
+
side: formattedOrder.side
|
|
1914
|
+
});
|
|
1832
1915
|
const onSubmit = () => {
|
|
1833
|
-
|
|
1916
|
+
const isSlPriceError = slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_ERROR;
|
|
1917
|
+
helper.validate(isSlPriceError ? slPriceError : void 0).then(() => {
|
|
1834
1918
|
props.onSubmit(formattedOrder);
|
|
1835
1919
|
}).catch((err) => {
|
|
1836
1920
|
});
|
|
@@ -1839,6 +1923,8 @@ var useTPSLAdvanced = (props) => {
|
|
|
1839
1923
|
order: order2,
|
|
1840
1924
|
formattedOrder,
|
|
1841
1925
|
symbolInfo,
|
|
1926
|
+
slPriceError,
|
|
1927
|
+
estLiqPrice: state.estLiqPrice,
|
|
1842
1928
|
setValue,
|
|
1843
1929
|
setValues,
|
|
1844
1930
|
onSubmit,
|
|
@@ -1934,13 +2020,16 @@ var useTPSLDetail = (props) => {
|
|
|
1934
2020
|
var TPSLDetailContext = createContext({});
|
|
1935
2021
|
var TPSLDetailProvider = (props) => {
|
|
1936
2022
|
const symbolInfo = useSymbolsInfo()[props.symbol];
|
|
2023
|
+
const estLiqPrice = useEstLiqPriceBySymbol(props.symbol);
|
|
1937
2024
|
return /* @__PURE__ */ jsx(
|
|
1938
2025
|
TPSLDetailContext.Provider,
|
|
1939
2026
|
{
|
|
1940
2027
|
value: {
|
|
1941
2028
|
base_dp: symbolInfo("base_dp"),
|
|
1942
2029
|
quote_dp: symbolInfo("quote_dp"),
|
|
1943
|
-
|
|
2030
|
+
side: props.position.position_qty > 0 ? OrderSide.BUY : OrderSide.SELL,
|
|
2031
|
+
position: props.position,
|
|
2032
|
+
estLiqPrice
|
|
1944
2033
|
},
|
|
1945
2034
|
children: props.children
|
|
1946
2035
|
}
|
|
@@ -1956,7 +2045,7 @@ var FlexCell = (props) => {
|
|
|
1956
2045
|
direction: "column",
|
|
1957
2046
|
justify: "center",
|
|
1958
2047
|
itemAlign: "start",
|
|
1959
|
-
className: "oui-text-2xs oui-h-[36px]",
|
|
2048
|
+
className: cn("oui-text-2xs oui-h-[36px]", props.className),
|
|
1960
2049
|
children: props.children
|
|
1961
2050
|
}
|
|
1962
2051
|
);
|
|
@@ -2083,9 +2172,65 @@ var TriggerPrice = ({ order: order2 }) => {
|
|
|
2083
2172
|
}
|
|
2084
2173
|
);
|
|
2085
2174
|
};
|
|
2175
|
+
var CloseToLiqPriceIcon = ({
|
|
2176
|
+
slPriceError,
|
|
2177
|
+
className
|
|
2178
|
+
}) => {
|
|
2179
|
+
const { t } = useTranslation();
|
|
2180
|
+
const { isMobile } = useScreen();
|
|
2181
|
+
const { getErrorMsg } = useOrderEntryFormErrorMsg(slPriceError);
|
|
2182
|
+
const isSlPriceWarning = slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
|
|
2183
|
+
const icon = /* @__PURE__ */ jsx(
|
|
2184
|
+
ExclamationFillIcon,
|
|
2185
|
+
{
|
|
2186
|
+
onMouseEnter: (e) => e.stopPropagation(),
|
|
2187
|
+
onMouseLeave: (e) => e.stopPropagation(),
|
|
2188
|
+
onPointerEnter: (e) => e.stopPropagation(),
|
|
2189
|
+
onPointerLeave: (e) => e.stopPropagation(),
|
|
2190
|
+
size: 14,
|
|
2191
|
+
className: cn(
|
|
2192
|
+
"oui-text-warning-darken hover:oui-cursor-pointer",
|
|
2193
|
+
className
|
|
2194
|
+
)
|
|
2195
|
+
}
|
|
2196
|
+
);
|
|
2197
|
+
if (!isSlPriceWarning || !slPriceError)
|
|
2198
|
+
return null;
|
|
2199
|
+
if (isMobile) {
|
|
2200
|
+
return /* @__PURE__ */ jsx(
|
|
2201
|
+
"button",
|
|
2202
|
+
{
|
|
2203
|
+
onClick: (e) => {
|
|
2204
|
+
modal.alert({
|
|
2205
|
+
title: t("common.tips"),
|
|
2206
|
+
message: getErrorMsg("sl_trigger_price")
|
|
2207
|
+
});
|
|
2208
|
+
},
|
|
2209
|
+
className: "oui-px-1",
|
|
2210
|
+
children: icon
|
|
2211
|
+
}
|
|
2212
|
+
);
|
|
2213
|
+
}
|
|
2214
|
+
return /* @__PURE__ */ jsx(
|
|
2215
|
+
Tooltip,
|
|
2216
|
+
{
|
|
2217
|
+
content: getErrorMsg("sl_trigger_price"),
|
|
2218
|
+
className: "oui-max-w-[240px] oui-text-base-contrast-80",
|
|
2219
|
+
children: icon
|
|
2220
|
+
}
|
|
2221
|
+
);
|
|
2222
|
+
};
|
|
2223
|
+
CloseToLiqPriceIcon.displayName = "CloseToLiqPriceIcon";
|
|
2086
2224
|
var TypeRender = ({ order: order2 }) => {
|
|
2225
|
+
const { side, estLiqPrice } = useTPSLDetailContext();
|
|
2087
2226
|
const { tp_trigger_price, sl_trigger_price } = findTPSLFromOrder(order2);
|
|
2088
2227
|
const { t } = useTranslation();
|
|
2228
|
+
const slPriceError = useTpslPriceChecker({
|
|
2229
|
+
slPrice: sl_trigger_price?.toString() ?? void 0,
|
|
2230
|
+
liqPrice: estLiqPrice ?? null,
|
|
2231
|
+
side
|
|
2232
|
+
});
|
|
2233
|
+
const isSlPriceWarning = slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
|
|
2089
2234
|
return /* @__PURE__ */ jsxs(
|
|
2090
2235
|
Flex,
|
|
2091
2236
|
{
|
|
@@ -2095,7 +2240,10 @@ var TypeRender = ({ order: order2 }) => {
|
|
|
2095
2240
|
className: "oui-text-2xs",
|
|
2096
2241
|
children: [
|
|
2097
2242
|
tp_trigger_price && /* @__PURE__ */ jsx(FlexCell, { children: /* @__PURE__ */ jsx(Text, { className: "oui-text-trade-profit", children: t("tpsl.tp") }) }),
|
|
2098
|
-
sl_trigger_price && /* @__PURE__ */
|
|
2243
|
+
sl_trigger_price && /* @__PURE__ */ jsxs(FlexCell, { className: "oui-flex-row oui-items-center oui-gap-1", children: [
|
|
2244
|
+
/* @__PURE__ */ jsx(Text, { className: "oui-text-trade-loss", children: t("tpsl.sl") }),
|
|
2245
|
+
isSlPriceWarning && /* @__PURE__ */ jsx(CloseToLiqPriceIcon, { slPriceError })
|
|
2246
|
+
] })
|
|
2099
2247
|
]
|
|
2100
2248
|
}
|
|
2101
2249
|
);
|
|
@@ -2387,6 +2535,7 @@ var TPSLDetailUI = (props) => {
|
|
|
2387
2535
|
addTPSLOrder,
|
|
2388
2536
|
symbolInfo
|
|
2389
2537
|
} = props;
|
|
2538
|
+
const { estLiqPrice } = useTPSLDetailContext();
|
|
2390
2539
|
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(ScrollArea, { className: cn(isMobile && "oui-h-[calc(100vh-100px)]"), children: [
|
|
2391
2540
|
/* @__PURE__ */ jsx(
|
|
2392
2541
|
OrderInfo,
|
|
@@ -2396,6 +2545,7 @@ var TPSLDetailUI = (props) => {
|
|
|
2396
2545
|
order_quantity: position.position_qty.toString(),
|
|
2397
2546
|
order_price: position.average_open_price.toString()
|
|
2398
2547
|
},
|
|
2548
|
+
estLiqPrice,
|
|
2399
2549
|
symbolLeverage: position.leverage,
|
|
2400
2550
|
baseDP: symbolInfo("base_dp"),
|
|
2401
2551
|
quoteDP: symbolInfo("quote_dp"),
|
|
@@ -3071,8 +3221,19 @@ var useEditBracketOrder = (props) => {
|
|
|
3071
3221
|
props.order
|
|
3072
3222
|
);
|
|
3073
3223
|
const [doUpdateOrder, { isMutating }] = useMutation("/v1/algo/order", "PUT");
|
|
3074
|
-
const
|
|
3075
|
-
|
|
3224
|
+
const maxQty = useEditOrderMaxQty(props.order, props.order.quantity);
|
|
3225
|
+
const {
|
|
3226
|
+
formattedOrder,
|
|
3227
|
+
setValue,
|
|
3228
|
+
setValues,
|
|
3229
|
+
estLiqPrice,
|
|
3230
|
+
metaState,
|
|
3231
|
+
symbolInfo,
|
|
3232
|
+
helper,
|
|
3233
|
+
...state
|
|
3234
|
+
} = useOrderEntry(props.order.symbol, {
|
|
3235
|
+
initialOrder: baseInfo,
|
|
3236
|
+
maxQty
|
|
3076
3237
|
});
|
|
3077
3238
|
const symbol = props.order.symbol;
|
|
3078
3239
|
const isPriceChanged = useMemo(() => {
|
|
@@ -3114,8 +3275,14 @@ var useEditBracketOrder = (props) => {
|
|
|
3114
3275
|
...tpslPriceInfo
|
|
3115
3276
|
});
|
|
3116
3277
|
}, [props.order, setValues]);
|
|
3278
|
+
const slPriceError = useTpslPriceChecker({
|
|
3279
|
+
slPrice: formattedOrder.sl_trigger_price,
|
|
3280
|
+
liqPrice: estLiqPrice,
|
|
3281
|
+
side: formattedOrder.side
|
|
3282
|
+
});
|
|
3283
|
+
const isSlPriceError = slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_ERROR;
|
|
3117
3284
|
const onSubmit = async () => {
|
|
3118
|
-
return helper.validate().then(() => {
|
|
3285
|
+
return helper.validate(isSlPriceError ? slPriceError : void 0).then(() => {
|
|
3119
3286
|
const tpOrder = {
|
|
3120
3287
|
order_id: tpInfo.orderId,
|
|
3121
3288
|
algo_type: AlgoOrderType.TAKE_PROFIT,
|
|
@@ -3155,6 +3322,9 @@ var useEditBracketOrder = (props) => {
|
|
|
3155
3322
|
return {
|
|
3156
3323
|
symbol,
|
|
3157
3324
|
symbolInfo,
|
|
3325
|
+
slPriceError,
|
|
3326
|
+
estLiqPrice,
|
|
3327
|
+
side: formattedOrder.side,
|
|
3158
3328
|
formattedOrder,
|
|
3159
3329
|
setValue,
|
|
3160
3330
|
setValues,
|
|
@@ -3164,10 +3334,22 @@ var useEditBracketOrder = (props) => {
|
|
|
3164
3334
|
isPriceChanged
|
|
3165
3335
|
};
|
|
3166
3336
|
};
|
|
3337
|
+
function useEditOrderMaxQty(order2, positionQty) {
|
|
3338
|
+
const { reduce_only } = order2;
|
|
3339
|
+
const maxQty = useMaxQty(order2.symbol, order2.side, reduce_only);
|
|
3340
|
+
return useMemo(() => {
|
|
3341
|
+
if (reduce_only) {
|
|
3342
|
+
return Math.abs(positionQty ?? 0);
|
|
3343
|
+
}
|
|
3344
|
+
return order2.quantity + Math.abs(maxQty);
|
|
3345
|
+
}, [order2.quantity, maxQty, reduce_only, positionQty]);
|
|
3346
|
+
}
|
|
3167
3347
|
var EditBracketOrderUI = (props) => {
|
|
3168
3348
|
const { t } = useTranslation();
|
|
3169
3349
|
const { errors, validated } = props.metaState;
|
|
3170
3350
|
const { isMobile } = useScreen();
|
|
3351
|
+
const isSlPriceWarning = props.slPriceError?.sl_trigger_price?.type === ERROR_MSG_CODES.SL_PRICE_WARNING;
|
|
3352
|
+
const { getErrorMsg } = useOrderEntryFormErrorMsg(props.slPriceError);
|
|
3171
3353
|
const {
|
|
3172
3354
|
formattedOrder,
|
|
3173
3355
|
setValue: setOrderValue,
|
|
@@ -3235,6 +3417,7 @@ var EditBracketOrderUI = (props) => {
|
|
|
3235
3417
|
order_quantity: formattedOrder.order_quantity,
|
|
3236
3418
|
order_price: formattedOrder.order_price
|
|
3237
3419
|
},
|
|
3420
|
+
estLiqPrice: props.estLiqPrice ?? void 0,
|
|
3238
3421
|
baseDP: symbolInfo.base_dp,
|
|
3239
3422
|
quoteDP: symbolInfo.quote_dp
|
|
3240
3423
|
}
|
|
@@ -3308,6 +3491,14 @@ var EditBracketOrderUI = (props) => {
|
|
|
3308
3491
|
side: formattedOrder.side,
|
|
3309
3492
|
values: slValues,
|
|
3310
3493
|
hideOrderPrice: formattedOrder.position_type === PositionType.FULL,
|
|
3494
|
+
inputWarnNode: isSlPriceWarning && /* @__PURE__ */ jsx(
|
|
3495
|
+
DotStatus,
|
|
3496
|
+
{
|
|
3497
|
+
color: "warning",
|
|
3498
|
+
size: "xs",
|
|
3499
|
+
label: getErrorMsg("sl_trigger_price")
|
|
3500
|
+
}
|
|
3501
|
+
),
|
|
3311
3502
|
errors: validated ? errors : null,
|
|
3312
3503
|
quote_dp: symbolInfo.quote_dp,
|
|
3313
3504
|
positionType: formattedOrder.position_type ?? PositionType.PARTIAL,
|
|
@@ -3370,6 +3561,6 @@ registerSimpleDialog(EditBracketOrderDialogId, EditBracketOrderWidget, {
|
|
|
3370
3561
|
}
|
|
3371
3562
|
});
|
|
3372
3563
|
|
|
3373
|
-
export { ArrowRightIcon, EditBracketOrderDialogId, EditBracketOrderSheetId, EditBracketOrderWidget, PositionTPSLConfirm, PositionTPSLPopover, PositionTPSLSheet, TPSL, TPSLAdvancedDialogId, TPSLAdvancedSheetId, TPSLAdvancedUI, TPSLAdvancedWidget, TPSLDetailDialogId, TPSLDetailSheetId, TPSLDetailWidget, TPSLDialogId, TPSLPositionTypeWidget, TPSLSheetId, TPSLSimpleDialogId, TPSLSimpleDialogUI, TPSLSimpleDialogWidget, TPSLSimpleSheetId, TPSLWidget, useTPSLAdvanced, useTPSLBuilder, useTPSLSimpleDialog };
|
|
3564
|
+
export { ArrowRightIcon, CloseToLiqPriceIcon, EditBracketOrderDialogId, EditBracketOrderSheetId, EditBracketOrderWidget, PositionTPSLConfirm, PositionTPSLPopover, PositionTPSLSheet, TPSL, TPSLAdvancedDialogId, TPSLAdvancedSheetId, TPSLAdvancedUI, TPSLAdvancedWidget, TPSLDetailDialogId, TPSLDetailSheetId, TPSLDetailWidget, TPSLDialogId, TPSLPositionTypeWidget, TPSLSheetId, TPSLSimpleDialogId, TPSLSimpleDialogUI, TPSLSimpleDialogWidget, TPSLSimpleSheetId, TPSLWidget, useTPSLAdvanced, useTPSLBuilder, useTPSLSimpleDialog };
|
|
3374
3565
|
//# sourceMappingURL=out.js.map
|
|
3375
3566
|
//# sourceMappingURL=index.mjs.map
|