@orderly.network/ui-order-entry 2.12.4 → 3.0.0-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.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import React3, { forwardRef, useState, useImperativeHandle, useEffect, memo, createContext, useMemo, useRef, useCallback, useContext, useId } from 'react';
2
- import { useLocalStorage, utils, usePositionStream, useMarkets, MarketsType, useMarginModes, useMarginModeBySymbol, useBadgeBySymbol, useEventEmitter, useDebouncedCallback, useFeeState, useRwaSymbolsInfoStore, useOrderlyContext, useMemoizedFn, ERROR_MSG_CODES, useAccount, useOrderEntry, useMarginRatio, useComputedLTV, useTpslPriceChecker, useHoldingStream, useAppStore, useIndexPricesStream, useGetEstLiqPrice, useTrack, useQuery, useFeatureFlag, FlagKeys, useBoolean } from '@orderly.network/hooks';
3
- import { useTranslation, i18n } from '@orderly.network/i18n';
1
+ import React3, { memo, forwardRef, useState, useImperativeHandle, useEffect, createContext, useMemo, useRef, useCallback, useContext, useId } from 'react';
2
+ import { useLocalStorage, utils, useGetEstLiqPrice, useOrderlyContext, useMemoizedFn, ERROR_MSG_CODES, usePositionStream, useFeeState, useRwaSymbolsInfoStore, useMarkets, MarketsType, useMarginModes, useMarginModeBySymbol, useBadgeBySymbol, useEventEmitter, useDebouncedCallback, useHoldingStream, useAppStore, useIndexPricesStream, useComputedLTV, useBoolean, useFeatureFlag, FlagKeys, useQuery, useAccount, useOrderEntry, useMarginRatio, useTpslPriceChecker, useTrack } from '@orderly.network/hooks';
3
+ import { i18n, useTranslation } from '@orderly.network/i18n';
4
4
  import { useOrderEntryFormErrorMsg, useCanTrade } from '@orderly.network/react-app';
5
- import { EMPTY_LIST, DistributionType, TrailingCallbackType, OrderSide, OrderType, MarginMode, PositionType, BBOOrderType, ORDER_ENTRY_EST_LIQ_PRICE_CHANGE, OrderLevel, TrackerEventName } from '@orderly.network/types';
6
- import { ExclamationFillIcon, modal, Text, Tooltip, TooltipTrigger, Flex, Input, cn, inputFormatter, Box, registerSimpleDialog, SimpleDialog, registerSimpleSheet, Select, Grid, Checkbox, Slider, textVariants, SettingFillIcon, useModal, Badge, Divider, Button, TokenIcon, DataTable, useScreen, toast, IconButton, CloseIcon, CloseCircleFillIcon, ChevronRightIcon, SymbolBadge as SymbolBadge$1, SimpleDropdownMenu, CaretDownIcon, Switch, ThrottledButton, SimpleSheet, InfoCircleIcon, AddCircleIcon, PopoverRoot, PopoverTrigger, PopoverContent, DotStatus, EditIcon as EditIcon$1 } from '@orderly.network/ui';
5
+ import { OrderSide, EMPTY_LIST, DistributionType, TrailingCallbackType, OrderType, MarginMode, PositionType, BBOOrderType, ORDER_ENTRY_EST_LIQ_PRICE_CHANGE, OrderLevel, TrackerEventName } from '@orderly.network/types';
6
+ import { registerSimpleDialog, SimpleDialog, ExclamationFillIcon, modal, Text, Tooltip, TooltipTrigger, Flex, Input, cn, inputFormatter, Box, Slider, textVariants, injectable, Button, ThrottledButton, registerSimpleSheet, Select, Grid, Checkbox, SettingFillIcon, useScreen, InfoCircleIcon, AddCircleIcon, useModal, toast, Divider, Switch, SimpleSheet, Badge, TokenIcon, DataTable, IconButton, CloseIcon, CloseCircleFillIcon, ChevronRightIcon, SymbolBadge as SymbolBadge$1, EditIcon as EditIcon$1, SimpleDropdownMenu, CaretDownIcon, DotStatus, PopoverRoot, PopoverTrigger, PopoverContent } from '@orderly.network/ui';
7
7
  import { TPSLPositionTypeWidget, TPSLAdvancedWidget } from '@orderly.network/ui-tpsl';
8
- import { Decimal, zero, formatSymbol, todpIfNeed, getBBOType, removeTrailingZeros } from '@orderly.network/utils';
8
+ import { Decimal, zero, formatSymbol, removeTrailingZeros, todpIfNeed, getBBOType } from '@orderly.network/utils';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import { AuthGuard } from '@orderly.network/ui-connector';
11
11
  import { account } from '@orderly.network/perp';
@@ -541,1035 +541,636 @@ var EditIcon = (props) => {
541
541
  }
542
542
  );
543
543
  };
544
- var RegularFeesUI = (props) => {
545
- const { t } = useTranslation();
546
- const { taker, maker } = props;
547
- const originalTrailingFees = /* @__PURE__ */ jsx(
548
- Flex,
549
- {
550
- itemAlign: "center",
551
- justify: "between",
552
- width: "100%",
553
- gap: 1,
554
- className: "oui-orderEntry-fees",
555
- children: /* @__PURE__ */ jsxs(Flex, { width: "100%", itemAlign: "center", justify: "between", children: [
556
- /* @__PURE__ */ jsx(Text, { className: "oui-fees-label oui-truncate", size: "2xs", children: t("common.fees") }),
557
- /* @__PURE__ */ jsx(
558
- AuthGuard,
559
- {
560
- fallback: () => /* @__PURE__ */ jsxs(Text, { className: "oui-truncate", size: "2xs", children: [
561
- t("dmm.taker"),
562
- ": --% / ",
563
- t("dmm.maker"),
564
- ": --%"
565
- ] }),
566
- children: /* @__PURE__ */ jsxs(Flex, { gap: 1, className: "oui-fees-value-container", children: [
567
- /* @__PURE__ */ jsxs(Text, { className: "oui-truncate", size: "2xs", children: [
568
- t("dmm.taker"),
569
- ":"
570
- ] }),
571
- /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-base-contrast-80", children: taker }),
572
- /* @__PURE__ */ jsx(Text, { size: "2xs", children: "/" }),
573
- /* @__PURE__ */ jsxs(Text, { className: "oui-truncate", size: "2xs", children: [
574
- t("dmm.maker"),
575
- ":"
576
- ] }),
577
- /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-base-contrast-80", children: maker })
578
- ] })
579
- }
580
- )
581
- ] })
544
+ function isBBOOrder(options2) {
545
+ const { order_type, order_type_ext } = options2;
546
+ const isBBO = [OrderType.ASK, OrderType.BID].includes(order_type_ext);
547
+ if (order_type) {
548
+ return order_type === OrderType.LIMIT && isBBO;
549
+ }
550
+ return isBBO;
551
+ }
552
+ function getOrderTypeByBBO(value, size) {
553
+ if ([BBOOrderType.COUNTERPARTY1, BBOOrderType.COUNTERPARTY5].includes(value)) {
554
+ return size === OrderSide.BUY ? OrderType.ASK : OrderType.BID;
555
+ }
556
+ if ([BBOOrderType.QUEUE1, BBOOrderType.QUEUE5].includes(value)) {
557
+ return size === OrderSide.BUY ? OrderType.BID : OrderType.ASK;
558
+ }
559
+ }
560
+ function getOrderLevelByBBO(value) {
561
+ if ([BBOOrderType.COUNTERPARTY1, BBOOrderType.QUEUE1].includes(value)) {
562
+ return OrderLevel.ONE;
563
+ }
564
+ if ([BBOOrderType.COUNTERPARTY5, BBOOrderType.QUEUE5].includes(value)) {
565
+ return OrderLevel.FIVE;
566
+ }
567
+ }
568
+ function getScaledPlaceOrderMessage(result) {
569
+ const rows = result?.data?.rows || [];
570
+ if (rows.length > 0) {
571
+ const totalCount = rows.length;
572
+ const successCount = rows.filter((row) => row.success).length;
573
+ if (successCount === totalCount) {
574
+ return i18n.t("orderEntry.scaledOrder.fullySuccessful", {
575
+ total: totalCount
576
+ });
582
577
  }
583
- );
584
- return originalTrailingFees;
585
- };
586
- var RegularFeesWidget = (props) => {
587
- return /* @__PURE__ */ jsx(RegularFeesUI, { ...props });
588
- };
589
- var FeesWidget = ({ symbol }) => {
590
- const { takerFee, makerFee, rwaTakerFee, rwaMakerFee } = useFeeState();
591
- const info = useRwaSymbolsInfoStore();
592
- const isRwa = info?.[symbol] !== void 0;
593
- return /* @__PURE__ */ jsx(
594
- RegularFeesWidget,
595
- {
596
- taker: isRwa ? rwaTakerFee : takerFee,
597
- maker: isRwa ? rwaMakerFee : makerFee
578
+ if (successCount === 0) {
579
+ return i18n.t("orderEntry.scaledOrder.allFailed");
598
580
  }
581
+ return i18n.t("orderEntry.scaledOrder.partiallySuccessful", {
582
+ successCount,
583
+ total: totalCount
584
+ });
585
+ }
586
+ }
587
+ var safeNumber = (val) => {
588
+ return Number.isNaN(Number(val)) ? 0 : Number(val);
589
+ };
590
+ var SymbolBadge = (props) => {
591
+ const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(
592
+ props.symbol
599
593
  );
594
+ const badge = brokerName ?? brokerId ?? void 0;
595
+ return /* @__PURE__ */ jsx(SymbolBadge$1, { badge, fullName: brokerNameRaw });
600
596
  };
601
- var options = [0.01, 0.05, 0.1];
602
- var SlippageEditor = forwardRef((props, ref) => {
597
+ var OrderConfirmDialog = (props) => {
598
+ const { symbolInfo, order, onConfirm, onCancel } = props;
599
+ const { quote, quote_dp, base_dp } = symbolInfo;
600
+ const { side, order_type, order_type_ext, level, symbol } = order;
601
+ const orderMarginMode = order.margin_mode;
603
602
  const { t } = useTranslation();
604
- const [value, setValue] = useState();
605
- const [customValue, setCustomValue] = useState("");
606
- const [error, setError] = useState(void 0);
607
- useImperativeHandle(ref, () => ({
608
- getValue: () => customValue ? new Decimal(customValue)?.toNumber() : value
609
- }));
610
- useEffect(() => {
611
- if (props.initialValue && !options.includes(props.initialValue)) {
612
- setCustomValue(props.initialValue.toString());
613
- } else {
614
- setValue(props.initialValue);
603
+ const [{ rows: positions }] = usePositionStream(symbol);
604
+ const position = useMemo(
605
+ () => orderMarginMode != null ? positions?.find(
606
+ (row) => row.symbol === symbol && row.margin_mode === orderMarginMode
607
+ ) : positions?.[0],
608
+ [positions, symbol, orderMarginMode]
609
+ );
610
+ const positionQty = position?.position_qty;
611
+ const [_, setNeedConfirm] = useLocalStorage("orderly_order_confirm", true);
612
+ const renderPositionType = () => {
613
+ if (order.position_type === PositionType.FULL) {
614
+ return /* @__PURE__ */ jsx(Text, { children: t("tpsl.positionType.full") });
615
615
  }
616
- }, [props.initialValue, open]);
617
- const onClick = (val) => {
618
- setValue(val);
619
- setCustomValue("");
620
- setError(void 0);
616
+ return /* @__PURE__ */ jsx(Text, { children: t("tpsl.positionType.partial") });
621
617
  };
622
- const onValueChange = (val) => {
623
- if (!val) {
624
- setCustomValue(val);
625
- return;
618
+ const renderPrice = () => {
619
+ if (order_type === OrderType.MARKET || order_type === OrderType.STOP_MARKET) {
620
+ return /* @__PURE__ */ jsx(Text, { intensity: 80, children: t("common.marketPrice") });
626
621
  }
627
- const d = new Decimal(val);
628
- setValue(void 0);
629
- if (d.gt(3)) {
630
- setCustomValue("3");
631
- setError(t("orderEntry.slippage.error.exceed"));
632
- } else {
633
- setCustomValue(val);
634
- setError(void 0);
622
+ if (isBBOOrder({ order_type, order_type_ext })) {
623
+ const bboType = getBBOType({
624
+ type: order_type_ext,
625
+ side,
626
+ level
627
+ });
628
+ const label = {
629
+ [BBOOrderType.COUNTERPARTY1]: t("orderEntry.bbo.counterparty1"),
630
+ [BBOOrderType.COUNTERPARTY5]: t("orderEntry.bbo.counterparty5"),
631
+ [BBOOrderType.QUEUE1]: t("orderEntry.bbo.queue1"),
632
+ [BBOOrderType.QUEUE5]: t("orderEntry.bbo.queue5")
633
+ }[bboType];
634
+ return /* @__PURE__ */ jsx(Text, { intensity: 80, children: label });
635
635
  }
636
+ return /* @__PURE__ */ jsx(
637
+ Text.numeral,
638
+ {
639
+ unit: quote,
640
+ rule: "price",
641
+ className: "oui-text-base-contrast",
642
+ unitClassName: "oui-text-base-contrast-36 oui-ml-1",
643
+ dp: quote_dp,
644
+ padding: false,
645
+ children: order.order_price
646
+ }
647
+ );
636
648
  };
637
- const toolTipButton = props.isMobile ? /* @__PURE__ */ jsx(
638
- "button",
639
- {
640
- onClick: () => {
641
- modal.alert({
642
- title: t("common.tips"),
643
- message: /* @__PURE__ */ jsx(Text, { size: "2xs", children: t("orderEntry.slippage.tips") })
644
- });
645
- },
646
- children: /* @__PURE__ */ jsx(ExclamationFillIcon, { className: "oui-text-base-contrast-54", size: 16 })
649
+ const renderTPSLPrice = ({
650
+ price,
651
+ isOrderPrice,
652
+ isEnable,
653
+ colorType
654
+ }) => {
655
+ if (!isEnable) {
656
+ return /* @__PURE__ */ jsx(Text, { className: "oui-text-base-contrast-36", children: "-- USDC" });
647
657
  }
648
- ) : /* @__PURE__ */ jsx(
649
- Tooltip,
650
- {
651
- content: /* @__PURE__ */ jsx(Text, { intensity: 80, size: "2xs", children: t("orderEntry.slippage.tips") }),
652
- className: "oui-w-[260px] oui-bg-base-6",
653
- arrow: { className: "oui-fill-base-6" },
654
- children: /* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(ExclamationFillIcon, { className: "oui-text-base-contrast-54", size: 16 }) })
658
+ if (!price) {
659
+ if (isOrderPrice) {
660
+ return /* @__PURE__ */ jsx(Text, { className: "oui-text-base-contrast-36", children: t("common.marketPrice") });
661
+ }
655
662
  }
656
- );
657
- return /* @__PURE__ */ jsxs("div", { className: "oui-orderEntry-slippageEditor oui-text-2xs", children: [
658
- /* @__PURE__ */ jsxs(Flex, { mb: 2, gapX: 1, children: [
659
- /* @__PURE__ */ jsx(Text, { size: "xs", children: t("orderEntry.slippage") }),
660
- toolTipButton
661
- ] }),
662
- /* @__PURE__ */ jsxs(Flex, { gapX: 2, children: [
663
- options.map((item) => {
664
- const isActive = value === item;
665
- return /* @__PURE__ */ jsx(
666
- SlippageItem,
667
- {
668
- value: item,
669
- isActive,
670
- onClick: () => {
671
- onClick(item);
672
- }
673
- },
674
- item
675
- );
676
- }),
663
+ return /* @__PURE__ */ jsx(
664
+ Text.numeral,
665
+ {
666
+ unit: "USDC",
667
+ rule: "price",
668
+ className: cn(
669
+ "oui-text-base-contrast",
670
+ colorType === "TP" ? "oui-text-trade-profit" : "oui-text-trade-loss"
671
+ ),
672
+ unitClassName: "oui-text-base-contrast-36 oui-ml-1",
673
+ dp: quote_dp,
674
+ padding: false,
675
+ children: price
676
+ }
677
+ );
678
+ };
679
+ const renderTPSLQty = () => {
680
+ if (!positionQty || !order.order_quantity) {
681
+ return null;
682
+ }
683
+ let qty = new Decimal(order.order_quantity);
684
+ if (order.position_type === PositionType.FULL) {
685
+ qty = qty.plus(new Decimal(positionQty ?? 0));
686
+ }
687
+ return /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
688
+ /* @__PURE__ */ jsx(Text, { children: order.position_type === PositionType.FULL ? t("common.positionQty") : t("common.orderQty") }),
677
689
  /* @__PURE__ */ jsx(
678
- Input,
690
+ Text.numeral,
679
691
  {
680
- suffix: "%",
681
- formatters: [
682
- inputFormatter.numberFormatter,
683
- inputFormatter.dpFormatter(2)
684
- ],
685
- value: customValue,
686
- onValueChange,
687
- classNames: {
688
- root: cn(
689
- "oui-slippageEditor-customInput",
690
- "oui-rounded-md oui-bg-base-6",
691
- "oui-h-[40px] oui-w-[74px]"
692
- ),
693
- input: "oui-text-base-contrast",
694
- additional: "oui-pl-1"
695
- }
692
+ rule: "price",
693
+ dp: base_dp,
694
+ padding: false,
695
+ className: "oui-text-base-contrast",
696
+ children: qty.toNumber()
696
697
  }
697
698
  )
698
- ] }),
699
- !!error && /* @__PURE__ */ jsx(Box, { mt: 5, className: "-oui-mb-5", children: /* @__PURE__ */ jsx(Text, { size: "2xs", color: "danger", children: error }) })
700
- ] });
701
- });
702
- var SlippageItem = ({ value, isActive, onClick }) => {
703
- return /* @__PURE__ */ jsx(
704
- Flex,
705
- {
706
- intensity: 600,
707
- justify: "center",
708
- itemAlign: "center",
709
- r: "md",
710
- width: 74,
711
- height: 40,
712
- className: cn(
713
- "oui-slippageEditor-option",
714
- "oui-cursor-pointer oui-select-none",
715
- isActive ? "oui-bg-primary-light oui-text-primary-contrast/80" : "oui-text-base-contrast-80"
716
- ),
717
- onClick,
718
- children: /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
719
- value,
720
- "%"
721
- ] })
722
- }
723
- );
724
- };
725
- var SlippageCell = (props) => {
726
- const { t } = useTranslation();
727
- const [open2, { setTrue: setOpen, setFalse: setClose, toggle }] = useBoolean(false);
728
- const { isMobile } = useScreen();
729
- const slippageRef = useRef(null);
730
- const onConfirm = () => {
731
- const val = slippageRef.current?.getValue();
732
- props.setSlippage(!val ? "1" : val.toString());
733
- setClose();
734
- return Promise.resolve(true);
699
+ ] });
735
700
  };
736
- return /* @__PURE__ */ jsxs(Fragment, { children: [
737
- /* @__PURE__ */ jsx(
738
- SimpleDialog,
739
- {
740
- open: open2,
741
- onOpenChange: toggle,
742
- title: t("common.settings"),
743
- contentProps: { size: isMobile ? "xs" : "sm" },
744
- classNames: {
745
- footer: "oui-orderEntry-slippage-footer",
746
- body: "oui-orderEntry-slippage-body"
747
- },
748
- actions: {
749
- primary: {
750
- disabled: false,
751
- label: t("common.save"),
752
- onClick: onConfirm,
753
- className: "oui-slippage-save-btn"
754
- },
755
- secondary: {
756
- label: t("common.cancel"),
757
- onClick: () => setClose(),
758
- className: "oui-slippage-cancel-btn"
759
- }
760
- },
761
- children: /* @__PURE__ */ jsx(
762
- SlippageEditor,
701
+ const renderPriceAndTotal = () => {
702
+ if (order_type === OrderType.TRAILING_STOP) {
703
+ const { activated_price, callback_value, callback_rate } = order;
704
+ const callbackView = callback_rate ? /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
705
+ /* @__PURE__ */ jsx(Text, { children: t("orderEntry.trailingRate") }),
706
+ /* @__PURE__ */ jsxs(Text, { className: "oui-text-base-contrast", children: [
707
+ callback_rate,
708
+ "%"
709
+ ] })
710
+ ] }) : /* @__PURE__ */ jsx(
711
+ OrderItem,
712
+ {
713
+ title: t("orderEntry.trailingValue"),
714
+ value: callback_value,
715
+ unit: quote,
716
+ dp: quote_dp
717
+ }
718
+ );
719
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
720
+ activated_price && /* @__PURE__ */ jsx(
721
+ OrderItem,
763
722
  {
764
- ref: slippageRef,
765
- isMobile,
766
- initialValue: props.slippage ? Number(props.slippage) : void 0
723
+ title: t("common.triggerPrice"),
724
+ value: activated_price,
725
+ unit: quote,
726
+ dp: quote_dp
767
727
  }
768
- )
769
- }
770
- ),
771
- /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-orderEntry-slippage", children: [
772
- /* @__PURE__ */ jsx(Text, { className: "oui-slippage-label", size: "2xs", children: t("orderEntry.slippage") }),
728
+ ),
729
+ callbackView
730
+ ] });
731
+ }
732
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
733
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
734
+ /* @__PURE__ */ jsx(Text, { children: t("common.price") }),
735
+ renderPrice()
736
+ ] }),
773
737
  /* @__PURE__ */ jsx(
774
- AuthGuard,
738
+ OrderItem,
775
739
  {
776
- fallback: () => /* @__PURE__ */ jsxs(Text, { size: "2xs", children: [
777
- t("orderEntry.slippage.est"),
778
- ": -% / ",
779
- t("common.max"),
780
- ": --%"
781
- ] }),
782
- children: /* @__PURE__ */ jsxs(Flex, { gap: 1, className: "oui-slippage-value-container", children: [
783
- /* @__PURE__ */ jsx(
784
- Text.numeral,
785
- {
786
- size: "2xs",
787
- rule: "percentages",
788
- prefix: `${t("orderEntry.slippage.est")}: `,
789
- suffix: ` / ${t("common.max")}: `,
790
- children: props.estSlippage ?? 0
791
- }
792
- ),
793
- /* @__PURE__ */ jsx(
794
- "button",
795
- {
796
- className: "oui-slippage-edit-btn oui-text-2xs",
797
- onClick: () => setOpen(),
798
- children: /* @__PURE__ */ jsxs(Flex, { className: "oui-gap-0.5", as: "span", children: [
799
- /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-primary", children: `${props.slippage || "-"}%` }),
800
- /* @__PURE__ */ jsx(
801
- EditIcon$1,
802
- {
803
- className: "oui-slippage-edit-icon oui-text-primary oui-hidden md:oui-block",
804
- size: 12,
805
- opacity: 1
806
- }
807
- )
808
- ] })
809
- }
810
- )
811
- ] })
740
+ title: t("common.estTotal"),
741
+ value: order.total,
742
+ unit: quote,
743
+ dp: quote_dp
812
744
  }
813
745
  )
814
- ] })
815
- ] });
816
- };
817
- var SlippageUI = (props) => {
818
- return /* @__PURE__ */ jsx(SlippageCell, { ...props });
819
- };
820
- function AssetInfo(props) {
821
- const { canTrade, disableFeatures, orderType, symbol } = props;
822
- const { t } = useTranslation();
823
- const { isMobile } = useScreen();
824
- const displayEstLiqPrice = useGetEstLiqPrice({
825
- estLiqPrice: props.estLiqPrice,
826
- symbol,
827
- side: props.side
828
- });
829
- return /* @__PURE__ */ jsxs(
830
- "div",
746
+ ] });
747
+ };
748
+ const header = /* @__PURE__ */ jsxs(
749
+ Flex,
831
750
  {
832
- className: "oui-orderEntry-assetInfo oui-space-y-[2px] xl:oui-space-y-1",
751
+ justify: "between",
752
+ className: "oui-orderEntry-orderConfirmDialog-header",
833
753
  children: [
834
- /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-orderEntry-estLiqPrice", children: [
835
- isMobile ? /* @__PURE__ */ jsx(Text, { size: "2xs", children: t("orderEntry.estLiqPrice") }) : /* @__PURE__ */ jsx(
836
- Tooltip,
837
- {
838
- content: /* @__PURE__ */ jsxs("div", { className: "oui-min-w-[204px] oui-max-w-[280px] oui-text-2xs oui-leading-normal oui-text-base-contrast-80", children: [
839
- /* @__PURE__ */ jsx("div", { className: "oui-text-pretty", children: t("common.liquidationPrice.tooltip") }),
840
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
841
- "a",
842
- {
843
- href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/liquidations",
844
- target: "_blank",
845
- rel: "noopener noreferrer",
846
- className: "oui-text-primary oui-underline",
847
- children: t("common.liquidationPrice.tooltip.learnMore")
848
- }
849
- ) })
850
- ] }),
851
- children: /* @__PURE__ */ jsx(
852
- Text,
853
- {
854
- size: "2xs",
855
- className: "oui-estLiqPrice-label oui-cursor-pointer oui-border-b oui-border-dashed oui-border-line-12",
856
- children: t("orderEntry.estLiqPrice")
857
- }
858
- )
859
- }
860
- ),
754
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, direction: "column", itemAlign: "start", children: [
861
755
  /* @__PURE__ */ jsx(
862
- Text.numeral,
756
+ Text.formatted,
863
757
  {
864
- unit: props.quote,
865
- size: "2xs",
866
- dp: props.dp,
867
- className: "oui-estLiqPrice-value oui-text-base-contrast-80",
868
- unitClassName: "oui-ml-1 oui-text-base-contrast-36",
869
- children: canTrade ? displayEstLiqPrice ?? "--" : "--"
758
+ rule: "symbol",
759
+ formatString: "base",
760
+ showIcon: true,
761
+ className: "oui-orderConfirmDialog-symbol",
762
+ children: order.symbol
870
763
  }
871
- )
764
+ ),
765
+ /* @__PURE__ */ jsx(SymbolBadge, { symbol: order.symbol })
872
766
  ] }),
