@orderly.network/ui-tpsl 3.0.0-beta.1 → 3.0.0-beta.3
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +43 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, SVGProps } from 'react';
|
|
3
3
|
import * as _orderly_network_types from '@orderly.network/types';
|
|
4
|
-
import { API, AlgoOrderRootType, PositionType, OrderSide, OrderlyOrder, AlgoOrder } from '@orderly.network/types';
|
|
4
|
+
import { API, AlgoOrderRootType, PositionType, OrderSide, OrderlyOrder, AlgoOrder, MarginMode } from '@orderly.network/types';
|
|
5
5
|
import { ButtonProps } from '@orderly.network/ui';
|
|
6
6
|
import * as _orderly_network_hooks from '@orderly.network/hooks';
|
|
7
7
|
import { ComputedAlgoOrder, OrderValidationResult } from '@orderly.network/hooks';
|
|
@@ -284,6 +284,7 @@ declare const TPSLSimpleDialogWidget: React.FC<{
|
|
|
284
284
|
symbol: string;
|
|
285
285
|
close?: () => void;
|
|
286
286
|
onComplete?: () => void;
|
|
287
|
+
marginMode?: MarginMode;
|
|
287
288
|
showAdvancedTPSLDialog?: () => void;
|
|
288
289
|
}>;
|
|
289
290
|
declare const TPSLSimpleSheetId = "TPSLSimpleSheetId";
|
|
@@ -293,6 +294,7 @@ type TPSLBuilderOptions = {
|
|
|
293
294
|
type: "tp" | "sl";
|
|
294
295
|
triggerPrice?: number;
|
|
295
296
|
symbol: string;
|
|
297
|
+
marginMode?: MarginMode;
|
|
296
298
|
};
|
|
297
299
|
declare const useTPSLSimpleDialog: (options: TPSLBuilderOptions) => {
|
|
298
300
|
readonly symbolInfo: (<Key extends keyof API.SymbolExt>(key: Key, defaultValue?: API.SymbolExt[Key] | undefined) => API.SymbolExt[Key]) & (() => API.SymbolExt);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode, SVGProps } from 'react';
|
|
3
3
|
import * as _orderly_network_types from '@orderly.network/types';
|
|
4
|
-
import { API, AlgoOrderRootType, PositionType, OrderSide, OrderlyOrder, AlgoOrder } from '@orderly.network/types';
|
|
4
|
+
import { API, AlgoOrderRootType, PositionType, OrderSide, OrderlyOrder, AlgoOrder, MarginMode } from '@orderly.network/types';
|
|
5
5
|
import { ButtonProps } from '@orderly.network/ui';
|
|
6
6
|
import * as _orderly_network_hooks from '@orderly.network/hooks';
|
|
7
7
|
import { ComputedAlgoOrder, OrderValidationResult } from '@orderly.network/hooks';
|
|
@@ -284,6 +284,7 @@ declare const TPSLSimpleDialogWidget: React.FC<{
|
|
|
284
284
|
symbol: string;
|
|
285
285
|
close?: () => void;
|
|
286
286
|
onComplete?: () => void;
|
|
287
|
+
marginMode?: MarginMode;
|
|
287
288
|
showAdvancedTPSLDialog?: () => void;
|
|
288
289
|
}>;
|
|
289
290
|
declare const TPSLSimpleSheetId = "TPSLSimpleSheetId";
|
|
@@ -293,6 +294,7 @@ type TPSLBuilderOptions = {
|
|
|
293
294
|
type: "tp" | "sl";
|
|
294
295
|
triggerPrice?: number;
|
|
295
296
|
symbol: string;
|
|
297
|
+
marginMode?: MarginMode;
|
|
296
298
|
};
|
|
297
299
|
declare const useTPSLSimpleDialog: (options: TPSLBuilderOptions) => {
|
|
298
300
|
readonly symbolInfo: (<Key extends keyof API.SymbolExt>(key: Key, defaultValue?: API.SymbolExt[Key] | undefined) => API.SymbolExt[Key]) & (() => API.SymbolExt);
|
package/dist/index.js
CHANGED
|
@@ -12,12 +12,20 @@ var perp = require('@orderly.network/perp');
|
|
|
12
12
|
var uiConnector = require('@orderly.network/ui-connector');
|
|
13
13
|
|
|
14
14
|
// src/editorPopover.tsx
|
|
15
|
+
var SymbolBadge = (props) => {
|
|
16
|
+
const { brokerId, brokerName, brokerNameRaw } = hooks.useBadgeBySymbol(
|
|
17
|
+
props.symbol
|
|
18
|
+
);
|
|
19
|
+
const badge = brokerName ?? brokerId ?? void 0;
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.SymbolBadge, { badge, fullName: brokerNameRaw });
|
|
21
|
+
};
|
|
15
22
|
var OrderInfo = (props) => {
|
|
16
23
|
const { t } = i18n.useTranslation();
|
|
17
24
|
const { order: order2, symbolLeverage } = props;
|
|
18
25
|
const { symbol } = order2;
|
|
19
26
|
const markPrice = hooks.useMarkPrice(symbol);
|
|
20
27
|
const indexPrice = hooks.useIndexPrice(symbol);
|
|
28
|
+
const marginModeLabel = props.marginMode === types.MarginMode.ISOLATED ? t("marginMode.isolated") : props.marginMode === types.MarginMode.CROSS ? t("marginMode.cross") : void 0;
|
|
21
29
|
const leverage = hooks.useLeverageBySymbol(
|
|
22
30
|
symbolLeverage ? void 0 : symbol,
|
|
23
31
|
props.marginMode
|
|
@@ -46,20 +54,21 @@ var OrderInfo = (props) => {
|
|
|
46
54
|
{
|
|
47
55
|
className: "oui-whitespace-nowrap oui-break-normal",
|
|
48
56
|
rule: "symbol",
|
|
49
|
-
formatString: "base
|
|
57
|
+
formatString: "base",
|
|
50
58
|
size: "sm",
|
|
51
59
|
weight: "semibold",
|
|
52
60
|
intensity: 98,
|
|
61
|
+
suffix: /* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol: symbol ?? "" }),
|
|
53
62
|
children: symbol
|
|
54
63
|
}
|
|
55
64
|
)
|
|
56
65
|
] }),
|
|
57
|
-
|
|
66
|
+
marginModeLabel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
67
|
ui.Text,
|
|
59
68
|
{
|
|
60
69
|
size: "2xs",
|
|
61
70
|
className: "oui-h-[18px] oui-rounded oui-bg-base-7 oui-px-2 oui-font-semibold oui-text-base-contrast-36",
|
|
62
|
-
children:
|
|
71
|
+
children: marginModeLabel
|
|
63
72
|
}
|
|
64
73
|
),
|
|
65
74
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -255,6 +264,7 @@ var useTPSLInputRowScript = (props) => {
|
|
|
255
264
|
});
|
|
256
265
|
return roi2 * 100;
|
|
257
266
|
} catch (error) {
|
|
267
|
+
console.error("error", error);
|
|
258
268
|
return null;
|
|
259
269
|
}
|
|
260
270
|
}, [values, leverage, rootOrderPrice, type, side]);
|
|
@@ -831,10 +841,10 @@ var TPSLQuantity = react.memo((props) => {
|
|
|
831
841
|
tooltip: errorMsg,
|
|
832
842
|
color: errorMsg ? "danger" : void 0,
|
|
833
843
|
formatters: [
|
|
844
|
+
ui.inputFormatter.decimalPointFormatter,
|
|
834
845
|
ui.inputFormatter.dpFormatter(props.base_dp),
|
|
835
846
|
ui.inputFormatter.numberFormatter,
|
|
836
|
-
ui.inputFormatter.currencyFormatter
|
|
837
|
-
ui.inputFormatter.decimalPointFormatter
|
|
847
|
+
ui.inputFormatter.currencyFormatter
|
|
838
848
|
],
|
|
839
849
|
onValueChange: (value) => {
|
|
840
850
|
props.onQuantityChange?.(value);
|
|
@@ -1106,6 +1116,7 @@ var TPSL = (props) => {
|
|
|
1106
1116
|
props.close?.();
|
|
1107
1117
|
onComplete?.();
|
|
1108
1118
|
}).catch((err) => {
|
|
1119
|
+
console.log("--->>>cancel order", err);
|
|
1109
1120
|
});
|
|
1110
1121
|
},
|
|
1111
1122
|
children: t("common.confirm")
|
|
@@ -1184,21 +1195,25 @@ var PositionTPSLConfirm = (props) => {
|
|
|
1184
1195
|
);
|
|
1185
1196
|
};
|
|
1186
1197
|
const isPositionTPSL = _isPositionTPSL;
|
|
1198
|
+
const displaySymbol = hooks.useSymbolWithBroker(symbol);
|
|
1187
1199
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1188
|
-
isEditing && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "div", size: "2xs", intensity: 80, className: "oui-mb-3", children: t("tpsl.agreement", { symbol:
|
|
1200
|
+
isEditing && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "div", size: "2xs", intensity: 80, className: "oui-mb-3", children: t("tpsl.agreement", { symbol: displaySymbol }) }),
|
|
1189
1201
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { pb: 4, children: [
|
|
1190
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1191
|
-
ui.
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, grow: true, children: [
|
|
1203
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { grow: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1204
|
+
ui.Text.formatted,
|
|
1205
|
+
{
|
|
1206
|
+
rule: "symbol",
|
|
1207
|
+
formatString: "base",
|
|
1208
|
+
size: "base",
|
|
1209
|
+
showIcon: true,
|
|
1210
|
+
as: "div",
|
|
1211
|
+
intensity: 80,
|
|
1212
|
+
children: symbol
|
|
1213
|
+
}
|
|
1214
|
+
) }),
|
|
1215
|
+
/* @__PURE__ */ jsxRuntime.jsx(SymbolBadge, { symbol })
|
|
1216
|
+
] }),
|
|
1202
1217
|
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
|
|
1203
1218
|
isPositionTPSL && /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "xs", color: "primary", children: t("common.position") }),
|
|
1204
1219
|
/* @__PURE__ */ jsxRuntime.jsx(TPSLOrderType, { tpPrice, slPrice }),
|
|
@@ -1343,9 +1358,10 @@ var useTPSLBuilder = (options) => {
|
|
|
1343
1358
|
const [needConfirm] = hooks.useLocalStorage("orderly_order_confirm", true);
|
|
1344
1359
|
const { marginMode: symbolMarginMode } = hooks.useMarginModeBySymbol(symbol);
|
|
1345
1360
|
const [{ rows: positions }] = hooks.usePositionStream();
|
|
1346
|
-
const mainAccountPosition = positions.find(
|
|
1347
|
-
|
|
1348
|
-
|
|
1361
|
+
const mainAccountPosition = positions.find((item) => {
|
|
1362
|
+
const marginMode = options.position?.margin_mode ?? symbolMarginMode;
|
|
1363
|
+
return item.symbol === symbol && item.margin_mode === marginMode;
|
|
1364
|
+
});
|
|
1349
1365
|
const isSubAccount = options.position?.account_id && options.position?.account_id !== state.mainAccountId;
|
|
1350
1366
|
const position = isSubAccount ? options.position : mainAccountPosition;
|
|
1351
1367
|
const estLiqPrice = hooks.useEstLiqPriceBySymbol(
|
|
@@ -1953,6 +1969,8 @@ var useTPSLAdvanced = (props) => {
|
|
|
1953
1969
|
helper.validate(isSlPriceError ? slPriceError : void 0).then(() => {
|
|
1954
1970
|
props.onSubmit(formattedOrder);
|
|
1955
1971
|
}).catch((err) => {
|
|
1972
|
+
console.log("metaState", metaState);
|
|
1973
|
+
console.log("err", err);
|
|
1956
1974
|
});
|
|
1957
1975
|
};
|
|
1958
1976
|
return {
|
|
@@ -2618,6 +2636,7 @@ var TPSLDetailUI = (props) => {
|
|
|
2618
2636
|
symbolInfo
|
|
2619
2637
|
} = props;
|
|
2620
2638
|
const { estLiqPrice } = useTPSLDetailContext();
|
|
2639
|
+
console.log("----- position", position);
|
|
2621
2640
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.ScrollArea, { className: ui.cn(isMobile && "oui-h-[calc(100vh-100px)]"), children: [
|
|
2622
2641
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2623
2642
|
OrderInfo,
|
|
@@ -2912,9 +2931,8 @@ ui.registerSimpleSheet(TPSLDetailSheetId, TPSLDetailWidget, {
|
|
|
2912
2931
|
}
|
|
2913
2932
|
});
|
|
2914
2933
|
var useTPSLSimpleDialog = (options) => {
|
|
2915
|
-
const { type, triggerPrice, symbol } = options;
|
|
2934
|
+
const { type, triggerPrice, symbol, marginMode } = options;
|
|
2916
2935
|
const symbolInfo = hooks.useSymbolsInfo();
|
|
2917
|
-
const { marginMode } = hooks.useMarginModeBySymbol(symbol ?? "");
|
|
2918
2936
|
const [{ rows: positions }, positionsInfo] = hooks.usePositionStream(symbol);
|
|
2919
2937
|
const position = positions?.find((item) => item.margin_mode === marginMode);
|
|
2920
2938
|
react.useRef(types.AlgoOrderRootType.TP_SL);
|
|
@@ -3164,7 +3182,7 @@ var TPSLSimpleDialogUI = (props) => {
|
|
|
3164
3182
|
TPSLQuantity,
|
|
3165
3183
|
{
|
|
3166
3184
|
maxQty: props.maxQty,
|
|
3167
|
-
quantity:
|
|
3185
|
+
quantity: props.orderQuantity ?? props.maxQty,
|
|
3168
3186
|
baseTick: props.symbolInfo("base_tick"),
|
|
3169
3187
|
base_dp: props.symbolInfo("base_dp"),
|
|
3170
3188
|
base: props.symbolInfo("base"),
|
|
@@ -3633,6 +3651,7 @@ var EditBracketOrderUI = (props) => {
|
|
|
3633
3651
|
props.onSubmit().then(() => {
|
|
3634
3652
|
props.onClose?.();
|
|
3635
3653
|
}).catch((err) => {
|
|
3654
|
+
console.log("--->>>cancel order", err);
|
|
3636
3655
|
});
|
|
3637
3656
|
},
|
|
3638
3657
|
children: t("common.confirm")
|