@orderly.network/ui-transfer 3.0.0-beta.0 → 3.0.0-beta.2

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,17 +1,19 @@
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';
3
- import { forwardRef, useState, 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';
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
+ 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, 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';
13
14
  import { PublicKey } from '@solana/web3.js';
14
15
  import { ethers } from 'ethers';
16
+ import { injectable } from '@orderly.network/plugin-core';
15
17
  import { DefaultSolanaWalletAdapter } from '@orderly.network/default-solana-adapter';
16
18
 
17
19
  // src/components/depositForm/depositForm.ui.tsx
@@ -596,6 +598,392 @@ var ExchangeDivider = ({ icon }) => {
596
598
  /* @__PURE__ */ jsx(Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
597
599
  ] });
598
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
+ };
599
987
  var Fee = (props) => {
600
988
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
601
989
  const { t } = useTranslation();
@@ -1520,7 +1908,10 @@ var DepositForm = (props) => {
1520
1908
  showSourceDepositCap,
1521
1909
  showTargetDepositCap,
1522
1910
  slippageValidate,
1523
- quantityNotional
1911
+ quantityNotional,
1912
+ activeSubTab,
1913
+ setActiveSubTab,
1914
+ showExclusiveDeposit
1524
1915
  } = props;
1525
1916
  const { t } = useTranslation();
1526
1917
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsx(
@@ -1581,101 +1972,129 @@ var DepositForm = (props) => {
1581
1972
  /* @__PURE__ */ jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1582
1973
  ] });
1583
1974
  };