873
- orderType === OrderType.MARKET && !disableFeatures?.includes("slippageSetting") && /* @__PURE__ */ jsx(
874
- SlippageUI,
767
+ /* @__PURE__ */ jsxs(
768
+ Flex,
875
769
  {
876
- slippage: props.slippage,
877
- setSlippage: props.setSlippage,
878
- estSlippage: props.estSlippage
770
+ justify: "end",
771
+ gapX: 1,
772
+ className: "oui-orderConfirmDialog-header-tags",
773
+ children: [
774
+ /* @__PURE__ */ jsx(OrderTypeTag, { type: order_type }),
775
+ side === OrderSide.BUY ? /* @__PURE__ */ jsx(Badge, { color: "buy", size: "sm", children: t("common.buy") }) : /* @__PURE__ */ jsx(Badge, { color: "sell", size: "sm", children: t("common.sell") })
776
+ ]
879
777
  }
880
- ),
881
- !disableFeatures?.includes("feesInfo") && /* @__PURE__ */ jsx(FeesWidget, { symbol: props.symbol })
778
+ )
882
779
  ]
883
780
  }
884
781
  );
885
- }
886
- var calculateLTVColor = (val) => {
887
- if (val >= 0 && val < 50) {
888
- return "oui-text-success";
889
- } else if (val >= 50 && val < 80) {
890
- return "oui-text-warning";
891
- } else if (val >= 80) {
892
- return "oui-text-danger";
893
- } else {
894
- return "";
895
- }
896
- };
897
- var LTVRiskTooltipUI = (props) => {
898
- const { t } = useTranslation();
899
- const {
900
- ltv_threshold,
901
- negative_usdc_threshold,
902
- isThresholdLoading,
903
- holdingData = [],
904
- currentLtv,
905
- onConvert,
906
- marginMode
907
- } = props;
908
- return /* @__PURE__ */ jsxs(
909
- Flex,
782
+ const quantityItem = /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
783
+ /* @__PURE__ */ jsx(Text, { children: t("common.orderQty") }),
784
+ /* @__PURE__ */ jsx(
785
+ Text.numeral,
786
+ {
787
+ rule: "price",
788
+ dp: base_dp,
789
+ padding: false,
790
+ className: "oui-text-base-contrast",
791
+ children: order.order_quantity
792
+ }
793
+ )
794
+ ] });
795
+ const triggerPriceItem = (order_type === OrderType.STOP_LIMIT || order_type === OrderType.STOP_MARKET && order.trigger_price) && /* @__PURE__ */ jsx(
796
+ OrderItem,
910
797
  {
911
- gap: 1,
912
- className: "oui-orderEntry-ltvRiskTooltip oui-w-72 oui-max-w-72",
913
- direction: "column",
914
- itemAlign: "start",
915
- children: [
916
- /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", itemAlign: "center", children: [
917
- /* @__PURE__ */ jsx(Text, { intensity: 36, size: "xs", children: t("common.assets") }),
918
- /* @__PURE__ */ jsx(Text, { intensity: 36, size: "xs", children: t("transfer.deposit.collateralContribution") })
919
- ] }),
920
- holdingData.map((asset, index) => {
921
- return /* @__PURE__ */ jsxs(
798
+ title: t("common.trigger"),
799
+ value: order.trigger_price,
800
+ unit: quote,
801
+ dp: quote_dp
802
+ }
803
+ );
804
+ const tpslTriggerPrice = (order.tp_trigger_price || order.sl_trigger_price) && /* @__PURE__ */ jsxs(Fragment, { children: [
805
+ /* @__PURE__ */ jsx(Divider, { className: "oui-my-4" }),
806
+ /* @__PURE__ */ jsxs(
807
+ "div",
808
+ {
809
+ className: textVariants({
810
+ size: "sm",
811
+ intensity: 54,
812
+ className: "oui-space-y-1 oui-w-full oui-flex oui-flex-col oui-gap-3"
813
+ }),
814
+ children: [
815
+ /* @__PURE__ */ jsx(Text, { className: "oui-text-base-contrast", children: renderPositionType() }),
816
+ renderTPSLQty(),
817
+ /* @__PURE__ */ jsxs(
922
818
  Flex,
923
819
  {
924
- width: "100%",
820
+ direction: "column",
925
821
  justify: "between",
926
- itemAlign: "center",
822
+ itemAlign: "start",
823
+ gap: 1,
824
+ className: "oui-w-full",
927
825
  children: [
928
- /* @__PURE__ */ jsx(Text, { intensity: 80, size: "xs", children: asset.token }),
929
- /* @__PURE__ */ jsx(
930
- Text,
931
- {
932
- size: "xs",
933
- intensity: 80,
934
- className: cn(
935
- Number(asset.collateralContribution) < 0 && "oui-text-warning"
936
- ),
937
- children: removeTrailingZeros(asset.collateralContribution)
938
- }
939
- )
826
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
827
+ /* @__PURE__ */ jsx(Text, { children: t("tpsl.tpTriggerPrice") }),
828
+ renderTPSLPrice({
829
+ price: order.tp_trigger_price ?? "",
830
+ isOrderPrice: false,
831
+ isEnable: !!order.tp_trigger_price,
832
+ colorType: "TP"
833
+ })
834
+ ] }),
835
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
836
+ /* @__PURE__ */ jsx(Text, { children: t("tpsl.tpOrderPrice") }),
837
+ renderTPSLPrice({
838
+ price: order.tp_order_price ?? "",
839
+ isOrderPrice: true,
840
+ isEnable: !!order.tp_trigger_price,
841
+ colorType: "TP"
842
+ })
843
+ ] })
940
844
  ]
941
- },
942
- `item-${index}`
943
- );
944
- }),
945
- /* @__PURE__ */ jsx(Divider, { className: "oui-w-full" }),
946
- /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", itemAlign: "center", children: [
947
- /* @__PURE__ */ jsx(Text, { intensity: 36, size: "xs", children: t("transfer.LTV.currentLTV") }),
845
+ }
846
+ ),
948
847
  /* @__PURE__ */ jsxs(
949
- Text,
848
+ Flex,
950
849
  {
951
- size: "xs",
952
- intensity: 36,
953
- className: cn("oui-select-none", calculateLTVColor(currentLtv)),
850
+ direction: "column",
851
+ justify: "between",
852
+ itemAlign: "start",
853
+ gap: 1,
854
+ className: "oui-w-full",
954
855
  children: [
955
- currentLtv,
956
- "%"
856
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
857
+ /* @__PURE__ */ jsx(Text, { children: t("tpsl.slTriggerPrice") }),
858
+ renderTPSLPrice({
859
+ price: order.sl_trigger_price ?? "",
860
+ isOrderPrice: false,
861
+ isEnable: !!order.sl_trigger_price,
862
+ colorType: "SL"
863
+ })
864
+ ] }),
865
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
866
+ /* @__PURE__ */ jsx(Text, { children: t("tpsl.slOrderPrice") }),
867
+ renderTPSLPrice({
868
+ price: order.sl_order_price ?? "",
869
+ isOrderPrice: true,
870
+ isEnable: !!order.sl_trigger_price,
871
+ colorType: "SL"
872
+ })
873
+ ] })
957
874
  ]
