@orderly.network/ui-transfer 3.0.0-beta.1 → 3.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,12 +1,13 @@
1
1
  import { i18n, useTranslation, Trans } from '@orderly.network/i18n';
2
- import { registerSimpleDialog, registerSimpleSheet, Tabs, TabPanel, ArrowDownSquareFillIcon, ArrowUpSquareFillIcon, ExtensionSlot, ExtensionPositionEnum, Box, textVariants, Flex, toast, Text, cn, Button, Spinner, Select, Input, inputFormatter, useScreen, modal, Tooltip, Tips, AlertDialog, EditIcon, ArrowLeftRightIcon, WalletIcon, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, ScrollArea, ChainIcon, Badge, CaretUpIcon, CaretDownIcon, SimpleDialog, CloseRoundFillIcon, ExclamationFillIcon, TokenIcon, Checkbox, CloseIcon } from '@orderly.network/ui';
2
+ import { registerSimpleDialog, registerSimpleSheet, Tabs, TabPanel, ArrowDownSquareFillIcon, ArrowUpSquareFillIcon, ExtensionSlot, ExtensionPositionEnum, Box, textVariants, Flex, toast, Text, cn, Button, Spinner, Select, Input, inputFormatter, useScreen, modal, Tooltip, Tips, AlertDialog, EditIcon, ArrowLeftRightIcon, WalletIcon, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, ScrollArea, ChainIcon, Badge, TokenIcon, CaretUpIcon, CaretDownIcon, SimpleDialog, CloseRoundFillIcon, ExclamationFillIcon, WarningIcon, SelectItem, ChevronRightIcon, Checkbox, CloseIcon } from '@orderly.network/ui';
3
3
  import { forwardRef, useState, isValidElement, useMemo, useEffect, useCallback, useRef } from 'react';
4
- import { useConfig, useWalletConnector, useLocalStorage, useConvert, useOdosQuote, useComputedLTV, useAccount, useAppStore, useTransfer, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useTokensInfo, useEventEmitter, usePositionStream, useIndexPricesStream, useOrderlyContext, useDeposit, useAssetsHistory, useChains, useMemoizedFn, useWithdraw, useWalletTopic, useQuery, useSWR, useTokenInfo, useHoldingStream, useInternalTransfer, useDebouncedCallback, useTransferHistory, useBalanceTopic } from '@orderly.network/hooks';
4
+ import { useConfig, useWalletConnector, useLocalStorage, useConvert, useOdosQuote, useComputedLTV, useAccount, useAppStore, useTransfer, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useTokensInfo, useEventEmitter, usePositionStream, useIndexPricesStream, useOrderlyContext, useDeposit, useAssetsHistory, useChains, useMemoizedFn, useWithdraw, useWalletTopic, useQuery, useSWR, useTokenInfo, useHoldingStream, useInternalTransfer, useDebouncedCallback, usePrivateQuery, useTransferHistory, useBalanceTopic } from '@orderly.network/hooks';
5
5
  import { Decimal, zero, praseChainIdToNumber, int2hex, toNonExponential, formatWithPrecision, isSolana } from '@orderly.network/utils';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
- import { AccountStatusEnum, AssetHistoryStatusEnum, AssetHistorySideEnum, Arbitrum, EMPTY_OBJECT, isNativeTokenChecker, ChainNamespace, ABSTRACT_CHAIN_ID_MAP, nativeTokenAddress } from '@orderly.network/types';
7
+ import { AccountStatusEnum, ChainNamespace, AssetHistoryStatusEnum, AssetHistorySideEnum, Arbitrum, EMPTY_OBJECT, isNativeTokenChecker, ABSTRACT_CHAIN_ID_MAP, nativeTokenAddress } from '@orderly.network/types';
8
8
  import { AuthGuard, useAuthGuard } from '@orderly.network/ui-connector';
9
9
  import { useAppContext, useAppConfig } from '@orderly.network/react-app';
10
+ import { qrcode } from '@akamfoad/qr';
10
11
  import { account } from '@orderly.network/perp';
11
12
  import { utils } from '@orderly.network/core';