1584
- return /* @__PURE__ */ jsxs(Box, { id: "oui-deposit-form", className: textVariants({ weight: "semibold" }), children: [
1585
- /* @__PURE__ */ jsxs(Box, { className: "oui-mb-6 lg:oui-mb-8", children: [
1586
- /* @__PURE__ */ jsx(Web3Wallet, {}),
1587
- /* @__PURE__ */ jsxs(Box, { mt: 3, mb: 1, children: [
1588
- /* @__PURE__ */ jsx(
1589
- 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,
1590
1987
  {
1591
- chains,
1592
- value: currentChain,
1593
- onValueChange: onChainChange,
1594
- wrongNetwork,
1595
- loading: settingChain,
1596
- 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
+ ]
1597
2085
  }
1598
2086
  ),
1599
- /* @__PURE__ */ jsx(
1600
- QuantityInput,
2087
+ showExclusiveDeposit && /* @__PURE__ */ jsx(
2088
+ TabPanel,
1601
2089
  {
1602
- "data-testId": "oui-testid-deposit-dialog-quantity-input",
1603
- classNames: {
1604
- root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
1605
- },
1606
- value: quantity,
1607
- onValueChange: onQuantityChange,
1608
- token: sourceToken,
1609
- tokens: sourceTokens,
1610
- onTokenChange: onSourceTokenChange,
1611
- status: inputStatus,
1612
- hintMessage,
1613
- tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
1614
- tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
1615
- disabled: !props.isLoggedIn,
1616
- balancesRevalidating: batchBalancesRevalidating,
1617
- showBalance: true
2090
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2091
+ value: "exclusive_deposit",
2092
+ children: /* @__PURE__ */ jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1618
2093
  }
1619
2094
  )
1620
- ] }),
1621
- /* @__PURE__ */ jsx(
1622
- AvailableQuantity,
1623
- {
1624
- token: sourceToken,
1625
- quantity,
1626
- maxQuantity,
1627
- notional: quantityNotional,
1628
- loading: balanceRevalidating,
1629
- onClick: () => {
1630
- onQuantityChange(maxDepositAmount);
1631
- }
1632
- }
1633
- ),
1634
- /* @__PURE__ */ jsx(
1635
- YieldBearingReminder,
1636
- {
1637
- symbol: targetToken?.symbol,
1638
- className: "oui-mt-3"
1639
- }
1640
- ),
1641
- /* @__PURE__ */ jsx(ExchangeDivider, {}),
1642
- /* @__PURE__ */ jsx(BrokerWallet, {}),
1643
- /* @__PURE__ */ jsx(
1644
- QuantityInput,
1645
- {
1646
- classNames: {
1647
- root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
1648
- },
1649
- token: targetToken,
1650
- tokens: targetTokens,
1651
- onTokenChange: onTargetTokenChange,
1652
- value: targetQuantity,
1653
- loading: targetQuantityLoading,
1654
- disabled: !props.isLoggedIn,
1655
- readOnly: true,
1656
- status: targetInputStatus,
1657
- hintMessage: targetHintMessage,
1658
- tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
1659
- tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
1660
- }
1661
- ),
1662
- renderContent()
1663
- ] }),
1664
- /* @__PURE__ */ jsx(Notice, { message: warningMessage, wrongNetwork }),
1665
- /* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
1666
- ActionButton,
1667
- {
1668
- actionType,
1669
- symbol: sourceToken?.symbol,
1670
- disabled,
1671
- loading,
1672
- onDeposit,
1673
- onApprove,
1674
- onApproveAndDeposit,
1675
- networkId
1676
- }
1677
- ) })
1678
- ] });
2095
+ ]
2096
+ }
2097
+ ) });
1679
2098
  };
1680
2099
  function useActionType(options2) {
1681
2100
  const { allowance, quantity, maxQuantity } = options2;
@@ -1991,7 +2410,7 @@ function useDepositFee(options2) {
1991
2410
  }
1992
2411
  var useMaxDepositAmount = (sourceToken, balance) => {
1993
2412
  const maxDepositAmount = useMemo(() => {
1994
- const balanceDecimal = new Decimal(balance || 0).todp(
2413
+ const balanceDecimal = new Decimal(balance).todp(
1995
2414
  sourceToken?.precision ?? 2,
1996
2415
  Decimal.ROUND_DOWN
1997
2416
  );
@@ -2022,7 +2441,7 @@ var useDepositFormQuantities = ({
2022
2441
  getIndexPrice
2023
2442
  }) => {
2024
2443
  const maxQuantity = useMemo(
2025
- () => new Decimal(balance || 0).todp(sourceToken?.precision ?? 2, Decimal.ROUND_DOWN).toString(),
2444
+ () => new Decimal(balance).todp(sourceToken?.precision ?? 2, Decimal.ROUND_DOWN).toString(),
2026
2445
  [balance, sourceToken?.precision]
2027
2446
  );
2028
2447
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2480,9 +2899,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2480
2899
  logo_uri: item.logoURI
2481
2900
  }));
2482
2901
  }, [data]);
2483
- if (!enableSwapDeposit) {
2484
- return [];
2485
- }
2486
2902
  return tokens;
2487
2903
  };
2488
2904
 
@@ -3777,7 +4193,7 @@ var useDepositFormScript = (options2) => {
3777
4193
  } = useDepositFormQuantities({
3778
4194
  sourceToken,
3779
4195
  targetToken,
3780
- balance,
4196
+ balance: balance || "0",
3781
4197
  quantity,
3782
4198
  needSwap,
3783
4199
  swapQuantity,
@@ -3864,6 +4280,8 @@ var useDepositFormScript = (options2) => {
3864
4280
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3865
4281
  const targetQuantityLoading = swapPriceRevalidating;
3866
4282
  const warningMessage = validationMessage || swapErrorMessage;
4283
+ const [activeSubTab, setActiveSubTab] = useState("web3");
4284
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== ChainNamespace.solana;
3867
4285
  return {
3868
4286
  sourceToken,
3869
4287
  targetToken,
@@ -3917,7 +4335,10 @@ var useDepositFormScript = (options2) => {
3917
4335
  isLoggedIn,
3918
4336
  showSourceDepositCap,
3919
4337
  showTargetDepositCap,
3920
- quantityNotional
4338
+ quantityNotional,
4339
+ activeSubTab,
4340
+ setActiveSubTab,
4341
+ showExclusiveDeposit
3921
4342
  };
3922
4343
  };
3923
4344
  var DepositFormWidget = (props) => {
@@ -5989,10 +6410,14 @@ var WithdrawSlot = (props) => {
5989
6410
  var DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
5990
6411
  var DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
5991
6412
  var DepositAndWithdraw = (props) => {
6413
+ const { extraTabs = [] } = props;
5992
6414
  const [activeTab, setActiveTab] = useState(
5993
6415
  props.activeTab || "deposit"
5994
6416
  );
5995
6417
  const { t } = useTranslation();
6418
+ const sortedExtra = [...extraTabs].sort(
6419
+ (a, b) => (a.order ?? 100) - (b.order ?? 100)
6420
+ );
5996
6421
  return /* @__PURE__ */ jsxs(
5997
6422
  Tabs,
5998
6423
  {
@@ -6022,18 +6447,39 @@ var DepositAndWithdraw = (props) => {
6022
6447
  value: "withdraw",
6023
6448
  children: /* @__PURE__ */ jsx(WithdrawSlot, { close: props.close })
6024
6449
  }
6025
- )
6450
+ ),
6451
+ sortedExtra.map((tab) => /* @__PURE__ */ jsx(
6452
+ TabPanel,
6453
+ {
6454
+ title: tab.title,
6455
+ icon: isValidElement(tab.icon) ? tab.icon : void 0,
6456
+ value: tab.id,
6457
+ children: /* @__PURE__ */ jsx(tab.component, { close: props.close })
6458
+ },
6459
+ tab.id
6460
+ ))
6026
6461
  ]
6027
6462
  }
6028
6463
  );