958
875
  }
959
876
  )
960
- ] }),
961
- /* @__PURE__ */ jsx(Text, { className: "oui-py-2", intensity: 54, size: "2xs", children: t("transfer.LTV.tooltip", {
962
- threshold: isThresholdLoading ? "-" : ltv_threshold,
963
- usdcThreshold: isThresholdLoading ? "-" : negative_usdc_threshold
964
- }) }),
877
+ ]
878
+ }
879
+ )
880
+ ] });
881
+ const orderConfirmCheckbox = /* @__PURE__ */ jsxs(
882
+ Flex,
883
+ {
884
+ gapX: 1,
885
+ pt: 4,
886
+ pb: 5,
887
+ className: "oui-orderEntry-orderConfirmDialog-disableConfirm",
888
+ children: [
889
+ /* @__PURE__ */ jsx(
890
+ Checkbox,
891
+ {
892
+ id: "orderConfirm",
893
+ color: "white",
894
+ className: "oui-orderConfirmDialog-disableConfirm-checkbox",
895
+ onCheckedChange: (checked) => {
896
+ setNeedConfirm(!!!checked);
897
+ }
898
+ }
899
+ ),
900
+ /* @__PURE__ */ jsx(
901
+ "label",
902
+ {
903
+ htmlFor: "orderConfirm",
904
+ className: textVariants({
905
+ size: "xs",
906
+ intensity: 54
907
+ }),
908
+ children: t("orderEntry.disableOrderConfirm")
909
+ }
910
+ )
911
+ ]
912
+ }
913
+ );
914
+ const buttons = /* @__PURE__ */ jsxs(
915
+ Grid,
916
+ {
917
+ cols: 2,
918
+ gapX: 3,
919
+ className: "oui-orderEntry-orderConfirmDialog-actions",
920
+ children: [
965
921
  /* @__PURE__ */ jsx(
966
922
  Button,
967
923
  {
968
- fullWidth: true,
969
- size: "md",
970
- variant: "outlined",
971
924
  color: "secondary",
972
- className: "oui-ltvRiskTooltip-convert-btn",
973
- onClick: onConvert,
974
- children: t("transfer.convert.convertAssets")
925
+ size: "md",
926
+ className: "oui-cancel-btn",
927
+ onClick: () => onCancel(),
928
+ children: t("common.cancel")
929
+ }
930
+ ),
931
+ /* @__PURE__ */ jsx(
932
+ Button,
933
+ {
934
+ size: "md",
935
+ className: "oui-confirm-btn",
936
+ onClick: () => onConfirm(),
937
+ children: t("common.confirm")
975
938
  }
976
939
  )
977
940
  ]
978
941
  }
979
942
  );
943
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
944
+ header,
945
+ /* @__PURE__ */ jsx(Divider, { className: "oui-my-4" }),
946
+ /* @__PURE__ */ jsxs(
947
+ "div",
948
+ {
949
+ className: textVariants({
950
+ size: "sm",
951
+ intensity: 54,
952
+ className: "oui-orderEntry-orderConfirmDialog-content oui-space-y-1"
953
+ }),
954
+ children: [
955
+ quantityItem,
956
+ triggerPriceItem,
957
+ renderPriceAndTotal()
958
+ ]
959
+ }
960
+ ),
961
+ tpslTriggerPrice,
962
+ orderConfirmCheckbox,
963
+ buttons
964
+ ] });
980
965
  };
981
- var useConvertThreshold = () => {
982
- const { data, error, isLoading } = useQuery(
983
- "/v1/public/auto_convert_threshold",
984
- { errorRetryCount: 3 }
985
- );
986
- return {
987
- ltv_threshold: new Decimal(data?.ltv_threshold ?? 0).mul(100).toNumber(),
988
- negative_usdc_threshold: data?.negative_usdc_threshold,
989
- isLoading,
990
- error
991
- };
992
- };
993
- var useLTVTooltipScript = (marginMode) => {
994
- const { data: holdingList = [], isLoading: isHoldingLoading } = useHoldingStream();
995
- const {
996
- ltv_threshold,
997
- negative_usdc_threshold,
998
- isLoading: isThresholdLoading
999
- } = useConvertThreshold();
1000
- const tokensInfo = useAppStore((state) => state.tokensInfo);
1001
- const { getIndexPrice } = useIndexPricesStream();
1002
- const holdingData = holdingList.map((item) => {
1003
- const tokenInfo = tokensInfo?.find(({ token }) => token === item.token);
1004
- const indexPrice = getIndexPrice(item.token);
1005
- const collateralRatio = tokenInfo ? account.collateralRatio({
1006
- baseWeight: tokenInfo.base_weight ?? 0,
1007
- discountFactor: tokenInfo.discount_factor ?? 0,
1008
- collateralQty: item.holding,
1009
- collateralCap: tokenInfo?.user_max_qty ?? item.holding,
1010
- indexPrice
1011
- }) : zero;
1012
- const collateralContribution = account.collateralContribution({
1013
- collateralQty: item.holding,
1014
- collateralCap: tokenInfo?.user_max_qty ?? item.holding,
1015
- collateralRatio: collateralRatio.toNumber(),
1016
- indexPrice
1017
- });
1018
- return {
1019
- ...item,
1020
- collateralContribution
1021
- };
1022
- });
1023
- const currentLtv = useComputedLTV();
1024
- const onConvert = useCallback(async () => {
1025
- return modal.show("ConvertDialogId");
1026
- }, []);
1027
- return {
1028
- holdingData,
1029
- isHoldingLoading,
1030
- ltv_threshold,
1031
- negative_usdc_threshold,
1032
- isThresholdLoading,
1033
- currentLtv,
1034
- onConvert,
1035
- marginMode
1036
- };
1037
- };
1038
- var LTVRiskTooltipWidget = ({
1039
- marginMode
1040
- }) => {
1041
- const state = useLTVTooltipScript(marginMode);
1042
- return /* @__PURE__ */ jsx(LTVRiskTooltipUI, { ...state });
966
+ var OrderItem = (props) => {
967
+ const { title, value, unit, dp } = props;
968
+ return /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
969
+ /* @__PURE__ */ jsx(Text, { children: title }),
970
+ /* @__PURE__ */ jsx(
971
+ Text.numeral,
972
+ {
973
+ unit,
974
+ rule: "price",
975
+ dp,
976
+ padding: false,
977
+ className: "oui-text-base-contrast",
978
+ unitClassName: "oui-text-base-contrast-36 oui-ml-1",
979
+ children: value
980
+ }
981
+ )
982
+ ] });
1043
983
  };