12
13
  import { ChainSelectorDialogId } from '@orderly.network/ui-chain-selector';
@@ -597,6 +598,392 @@ var ExchangeDivider = ({ icon }) => {
597
598
  /* @__PURE__ */ jsx(Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
598
599
  ] });
599
600
  };
601
+ var CopyIcon = ({ copied }) => /* @__PURE__ */ jsx(
602
+ "svg",
603
+ {
604
+ width: "17",
605
+ height: "16",
606
+ viewBox: "0 0 17 16",
607
+ fill: "currentColor",
608
+ xmlns: "http://www.w3.org/2000/svg",
609
+ className: `oui-fill-base-contrast oui-text-base-contrast-54 ${copied ? "oui-fill-success oui-text-success" : ""}`,
610
+ children: copied ? /* @__PURE__ */ jsx(
611
+ "path",
612
+ {
613
+ d: "M14 4L6 11.5L3 8.5",
614
+ fill: "none",
615
+ stroke: "currentColor",
616
+ strokeWidth: "2",
617
+ strokeLinecap: "round",
618
+ strokeLinejoin: "round"
619
+ }
620
+ ) : /* @__PURE__ */ jsx(
621
+ "path",
622
+ {
623
+ d: "M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",
624
+ fill: "currentColor"
625
+ }
626
+ )
627
+ }
628
+ );
629
+ var CopyAddress = ({ address }) => {
630
+ const [copied, setCopied] = useState(false);
631
+ const handleCopy = () => {
632
+ navigator.clipboard.writeText(address);
633
+ setCopied(true);
634
+ setTimeout(() => setCopied(false), 2e3);
635
+ };
636
+ return /* @__PURE__ */ jsxs(
637
+ Flex,
638
+ {
639
+ gap: 1,
640
+ itemAlign: "start",
641
+ className: "oui-mt-6 oui-w-full oui-cursor-pointer oui-justify-center",
642
+ onClick: handleCopy,
643
+ children: [
644
+ /* @__PURE__ */ jsx(
645
+ Text,
646
+ {
647
+ size: "xs",
648
+ className: "oui-break-all oui-text-center oui-text-base-contrast-80",
649
+ title: address,
650
+ children: address
651
+ }
652
+ ),
653
+ /* @__PURE__ */ jsx(Box, { className: "oui-mt-0.5 oui-shrink-0", children: /* @__PURE__ */ jsx(CopyIcon, { copied }) })
654
+ ]
655
+ }
656
+ );
657
+ };
658
+ var DepositStatusBlock = ({
659
+ amount,
660
+ symbol = "USDC",
661
+ pendingCount,
662
+ explorerUrl
663
+ }) => {
664
+ const { t: t0 } = useTranslation();
665
+ const t = t0;
666
+ const label = t("transfer.exclusiveDeposit.depositPending", {
667
+ amount,
668
+ symbol
669
+ });
670
+ const handleClick = () => {
671
+ window.open(explorerUrl, "_blank", "noopener,noreferrer");
672
+ };
673
+ return /* @__PURE__ */ jsxs(
674
+ Flex,
675
+ {
676
+ itemAlign: "center",
677
+ gap: 2,
678
+ className: "oui-group oui-mt-6 oui-w-full oui-cursor-pointer",
679
+ onClick: handleClick,
680
+ children: [
681
+ /* @__PURE__ */ jsx("div", { className: "oui-size-2 oui-shrink-0 oui-rounded-full oui-bg-primary" }),
682
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, className: "oui-flex-1", children: label }),
683
+ pendingCount > 1 && /* @__PURE__ */ jsx(
684
+ Flex,
685
+ {
686
+ justify: "center",
687
+ itemAlign: "center",
688
+ r: "full",
689
+ width: 18,
690
+ height: 18,
691
+ className: "oui-bg-line-12",
692
+ children: /* @__PURE__ */ jsx(Text, { size: "3xs", intensity: 80, children: pendingCount })
693
+ }
694
+ ),
695
+ /* @__PURE__ */ jsx(ChevronRightIcon, { className: "oui-size-4 oui-text-base-contrast-54 oui-transition-colors group-hover:oui-text-base-contrast-80" })
696
+ ]
697
+ }
698
+ );
699
+ };
700
+ var NetworkTokenSelect = ({
701
+ selectedNetwork,
702
+ selectedToken,
703
+ onNetworkChange,
704
+ onTokenChange,
705
+ networkOptions,
706
+ tokenOptions
707
+ }) => {
708
+ const { t: t0 } = useTranslation();
709
+ const t = t0;
710
+ const selectContentProps = {
711
+ align: "end",
712
+ sideOffset: -4,
713
+ className: "oui-custom-scrollbar"
714
+ };
715
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
716
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
717
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.network") }),
718
+ /* @__PURE__ */ jsx(Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsx(
719
+ Select,
720
+ {
721
+ size: "xs",
722
+ value: selectedNetwork || void 0,
723
+ onValueChange: onNetworkChange,
724
+ placeholder: t("transfer.exclusiveDeposit.selectNetwork"),
725
+ variant: "text",
726
+ classNames: { trigger: "oui-pr-0" },
727
+ maxHeight: 128,
728
+ contentProps: selectContentProps,
729
+ children: networkOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
730
+ /* @__PURE__ */ jsx(ChainIcon, { chainId: opt.chainId, size: "2xs" }),
731
+ opt.label
732
+ ] }) }, opt.value))
733
+ }
734
+ ) })
735
+ ] }),
736
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
737
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.token") }),
738
+ /* @__PURE__ */ jsx(Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsx(
739
+ Select,
740
+ {
741
+ size: "xs",
742
+ value: selectedToken || void 0,
743
+ onValueChange: onTokenChange,
744
+ placeholder: t("transfer.exclusiveDeposit.selectToken"),
745
+ variant: "text",
746
+ classNames: { trigger: "oui-pr-0" },
747
+ maxHeight: 128,
748
+ contentProps: selectContentProps,
749
+ children: tokenOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
750
+ /* @__PURE__ */ jsx(TokenIcon, { name: opt.value, size: "2xs" }),
751
+ opt.label
752
+ ] }) }, opt.value))
753
+ }
754
+ ) })
755
+ ] })
756
+ ] });
757
+ };
758
+ var QRCodeDisplay = ({ address }) => {
759
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", className: "oui-mt-5 oui-w-full", itemAlign: "center", children: /* @__PURE__ */ jsx(Box, { className: "oui-relative oui-flex oui-size-[140px] oui-items-center oui-justify-center oui-rounded-lg oui-bg-white oui-p-2", children: address ? /* @__PURE__ */ jsx(QRCodeCanvas, { width: 124, height: 124, content: address }) : /* @__PURE__ */ jsx(Box, { className: "oui-size-full oui-border-8 oui-border-dashed oui-border-black oui-opacity-50" }) }) });
760
+ };
761
+ var QRCodeCanvas = ({ width, height, content }) => {
762
+ const canvasRef = useRef(null);
763
+ useEffect(() => {
764
+ if (!canvasRef.current || !content) return;
765
+ const qrcode$1 = qrcode(content);
766
+ const ctx = canvasRef.current.getContext("2d");
767
+ const cells = qrcode$1.modules;
768
+ const tileW = width / cells.length;
769
+ const tileH = height / cells.length;
770
+ for (let r = 0; r < cells.length; ++r) {
771
+ const row = cells[r];
772
+ for (let c = 0; c < row.length; ++c) {
773
+ ctx.fillStyle = row[c] ? "#000" : "#fff";
774
+ const w = Math.ceil((c + 1) * tileW) - Math.floor(c * tileW);
775
+ const h = Math.ceil((r + 1) * tileH) - Math.floor(r * tileH);
776
+ ctx.fillRect(Math.round(c * tileW), Math.round(r * tileH), w, h);
777
+ }
778
+ }
779
+ }, [content, width, height]);
780
+ return /* @__PURE__ */ jsx("canvas", { width, height, ref: canvasRef });
781
+ };
782
+ var WarningBanner = ({ message }) => {
783
+ return /* @__PURE__ */ jsxs(
784
+ Flex,
785
+ {
786
+ itemAlign: "start",
787
+ gap: 1,
788
+ className: "oui-mt-4 oui-w-[calc(100%+2.5rem)] oui-rounded oui-bg-[#FF7D00]/10 oui-px-5 oui-py-2 oui-text-[#FF7D00]",
789
+ children: [
790
+ /* @__PURE__ */ jsx(Box, { className: "oui-mt-0.5", children: /* @__PURE__ */ jsx(WarningIcon, { width: 16, height: 16 }) }),
791
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 80, className: "oui-w-full oui-text-[#FF7D00]", children: message })
792
+ ]
793
+ }
794
+ );
795
+ };
796
+ var buildExplorerUrl = (baseUrl, txId) => {
797
+ const url = baseUrl;
798
+ if (url.endsWith("/")) {
799
+ return `${url}tx/${txId}`;
800
+ }
801
+ return `${url}/tx/${txId}`;
802
+ };
803
+ var useExclusiveDeposit = (options2) => {
804
+ const active = options2.active ?? true;
805
+ const confirmed = options2.confirmed ?? true;
806
+ const { chainId, explorerBaseUrl } = options2;
807
+ const { t: t0 } = useTranslation();
808
+ const t = t0;
809
+ const receiverAddressKey = confirmed && chainId ? `/v1/client/asset/receiver_address?chain_id=${chainId}` : null;
810
+ const receiverEventsKey = active && confirmed ? "/v1/client/asset/receiver_events" : null;
811
+ const {
812
+ data: addressData,
813
+ isLoading: isAddressLoading,
814
+ error: addressError
815
+ } = usePrivateQuery(receiverAddressKey, {
816
+ revalidateOnFocus: false
817
+ });
818
+ const {
819
+ data: eventsData,
820
+ isLoading: isEventsLoading,
821
+ error: eventsError
822
+ } = usePrivateQuery(receiverEventsKey, {
823
+ refreshInterval: active ? 1e4 : 0,
824
+ revalidateOnFocus: false
825
+ });
826
+ const { latestEvent, pendingCount, explorerUrl } = useMemo(() => {
827
+ const events = eventsData ?? [];
828
+ if (!events.length) {
829
+ return {
830
+ latestEvent: void 0,
831
+ pendingCount: 0,
832
+ explorerUrl: void 0
833
+ };
834
+ }
835
+ const latest = events.reduce((acc, curr) => {
836
+ if (!acc) return curr;
837
+ return curr.created_time > acc.created_time ? curr : acc;
838
+ }, void 0);
839
+ const count = events.length;
840
+ const url = latest?.tx_id ? buildExplorerUrl(explorerBaseUrl, latest.tx_id) : void 0;
841
+ return {
842
+ latestEvent: latest,
843
+ pendingCount: count,
844
+ explorerUrl: url
845
+ };
846
+ }, [explorerBaseUrl, eventsData]);
847
+ return {
848
+ address: addressData?.receiver_address,
849
+ qrUri: addressData?.receiver_address,
850
+ minimumDeposit: addressData?.minimum_deposit,
851
+ estimatedArrivalText: t("transfer.exclusiveDeposit.estimatedTime.default"),
852
+ latestEvent,
853
+ pendingCount,
854
+ explorerUrl,
855
+ isAddressLoading,
856
+ isEventsLoading,
857
+ addressError,
858
+ eventsError
859
+ };
860
+ };
861
+ var SUPPORTED_CHAINS = {
862
+ prod: [42161],
863
+ testnet: [421614]
864
+ };
865
+ var SUPPORTED_TOKENS = ["USDC"];
866
+ var useExclusiveDepositOptions = () => {
867
+ const env = useConfig("env");
868
+ const networkId = useConfig("networkId");
869
+ const [chains, { findByChainId }] = useChains(networkId, {
870
+ pick: "network_infos"
871
+ });
872
+ const supportedChainIds = env === "prod" ? SUPPORTED_CHAINS.prod : SUPPORTED_CHAINS.testnet;
873
+ const networkOptions = useMemo(() => {
874
+ return supportedChainIds.map((chainId) => {
875
+ const chain = findByChainId(chainId);
876
+ const name = chain?.network_infos?.name ?? `Chain ${chainId}`;
877
+ const explorerUrl = chain?.network_infos?.explorer_base_url ?? "";
878
+ return {
879
+ label: name,
880
+ value: String(chainId),
881
+ chainId,
882
+ explorerUrl
883
+ };
884
+ });
885
+ }, [supportedChainIds, findByChainId]);
886
+ const tokenOptions = useMemo(() => {
887
+ return SUPPORTED_TOKENS.map((symbol) => ({
888
+ label: symbol,
889
+ value: symbol
890
+ }));
891
+ }, []);
892
+ return { networkOptions, tokenOptions };
893
+ };
894
+ var ExclusiveDeposit = ({ active }) => {
895
+ const { t: t0 } = useTranslation();
896
+ const t = t0;
897
+ const [selectedNetwork, setSelectedNetwork] = useState("");
898
+ const [selectedToken, setSelectedToken] = useState("");
899
+ const { networkOptions, tokenOptions } = useExclusiveDepositOptions();
900
+ const confirmed = !!selectedNetwork && !!selectedToken;
901
+ const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
902
+ const selectedChainId = selectedNetworkOption?.chainId;
903
+ const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
904
+ const {
905
+ address,
906
+ qrUri,
907
+ minimumDeposit,
908
+ estimatedArrivalText,
909
+ latestEvent,
910
+ pendingCount,
911
+ explorerUrl
912
+ } = useExclusiveDeposit({
913
+ active,
914
+ confirmed,
915
+ chainId: selectedChainId,
916
+ explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
917
+ });
918
+ const networkName = selectedNetworkOption?.label ?? "";
919
+ const tokenName = selectedTokenOption?.label ?? "";
920
+ const warningMessage = confirmed ? t("transfer.exclusiveDeposit.warning", {
921
+ token: tokenName,
922
+ network: networkName
923
+ }) : t("transfer.exclusiveDeposit.selectFirst");
924
+ const minText = confirmed && typeof minimumDeposit === "number" ? `${minimumDeposit} ${tokenName}` : "--";
925
+ const estText = confirmed ? estimatedArrivalText ?? t("transfer.exclusiveDeposit.estimatedTime.default") : "--";
926
+ return /* @__PURE__ */ jsxs(Box, { className: "oui-flex oui-flex-col oui-items-center oui-rounded-xl oui-bg-base-8 oui-tracking-[0.03em]", children: [
927
+ /* @__PURE__ */ jsx(WarningBanner, { message: warningMessage }),
928
+ confirmed && /* @__PURE__ */ jsxs(Fragment, { children: [
929
+ /* @__PURE__ */ jsx(QRCodeDisplay, { address: qrUri }),
930
+ address && /* @__PURE__ */ jsx(CopyAddress, { address })
931
+ ] }),
932
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
933
+ confirmed ? /* @__PURE__ */ jsxs(Fragment, { children: [
934
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
935
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.network") }),
936
+ /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
937
+ /* @__PURE__ */ jsx(ChainIcon, { chainId: selectedChainId, size: "2xs" }),
938
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: networkName })
939
+ ] })
940
+ ] }),
941
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
942
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.token") }),
943
+ /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
944
+ /* @__PURE__ */ jsx(TokenIcon, { name: tokenName, size: "2xs" }),
945
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: tokenName })
946
+ ] })
947
+ ] })
948
+ ] }) : /* @__PURE__ */ jsx(
949
+ NetworkTokenSelect,
950
+ {
951
+ selectedNetwork,
952
+ selectedToken,
953
+ onNetworkChange: setSelectedNetwork,
954
+ onTokenChange: setSelectedToken,
955
+ networkOptions,
956
+ tokenOptions
957
+ }
958
+ ),
959
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", children: [
960
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
961
+ /* @__PURE__ */ jsx(
962
+ Text,
963
+ {
964
+ size: "xs",
965
+ className: confirmed ? "oui-text-[#FF7D00]" : "",
966
+ intensity: confirmed ? void 0 : 98,
967
+ children: minText
968
+ }
969
+ )
970
+ ] }),
971
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", children: [
972
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.estimatedTime") }),
973
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: estText })
974
+ ] })
975
+ ] }),
976
+ confirmed && latestEvent && explorerUrl && /* @__PURE__ */ jsx(
977
+ DepositStatusBlock,
978
+ {
979
+ amount: latestEvent.amount,
980
+ symbol: latestEvent.token,
981
+ pendingCount,
982
+ explorerUrl
983
+ }
984
+ )
985
+ ] });
986
+ };
600
987
  var Fee = (props) => {
601
988
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
602
989
  const { t } = useTranslation();
@@ -1521,7 +1908,10 @@ var DepositForm = (props) => {
1521
1908
  showSourceDepositCap,
1522
1909
  showTargetDepositCap,
1523
1910
  slippageValidate,
1524
- quantityNotional
1911
+ quantityNotional,
1912
+ activeSubTab,
1913
+ setActiveSubTab,
1914
+ showExclusiveDeposit
1525
1915
  } = props;
1526
1916
  const { t } = useTranslation();
1527
1917
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsx(
@@ -1582,101 +1972,129 @@ var DepositForm = (props) => {
1582
1972
  /* @__PURE__ */ jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1583
1973
  ] });
