@orderly.network/ui-order-entry 2.10.0 → 2.10.1-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.js +126 -271
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -154
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React2 = require('react');
|
|
4
4
|
var hooks = require('@orderly.network/hooks');
|
|
5
5
|
var i18n = require('@orderly.network/i18n');
|
|
6
6
|
var reactApp = require('@orderly.network/react-app');
|
|
@@ -10,13 +10,12 @@ var uiTpsl = require('@orderly.network/ui-tpsl');
|
|
|
10
10
|
var utils = require('@orderly.network/utils');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
12
|
var uiConnector = require('@orderly.network/ui-connector');
|
|
13
|
-
var uiScaffold = require('@orderly.network/ui-scaffold');
|
|
14
13
|
var perp = require('@orderly.network/perp');
|
|
15
14
|
var uiLeverage = require('@orderly.network/ui-leverage');
|
|
16
15
|
|
|
17
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
17
|
|
|
19
|
-
var
|
|
18
|
+
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
20
19
|
|
|
21
20
|
// src/orderEntry.ui.tsx
|
|
22
21
|
var AdditionalInfo = (props) => {
|
|
@@ -31,7 +30,7 @@ var AdditionalInfo = (props) => {
|
|
|
31
30
|
);
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
|
-
|
|
33
|
+
React2.useEffect(() => {
|
|
35
34
|
props.onValueChange?.("visible_quantity", props.hidden ? 0 : 1);
|
|
36
35
|
}, [props.hidden]);
|
|
37
36
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-base-contrast-54", children: [
|
|
@@ -226,7 +225,7 @@ var AdditionalInfo = (props) => {
|
|
|
226
225
|
] });
|
|
227
226
|
};
|
|
228
227
|
function AdditionalConfigButton(props) {
|
|
229
|
-
const [open2, setOpen] =
|
|
228
|
+
const [open2, setOpen] = React2.useState(false);
|
|
230
229
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.PopoverRoot, { open: open2, onOpenChange: setOpen, children: [
|
|
231
230
|
/* @__PURE__ */ jsxRuntime.jsx(ui.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
232
231
|
"button",
|
|
@@ -259,7 +258,7 @@ function AdditionalConfigButton(props) {
|
|
|
259
258
|
}
|
|
260
259
|
var defaultPath = "M10.007 1.302a.74.74 0 0 0-.486.214c-1.033.989-1.349 1.815-.972 2.948-.88.675-1.437.84-2.536.84-1.503 0-2.484.182-3.152.85v.02a1.583 1.583 0 0 0 0 2.248l1.867 1.882-3.181 3.18c-.26.26-.28.696-.02.956.261.26.699.26.959 0l3.193-3.194 1.87 1.861a1.585 1.585 0 0 0 2.25 0h.02c.668-.667.854-1.523.854-3.144 0-1.03.212-1.758.852-2.523 1.233.361 1.95.015 2.961-.995a.68.68 0 0 0 .188-.48c0-.234-.06-.593-.209-1.04a5.34 5.34 0 0 0-1.312-2.103 5.35 5.35 0 0 0-2.104-1.312c-.448-.15-.808-.208-1.042-.208";
|
|
261
260
|
var PinButton = (props) => {
|
|
262
|
-
const [path, setPath] =
|
|
261
|
+
const [path, setPath] = React2.useState(defaultPath);
|
|
263
262
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
264
263
|
"svg",
|
|
265
264
|
{
|
|
@@ -509,142 +508,6 @@ var EditIcon = (props) => {
|
|
|
509
508
|
}
|
|
510
509
|
);
|
|
511
510
|
};
|
|
512
|
-
var EffectiveFee = React3__default.default.forwardRef((props, ref) => {
|
|
513
|
-
const linearId = React3.useId();
|
|
514
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
515
|
-
"svg",
|
|
516
|
-
{
|
|
517
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
518
|
-
width: 14,
|
|
519
|
-
height: 14,
|
|
520
|
-
viewBox: "0 0 14 14",
|
|
521
|
-
fill: "currentColor",
|
|
522
|
-
ref,
|
|
523
|
-
focusable: false,
|
|
524
|
-
...props,
|
|
525
|
-
children: [
|
|
526
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
527
|
-
"path",
|
|
528
|
-
{
|
|
529
|
-
d: "M6.16411 1.53106C6.61974 1.07566 7.35888 1.07551 7.81442 1.53106L8.48833 2.20496C8.6797 2.39624 8.93064 2.51452 9.19755 2.54106L9.3132 2.54676H10.2662C10.9104 2.54691 11.4328 3.06926 11.4329 3.71343V4.66647C11.4329 4.97589 11.5559 5.27312 11.7747 5.49191L12.4492 6.16582C12.9047 6.62142 12.9047 7.36054 12.4492 7.81613L11.7753 8.49004L11.6972 8.57549C11.5272 8.78302 11.433 9.04426 11.4329 9.31491V10.2685L11.4272 10.3876C11.3715 10.9366 10.9348 11.373 10.3859 11.4289L10.2662 11.4352H9.3132L9.19755 11.4409C8.93066 11.4674 8.67969 11.5857 8.48833 11.777L7.81442 12.4509L7.72555 12.5306C7.29789 12.8795 6.68066 12.8794 6.25297 12.5306L6.16411 12.4509L5.4902 11.777C5.29887 11.5857 5.04786 11.4675 4.78097 11.4409L4.66533 11.4352H3.71171L3.59265 11.4289C3.04358 11.3731 2.60705 10.9367 2.55131 10.3876L2.54505 10.2685V9.31491C2.54499 9.04416 2.45089 8.78306 2.28072 8.57549L2.20325 8.49004L1.52934 7.81613C1.10213 7.38905 1.07534 6.71297 1.44902 6.25469L1.52934 6.16582L2.20382 5.49191C2.42248 5.27314 2.54505 4.97579 2.54505 4.66647V3.71343C2.54513 3.10945 3.00442 2.61221 3.59265 2.55246L3.71171 2.54676H4.66533L4.78097 2.54106C5.00968 2.51826 5.22694 2.4281 5.40475 2.28244L5.4902 2.20496L6.16411 1.53106ZM6.31507 3.02983C5.87756 3.46727 5.28401 3.71336 4.66533 3.71343H3.71171V4.66647C3.71171 5.28521 3.46614 5.87922 3.02869 6.31678L2.35421 6.99069L3.02812 7.6646C3.46577 8.10214 3.71164 8.69607 3.71171 9.31491V10.2685H4.66533C5.28396 10.2686 5.87757 10.5142 6.31507 10.9515L6.98898 11.6255L7.66289 10.9515C8.10045 10.5141 8.69446 10.2685 9.3132 10.2685H10.2662V9.31491C10.2663 8.69604 10.5127 8.10214 10.9504 7.6646L11.6243 6.99069L10.9498 6.31678C10.5122 5.8792 10.2662 5.28531 10.2662 4.66647V3.71343H9.3132C8.69438 3.71343 8.10047 3.46739 7.66289 3.02983L6.98898 2.35592L6.31507 3.02983ZM8.52934 4.64255C8.7571 4.41479 9.12639 4.41489 9.35421 4.64255C9.58202 4.87035 9.58202 5.23961 9.35421 5.46742L5.4657 9.35593C5.2379 9.58372 4.86863 9.58373 4.64083 9.35593C4.41318 9.12811 4.41308 8.75881 4.64083 8.53106L8.52934 4.64255ZM8.66435 7.83265C9.1245 7.83272 9.49777 8.2059 9.49777 8.66607C9.49769 9.12616 9.12445 9.49941 8.66435 9.49948C8.20419 9.49948 7.83101 9.12621 7.83094 8.66607C7.83094 8.20586 8.20415 7.83265 8.66435 7.83265ZM5.33126 4.49956C5.79141 4.49963 6.16468 4.87282 6.16468 5.33298C6.1646 5.79307 5.79136 6.16575 5.33126 6.16582C4.87111 6.16582 4.49793 5.79311 4.49785 5.33298C4.49785 4.87277 4.87106 4.49956 5.33126 4.49956Z",
|
|
530
|
-
fill: `url(#${linearId})`
|
|
531
|
-
}
|
|
532
|
-
),
|
|
533
|
-
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
534
|
-
"linearGradient",
|
|
535
|
-
{
|
|
536
|
-
id: linearId,
|
|
537
|
-
x1: "12.7908",
|
|
538
|
-
y1: "6.99084",
|
|
539
|
-
x2: "1.1875",
|
|
540
|
-
y2: "6.99084",
|
|
541
|
-
gradientUnits: "userSpaceOnUse",
|
|
542
|
-
children: [
|
|
543
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-end))" }),
|
|
544
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "rgb(var(--oui-gradient-brand-start))", offset: 1 })
|
|
545
|
-
]
|
|
546
|
-
}
|
|
547
|
-
) })
|
|
548
|
-
]
|
|
549
|
-
}
|
|
550
|
-
);
|
|
551
|
-
});
|
|
552
|
-
if (process.env.NODE_ENV !== "production") {
|
|
553
|
-
EffectiveFee.displayName = "EffectiveFee";
|
|
554
|
-
}
|
|
555
|
-
var EffectiveFeeBody = ({ routerAdapter, onClose }) => {
|
|
556
|
-
const { t } = i18n.useTranslation();
|
|
557
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: "2xs", className: "oui-whitespace-normal oui-break-words", children: [
|
|
558
|
-
t("portfolio.feeTier.effectiveFee.tooltip"),
|
|
559
|
-
" ",
|
|
560
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
561
|
-
"a",
|
|
562
|
-
{
|
|
563
|
-
href: "/rewards/affiliate",
|
|
564
|
-
onClick: (e) => {
|
|
565
|
-
e.preventDefault();
|
|
566
|
-
routerAdapter?.onRouteChange({
|
|
567
|
-
href: "/rewards/affiliate",
|
|
568
|
-
name: t("portfolio.feeTier.effectiveFee.tooltipLink")
|
|
569
|
-
});
|
|
570
|
-
onClose?.();
|
|
571
|
-
},
|
|
572
|
-
className: "oui-cursor-pointer oui-border-none oui-bg-transparent oui-p-0 oui-text-2xs oui-underline hover:oui-text-base-contrast-80",
|
|
573
|
-
children: t("portfolio.feeTier.effectiveFee.tooltipLink")
|
|
574
|
-
}
|
|
575
|
-
)
|
|
576
|
-
] });
|
|
577
|
-
};
|
|
578
|
-
var EffectiveFeeMobileContent = ({ routerAdapter }) => {
|
|
579
|
-
const { hide } = ui.useModal();
|
|
580
|
-
return /* @__PURE__ */ jsxRuntime.jsx(EffectiveFeeBody, { routerAdapter, onClose: hide });
|
|
581
|
-
};
|
|
582
|
-
var EffectiveFeeSection = (props) => {
|
|
583
|
-
const { routerAdapter } = props;
|
|
584
|
-
const { isMobile } = ui.useScreen();
|
|
585
|
-
const { t } = i18n.useTranslation();
|
|
586
|
-
if (isMobile) {
|
|
587
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
588
|
-
EffectiveFee,
|
|
589
|
-
{
|
|
590
|
-
onClick: () => {
|
|
591
|
-
ui.modal.dialog({
|
|
592
|
-
size: "sm",
|
|
593
|
-
title: t("common.tips"),
|
|
594
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(EffectiveFeeMobileContent, { routerAdapter })
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
601
|
-
ui.Tooltip,
|
|
602
|
-
{
|
|
603
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(EffectiveFeeBody, { routerAdapter }),
|
|
604
|
-
className: "oui-p-1.5 oui-text-base-contrast-54",
|
|
605
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(EffectiveFee, { className: "oui-cursor-pointer" })
|
|
606
|
-
}
|
|
607
|
-
);
|
|
608
|
-
};
|
|
609
|
-
var EffectiveFeeUI = (props) => {
|
|
610
|
-
const { t } = i18n.useTranslation();
|
|
611
|
-
const { routerAdapter } = uiScaffold.useScaffoldContext();
|
|
612
|
-
const { taker, maker } = props;
|
|
613
|
-
const originalTrailingFees = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { itemAlign: "center", justify: "between", width: "100%", gap: 1, children: [
|
|
614
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "100%", itemAlign: "center", justify: "between", children: [
|
|
615
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-truncate", size: "2xs", children: t("common.fees") }),
|
|
616
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
617
|
-
uiConnector.AuthGuard,
|
|
618
|
-
{
|
|
619
|
-
fallback: () => /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "oui-truncate", size: "2xs", children: [
|
|
620
|
-
t("dmm.taker"),
|
|
621
|
-
": --% / ",
|
|
622
|
-
t("dmm.maker"),
|
|
623
|
-
": --%"
|
|
624
|
-
] }),
|
|
625
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, children: [
|
|
626
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "oui-truncate", size: "2xs", children: [
|
|
627
|
-
t("dmm.taker"),
|
|
628
|
-
":"
|
|
629
|
-
] }),
|
|
630
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", className: "oui-text-base-contrast-80", children: taker }),
|
|
631
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", children: "/" }),
|
|
632
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { className: "oui-truncate", size: "2xs", children: [
|
|
633
|
-
t("dmm.maker"),
|
|
634
|
-
":"
|
|
635
|
-
] }),
|
|
636
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "2xs", className: "oui-text-base-contrast-80", children: maker })
|
|
637
|
-
] })
|
|
638
|
-
}
|
|
639
|
-
)
|
|
640
|
-
] }),
|
|
641
|
-
/* @__PURE__ */ jsxRuntime.jsx(EffectiveFeeSection, { routerAdapter })
|
|
642
|
-
] });
|
|
643
|
-
return originalTrailingFees;
|
|
644
|
-
};
|
|
645
|
-
var EffectiveFeesWidget = (props) => {
|
|
646
|
-
return /* @__PURE__ */ jsxRuntime.jsx(EffectiveFeeUI, { ...props });
|
|
647
|
-
};
|
|
648
511
|
var RegularFeesUI = (props) => {
|
|
649
512
|
const { t } = i18n.useTranslation();
|
|
650
513
|
const { taker, maker } = props;
|
|
@@ -680,36 +543,28 @@ var RegularFeesUI = (props) => {
|
|
|
680
543
|
var RegularFeesWidget = (props) => {
|
|
681
544
|
return /* @__PURE__ */ jsxRuntime.jsx(RegularFeesUI, { ...props });
|
|
682
545
|
};
|
|
683
|
-
var isEffective = (val) => typeof val !== "undefined" && val !== null;
|
|
684
546
|
var FeesWidget = ({ symbol }) => {
|
|
685
|
-
const {
|
|
547
|
+
const { takerFee, makerFee, rwaTakerFee, rwaMakerFee } = hooks.useFeeState();
|
|
686
548
|
const info = hooks.useRwaSymbolsInfoStore();
|
|
687
549
|
const isRwa = info?.[symbol] !== void 0;
|
|
688
|
-
|
|
689
|
-
return isEffectiveFee ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
690
|
-
EffectiveFeesWidget,
|
|
691
|
-
{
|
|
692
|
-
taker: isRwa ? others.rwaEffectiveTakerFee : others.effectiveTakerFee,
|
|
693
|
-
maker: isRwa ? others.rwaEffectiveMakerFee : others.effectiveMakerFee
|
|
694
|
-
}
|
|
695
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
550
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
696
551
|
RegularFeesWidget,
|
|
697
552
|
{
|
|
698
|
-
taker: isRwa ?
|
|
699
|
-
maker: isRwa ?
|
|
553
|
+
taker: isRwa ? rwaTakerFee : takerFee,
|
|
554
|
+
maker: isRwa ? rwaMakerFee : makerFee
|
|
700
555
|
}
|
|
701
556
|
);
|
|
702
557
|
};
|
|
703
558
|
var options = [0.01, 0.05, 0.1];
|
|
704
|
-
var SlippageEditor =
|
|
559
|
+
var SlippageEditor = React2.forwardRef((props, ref) => {
|
|
705
560
|
const { t } = i18n.useTranslation();
|
|
706
|
-
const [value, setValue] =
|
|
707
|
-
const [customValue, setCustomValue] =
|
|
708
|
-
const [error, setError] =
|
|
709
|
-
|
|
561
|
+
const [value, setValue] = React2.useState();
|
|
562
|
+
const [customValue, setCustomValue] = React2.useState("");
|
|
563
|
+
const [error, setError] = React2.useState(void 0);
|
|
564
|
+
React2.useImperativeHandle(ref, () => ({
|
|
710
565
|
getValue: () => customValue ? new utils.Decimal(customValue)?.toNumber() : value
|
|
711
566
|
}));
|
|
712
|
-
|
|
567
|
+
React2.useEffect(() => {
|
|
713
568
|
if (props.initialValue && !options.includes(props.initialValue)) {
|
|
714
569
|
setCustomValue(props.initialValue.toString());
|
|
715
570
|
} else {
|
|
@@ -826,7 +681,7 @@ var SlippageCell = (props) => {
|
|
|
826
681
|
const { t } = i18n.useTranslation();
|
|
827
682
|
const [open2, { setTrue: setOpen, setFalse: setClose, toggle }] = hooks.useBoolean(false);
|
|
828
683
|
const { isMobile } = ui.useScreen();
|
|
829
|
-
const slippageRef =
|
|
684
|
+
const slippageRef = React2.useRef(null);
|
|
830
685
|
const onConfirm = () => {
|
|
831
686
|
const val = slippageRef.current?.getValue();
|
|
832
687
|
props.setSlippage(!val ? "1" : val.toString());
|
|
@@ -1091,7 +946,7 @@ var useLTVTooltipScript = () => {
|
|
|
1091
946
|
};
|
|
1092
947
|
});
|
|
1093
948
|
const currentLtv = hooks.useComputedLTV();
|
|
1094
|
-
const onConvert =
|
|
949
|
+
const onConvert = React2.useCallback(async () => {
|
|
1095
950
|
return ui.modal.show("ConvertDialogId");
|
|
1096
951
|
}, []);
|
|
1097
952
|
return {
|
|
@@ -1112,7 +967,7 @@ var Available = (props) => {
|
|
|
1112
967
|
const { canTrade, currentLtv, quote, freeCollateral } = props;
|
|
1113
968
|
const { t } = i18n.useTranslation();
|
|
1114
969
|
const { isMobile } = ui.useScreen();
|
|
1115
|
-
const showLTV =
|
|
970
|
+
const showLTV = React2.useMemo(() => {
|
|
1116
971
|
return typeof currentLtv === "number" && !Number.isNaN(currentLtv) && currentLtv > 0;
|
|
1117
972
|
}, [currentLtv]);
|
|
1118
973
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { itemAlign: "center", justify: "between", children: [
|
|
@@ -1530,7 +1385,7 @@ var OrderItem = (props) => {
|
|
|
1530
1385
|
OrderConfirmDialog.displayName = "OrderConfirmDialog";
|
|
1531
1386
|
var OrderTypeTag = (props) => {
|
|
1532
1387
|
const { t } = i18n.useTranslation();
|
|
1533
|
-
const typeStr =
|
|
1388
|
+
const typeStr = React2.useMemo(() => {
|
|
1534
1389
|
switch (props.type) {
|
|
1535
1390
|
case types.OrderType.LIMIT:
|
|
1536
1391
|
return t("orderEntry.orderType.limit");
|
|
@@ -1570,7 +1425,7 @@ ui.registerSimpleDialog(orderConfirmDialogId, Dialog, {
|
|
|
1570
1425
|
size: "sm",
|
|
1571
1426
|
title: () => i18n.i18n.t("orderEntry.orderConfirm")
|
|
1572
1427
|
});
|
|
1573
|
-
var MaxQtyConfirm =
|
|
1428
|
+
var MaxQtyConfirm = React2.memo((props) => {
|
|
1574
1429
|
const { t } = i18n.useTranslation();
|
|
1575
1430
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1576
1431
|
ui.SimpleDialog,
|
|
@@ -1616,7 +1471,7 @@ var ScaledOrderConfirm = (props) => {
|
|
|
1616
1471
|
props.resolve();
|
|
1617
1472
|
props.close?.();
|
|
1618
1473
|
};
|
|
1619
|
-
const columns =
|
|
1474
|
+
const columns = React2.useMemo(() => {
|
|
1620
1475
|
return [
|
|
1621
1476
|
{
|
|
1622
1477
|
title: t("common.symbol"),
|
|
@@ -1760,7 +1615,7 @@ var ScaledOrderConfirm = (props) => {
|
|
|
1760
1615
|
] })
|
|
1761
1616
|
] });
|
|
1762
1617
|
};
|
|
1763
|
-
var TooltipIcon =
|
|
1618
|
+
var TooltipIcon = React2.forwardRef(
|
|
1764
1619
|
(props, ref) => {
|
|
1765
1620
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1766
1621
|
"svg",
|
|
@@ -1779,13 +1634,13 @@ var TooltipIcon = React3.forwardRef(
|
|
|
1779
1634
|
);
|
|
1780
1635
|
function useAskAndBid() {
|
|
1781
1636
|
const ee = hooks.useEventEmitter();
|
|
1782
|
-
const [askAndBid, setAskAndBid] =
|
|
1637
|
+
const [askAndBid, setAskAndBid] = React2.useState([0, 0]);
|
|
1783
1638
|
const onOrderBookUpdate = hooks.useDebouncedCallback((data) => {
|
|
1784
1639
|
const ask0 = data.asks?.[data.asks.length - 1]?.[0];
|
|
1785
1640
|
const bid0 = data.bids?.[0]?.[0];
|
|
1786
1641
|
setAskAndBid([ask0, bid0]);
|
|
1787
1642
|
}, 200);
|
|
1788
|
-
|
|
1643
|
+
React2.useEffect(() => {
|
|
1789
1644
|
ee.on("orderbook:update", onOrderBookUpdate);
|
|
1790
1645
|
return () => {
|
|
1791
1646
|
ee.off("orderbook:update", onOrderBookUpdate);
|
|
@@ -1800,13 +1655,13 @@ function useScaledOrderConfirmScript(options2) {
|
|
|
1800
1655
|
const { order, symbolInfo } = options2;
|
|
1801
1656
|
const orders = order.orders;
|
|
1802
1657
|
const askAndBid = useAskAndBid();
|
|
1803
|
-
const national =
|
|
1658
|
+
const national = React2.useMemo(() => {
|
|
1804
1659
|
const national2 = orders.reduce((acc, order2) => {
|
|
1805
1660
|
return acc.add(new utils.Decimal(order2.order_price).mul(order2.order_quantity));
|
|
1806
1661
|
}, utils.zero);
|
|
1807
1662
|
return national2.toNumber();
|
|
1808
1663
|
}, [orders]);
|
|
1809
|
-
const totalQuantity =
|
|
1664
|
+
const totalQuantity = React2.useMemo(() => {
|
|
1810
1665
|
const totalQuantity2 = orders.reduce((acc, order2) => {
|
|
1811
1666
|
return acc.add(new utils.Decimal(order2.order_quantity));
|
|
1812
1667
|
}, utils.zero);
|
|
@@ -1828,7 +1683,7 @@ ui.registerSimpleDialog(scaledOrderConfirmDialogId, ScaledOrderConfirmWidget, {
|
|
|
1828
1683
|
});
|
|
1829
1684
|
var OrderTypeSelect = (props) => {
|
|
1830
1685
|
const { t } = i18n.useTranslation();
|
|
1831
|
-
const options2 =
|
|
1686
|
+
const options2 = React2.useMemo(() => {
|
|
1832
1687
|
return [
|
|
1833
1688
|
{ label: t("orderEntry.orderType.limitOrder"), value: types.OrderType.LIMIT },
|
|
1834
1689
|
{ label: t("orderEntry.orderType.marketOrder"), value: types.OrderType.MARKET },
|
|
@@ -1850,7 +1705,7 @@ var OrderTypeSelect = (props) => {
|
|
|
1850
1705
|
}
|
|
1851
1706
|
];
|
|
1852
1707
|
}, [t]);
|
|
1853
|
-
const displayLabelMap =
|
|
1708
|
+
const displayLabelMap = React2.useMemo(() => {
|
|
1854
1709
|
return {
|
|
1855
1710
|
[types.OrderType.LIMIT]: t("orderEntry.orderType.limit"),
|
|
1856
1711
|
[types.OrderType.MARKET]: t("common.marketPrice"),
|
|
@@ -2004,11 +1859,11 @@ function OrderEntryHeader(props) {
|
|
|
2004
1859
|
)
|
|
2005
1860
|
] });
|
|
2006
1861
|
}
|
|
2007
|
-
var OrderEntryContext =
|
|
1862
|
+
var OrderEntryContext = React2.createContext(
|
|
2008
1863
|
{}
|
|
2009
1864
|
);
|
|
2010
1865
|
var useOrderEntryContext = () => {
|
|
2011
|
-
return
|
|
1866
|
+
return React2.useContext(OrderEntryContext);
|
|
2012
1867
|
};
|
|
2013
1868
|
var OrderEntryProvider = (props) => {
|
|
2014
1869
|
const {
|
|
@@ -2028,7 +1883,7 @@ var OrderEntryProvider = (props) => {
|
|
|
2028
1883
|
lastQuantityInputType,
|
|
2029
1884
|
leverage
|
|
2030
1885
|
} = props;
|
|
2031
|
-
const memoizedValue =
|
|
1886
|
+
const memoizedValue = React2.useMemo(() => {
|
|
2032
1887
|
return {
|
|
2033
1888
|
errorMsgVisible,
|
|
2034
1889
|
symbolInfo,
|
|
@@ -2066,7 +1921,7 @@ var OrderEntryProvider = (props) => {
|
|
|
2066
1921
|
]);
|
|
2067
1922
|
return /* @__PURE__ */ jsxRuntime.jsx(OrderEntryContext.Provider, { value: memoizedValue, children: props.children });
|
|
2068
1923
|
};
|
|
2069
|
-
var CustomInput =
|
|
1924
|
+
var CustomInput = React2.forwardRef(
|
|
2070
1925
|
(props, ref) => {
|
|
2071
1926
|
const { placeholder = "0" } = props;
|
|
2072
1927
|
const { errorMsgVisible } = useOrderEntryContext();
|
|
@@ -2132,7 +1987,7 @@ var InputLabel = (props) => {
|
|
|
2132
1987
|
};
|
|
2133
1988
|
var BBOOrderTypeSelect = (props) => {
|
|
2134
1989
|
const { t } = i18n.useTranslation();
|
|
2135
|
-
const options2 =
|
|
1990
|
+
const options2 = React2.useMemo(
|
|
2136
1991
|
() => [
|
|
2137
1992
|
{
|
|
2138
1993
|
label: t("orderEntry.bbo.counterparty1"),
|
|
@@ -2306,7 +2161,7 @@ var PriceInput = (props) => {
|
|
|
2306
2161
|
}
|
|
2307
2162
|
);
|
|
2308
2163
|
};
|
|
2309
|
-
var QuantityInput =
|
|
2164
|
+
var QuantityInput = React2.memo((props) => {
|
|
2310
2165
|
const { t } = i18n.useTranslation();
|
|
2311
2166
|
const { symbolInfo, onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
|
|
2312
2167
|
const { base, base_dp } = symbolInfo;
|
|
@@ -2333,9 +2188,9 @@ var QuantityInput = React3.memo((props) => {
|
|
|
2333
2188
|
);
|
|
2334
2189
|
});
|
|
2335
2190
|
QuantityInput.displayName = "QuantityInput";
|
|
2336
|
-
var TotalTypeSelect =
|
|
2191
|
+
var TotalTypeSelect = React2.memo((props) => {
|
|
2337
2192
|
const { t } = i18n.useTranslation();
|
|
2338
|
-
const options2 =
|
|
2193
|
+
const options2 = React2.useMemo(() => {
|
|
2339
2194
|
return [
|
|
2340
2195
|
{
|
|
2341
2196
|
label: t("orderEntry.orderSize"),
|
|
@@ -2368,10 +2223,10 @@ var TotalTypeSelect = React3.memo((props) => {
|
|
|
2368
2223
|
);
|
|
2369
2224
|
});
|
|
2370
2225
|
TotalTypeSelect.displayName = "TotalTypeSelect";
|
|
2371
|
-
var TotalInput =
|
|
2226
|
+
var TotalInput = React2.memo((props) => {
|
|
2372
2227
|
const { t } = i18n.useTranslation();
|
|
2373
2228
|
const { total } = props;
|
|
2374
|
-
const [margin, setMargin] =
|
|
2229
|
+
const [margin, setMargin] = React2.useState("");
|
|
2375
2230
|
const {
|
|
2376
2231
|
symbolInfo,
|
|
2377
2232
|
onFocus,
|
|
@@ -2386,7 +2241,7 @@ var TotalInput = React3.memo((props) => {
|
|
|
2386
2241
|
"orderly_order_total_type",
|
|
2387
2242
|
"orderSize" /* OrderSize */
|
|
2388
2243
|
);
|
|
2389
|
-
|
|
2244
|
+
React2.useEffect(() => {
|
|
2390
2245
|
if (total) {
|
|
2391
2246
|
if (currentFocusInput !== 6 /* MARGIN */) {
|
|
2392
2247
|
const margin2 = new utils.Decimal(total).div(leverage).todp(2).toString();
|
|
@@ -2448,14 +2303,14 @@ var TotalInput = React3.memo((props) => {
|
|
|
2448
2303
|
);
|
|
2449
2304
|
});
|
|
2450
2305
|
TotalInput.displayName = "TotalInput";
|
|
2451
|
-
var QtyAndTotalInput =
|
|
2306
|
+
var QtyAndTotalInput = React2.memo((props) => {
|
|
2452
2307
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Grid, { cols: 2, className: "oui-group oui-space-x-1", children: [
|
|
2453
2308
|
/* @__PURE__ */ jsxRuntime.jsx(QuantityInput, { order_quantity: props.order_quantity }),
|
|
2454
2309
|
/* @__PURE__ */ jsxRuntime.jsx(TotalInput, { total: props.total })
|
|
2455
2310
|
] });
|
|
2456
2311
|
});
|
|
2457
2312
|
QtyAndTotalInput.displayName = "QtyAndTotalInput";
|
|
2458
|
-
var QuantityDistributionInput =
|
|
2313
|
+
var QuantityDistributionInput = React2.memo((props) => {
|
|
2459
2314
|
const { t } = i18n.useTranslation();
|
|
2460
2315
|
const { setOrderValue } = useOrderEntryContext();
|
|
2461
2316
|
const showHint = () => {
|
|
@@ -2508,8 +2363,8 @@ var QuantityDistributionInput = React3.memo((props) => {
|
|
|
2508
2363
|
});
|
|
2509
2364
|
var QuantityDistributionHint = (props) => {
|
|
2510
2365
|
const { t } = i18n.useTranslation();
|
|
2511
|
-
const [type, setType] =
|
|
2512
|
-
|
|
2366
|
+
const [type, setType] = React2.useState(types.DistributionType.FLAT);
|
|
2367
|
+
React2.useEffect(() => {
|
|
2513
2368
|
setType(
|
|
2514
2369
|
[
|
|
2515
2370
|
types.DistributionType.FLAT,
|
|
@@ -2518,7 +2373,7 @@ var QuantityDistributionHint = (props) => {
|
|
|
2518
2373
|
].includes(props.value) ? props.value : types.DistributionType.FLAT
|
|
2519
2374
|
);
|
|
2520
2375
|
}, [props.value]);
|
|
2521
|
-
const content =
|
|
2376
|
+
const content = React2.useMemo(() => {
|
|
2522
2377
|
return [
|
|
2523
2378
|
{
|
|
2524
2379
|
type: types.DistributionType.FLAT,
|
|
@@ -2543,7 +2398,7 @@ var QuantityDistributionHint = (props) => {
|
|
|
2543
2398
|
}
|
|
2544
2399
|
];
|
|
2545
2400
|
}, []);
|
|
2546
|
-
const currentContent =
|
|
2401
|
+
const currentContent = React2.useMemo(() => {
|
|
2547
2402
|
return content.find((item) => item.type === type);
|
|
2548
2403
|
}, [content, type]);
|
|
2549
2404
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast-54", children: [
|
|
@@ -2601,7 +2456,7 @@ var QuantityDistribution = (props) => {
|
|
|
2601
2456
|
const onChange = (value2) => (checked) => {
|
|
2602
2457
|
onValueChange(value2);
|
|
2603
2458
|
};
|
|
2604
|
-
const distributionTypeMap =
|
|
2459
|
+
const distributionTypeMap = React2.useMemo(() => {
|
|
2605
2460
|
return {
|
|
2606
2461
|
[types.DistributionType.FLAT]: t("orderEntry.distributionType.flat"),
|
|
2607
2462
|
[types.DistributionType.ASCENDING]: t(
|
|
@@ -2900,7 +2755,7 @@ var PriceChart = () => {
|
|
|
2900
2755
|
}
|
|
2901
2756
|
);
|
|
2902
2757
|
};
|
|
2903
|
-
var ScaledPriceInput =
|
|
2758
|
+
var ScaledPriceInput = React2.memo((props) => {
|
|
2904
2759
|
const { t } = i18n.useTranslation();
|
|
2905
2760
|
const { symbolInfo, onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
|
|
2906
2761
|
const { quote, quote_dp } = symbolInfo;
|
|
@@ -2948,7 +2803,7 @@ var valueRenderer = (value) => {
|
|
|
2948
2803
|
};
|
|
2949
2804
|
var ScaledQuantityUnit = (props) => {
|
|
2950
2805
|
const { base, quote } = props;
|
|
2951
|
-
const options2 =
|
|
2806
|
+
const options2 = React2.useMemo(() => {
|
|
2952
2807
|
return [{ name: quote }, { name: base }];
|
|
2953
2808
|
}, [base, quote]);
|
|
2954
2809
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2976,7 +2831,7 @@ var ScaledQuantityUnit = (props) => {
|
|
|
2976
2831
|
}
|
|
2977
2832
|
);
|
|
2978
2833
|
};
|
|
2979
|
-
var ScaledQuantityInput =
|
|
2834
|
+
var ScaledQuantityInput = React2.memo((props) => {
|
|
2980
2835
|
const { t } = i18n.useTranslation();
|
|
2981
2836
|
const { errors, symbolInfo, onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
|
|
2982
2837
|
const [quantityUnit, setQuantityUnit] = hooks.useLocalStorage(
|
|
@@ -3039,7 +2894,7 @@ var ScaledQuantityInput = React3.memo((props) => {
|
|
|
3039
2894
|
}
|
|
3040
2895
|
);
|
|
3041
2896
|
});
|
|
3042
|
-
var SkewInput =
|
|
2897
|
+
var SkewInput = React2.memo((props) => {
|
|
3043
2898
|
const { t } = i18n.useTranslation();
|
|
3044
2899
|
const { onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
|
|
3045
2900
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3064,7 +2919,7 @@ var SkewInput = React3.memo((props) => {
|
|
|
3064
2919
|
}
|
|
3065
2920
|
);
|
|
3066
2921
|
});
|
|
3067
|
-
var TotalOrdersInput =
|
|
2922
|
+
var TotalOrdersInput = React2.memo((props) => {
|
|
3068
2923
|
const { t } = i18n.useTranslation();
|
|
3069
2924
|
const { onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
|
|
3070
2925
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3120,7 +2975,7 @@ var ScaledOrderInput = (props) => {
|
|
|
3120
2975
|
showSkewInput && /* @__PURE__ */ jsxRuntime.jsx(SkewInput, { skew: values.skew })
|
|
3121
2976
|
] });
|
|
3122
2977
|
};
|
|
3123
|
-
var TriggerPriceInput =
|
|
2978
|
+
var TriggerPriceInput = React2.memo((props) => {
|
|
3124
2979
|
const { t } = i18n.useTranslation();
|
|
3125
2980
|
const {
|
|
3126
2981
|
symbolInfo,
|
|
@@ -3150,7 +3005,7 @@ var TriggerPriceInput = React3.memo((props) => {
|
|
|
3150
3005
|
) });
|
|
3151
3006
|
});
|
|
3152
3007
|
TriggerPriceInput.displayName = "TriggerPriceInput";
|
|
3153
|
-
var ActivePriceInput =
|
|
3008
|
+
var ActivePriceInput = React2.memo((props) => {
|
|
3154
3009
|
const { t } = i18n.useTranslation();
|
|
3155
3010
|
const {
|
|
3156
3011
|
symbolInfo,
|
|
@@ -3182,7 +3037,7 @@ var ActivePriceInput = React3.memo((props) => {
|
|
|
3182
3037
|
});
|
|
3183
3038
|
ActivePriceInput.displayName = "ActivePriceInput";
|
|
3184
3039
|
var percentages = [1, 2, 3, 5];
|
|
3185
|
-
var CallbackRatePercentages =
|
|
3040
|
+
var CallbackRatePercentages = React2.memo(
|
|
3186
3041
|
(props) => {
|
|
3187
3042
|
const { setOrderValue } = useOrderEntryContext();
|
|
3188
3043
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gapX: 2, className: props.className, children: percentages.map((item) => {
|
|
@@ -3215,10 +3070,10 @@ var CallbackRatePercentages = React3.memo(
|
|
|
3215
3070
|
}
|
|
3216
3071
|
);
|
|
3217
3072
|
CallbackRatePercentages.displayName = "CallbackRatePercentages";
|
|
3218
|
-
var TrailingCallbackSelect =
|
|
3073
|
+
var TrailingCallbackSelect = React2.memo(
|
|
3219
3074
|
(props) => {
|
|
3220
3075
|
const { quote } = props;
|
|
3221
|
-
const options2 =
|
|
3076
|
+
const options2 = React2.useMemo(() => {
|
|
3222
3077
|
return [
|
|
3223
3078
|
{ label: quote, value: types.TrailingCallbackType.VALUE },
|
|
3224
3079
|
{ label: "%", value: types.TrailingCallbackType.RATE }
|
|
@@ -3250,7 +3105,7 @@ var TrailingCallbackSelect = React3.memo(
|
|
|
3250
3105
|
}
|
|
3251
3106
|
);
|
|
3252
3107
|
TrailingCallbackSelect.displayName = "trailingCallbackSelect";
|
|
3253
|
-
var TrailingCallbackInput =
|
|
3108
|
+
var TrailingCallbackInput = React2.memo(
|
|
3254
3109
|
(props) => {
|
|
3255
3110
|
const { callback_value, callback_rate } = props;
|
|
3256
3111
|
const { t } = i18n.useTranslation();
|
|
@@ -3263,13 +3118,13 @@ var TrailingCallbackInput = React3.memo(
|
|
|
3263
3118
|
setOrderValues
|
|
3264
3119
|
} = useOrderEntryContext();
|
|
3265
3120
|
const { quote, quote_dp } = symbolInfo;
|
|
3266
|
-
const lastCallbackValueRef =
|
|
3267
|
-
const lastCallbackRateRef =
|
|
3121
|
+
const lastCallbackValueRef = React2.useRef();
|
|
3122
|
+
const lastCallbackRateRef = React2.useRef();
|
|
3268
3123
|
const [callbackType, setCallbackType] = hooks.useLocalStorage(
|
|
3269
3124
|
"orderly_order_trailing_callback_type",
|
|
3270
3125
|
types.TrailingCallbackType.VALUE
|
|
3271
3126
|
);
|
|
3272
|
-
const onCallbackTypeChange =
|
|
3127
|
+
const onCallbackTypeChange = React2.useCallback(
|
|
3273
3128
|
(type) => {
|
|
3274
3129
|
setCallbackType(type);
|
|
3275
3130
|
if (type === types.TrailingCallbackType.RATE) {
|
|
@@ -3421,17 +3276,17 @@ function OrderInput(props) {
|
|
|
3421
3276
|
}
|
|
3422
3277
|
var SLIDER_MIN = 0;
|
|
3423
3278
|
var SLIDER_MAX = 100;
|
|
3424
|
-
var QuantitySlider =
|
|
3279
|
+
var QuantitySlider = React2.memo((props) => {
|
|
3425
3280
|
const { canTrade, side, order_quantity, maxQty } = props;
|
|
3426
|
-
const [sliderValue, setSliderValue] =
|
|
3281
|
+
const [sliderValue, setSliderValue] = React2.useState(0);
|
|
3427
3282
|
const { setOrderValue, symbolInfo, lastQuantityInputType } = useOrderEntryContext();
|
|
3428
3283
|
const { base_dp, base_tick } = symbolInfo;
|
|
3429
3284
|
const { t } = i18n.useTranslation();
|
|
3430
|
-
const color =
|
|
3285
|
+
const color = React2.useMemo(
|
|
3431
3286
|
() => canTrade ? side === types.OrderSide.BUY ? "buy" : "sell" : void 0,
|
|
3432
3287
|
[side, canTrade]
|
|
3433
3288
|
);
|
|
3434
|
-
const maxLabel =
|
|
3289
|
+
const maxLabel = React2.useMemo(() => {
|
|
3435
3290
|
return side === types.OrderSide.BUY ? t("orderEntry.maxBuy") : t("orderEntry.maxSell");
|
|
3436
3291
|
}, [side, t]);
|
|
3437
3292
|
const onSliderValueChange = (value) => {
|
|
@@ -3448,12 +3303,12 @@ var QuantitySlider = React3.memo((props) => {
|
|
|
3448
3303
|
sliderToQuantity(SLIDER_MAX);
|
|
3449
3304
|
}
|
|
3450
3305
|
};
|
|
3451
|
-
|
|
3306
|
+
React2.useEffect(() => {
|
|
3452
3307
|
if (lastQuantityInputType.current === 4 /* QUANTITY_SLIDER */) {
|
|
3453
3308
|
sliderToQuantity(sliderValue);
|
|
3454
3309
|
}
|
|
3455
3310
|
}, [sliderValue, maxQty]);
|
|
3456
|
-
|
|
3311
|
+
React2.useEffect(() => {
|
|
3457
3312
|
const quantityToSlider = () => {
|
|
3458
3313
|
if (order_quantity && Number(order_quantity) !== 0 && maxQty !== 0) {
|
|
3459
3314
|
return new utils.Decimal(Math.min(Number(order_quantity), maxQty)).div(maxQty).mul(SLIDER_MAX).todp(2, utils.Decimal.ROUND_DOWN).toNumber();
|
|
@@ -3542,22 +3397,22 @@ var ReduceOnlySwitch = ({
|
|
|
3542
3397
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "reduceOnly", className: "oui-text-xs", children: t("orderEntry.reduceOnly") })
|
|
3543
3398
|
] });
|
|
3544
3399
|
};
|
|
3545
|
-
var PnlInputContext =
|
|
3400
|
+
var PnlInputContext = React2.createContext(
|
|
3546
3401
|
{}
|
|
3547
3402
|
);
|
|
3548
3403
|
var usePnlInputContext = () => {
|
|
3549
|
-
return
|
|
3404
|
+
return React2.useContext(PnlInputContext);
|
|
3550
3405
|
};
|
|
3551
3406
|
|
|
3552
3407
|
// src/components/pnlInput/useBuilder.script.ts
|
|
3553
3408
|
var usePNLInputBuilder = (props) => {
|
|
3554
3409
|
const { type, values, quote_dp } = props;
|
|
3555
3410
|
const { t } = i18n.useTranslation();
|
|
3556
|
-
const [focus, setFocus] =
|
|
3411
|
+
const [focus, setFocus] = React2.useState(true);
|
|
3557
3412
|
const { mode, setMode, tipsEle } = usePnlInputContext();
|
|
3558
|
-
const [tipVisible, setTipVisible] =
|
|
3559
|
-
const [isFocused, setIsFocused] =
|
|
3560
|
-
const key =
|
|
3413
|
+
const [tipVisible, setTipVisible] = React2.useState(false);
|
|
3414
|
+
const [isFocused, setIsFocused] = React2.useState(false);
|
|
3415
|
+
const key = React2.useMemo(() => {
|
|
3561
3416
|
switch (mode) {
|
|
3562
3417
|
case "Offset" /* OFFSET */:
|
|
3563
3418
|
return `${type.toLowerCase()}_offset`;
|
|
@@ -3567,16 +3422,16 @@ var usePNLInputBuilder = (props) => {
|
|
|
3567
3422
|
return `${type.toLowerCase()}_pnl`;
|
|
3568
3423
|
}
|
|
3569
3424
|
}, [mode]);
|
|
3570
|
-
const [innerValue, setInnerValue] =
|
|
3425
|
+
const [innerValue, setInnerValue] = React2.useState(
|
|
3571
3426
|
values[mode]
|
|
3572
3427
|
);
|
|
3573
|
-
|
|
3428
|
+
React2.useEffect(() => {
|
|
3574
3429
|
if (isFocused) {
|
|
3575
3430
|
return;
|
|
3576
3431
|
}
|
|
3577
3432
|
setInnerValue(values[mode]);
|
|
3578
3433
|
}, [values, mode, isFocused]);
|
|
3579
|
-
const modes =
|
|
3434
|
+
const modes = React2.useMemo(() => {
|
|
3580
3435
|
return [
|
|
3581
3436
|
{
|
|
3582
3437
|
label: t("tpsl.pnl"),
|
|
@@ -3595,14 +3450,14 @@ var usePNLInputBuilder = (props) => {
|
|
|
3595
3450
|
}
|
|
3596
3451
|
];
|
|
3597
3452
|
}, [t]);
|
|
3598
|
-
const modeLabelMap =
|
|
3453
|
+
const modeLabelMap = React2.useMemo(() => {
|
|
3599
3454
|
return {
|
|
3600
3455
|
["PnL" /* PnL */]: t("tpsl.pnl"),
|
|
3601
3456
|
["Offset" /* OFFSET */]: t("tpsl.offset"),
|
|
3602
3457
|
["Offset%" /* PERCENTAGE */]: `${t("tpsl.offset")}%`
|
|
3603
3458
|
};
|
|
3604
3459
|
}, [t]);
|
|
3605
|
-
const percentageSuffix =
|
|
3460
|
+
const percentageSuffix = React2.useRef("");
|
|
3606
3461
|
const onValueChange = (value) => {
|
|
3607
3462
|
setInnerValue(value);
|
|
3608
3463
|
props.onChange(key, value);
|
|
@@ -3698,18 +3553,18 @@ var PNLInput = (props) => {
|
|
|
3698
3553
|
onBlur,
|
|
3699
3554
|
setFocus
|
|
3700
3555
|
} = props;
|
|
3701
|
-
const [prefix, setPrefix] =
|
|
3702
|
-
const [placeholder, setPlaceholder] =
|
|
3556
|
+
const [prefix, setPrefix] = React2.useState(mode);
|
|
3557
|
+
const [placeholder, setPlaceholder] = React2.useState(
|
|
3703
3558
|
mode === "Offset%" /* PERCENTAGE */ ? "%" : quote
|
|
3704
3559
|
);
|
|
3705
|
-
|
|
3560
|
+
React2.useEffect(() => {
|
|
3706
3561
|
setPrefix(mode);
|
|
3707
3562
|
setPlaceholder(mode === "Offset%" /* PERCENTAGE */ ? "%" : quote);
|
|
3708
3563
|
}, [mode]);
|
|
3709
|
-
|
|
3564
|
+
React2.useEffect(() => {
|
|
3710
3565
|
setPrefix(!!value ? "" : mode);
|
|
3711
3566
|
}, [value]);
|
|
3712
|
-
const id =
|
|
3567
|
+
const id = React2.useMemo(() => `${type.toLowerCase()}_${mode.toLowerCase()}`, []);
|
|
3713
3568
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3714
3569
|
ui.Input.tooltip,
|
|
3715
3570
|
{
|
|
@@ -3791,7 +3646,7 @@ var PnlInputProvider = (props) => {
|
|
|
3791
3646
|
"Offset%" /* PERCENTAGE */
|
|
3792
3647
|
);
|
|
3793
3648
|
const { t } = i18n.useTranslation();
|
|
3794
|
-
const tipsEle =
|
|
3649
|
+
const tipsEle = React2.useMemo(() => {
|
|
3795
3650
|
if (!values.PnL || !values.trigger_price) {
|
|
3796
3651
|
return null;
|
|
3797
3652
|
}
|
|
@@ -3820,16 +3675,16 @@ var PnlInputProvider = (props) => {
|
|
|
3820
3675
|
)
|
|
3821
3676
|
] });
|
|
3822
3677
|
}, [mode, values.ROI, values.PnL, values.trigger_price]);
|
|
3823
|
-
const memoizedValue =
|
|
3678
|
+
const memoizedValue = React2.useMemo(() => {
|
|
3824
3679
|
return { mode, setMode, tipsEle };
|
|
3825
3680
|
}, [mode, setMode, tipsEle]);
|
|
3826
3681
|
return /* @__PURE__ */ jsxRuntime.jsx(PnlInputContext.Provider, { value: memoizedValue, children });
|
|
3827
3682
|
};
|
|
3828
3683
|
var OrderTPSL = (props) => {
|
|
3829
|
-
const tpslFormRef =
|
|
3684
|
+
const tpslFormRef = React2__default.default.useRef(null);
|
|
3830
3685
|
const { t } = i18n.useTranslation();
|
|
3831
3686
|
const { isMobile } = ui.useScreen();
|
|
3832
|
-
|
|
3687
|
+
React2.useEffect(() => {
|
|
3833
3688
|
if (props.orderType !== types.OrderType.LIMIT && props.orderType !== types.OrderType.MARKET) {
|
|
3834
3689
|
props.onSwitchChanged(false);
|
|
3835
3690
|
}
|
|
@@ -3918,7 +3773,7 @@ var TPSLPriceWarning = (props) => {
|
|
|
3918
3773
|
}
|
|
3919
3774
|
);
|
|
3920
3775
|
};
|
|
3921
|
-
var TPSLInputForm =
|
|
3776
|
+
var TPSLInputForm = React2__default.default.forwardRef((props, ref) => {
|
|
3922
3777
|
const { getErrorMsg } = reactApp.useOrderEntryFormErrorMsg(props.errors);
|
|
3923
3778
|
const { t } = i18n.useTranslation();
|
|
3924
3779
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4019,20 +3874,20 @@ var TPSLTriggerPriceInput = (props) => {
|
|
|
4019
3874
|
const { t } = i18n.useTranslation();
|
|
4020
3875
|
const { errorMsgVisible } = useOrderEntryContext();
|
|
4021
3876
|
const { tipsEle } = usePnlInputContext();
|
|
4022
|
-
const [prefix, setPrefix] =
|
|
4023
|
-
const [placeholder, setPlaceholder] =
|
|
4024
|
-
const [tipVisible, setTipVisible] =
|
|
4025
|
-
const [isFocused, setIsFocused] =
|
|
4026
|
-
const [innerValue, setInnerValue] =
|
|
3877
|
+
const [prefix, setPrefix] = React2.useState(`${props.type} Price`);
|
|
3878
|
+
const [placeholder, setPlaceholder] = React2.useState("USDC");
|
|
3879
|
+
const [tipVisible, setTipVisible] = React2.useState(false);
|
|
3880
|
+
const [isFocused, setIsFocused] = React2.useState(false);
|
|
3881
|
+
const [innerValue, setInnerValue] = React2.useState(
|
|
4027
3882
|
props.values.trigger_price ?? ""
|
|
4028
3883
|
);
|
|
4029
|
-
|
|
3884
|
+
React2.useEffect(() => {
|
|
4030
3885
|
if (isFocused) {
|
|
4031
3886
|
return;
|
|
4032
3887
|
}
|
|
4033
3888
|
setInnerValue(props.values.trigger_price ?? "");
|
|
4034
3889
|
}, [props.values.trigger_price, isFocused]);
|
|
4035
|
-
const triggerPriceToolTipEle =
|
|
3890
|
+
const triggerPriceToolTipEle = React2.useMemo(() => {
|
|
4036
3891
|
if (props.error && (errorMsgVisible || props.displayErrorMessage))
|
|
4037
3892
|
return props.error;
|
|
4038
3893
|
if (tipVisible) return tipsEle;
|
|
@@ -4055,7 +3910,7 @@ var TPSLTriggerPriceInput = (props) => {
|
|
|
4055
3910
|
setInnerValue(value);
|
|
4056
3911
|
props.onChange(value);
|
|
4057
3912
|
};
|
|
4058
|
-
|
|
3913
|
+
React2.useEffect(() => {
|
|
4059
3914
|
setPrefix(getPrefixLabel(props.values.trigger_price));
|
|
4060
3915
|
if (!isFocused) {
|
|
4061
3916
|
setInnerValue(props.values.trigger_price ?? "");
|
|
@@ -4175,12 +4030,12 @@ var OrderEntry = (props) => {
|
|
|
4175
4030
|
setSoundAlert,
|
|
4176
4031
|
currentFocusInput
|
|
4177
4032
|
} = props;
|
|
4178
|
-
const [maxQtyConfirmOpen, setMaxQtyConfirmOpen] =
|
|
4033
|
+
const [maxQtyConfirmOpen, setMaxQtyConfirmOpen] = React2.useState(false);
|
|
4179
4034
|
const { t } = i18n.useTranslation();
|
|
4180
4035
|
const { isMobile } = ui.useScreen();
|
|
4181
|
-
const [hasAdvancedTPSLResult, setHasAdvancedTPSLResult] =
|
|
4036
|
+
const [hasAdvancedTPSLResult, setHasAdvancedTPSLResult] = React2.useState(false);
|
|
4182
4037
|
const { errors, validated } = metaState;
|
|
4183
|
-
const [errorMsgVisible, setErrorMsgVisible] =
|
|
4038
|
+
const [errorMsgVisible, setErrorMsgVisible] = React2.useState(false);
|
|
4184
4039
|
const [needConfirm, setNeedConfirm] = hooks.useLocalStorage(
|
|
4185
4040
|
"orderly_order_confirm",
|
|
4186
4041
|
true
|
|
@@ -4189,7 +4044,7 @@ var OrderEntry = (props) => {
|
|
|
4189
4044
|
"orderly-order-additional-pinned",
|
|
4190
4045
|
true
|
|
4191
4046
|
);
|
|
4192
|
-
const [showTPSLAdvanced, setShowTPSLAdvanced] =
|
|
4047
|
+
const [showTPSLAdvanced, setShowTPSLAdvanced] = React2.useState(false);
|
|
4193
4048
|
const [hidden, setHidden] = hooks.useLocalStorage("orderly-order-hidden", false);
|
|
4194
4049
|
const [slippage, setSlippage] = hooks.useLocalStorage("orderly-slippage", "1", {
|
|
4195
4050
|
parseJSON: ((value) => {
|
|
@@ -4197,17 +4052,17 @@ var OrderEntry = (props) => {
|
|
|
4197
4052
|
})
|
|
4198
4053
|
});
|
|
4199
4054
|
const { notification } = hooks.useOrderlyContext();
|
|
4200
|
-
const soundAlertId =
|
|
4055
|
+
const soundAlertId = React2.useId();
|
|
4201
4056
|
const { getErrorMsg } = reactApp.useOrderEntryFormErrorMsg(validated ? errors : null);
|
|
4202
|
-
const buttonLabel =
|
|
4057
|
+
const buttonLabel = React2.useMemo(() => {
|
|
4203
4058
|
return side === types.OrderSide.BUY ? t("orderEntry.buyLong") : t("orderEntry.sellShort");
|
|
4204
4059
|
}, [side, t, isMobile]);
|
|
4205
|
-
|
|
4060
|
+
React2.useEffect(() => {
|
|
4206
4061
|
if (validated) {
|
|
4207
4062
|
setErrorMsgVisible(true);
|
|
4208
4063
|
}
|
|
4209
4064
|
}, [validated]);
|
|
4210
|
-
|
|
4065
|
+
React2.useEffect(() => {
|
|
4211
4066
|
if (disableFeatures?.includes("slippageSetting")) {
|
|
4212
4067
|
return;
|
|
4213
4068
|
}
|
|
@@ -4217,7 +4072,7 @@ var OrderEntry = (props) => {
|
|
|
4217
4072
|
setOrderValue("slippage", void 0);
|
|
4218
4073
|
}
|
|
4219
4074
|
}, [slippage, disableFeatures]);
|
|
4220
|
-
|
|
4075
|
+
React2.useEffect(() => {
|
|
4221
4076
|
const clickHandler = (event) => {
|
|
4222
4077
|
const target = event.target;
|
|
4223
4078
|
if (target.closest("#order-entry-submit-button")) {
|
|
@@ -4286,10 +4141,10 @@ var OrderEntry = (props) => {
|
|
|
4286
4141
|
}
|
|
4287
4142
|
});
|
|
4288
4143
|
});
|
|
4289
|
-
const formattedMaxQty =
|
|
4144
|
+
const formattedMaxQty = React2.useMemo(() => {
|
|
4290
4145
|
return new utils.Decimal(maxQty).todp(symbolInfo.base_dp, utils.Decimal.ROUND_DOWN).toString();
|
|
4291
4146
|
}, [maxQty, symbolInfo.base_dp]);
|
|
4292
|
-
const onMaxQtyConfirm =
|
|
4147
|
+
const onMaxQtyConfirm = React2.useCallback(() => {
|
|
4293
4148
|
setOrderValue("order_quantity", formattedMaxQty);
|
|
4294
4149
|
requestAnimationFrame(() => {
|
|
4295
4150
|
onSubmit();
|
|
@@ -4371,7 +4226,7 @@ var OrderEntry = (props) => {
|
|
|
4371
4226
|
position_type: types.PositionType.FULL
|
|
4372
4227
|
});
|
|
4373
4228
|
};
|
|
4374
|
-
|
|
4229
|
+
React2.useEffect(() => {
|
|
4375
4230
|
setHasAdvancedTPSLResult(false);
|
|
4376
4231
|
}, [props.symbol]);
|
|
4377
4232
|
const showReduceOnlySection = isMobile && formattedOrder.order_type !== types.OrderType.LIMIT && formattedOrder.order_type !== types.OrderType.MARKET || !isMobile;
|
|
@@ -4634,9 +4489,9 @@ function useBBOState({
|
|
|
4634
4489
|
setOrderValues
|
|
4635
4490
|
}) {
|
|
4636
4491
|
const [localBBOType, setLocalBBOType] = hooks.useLocalStorage("orderly_order_bbo_type", void 0);
|
|
4637
|
-
const lastBBOType =
|
|
4492
|
+
const lastBBOType = React2.useRef(localBBOType);
|
|
4638
4493
|
const { track } = hooks.useTrack();
|
|
4639
|
-
const bboStatus =
|
|
4494
|
+
const bboStatus = React2.useMemo(() => {
|
|
4640
4495
|
if (tpslSwitch || [types.OrderType.POST_ONLY, types.OrderType.IOC, types.OrderType.FOK].includes(
|
|
4641
4496
|
order_type_ext
|
|
4642
4497
|
)) {
|
|
@@ -4660,7 +4515,7 @@ function useBBOState({
|
|
|
4660
4515
|
setLocalBBOType(value);
|
|
4661
4516
|
lastBBOType.current = value;
|
|
4662
4517
|
};
|
|
4663
|
-
|
|
4518
|
+
React2.useEffect(() => {
|
|
4664
4519
|
if (bboStatus === "disabled" /* DISABLED */) {
|
|
4665
4520
|
setOrderValues({
|
|
4666
4521
|
// if order_type_ext is not bbo(ask, bid), keep previous value
|
|
@@ -4669,7 +4524,7 @@ function useBBOState({
|
|
|
4669
4524
|
});
|
|
4670
4525
|
}
|
|
4671
4526
|
}, [bboStatus, order_type_ext]);
|
|
4672
|
-
|
|
4527
|
+
React2.useEffect(() => {
|
|
4673
4528
|
if (bboStatus === "on" /* ON */) {
|
|
4674
4529
|
const orderType = getOrderTypeByBBO(localBBOType, side);
|
|
4675
4530
|
const orderLevel = getOrderLevelByBBO(localBBOType);
|
|
@@ -4689,9 +4544,9 @@ function useBBOState({
|
|
|
4689
4544
|
}
|
|
4690
4545
|
function useFocusAndBlur(props) {
|
|
4691
4546
|
const { base_tick, order_type, order_quantity, setValue } = props;
|
|
4692
|
-
const currentFocusInput =
|
|
4693
|
-
const lastScaledOrderPriceInput =
|
|
4694
|
-
const lastQuantityInputType =
|
|
4547
|
+
const currentFocusInput = React2.useRef(0 /* NONE */);
|
|
4548
|
+
const lastScaledOrderPriceInput = React2.useRef(8 /* END_PRICE */);
|
|
4549
|
+
const lastQuantityInputType = React2.useRef(0 /* NONE */);
|
|
4695
4550
|
const formatQty = () => {
|
|
4696
4551
|
if (base_tick < 1 || // scaled order should not format quantity, because it is total quantity
|
|
4697
4552
|
order_type === types.OrderType.SCALED || !order_quantity) {
|
|
@@ -4738,9 +4593,9 @@ function useFocusAndBlur(props) {
|
|
|
4738
4593
|
function usePriceInputContainer({
|
|
4739
4594
|
order_type_ext
|
|
4740
4595
|
}) {
|
|
4741
|
-
const [priceInputContainerWidth, setPriceInputContainerWidth] =
|
|
4742
|
-
const priceInputContainerRef =
|
|
4743
|
-
|
|
4596
|
+
const [priceInputContainerWidth, setPriceInputContainerWidth] = React2.useState(0);
|
|
4597
|
+
const priceInputContainerRef = React2.useRef(null);
|
|
4598
|
+
React2.useEffect(() => {
|
|
4744
4599
|
const element = priceInputContainerRef.current;
|
|
4745
4600
|
if (!element) {
|
|
4746
4601
|
return;
|
|
@@ -4799,9 +4654,9 @@ var useOrderEntryScript = (inputs) => {
|
|
|
4799
4654
|
);
|
|
4800
4655
|
const { currentLeverage } = hooks.useMarginRatio();
|
|
4801
4656
|
const ee = hooks.useEventEmitter();
|
|
4802
|
-
const triggerPriceInputRef =
|
|
4803
|
-
const priceInputRef =
|
|
4804
|
-
const activatedPriceInputRef =
|
|
4657
|
+
const triggerPriceInputRef = React2.useRef(null);
|
|
4658
|
+
const priceInputRef = React2.useRef(null);
|
|
4659
|
+
const activatedPriceInputRef = React2.useRef(null);
|
|
4805
4660
|
const { bboStatus, bboType, setBBOType, onBBOChange, toggleBBO } = useBBOState({
|
|
4806
4661
|
tpslSwitch,
|
|
4807
4662
|
order_type: formattedOrder.order_type,
|
|
@@ -4881,7 +4736,7 @@ var useOrderEntryScript = (inputs) => {
|
|
|
4881
4736
|
cancelTP_SL();
|
|
4882
4737
|
}
|
|
4883
4738
|
};
|
|
4884
|
-
|
|
4739
|
+
React2.useEffect(() => {
|
|
4885
4740
|
const updateOrderPrice = (price) => {
|
|
4886
4741
|
setValue("order_price", price);
|
|
4887
4742
|
};
|
|
@@ -4890,7 +4745,7 @@ var useOrderEntryScript = (inputs) => {
|
|
|
4890
4745
|
ee.off("update:orderPrice", updateOrderPrice);
|
|
4891
4746
|
};
|
|
4892
4747
|
}, []);
|
|
4893
|
-
|
|
4748
|
+
React2.useEffect(() => {
|
|
4894
4749
|
const focusInputElement = (target) => {
|
|
4895
4750
|
requestAnimationFrame(() => {
|
|
4896
4751
|
target?.focus();
|
|
@@ -4954,12 +4809,12 @@ var useOrderEntryScript = (inputs) => {
|
|
|
4954
4809
|
ee.off("orderbook:item:click", orderBookItemClickHandler);
|
|
4955
4810
|
};
|
|
4956
4811
|
}, [formattedOrder, symbolInfo]);
|
|
4957
|
-
|
|
4812
|
+
React2.useEffect(() => {
|
|
4958
4813
|
state.reset();
|
|
4959
4814
|
state.resetMetaState();
|
|
4960
4815
|
lastQuantityInputType.current = 0 /* NONE */;
|
|
4961
4816
|
}, [symbol]);
|
|
4962
|
-
|
|
4817
|
+
React2.useEffect(() => {
|
|
4963
4818
|
if (formattedOrder.order_type === types.OrderType.SCALED && !formattedOrder.distribution_type) {
|
|
4964
4819
|
setValue("distribution_type", types.DistributionType.FLAT);
|
|
4965
4820
|
}
|
|
@@ -4988,12 +4843,12 @@ var useOrderEntryScript = (inputs) => {
|
|
|
4988
4843
|
currentPosition: state.currentPosition,
|
|
4989
4844
|
orderQuantity: Number(formattedOrder.order_quantity)
|
|
4990
4845
|
});
|
|
4991
|
-
|
|
4846
|
+
React2.useEffect(() => {
|
|
4992
4847
|
if (formattedOrder.reduce_only) {
|
|
4993
4848
|
setTpslSwitch(false);
|
|
4994
4849
|
}
|
|
4995
4850
|
}, [formattedOrder.reduce_only]);
|
|
4996
|
-
|
|
4851
|
+
React2.useEffect(() => {
|
|
4997
4852
|
if (tpslSwitch) {
|
|
4998
4853
|
setOrderValue("reduce_only", false);
|
|
4999
4854
|
}
|