1044
- var Available = (props) => {
1045
- const { canTrade, currentLtv, quote, freeCollateral, marginMode } = props;
984
+ OrderConfirmDialog.displayName = "OrderConfirmDialog";
985
+ var OrderTypeTag = (props) => {
1046
986
  const { t } = useTranslation();
1047
- const { isMobile } = useScreen();
1048
- const showLTV = useMemo(() => {
1049
- return typeof currentLtv === "number" && !Number.isNaN(currentLtv) && currentLtv > 0;
1050
- }, [currentLtv]);
1051
- return /* @__PURE__ */ jsxs(
1052
- Flex,
1053
- {
1054
- itemAlign: "center",
1055
- justify: "between",
1056
- className: "oui-orderEntry-available",
1057
- children: [
1058
- marginMode === MarginMode.ISOLATED ? /* @__PURE__ */ jsx(Tooltip, { content: t("transfer.LTV.isolatedModeUsdcOnly"), children: /* @__PURE__ */ jsx(Text, { className: "oui-available-label oui-cursor-pointer", size: "2xs", children: t("common.available") }) }) : /* @__PURE__ */ jsx(Text, { className: "oui-available-label", size: "2xs", children: t("common.available") }),
1059
- /* @__PURE__ */ jsxs(Flex, { itemAlign: "center", justify: "center", gap: 1, children: [
1060
- showLTV && /* @__PURE__ */ jsx(
1061
- Tooltip,
1062
- {
1063
- className: "oui-available-ltvRisk-tooltip oui-bg-base-6 oui-p-2",
1064
- content: /* @__PURE__ */ jsx(LTVRiskTooltipWidget, { marginMode }),
1065
- children: /* @__PURE__ */ jsx(
1066
- InfoCircleIcon,
1067
- {
1068
- className: "oui-cursor-pointer oui-text-warning oui-opacity-80"
1069
- }
1070
- )
1071
- }
1072
- ),
1073
- /* @__PURE__ */ jsx(
1074
- Text.numeral,
1075
- {
1076
- unit: quote,
1077
- size: "2xs",
1078
- className: "oui-available-value oui-text-base-contrast-80",
1079
- unitClassName: "oui-ml-1 oui-text-base-contrast-54",
1080
- dp: 2,
1081
- padding: false,
1082
- children: canTrade ? freeCollateral : 0
1083
- }
1084
- ),
1085
- /* @__PURE__ */ jsx(
1086
- Button,
1087
- {
1088
- variant: "text",
1089
- size: "xs",
1090
- color: "secondary",
1091
- className: "oui-available-deposit-icon oui-p-0 hover:oui-text-base-contrast-80",
1092
- onClick: () => {
1093
- const handleDomId = isMobile ? "DepositAndWithdrawWithSheetId" : "DepositAndWithdrawWithDialogId";
1094
- modal.show(handleDomId, {
1095
- activeTab: "deposit"
1096
- });
1097
- },
1098
- children: /* @__PURE__ */ jsx(AddCircleIcon, { opacity: 1 })
1099
- }
1100
- )
1101
- ] })
1102
- ]
987
+ const typeStr = useMemo(() => {
988
+ switch (props.type) {
989
+ case OrderType.LIMIT:
990
+ return t("orderEntry.orderType.limit");
991
+ case OrderType.MARKET:
992
+ return t("common.marketPrice");
993
+ case OrderType.STOP_LIMIT:
994
+ return t("orderEntry.orderType.stopLimit");
995
+ case OrderType.STOP_MARKET:
996
+ return t("orderEntry.orderType.stopMarket");
997
+ case OrderType.TRAILING_STOP:
998
+ return t("orderEntry.orderType.trailingStop");
999
+ default:
1000
+ return "";
1103
1001
  }
1104
- );
1002
+ }, [props.type]);
1003
+ return /* @__PURE__ */ jsx(Badge, { color: "neutral", size: "sm", children: typeStr });
1105
1004
  };
1106
- function isBBOOrder(options2) {
1107
- const { order_type, order_type_ext } = options2;
1108
- const isBBO = [OrderType.ASK, OrderType.BID].includes(order_type_ext);
1109
- if (order_type) {
1110
- return order_type === OrderType.LIMIT && isBBO;
1111
- }
1112
- return isBBO;
1113
- }
1114
- function getOrderTypeByBBO(value, size) {
1115
- if ([BBOOrderType.COUNTERPARTY1, BBOOrderType.COUNTERPARTY5].includes(value)) {
1116
- return size === OrderSide.BUY ? OrderType.ASK : OrderType.BID;
1117
- }
1118
- if ([BBOOrderType.QUEUE1, BBOOrderType.QUEUE5].includes(value)) {
1119
- return size === OrderSide.BUY ? OrderType.BID : OrderType.ASK;
1120
- }
1121
- }
1122
- function getOrderLevelByBBO(value) {
1123
- if ([BBOOrderType.COUNTERPARTY1, BBOOrderType.QUEUE1].includes(value)) {
1124
- return OrderLevel.ONE;
1125
- }
1126
- if ([BBOOrderType.COUNTERPARTY5, BBOOrderType.QUEUE5].includes(value)) {
1127
- return OrderLevel.FIVE;
1128
- }
1129
- }
1130
- function getScaledPlaceOrderMessage(result) {
1131
- const rows = result?.data?.rows || [];
1132
- if (rows.length > 0) {
1133
- const totalCount = rows.length;
1134
- const successCount = rows.filter((row) => row.success).length;
1135
- if (successCount === totalCount) {
1136
- return i18n.t("orderEntry.scaledOrder.fullySuccessful", {
1137
- total: totalCount
1138
- });
1139
- }
1140
- if (successCount === 0) {
1141
- return i18n.t("orderEntry.scaledOrder.allFailed");
1005
+ var Dialog = (props) => {
1006
+ const { close, resolve, reject, ...rest } = props;
1007
+ return /* @__PURE__ */ jsx(
1008
+ OrderConfirmDialog,
1009
+ {
1010
+ ...rest,
1011
+ onCancel: () => {
1012
+ reject();
1013
+ close();
1014
+ },
1015
+ onConfirm: () => {
1016
+ resolve();
1017
+ close();
1018
+ }
1142
1019
  }
1143
- return i18n.t("orderEntry.scaledOrder.partiallySuccessful", {
1144
- successCount,
1145
- total: totalCount
1146
- });
1147
- }
1148
- }
1149
- var safeNumber = (val) => {
1150
- return Number.isNaN(Number(val)) ? 0 : Number(val);
1151
- };
1152
- var SymbolBadge = (props) => {
1153
- const { brokerId, brokerName, brokerNameRaw } = useBadgeBySymbol(
1154
- props.symbol
1155
1020
  );
1156
- const badge = brokerName ?? brokerId ?? void 0;
1157
- return /* @__PURE__ */ jsx(SymbolBadge$1, { badge, fullName: brokerNameRaw });
1158
1021
  };
1159
- var OrderConfirmDialog = (props) => {
1160
- const { symbolInfo, order, onConfirm, onCancel } = props;
1161
- const { quote, quote_dp, base_dp } = symbolInfo;
1162
- const { side, order_type, order_type_ext, level, symbol } = order;
1163
- const orderMarginMode = order.margin_mode;
1022
+ var orderConfirmDialogId = "orderConfirm";
1023
+ registerSimpleDialog(orderConfirmDialogId, Dialog, {
1024
+ size: "sm",
1025
+ title: () => i18n.t("orderEntry.orderConfirm")
1026
+ });
1027
+ var MaxQtyConfirm = memo((props) => {
1164
1028
  const { t } = useTranslation();
1165
- const [{ rows: positions }] = usePositionStream(symbol);
1166
- const position = useMemo(
1167
- () => orderMarginMode != null ? positions?.find(
1168
- (row) => row.symbol === symbol && row.margin_mode === orderMarginMode
1169
- ) : positions?.[0],
1170
- [positions, symbol, orderMarginMode]
1171
- );
1172
- const positionQty = position?.position_qty;
1173
- const [_, setNeedConfirm] = useLocalStorage("orderly_order_confirm", true);
1174
- const renderPositionType = () => {
1175
- if (order.position_type === PositionType.FULL) {
1176
- return /* @__PURE__ */ jsx(Text, { children: t("tpsl.positionType.full") });
1029
+ return /* @__PURE__ */ jsx(
1030
+ SimpleDialog,
1031
+ {
1032
+ open: props.open,
1033
+ title: t("orderEntry.orderConfirm"),
1034
+ closable: true,
1035
+ onOpenChange: props.onOpenChange,
1036
+ size: "sm",
1037
+ classNames: {
1038
+ footer: "oui-maxQtyConfirm-footer",
1039
+ body: "oui-maxQtyConfirm-body"
1040
+ },
1041
+ actions: {
1042
+ primary: {
1043
+ label: t("orderEntry.placeOrderNow"),
1044
+ className: "oui-primary-btn oui-text-sm oui-font-semibold oui-w-[100%] oui-h-8",
1045
+ onClick: () => {
1046
+ props.onConfirm();
1047
+ return Promise.resolve();
1048
+ }
1049
+ },
1050
+ secondary: {
1051
+ label: t("common.cancel"),
1052
+ className: "oui-secondary-btn oui-text-sm oui-font-semibold oui-w-[100%] oui-h-8",
1053
+ onClick: () => {
1054
+ props.onOpenChange(false);
1055
+ return Promise.resolve();
1056
+ }
1057
+ }
1058
+ },
1059
+ children: /* @__PURE__ */ jsx("div", { className: "oui-maxQtyConfirm-content oui-text-2xs lg:oui-text-sm", children: t("orderEntry.maxQty.reminder.content", {
1060
+ maxQty: `${props.maxQty} ${props.base}`
1061
+ }) })
1177
1062
  }
1178
- return /* @__PURE__ */ jsx(Text, { children: t("tpsl.positionType.partial") });
1179
- };
1180
- const renderPrice = () => {
1181
- if (order_type === OrderType.MARKET || order_type === OrderType.STOP_MARKET) {
1182
- return /* @__PURE__ */ jsx(Text, { intensity: 80, children: t("common.marketPrice") });
1183
- }
1184
- if (isBBOOrder({ order_type, order_type_ext })) {
1185
- const bboType = getBBOType({
1186
- type: order_type_ext,
1187
- side,
1188
- level
1189
- });
1190
- const label = {
1191
- [BBOOrderType.COUNTERPARTY1]: t("orderEntry.bbo.counterparty1"),
1192
- [BBOOrderType.COUNTERPARTY5]: t("orderEntry.bbo.counterparty5"),
1193
- [BBOOrderType.QUEUE1]: t("orderEntry.bbo.queue1"),
1194
- [BBOOrderType.QUEUE5]: t("orderEntry.bbo.queue5")
1195
- }[bboType];
1196
- return /* @__PURE__ */ jsx(Text, { intensity: 80, children: label });
1197
- }
1198
- return /* @__PURE__ */ jsx(
1199
- Text.numeral,
1200
- {
1201
- unit: quote,
1202
- rule: "price",
1203
- className: "oui-text-base-contrast",
1204
- unitClassName: "oui-text-base-contrast-36 oui-ml-1",
1205
- dp: quote_dp,
1206
- padding: false,
1207
- children: order.order_price
1208
- }
1209
- );
1210
- };
1211
- const renderTPSLPrice = ({
1212
- price,
1213
- isOrderPrice,
1214
- isEnable,
1215
- colorType
1216
- }) => {
1217
- if (!isEnable) {
1218
- return /* @__PURE__ */ jsx(Text, { className: "oui-text-base-contrast-36", children: "-- USDC" });
1219
- }
1220
- if (!price) {
1221
- if (isOrderPrice) {
1222
- return /* @__PURE__ */ jsx(Text, { className: "oui-text-base-contrast-36", children: t("common.marketPrice") });
1223
- }
1224
- }
1225
- return /* @__PURE__ */ jsx(
1226
- Text.numeral,
1227
- {
1228
- unit: "USDC",
1229
- rule: "price",
1230
- className: cn(
1231
- "oui-text-base-contrast",
1232
- colorType === "TP" ? "oui-text-trade-profit" : "oui-text-trade-loss"
1063
+ );
1064
+ });
1065
+ var PermissionlessMarketNoticeDialog = (props) => {
1066
+ const { onConfirm, onCancel } = props;
1067
+ const { t } = useTranslation();
1068
+ const [checked, setChecked] = useState(false);
1069
+ const content = /* @__PURE__ */ jsxs(
1070
+ Flex,
1071
+ {
1072
+ direction: "column",
1073
+ gap: 3,
1074
+ itemAlign: "start",
1075
+ className: "oui-permissionlessNotice-content",
1076
+ children: [
1077
+ /* @__PURE__ */ jsx(
1078
+ Text,
1079
+ {
1080
+ className: textVariants({
1081
+ size: "sm",
1082
+ intensity: 54
1083
+ }),
1084
+ children: t("orderEntry.permissionlessNotice.content1")
1085
+ }
1233
1086
  ),
1234
- unitClassName: "oui-text-base-contrast-36 oui-ml-1",
1235
- dp: quote_dp,
1236
- padding: false,
1237
- children: price
1238
- }
1239
- );
1240
- };
1241
- const renderTPSLQty = () => {
1242
- if (!positionQty || !order.order_quantity) {
1243
- return null;
1244
- }
1245
- let qty = new Decimal(order.order_quantity);
1246
- if (order.position_type === PositionType.FULL) {
1247
- qty = qty.plus(new Decimal(positionQty ?? 0));
1248
- }
1249
- return /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
1250
- /* @__PURE__ */ jsx(Text, { children: order.position_type === PositionType.FULL ? t("common.positionQty") : t("common.orderQty") }),
1251
- /* @__PURE__ */ jsx(
1252
- Text.numeral,
1253
- {
1254
- rule: "price",
1255
- dp: base_dp,
1256
- padding: false,
1257
- className: "oui-text-base-contrast",
1258
- children: qty.toNumber()
1259
- }
1260
- )
1261
- ] });
1262
- };
1263
- const renderPriceAndTotal = () => {
1264
- if (order_type === OrderType.TRAILING_STOP) {
1265
- const { activated_price, callback_value, callback_rate } = order;
1266
- const callbackView = callback_rate ? /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
1267
- /* @__PURE__ */ jsx(Text, { children: t("orderEntry.trailingRate") }),
1268
- /* @__PURE__ */ jsxs(Text, { className: "oui-text-base-contrast", children: [
1269
- callback_rate,
1270
- "%"
1271
- ] })
1272
- ] }) : /* @__PURE__ */ jsx(
1273
- OrderItem,
1274
- {
1275
- title: t("orderEntry.trailingValue"),
1276
- value: callback_value,
1277
- unit: quote,
1278
- dp: quote_dp
1279
- }
1280
- );
1281
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1282
- activated_price && /* @__PURE__ */ jsx(
1283
- OrderItem,
1087
+ /* @__PURE__ */ jsx(
1088
+ Text,
1284
1089
  {
1285
- title: t("common.triggerPrice"),
1286
- value: activated_price,
1287
- unit: quote,
1288
- dp: quote_dp
1090
+ className: textVariants({
1091
+ size: "sm",
1092
+ intensity: 54
1093
+ }),
1094
+ children: t("orderEntry.permissionlessNotice.content2")
1289
1095
  }
1290
1096
  ),
1291
- callbackView
1292
- ] });
1097
+ /* @__PURE__ */ jsx(
1098
+ Text,
1099
+ {
1100
+ className: textVariants({
1101
+ size: "sm",
1102
+ intensity: 54
1103
+ }),
1104
+ children: t("orderEntry.permissionlessNotice.content3")
1105
+ }
1106
+ )
1107
+ ]
1293
1108
  }
1294
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1295
- /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
1296
- /* @__PURE__ */ jsx(Text, { children: t("common.price") }),
1297
- renderPrice()
1298
- ] }),
1299
- /* @__PURE__ */ jsx(
1300
- OrderItem,
1301
- {
1302
- title: t("common.estTotal"),
1303
- value: order.total,
1304
- unit: quote,
1305
- dp: quote_dp
1306
- }
1307
- )
1308
- ] });
1309
- };
1310
- const header = /* @__PURE__ */ jsxs(
1109
+ );
1110
+ const checkboxSection = /* @__PURE__ */ jsxs(
1311
1111
  Flex,
1312
1112
  {
1313
- justify: "between",
1314
- className: "oui-orderEntry-orderConfirmDialog-header",
1113
+ gapX: 1,
1114
+ pt: 4,
1115
+ pb: 5,
1116
+ itemAlign: "start",
1117
+ className: "oui-permissionlessNotice-checkbox oui-orderEntry-orderConfirmDialog-disableConfirm oui-cursor-pointer",
1315
1118
  children: [
1316
- /* @__PURE__ */ jsxs(Flex, { gap: 2, direction: "column", itemAlign: "start", children: [
1317
- /* @__PURE__ */ jsx(
1318
- Text.formatted,
1319
- {
1320
- rule: "symbol",
1321
- formatString: "base",
1322
- showIcon: true,
1323
- className: "oui-orderConfirmDialog-symbol",
1324
- children: order.symbol
1325
- }
1326
- ),
1327
- /* @__PURE__ */ jsx(SymbolBadge, { symbol: order.symbol })
1328
- ] }),
1329
- /* @__PURE__ */ jsxs(
1330
- Flex,
1119
+ /* @__PURE__ */ jsx(
1120
+ Checkbox,
1331
1121
  {
1332
- justify: "end",
1333
- gapX: 1,
1334
- className: "oui-orderConfirmDialog-header-tags",
1335
- children: [
1336
- /* @__PURE__ */ jsx(OrderTypeTag, { type: order_type }),
1337
- side === OrderSide.BUY ? /* @__PURE__ */ jsx(Badge, { color: "buy", size: "sm", children: t("common.buy") }) : /* @__PURE__ */ jsx(Badge, { color: "sell", size: "sm", children: t("common.sell") })
1338
- ]
1122
+ id: "permissionlessNotice",
1123
+ color: "white",
1124
+ className: "oui-permissionlessNotice-checkbox-input oui-mt-1",
1125
+ checked,
1126
+ onCheckedChange: (value) => setChecked(!!value)
1127
+ }
1128
+ ),
1129
+ /* @__PURE__ */ jsx(
1130
+ "label",
1131
+ {
1132
+ htmlFor: "permissionlessNotice",
1133
+ className: textVariants({
1134
+ size: "xs",
1135
+ intensity: 54,
1136
+ className: "oui-cursor-pointer"
1137
+ }),
1138
+ children: t("orderEntry.permissionlessNotice.checkbox")
1339
1139
  }
1340
1140
  )
1341
1141
  ]
1342
1142
  }
1343
1143
  );
1344
- const quantityItem = /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
1345
- /* @__PURE__ */ jsx(Text, { children: t("common.orderQty") }),
1346
- /* @__PURE__ */ jsx(
1347
- Text.numeral,
1348
- {
1349
- rule: "price",
1350
- dp: base_dp,
1351
- padding: false,
1352
- className: "oui-text-base-contrast",
1353
- children: order.order_quantity
1354
- }
1355
- )
1356
- ] });
1357
- const triggerPriceItem = (order_type === OrderType.STOP_LIMIT || order_type === OrderType.STOP_MARKET && order.trigger_price) && /* @__PURE__ */ jsx(
1358
- OrderItem,
1144
+ const confirmButton = /* @__PURE__ */ jsx(
1145
+ Flex,
1359
1146
  {
1360
- title: t("common.trigger"),
1361
- value: order.trigger_price,
1362
- unit: quote,
1363
- dp: quote_dp
1364
- }
1365
- );
1366
- const tpslTriggerPrice = (order.tp_trigger_price || order.sl_trigger_price) && /* @__PURE__ */ jsxs(Fragment, { children: [
1367
- /* @__PURE__ */ jsx(Divider, { className: "oui-my-4" }),
1368
- /* @__PURE__ */ jsxs(
1369
- "div",
1370
- {
1371
- className: textVariants({
1372
- size: "sm",
1373
- intensity: 54,
1374
- className: "oui-space-y-1 oui-w-full oui-flex oui-flex-col oui-gap-3"
1375
- }),
1376
- children: [
1377
- /* @__PURE__ */ jsx(Text, { className: "oui-text-base-contrast", children: renderPositionType() }),
1378
- renderTPSLQty(),
1379
- /* @__PURE__ */ jsxs(
1380
- Flex,
1381
- {
1382
- direction: "column",
1383
- justify: "between",
1384
- itemAlign: "start",
1385
- gap: 1,
1386
- className: "oui-w-full",
1387
- children: [
1388
- /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
1389
- /* @__PURE__ */ jsx(Text, { children: t("tpsl.tpTriggerPrice") }),
1390
- renderTPSLPrice({
1391
- price: order.tp_trigger_price ?? "",
1392
- isOrderPrice: false,
1393
- isEnable: !!order.tp_trigger_price,
1394
- colorType: "TP"
1395
- })
1396
- ] }),
1397
- /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
1398
- /* @__PURE__ */ jsx(Text, { children: t("tpsl.tpOrderPrice") }),
1399
- renderTPSLPrice({
1400
- price: order.tp_order_price ?? "",
1401
- isOrderPrice: true,
1402
- isEnable: !!order.tp_trigger_price,
1403
- colorType: "TP"
1404
- })
1405
- ] })
1406
- ]
1407
- }
1408
- ),
1409
- /* @__PURE__ */ jsxs(
1410
- Flex,
1411
- {
1412
- direction: "column",
1413
- justify: "between",
1414
- itemAlign: "start",
1415
- gap: 1,
1416
- className: "oui-w-full",
1417
- children: [
1418
- /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
1419
- /* @__PURE__ */ jsx(Text, { children: t("tpsl.slTriggerPrice") }),
1420
- renderTPSLPrice({
1421
- price: order.sl_trigger_price ?? "",
1422
- isOrderPrice: false,
1423
- isEnable: !!order.sl_trigger_price,
1424
- colorType: "SL"
1425
- })
1426
- ] }),
1427
- /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-w-full", children: [
1428
- /* @__PURE__ */ jsx(Text, { children: t("tpsl.slOrderPrice") }),
1429
- renderTPSLPrice({
1430
- price: order.sl_order_price ?? "",
1431
- isOrderPrice: true,
1432
- isEnable: !!order.sl_trigger_price,
1433
- colorType: "SL"
1434
- })
1435
- ] })
1436
- ]
1437
- }
1438
- )
1439
- ]
1440
- }
1441
- )
1442
- ] });
1443
- const orderConfirmCheckbox = /* @__PURE__ */ jsxs(
1444
- Flex,
1445
- {
1446
- gapX: 1,
1447
- pt: 4,
1448
- pb: 5,
1449
- className: "oui-orderEntry-orderConfirmDialog-disableConfirm",
1450
- children: [
1451
- /* @__PURE__ */ jsx(
1452
- Checkbox,
1453
- {
1454
- id: "orderConfirm",
1455
- color: "white",
1456
- className: "oui-orderConfirmDialog-disableConfirm-checkbox",
1457
- onCheckedChange: (checked) => {
1458
- setNeedConfirm(!!!checked);
1459
- }
1460
- }
1461
- ),
1462
- /* @__PURE__ */ jsx(
1463
- "label",
1464
- {
1465
- htmlFor: "orderConfirm",
1466
- className: textVariants({
1467
- size: "xs",
1468
- intensity: 54
1469
- }),
1470
- children: t("orderEntry.disableOrderConfirm")
1471
- }
1472
- )
1473
- ]
1474
- }
1475
- );
1476
- const buttons = /* @__PURE__ */ jsxs(
1477
- Grid,
1478
- {
1479
- cols: 2,
1480
- gapX: 3,
1481
- className: "oui-orderEntry-orderConfirmDialog-actions",
1482
- children: [
1483
- /* @__PURE__ */ jsx(
1484
- Button,
1485
- {
1486
- color: "secondary",
1487
- size: "md",
1488
- className: "oui-cancel-btn",
1489
- onClick: () => onCancel(),
1490
- children: t("common.cancel")
1491
- }
1492
- ),
1493
- /* @__PURE__ */ jsx(
1494
- Button,
1495
- {
1496
- size: "md",
1497
- className: "oui-confirm-btn",
1498
- onClick: () => onConfirm(),
1499
- children: t("common.confirm")
1500
- }
1501
- )
1502
- ]
1147
+ className: "oui-permissionlessNotice-confirm-button oui-w-full",
1148
+ justify: "center",
1149
+ children: /* @__PURE__ */ jsx(
1150
+ Button,
1151
+ {
1152
+ fullWidth: true,
1153
+ size: "md",
1154
+ className: "oui-permissionlessNotice-confirm oui-confirm-btn oui-max-w-[244px]",
1155
+ disabled: !checked,
1156
+ onClick: () => onConfirm(),
1157
+ children: t("common.confirm")
1158
+ }
1159
+ )
1503
1160
  }
1504
1161
  );
