@rango-dev/widget-embedded 0.17.1-next.2 → 0.17.1-next.21
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/QueueManager.d.ts +5 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -3
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +1 -3
- 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 +1 -4
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/Layout/Layout.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/NoResult/NoResult.d.ts +4 -0
- package/dist/components/NoResult/NoResult.d.ts.map +1 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
- package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
- package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
- package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
- package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
- package/dist/components/NoResult/index.d.ts +2 -0
- package/dist/components/NoResult/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts +4 -0
- package/dist/components/Quote/Quote.d.ts.map +1 -0
- package/dist/components/Quote/Quote.styles.d.ts +1588 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
- package/dist/components/Quote/Quote.types.d.ts +21 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSkeleton.d.ts +4 -0
- package/dist/components/Quote/QuoteSkeleton.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts +319 -0
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSkeleton.types.d.ts +6 -0
- package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.d.ts +11 -0
- package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts +158 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
- package/dist/components/Quote/index.d.ts +4 -0
- package/dist/components/Quote/index.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
- package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +23 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- 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.styles.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- 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 +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/navigationRoutes.d.ts +1 -2
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +2 -1
- 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/containers/App/App.d.ts +3 -0
- package/dist/containers/App/App.d.ts.map +1 -0
- package/dist/containers/App/App.styles.d.ts +158 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -0
- package/dist/containers/App/index.d.ts +2 -0
- package/dist/containers/App/index.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +788 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +20 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/index.d.ts +2 -0
- package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.d.ts +6 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
- package/dist/containers/Wallets/index.d.ts +2 -0
- package/dist/containers/Wallets/index.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.d.ts +5 -0
- package/dist/containers/Widget/Widget.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.types.d.ts +5 -0
- package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
- package/dist/containers/Widget/index.d.ts +3 -0
- package/dist/containers/Widget/index.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +14 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/index.d.ts +2 -0
- package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/index.d.ts +2 -0
- package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
- package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +19 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
- package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
- package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
- package/dist/hooks/useFetchQuote.d.ts.map +1 -0
- package/dist/hooks/useForceAutoConnect.d.ts +2 -0
- package/dist/hooks/useForceAutoConnect.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 +1 -3
- 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 +5 -7
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +5 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts +4 -2
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +13 -5
- 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 +1 -6
- 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 +1 -2
- 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 +1 -6
- 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 +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +11 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +5 -23
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/{bestRoute.d.ts → quote.d.ts} +39 -27
- package/dist/store/quote.d.ts.map +1 -0
- package/dist/store/settings.d.ts +3 -2
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +3 -0
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -4
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +19 -5
- 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/quote.d.ts +82 -0
- package/dist/types/quote.d.ts.map +1 -0
- package/dist/types/swap.d.ts +3 -13
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +2 -1
- 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/{routing.d.ts → quote.d.ts} +16 -12
- package/dist/utils/quote.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +3 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +34 -23
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/QueueManager.tsx +18 -17
- package/src/components/AppRouter.tsx +8 -32
- package/src/components/AppRoutes.tsx +57 -69
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +39 -45
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -3
- package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/Layout/Layout.tsx +10 -7
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
- package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +23 -16
- package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
- package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +10 -12
- package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
- package/src/components/NoResult/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +5 -3
- package/src/components/Quote/Quote.styles.ts +239 -0
- package/src/components/Quote/Quote.tsx +413 -0
- package/src/components/Quote/Quote.types.ts +15 -0
- package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
- package/src/components/Quote/QuoteSkeleton.tsx +108 -0
- package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
- package/src/components/Quote/QuoteSummary.styles.ts +15 -0
- package/src/components/Quote/QuoteSummary.tsx +46 -0
- package/src/components/Quote/index.ts +3 -0
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
- package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +4 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +74 -0
- package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +8 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +25 -0
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
- package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +0 -4
- package/src/components/SwapDetails/SwapDetails.tsx +17 -24
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +4 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +8 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +0 -2
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.styles.ts +14 -2
- package/src/components/TokenList/TokenList.tsx +6 -7
- package/src/components/UpdateUrl.tsx +36 -29
- package/src/components/WidgetEvents.tsx +4 -2
- package/src/constants/errors.ts +17 -15
- package/src/constants/index.ts +1 -0
- package/src/constants/messages.ts +1 -1
- package/src/constants/navigationRoutes.ts +7 -8
- package/src/constants/searchParams.ts +1 -0
- package/src/constants/warnings.ts +7 -7
- package/src/containers/App/App.styles.ts +18 -0
- package/src/containers/App/App.tsx +55 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +31 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +98 -0
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +20 -0
- package/src/containers/QuoteInfo/index.ts +1 -0
- package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +40 -32
- package/src/containers/Wallets/Wallets.types.ts +12 -0
- package/src/containers/Wallets/index.ts +1 -0
- package/src/containers/Widget/Widget.tsx +19 -0
- package/src/containers/Widget/Widget.types.ts +5 -0
- package/src/containers/Widget/index.ts +2 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +47 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +14 -0
- package/src/containers/WidgetInfo/index.ts +1 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +28 -0
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
- package/src/containers/WidgetProvider/index.ts +1 -0
- package/src/hooks/useConfirmSwap/index.ts +1 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +172 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +137 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
- package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
- package/src/hooks/useForceAutoConnect.ts +27 -0
- package/src/hooks/useLanguage.ts +2 -2
- package/src/hooks/useNavigateBack.ts +3 -52
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +37 -7
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +60 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +78 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +13 -4
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +6 -1
- package/src/hooks/useSwapInput.ts +139 -46
- package/src/hooks/useSyncStoresWithConfig.ts +22 -19
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +14 -3
- package/src/pages/ConfirmSwapPage.tsx +95 -248
- package/src/pages/HistoryPage.tsx +1 -5
- package/src/pages/Home.tsx +75 -270
- package/src/pages/LanguagePage.tsx +0 -5
- package/src/pages/LiquiditySourcePage.tsx +22 -35
- package/src/pages/SelectBlockchainPage.tsx +31 -24
- package/src/pages/SelectSwapItemsPage.tsx +9 -23
- package/src/pages/SettingsPage.tsx +8 -15
- package/src/pages/SwapDetailsPage.tsx +6 -7
- package/src/pages/ThemePage.tsx +0 -4
- package/src/pages/WalletsPage.tsx +4 -15
- package/src/services/httpService.ts +1 -1
- package/src/store/AppStore.tsx +35 -0
- package/src/store/app.ts +18 -6
- package/src/store/{bestRoute.ts → quote.ts} +68 -60
- package/src/store/settings.ts +7 -4
- package/src/store/slices/config.ts +25 -15
- package/src/store/slices/data.ts +64 -29
- package/src/store/wallets.ts +12 -8
- package/src/types/config.ts +20 -5
- package/src/types/index.ts +1 -1
- package/src/types/quote.ts +107 -0
- package/src/types/swap.ts +3 -12
- package/src/utils/colors.ts +2 -1
- package/src/utils/configs.ts +2 -1
- package/src/utils/meta.ts +8 -1
- package/src/utils/numbers.ts +1 -1
- package/src/utils/quote.ts +338 -0
- package/src/utils/settings.ts +8 -7
- package/src/utils/swap.ts +153 -116
- package/src/utils/wallets.ts +29 -17
- package/dist/Wallets.d.ts +0 -17
- package/dist/Wallets.d.ts.map +0 -1
- package/dist/Widget.d.ts +0 -9
- package/dist/Widget.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
- package/dist/components/NoRoutes/index.d.ts +0 -2
- package/dist/components/NoRoutes/index.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/RouteErrors/index.d.ts +0 -2
- package/dist/components/RouteErrors/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
- package/dist/store/bestRoute.d.ts.map +0 -1
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/dist/types/routing.d.ts +0 -65
- package/dist/types/routing.d.ts.map +0 -1
- package/dist/utils/routing.d.ts.map +0 -1
- package/src/Widget.tsx +0 -119
- package/src/components/NoRoutes/index.ts +0 -1
- package/src/components/RouteErrors/RouteErrors.tsx +0 -79
- package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
- package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
- package/src/components/RouteErrors/index.ts +0 -1
- package/src/hooks/useConfirmSwap.ts +0 -303
- package/src/store/meta.ts +0 -39
- package/src/types/routing.ts +0 -77
- package/src/utils/routing.ts +0 -321
package/src/utils/swap.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
2
|
+
import type { FetchStatus } from '../store/slices/data';
|
|
3
|
+
import type {
|
|
4
|
+
ConvertedToken,
|
|
5
|
+
QuoteError,
|
|
6
|
+
QuoteWarning,
|
|
7
|
+
RecommendedSlippages,
|
|
8
|
+
SwapButtonState,
|
|
9
|
+
Wallet,
|
|
10
|
+
} from '../types';
|
|
5
11
|
import type {
|
|
6
12
|
PendingSwap,
|
|
7
13
|
PendingSwapStep,
|
|
@@ -30,12 +36,11 @@ import {
|
|
|
30
36
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
31
37
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
32
38
|
} from '../constants/routing';
|
|
33
|
-
import { useMetaStore } from '../store/meta';
|
|
34
|
-
import { ButtonState } from '../types';
|
|
35
39
|
|
|
36
40
|
import { removeDuplicateFrom } from './common';
|
|
41
|
+
import { getBlockchainShortNameFor } from './meta';
|
|
37
42
|
import { numberToString } from './numbers';
|
|
38
|
-
import { getRequiredBalanceOfWallet } from './
|
|
43
|
+
import { getPriceImpact, getRequiredBalanceOfWallet } from './quote';
|
|
39
44
|
import { getRequiredChains } from './wallets';
|
|
40
45
|
|
|
41
46
|
export function getOutputRatio(
|
|
@@ -50,25 +55,29 @@ export function getOutputRatio(
|
|
|
50
55
|
) {
|
|
51
56
|
return 0;
|
|
52
57
|
}
|
|
53
|
-
return outputUsdValue
|
|
58
|
+
return outputUsdValue
|
|
59
|
+
.div(inputUsdValue)
|
|
60
|
+
.minus(1)
|
|
61
|
+
.multipliedBy(100)
|
|
62
|
+
.toNumber();
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
export function
|
|
65
|
+
export function hasHighValueLoss(
|
|
57
66
|
inputUsdValue: BigNumber | null,
|
|
58
|
-
|
|
67
|
+
priceImpact: number
|
|
59
68
|
): boolean {
|
|
60
69
|
return (
|
|
61
|
-
((parseInt(
|
|
70
|
+
((parseInt(priceImpact.toFixed(2) || '0') <= -10 &&
|
|
62
71
|
inputUsdValue?.gte(new BigNumber(400))) ||
|
|
63
|
-
(parseInt(
|
|
72
|
+
(parseInt(priceImpact.toFixed(2) || '0') <= -5 &&
|
|
64
73
|
inputUsdValue?.gte(new BigNumber(1000)))) ??
|
|
65
74
|
false
|
|
66
75
|
);
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
export function hasLimitError(
|
|
78
|
+
export function hasLimitError(quote: BestRouteResponse | null): boolean {
|
|
70
79
|
return (
|
|
71
|
-
(
|
|
80
|
+
(quote?.result?.swaps || []).filter((swap) => {
|
|
72
81
|
const minimum = !!swap.fromAmountMinValue
|
|
73
82
|
? new BigNumber(swap.fromAmountMinValue)
|
|
74
83
|
: null;
|
|
@@ -83,16 +92,12 @@ export function hasLimitError(bestRoute: BestRouteResponse | null): boolean {
|
|
|
83
92
|
}).length > 0
|
|
84
93
|
);
|
|
85
94
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
swap: SwapResult | null;
|
|
95
|
+
export function getLimitErrorMessage(quote: BestRouteResponse): {
|
|
96
|
+
swap: SwapResult;
|
|
89
97
|
fromAmountRangeError: string;
|
|
90
98
|
recommendation: string;
|
|
91
99
|
} {
|
|
92
|
-
|
|
93
|
-
return { swap: null, fromAmountRangeError: '', recommendation: '' };
|
|
94
|
-
}
|
|
95
|
-
const swap = (bestRoute?.result?.swaps || []).filter((swap) => {
|
|
100
|
+
const swap = (quote.result?.swaps || []).filter((swap) => {
|
|
96
101
|
const minimum = !!swap.fromAmountMinValue
|
|
97
102
|
? new BigNumber(swap.fromAmountMinValue)
|
|
98
103
|
: null;
|
|
@@ -105,9 +110,7 @@ export function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
|
|
|
105
110
|
}
|
|
106
111
|
return minimum?.gt(swap.fromAmount) || maximum?.lt(swap.fromAmount);
|
|
107
112
|
})[0];
|
|
108
|
-
|
|
109
|
-
return { swap: null, fromAmountRangeError: '', recommendation: '' };
|
|
110
|
-
}
|
|
113
|
+
|
|
111
114
|
const minimum = !!swap.fromAmountMinValue
|
|
112
115
|
? new BigNumber(swap.fromAmountMinValue)
|
|
113
116
|
: null;
|
|
@@ -177,85 +180,92 @@ export function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
|
|
|
177
180
|
return { swap, fromAmountRangeError, recommendation };
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
export function getSwapButtonState(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
needsToWarnEthOnPath: boolean
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
183
|
+
export function getSwapButtonState(params: {
|
|
184
|
+
fetchMetaStatus: FetchStatus;
|
|
185
|
+
anyWalletConnected: boolean;
|
|
186
|
+
fetchingQuote: boolean;
|
|
187
|
+
inputAmount: string;
|
|
188
|
+
quote: BestRouteResponse | null;
|
|
189
|
+
warning: QuoteWarning | null;
|
|
190
|
+
error: QuoteError | null;
|
|
191
|
+
needsToWarnEthOnPath: boolean;
|
|
192
|
+
}): SwapButtonState {
|
|
193
|
+
const {
|
|
194
|
+
fetchMetaStatus,
|
|
195
|
+
anyWalletConnected,
|
|
196
|
+
fetchingQuote,
|
|
197
|
+
inputAmount,
|
|
198
|
+
quote,
|
|
199
|
+
warning,
|
|
200
|
+
error,
|
|
201
|
+
needsToWarnEthOnPath,
|
|
202
|
+
} = params;
|
|
203
|
+
if (fetchMetaStatus !== 'success') {
|
|
192
204
|
return {
|
|
193
205
|
title: swapButtonTitles().connectWallet,
|
|
194
|
-
|
|
206
|
+
action: 'connect-wallet',
|
|
195
207
|
disabled: true,
|
|
196
208
|
};
|
|
197
209
|
}
|
|
198
|
-
if (
|
|
210
|
+
if (!anyWalletConnected) {
|
|
199
211
|
return {
|
|
200
212
|
title: swapButtonTitles().connectWallet,
|
|
201
|
-
|
|
213
|
+
action: 'connect-wallet',
|
|
202
214
|
disabled: false,
|
|
203
215
|
};
|
|
204
216
|
}
|
|
205
217
|
if (
|
|
206
|
-
|
|
207
|
-
!
|
|
208
|
-
!
|
|
209
|
-
|
|
218
|
+
fetchingQuote ||
|
|
219
|
+
!quote ||
|
|
220
|
+
!quote.result ||
|
|
221
|
+
error ||
|
|
210
222
|
!inputAmount ||
|
|
211
223
|
inputAmount === '0'
|
|
212
224
|
) {
|
|
213
225
|
return {
|
|
214
226
|
title: swapButtonTitles().swap,
|
|
227
|
+
action: 'confirm-swap',
|
|
215
228
|
disabled: true,
|
|
216
|
-
state: ButtonState.SWAP,
|
|
217
229
|
};
|
|
218
|
-
} else if (
|
|
230
|
+
} else if (warning) {
|
|
219
231
|
return {
|
|
220
232
|
title: swapButtonTitles().swapAnyway,
|
|
233
|
+
action: 'confirm-warning',
|
|
221
234
|
disabled: false,
|
|
222
|
-
hasWarning: true,
|
|
223
|
-
state: ButtonState.NEEDTOCONFIRM,
|
|
224
235
|
};
|
|
225
236
|
} else if (needsToWarnEthOnPath) {
|
|
226
237
|
return {
|
|
227
|
-
title: swapButtonTitles().
|
|
238
|
+
title: swapButtonTitles().ethWarning,
|
|
239
|
+
action: 'confirm-warning',
|
|
228
240
|
disabled: false,
|
|
229
|
-
hasWarning: true,
|
|
230
|
-
state: ButtonState.WARNING,
|
|
231
241
|
};
|
|
232
242
|
}
|
|
233
243
|
return {
|
|
234
244
|
title: swapButtonTitles().swap,
|
|
245
|
+
action: 'confirm-swap',
|
|
235
246
|
disabled: false,
|
|
236
|
-
state: ButtonState.SWAP,
|
|
237
247
|
};
|
|
238
248
|
}
|
|
239
249
|
|
|
240
250
|
export function canComputePriceImpact(
|
|
241
|
-
|
|
251
|
+
quote: BestRouteResponse | null,
|
|
242
252
|
inputAmount: string,
|
|
243
253
|
usdValue: BigNumber | null
|
|
244
254
|
) {
|
|
245
255
|
return !(
|
|
246
256
|
(!usdValue || usdValue.lte(ZERO)) &&
|
|
247
|
-
!!
|
|
257
|
+
!!quote?.result &&
|
|
248
258
|
!!inputAmount &&
|
|
249
259
|
inputAmount !== '0' &&
|
|
250
260
|
parseFloat(inputAmount || '0') !== 0 &&
|
|
251
|
-
!!
|
|
261
|
+
!!quote.result
|
|
252
262
|
);
|
|
253
263
|
}
|
|
254
264
|
|
|
255
|
-
export function requiredWallets(
|
|
265
|
+
export function requiredWallets(quote: BestRouteResponse | null) {
|
|
256
266
|
const wallets: string[] = [];
|
|
257
267
|
|
|
258
|
-
|
|
268
|
+
quote?.result?.swaps.forEach((swap) => {
|
|
259
269
|
const currentStepFromBlockchain = swap.from.blockchain;
|
|
260
270
|
const currentStepToBlockchain = swap.to.blockchain;
|
|
261
271
|
let lastAddedWallet = wallets[wallets.length - 1];
|
|
@@ -311,15 +321,13 @@ export function getUsdFeeOfStep(
|
|
|
311
321
|
}
|
|
312
322
|
|
|
313
323
|
export function getTotalFeeInUsd(
|
|
314
|
-
|
|
324
|
+
swaps: SwapResult[],
|
|
315
325
|
allTokens: Token[]
|
|
316
|
-
): BigNumber
|
|
317
|
-
return (
|
|
318
|
-
|
|
319
|
-
(
|
|
320
|
-
|
|
321
|
-
ZERO
|
|
322
|
-
) || null
|
|
326
|
+
): BigNumber {
|
|
327
|
+
return swaps.reduce(
|
|
328
|
+
(totalFee: BigNumber, step) =>
|
|
329
|
+
totalFee.plus(getUsdFeeOfStep(step, allTokens)),
|
|
330
|
+
ZERO
|
|
323
331
|
);
|
|
324
332
|
}
|
|
325
333
|
|
|
@@ -336,10 +344,44 @@ export function hasSlippageError(
|
|
|
336
344
|
return (slippages?.filter((s) => !!s?.error)?.length || 0) > 0;
|
|
337
345
|
}
|
|
338
346
|
|
|
347
|
+
export function checkSlippageErrors(
|
|
348
|
+
quote: BestRouteResponse
|
|
349
|
+
): RecommendedSlippages | null {
|
|
350
|
+
const recommendedSlippages: RecommendedSlippages = new Map();
|
|
351
|
+
quote.result?.swaps.forEach((swap, index) => {
|
|
352
|
+
if (swap.recommendedSlippage?.error) {
|
|
353
|
+
recommendedSlippages.set(index, swap.recommendedSlippage.slippage);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
if (recommendedSlippages.size > 0) {
|
|
357
|
+
return recommendedSlippages;
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export function checkSlippageWarnings(
|
|
363
|
+
quote: BestRouteResponse,
|
|
364
|
+
userSlippage: number
|
|
365
|
+
): RecommendedSlippages | null {
|
|
366
|
+
const recommendedSlippages: RecommendedSlippages = new Map();
|
|
367
|
+
quote.result?.swaps.forEach((swap, index) => {
|
|
368
|
+
if (
|
|
369
|
+
swap.recommendedSlippage?.slippage &&
|
|
370
|
+
parseFloat(swap.recommendedSlippage.slippage) > userSlippage
|
|
371
|
+
) {
|
|
372
|
+
recommendedSlippages.set(index, swap.recommendedSlippage.slippage);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
if (recommendedSlippages.size > 0) {
|
|
376
|
+
return recommendedSlippages;
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
|
|
339
381
|
export function getMinRequiredSlippage(
|
|
340
|
-
|
|
382
|
+
quote: BestRouteResponse
|
|
341
383
|
): string | null {
|
|
342
|
-
const slippages =
|
|
384
|
+
const slippages = quote.result?.swaps.map(
|
|
343
385
|
(slippage) => slippage.recommendedSlippage
|
|
344
386
|
);
|
|
345
387
|
return (
|
|
@@ -362,10 +404,10 @@ export function hasProperSlippage(
|
|
|
362
404
|
}
|
|
363
405
|
|
|
364
406
|
export function hasEnoughBalance(
|
|
365
|
-
|
|
407
|
+
quote: BestRouteResponse,
|
|
366
408
|
selectedWallets: Wallet[]
|
|
367
409
|
) {
|
|
368
|
-
const fee =
|
|
410
|
+
const fee = quote.validationStatus;
|
|
369
411
|
|
|
370
412
|
if (fee === null || fee.length === 0) {
|
|
371
413
|
return true;
|
|
@@ -389,29 +431,31 @@ export function hasEnoughBalance(
|
|
|
389
431
|
}
|
|
390
432
|
|
|
391
433
|
export function hasEnoughBalanceAndProperSlippage(
|
|
392
|
-
|
|
434
|
+
quote: BestRouteResponse,
|
|
393
435
|
selectedWallets: Wallet[],
|
|
394
436
|
userSlippage: string,
|
|
395
437
|
minRequiredSlippage: string | null
|
|
396
438
|
): boolean {
|
|
397
439
|
return (
|
|
398
|
-
hasEnoughBalance(
|
|
440
|
+
hasEnoughBalance(quote, selectedWallets) &&
|
|
399
441
|
hasProperSlippage(userSlippage, minRequiredSlippage)
|
|
400
442
|
);
|
|
401
443
|
}
|
|
402
444
|
|
|
403
|
-
export function
|
|
445
|
+
export function createQuoteRequestBody(params: {
|
|
404
446
|
fromToken: Token;
|
|
405
447
|
toToken: Token;
|
|
406
448
|
inputAmount: string;
|
|
407
449
|
wallets?: Wallet[];
|
|
408
450
|
selectedWallets?: Wallet[];
|
|
451
|
+
liquiditySources?: string[];
|
|
452
|
+
excludeLiquiditySources?: boolean;
|
|
409
453
|
disabledLiquiditySources: string[];
|
|
410
454
|
slippage: number;
|
|
411
455
|
affiliateRef: string | null;
|
|
412
456
|
affiliatePercent: number | null;
|
|
413
457
|
affiliateWallets: { [key: string]: string } | null;
|
|
414
|
-
|
|
458
|
+
initialQuote?: BestRouteResponse;
|
|
415
459
|
destination?: string;
|
|
416
460
|
}): BestRouteRequest {
|
|
417
461
|
const {
|
|
@@ -421,11 +465,13 @@ export function createBestRouteRequestBody(params: {
|
|
|
421
465
|
wallets,
|
|
422
466
|
selectedWallets,
|
|
423
467
|
disabledLiquiditySources,
|
|
468
|
+
liquiditySources,
|
|
469
|
+
excludeLiquiditySources,
|
|
424
470
|
slippage,
|
|
425
471
|
affiliateRef,
|
|
426
472
|
affiliatePercent,
|
|
427
473
|
affiliateWallets,
|
|
428
|
-
|
|
474
|
+
initialQuote,
|
|
429
475
|
destination,
|
|
430
476
|
} = params;
|
|
431
477
|
const selectedWalletsMap = selectedWallets?.reduce(
|
|
@@ -455,10 +501,10 @@ export function createBestRouteRequestBody(params: {
|
|
|
455
501
|
}
|
|
456
502
|
});
|
|
457
503
|
|
|
458
|
-
const checkPrerequisites = !!
|
|
504
|
+
const checkPrerequisites = !!initialQuote;
|
|
459
505
|
|
|
460
506
|
const filteredBlockchains = removeDuplicateFrom(
|
|
461
|
-
(
|
|
507
|
+
(initialQuote?.result?.swaps || []).reduce(
|
|
462
508
|
(blockchains: string[], swap) => {
|
|
463
509
|
blockchains.push(swap.from.blockchain, swap.to.blockchain);
|
|
464
510
|
// Check if internalSwaps array exists
|
|
@@ -496,13 +542,18 @@ export function createBestRouteRequestBody(params: {
|
|
|
496
542
|
selectedWallets: selectedWalletsMap ?? {},
|
|
497
543
|
slippage: slippage.toString(),
|
|
498
544
|
...(destination && { destination: destination }),
|
|
499
|
-
...(
|
|
500
|
-
swapperGroups: disabledLiquiditySources,
|
|
545
|
+
...(excludeLiquiditySources && {
|
|
546
|
+
swapperGroups: disabledLiquiditySources.concat(liquiditySources ?? []),
|
|
501
547
|
swappersGroupsExclude: true,
|
|
502
548
|
}),
|
|
549
|
+
...(!excludeLiquiditySources && {
|
|
550
|
+
swapperGroups: liquiditySources?.filter(
|
|
551
|
+
(liquiditySource) => !disabledLiquiditySources.includes(liquiditySource)
|
|
552
|
+
),
|
|
553
|
+
swappersGroupsExclude: false,
|
|
554
|
+
}),
|
|
503
555
|
...(checkPrerequisites && { blockchains: filteredBlockchains }),
|
|
504
556
|
};
|
|
505
|
-
|
|
506
557
|
return requestBody;
|
|
507
558
|
}
|
|
508
559
|
|
|
@@ -526,49 +577,42 @@ export function getWalletsForNewSwap(selectedWallets: Wallet[]) {
|
|
|
526
577
|
return wallets;
|
|
527
578
|
}
|
|
528
579
|
|
|
529
|
-
export function
|
|
530
|
-
return
|
|
580
|
+
export function getQuoteOutputAmount(quote: BestRouteResponse) {
|
|
581
|
+
return quote.result?.outputAmount || null;
|
|
531
582
|
}
|
|
532
583
|
|
|
533
|
-
export function getPercentageChange(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
) {
|
|
537
|
-
if (!inputUsdValue || !outputUsdValue) {
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
540
|
-
return new BigNumber(outputUsdValue)
|
|
541
|
-
.div(new BigNumber(inputUsdValue))
|
|
584
|
+
export function getPercentageChange(input: string, output: string) {
|
|
585
|
+
return new BigNumber(output)
|
|
586
|
+
.div(new BigNumber(input))
|
|
542
587
|
.minus(1)
|
|
543
|
-
.multipliedBy(100)
|
|
588
|
+
.multipliedBy(100)
|
|
589
|
+
.toNumber();
|
|
544
590
|
}
|
|
545
591
|
|
|
546
592
|
export function isOutputAmountChangedALot(
|
|
547
|
-
|
|
548
|
-
|
|
593
|
+
oldQuote: BestRouteResponse,
|
|
594
|
+
newQuote: BestRouteResponse
|
|
549
595
|
) {
|
|
550
|
-
const oldOutputAmount =
|
|
551
|
-
const newOutputAmount =
|
|
596
|
+
const oldOutputAmount = getQuoteOutputAmount(oldQuote);
|
|
597
|
+
const newOutputAmount = getQuoteOutputAmount(newQuote);
|
|
552
598
|
if (!oldOutputAmount || !newOutputAmount) {
|
|
553
599
|
return false;
|
|
554
600
|
}
|
|
555
|
-
const percentageChange =
|
|
556
|
-
oldOutputAmount,
|
|
557
|
-
newOutputAmount
|
|
558
|
-
);
|
|
601
|
+
const percentageChange = getPriceImpact(oldOutputAmount, newOutputAmount);
|
|
559
602
|
if (!percentageChange) {
|
|
560
603
|
return true;
|
|
561
604
|
}
|
|
562
605
|
|
|
563
|
-
return percentageChange
|
|
606
|
+
return percentageChange <= -1;
|
|
564
607
|
}
|
|
565
608
|
|
|
566
|
-
export function
|
|
567
|
-
|
|
568
|
-
selectedWallets: Wallet[]
|
|
609
|
+
export function generateBalanceWarnings(
|
|
610
|
+
quote: BestRouteResponse,
|
|
611
|
+
selectedWallets: Wallet[],
|
|
612
|
+
blockchains: BlockchainMeta[]
|
|
569
613
|
) {
|
|
570
|
-
const fee =
|
|
571
|
-
const requiredWallets = getRequiredChains(
|
|
614
|
+
const fee = quote.validationStatus;
|
|
615
|
+
const requiredWallets = getRequiredChains(quote);
|
|
572
616
|
const walletsSortedByRequiredWallets = selectedWallets.sort(
|
|
573
617
|
(selectedWallet1, selectedWallet2) =>
|
|
574
618
|
requiredWallets.indexOf(selectedWallet1.chain) -
|
|
@@ -610,7 +654,10 @@ export function getBalanceWarnings(
|
|
|
610
654
|
symbol,
|
|
611
655
|
reason,
|
|
612
656
|
currentAmount,
|
|
613
|
-
blockchain:
|
|
657
|
+
blockchain: getBlockchainShortNameFor(
|
|
658
|
+
asset.asset.blockchain,
|
|
659
|
+
blockchains
|
|
660
|
+
),
|
|
614
661
|
},
|
|
615
662
|
});
|
|
616
663
|
return warningMessage;
|
|
@@ -714,29 +761,19 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
|
|
|
714
761
|
new Date().getTime() - parseInt(pendingSwap.finishTime) < 4 * 3600 * 1000
|
|
715
762
|
);
|
|
716
763
|
}
|
|
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
|
-
}
|
|
727
764
|
|
|
728
765
|
export function confirmSwapDisabled(
|
|
729
766
|
fetching: boolean,
|
|
730
767
|
showCustomDestination: boolean,
|
|
731
768
|
customDestination: string,
|
|
732
|
-
|
|
769
|
+
quote: BestRouteResponse | null,
|
|
733
770
|
selectedWallets: { walletType: string; chain: string }[],
|
|
734
771
|
lastStepToBlockchain?: BlockchainMeta
|
|
735
772
|
) {
|
|
736
773
|
return (
|
|
737
774
|
fetching ||
|
|
738
775
|
(!showCustomDestination &&
|
|
739
|
-
!requiredWallets(
|
|
776
|
+
!requiredWallets(quote).every((chain) =>
|
|
740
777
|
selectedWallets.map((wallet) => wallet.chain).includes(chain)
|
|
741
778
|
)) ||
|
|
742
779
|
(!!showCustomDestination && !customDestination) ||
|
package/src/utils/wallets.ts
CHANGED
|
@@ -55,8 +55,11 @@ export function mapWalletTypesToWalletInfo(
|
|
|
55
55
|
return list
|
|
56
56
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
57
57
|
.filter((wallet) => {
|
|
58
|
-
const { supportedChains,
|
|
59
|
-
|
|
58
|
+
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
59
|
+
const { installed, network } = getState(wallet);
|
|
60
|
+
const filterContractWallets =
|
|
61
|
+
isContractWallet && (!installed || (!!chain && network !== chain));
|
|
62
|
+
if (filterContractWallets) {
|
|
60
63
|
return false;
|
|
61
64
|
}
|
|
62
65
|
if (chain) {
|
|
@@ -97,7 +100,8 @@ export function prepareAccountsForWalletStore(
|
|
|
97
100
|
wallet: WalletType,
|
|
98
101
|
accounts: string[],
|
|
99
102
|
evmBasedChains: string[],
|
|
100
|
-
supportedChainNames: Network[] | null
|
|
103
|
+
supportedChainNames: Network[] | null,
|
|
104
|
+
isContractWallet: boolean
|
|
101
105
|
): Wallet[] {
|
|
102
106
|
const result: Wallet[] = [];
|
|
103
107
|
|
|
@@ -151,21 +155,29 @@ export function prepareAccountsForWalletStore(
|
|
|
151
155
|
|
|
152
156
|
// If it's an evm network, we will add the address to all the evm chains.
|
|
153
157
|
if (isEvmBasedChain || isUnknownAndEvmBased) {
|
|
154
|
-
|
|
155
|
-
* all evm chains are not supported in wallets, so we are adding
|
|
156
|
-
* only to those that are supported by wallet.
|
|
157
|
-
*/
|
|
158
|
-
const evmChainsSupportedByWallet = supportedBlockchains.filter((chain) =>
|
|
159
|
-
evmBasedChains.includes(chain)
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
evmChainsSupportedByWallet.forEach((network) => {
|
|
158
|
+
if (isContractWallet) {
|
|
163
159
|
/*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
160
|
+
* for contract wallets like Safe wallet, we should add only account for the
|
|
161
|
+
* current connected blockchain not all of the supported blockchains
|
|
166
162
|
*/
|
|
167
163
|
addAccount(network, address.toLowerCase());
|
|
168
|
-
}
|
|
164
|
+
} else {
|
|
165
|
+
/*
|
|
166
|
+
* all evm chains are not supported in wallets, so we are adding
|
|
167
|
+
* only to those that are supported by wallet.
|
|
168
|
+
*/
|
|
169
|
+
const evmChainsSupportedByWallet = supportedBlockchains.filter(
|
|
170
|
+
(chain) => evmBasedChains.includes(chain)
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
evmChainsSupportedByWallet.forEach((network) => {
|
|
174
|
+
/*
|
|
175
|
+
* EVM addresses are not case sensitive.
|
|
176
|
+
* Some wallets like Binance-chain return some letters in uppercase which produces bugs in our wallet state.
|
|
177
|
+
*/
|
|
178
|
+
addAccount(network, address.toLowerCase());
|
|
179
|
+
});
|
|
180
|
+
}
|
|
169
181
|
} else {
|
|
170
182
|
addAccount(network, address);
|
|
171
183
|
}
|
|
@@ -174,10 +186,10 @@ export function prepareAccountsForWalletStore(
|
|
|
174
186
|
return result;
|
|
175
187
|
}
|
|
176
188
|
|
|
177
|
-
export function getRequiredChains(
|
|
189
|
+
export function getRequiredChains(quote: BestRouteResponse | null) {
|
|
178
190
|
const wallets: string[] = [];
|
|
179
191
|
|
|
180
|
-
|
|
192
|
+
quote?.result?.swaps.forEach((swap) => {
|
|
181
193
|
const currentStepFromBlockchain = swap.from.blockchain;
|
|
182
194
|
const currentStepToBlockchain = swap.to.blockchain;
|
|
183
195
|
if (!wallets.includes(currentStepFromBlockchain)) {
|
package/dist/Wallets.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { WidgetConfig } from './types';
|
|
2
|
-
import type { ProvidersOptions } from './utils/providers';
|
|
3
|
-
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
4
|
-
import type { PropsWithChildren } from 'react';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
type OnConnectHandler = (key: string) => void;
|
|
7
|
-
interface WidgetContextInterface {
|
|
8
|
-
onConnectWallet(handler: OnConnectHandler): void;
|
|
9
|
-
}
|
|
10
|
-
export declare const WidgetContext: React.Context<WidgetContextInterface>;
|
|
11
|
-
export declare function WidgetWallets(props: PropsWithChildren<{
|
|
12
|
-
providers: WidgetConfig['wallets'];
|
|
13
|
-
options?: ProvidersOptions;
|
|
14
|
-
onUpdateState?: EventHandler;
|
|
15
|
-
}>): React.JSX.Element;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=Wallets.d.ts.map
|
package/dist/Wallets.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Wallets.d.ts","sourceRoot":"","sources":["../src/Wallets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,KAAgC,MAAM,OAAO,CAAC;AAUrD,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAC9C,UAAU,sBAAsB;IAC9B,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,aAAa,uCAIxB,CAAC;AAEH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,CAAC;IACvB,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC,qBA+EH"}
|
package/dist/Widget.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { WidgetConfig } from './types';
|
|
2
|
-
import type { PropsWithChildren } from 'react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
export type WidgetProps = {
|
|
5
|
-
config?: WidgetConfig;
|
|
6
|
-
};
|
|
7
|
-
export declare function Main(props: PropsWithChildren<WidgetProps>): React.JSX.Element;
|
|
8
|
-
export declare function Widget(props: PropsWithChildren<WidgetProps>): React.JSX.Element;
|
|
9
|
-
//# sourceMappingURL=Widget.d.ts.map
|
package/dist/Widget.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Widget.d.ts","sourceRoot":"","sources":["../src/Widget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAiCxE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,qBAoDzD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,qBAsB3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoRoutes.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/NoRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAUlD,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,qBA6DxC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { Info } from './NoRoutes.types';
|
|
2
|
-
export declare function makeInfo(diagnosisMessage: string | null, disabledLiquiditySources: string[], hasError: boolean, toggleAllLiquiditySources: (shouldReset: boolean) => void, refetchBestRoute: () => void): Info;
|
|
3
|
-
//# sourceMappingURL=NoRoutes.helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoRoutes.helper.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/NoRoutes.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAM7C,wBAAgB,QAAQ,CACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,wBAAwB,EAAE,MAAM,EAAE,EAClC,QAAQ,EAAE,OAAO,EACjB,yBAAyB,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,EACzD,gBAAgB,EAAE,MAAM,IAAI,GAC3B,IAAI,CAuCN"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoRoutes.types.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/NoRoutes.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RouteErrors.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,qBAgE3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RouteErrors.styles.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrors.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAGjB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAMf,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAMf,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAIjB,CAAC"}
|