6029
6464
  };
6030
- registerSimpleDialog(DepositAndWithdrawWithDialogId, DepositAndWithdraw, {
6031
- size: "md",
6032
- classNames: {
6033
- content: "oui-border oui-border-line-6"
6465
+ var InjectableDepositAndWithdraw = injectable(
6466
+ DepositAndWithdraw,
6467
+ "Transfer.DepositAndWithdraw"
6468
+ );
6469
+ registerSimpleDialog(
6470
+ DepositAndWithdrawWithDialogId,
6471
+ InjectableDepositAndWithdraw,
6472
+ {
6473
+ size: "md",
6474
+ classNames: {
6475
+ content: "oui-border oui-border-line-6"
6476
+ }
6034
6477
  }
6035
- });
6036
- registerSimpleSheet(DepositAndWithdrawWithSheetId, DepositAndWithdraw);
6478
+ );
6479
+ registerSimpleSheet(
6480
+ DepositAndWithdrawWithSheetId,
6481
+ InjectableDepositAndWithdraw
6482
+ );
6037
6483
  var AccountSelect = (props) => {
6038
6484
  const { subAccounts = [], value } = props;
6039
6485
  const [open, setOpen] = useState(false);
@@ -7871,6 +8317,6 @@ var DepositStatusWidget = (props) => {
7871
8317
  return /* @__PURE__ */ jsx(DepositStatus, { ...state, ...props });
7872
8318
  };
7873
8319
 
7874
- export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, ConvertFormUI, ConvertFormWidget, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, DepositFormWidget, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, WithdrawFormWidget, WithdrawTo, YIELD_BEARING_ASSETS, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
8320
+ export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, ConvertFormUI, ConvertFormWidget, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, DepositFormWidget, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, InjectableDepositAndWithdraw, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, WithdrawFormWidget, WithdrawTo, YIELD_BEARING_ASSETS, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
7875
8321
  //# sourceMappingURL=index.mjs.map
7876
8322
  //# sourceMappingURL=index.mjs.map