1505
1162
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1506
- header,
1507
- /* @__PURE__ */ jsx(Divider, { className: "oui-my-4" }),
1508
- /* @__PURE__ */ jsxs(
1509
- "div",
1510
- {
1511
- className: textVariants({
1512
- size: "sm",
1513
- intensity: 54,
1514
- className: "oui-orderEntry-orderConfirmDialog-content oui-space-y-1"
1515
- }),
1516
- children: [
1517
- quantityItem,
1518
- triggerPriceItem,
1519
- renderPriceAndTotal()
1520
- ]
1521
- }
1522
- ),
1523
- tpslTriggerPrice,
1524
- orderConfirmCheckbox,
1525
- buttons
1526
- ] });
1527
- };
1528
- var OrderItem = (props) => {
1529
- const { title, value, unit, dp } = props;
1530
- return /* @__PURE__ */ jsxs(Flex, { justify: "between", children: [
1531
- /* @__PURE__ */ jsx(Text, { children: title }),
1532
- /* @__PURE__ */ jsx(
1533
- Text.numeral,
1534
- {
1535
- unit,
1536
- rule: "price",
1537
- dp,
1538
- padding: false,
1539
- className: "oui-text-base-contrast",
1540
- unitClassName: "oui-text-base-contrast-36 oui-ml-1",
1541
- children: value
1542
- }
1543
- )
1163
+ content,
1164
+ checkboxSection,
1165
+ confirmButton
1544
1166
  ] });
1545
1167
  };
