@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/providers.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
|
-
import type { ProviderInterface } from '@rango-dev/wallets-react';
|
|
3
|
-
|
|
4
1
|
import { allProviders } from '@rango-dev/provider-all';
|
|
2
|
+
import { ProviderInterface } from '@rango-dev/wallets-react';
|
|
3
|
+
import { WidgetConfig } from '../types';
|
|
5
4
|
|
|
6
5
|
export interface ProvidersOptions {
|
|
7
6
|
walletConnectProjectId?: WidgetConfig['walletConnectProjectId'];
|
|
@@ -27,11 +26,9 @@ export function matchAndGenerateProviders(
|
|
|
27
26
|
const selectedProviders: ProviderInterface[] = [];
|
|
28
27
|
|
|
29
28
|
providers.forEach((requestedProvider) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* The second way is passing a custom provider which implemented ProviderInterface.
|
|
34
|
-
*/
|
|
29
|
+
// There are two types of provider we get, the first one is only passing the wallet name
|
|
30
|
+
// then we will match the wallet name with our providers (@rango-dev/provider-*).
|
|
31
|
+
// The second way is passing a custom provider which implemented ProviderInterface.
|
|
35
32
|
if (typeof requestedProvider === 'string') {
|
|
36
33
|
const result: ProviderInterface | undefined = all.find((provider) => {
|
|
37
34
|
return provider.config.type === requestedProvider;
|
package/src/utils/queue.ts
CHANGED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
+
import type { BestRouteEqualityParams, Wallet } from '../types';
|
|
3
|
+
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
4
|
+
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
5
|
+
import type {
|
|
6
|
+
SimulationAssetAndAmount,
|
|
7
|
+
SimulationValidationStatus,
|
|
8
|
+
} from '@rango-dev/ui/dist/widget/ui/src/types/swaps';
|
|
9
|
+
import type {
|
|
10
|
+
Asset,
|
|
11
|
+
BestRouteResponse,
|
|
12
|
+
BlockchainMeta,
|
|
13
|
+
Token,
|
|
14
|
+
} from 'rango-sdk';
|
|
15
|
+
|
|
16
|
+
import { getLastSuccessfulStep } from '@rango-dev/queue-manager-rango-preset';
|
|
17
|
+
import BigNumber from 'bignumber.js';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
GAS_FEE_MAX_DECIMALS,
|
|
21
|
+
GAS_FEE_MIN_DECIMALS,
|
|
22
|
+
HIGHT_PRICE_IMPACT,
|
|
23
|
+
LOW_PRICE_IMPACT,
|
|
24
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
25
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
26
|
+
} from '../constants/routing';
|
|
27
|
+
|
|
28
|
+
import { areEqual } from './common';
|
|
29
|
+
import { findBlockchain, findToken } from './meta';
|
|
30
|
+
import { numberToString } from './numbers';
|
|
31
|
+
|
|
32
|
+
export function searchParamsToToken(
|
|
33
|
+
tokens: Token[],
|
|
34
|
+
searchParams: string | null,
|
|
35
|
+
chain: BlockchainMeta | null
|
|
36
|
+
): Token | null {
|
|
37
|
+
if (!chain) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return (
|
|
41
|
+
tokens.find((token) => {
|
|
42
|
+
const symbolAndAddress = searchParams?.split('--');
|
|
43
|
+
if (symbolAndAddress?.length === 1) {
|
|
44
|
+
return (
|
|
45
|
+
token.symbol === symbolAndAddress[0] &&
|
|
46
|
+
token.address === null &&
|
|
47
|
+
token.blockchain === chain.name
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return (
|
|
51
|
+
token.symbol === symbolAndAddress?.[0] &&
|
|
52
|
+
token.address === symbolAndAddress?.[1] &&
|
|
53
|
+
token.blockchain === chain.name
|
|
54
|
+
);
|
|
55
|
+
}) || null
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getBestRouteToTokenUsdPrice(
|
|
60
|
+
bestRoute: BestRouteResponse | null
|
|
61
|
+
): number | null | undefined {
|
|
62
|
+
return bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to
|
|
63
|
+
.usdPrice;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function isNumberOfSwapsChanged(
|
|
67
|
+
route1: BestRouteResponse,
|
|
68
|
+
route2: BestRouteResponse
|
|
69
|
+
) {
|
|
70
|
+
const route1Swaps = route1.result?.swaps || [];
|
|
71
|
+
const route2Swaps = route2.result?.swaps || [];
|
|
72
|
+
return route1Swaps.length !== route2Swaps.length;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function isRouteSwappersUpdated(
|
|
76
|
+
route1: BestRouteResponse,
|
|
77
|
+
route2: BestRouteResponse
|
|
78
|
+
) {
|
|
79
|
+
const route1Swappers =
|
|
80
|
+
route1.result?.swaps.map((swap) => swap.swapperId) || [];
|
|
81
|
+
const route2Swappers =
|
|
82
|
+
route2.result?.swaps.map((swap) => swap.swapperId) || [];
|
|
83
|
+
return !areEqual(route1Swappers, route2Swappers);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function isRouteInternalCoinsUpdated(
|
|
87
|
+
route1: BestRouteResponse,
|
|
88
|
+
route2: BestRouteResponse
|
|
89
|
+
) {
|
|
90
|
+
const route1InternalCoins =
|
|
91
|
+
route1.result?.swaps.map((swap) => swap.to.symbol) || [];
|
|
92
|
+
const route2InternalCoins =
|
|
93
|
+
route2.result?.swaps.map((swap) => swap.to.symbol) || [];
|
|
94
|
+
return !areEqual(route1InternalCoins, route2InternalCoins);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function isRouteChanged(
|
|
98
|
+
route1: BestRouteResponse,
|
|
99
|
+
route2: BestRouteResponse
|
|
100
|
+
): boolean {
|
|
101
|
+
return (
|
|
102
|
+
isNumberOfSwapsChanged(route1, route2) ||
|
|
103
|
+
isRouteSwappersUpdated(route1, route2) ||
|
|
104
|
+
isRouteInternalCoinsUpdated(route1, route2)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function outToRatioHasWarning(
|
|
109
|
+
fromUsdValue: BigNumber | null,
|
|
110
|
+
outToInRatio: BigNumber | 0
|
|
111
|
+
) {
|
|
112
|
+
return (
|
|
113
|
+
(parseInt(outToInRatio?.toFixed(2) || '0') <= -10 &&
|
|
114
|
+
(fromUsdValue === null || fromUsdValue.gte(new BigNumber(200)))) ||
|
|
115
|
+
(parseInt(outToInRatio?.toFixed(2) || '0') <= -5 &&
|
|
116
|
+
(fromUsdValue === null || fromUsdValue.gte(new BigNumber(1000))))
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function getRequiredBalanceOfWallet(
|
|
121
|
+
selectedWallet: Wallet,
|
|
122
|
+
fee: SimulationValidationStatus[] | null
|
|
123
|
+
): SimulationAssetAndAmount[] | null {
|
|
124
|
+
if (fee === null) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const relatedFeeStatus = fee
|
|
128
|
+
?.find((item) => item.blockchain === selectedWallet.chain)
|
|
129
|
+
?.wallets.find(
|
|
130
|
+
(wallet) =>
|
|
131
|
+
wallet.address?.toLowerCase() === selectedWallet.address.toLowerCase()
|
|
132
|
+
);
|
|
133
|
+
if (!relatedFeeStatus) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return relatedFeeStatus.requiredAssets;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function isRouteParametersChanged(params: BestRouteEqualityParams) {
|
|
140
|
+
if (params.store === 'bestRoute') {
|
|
141
|
+
const { prevState, currentState } = params;
|
|
142
|
+
return (
|
|
143
|
+
!!currentState.fromToken &&
|
|
144
|
+
!!currentState.toToken &&
|
|
145
|
+
(prevState.fromBlockchain?.name !== currentState.fromBlockchain?.name ||
|
|
146
|
+
prevState.toBlockchain?.name !== currentState.toBlockchain?.name ||
|
|
147
|
+
prevState.fromToken?.symbol !== currentState.fromToken?.symbol ||
|
|
148
|
+
prevState.toToken?.symbol !== currentState.toToken?.symbol ||
|
|
149
|
+
prevState.fromToken?.blockchain !== prevState.fromToken?.blockchain ||
|
|
150
|
+
prevState.toToken?.blockchain !== currentState.toToken?.blockchain ||
|
|
151
|
+
prevState.fromToken?.address !== currentState.fromToken?.address ||
|
|
152
|
+
prevState.toToken?.address !== currentState.toToken?.address ||
|
|
153
|
+
prevState.inputAmount !== currentState.inputAmount)
|
|
154
|
+
);
|
|
155
|
+
} else if (params.store === 'settings') {
|
|
156
|
+
const { prevState, currentState } = params;
|
|
157
|
+
return (
|
|
158
|
+
prevState.slippage !== currentState.slippage ||
|
|
159
|
+
prevState.customSlippage !== currentState.customSlippage ||
|
|
160
|
+
prevState.disabledLiquiditySources?.length !==
|
|
161
|
+
currentState.disabledLiquiditySources?.length ||
|
|
162
|
+
prevState.infiniteApprove ||
|
|
163
|
+
currentState.infiniteApprove
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function getFormattedBestRoute(
|
|
170
|
+
bestRoute: BestRouteResponse | null
|
|
171
|
+
): BestRouteResponse | null {
|
|
172
|
+
if (!bestRoute) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const formattedSwaps = (bestRoute.result?.swaps || []).map((swap) => ({
|
|
177
|
+
...swap,
|
|
178
|
+
fromAmount: numberToString(
|
|
179
|
+
swap.fromAmount,
|
|
180
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
181
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
182
|
+
),
|
|
183
|
+
toAmount: numberToString(
|
|
184
|
+
swap.toAmount,
|
|
185
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
186
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
187
|
+
),
|
|
188
|
+
}));
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
...bestRoute,
|
|
192
|
+
...(bestRoute.result && {
|
|
193
|
+
result: { ...bestRoute.result, swaps: formattedSwaps },
|
|
194
|
+
}),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function getFormattedPendingSwap(pendingSwap: PendingSwap): PendingSwap {
|
|
199
|
+
const formattedSteps = pendingSwap.steps.map((step) => ({
|
|
200
|
+
...step,
|
|
201
|
+
feeInUsd: numberToString(
|
|
202
|
+
step.feeInUsd,
|
|
203
|
+
GAS_FEE_MIN_DECIMALS,
|
|
204
|
+
GAS_FEE_MAX_DECIMALS
|
|
205
|
+
),
|
|
206
|
+
outputAmount: numberToString(
|
|
207
|
+
step.outputAmount,
|
|
208
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
209
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
210
|
+
),
|
|
211
|
+
expectedOutputAmountHumanReadable: numberToString(
|
|
212
|
+
step.expectedOutputAmountHumanReadable,
|
|
213
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
214
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
215
|
+
),
|
|
216
|
+
}));
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
...pendingSwap,
|
|
220
|
+
inputAmount: numberToString(
|
|
221
|
+
pendingSwap.inputAmount,
|
|
222
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
223
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
224
|
+
),
|
|
225
|
+
steps: formattedSteps,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//todo: refactor bestRoute store and add loadingStatus
|
|
230
|
+
export const getBestRouteStatus = (loading: boolean, error: boolean) => {
|
|
231
|
+
if (loading) {
|
|
232
|
+
return 'loading';
|
|
233
|
+
}
|
|
234
|
+
if (error) {
|
|
235
|
+
return 'failed';
|
|
236
|
+
}
|
|
237
|
+
return 'success';
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export function getPriceImpactLevel(
|
|
241
|
+
priceImpact: number
|
|
242
|
+
): PriceImpactWarningLevel {
|
|
243
|
+
let warningLevel: PriceImpactWarningLevel = undefined;
|
|
244
|
+
if (priceImpact <= LOW_PRICE_IMPACT && priceImpact > HIGHT_PRICE_IMPACT) {
|
|
245
|
+
warningLevel = 'low';
|
|
246
|
+
} else if (priceImpact <= HIGHT_PRICE_IMPACT) {
|
|
247
|
+
warningLevel = 'high';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return warningLevel;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function findCommonTokens<T extends Asset[], R extends Asset[]>(
|
|
254
|
+
listA: T,
|
|
255
|
+
listB: R
|
|
256
|
+
) {
|
|
257
|
+
const tokenToString = (token: Asset): string =>
|
|
258
|
+
`${token.symbol}-${token.blockchain}-${token.address ?? ''}`;
|
|
259
|
+
|
|
260
|
+
const set = new Set();
|
|
261
|
+
|
|
262
|
+
listA.forEach((token) => set.add(tokenToString(token)));
|
|
263
|
+
|
|
264
|
+
return listB.filter((token) => set.has(tokenToString(token))) as R;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function createRetryRoute(
|
|
268
|
+
pendingSwap: PendingSwap,
|
|
269
|
+
blockchains: BlockchainMeta[],
|
|
270
|
+
tokens: Token[]
|
|
271
|
+
): {
|
|
272
|
+
fromBlockchain: BlockchainMeta | null;
|
|
273
|
+
fromToken: Token | null;
|
|
274
|
+
toBlockchain: BlockchainMeta | null;
|
|
275
|
+
toToken: Token | null;
|
|
276
|
+
inputAmount: string;
|
|
277
|
+
} {
|
|
278
|
+
const firstStep = pendingSwap.steps[0];
|
|
279
|
+
const lastStep = pendingSwap.steps[pendingSwap.steps.length - 1];
|
|
280
|
+
const lastSuccessfulStep = getLastSuccessfulStep(pendingSwap.steps);
|
|
281
|
+
|
|
282
|
+
const toToken = {
|
|
283
|
+
blockchain: lastStep.toBlockchain,
|
|
284
|
+
symbol: lastStep.toSymbol,
|
|
285
|
+
address: lastStep.toSymbolAddress,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const fromBlockchainMeta = findBlockchain(
|
|
289
|
+
lastSuccessfulStep
|
|
290
|
+
? lastSuccessfulStep.toBlockchain
|
|
291
|
+
: firstStep.fromBlockchain,
|
|
292
|
+
blockchains
|
|
293
|
+
);
|
|
294
|
+
const toBlockchainMeta = findBlockchain(lastStep.toBlockchain, blockchains);
|
|
295
|
+
const fromTokenMeta = findToken(
|
|
296
|
+
lastSuccessfulStep
|
|
297
|
+
? {
|
|
298
|
+
blockchain: fromBlockchainMeta?.name ?? '',
|
|
299
|
+
symbol: lastSuccessfulStep.toSymbol,
|
|
300
|
+
address: lastSuccessfulStep.toSymbolAddress,
|
|
301
|
+
}
|
|
302
|
+
: {
|
|
303
|
+
blockchain: fromBlockchainMeta?.name ?? '',
|
|
304
|
+
symbol: firstStep.fromSymbol,
|
|
305
|
+
address: firstStep.fromSymbolAddress,
|
|
306
|
+
},
|
|
307
|
+
tokens
|
|
308
|
+
);
|
|
309
|
+
const toTokenMeta = findToken(toToken, tokens);
|
|
310
|
+
const inputAmount = lastSuccessfulStep
|
|
311
|
+
? lastSuccessfulStep.outputAmount ?? ''
|
|
312
|
+
: pendingSwap.inputAmount;
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
fromBlockchain: fromBlockchainMeta,
|
|
316
|
+
fromToken: fromTokenMeta,
|
|
317
|
+
toBlockchain: toBlockchainMeta,
|
|
318
|
+
toToken: toTokenMeta,
|
|
319
|
+
inputAmount,
|
|
320
|
+
};
|
|
321
|
+
}
|
package/src/utils/settings.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { useMetaStore } from '../store/meta';
|
|
2
|
+
import { useSettingsStore } from '../store/settings';
|
|
3
3
|
|
|
4
4
|
import { removeDuplicateFrom } from './common';
|
|
5
5
|
|
|
@@ -14,10 +14,11 @@ export type UniqueSwappersGroupType = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export function getUniqueSwappersGroups(
|
|
17
|
-
|
|
18
|
-
disabledLiquiditySources: string[]
|
|
17
|
+
supportedSwappers?: string[]
|
|
19
18
|
): UniqueSwappersGroupType[] {
|
|
20
|
-
const
|
|
19
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
20
|
+
const disabledLiquiditySources =
|
|
21
|
+
useSettingsStore.use.disabledLiquiditySources();
|
|
21
22
|
|
|
22
23
|
const uniqueSupportedSwappersGroups: Array<UniqueSwappersGroupType> = [];
|
|
23
24
|
|
|
@@ -56,24 +57,16 @@ export function getUniqueSwappersGroups(
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export function sortLiquiditySourcesByGroupTitle(
|
|
59
|
-
a:
|
|
60
|
-
b:
|
|
60
|
+
a: UniqueSwappersGroupType,
|
|
61
|
+
b: UniqueSwappersGroupType
|
|
61
62
|
) {
|
|
62
|
-
if (a.
|
|
63
|
+
if (a.groupTitle < b.groupTitle) {
|
|
63
64
|
return -1;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
if (a.
|
|
67
|
+
if (a.groupTitle > b.groupTitle) {
|
|
67
68
|
return 1;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
return 0;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
export function isFeatureHidden(feature: keyof Features, features?: Features) {
|
|
74
|
-
return features?.[feature] === 'hidden';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function isFeatureEnabled(feature: keyof Features, features?: Features) {
|
|
78
|
-
return features?.[feature] === 'enabled';
|
|
79
|
-
}
|