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