1546
- OrderConfirmDialog.displayName = "OrderConfirmDialog";
1547
- var OrderTypeTag = (props) => {
1548
- const { t } = useTranslation();
1549
- const typeStr = useMemo(() => {
1550
- switch (props.type) {
1551
- case OrderType.LIMIT:
1552
- return t("orderEntry.orderType.limit");
1553
- case OrderType.MARKET:
1554
- return t("common.marketPrice");
1555
- case OrderType.STOP_LIMIT:
1556
- return t("orderEntry.orderType.stopLimit");
1557
- case OrderType.STOP_MARKET:
1558
- return t("orderEntry.orderType.stopMarket");
1559
- case OrderType.TRAILING_STOP:
1560
- return t("orderEntry.orderType.trailingStop");
1561
- default:
1562
- return "";
1563
- }
1564
- }, [props.type]);
1565
- return /* @__PURE__ */ jsx(Badge, { color: "neutral", size: "sm", children: typeStr });
1566
- };
1567
- var Dialog = (props) => {
1568
- const { close, resolve, reject, ...rest } = props;
1168
+ PermissionlessMarketNoticeDialog.displayName = "PermissionlessMarketNoticeDialog";
1169
+ var Dialog2 = (props) => {
1170
+ const { close, resolve, reject } = props;
1569
1171
  return /* @__PURE__ */ jsx(
1570
- OrderConfirmDialog,
1172
+ PermissionlessMarketNoticeDialog,
1571
1173
  {
1572
- ...rest,
1573
1174
  onCancel: () => {
1574
1175
  reject();
1575
1176
  close();
@@ -1581,178 +1182,15 @@ var Dialog = (props) => {
1581
1182
  }
1582
1183
  );
1583
1184
  };
1584
- var orderConfirmDialogId = "orderConfirm";
1585
- registerSimpleDialog(orderConfirmDialogId, Dialog, {
1185
+ var permissionlessMarketNoticeDialogId = "permissionlessMarketNotice";
1186
+ var permissionlessMarketNoticeDesktopDialogId = "permissionlessMarketNoticeDesktop";
1187
+ registerSimpleDialog(permissionlessMarketNoticeDialogId, Dialog2, {
1586
1188
  size: "sm",
1587
- title: () => i18n.t("orderEntry.orderConfirm")
1189
+ title: () => i18n.t("orderEntry.permissionlessNotice.title")
1588
1190
  });
1589
- var MaxQtyConfirm = memo((props) => {
1590
- const { t } = useTranslation();
1591
- return /* @__PURE__ */ jsx(
1592
- SimpleDialog,
1593
- {
1594
- open: props.open,
1595
- title: t("orderEntry.orderConfirm"),
1596
- closable: true,
1597
- onOpenChange: props.onOpenChange,
1598
- size: "sm",
1599
- classNames: {
1600
- footer: "oui-maxQtyConfirm-footer",
1601
- body: "oui-maxQtyConfirm-body"
1602
- },
1603
- actions: {
1604
- primary: {
1605
- label: t("orderEntry.placeOrderNow"),
1606
- className: "oui-primary-btn oui-text-sm oui-font-semibold oui-w-[100%] oui-h-8",
1607
- onClick: () => {
1608
- props.onConfirm();
1609
- return Promise.resolve();
1610
- }
1611
- },
1612
- secondary: {
1613
- label: t("common.cancel"),
1614
- className: "oui-secondary-btn oui-text-sm oui-font-semibold oui-w-[100%] oui-h-8",
1615
- onClick: () => {
1616
- props.onOpenChange(false);
1617
- return Promise.resolve();
1618
- }
1619
- }
1620
- },
1621
- children: /* @__PURE__ */ jsx("div", { className: "oui-maxQtyConfirm-content oui-text-2xs lg:oui-text-sm", children: t("orderEntry.maxQty.reminder.content", {
1622
- maxQty: `${props.maxQty} ${props.base}`
1623
- }) })
1624
- }
1625
- );
1626
- });
1627
- var PermissionlessMarketNoticeDialog = (props) => {
1628
- const { onConfirm, onCancel } = props;
1629
- const { t } = useTranslation();
1630
- const [checked, setChecked] = useState(false);
1631
- const content = /* @__PURE__ */ jsxs(
1632
- Flex,
1633
- {
1634
- direction: "column",
1635
- gap: 3,
1636
- itemAlign: "start",
1637
- className: "oui-permissionlessNotice-content",
1638
- children: [
1639
- /* @__PURE__ */ jsx(
1640
- Text,
1641
- {
1642
- className: textVariants({
1643
- size: "sm",
1644
- intensity: 54
1645
- }),
1646
- children: t("orderEntry.permissionlessNotice.content1")
1647
- }
1648
- ),
1649
- /* @__PURE__ */ jsx(
1650
- Text,
1651
- {
1652
- className: textVariants({
1653
- size: "sm",
1654
- intensity: 54
1655
- }),
1656
- children: t("orderEntry.permissionlessNotice.content2")
1657
- }
1658
- ),
1659
- /* @__PURE__ */ jsx(
1660
- Text,
1661
- {
1662
- className: textVariants({
1663
- size: "sm",
1664
- intensity: 54
1665
- }),
1666
- children: t("orderEntry.permissionlessNotice.content3")
1667
- }
1668
- )
1669
- ]
1670
- }
1671
- );
1672
- const checkboxSection = /* @__PURE__ */ jsxs(
1673
- Flex,
1674
- {
1675
- gapX: 1,
1676
- pt: 4,
1677
- pb: 5,
1678
- itemAlign: "start",
1679
- className: "oui-permissionlessNotice-checkbox oui-orderEntry-orderConfirmDialog-disableConfirm oui-cursor-pointer",
1680
- children: [
1681
- /* @__PURE__ */ jsx(
1682
- Checkbox,
1683
- {
1684
- id: "permissionlessNotice",
1685
- color: "white",
1686
- className: "oui-permissionlessNotice-checkbox-input oui-mt-1",
1687
- checked,
1688
- onCheckedChange: (value) => setChecked(!!value)
1689
- }
1690
- ),
1691
- /* @__PURE__ */ jsx(
1692
- "label",
1693
- {
1694
- htmlFor: "permissionlessNotice",
1695
- className: textVariants({
1696
- size: "xs",
1697
- intensity: 54,
1698
- className: "oui-cursor-pointer"
1699
- }),
1700
- children: t("orderEntry.permissionlessNotice.checkbox")
1701
- }
1702
- )
1703
- ]
1704
- }
1705
- );
1706
- const confirmButton = /* @__PURE__ */ jsx(
1707
- Flex,
1708
- {
1709
- className: "oui-permissionlessNotice-confirm-button oui-w-full",
1710
- justify: "center",
1711
- children: /* @__PURE__ */ jsx(
1712
- Button,
1713
- {
1714
- fullWidth: true,
1715
- size: "md",
1716
- className: "oui-permissionlessNotice-confirm oui-confirm-btn oui-max-w-[244px]",
1717
- disabled: !checked,
1718
- onClick: () => onConfirm(),
1719
- children: t("common.confirm")
1720
- }
1721
- )
1722
- }
1723
- );
1724
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1725
- content,
1726
- checkboxSection,
1727
- confirmButton
1728
- ] });
1729
- };
1730
- PermissionlessMarketNoticeDialog.displayName = "PermissionlessMarketNoticeDialog";
1731
- var Dialog2 = (props) => {
1732
- const { close, resolve, reject } = props;
1733
- return /* @__PURE__ */ jsx(
1734
- PermissionlessMarketNoticeDialog,
1735
- {
1736
- onCancel: () => {
1737
- reject();
1738
- close();
1739
- },
1740
- onConfirm: () => {
1741
- resolve();
1742
- close();
1743
- }
1744
- }
1745
- );
1746
- };
1747
- var permissionlessMarketNoticeDialogId = "permissionlessMarketNotice";
1748
- var permissionlessMarketNoticeDesktopDialogId = "permissionlessMarketNoticeDesktop";
1749
- registerSimpleDialog(permissionlessMarketNoticeDialogId, Dialog2, {
1750
- size: "sm",
1751
- title: () => i18n.t("orderEntry.permissionlessNotice.title")
1752
- });
1753
- registerSimpleDialog(permissionlessMarketNoticeDesktopDialogId, Dialog2, {
1754
- size: "xl",
1755
- title: () => i18n.t("orderEntry.permissionlessNotice.title")
1191
+ registerSimpleDialog(permissionlessMarketNoticeDesktopDialogId, Dialog2, {
1192
+ size: "xl",
1193
+ title: () => i18n.t("orderEntry.permissionlessNotice.title")
1756
1194
  });
1757
1195
  var ScaledOrderConfirm = (props) => {
1758
1196
  const { order, symbolInfo, dataSource, national, askAndBid, totalQuantity } = props;
@@ -1981,14 +1419,576 @@ var ScaledOrderConfirmWidget = (props) => {
1981
1419
  const state = useScaledOrderConfirmScript(props);
1982
1420
  return /* @__PURE__ */ jsx(ScaledOrderConfirm, { ...props, ...state });
1983
1421
  };
1984
- var scaledOrderConfirmDialogId = "scaledOrderConfirm";
1985
- registerSimpleDialog(scaledOrderConfirmDialogId, ScaledOrderConfirmWidget, {
1986
- size: "md",
1987
- title: () => i18n.t("orderEntry.confirmScaledOrder"),
1988
- contentProps: {
1989
- // className: "oui-p-0",
1990
- }
1991
- });
1422
+ var scaledOrderConfirmDialogId = "scaledOrderConfirm";
1423
+ registerSimpleDialog(scaledOrderConfirmDialogId, ScaledOrderConfirmWidget, {
1424
+ size: "md",
1425
+ title: () => i18n.t("orderEntry.confirmScaledOrder"),
1426
+ contentProps: {
1427
+ // className: "oui-p-0",
1428
+ }
1429
+ });
1430
+ var RegularFeesUI = (props) => {
1431
+ const { t } = useTranslation();
1432
+ const { taker, maker } = props;
1433
+ const originalTrailingFees = /* @__PURE__ */ jsx(
1434
+ Flex,
1435
+ {
1436
+ itemAlign: "center",
1437
+ justify: "between",
1438
+ width: "100%",
1439
+ gap: 1,
1440
+ className: "oui-orderEntry-fees",
1441
+ children: /* @__PURE__ */ jsxs(Flex, { width: "100%", itemAlign: "center", justify: "between", children: [
1442
+ /* @__PURE__ */ jsx(Text, { className: "oui-fees-label oui-truncate", size: "2xs", children: t("common.fees") }),
1443
+ /* @__PURE__ */ jsx(
1444
+ AuthGuard,
1445
+ {
1446
+ fallback: () => /* @__PURE__ */ jsxs(Text, { className: "oui-truncate", size: "2xs", children: [
1447
+ t("dmm.taker"),
1448
+ ": --% / ",
1449
+ t("dmm.maker"),
1450
+ ": --%"
1451
+ ] }),
1452
+ children: /* @__PURE__ */ jsxs(Flex, { gap: 1, className: "oui-fees-value-container", children: [
1453
+ /* @__PURE__ */ jsxs(Text, { className: "oui-truncate", size: "2xs", children: [
1454
+ t("dmm.taker"),
1455
+ ":"
1456
+ ] }),
1457
+ /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-base-contrast-80", children: taker }),
1458
+ /* @__PURE__ */ jsx(Text, { size: "2xs", children: "/" }),
1459
+ /* @__PURE__ */ jsxs(Text, { className: "oui-truncate", size: "2xs", children: [
1460
+ t("dmm.maker"),
1461
+ ":"
1462
+ ] }),
1463
+ /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-base-contrast-80", children: maker })
1464
+ ] })
1465
+ }
1466
+ )
1467
+ ] })
1468
+ }
1469
+ );
1470
+ return originalTrailingFees;
1471
+ };
1472
+ var RegularFeesWidget = (props) => {
1473
+ return /* @__PURE__ */ jsx(RegularFeesUI, { ...props });
1474
+ };
1475
+ var FeesWidget = ({ symbol }) => {
1476
+ const { takerFee, makerFee, rwaTakerFee, rwaMakerFee } = useFeeState();
1477
+ const info = useRwaSymbolsInfoStore();
1478
+ const isRwa = info?.[symbol] !== void 0;
1479
+ return /* @__PURE__ */ jsx(
1480
+ RegularFeesWidget,
1481
+ {
1482
+ taker: isRwa ? rwaTakerFee : takerFee,
1483
+ maker: isRwa ? rwaMakerFee : makerFee
1484
+ }
1485
+ );
1486
+ };
1487
+ var options = [0.01, 0.05, 0.1];
1488
+ var SlippageEditor = forwardRef((props, ref) => {
1489
+ const { t } = useTranslation();
1490
+ const [value, setValue] = useState();
1491
+ const [customValue, setCustomValue] = useState("");
1492
+ const [error, setError] = useState(void 0);
1493
+ useImperativeHandle(ref, () => ({
1494
+ getValue: () => customValue ? new Decimal(customValue)?.toNumber() : value
1495
+ }));
1496
+ useEffect(() => {
1497
+ if (props.initialValue && !options.includes(props.initialValue)) {
1498
+ setCustomValue(props.initialValue.toString());
1499
+ } else {
1500
+ setValue(props.initialValue);
1501
+ }
1502
+ }, [props.initialValue, open]);
1503
+ const onClick = (val) => {
1504
+ setValue(val);
1505
+ setCustomValue("");
1506
+ setError(void 0);
1507
+ };
1508
+ const onValueChange = (val) => {
1509
+ if (!val) {
1510
+ setCustomValue(val);
1511
+ return;
1512
+ }
1513
+ const d = new Decimal(val);
1514
+ setValue(void 0);
1515
+ if (d.gt(3)) {
1516
+ setCustomValue("3");
1517
+ setError(t("orderEntry.slippage.error.exceed"));
1518
+ } else {
1519
+ setCustomValue(val);
1520
+ setError(void 0);
1521
+ }
1522
+ };
1523
+ const toolTipButton = props.isMobile ? /* @__PURE__ */ jsx(
1524
+ "button",
1525
+ {
1526
+ onClick: () => {
1527
+ modal.alert({
1528
+ title: t("common.tips"),
1529
+ message: /* @__PURE__ */ jsx(Text, { size: "2xs", children: t("orderEntry.slippage.tips") })
1530
+ });
1531
+ },
1532
+ children: /* @__PURE__ */ jsx(ExclamationFillIcon, { className: "oui-text-base-contrast-54", size: 16 })
1533
+ }
1534
+ ) : /* @__PURE__ */ jsx(
1535
+ Tooltip,
1536
+ {
1537
+ content: /* @__PURE__ */ jsx(Text, { intensity: 80, size: "2xs", children: t("orderEntry.slippage.tips") }),
1538
+ className: "oui-w-[260px] oui-bg-base-6",
1539
+ arrow: { className: "oui-fill-base-6" },
1540
+ children: /* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(ExclamationFillIcon, { className: "oui-text-base-contrast-54", size: 16 }) })
1541
+ }
1542
+ );
1543
+ return /* @__PURE__ */ jsxs("div", { className: "oui-orderEntry-slippageEditor oui-text-2xs", children: [
1544
+ /* @__PURE__ */ jsxs(Flex, { mb: 2, gapX: 1, children: [
1545
+ /* @__PURE__ */ jsx(Text, { size: "xs", children: t("orderEntry.slippage") }),
1546
+ toolTipButton
1547
+ ] }),
1548
+ /* @__PURE__ */ jsxs(Flex, { gapX: 2, children: [
1549
+ options.map((item) => {
1550
+ const isActive = value === item;
1551
+ return /* @__PURE__ */ jsx(
1552
+ SlippageItem,
1553
+ {
1554
+ value: item,
1555
+ isActive,
1556
+ onClick: () => {
1557
+ onClick(item);
1558
+ }
1559
+ },
1560
+ item
1561
+ );
1562
+ }),
1563
+ /* @__PURE__ */ jsx(
1564
+ Input,
1565
+ {
1566
+ suffix: "%",
1567
+ formatters: [
1568
+ inputFormatter.numberFormatter,
1569
+ inputFormatter.dpFormatter(2)
1570
+ ],
1571
+ value: customValue,
1572
+ onValueChange,
1573
+ classNames: {
1574
+ root: cn(
1575
+ "oui-slippageEditor-customInput",
1576
+ "oui-rounded-md oui-bg-base-6",
1577
+ "oui-h-[40px] oui-w-[74px]"
1578
+ ),
1579
+ input: "oui-text-base-contrast",
1580
+ additional: "oui-pl-1"
1581
+ }
1582
+ }
1583
+ )
1584
+ ] }),
1585
+ !!error && /* @__PURE__ */ jsx(Box, { mt: 5, className: "-oui-mb-5", children: /* @__PURE__ */ jsx(Text, { size: "2xs", color: "danger", children: error }) })
1586
+ ] });
1587
+ });
1588
+ var SlippageItem = ({ value, isActive, onClick }) => {
1589
+ return /* @__PURE__ */ jsx(
1590
+ Flex,
1591
+ {
1592
+ intensity: 600,
1593
+ justify: "center",
1594
+ itemAlign: "center",
1595
+ r: "md",
1596
+ width: 74,
1597
+ height: 40,
1598
+ className: cn(
1599
+ "oui-slippageEditor-option",
1600
+ "oui-cursor-pointer oui-select-none",
1601
+ isActive ? "oui-bg-primary-light oui-text-primary-contrast/80" : "oui-text-base-contrast-80"
1602
+ ),
1603
+ onClick,
1604
+ children: /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
1605
+ value,
1606
+ "%"
1607
+ ] })
1608
+ }
1609
+ );
1610
+ };
1611
+ var SlippageCell = (props) => {
1612
+ const { t } = useTranslation();
1613
+ const [open2, { setTrue: setOpen, setFalse: setClose, toggle }] = useBoolean(false);
1614
+ const { isMobile } = useScreen();
1615
+ const slippageRef = useRef(null);
1616
+ const onConfirm = () => {
1617
+ const val = slippageRef.current?.getValue();
1618
+ props.setSlippage(!val ? "1" : val.toString());
1619
+ setClose();
1620
+ return Promise.resolve(true);
1621
+ };
1622
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1623
+ /* @__PURE__ */ jsx(
1624
+ SimpleDialog,
1625
+ {
1626
+ open: open2,
1627
+ onOpenChange: toggle,
1628
+ title: t("common.settings"),
1629
+ contentProps: { size: isMobile ? "xs" : "sm" },
1630
+ classNames: {
1631
+ footer: "oui-orderEntry-slippage-footer",
1632
+ body: "oui-orderEntry-slippage-body"
1633
+ },
1634
+ actions: {
1635
+ primary: {
1636
+ disabled: false,
1637
+ label: t("common.save"),
1638
+ onClick: onConfirm,
1639
+ className: "oui-slippage-save-btn"
1640
+ },
1641
+ secondary: {
1642
+ label: t("common.cancel"),
1643
+ onClick: () => setClose(),
1644
+ className: "oui-slippage-cancel-btn"
1645
+ }
1646
+ },
1647
+ children: /* @__PURE__ */ jsx(
1648
+ SlippageEditor,
1649
+ {
1650
+ ref: slippageRef,
1651
+ isMobile,
1652
+ initialValue: props.slippage ? Number(props.slippage) : void 0
1653
+ }
1654
+ )
1655
+ }
1656
+ ),
1657
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-orderEntry-slippage", children: [
1658
+ /* @__PURE__ */ jsx(Text, { className: "oui-slippage-label", size: "2xs", children: t("orderEntry.slippage") }),
1659
+ /* @__PURE__ */ jsx(
1660
+ AuthGuard,
1661
+ {
1662
+ fallback: () => /* @__PURE__ */ jsxs(Text, { size: "2xs", children: [
1663
+ t("orderEntry.slippage.est"),
1664
+ ": -% / ",
1665
+ t("common.max"),
1666
+ ": --%"
1667
+ ] }),
1668
+ children: /* @__PURE__ */ jsxs(Flex, { gap: 1, className: "oui-slippage-value-container", children: [
1669
+ /* @__PURE__ */ jsx(
1670
+ Text.numeral,
1671
+ {
1672
+ size: "2xs",
1673
+ rule: "percentages",
1674
+ prefix: `${t("orderEntry.slippage.est")}: `,
1675
+ suffix: ` / ${t("common.max")}: `,
1676
+ children: props.estSlippage ?? 0
1677
+ }
1678
+ ),
1679
+ /* @__PURE__ */ jsx(
1680
+ "button",
1681
+ {
1682
+ className: "oui-slippage-edit-btn oui-text-2xs",
1683
+ onClick: () => setOpen(),
1684
+ children: /* @__PURE__ */ jsxs(Flex, { className: "oui-gap-0.5", as: "span", children: [
1685
+ /* @__PURE__ */ jsx(Text, { size: "2xs", className: "oui-text-primary", children: `${props.slippage || "-"}%` }),
1686
+ /* @__PURE__ */ jsx(
1687
+ EditIcon$1,
1688
+ {
1689
+ className: "oui-slippage-edit-icon oui-text-primary oui-hidden md:oui-block",
1690
+ size: 12,
1691
+ opacity: 1
1692
+ }
1693
+ )
1694
+ ] })
1695
+ }
1696
+ )
1697
+ ] })
1698
+ }
1699
+ )
1700
+ ] })
1701
+ ] });
1702
+ };
1703
+ var SlippageUI = (props) => {
1704
+ return /* @__PURE__ */ jsx(SlippageCell, { ...props });
1705
+ };
1706
+ function AssetInfo(props) {
1707
+ const { canTrade, disableFeatures, orderType, symbol } = props;
1708
+ const { t } = useTranslation();
1709
+ const { isMobile } = useScreen();
1710
+ const displayEstLiqPrice = useGetEstLiqPrice({
1711
+ estLiqPrice: props.estLiqPrice,
1712
+ symbol,
1713
+ side: props.side
1714
+ });
1715
+ return /* @__PURE__ */ jsxs(
1716
+ "div",
1717
+ {
1718
+ className: "oui-orderEntry-assetInfo oui-space-y-[2px] xl:oui-space-y-1",
1719
+ children: [
1720
+ /* @__PURE__ */ jsxs(Flex, { justify: "between", className: "oui-orderEntry-estLiqPrice", children: [
1721
+ isMobile ? /* @__PURE__ */ jsx(Text, { size: "2xs", children: t("orderEntry.estLiqPrice") }) : /* @__PURE__ */ jsx(
1722
+ Tooltip,
1723
+ {
1724
+ content: /* @__PURE__ */ jsxs("div", { className: "oui-min-w-[204px] oui-max-w-[280px] oui-text-2xs oui-leading-normal oui-text-base-contrast-80", children: [
1725
+ /* @__PURE__ */ jsx("div", { className: "oui-text-pretty", children: t("common.liquidationPrice.tooltip") }),
1726
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
1727
+ "a",
1728
+ {
1729
+ href: "https://orderly.network/docs/introduction/trade-on-orderly/perpetual-futures/liquidations",
1730
+ target: "_blank",
1731
+ rel: "noopener noreferrer",
1732
+ className: "oui-text-primary oui-underline",
1733
+ children: t("common.liquidationPrice.tooltip.learnMore")
1734
+ }
1735
+ ) })
1736
+ ] }),
1737
+ children: /* @__PURE__ */ jsx(
1738
+ Text,
1739
+ {
1740
+ size: "2xs",
1741
+ className: "oui-estLiqPrice-label oui-cursor-pointer oui-border-b oui-border-dashed oui-border-line-12",
1742
+ children: t("orderEntry.estLiqPrice")
1743
+ }
1744
+ )
1745
+ }
1746
+ ),
1747
+ /* @__PURE__ */ jsx(
1748
+ Text.numeral,
1749
+ {
1750
+ unit: props.quote,
1751
+ size: "2xs",
1752
+ dp: props.dp,
1753
+ className: "oui-estLiqPrice-value oui-text-base-contrast-80",
1754
+ unitClassName: "oui-ml-1 oui-text-base-contrast-36",
1755
+ children: canTrade ? displayEstLiqPrice ?? "--" : "--"
1756
+ }
1757
+ )
1758
+ ] }),
1759
+ orderType === OrderType.MARKET && !disableFeatures?.includes("slippageSetting") && /* @__PURE__ */ jsx(
1760
+ SlippageUI,
1761
+ {
1762
+ slippage: props.slippage,
1763
+ setSlippage: props.setSlippage,
1764
+ estSlippage: props.estSlippage
1765
+ }
1766
+ ),
1767
+ !disableFeatures?.includes("feesInfo") && /* @__PURE__ */ jsx(FeesWidget, { symbol: props.symbol })
1768
+ ]
1769
+ }
1770
+ );
1771
+ }
1772
+ var calculateLTVColor = (val) => {
1773
+ if (val >= 0 && val < 50) {
1774
+ return "oui-text-success";
1775
+ } else if (val >= 50 && val < 80) {
1776
+ return "oui-text-warning";
1777
+ } else if (val >= 80) {
1778
+ return "oui-text-danger";
1779
+ } else {
1780
+ return "";
1781
+ }
1782
+ };
1783
+ var LTVRiskTooltipUI = (props) => {
1784
+ const { t } = useTranslation();
1785
+ const {
1786
+ ltv_threshold,
1787
+ negative_usdc_threshold,
1788
+ isThresholdLoading,
1789
+ holdingData = [],
1790
+ currentLtv,
1791
+ onConvert,
1792
+ marginMode
1793
+ } = props;
1794
+ return /* @__PURE__ */ jsxs(
1795
+ Flex,
1796
+ {
1797
+ gap: 1,
1798
+ className: "oui-orderEntry-ltvRiskTooltip oui-w-72 oui-max-w-72",
1799
+ direction: "column",
1800
+ itemAlign: "start",
1801
+ children: [
1802
+ /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", itemAlign: "center", children: [
1803
+ /* @__PURE__ */ jsx(Text, { intensity: 36, size: "xs", children: t("common.assets") }),
1804
+ /* @__PURE__ */ jsx(Text, { intensity: 36, size: "xs", children: t("transfer.deposit.collateralContribution") })
1805
+ ] }),
1806
+ holdingData.map((asset, index) => {
1807
+ return /* @__PURE__ */ jsxs(
1808
+ Flex,
1809
+ {
1810
+ width: "100%",
1811
+ justify: "between",
1812
+ itemAlign: "center",
1813
+ children: [
1814
+ /* @__PURE__ */ jsx(Text, { intensity: 80, size: "xs", children: asset.token }),
1815
+ /* @__PURE__ */ jsx(
1816
+ Text,
1817
+ {
1818
+ size: "xs",
1819
+ intensity: 80,
1820
+ className: cn(
1821
+ Number(asset.collateralContribution) < 0 && "oui-text-warning"
1822
+ ),
1823
+ children: removeTrailingZeros(asset.collateralContribution)
1824
+ }
1825
+ )
1826
+ ]
1827
+ },
1828
+ `item-${index}`
1829
+ );
1830
+ }),
1831
+ /* @__PURE__ */ jsx(Divider, { className: "oui-w-full" }),
1832
+ /* @__PURE__ */ jsxs(Flex, { width: "100%", justify: "between", itemAlign: "center", children: [
1833
+ /* @__PURE__ */ jsx(Text, { intensity: 36, size: "xs", children: t("transfer.LTV.currentLTV") }),
1834
+ /* @__PURE__ */ jsxs(
1835
+ Text,
1836
+ {
1837
+ size: "xs",
1838
+ intensity: 36,
1839
+ className: cn("oui-select-none", calculateLTVColor(currentLtv)),
1840
+ children: [
1841
+ currentLtv,
1842
+ "%"
1843
+ ]
1844
+ }
1845
+ )
1846
+ ] }),
1847
+ /* @__PURE__ */ jsx(Text, { className: "oui-py-2", intensity: 54, size: "2xs", children: t("transfer.LTV.tooltip", {
1848
+ threshold: isThresholdLoading ? "-" : ltv_threshold,
1849
+ usdcThreshold: isThresholdLoading ? "-" : negative_usdc_threshold
1850
+ }) }),
1851
+ /* @__PURE__ */ jsx(
1852
+ Button,
1853
+ {
1854
+ fullWidth: true,
1855
+ size: "md",
1856
+ variant: "outlined",
1857
+ color: "secondary",
1858
+ className: "oui-ltvRiskTooltip-convert-btn",
1859
+ onClick: onConvert,
1860
+ children: t("transfer.convert.convertAssets")
1861
+ }
1862
+ )
1863
+ ]
1864
+ }
1865
+ );
1866
+ };
1867
+ var useConvertThreshold = () => {
1868
+ const { data, error, isLoading } = useQuery(
1869
+ "/v1/public/auto_convert_threshold",
1870
+ { errorRetryCount: 3 }
1871
+ );
1872
+ return {
1873
+ ltv_threshold: new Decimal(data?.ltv_threshold ?? 0).mul(100).toNumber(),
1874
+ negative_usdc_threshold: data?.negative_usdc_threshold,
1875
+ isLoading,
1876
+ error
1877
+ };
1878
+ };
1879
+ var useLTVTooltipScript = (marginMode) => {
1880
+ const { data: holdingList = [], isLoading: isHoldingLoading } = useHoldingStream();
1881
+ const {
1882
+ ltv_threshold,
1883
+ negative_usdc_threshold,
1884
+ isLoading: isThresholdLoading
1885
+ } = useConvertThreshold();
1886
+ const tokensInfo = useAppStore((state) => state.tokensInfo);
1887
+ const { getIndexPrice } = useIndexPricesStream();
1888
+ const holdingData = holdingList.map((item) => {
1889
+ const tokenInfo = tokensInfo?.find(({ token }) => token === item.token);
1890
+ const indexPrice = getIndexPrice(item.token);
1891
+ const collateralRatio = tokenInfo ? account.collateralRatio({
1892
+ baseWeight: tokenInfo.base_weight ?? 0,
1893
+ discountFactor: tokenInfo.discount_factor ?? 0,
1894
+ collateralQty: item.holding,
1895
+ collateralCap: tokenInfo?.user_max_qty ?? item.holding,
1896
+ indexPrice
1897
+ }) : zero;
1898
+ const collateralContribution = account.collateralContribution({
1899
+ collateralQty: item.holding,
1900
+ collateralCap: tokenInfo?.user_max_qty ?? item.holding,
1901
+ collateralRatio: collateralRatio.toNumber(),
1902
+ indexPrice
1903
+ });
1904
+ return {
1905
+ ...item,
1906
+ collateralContribution
1907
+ };
1908
+ });
1909
+ const currentLtv = useComputedLTV();
1910
+ const onConvert = useCallback(async () => {
1911
+ return modal.show("ConvertDialogId");
1912
+ }, []);
1913
+ return {
1914
+ holdingData,
1915
+ isHoldingLoading,
1916
+ ltv_threshold,
1917
+ negative_usdc_threshold,
1918
+ isThresholdLoading,
1919
+ currentLtv,
1920
+ onConvert,
1921
+ marginMode
1922
+ };
1923
+ };
1924
+ var LTVRiskTooltipWidget = ({
1925
+ marginMode
1926
+ }) => {
1927
+ const state = useLTVTooltipScript(marginMode);
1928
+ return /* @__PURE__ */ jsx(LTVRiskTooltipUI, { ...state });
1929
+ };
1930
+ var Available = (props) => {
1931
+ const { canTrade, currentLtv, quote, freeCollateral, marginMode } = props;
1932
+ const { t } = useTranslation();
1933
+ const { isMobile } = useScreen();
1934
+ const showLTV = useMemo(() => {
1935
+ return typeof currentLtv === "number" && !Number.isNaN(currentLtv) && currentLtv > 0;
1936
+ }, [currentLtv]);
1937
+ return /* @__PURE__ */ jsxs(
1938
+ Flex,
1939
+ {
1940
+ itemAlign: "center",
1941
+ justify: "between",
1942
+ className: "oui-orderEntry-available",
1943
+ children: [
1944
+ marginMode === MarginMode.ISOLATED ? /* @__PURE__ */ jsx(Tooltip, { content: t("transfer.LTV.isolatedModeUsdcOnly"), children: /* @__PURE__ */ jsx(Text, { className: "oui-available-label oui-cursor-pointer", size: "2xs", children: t("common.available") }) }) : /* @__PURE__ */ jsx(Text, { className: "oui-available-label", size: "2xs", children: t("common.available") }),
1945
+ /* @__PURE__ */ jsxs(Flex, { itemAlign: "center", justify: "center", gap: 1, children: [
1946
+ showLTV && /* @__PURE__ */ jsx(
1947
+ Tooltip,
1948
+ {
1949
+ className: "oui-available-ltvRisk-tooltip oui-bg-base-6 oui-p-2",
1950
+ content: /* @__PURE__ */ jsx(LTVRiskTooltipWidget, { marginMode }),
1951
+ children: /* @__PURE__ */ jsx(
1952
+ InfoCircleIcon,
1953
+ {
1954
+ className: "oui-cursor-pointer oui-text-warning oui-opacity-80"
1955
+ }
1956
+ )
1957
+ }
1958
+ ),
1959
+ /* @__PURE__ */ jsx(
1960
+ Text.numeral,
1961
+ {
1962
+ unit: quote,
1963
+ size: "2xs",
1964
+ className: "oui-available-value oui-text-base-contrast-80",
1965
+ unitClassName: "oui-ml-1 oui-text-base-contrast-54",
1966
+ dp: 2,
1967
+ padding: false,
1968
+ children: canTrade ? freeCollateral : 0
1969
+ }
1970
+ ),
1971
+ /* @__PURE__ */ jsx(
1972
+ Button,
1973
+ {
1974
+ variant: "text",
1975
+ size: "xs",
1976
+ color: "secondary",
1977
+ className: "oui-available-deposit-icon oui-p-0 hover:oui-text-base-contrast-80",
1978
+ onClick: () => {
1979
+ const handleDomId = isMobile ? "DepositAndWithdrawWithSheetId" : "DepositAndWithdrawWithDialogId";
1980
+ modal.show(handleDomId, {
1981
+ activeTab: "deposit"
1982
+ });
1983
+ },
1984
+ children: /* @__PURE__ */ jsx(AddCircleIcon, { opacity: 1 })
1985
+ }
1986
+ )
1987
+ ] })
1988
+ ]
1989
+ }
1990
+ );
1991
+ };
1992
1992
  var OrderTypeSelect = (props) => {
1993
1993
  const { t } = useTranslation();
1994
1994
  const { isMobile } = useScreen();
@@ -2140,49 +2140,317 @@ var OrderTypeSelect = (props) => {
2140
2140
  ]
2141
2141
  }