1584
1974
  };
1585
- return /* @__PURE__ */ jsxs(Box, { id: "oui-deposit-form", className: textVariants({ weight: "semibold" }), children: [
1586
- /* @__PURE__ */ jsxs(Box, { className: "oui-mb-6 lg:oui-mb-8", children: [
1587
- /* @__PURE__ */ jsx(Web3Wallet, {}),
1588
- /* @__PURE__ */ jsxs(Box, { mt: 3, mb: 1, children: [
1589
- /* @__PURE__ */ jsx(
1590
- ChainSelect,
1975
+ return /* @__PURE__ */ jsx(Box, { id: "oui-deposit-form", className: textVariants({ weight: "semibold" }), children: /* @__PURE__ */ jsxs(
1976
+ Tabs,
1977
+ {
1978
+ value: activeSubTab,
1979
+ onValueChange: (value) => setActiveSubTab(value),
1980
+ variant: "contained",
1981
+ classNames: {
1982
+ tabsList: "oui-w-fit"
1983
+ },
1984
+ children: [
1985
+ /* @__PURE__ */ jsxs(
1986
+ TabPanel,
1591
1987
  {
1592
- chains,
1593
- value: currentChain,
1594
- onValueChange: onChainChange,
1595
- wrongNetwork,
1596
- loading: settingChain,
1597
- disabled: !props.isLoggedIn
1988
+ title: t("transfer.deposit.tab.connectedWallet"),
1989
+ value: "web3",
1990
+ children: [
1991
+ /* @__PURE__ */ jsxs(Box, { className: "oui-mt-3", children: [
1992
+ /* @__PURE__ */ jsx(Web3Wallet, {}),
1993
+ /* @__PURE__ */ jsxs(Box, { mt: 3, mb: 1, children: [
1994
+ /* @__PURE__ */ jsx(
1995
+ ChainSelect,
1996
+ {
1997
+ chains,
1998
+ value: currentChain,
1999
+ onValueChange: onChainChange,
2000
+ wrongNetwork,
2001
+ loading: settingChain,
2002
+ disabled: !props.isLoggedIn
2003
+ }
2004
+ ),
2005
+ /* @__PURE__ */ jsx(
2006
+ QuantityInput,
2007
+ {
2008
+ "data-testId": "oui-testid-deposit-dialog-quantity-input",
2009
+ classNames: {
2010
+ root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
2011
+ },
2012
+ value: quantity,
2013
+ onValueChange: onQuantityChange,
2014
+ token: sourceToken,
2015
+ tokens: sourceTokens,
2016
+ onTokenChange: onSourceTokenChange,
2017
+ status: inputStatus,
2018
+ hintMessage,
2019
+ tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
2020
+ tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
2021
+ disabled: !props.isLoggedIn,
2022
+ balancesRevalidating: batchBalancesRevalidating,
2023
+ showBalance: true
2024
+ }
2025
+ )
2026
+ ] }),
2027
+ /* @__PURE__ */ jsx(
2028
+ AvailableQuantity,
2029
+ {
2030
+ token: sourceToken,
2031
+ quantity,
2032
+ maxQuantity,
2033
+ notional: quantityNotional,
2034
+ loading: balanceRevalidating,
2035
+ onClick: () => {
2036
+ onQuantityChange(maxDepositAmount);
2037
+ }
2038
+ }
2039
+ ),
2040
+ /* @__PURE__ */ jsx(
2041
+ YieldBearingReminder,
2042
+ {
2043
+ symbol: targetToken?.symbol,
2044
+ className: "oui-mt-3"
2045
+ }
2046
+ ),
2047
+ /* @__PURE__ */ jsx(ExchangeDivider, {}),
2048
+ /* @__PURE__ */ jsx(BrokerWallet, {}),
2049
+ /* @__PURE__ */ jsx(
2050
+ QuantityInput,
2051
+ {
2052
+ classNames: {
2053
+ root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
2054
+ },
2055
+ token: targetToken,
2056
+ tokens: targetTokens,
2057
+ onTokenChange: onTargetTokenChange,
2058
+ value: targetQuantity,
2059
+ loading: targetQuantityLoading,
2060
+ disabled: !props.isLoggedIn,
2061
+ readOnly: true,
2062
+ status: targetInputStatus,
2063
+ hintMessage: targetHintMessage,
2064
+ tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
2065
+ tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
2066
+ }
2067
+ ),
2068
+ renderContent()
2069
+ ] }),
2070
+ /* @__PURE__ */ jsx(Box, { className: "oui-mb-6 lg:oui-mb-8", children: /* @__PURE__ */ jsx(Notice, { message: warningMessage, wrongNetwork }) }),
2071
+ /* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
2072
+ ActionButton,
2073
+ {
2074
+ actionType,
2075
+ symbol: sourceToken?.symbol,
2076
+ disabled,
2077
+ loading,
2078
+ onDeposit,
2079
+ onApprove,
2080
+ onApproveAndDeposit,
2081
+ networkId
2082
+ }
2083
+ ) })
2084
+ ]
1598
2085
  }
1599
2086
  ),
1600
- /* @__PURE__ */ jsx(
1601
- QuantityInput,
2087
+ showExclusiveDeposit && /* @__PURE__ */ jsx(
2088
+ TabPanel,
1602
2089
  {
1603
- "data-testId": "oui-testid-deposit-dialog-quantity-input",
1604
- classNames: {
1605
- root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
1606
- },
1607
- value: quantity,
1608
- onValueChange: onQuantityChange,
1609
- token: sourceToken,
1610
- tokens: sourceTokens,
1611
- onTokenChange: onSourceTokenChange,
1612
- status: inputStatus,
1613
- hintMessage,
1614
- tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
1615
- tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
1616
- disabled: !props.isLoggedIn,
1617
- balancesRevalidating: batchBalancesRevalidating,
1618
- showBalance: true
2090
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2091
+ value: "exclusive_deposit",
2092
+ children: /* @__PURE__ */ jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1619
2093
  }
1620
2094
  )
1621
- ] }),
1622
- /* @__PURE__ */ jsx(
1623
- AvailableQuantity,
1624
- {
1625
- token: sourceToken,
1626
- quantity,
1627
- maxQuantity,
1628
- notional: quantityNotional,
1629
- loading: balanceRevalidating,
1630
- onClick: () => {
1631
- onQuantityChange(maxDepositAmount);
1632
- }
1633
- }
1634
- ),
1635
- /* @__PURE__ */ jsx(
1636
- YieldBearingReminder,
1637
- {
1638
- symbol: targetToken?.symbol,
1639
- className: "oui-mt-3"
1640
- }
1641
- ),
1642
- /* @__PURE__ */ jsx(ExchangeDivider, {}),
1643
- /* @__PURE__ */ jsx(BrokerWallet, {}),
1644
- /* @__PURE__ */ jsx(
1645
- QuantityInput,
1646
- {
1647
- classNames: {
1648
- root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
1649
- },
1650
- token: targetToken,
1651
- tokens: targetTokens,
1652
- onTokenChange: onTargetTokenChange,
1653
- value: targetQuantity,
1654
- loading: targetQuantityLoading,
1655
- disabled: !props.isLoggedIn,
1656
- readOnly: true,
1657
- status: targetInputStatus,
1658
- hintMessage: targetHintMessage,
1659
- tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
1660
- tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
1661
- }
1662
- ),
1663
- renderContent()
1664
- ] }),
1665
- /* @__PURE__ */ jsx(Notice, { message: warningMessage, wrongNetwork }),
1666
- /* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
1667
- ActionButton,
1668
- {
1669
- actionType,
1670
- symbol: sourceToken?.symbol,
1671
- disabled,
1672
- loading,
1673
- onDeposit,
1674
- onApprove,
1675
- onApproveAndDeposit,
1676
- networkId
1677
- }
1678
- ) })
1679
- ] });
2095
+ ]
2096
+ }
2097
+ ) });
1680
2098
  };
1681
2099
  function useActionType(options2) {
1682
2100
  const { allowance, quantity, maxQuantity } = options2;
@@ -1992,7 +2410,7 @@ function useDepositFee(options2) {
1992
2410
  }
1993
2411
  var useMaxDepositAmount = (sourceToken, balance) => {
1994
2412
  const maxDepositAmount = useMemo(() => {
1995
- const balanceDecimal = new Decimal(balance || 0).todp(
2413
+ const balanceDecimal = new Decimal(balance).todp(
1996
2414
  sourceToken?.precision ?? 2,
1997
2415
  Decimal.ROUND_DOWN
1998
2416
  );
@@ -2023,7 +2441,7 @@ var useDepositFormQuantities = ({
2023
2441
  getIndexPrice
2024
2442
  }) => {
2025
2443
  const maxQuantity = useMemo(
2026
- () => new Decimal(balance || 0).todp(sourceToken?.precision ?? 2, Decimal.ROUND_DOWN).toString(),
2444
+ () => new Decimal(balance).todp(sourceToken?.precision ?? 2, Decimal.ROUND_DOWN).toString(),
2027
2445
  [balance, sourceToken?.precision]
2028
2446
  );
2029
2447
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2481,9 +2899,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2481
2899
  logo_uri: item.logoURI
2482
2900
  }));
2483
2901
  }, [data]);
2484
- if (!enableSwapDeposit) {
2485
- return [];
2486
- }
2487
2902
  return tokens;
2488
2903
  };
2489
2904
 
@@ -3778,7 +4193,7 @@ var useDepositFormScript = (options2) => {
3778
4193
  } = useDepositFormQuantities({
3779
4194
  sourceToken,
3780
4195
  targetToken,
3781
- balance,
4196
+ balance: balance || "0",
3782
4197
  quantity,
3783
4198
  needSwap,
3784
4199
  swapQuantity,
@@ -3865,6 +4280,8 @@ var useDepositFormScript = (options2) => {
3865
4280
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3866
4281
  const targetQuantityLoading = swapPriceRevalidating;
3867
4282
  const warningMessage = validationMessage || swapErrorMessage;
4283
+ const [activeSubTab, setActiveSubTab] = useState("web3");
4284
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== ChainNamespace.solana;
3868
4285
  return {
3869
4286
  sourceToken,
3870
4287
  targetToken,
@@ -3918,7 +4335,10 @@ var useDepositFormScript = (options2) => {
3918
4335
  isLoggedIn,
3919
4336
  showSourceDepositCap,
3920
4337
  showTargetDepositCap,
3921
- quantityNotional
4338
+ quantityNotional,
4339
+ activeSubTab,
4340
+ setActiveSubTab,
4341
+ showExclusiveDeposit
3922
4342
  };
3923
4343
  };
3924
4344
  var DepositFormWidget = (props) => {