@rango-dev/widget-embedded 0.18.0 → 0.19.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/CHANGELOG.md +1 -113
- package/dist/QueueManager.d.ts +2 -5
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +17 -0
- package/dist/Wallets.d.ts.map +1 -0
- package/dist/Widget.d.ts +9 -0
- package/dist/Widget.d.ts.map +1 -0
- package/dist/components/AppRouter.d.ts +2 -0
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +6 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +62 -691
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +2 -2
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +0 -1727
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
- package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
- package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
- package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/index.d.ts +2 -0
- package/dist/components/NoRoutes/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
- package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/RouteErrors/index.d.ts +2 -0
- package/dist/components/RouteErrors/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +0 -158
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +0 -628
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +0 -157
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +1 -1100
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +9 -4
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +1 -0
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +4 -4
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/navigationRoutes.d.ts +2 -1
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +1 -2
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/warnings.d.ts +2 -2
- package/dist/constants/warnings.d.ts.map +1 -1
- package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
- package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
- package/dist/hooks/useLanguage.d.ts +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts +3 -1
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +7 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +0 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +1 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +2 -4
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +8 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +6 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LanguagePage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +2 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +6 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +8 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +22 -41
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +77 -0
- package/dist/store/bestRoute.d.ts.map +1 -0
- package/dist/store/meta.d.ts +23 -0
- package/dist/store/meta.d.ts.map +1 -0
- package/dist/store/notification.d.ts +3 -4
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/settings.d.ts +81 -0
- package/dist/store/settings.d.ts.map +1 -0
- package/dist/store/slices/config.d.ts +2 -3
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +2 -5
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/ui.d.ts +1 -2
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +9 -14
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -41
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/routing.d.ts +65 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/types/swap.d.ts +14 -4
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -15
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +0 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -2
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/queue.d.ts +2 -2
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +28 -0
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +2 -6
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +24 -35
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +10 -9
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +10 -12
- package/src/QueueManager.tsx +17 -18
- package/src/{containers/Wallets/Wallets.tsx → Wallets.tsx} +34 -48
- package/src/Widget.tsx +119 -0
- package/src/components/AppRouter.tsx +32 -8
- package/src/components/AppRoutes.tsx +69 -57
- package/src/components/BlockchainList/BlockchainList.styles.ts +2 -2
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.styles.ts +1 -1
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +17 -26
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +10 -29
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +47 -43
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.tsx +8 -9
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
- package/src/components/HeaderButtons/HomeButtons.tsx +18 -28
- package/src/components/Layout/Layout.styles.ts +0 -2
- package/src/components/Layout/Layout.tsx +7 -20
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +61 -65
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +34 -28
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
- package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +16 -23
- package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
- package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +17 -12
- package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
- package/src/components/NoRoutes/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +3 -5
- package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +1 -8
- package/src/components/RouteErrors/RouteErrors.tsx +79 -0
- package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
- package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
- package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +4 -4
- package/src/components/RouteErrors/index.ts +1 -0
- package/src/components/Slippage/Slippage.styles.ts +5 -15
- package/src/components/Slippage/Slippage.tsx +10 -11
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +8 -5
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.styles.ts +33 -36
- package/src/components/SwapDetails/SwapDetails.tsx +56 -41
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +3 -4
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +8 -14
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +1 -10
- package/src/components/SwapsGroup/SwapsGroup.tsx +5 -3
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +38 -74
- package/src/components/TokenList/TokenList.tsx +26 -35
- package/src/components/TokenList/TokenList.types.ts +10 -4
- package/src/components/TokenList/index.ts +1 -0
- package/src/components/UpdateUrl.tsx +30 -35
- package/src/components/WidgetEvents.tsx +2 -4
- package/src/constants/errors.ts +15 -17
- package/src/constants/index.ts +0 -1
- package/src/constants/messages.ts +1 -1
- package/src/constants/navigationRoutes.ts +8 -7
- package/src/constants/searchParams.ts +0 -1
- package/src/constants/warnings.ts +7 -7
- package/src/hooks/useConfirmSwap.ts +303 -0
- package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
- package/src/hooks/useLanguage.ts +5 -4
- package/src/hooks/useNavigateBack.ts +52 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +7 -37
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +0 -60
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +3 -78
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +6 -15
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +1 -6
- package/src/hooks/useSwapInput.ts +48 -141
- package/src/hooks/useSyncStoresWithConfig.ts +24 -40
- package/src/hooks/useTheme.ts +5 -4
- package/src/hooks/useWalletList.ts +5 -3
- package/src/index.ts +5 -53
- package/src/pages/ConfirmSwapPage.tsx +266 -117
- package/src/pages/HistoryPage.tsx +7 -2
- package/src/pages/Home.tsx +303 -88
- package/src/pages/LanguagePage.tsx +5 -0
- package/src/pages/LiquiditySourcePage.tsx +37 -24
- package/src/pages/SelectBlockchainPage.tsx +24 -31
- package/src/pages/SelectSwapItemsPage.tsx +31 -18
- package/src/pages/SettingsPage.tsx +27 -32
- package/src/pages/SwapDetailsPage.tsx +7 -6
- package/src/pages/ThemePage.tsx +7 -2
- package/src/pages/WalletsPage.tsx +19 -9
- package/src/services/httpService.ts +1 -1
- package/src/store/app.ts +6 -44
- package/src/store/{quote.ts → bestRoute.ts} +64 -71
- package/src/store/meta.ts +39 -0
- package/src/store/settings.ts +158 -0
- package/src/store/slices/config.ts +15 -26
- package/src/store/slices/data.ts +35 -74
- package/src/store/wallets.ts +37 -68
- package/src/types/config.ts +8 -53
- package/src/types/index.ts +1 -1
- package/src/types/routing.ts +77 -0
- package/src/types/swap.ts +13 -4
- package/src/types/wallets.ts +1 -18
- package/src/utils/colors.ts +1 -2
- package/src/utils/configs.ts +1 -2
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +1 -8
- package/src/utils/numbers.ts +1 -1
- package/src/utils/providers.ts +5 -8
- package/src/utils/queue.ts +2 -2
- package/src/utils/routing.ts +321 -0
- package/src/utils/settings.ts +10 -17
- package/src/utils/swap.ts +120 -154
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +161 -156
- package/dist/components/NoResult/NoResult.d.ts +0 -4
- package/dist/components/NoResult/NoResult.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
- package/dist/components/NoResult/index.d.ts +0 -2
- package/dist/components/NoResult/index.d.ts.map +0 -1
- package/dist/components/Quote/Quote.d.ts +0 -4
- package/dist/components/Quote/Quote.d.ts.map +0 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -2217
- package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -21
- package/dist/components/Quote/Quote.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.d.ts +0 -11
- package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -315
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
- package/dist/components/Quote/index.d.ts +0 -3
- package/dist/components/Quote/index.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +0 -633
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +0 -6
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +0 -1571
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +0 -6
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +0 -4
- package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +0 -786
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +0 -4
- package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +0 -1
- package/dist/components/QuoteSkeleton/index.d.ts +0 -4
- package/dist/components/QuoteSkeleton/index.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -23
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
- package/dist/containers/App/App.d.ts +0 -3
- package/dist/containers/App/App.d.ts.map +0 -1
- package/dist/containers/App/App.styles.d.ts +0 -158
- package/dist/containers/App/App.styles.d.ts.map +0 -1
- package/dist/containers/App/index.d.ts +0 -2
- package/dist/containers/App/index.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -788
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -20
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/index.d.ts +0 -2
- package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
- package/dist/containers/Wallets/Wallets.d.ts +0 -6
- package/dist/containers/Wallets/Wallets.d.ts.map +0 -1
- package/dist/containers/Wallets/Wallets.types.d.ts +0 -11
- package/dist/containers/Wallets/Wallets.types.d.ts.map +0 -1
- package/dist/containers/Wallets/index.d.ts +0 -2
- package/dist/containers/Wallets/index.d.ts.map +0 -1
- package/dist/containers/Widget/Widget.d.ts +0 -5
- package/dist/containers/Widget/Widget.d.ts.map +0 -1
- package/dist/containers/Widget/Widget.types.d.ts +0 -5
- package/dist/containers/Widget/Widget.types.d.ts.map +0 -1
- package/dist/containers/Widget/index.d.ts +0 -3
- package/dist/containers/Widget/index.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +0 -6
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +0 -20
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +0 -21
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +0 -1
- package/dist/containers/WidgetInfo/index.d.ts +0 -2
- package/dist/containers/WidgetInfo/index.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +0 -5
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +0 -7
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +0 -1
- package/dist/containers/WidgetProvider/index.d.ts +0 -2
- package/dist/containers/WidgetProvider/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
- package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -19
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
- package/dist/hooks/useFetchQuote.d.ts.map +0 -1
- package/dist/hooks/useForceAutoConnect.d.ts +0 -2
- package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
- package/dist/store/AppStore.d.ts +0 -47
- package/dist/store/AppStore.d.ts.map +0 -1
- package/dist/store/quote.d.ts +0 -89
- package/dist/store/quote.d.ts.map +0 -1
- package/dist/store/slices/settings.d.ts +0 -39
- package/dist/store/slices/settings.d.ts.map +0 -1
- package/dist/types/quote.d.ts +0 -82
- package/dist/types/quote.d.ts.map +0 -1
- package/dist/utils/quote.d.ts +0 -32
- package/dist/utils/quote.d.ts.map +0 -1
- package/src/components/NoResult/index.ts +0 -1
- package/src/components/Quote/Quote.styles.ts +0 -249
- package/src/components/Quote/Quote.tsx +0 -414
- package/src/components/Quote/Quote.types.ts +0 -15
- package/src/components/Quote/QuoteSummary.styles.ts +0 -16
- package/src/components/Quote/QuoteSummary.tsx +0 -46
- package/src/components/Quote/index.ts +0 -2
- package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +0 -42
- package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +0 -30
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +0 -5
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +0 -57
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +0 -76
- package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +0 -6
- package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +0 -33
- package/src/components/QuoteSkeleton/StepSkeleton.tsx +0 -44
- package/src/components/QuoteSkeleton/StepSkeleton.types.ts +0 -1
- package/src/components/QuoteSkeleton/index.ts +0 -3
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -74
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -25
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
- package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
- package/src/containers/App/App.styles.ts +0 -18
- package/src/containers/App/App.tsx +0 -52
- package/src/containers/App/index.ts +0 -1
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -31
- package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -99
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -20
- package/src/containers/QuoteInfo/index.ts +0 -1
- package/src/containers/Wallets/Wallets.types.ts +0 -12
- package/src/containers/Wallets/index.ts +0 -1
- package/src/containers/Widget/Widget.tsx +0 -19
- package/src/containers/Widget/Widget.types.ts +0 -5
- package/src/containers/Widget/index.ts +0 -2
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +0 -64
- package/src/containers/WidgetInfo/WidgetInfo.tsx +0 -62
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +0 -21
- package/src/containers/WidgetInfo/index.ts +0 -1
- package/src/containers/WidgetProvider/WidgetProvider.tsx +0 -28
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +0 -7
- package/src/containers/WidgetProvider/index.ts +0 -1
- package/src/hooks/useConfirmSwap/index.ts +0 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -172
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -137
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
- package/src/hooks/useForceAutoConnect.ts +0 -27
- package/src/store/AppStore.tsx +0 -41
- package/src/store/slices/settings.ts +0 -168
- package/src/types/quote.ts +0 -107
- package/src/utils/quote.ts +0 -338
package/src/utils/swap.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoadingStatus } from '../store/meta';
|
|
3
|
+
import type { ConnectedWallet } from '../store/wallets';
|
|
4
|
+
import type { ConvertedToken, SwapButtonState, Wallet } from '../types';
|
|
3
5
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
RecommendedSlippages,
|
|
8
|
-
SwapButtonState,
|
|
9
|
-
Wallet,
|
|
10
|
-
} from '../types';
|
|
6
|
+
PendingSwap,
|
|
7
|
+
PendingSwapStep,
|
|
8
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
11
9
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
12
10
|
import type {
|
|
13
11
|
BestRouteRequest,
|
|
@@ -17,11 +15,10 @@ import type {
|
|
|
17
15
|
SwapResult,
|
|
18
16
|
Token,
|
|
19
17
|
} from 'rango-sdk';
|
|
20
|
-
import type { PendingSwap, PendingSwapStep } from 'rango-types';
|
|
21
18
|
|
|
22
19
|
import { i18n } from '@lingui/core';
|
|
20
|
+
import { PendingSwapNetworkStatus } from '@rango-dev/queue-manager-rango-preset';
|
|
23
21
|
import BigNumber from 'bignumber.js';
|
|
24
|
-
import { PendingSwapNetworkStatus } from 'rango-types';
|
|
25
22
|
|
|
26
23
|
import { isValidAddress } from '../components/ConfirmWalletsModal/ConfirmWallets.helpers';
|
|
27
24
|
import { errorMessages } from '../constants/errors';
|
|
@@ -33,11 +30,12 @@ import {
|
|
|
33
30
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
34
31
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
35
32
|
} from '../constants/routing';
|
|
33
|
+
import { useMetaStore } from '../store/meta';
|
|
34
|
+
import { ButtonState } from '../types';
|
|
36
35
|
|
|
37
36
|
import { removeDuplicateFrom } from './common';
|
|
38
|
-
import { getBlockchainShortNameFor } from './meta';
|
|
39
37
|
import { numberToString } from './numbers';
|
|
40
|
-
import {
|
|
38
|
+
import { getRequiredBalanceOfWallet } from './routing';
|
|
41
39
|
import { getRequiredChains } from './wallets';
|
|
42
40
|
|
|
43
41
|
export function getOutputRatio(
|
|
@@ -52,29 +50,25 @@ export function getOutputRatio(
|
|
|
52
50
|
) {
|
|
53
51
|
return 0;
|
|
54
52
|
}
|
|
55
|
-
return outputUsdValue
|
|
56
|
-
.div(inputUsdValue)
|
|
57
|
-
.minus(1)
|
|
58
|
-
.multipliedBy(100)
|
|
59
|
-
.toNumber();
|
|
53
|
+
return outputUsdValue.div(inputUsdValue).minus(1).multipliedBy(100);
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
export function
|
|
56
|
+
export function outputRatioHasWarning(
|
|
63
57
|
inputUsdValue: BigNumber | null,
|
|
64
|
-
|
|
58
|
+
outputRatio: BigNumber | 0
|
|
65
59
|
): boolean {
|
|
66
60
|
return (
|
|
67
|
-
((parseInt(
|
|
61
|
+
((parseInt(outputRatio.toFixed(2) || '0') <= -10 &&
|
|
68
62
|
inputUsdValue?.gte(new BigNumber(400))) ||
|
|
69
|
-
(parseInt(
|
|
63
|
+
(parseInt(outputRatio.toFixed(2) || '0') <= -5 &&
|
|
70
64
|
inputUsdValue?.gte(new BigNumber(1000)))) ??
|
|
71
65
|
false
|
|
72
66
|
);
|
|
73
67
|
}
|
|
74
68
|
|
|
75
|
-
export function hasLimitError(
|
|
69
|
+
export function hasLimitError(bestRoute: BestRouteResponse | null): boolean {
|
|
76
70
|
return (
|
|
77
|
-
(
|
|
71
|
+
(bestRoute?.result?.swaps || []).filter((swap) => {
|
|
78
72
|
const minimum = !!swap.fromAmountMinValue
|
|
79
73
|
? new BigNumber(swap.fromAmountMinValue)
|
|
80
74
|
: null;
|
|
@@ -89,12 +83,16 @@ export function hasLimitError(quote: BestRouteResponse | null): boolean {
|
|
|
89
83
|
}).length > 0
|
|
90
84
|
);
|
|
91
85
|
}
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
|
|
87
|
+
export function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
|
|
88
|
+
swap: SwapResult | null;
|
|
94
89
|
fromAmountRangeError: string;
|
|
95
90
|
recommendation: string;
|
|
96
91
|
} {
|
|
97
|
-
|
|
92
|
+
if (!bestRoute) {
|
|
93
|
+
return { swap: null, fromAmountRangeError: '', recommendation: '' };
|
|
94
|
+
}
|
|
95
|
+
const swap = (bestRoute?.result?.swaps || []).filter((swap) => {
|
|
98
96
|
const minimum = !!swap.fromAmountMinValue
|
|
99
97
|
? new BigNumber(swap.fromAmountMinValue)
|
|
100
98
|
: null;
|
|
@@ -107,7 +105,9 @@ export function getLimitErrorMessage(quote: BestRouteResponse): {
|
|
|
107
105
|
}
|
|
108
106
|
return minimum?.gt(swap.fromAmount) || maximum?.lt(swap.fromAmount);
|
|
109
107
|
})[0];
|
|
110
|
-
|
|
108
|
+
if (!swap) {
|
|
109
|
+
return { swap: null, fromAmountRangeError: '', recommendation: '' };
|
|
110
|
+
}
|
|
111
111
|
const minimum = !!swap.fromAmountMinValue
|
|
112
112
|
? new BigNumber(swap.fromAmountMinValue)
|
|
113
113
|
: null;
|
|
@@ -177,92 +177,85 @@ export function getLimitErrorMessage(quote: BestRouteResponse): {
|
|
|
177
177
|
return { swap, fromAmountRangeError, recommendation };
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
export function getSwapButtonState(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
needsToWarnEthOnPath: boolean
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
anyWalletConnected,
|
|
193
|
-
fetchingQuote,
|
|
194
|
-
inputAmount,
|
|
195
|
-
quote,
|
|
196
|
-
warning,
|
|
197
|
-
error,
|
|
198
|
-
needsToWarnEthOnPath,
|
|
199
|
-
} = params;
|
|
200
|
-
if (fetchMetaStatus !== 'success') {
|
|
180
|
+
export function getSwapButtonState(
|
|
181
|
+
loadingMetaStatus: LoadingStatus,
|
|
182
|
+
connectedWallets: ConnectedWallet[],
|
|
183
|
+
loading: boolean,
|
|
184
|
+
bestRoute: BestRouteResponse | null,
|
|
185
|
+
hasLimitError: boolean,
|
|
186
|
+
highValueLoss: boolean,
|
|
187
|
+
priceImpactCanNotBeComputed: boolean,
|
|
188
|
+
needsToWarnEthOnPath: boolean,
|
|
189
|
+
inputAmount: string
|
|
190
|
+
): SwapButtonState {
|
|
191
|
+
if (loadingMetaStatus !== 'success') {
|
|
201
192
|
return {
|
|
202
193
|
title: swapButtonTitles().connectWallet,
|
|
203
|
-
|
|
194
|
+
state: ButtonState.WAITFORCONNECTING,
|
|
204
195
|
disabled: true,
|
|
205
196
|
};
|
|
206
197
|
}
|
|
207
|
-
if (
|
|
198
|
+
if (connectedWallets.length == 0) {
|
|
208
199
|
return {
|
|
209
200
|
title: swapButtonTitles().connectWallet,
|
|
210
|
-
|
|
201
|
+
state: ButtonState.WAITFORCONNECTING,
|
|
211
202
|
disabled: false,
|
|
212
203
|
};
|
|
213
204
|
}
|
|
214
205
|
if (
|
|
215
|
-
|
|
216
|
-
!
|
|
217
|
-
!
|
|
218
|
-
|
|
206
|
+
loading ||
|
|
207
|
+
!bestRoute ||
|
|
208
|
+
!bestRoute.result ||
|
|
209
|
+
hasLimitError ||
|
|
219
210
|
!inputAmount ||
|
|
220
211
|
inputAmount === '0'
|
|
221
212
|
) {
|
|
222
213
|
return {
|
|
223
214
|
title: swapButtonTitles().swap,
|
|
224
|
-
action: 'confirm-swap',
|
|
225
215
|
disabled: true,
|
|
216
|
+
state: ButtonState.SWAP,
|
|
226
217
|
};
|
|
227
|
-
} else if (
|
|
218
|
+
} else if (highValueLoss || priceImpactCanNotBeComputed) {
|
|
228
219
|
return {
|
|
229
220
|
title: swapButtonTitles().swapAnyway,
|
|
230
|
-
action: 'confirm-warning',
|
|
231
221
|
disabled: false,
|
|
222
|
+
hasWarning: true,
|
|
223
|
+
state: ButtonState.NEEDTOCONFIRM,
|
|
232
224
|
};
|
|
233
225
|
} else if (needsToWarnEthOnPath) {
|
|
234
226
|
return {
|
|
235
|
-
title: swapButtonTitles().
|
|
236
|
-
action: 'confirm-warning',
|
|
227
|
+
title: swapButtonTitles().ethRouteWarning,
|
|
237
228
|
disabled: false,
|
|
229
|
+
hasWarning: true,
|
|
230
|
+
state: ButtonState.WARNING,
|
|
238
231
|
};
|
|
239
232
|
}
|
|
240
233
|
return {
|
|
241
234
|
title: swapButtonTitles().swap,
|
|
242
|
-
action: 'confirm-swap',
|
|
243
235
|
disabled: false,
|
|
236
|
+
state: ButtonState.SWAP,
|
|
244
237
|
};
|
|
245
238
|
}
|
|
246
239
|
|
|
247
240
|
export function canComputePriceImpact(
|
|
248
|
-
|
|
241
|
+
bestRoute: BestRouteResponse | null,
|
|
249
242
|
inputAmount: string,
|
|
250
243
|
usdValue: BigNumber | null
|
|
251
244
|
) {
|
|
252
245
|
return !(
|
|
253
246
|
(!usdValue || usdValue.lte(ZERO)) &&
|
|
254
|
-
!!
|
|
247
|
+
!!bestRoute?.result &&
|
|
255
248
|
!!inputAmount &&
|
|
256
249
|
inputAmount !== '0' &&
|
|
257
250
|
parseFloat(inputAmount || '0') !== 0 &&
|
|
258
|
-
!!
|
|
251
|
+
!!bestRoute.result
|
|
259
252
|
);
|
|
260
253
|
}
|
|
261
254
|
|
|
262
|
-
export function requiredWallets(
|
|
255
|
+
export function requiredWallets(route: BestRouteResponse | null) {
|
|
263
256
|
const wallets: string[] = [];
|
|
264
257
|
|
|
265
|
-
|
|
258
|
+
route?.result?.swaps.forEach((swap) => {
|
|
266
259
|
const currentStepFromBlockchain = swap.from.blockchain;
|
|
267
260
|
const currentStepToBlockchain = swap.to.blockchain;
|
|
268
261
|
let lastAddedWallet = wallets[wallets.length - 1];
|
|
@@ -318,13 +311,15 @@ export function getUsdFeeOfStep(
|
|
|
318
311
|
}
|
|
319
312
|
|
|
320
313
|
export function getTotalFeeInUsd(
|
|
321
|
-
|
|
314
|
+
bestRoute: BestRouteResponse | null,
|
|
322
315
|
allTokens: Token[]
|
|
323
|
-
): BigNumber {
|
|
324
|
-
return
|
|
325
|
-
(
|
|
326
|
-
totalFee
|
|
327
|
-
|
|
316
|
+
): BigNumber | null {
|
|
317
|
+
return (
|
|
318
|
+
bestRoute?.result?.swaps.reduce(
|
|
319
|
+
(totalFee: BigNumber, step) =>
|
|
320
|
+
totalFee.plus(getUsdFeeOfStep(step, allTokens)),
|
|
321
|
+
ZERO
|
|
322
|
+
) || null
|
|
328
323
|
);
|
|
329
324
|
}
|
|
330
325
|
|
|
@@ -341,44 +336,10 @@ export function hasSlippageError(
|
|
|
341
336
|
return (slippages?.filter((s) => !!s?.error)?.length || 0) > 0;
|
|
342
337
|
}
|
|
343
338
|
|
|
344
|
-
export function checkSlippageErrors(
|
|
345
|
-
quote: BestRouteResponse
|
|
346
|
-
): RecommendedSlippages | null {
|
|
347
|
-
const recommendedSlippages: RecommendedSlippages = new Map();
|
|
348
|
-
quote.result?.swaps.forEach((swap, index) => {
|
|
349
|
-
if (swap.recommendedSlippage?.error) {
|
|
350
|
-
recommendedSlippages.set(index, swap.recommendedSlippage.slippage);
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
if (recommendedSlippages.size > 0) {
|
|
354
|
-
return recommendedSlippages;
|
|
355
|
-
}
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export function checkSlippageWarnings(
|
|
360
|
-
quote: BestRouteResponse,
|
|
361
|
-
userSlippage: number
|
|
362
|
-
): RecommendedSlippages | null {
|
|
363
|
-
const recommendedSlippages: RecommendedSlippages = new Map();
|
|
364
|
-
quote.result?.swaps.forEach((swap, index) => {
|
|
365
|
-
if (
|
|
366
|
-
swap.recommendedSlippage?.slippage &&
|
|
367
|
-
parseFloat(swap.recommendedSlippage.slippage) > userSlippage
|
|
368
|
-
) {
|
|
369
|
-
recommendedSlippages.set(index, swap.recommendedSlippage.slippage);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
if (recommendedSlippages.size > 0) {
|
|
373
|
-
return recommendedSlippages;
|
|
374
|
-
}
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
339
|
export function getMinRequiredSlippage(
|
|
379
|
-
|
|
340
|
+
route: BestRouteResponse
|
|
380
341
|
): string | null {
|
|
381
|
-
const slippages =
|
|
342
|
+
const slippages = route.result?.swaps.map(
|
|
382
343
|
(slippage) => slippage.recommendedSlippage
|
|
383
344
|
);
|
|
384
345
|
return (
|
|
@@ -401,10 +362,10 @@ export function hasProperSlippage(
|
|
|
401
362
|
}
|
|
402
363
|
|
|
403
364
|
export function hasEnoughBalance(
|
|
404
|
-
|
|
365
|
+
route: BestRouteResponse,
|
|
405
366
|
selectedWallets: Wallet[]
|
|
406
367
|
) {
|
|
407
|
-
const fee =
|
|
368
|
+
const fee = route.validationStatus;
|
|
408
369
|
|
|
409
370
|
if (fee === null || fee.length === 0) {
|
|
410
371
|
return true;
|
|
@@ -428,31 +389,29 @@ export function hasEnoughBalance(
|
|
|
428
389
|
}
|
|
429
390
|
|
|
430
391
|
export function hasEnoughBalanceAndProperSlippage(
|
|
431
|
-
|
|
392
|
+
route: BestRouteResponse,
|
|
432
393
|
selectedWallets: Wallet[],
|
|
433
394
|
userSlippage: string,
|
|
434
395
|
minRequiredSlippage: string | null
|
|
435
396
|
): boolean {
|
|
436
397
|
return (
|
|
437
|
-
hasEnoughBalance(
|
|
398
|
+
hasEnoughBalance(route, selectedWallets) &&
|
|
438
399
|
hasProperSlippage(userSlippage, minRequiredSlippage)
|
|
439
400
|
);
|
|
440
401
|
}
|
|
441
402
|
|
|
442
|
-
export function
|
|
403
|
+
export function createBestRouteRequestBody(params: {
|
|
443
404
|
fromToken: Token;
|
|
444
405
|
toToken: Token;
|
|
445
406
|
inputAmount: string;
|
|
446
407
|
wallets?: Wallet[];
|
|
447
408
|
selectedWallets?: Wallet[];
|
|
448
|
-
liquiditySources?: string[];
|
|
449
|
-
excludeLiquiditySources?: boolean;
|
|
450
409
|
disabledLiquiditySources: string[];
|
|
451
410
|
slippage: number;
|
|
452
411
|
affiliateRef: string | null;
|
|
453
412
|
affiliatePercent: number | null;
|
|
454
413
|
affiliateWallets: { [key: string]: string } | null;
|
|
455
|
-
|
|
414
|
+
initialRoute?: BestRouteResponse;
|
|
456
415
|
destination?: string;
|
|
457
416
|
}): BestRouteRequest {
|
|
458
417
|
const {
|
|
@@ -462,13 +421,11 @@ export function createQuoteRequestBody(params: {
|
|
|
462
421
|
wallets,
|
|
463
422
|
selectedWallets,
|
|
464
423
|
disabledLiquiditySources,
|
|
465
|
-
liquiditySources,
|
|
466
|
-
excludeLiquiditySources,
|
|
467
424
|
slippage,
|
|
468
425
|
affiliateRef,
|
|
469
426
|
affiliatePercent,
|
|
470
427
|
affiliateWallets,
|
|
471
|
-
|
|
428
|
+
initialRoute,
|
|
472
429
|
destination,
|
|
473
430
|
} = params;
|
|
474
431
|
const selectedWalletsMap = selectedWallets?.reduce(
|
|
@@ -498,10 +455,10 @@ export function createQuoteRequestBody(params: {
|
|
|
498
455
|
}
|
|
499
456
|
});
|
|
500
457
|
|
|
501
|
-
const checkPrerequisites = !!
|
|
458
|
+
const checkPrerequisites = !!initialRoute;
|
|
502
459
|
|
|
503
460
|
const filteredBlockchains = removeDuplicateFrom(
|
|
504
|
-
(
|
|
461
|
+
(initialRoute?.result?.swaps || []).reduce(
|
|
505
462
|
(blockchains: string[], swap) => {
|
|
506
463
|
blockchains.push(swap.from.blockchain, swap.to.blockchain);
|
|
507
464
|
// Check if internalSwaps array exists
|
|
@@ -539,18 +496,13 @@ export function createQuoteRequestBody(params: {
|
|
|
539
496
|
selectedWallets: selectedWalletsMap ?? {},
|
|
540
497
|
slippage: slippage.toString(),
|
|
541
498
|
...(destination && { destination: destination }),
|
|
542
|
-
...(
|
|
543
|
-
swapperGroups: disabledLiquiditySources
|
|
499
|
+
...(disabledLiquiditySources.length > 0 && {
|
|
500
|
+
swapperGroups: disabledLiquiditySources,
|
|
544
501
|
swappersGroupsExclude: true,
|
|
545
502
|
}),
|
|
546
|
-
...(!excludeLiquiditySources && {
|
|
547
|
-
swapperGroups: liquiditySources?.filter(
|
|
548
|
-
(liquiditySource) => !disabledLiquiditySources.includes(liquiditySource)
|
|
549
|
-
),
|
|
550
|
-
swappersGroupsExclude: false,
|
|
551
|
-
}),
|
|
552
503
|
...(checkPrerequisites && { blockchains: filteredBlockchains }),
|
|
553
504
|
};
|
|
505
|
+
|
|
554
506
|
return requestBody;
|
|
555
507
|
}
|
|
556
508
|
|
|
@@ -574,42 +526,49 @@ export function getWalletsForNewSwap(selectedWallets: Wallet[]) {
|
|
|
574
526
|
return wallets;
|
|
575
527
|
}
|
|
576
528
|
|
|
577
|
-
export function
|
|
578
|
-
return
|
|
529
|
+
export function getRouteOutputAmount(route: BestRouteResponse | null) {
|
|
530
|
+
return route?.result?.outputAmount || null;
|
|
579
531
|
}
|
|
580
532
|
|
|
581
|
-
export function getPercentageChange(
|
|
582
|
-
|
|
583
|
-
|
|
533
|
+
export function getPercentageChange(
|
|
534
|
+
inputUsdValue: string | number | null,
|
|
535
|
+
outputUsdValue: string | number | null
|
|
536
|
+
) {
|
|
537
|
+
if (!inputUsdValue || !outputUsdValue) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
return new BigNumber(outputUsdValue)
|
|
541
|
+
.div(new BigNumber(inputUsdValue))
|
|
584
542
|
.minus(1)
|
|
585
|
-
.multipliedBy(100)
|
|
586
|
-
.toNumber();
|
|
543
|
+
.multipliedBy(100);
|
|
587
544
|
}
|
|
588
545
|
|
|
589
546
|
export function isOutputAmountChangedALot(
|
|
590
|
-
|
|
591
|
-
|
|
547
|
+
oldRoute: BestRouteResponse,
|
|
548
|
+
newRoute: BestRouteResponse
|
|
592
549
|
) {
|
|
593
|
-
const oldOutputAmount =
|
|
594
|
-
const newOutputAmount =
|
|
550
|
+
const oldOutputAmount = getRouteOutputAmount(oldRoute);
|
|
551
|
+
const newOutputAmount = getRouteOutputAmount(newRoute);
|
|
595
552
|
if (!oldOutputAmount || !newOutputAmount) {
|
|
596
553
|
return false;
|
|
597
554
|
}
|
|
598
|
-
const percentageChange =
|
|
555
|
+
const percentageChange = getPercentageChange(
|
|
556
|
+
oldOutputAmount,
|
|
557
|
+
newOutputAmount
|
|
558
|
+
);
|
|
599
559
|
if (!percentageChange) {
|
|
600
560
|
return true;
|
|
601
561
|
}
|
|
602
562
|
|
|
603
|
-
return percentageChange <= -1;
|
|
563
|
+
return percentageChange.toNumber() <= -1;
|
|
604
564
|
}
|
|
605
565
|
|
|
606
|
-
export function
|
|
607
|
-
|
|
608
|
-
selectedWallets: Wallet[]
|
|
609
|
-
blockchains: BlockchainMeta[]
|
|
566
|
+
export function getBalanceWarnings(
|
|
567
|
+
route: BestRouteResponse,
|
|
568
|
+
selectedWallets: Wallet[]
|
|
610
569
|
) {
|
|
611
|
-
const fee =
|
|
612
|
-
const requiredWallets = getRequiredChains(
|
|
570
|
+
const fee = route.validationStatus;
|
|
571
|
+
const requiredWallets = getRequiredChains(route);
|
|
613
572
|
const walletsSortedByRequiredWallets = selectedWallets.sort(
|
|
614
573
|
(selectedWallet1, selectedWallet2) =>
|
|
615
574
|
requiredWallets.indexOf(selectedWallet1.chain) -
|
|
@@ -651,10 +610,7 @@ export function generateBalanceWarnings(
|
|
|
651
610
|
symbol,
|
|
652
611
|
reason,
|
|
653
612
|
currentAmount,
|
|
654
|
-
blockchain:
|
|
655
|
-
asset.asset.blockchain,
|
|
656
|
-
blockchains
|
|
657
|
-
),
|
|
613
|
+
blockchain: asset.asset.blockchain,
|
|
658
614
|
},
|
|
659
615
|
});
|
|
660
616
|
return warningMessage;
|
|
@@ -758,19 +714,29 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
|
|
|
758
714
|
new Date().getTime() - parseInt(pendingSwap.finishTime) < 4 * 3600 * 1000
|
|
759
715
|
);
|
|
760
716
|
}
|
|
717
|
+
export function isValidCustomDestination(
|
|
718
|
+
blockchain: string,
|
|
719
|
+
address: string
|
|
720
|
+
): boolean {
|
|
721
|
+
const blockchains = useMetaStore.getState().meta.blockchains;
|
|
722
|
+
const regex =
|
|
723
|
+
blockchains.find((chain) => chain.name === blockchain)?.addressPatterns ||
|
|
724
|
+
[];
|
|
725
|
+
return regex.filter((r) => new RegExp(r).test(address)).length > 0;
|
|
726
|
+
}
|
|
761
727
|
|
|
762
728
|
export function confirmSwapDisabled(
|
|
763
729
|
fetching: boolean,
|
|
764
730
|
showCustomDestination: boolean,
|
|
765
731
|
customDestination: string,
|
|
766
|
-
|
|
732
|
+
bestRoute: BestRouteResponse | null,
|
|
767
733
|
selectedWallets: { walletType: string; chain: string }[],
|
|
768
734
|
lastStepToBlockchain?: BlockchainMeta
|
|
769
735
|
) {
|
|
770
736
|
return (
|
|
771
737
|
fetching ||
|
|
772
738
|
(!showCustomDestination &&
|
|
773
|
-
!requiredWallets(
|
|
739
|
+
!requiredWallets(bestRoute).every((chain) =>
|
|
774
740
|
selectedWallets.map((wallet) => wallet.chain).includes(chain)
|
|
775
741
|
)) ||
|
|
776
742
|
(!!showCustomDestination && !customDestination) ||
|
package/src/utils/time.ts
CHANGED