2142
2142
  );
2143
- }
2144
- const handleMobileValueChange = (value) => {
2145
- if (marketOrderDisabled && value === OrderType.MARKET && marketOrderDisabledTooltip) {
2146
- modal.alert({
2147
- title: t("common.tips"),
2148
- message: marketOrderDisabledTooltip
2149
- });
2150
- return;
2151
- }
2152
- props.onChange(value);
2153
- };
2154
- return /* @__PURE__ */ jsx(
2155
- Select.options,
2156
- {
2157
- testid: "oui-testid-orderEntry-orderType-button",
2158
- currentValue: props.type,
2159
- value: props.type,
2160
- options: mobileOptions,
2161
- onValueChange: handleMobileValueChange,
2162
- contentProps: {
2163
- className: cn(
2164
- "oui-orderEntry-orderTypeSelect-content",
2165
- "oui-bg-base-8"
2166
- )
2167
- },
2168
- classNames: {
2169
- trigger: cn(
2170
- "oui-orderEntry-orderTypeSelect-btn",
2171
- "oui-bg-base-7 oui-border-line-12 oui-h-8 oui-rounded-md"
2172
- )
2173
- },
2174
- valueFormatter: (value, option) => {
2175
- const item = allOptions.find((o) => o.value === value);
2176
- if (!item) {
2177
- return /* @__PURE__ */ jsx(Text, { size: "xs", children: option.placeholder });
2143
+ }
2144
+ const handleMobileValueChange = (value) => {
2145
+ if (marketOrderDisabled && value === OrderType.MARKET && marketOrderDisabledTooltip) {
2146
+ modal.alert({
2147
+ title: t("common.tips"),
2148
+ message: marketOrderDisabledTooltip
2149
+ });
2150
+ return;
2151
+ }
2152
+ props.onChange(value);
2153
+ };
2154
+ return /* @__PURE__ */ jsx(
2155
+ Select.options,
2156
+ {
2157
+ testid: "oui-testid-orderEntry-orderType-button",
2158
+ currentValue: props.type,
2159
+ value: props.type,
2160
+ options: mobileOptions,
2161
+ onValueChange: handleMobileValueChange,
2162
+ contentProps: {
2163
+ className: cn(
2164
+ "oui-orderEntry-orderTypeSelect-content",
2165
+ "oui-bg-base-8"
2166
+ )
2167
+ },
2168
+ classNames: {
2169
+ trigger: cn(
2170
+ "oui-orderEntry-orderTypeSelect-btn",
2171
+ "oui-bg-base-7 oui-border-line-12 oui-h-8 oui-rounded-md"
2172
+ )
2173
+ },
2174
+ valueFormatter: (value, option) => {
2175
+ const item = allOptions.find((o) => o.value === value);
2176
+ if (!item) {
2177
+ return /* @__PURE__ */ jsx(Text, { size: "xs", children: option.placeholder });
2178
+ }
2179
+ const label = displayLabelMap[value];
2180
+ return /* @__PURE__ */ jsx(Text, { size: "xs", className: "oui-text-base-contrast-80", children: label });
2181
+ },
2182
+ size: "md"
2183
+ }
2184
+ );
2185
+ };
2186
+ var OrderEntryContext = createContext(
2187
+ {}
2188
+ );
2189
+ var useOrderEntryContext = () => {
2190
+ return useContext(OrderEntryContext);
2191
+ };
2192
+ var SLIDER_MIN = 0;
2193
+ var SLIDER_MAX = 100;
2194
+ var QuantitySlider = memo((props) => {
2195
+ const { canTrade, side, order_quantity, maxQty } = props;
2196
+ const [sliderValue, setSliderValue] = useState(0);
2197
+ const {
2198
+ setOrderValue,
2199
+ manualSetOrderValue,
2200
+ symbolInfo,
2201
+ lastQuantityInputType
2202
+ } = useOrderEntryContext();
2203
+ const { base_dp, base_tick } = symbolInfo;
2204
+ const { t } = useTranslation();
2205
+ const color = useMemo(
2206
+ () => canTrade ? side === OrderSide.BUY ? "buy" : "sell" : void 0,
2207
+ [side, canTrade]
2208
+ );
2209
+ const maxLabel = useMemo(() => {
2210
+ return side === OrderSide.BUY ? t("orderEntry.maxBuy") : t("orderEntry.maxSell");
2211
+ }, [side, t]);
2212
+ const onSliderValueChange = (value) => {
2213
+ lastQuantityInputType.current = 4 /* QUANTITY_SLIDER */;
2214
+ setSliderValue(value);
2215
+ sliderToQuantity(value, true);
2216
+ };
2217
+ const sliderToQuantity = (value, isManual = false) => {
2218
+ const newQty = new Decimal(value).div(SLIDER_MAX).mul(maxQty).toFixed(base_dp, Decimal.ROUND_DOWN);
2219
+ if (isManual) {
2220
+ manualSetOrderValue?.(
2221
+ "order_quantity",
2222
+ utils.formatNumber(newQty, base_tick)
2223
+ );
2224
+ } else {
2225
+ setOrderValue("order_quantity", utils.formatNumber(newQty, base_tick));
2226
+ }
2227
+ };
2228
+ const onMax = () => {
2229
+ onSliderValueChange(SLIDER_MAX);
2230
+ if (sliderValue === SLIDER_MAX) {
2231
+ sliderToQuantity(SLIDER_MAX, true);
2232
+ }
2233
+ };
2234
+ useEffect(() => {
2235
+ if (lastQuantityInputType.current === 4 /* QUANTITY_SLIDER */) {
2236
+ sliderToQuantity(sliderValue);
2237
+ }
2238
+ }, [maxQty]);
2239
+ useEffect(() => {
2240
+ const quantityToSlider = () => {
2241
+ if (order_quantity && Number(order_quantity) !== 0 && maxQty !== 0) {
2242
+ return new Decimal(Math.min(Number(order_quantity), maxQty)).div(maxQty).mul(SLIDER_MAX).todp(2, Decimal.ROUND_DOWN).toNumber();
2243
+ }
2244
+ return 0;
2245
+ };
2246
+ if (lastQuantityInputType.current !== 4 /* QUANTITY_SLIDER */) {
2247
+ setSliderValue(quantityToSlider());
2248
+ }
2249
+ }, [order_quantity, maxQty]);
2250
+ return /* @__PURE__ */ jsxs("div", { className: "oui-orderEntry-quantitySlider", children: [
2251
+ /* @__PURE__ */ jsx(
2252
+ Slider,
2253
+ {
2254
+ disabled: maxQty === 0 || !canTrade,
2255
+ value: [sliderValue],
2256
+ color,
2257
+ markCount: 4,
2258
+ showTip: true,
2259
+ onValueChange: (e) => {
2260
+ onSliderValueChange(e[0]);
2261
+ },
2262
+ min: SLIDER_MIN,
2263
+ max: SLIDER_MAX
2264
+ }
2265
+ ),
2266
+ /* @__PURE__ */ jsxs(
2267
+ Flex,
2268
+ {
2269
+ justify: "between",
2270
+ className: "oui-quantitySlider-footer oui-pt-1 xl:oui-pt-2",
2271
+ children: [
2272
+ /* @__PURE__ */ jsx(
2273
+ Text.numeral,
2274
+ {
2275
+ size: "2xs",
2276
+ color,
2277
+ dp: 2,
2278
+ padding: false,
2279
+ suffix: "%",
2280
+ children: canTrade ? sliderValue : 0
2281
+ }
2282
+ ),
2283
+ /* @__PURE__ */ jsxs(Flex, { children: [
2284
+ /* @__PURE__ */ jsx(
2285
+ "button",
2286
+ {
2287
+ className: textVariants({
2288
+ size: "2xs",
2289
+ className: "oui-quantitySlider-maxQty-btn oui-mr-1"
2290
+ }),
2291
+ onClick: onMax,
2292
+ "data-testid": "oui-testid-orderEntry-maxQty-value-button",
2293
+ children: maxLabel
2294
+ }
2295
+ ),
2296
+ /* @__PURE__ */ jsx(
2297
+ Text.numeral,
2298
+ {
2299
+ size: "2xs",
2300
+ color,
2301
+ dp: base_dp,
2302
+ padding: false,
2303
+ className: "oui-quantitySlider-maxQty-value",
2304
+ "data-testid": "oui-testid-orderEntry-maxQty-value",
2305
+ children: canTrade ? maxQty : 0
2306
+ }
2307
+ )
2308
+ ] })
2309
+ ]
2310
+ }
2311
+ )
2312
+ ] });
2313
+ });
2314
+ QuantitySlider.displayName = "QuantitySlider";
2315
+ var OrderEntryTypeTabsInjectabled = injectable(
2316
+ (props) => {
2317
+ return /* @__PURE__ */ jsx("div", { className: "oui-w-full", children: /* @__PURE__ */ jsx(
2318
+ OrderTypeSelect,
2319
+ {
2320
+ type: props.type,
2321
+ side: props.side,
2322
+ canTrade: props.canTrade,
2323
+ onChange: props.onChange,
2324
+ marketOrderDisabled: props.marketOrderDisabled,
2325
+ marketOrderDisabledTooltip: props.marketOrderDisabledTooltip
2326
+ }
2327
+ ) });
2328
+ },
2329
+ "Trading.OrderEntry.TypeTabs"
2330
+ );
2331
+ var OrderEntryBuySellSwitchInjectabled = injectable(
2332
+ (props) => {
2333
+ const { t } = useTranslation();
2334
+ return /* @__PURE__ */ jsxs(
2335
+ "div",
2336
+ {
2337
+ className: cn(
2338
+ "oui-orderEntry-side",
2339
+ "oui-grid oui-w-full oui-flex-1 oui-gap-x-2 lg:oui-flex lg:oui-gap-x-[6px]",
2340
+ "oui-grid-cols-2"
2341
+ ),
2342
+ children: [
2343
+ /* @__PURE__ */ jsx(
2344
+ Button,
2345
+ {
2346
+ onClick: () => {
2347
+ props.onSideChange(OrderSide.BUY);
2348
+ },
2349
+ size: "md",
2350
+ fullWidth: true,
2351
+ "data-type": OrderSide.BUY,
2352
+ className: cn(
2353
+ "oui-orderEntry-side-buy-btn",
2354
+ props.side === OrderSide.BUY && props.canTrade ? "oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80" : "oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"
2355
+ ),
2356
+ "data-testid": "oui-testid-orderEntry-side-buy-button",
2357
+ children: t("common.buy")
2358
+ }
2359
+ ),
2360
+ /* @__PURE__ */ jsx(
2361
+ Button,
2362
+ {
2363
+ onClick: () => {
2364
+ props.onSideChange(OrderSide.SELL);
2365
+ },
2366
+ "data-type": OrderSide.SELL,
2367
+ fullWidth: true,
2368
+ size: "md",
2369
+ className: cn(
2370
+ "oui-orderEntry-side-sell-btn",
2371
+ props.side === OrderSide.SELL && props.canTrade ? "oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80" : "oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"
2372
+ ),
2373
+ "data-testid": "oui-testid-orderEntry-side-sell-button",
2374
+ children: t("common.sell")
2375
+ }
2376
+ )
2377
+ ]
2378
+ }
2379
+ );
2380
+ },
2381
+ "Trading.OrderEntry.BuySellSwitch"
2382
+ );
2383
+ var OrderEntryAvailableInjectabled = injectable(
2384
+ (props) => {
2385
+ return /* @__PURE__ */ jsx(
2386
+ Available,
2387
+ {
2388
+ currentLtv: props.currentLtv,
2389
+ canTrade: props.canTrade,
2390
+ quote: props.quote,
2391
+ freeCollateral: props.freeCollateral,
2392
+ marginMode: props.marginMode
2393
+ }
2394
+ );
2395
+ },
2396
+ "Trading.OrderEntry.Available"
2397
+ );
2398
+ var OrderEntryQuantitySliderInjectabled = injectable(
2399
+ (props) => {
2400
+ return /* @__PURE__ */ jsx(
2401
+ QuantitySlider,
2402
+ {
2403
+ canTrade: props.canTrade,
2404
+ side: props.side,
2405
+ order_quantity: props.order_quantity,
2406
+ maxQty: props.maxQty
2407
+ }
2408
+ );
2409
+ },
2410
+ "Trading.OrderEntry.QuantitySlider"
2411
+ );
2412
+ var OrderEntrySubmitSectionInjectabled = injectable(
2413
+ (props) => {
2414
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2415
+ /* @__PURE__ */ jsx(
2416
+ ThrottledButton,
2417
+ {
2418
+ fullWidth: true,
2419
+ id: "order-entry-submit-button",
2420
+ "data-type": OrderSide.BUY,
2421
+ className: cn(
2422
+ "oui-orderEntry-submit-btn",
2423
+ props.side === OrderSide.BUY ? "orderly-order-entry-submit-button-buy oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80" : "orderly-order-entry-submit-button-sell oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80"
2424
+ ),
2425
+ onClick: props.onSubmit,
2426
+ loading: props.isMutating,
2427
+ disabled: !props.canTrade,
2428
+ children: props.buttonLabel
2178
2429
  }
2179
- const label = displayLabelMap[value];
2180
- return /* @__PURE__ */ jsx(Text, { size: "xs", className: "oui-text-base-contrast-80", children: label });
2181
- },
2182
- size: "md"
2183
- }
2184
- );
2185
- };
2430
+ ),
2431
+ /* @__PURE__ */ jsx(
2432
+ AssetInfo,
2433
+ {
2434
+ canTrade: props.assetInfo.canTrade,
2435
+ quote: props.assetInfo.quote,
2436
+ estLiqPrice: props.assetInfo.estLiqPrice,
2437
+ estLiqPriceDistance: props.assetInfo.estLiqPriceDistance,
2438
+ estLeverage: props.assetInfo.estLeverage,
2439
+ currentLeverage: props.assetInfo.currentLeverage,
2440
+ slippage: props.assetInfo.slippage,
2441
+ dp: props.assetInfo.dp,
2442
+ setSlippage: props.assetInfo.setSlippage,
2443
+ estSlippage: props.assetInfo.estSlippage,
2444
+ orderType: props.assetInfo.orderType,
2445
+ disableFeatures: props.assetInfo.disableFeatures,
2446
+ symbol: props.assetInfo.symbol,
2447
+ side: props.assetInfo.side
2448
+ }
2449
+ )
2450
+ ] });
2451
+ },
2452
+ "Trading.OrderEntry.SubmitSection"
2453
+ );
2186
2454
  var MarginModeSwitch = (props) => {
2187
2455
  const { t } = useTranslation();
2188
2456
  const handleSelect = (mode) => {
@@ -3043,7 +3311,6 @@ var LeverageBadge = (props) => {
3043
3311
  };
3044
3312
  function OrderEntryHeader(props) {
3045
3313
  const { canTrade, side, order_type, setOrderValue } = props;
3046
- const { t } = useTranslation();
3047
3314
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3048
3315
  /* @__PURE__ */ jsx("div", { className: "oui-w-full", children: /* @__PURE__ */ jsx(
3049
3316
  LeverageBadge,
@@ -3055,8 +3322,8 @@ function OrderEntryHeader(props) {
3055
3322
  disabled: !props.canTrade
3056
3323
  }
3057
3324
  ) }),
3058
- /* @__PURE__ */ jsx("div", { className: "oui-w-full", children: /* @__PURE__ */ jsx(
3059
- OrderTypeSelect,
3325
+ /* @__PURE__ */ jsx(
3326
+ OrderEntryTypeTabsInjectabled,
3060
3327
  {
3061
3328
  type: order_type,
3062
3329
  side,
@@ -3067,61 +3334,19 @@ function OrderEntryHeader(props) {
3067
3334
  marketOrderDisabled: props.marketOrderDisabled,
3068
3335
  marketOrderDisabledTooltip: props.marketOrderDisabledTooltip
3069
3336
  }
3070
- ) }),
3071
- /* @__PURE__ */ jsxs(
3072
- "div",
3337
+ ),
3338
+ /* @__PURE__ */ jsx(
3339
+ OrderEntryBuySellSwitchInjectabled,
3073
3340
  {
3074
- className: cn(
3075
- "oui-orderEntry-side",
3076
- "oui-grid oui-w-full oui-flex-1 oui-gap-x-2 lg:oui-flex lg:oui-gap-x-[6px]",
3077
- "oui-grid-cols-2"
3078
- ),
3079
- children: [
3080
- /* @__PURE__ */ jsx(
3081
- Button,
3082
- {
3083
- onClick: () => {
3084
- props.setOrderValue("side", OrderSide.BUY);
3085
- },
3086
- size: "md",
3087
- fullWidth: true,
3088
- "data-type": OrderSide.BUY,
3089
- className: cn(
3090
- "oui-orderEntry-side-buy-btn",
3091
- side === OrderSide.BUY && canTrade ? "oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80" : "oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"
3092
- ),
3093
- "data-testid": "oui-testid-orderEntry-side-buy-button",
3094
- children: t("common.buy")
3095
- }
3096
- ),
3097
- /* @__PURE__ */ jsx(
3098
- Button,
3099
- {
3100
- onClick: () => {
3101
- props.setOrderValue("side", OrderSide.SELL);
3102
- },
3103
- "data-type": OrderSide.SELL,
3104
- fullWidth: true,
3105
- size: "md",
3106
- className: cn(
3107
- "oui-orderEntry-side-sell-btn",
3108
- side === OrderSide.SELL && props.canTrade ? "oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80" : "oui-bg-base-7 oui-text-base-contrast-36 hover:oui-bg-base-6 active:oui-bg-base-6"
3109
- ),
3110
- "data-testid": "oui-testid-orderEntry-side-sell-button",
3111
- children: t("common.sell")
3112
- }
3113
- )
3114
- ]
3341
+ side,
3342
+ canTrade,
3343
+ onSideChange: (nextSide) => {
3344
+ props.setOrderValue("side", nextSide);
3345
+ }
3115
3346
  }
3116
3347
  )
3117
3348
  ] });
3118
3349
  }
3119
- var OrderEntryContext = createContext(
3120
- {}
3121
- );
3122
- var useOrderEntryContext = () => {
3123
- return useContext(OrderEntryContext);
3124
- };
3125
3350
  var OrderEntryProvider = (props) => {
3126
3351
  const {
3127
3352
  errorMsgVisible,
@@ -4592,129 +4817,6 @@ function OrderInput(props) {
4592
4817
  )
4593
4818
  ] });
4594
4819
  }
4595
- var SLIDER_MIN = 0;
4596
- var SLIDER_MAX = 100;
4597
- var QuantitySlider = memo((props) => {
4598
- const { canTrade, side, order_quantity, maxQty } = props;
4599
- const [sliderValue, setSliderValue] = useState(0);
4600
- const {
4601
- setOrderValue,
4602
- manualSetOrderValue,
4603
- symbolInfo,
4604
- lastQuantityInputType
4605
- } = useOrderEntryContext();
4606
- const { base_dp, base_tick } = symbolInfo;
4607
- const { t } = useTranslation();
4608
- const color = useMemo(
4609
- () => canTrade ? side === OrderSide.BUY ? "buy" : "sell" : void 0,
4610
- [side, canTrade]
4611
- );
4612
- const maxLabel = useMemo(() => {
4613
- return side === OrderSide.BUY ? t("orderEntry.maxBuy") : t("orderEntry.maxSell");
4614
- }, [side, t]);
4615
- const onSliderValueChange = (value) => {
4616
- lastQuantityInputType.current = 4 /* QUANTITY_SLIDER */;
4617
- setSliderValue(value);
4618
- sliderToQuantity(value, true);
4619
- };
4620
- const sliderToQuantity = (value, isManual = false) => {
4621
- const newQty = new Decimal(value).div(SLIDER_MAX).mul(maxQty).toFixed(base_dp, Decimal.ROUND_DOWN);
4622
- if (isManual) {
4623
- manualSetOrderValue?.(
4624
- "order_quantity",
4625
- utils.formatNumber(newQty, base_tick)
4626
- );
4627
- } else {
4628
- setOrderValue("order_quantity", utils.formatNumber(newQty, base_tick));
4629
- }
4630
- };
4631
- const onMax = () => {
4632
- onSliderValueChange(SLIDER_MAX);
4633
- if (sliderValue === SLIDER_MAX) {
4634
- sliderToQuantity(SLIDER_MAX, true);
4635
- }
4636
- };
4637
- useEffect(() => {
4638
- if (lastQuantityInputType.current === 4 /* QUANTITY_SLIDER */) {
4639
- sliderToQuantity(sliderValue);
4640
- }
4641
- }, [maxQty]);
4642
- useEffect(() => {
4643
- const quantityToSlider = () => {
4644
- if (order_quantity && Number(order_quantity) !== 0 && maxQty !== 0) {
4645
- return new Decimal(Math.min(Number(order_quantity), maxQty)).div(maxQty).mul(SLIDER_MAX).todp(2, Decimal.ROUND_DOWN).toNumber();
4646
- }
4647
- return 0;
4648
- };
4649
- if (lastQuantityInputType.current !== 4 /* QUANTITY_SLIDER */) {
4650
- setSliderValue(quantityToSlider());
4651
- }
4652
- }, [order_quantity, maxQty]);
4653
- return /* @__PURE__ */ jsxs("div", { className: "oui-orderEntry-quantitySlider", children: [
4654
- /* @__PURE__ */ jsx(
4655
- Slider,
4656
- {
4657
- disabled: maxQty === 0 || !canTrade,
4658
- value: [sliderValue],
4659
- color,
4660
- markCount: 4,
4661
- showTip: true,
4662
- onValueChange: (e) => {
4663
- onSliderValueChange(e[0]);
4664
- },
4665
- min: SLIDER_MIN,
4666
- max: SLIDER_MAX
4667
- }
4668
- ),
4669
- /* @__PURE__ */ jsxs(
4670
- Flex,
4671
- {
4672
- justify: "between",
4673
- className: "oui-quantitySlider-footer oui-pt-1 xl:oui-pt-2",
4674
- children: [
4675
- /* @__PURE__ */ jsx(
4676
- Text.numeral,
4677
- {
4678
- size: "2xs",
4679
- color,
4680
- dp: 2,
4681
- padding: false,
4682
- suffix: "%",
4683
- children: canTrade ? sliderValue : 0
4684
- }
4685
- ),
4686
- /* @__PURE__ */ jsxs(Flex, { children: [
4687
- /* @__PURE__ */ jsx(
4688
- "button",
4689
- {
4690
- className: textVariants({
4691
- size: "2xs",
4692
- className: "oui-quantitySlider-maxQty-btn oui-mr-1"
4693
- }),
4694
- onClick: onMax,
4695
- "data-testid": "oui-testid-orderEntry-maxQty-value-button",
4696
- children: maxLabel
4697
- }
4698
- ),
4699
- /* @__PURE__ */ jsx(
4700
- Text.numeral,
4701
- {
4702
- size: "2xs",
4703
- color,
4704
- dp: base_dp,
4705
- padding: false,
4706
- className: "oui-quantitySlider-maxQty-value",
4707
- "data-testid": "oui-testid-orderEntry-maxQty-value",
4708
- children: canTrade ? maxQty : 0
4709
- }
4710
- )
4711
- ] })
4712
- ]
4713
- }
4714
- )
4715
- ] });
4716
- });
4717
- QuantitySlider.displayName = "QuantitySlider";
4718
4820
  var ReduceOnlySwitch = ({
4719
4821
  checked,
4720
4822
  onCheckedChange,
@@ -5148,8 +5250,8 @@ var OrderTPSL = (props) => {
5148
5250
  {
5149
5251
  className: cn(
5150
5252
  "oui-orderEntry-tpsl-body",
5151
- "oui-max-h-0 oui-overflow-hidden oui-transition-all",
5152
- props.switchState && "oui-max-h-[120px]"
5253
+ "oui-overflow-hidden oui-transition-all",
5254
+ props.switchState ? "oui-max-h-[120px]" : "oui-max-h-0"
5153
5255
  ),
5154
5256
  onTransitionEnd: () => {
5155
5257
  tpslFormRef.current?.style.setProperty(
@@ -5757,7 +5859,7 @@ var OrderEntry = (props) => {
5757
5859
  }
5758
5860
  ),
5759
5861
  /* @__PURE__ */ jsx(
5760
- Available,
5862
+ OrderEntryAvailableInjectabled,
5761
5863
  {
5762
5864
  currentLtv,
5763
5865
  canTrade: props.canTrade,
@@ -5781,7 +5883,7 @@ var OrderEntry = (props) => {
5781
5883
  }
5782
5884
  ),
5783
5885
  /* @__PURE__ */ jsx(
5784
- QuantitySlider,
5886
+ OrderEntryQuantitySliderInjectabled,
5785
5887
  {
5786
5888
  canTrade: props.canTrade,
5787
5889
  side: props.side,
@@ -5790,38 +5892,29 @@ var OrderEntry = (props) => {
5790
5892
  }
5791
5893
  ),
5792
5894
  /* @__PURE__ */ jsx(
5793
- ThrottledButton,
5794
- {
5795
- fullWidth: true,
5796
- id: "order-entry-submit-button",
5797
- "data-type": OrderSide.BUY,
5798
- className: cn(
5799
- "oui-orderEntry-submit-btn",
5800
- side === OrderSide.BUY ? "orderly-order-entry-submit-button-buy oui-bg-success-darken hover:oui-bg-success-darken/80 active:oui-bg-success-darken/80" : "orderly-order-entry-submit-button-sell oui-bg-danger-darken hover:oui-bg-danger-darken/80 active:oui-bg-danger-darken/80"
5801
- ),
5802
- onClick: validateSubmit,
5803
- loading: props.isMutating,
5804
- disabled: !props.canTrade,
5805
- children: buttonLabel
5806
- }
5807
- ),
5808
- /* @__PURE__ */ jsx(
5809
- AssetInfo,
5895
+ OrderEntrySubmitSectionInjectabled,
5810
5896
  {
5897
+ buttonLabel,
5898
+ side,
5811
5899
  canTrade: props.canTrade,
5812
- quote: symbolInfo.quote,
5813
- estLiqPrice: props.estLiqPrice,
5814
- estLiqPriceDistance: props.estLiqPriceDistance,
5815
- estLeverage: props.estLeverage,
5816
- currentLeverage: props.currentLeverage,
5817
- slippage,
5818
- dp: symbolInfo.quote_dp,
5819
- setSlippage,
5820
- estSlippage: props.estSlippage,
5821
- orderType: formattedOrder.order_type,
5822
- disableFeatures,
5823
- symbol: props.symbol,
5824
- side
5900
+ isMutating: props.isMutating,
5901
+ onSubmit: validateSubmit,
5902
+ assetInfo: {
5903
+ canTrade: props.canTrade,
5904
+ quote: symbolInfo.quote,
5905
+ estLiqPrice: props.estLiqPrice,
5906
+ estLiqPriceDistance: props.estLiqPriceDistance,
5907
+ estLeverage: props.estLeverage,
5908
+ currentLeverage: props.currentLeverage,
5909
+ slippage,
5910
+ dp: symbolInfo.quote_dp,
5911
+ setSlippage,
5912
+ estSlippage: props.estSlippage,
5913
+ orderType: formattedOrder.order_type,
5914
+ disableFeatures,
5915
+ symbol: props.symbol,
5916
+ side
5917
+ }
5825
5918
  }
5826
5919
  ),
5827
5920
  /* @__PURE__ */ jsx(Divider, { className: "oui-w-full" }),
@@ -6475,10 +6568,14 @@ var useOrderEntryScript = (inputs) => {
6475
6568
  isSymbolPostOnly
6476
6569
  };
6477
6570
  };
6571
+ var InjectableOrderEntry = injectable(
6572
+ OrderEntry,
6573
+ "OrderEntry"
6574
+ );
6478
6575
  var OrderEntryWidget = (props) => {
6479
6576
  const state = useOrderEntryScript(props);
6480
6577
  return /* @__PURE__ */ jsx(
6481
- OrderEntry,
6578
+ InjectableOrderEntry,
6482
6579
  {
6483
6580
  ...state,
6484
6581
  containerRef: props.containerRef,