@rango-dev/widget-embedded 0.12.1-next.9 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +5 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +14 -4
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +6 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +94 -17
- 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/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +18 -3
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +25 -284
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +18 -3
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +6 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts +3 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -0
- package/dist/components/{SelectableCategoryList/SelectableCategoryList.styles.d.ts → LoadingSwapDetails/LoadingSwapDetails.styles.d.ts} +21 -6
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/index.d.ts +2 -0
- package/dist/components/LoadingSwapDetails/index.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -1
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts +18 -3
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +24 -4
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts +24 -4
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +3 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +6 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +23 -151
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/SettingsContainer/index.d.ts +1 -1
- package/dist/components/SettingsContainer/index.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +24 -4
- 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 +2 -9
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +35 -153
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +6 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +6 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -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 +24 -4
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +207 -9
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +24 -4
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +2 -2
- package/dist/constants/routing.d.ts +12 -2
- package/dist/constants/routing.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/globalStyles.d.ts +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList.d.ts +18 -0
- package/dist/hooks/usePrepareBlockchainList.d.ts.map +1 -0
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +3 -0
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +3 -6
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders.d.ts +3 -3
- package/dist/hooks/useWalletProviders.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts +1 -2
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts +1 -5
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +0 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/app.d.ts +26 -0
- package/dist/store/app.d.ts.map +1 -0
- package/dist/store/bestRoute.d.ts +4 -8
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts +0 -2
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +8 -0
- package/dist/store/slices/config.d.ts.map +1 -0
- package/dist/store/slices/data.d.ts +26 -0
- package/dist/store/slices/data.d.ts.map +1 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +5 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +3 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +6 -3
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +2 -2
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/readme.md +3 -1
- package/src/Widget.tsx +22 -3
- package/src/components/AppRouter.tsx +38 -7
- package/src/components/AppRoutes.tsx +4 -28
- package/src/components/BlockchainList/BlockchainList.helpers.ts +1 -1
- package/src/components/BlockchainList/BlockchainList.styles.ts +6 -5
- package/src/components/BlockchainList/BlockchainList.tsx +6 -9
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +29 -42
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +33 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +48 -7
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +59 -16
- package/src/components/ConfirmWalletsModal/WalletList.tsx +66 -22
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +2 -2
- package/src/components/HeaderButtons/HeaderButtons.types.ts +1 -0
- package/src/components/HeaderButtons/HomeButtons.tsx +18 -5
- package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +1 -2
- package/src/components/HeaderButtons/WalletButton.tsx +4 -1
- package/src/components/Layout/Layout.styles.ts +5 -3
- package/src/components/Layout/Layout.tsx +5 -20
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +78 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +53 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
- package/src/components/LoadingSwapDetails/index.ts +1 -0
- package/src/components/NoRoutes/NoRoutes.helper.ts +4 -2
- package/src/components/NotificationContent/NotificationContent.tsx +3 -7
- package/src/components/RouteErrors/RouteErrors.styles.ts +2 -1
- package/src/components/RouteErrors/RouteErrors.tsx +37 -26
- package/src/components/RouteErrors/RouteErrors.types.ts +3 -1
- package/src/components/RouteErrors/RouteErrorsModal.tsx +42 -14
- package/src/components/SettingsContainer/SettingsContainer.style.ts +2 -7
- package/src/components/SettingsContainer/index.ts +0 -1
- package/src/components/Slippage/Slippage.tsx +6 -2
- package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +52 -16
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +19 -33
- package/src/components/SwapDetails/SwapDetails.styles.ts +10 -14
- package/src/components/SwapDetails/SwapDetails.tsx +143 -101
- package/src/components/SwapDetails/SwapDetails.types.ts +1 -1
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +5 -4
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +6 -7
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +3 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +3 -2
- package/src/components/SwitchFromAndTo.tsx +1 -35
- package/src/components/TokenList/TokenList.helpers.ts +6 -8
- package/src/components/TokenList/TokenList.styles.ts +7 -1
- package/src/components/TokenList/TokenList.tsx +29 -23
- package/src/components/TokenList/TokenList.types.ts +1 -1
- package/src/components/UpdateUrl.tsx +7 -1
- package/src/components/WidgetEvents.tsx +9 -3
- package/src/constants/errors.ts +2 -2
- package/src/constants/routing.ts +17 -2
- package/src/constants.ts +1 -0
- package/src/globalStyles.ts +1 -4
- package/src/hooks/useFetchBestRoute.ts +2 -2
- package/src/hooks/useNavigateBack.ts +10 -0
- package/src/hooks/usePrepareBlockchainList.ts +125 -0
- package/src/hooks/useSwapInput.ts +17 -3
- package/src/hooks/useSyncStoresWithConfig.ts +102 -0
- package/src/hooks/useTheme.ts +37 -75
- package/src/hooks/useWalletProviders.ts +7 -7
- package/src/pages/ConfirmSwapPage.tsx +65 -36
- package/src/pages/HistoryPage.tsx +2 -2
- package/src/pages/Home.tsx +114 -50
- package/src/pages/LanguagePage.tsx +1 -1
- package/src/pages/LiquiditySourcePage.tsx +22 -18
- package/src/pages/SelectBlockchainPage.tsx +19 -20
- package/src/pages/SelectSwapItemsPage.tsx +66 -88
- package/src/pages/SettingsPage.tsx +42 -15
- package/src/pages/SwapDetailsPage.tsx +9 -2
- package/src/pages/ThemePage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +11 -5
- package/src/services/httpService.ts +4 -5
- package/src/store/app.ts +15 -0
- package/src/store/bestRoute.ts +45 -71
- package/src/store/meta.ts +11 -29
- package/src/store/slices/config.ts +26 -0
- package/src/store/slices/data.ts +203 -0
- package/src/store/wallets.ts +0 -27
- package/src/types/config.ts +3 -0
- package/src/utils/common.ts +3 -0
- package/src/utils/configs.ts +8 -2
- package/src/utils/meta.ts +7 -0
- package/src/utils/numbers.ts +3 -2
- package/src/utils/routing.ts +76 -14
- package/src/utils/settings.ts +15 -0
- package/src/utils/swap.ts +82 -26
- package/src/utils/time.ts +69 -36
- package/src/utils/wallets.ts +49 -29
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts +0 -5
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts +0 -151
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts +0 -6
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/index.d.ts +0 -2
- package/dist/components/BlockchainsChip/index.d.ts.map +0 -1
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts +0 -3
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts +0 -4
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +0 -4
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts +0 -12
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/index.d.ts +0 -2
- package/dist/components/SelectableCategoryList/index.d.ts.map +0 -1
- package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +0 -30
- package/src/components/BlockchainsChip/BlockchainsChip.tsx +0 -15
- package/src/components/BlockchainsChip/BlockchainsChip.types.ts +0 -4
- package/src/components/BlockchainsChip/index.ts +0 -1
- package/src/components/BlockchainsSection/BlockchainSection.helpers.ts +0 -20
- package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +0 -20
- package/src/components/SelectableCategoryList/SelectableCategoryList.styles.ts +0 -21
- package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +0 -79
- package/src/components/SelectableCategoryList/SelectableCategoryList.types.ts +0 -12
- package/src/components/SelectableCategoryList/index.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropTypes } from './RouteErrors.types';
|
|
2
2
|
|
|
3
|
-
import { Alert, InfoIcon } from '@rango-dev/ui';
|
|
3
|
+
import { Alert, Divider, InfoIcon } from '@rango-dev/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
6
|
import { errorMessages } from '../../constants/errors';
|
|
@@ -23,37 +23,48 @@ export function RouteErrors(props: PropTypes) {
|
|
|
23
23
|
totalFeeInUsd,
|
|
24
24
|
outputUsdValue,
|
|
25
25
|
inputUsdValue,
|
|
26
|
+
loading,
|
|
27
|
+
extraSpace,
|
|
26
28
|
} = props;
|
|
27
29
|
const error = hasLimitError(bestRoute);
|
|
28
30
|
const { recommendation } = LimitErrorMessage(bestRoute);
|
|
29
31
|
|
|
32
|
+
const showWarnings = !error && (highValueLoss || priceImpactCanNotBeComputed);
|
|
33
|
+
const showAlerts = showWarnings || error;
|
|
34
|
+
|
|
30
35
|
return (
|
|
31
36
|
<>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
{(loading || (extraSpace && !showAlerts)) && <Divider size={20} />}
|
|
38
|
+
{showAlerts && (
|
|
39
|
+
<Alerts>
|
|
40
|
+
{showWarnings && (
|
|
41
|
+
<>
|
|
42
|
+
<Alert
|
|
43
|
+
title={
|
|
44
|
+
highValueLoss
|
|
45
|
+
? errorMessages.highValueLossError.title
|
|
46
|
+
: errorMessages.unknownPriceError.title
|
|
47
|
+
}
|
|
48
|
+
type={
|
|
49
|
+
highValueLoss && !!percentageChange?.lt(WARNING_LEVEL_LIMIT)
|
|
50
|
+
? 'error'
|
|
51
|
+
: 'warning'
|
|
52
|
+
}
|
|
53
|
+
variant="alarm"
|
|
54
|
+
action={
|
|
55
|
+
<Action onClick={() => onToggle(true)}>
|
|
56
|
+
<InfoIcon size={12} color="gray" />
|
|
57
|
+
</Action>
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
</>
|
|
61
|
+
)}
|
|
62
|
+
{error && (
|
|
63
|
+
<Alert type="error" variant="alarm" title={recommendation} />
|
|
64
|
+
)}
|
|
65
|
+
</Alerts>
|
|
66
|
+
)}
|
|
67
|
+
|
|
57
68
|
<RouteErrorsModal
|
|
58
69
|
highValueLoss={highValueLoss}
|
|
59
70
|
open={openModal}
|
|
@@ -9,11 +9,13 @@ export interface PropTypes {
|
|
|
9
9
|
percentageChange: BigNumber | null;
|
|
10
10
|
highValueLoss: boolean;
|
|
11
11
|
priceImpactCanNotBeComputed: boolean;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
extraSpace: boolean;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
type ModalPropTypesKeys = keyof Omit<
|
|
15
17
|
PropTypes,
|
|
16
|
-
'priceImpactCanNotBeComputed' | 'openModal'
|
|
18
|
+
'priceImpactCanNotBeComputed' | 'openModal' | 'extraSpace' | 'loading'
|
|
17
19
|
>;
|
|
18
20
|
|
|
19
21
|
export type ModalPropTypes = Pick<PropTypes, ModalPropTypesKeys> & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModalPropTypes } from './RouteErrors.types';
|
|
2
2
|
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
3
4
|
import {
|
|
4
5
|
Button,
|
|
5
6
|
Divider,
|
|
@@ -13,15 +14,20 @@ import { useNavigate } from 'react-router-dom';
|
|
|
13
14
|
|
|
14
15
|
import { errorMessages } from '../../constants/errors';
|
|
15
16
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
17
|
+
import {
|
|
18
|
+
GAS_FEE_MAX_DECIMALS,
|
|
19
|
+
GAS_FEE_MIN_DECIMALS,
|
|
20
|
+
HIGHT_PRICE_IMPACT,
|
|
21
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
22
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
23
|
+
USD_VALUE_MAX_DECIMALS,
|
|
24
|
+
USD_VALUE_MIN_DECIMALS,
|
|
25
|
+
} from '../../constants/routing';
|
|
16
26
|
import { numberToString } from '../../utils/numbers';
|
|
17
27
|
|
|
18
28
|
import { Flex } from './RouteErrors.styles';
|
|
19
29
|
import { RouteErrorsModalItem } from './RouteErrorsModalItem';
|
|
20
30
|
|
|
21
|
-
const WARNING_LEVEL_LIMIT = -10;
|
|
22
|
-
const MAX_DECIMAL = 2;
|
|
23
|
-
const MIN_DECIMAL = 0;
|
|
24
|
-
|
|
25
31
|
export function RouteErrorsModal(props: ModalPropTypes) {
|
|
26
32
|
const {
|
|
27
33
|
highValueLoss,
|
|
@@ -34,19 +40,41 @@ export function RouteErrorsModal(props: ModalPropTypes) {
|
|
|
34
40
|
} = props;
|
|
35
41
|
const navigate = useNavigate();
|
|
36
42
|
const type =
|
|
37
|
-
highValueLoss && !!percentageChange?.lt(
|
|
43
|
+
highValueLoss && !!percentageChange?.lt(HIGHT_PRICE_IMPACT)
|
|
38
44
|
? 'error'
|
|
39
45
|
: 'warning';
|
|
40
46
|
const highValueLossData = [
|
|
41
|
-
{ title: 'Swapping', value: numberToString(inputUsdValue) },
|
|
42
47
|
{
|
|
43
|
-
title: '
|
|
44
|
-
value: numberToString(
|
|
48
|
+
title: i18n.t('Swapping'),
|
|
49
|
+
value: numberToString(
|
|
50
|
+
inputUsdValue,
|
|
51
|
+
USD_VALUE_MIN_DECIMALS,
|
|
52
|
+
USD_VALUE_MAX_DECIMALS
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: i18n.t('Gas cost'),
|
|
57
|
+
value: numberToString(
|
|
58
|
+
totalFeeInUsd,
|
|
59
|
+
GAS_FEE_MIN_DECIMALS,
|
|
60
|
+
GAS_FEE_MAX_DECIMALS
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: i18n.t('Receiving'),
|
|
65
|
+
value: numberToString(
|
|
66
|
+
outputUsdValue,
|
|
67
|
+
USD_VALUE_MIN_DECIMALS,
|
|
68
|
+
USD_VALUE_MAX_DECIMALS
|
|
69
|
+
),
|
|
45
70
|
},
|
|
46
|
-
{ title: 'Receiving', value: numberToString(outputUsdValue) },
|
|
47
71
|
{
|
|
48
|
-
title: 'Price impact',
|
|
49
|
-
value: numberToString(
|
|
72
|
+
title: i18n.t('Price impact'),
|
|
73
|
+
value: numberToString(
|
|
74
|
+
percentageChange,
|
|
75
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
76
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
77
|
+
),
|
|
50
78
|
valueColor: `${type}500`,
|
|
51
79
|
},
|
|
52
80
|
];
|
|
@@ -59,13 +87,13 @@ export function RouteErrorsModal(props: ModalPropTypes) {
|
|
|
59
87
|
{highValueLoss ? (
|
|
60
88
|
<MessageBox
|
|
61
89
|
type={type}
|
|
62
|
-
title={errorMessages.highValueLossError.
|
|
90
|
+
title={errorMessages.highValueLossError.impactTitle}
|
|
63
91
|
description={errorMessages.highValueLossError.description}
|
|
64
92
|
/>
|
|
65
93
|
) : (
|
|
66
94
|
<MessageBox
|
|
67
95
|
type={type}
|
|
68
|
-
title={errorMessages.unknownPriceError.
|
|
96
|
+
title={errorMessages.unknownPriceError.impactTitle}
|
|
69
97
|
description={errorMessages.unknownPriceError.description}
|
|
70
98
|
/>
|
|
71
99
|
)}
|
|
@@ -73,7 +101,7 @@ export function RouteErrorsModal(props: ModalPropTypes) {
|
|
|
73
101
|
<Flex>
|
|
74
102
|
<Divider size={20} />
|
|
75
103
|
<Typography size="small" variant="title">
|
|
76
|
-
Details
|
|
104
|
+
{i18n.t('Details')}
|
|
77
105
|
</Typography>
|
|
78
106
|
<Flex>
|
|
79
107
|
{highValueLossData.map((item, index) => {
|
|
@@ -2,6 +2,7 @@ import { styled } from '@rango-dev/ui';
|
|
|
2
2
|
|
|
3
3
|
export const SettingsContainer = styled('div', {
|
|
4
4
|
height: '100%',
|
|
5
|
+
overflow: 'hidden',
|
|
5
6
|
});
|
|
6
7
|
|
|
7
8
|
export const LiquiditySourceList = styled('ul', {
|
|
@@ -9,15 +10,9 @@ export const LiquiditySourceList = styled('ul', {
|
|
|
9
10
|
margin: 0,
|
|
10
11
|
listStyle: 'none',
|
|
11
12
|
height: '100%',
|
|
12
|
-
overflowY: '
|
|
13
|
+
overflowY: 'auto',
|
|
13
14
|
});
|
|
14
15
|
|
|
15
|
-
export const LiquiditySourceDivider = styled('li', {
|
|
16
|
-
margin: '0 auto',
|
|
17
|
-
width: '100%',
|
|
18
|
-
height: '1px',
|
|
19
|
-
backgroundColor: '$neutral300',
|
|
20
|
-
});
|
|
21
16
|
export const LiquiditySourceSuffix = styled('div', {
|
|
22
17
|
width: 80,
|
|
23
18
|
display: 'flex',
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
SLIPPAGES,
|
|
16
16
|
} from '../../constants/swapSettings';
|
|
17
17
|
import { useSettingsStore } from '../../store/settings';
|
|
18
|
+
import { getContainer } from '../../utils/common';
|
|
18
19
|
|
|
19
20
|
import { BaseContainer, Head, SlippageChipsContainer } from './Slippage.styles';
|
|
20
21
|
import { SlippageTooltipContent } from './SlippageTooltipContent';
|
|
@@ -32,7 +33,10 @@ export function Slippage() {
|
|
|
32
33
|
{i18n.t('Slippage tolerance per swap')}
|
|
33
34
|
</Typography>
|
|
34
35
|
<Divider direction="horizontal" size={4} />
|
|
35
|
-
<Tooltip
|
|
36
|
+
<Tooltip
|
|
37
|
+
container={getContainer()}
|
|
38
|
+
side="top"
|
|
39
|
+
content={<SlippageTooltipContent />}>
|
|
36
40
|
<InfoIcon color="gray" />
|
|
37
41
|
</Tooltip>
|
|
38
42
|
</Head>
|
|
@@ -82,7 +86,7 @@ export function Slippage() {
|
|
|
82
86
|
</Typography>
|
|
83
87
|
)
|
|
84
88
|
}
|
|
85
|
-
placeholder=
|
|
89
|
+
placeholder={i18n.t('Custom')}
|
|
86
90
|
/>
|
|
87
91
|
</SlippageChipsContainer>
|
|
88
92
|
</BaseContainer>
|
|
@@ -7,7 +7,7 @@ import { SlippageTooltipContainer } from './Slippage.styles';
|
|
|
7
7
|
export function SlippageTooltipContent() {
|
|
8
8
|
return (
|
|
9
9
|
<SlippageTooltipContainer>
|
|
10
|
-
<Typography variant="label" size="
|
|
10
|
+
<Typography variant="label" size="medium" color="neutral900">
|
|
11
11
|
{i18n.t(
|
|
12
12
|
'Your transaction will be reverted if the price changes unfavorably by more than this percentage'
|
|
13
13
|
)}
|
|
@@ -1,43 +1,79 @@
|
|
|
1
1
|
import type { SwapDetailsPlaceholderPropTypes } from './SwapDetails.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CopyIcon,
|
|
6
|
+
IconButton,
|
|
7
|
+
NotFound,
|
|
8
|
+
Skeleton,
|
|
9
|
+
Typography,
|
|
10
|
+
} from '@rango-dev/ui';
|
|
5
11
|
import React from 'react';
|
|
6
12
|
|
|
7
13
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
8
14
|
import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
9
15
|
import { SuffixContainer } from '../HeaderButtons/HeaderButtons.styles';
|
|
10
16
|
import { Layout } from '../Layout';
|
|
17
|
+
import { LoadingSwapDetails } from '../LoadingSwapDetails';
|
|
11
18
|
|
|
12
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
Container,
|
|
21
|
+
HeaderDetails,
|
|
22
|
+
PlaceholderContainer,
|
|
23
|
+
} from './SwapDetails.styles';
|
|
13
24
|
|
|
14
25
|
export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
|
|
15
|
-
const { requestId,
|
|
26
|
+
const { requestId, showSkeleton } = props;
|
|
16
27
|
const { navigateBackFrom } = useNavigateBack();
|
|
17
28
|
|
|
18
29
|
return (
|
|
19
30
|
<Layout
|
|
31
|
+
noPadding
|
|
20
32
|
header={{
|
|
21
33
|
title: i18n.t('Swap and Bridge'),
|
|
22
34
|
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
|
|
23
35
|
suffix: <SuffixContainer />,
|
|
24
36
|
}}>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
{showSkeleton && (
|
|
38
|
+
<Container>
|
|
39
|
+
<HeaderDetails>
|
|
40
|
+
<div className="row">
|
|
41
|
+
<Typography variant="label" size="large" color="neutral900">
|
|
42
|
+
{`${i18n.t('Request ID')}:`}
|
|
43
|
+
</Typography>
|
|
44
|
+
<div className="request-id">
|
|
45
|
+
<Typography variant="label" size="small" color="neutral900">
|
|
46
|
+
<Skeleton width={60} height={10} variant="rounded" />
|
|
47
|
+
</Typography>
|
|
48
|
+
<IconButton variant="ghost">
|
|
49
|
+
<CopyIcon size={16} color="gray" />
|
|
50
|
+
</IconButton>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div className="row">
|
|
54
|
+
<Typography variant="label" size="large" color="neutral900">
|
|
55
|
+
{`${i18n.t('Created at')}:`}
|
|
56
|
+
</Typography>
|
|
57
|
+
<Typography variant="label" size="small" color="neutral900">
|
|
58
|
+
<Skeleton width={60} height={10} variant="rounded" />
|
|
59
|
+
</Typography>
|
|
60
|
+
</div>
|
|
61
|
+
</HeaderDetails>
|
|
62
|
+
<LoadingSwapDetails />
|
|
63
|
+
</Container>
|
|
64
|
+
)}
|
|
65
|
+
{!showSkeleton && (
|
|
66
|
+
<PlaceholderContainer>
|
|
31
67
|
<NotFound
|
|
32
68
|
title={i18n.t('Not found')}
|
|
33
|
-
description={i18n.t(
|
|
34
|
-
'swapNotFound',
|
|
35
|
-
{ requestId },
|
|
36
|
-
|
|
37
|
-
)}
|
|
69
|
+
description={i18n.t({
|
|
70
|
+
id: 'swapNotFound',
|
|
71
|
+
values: { requestId },
|
|
72
|
+
message: 'Swap with request ID = {requestId} not found.',
|
|
73
|
+
})}
|
|
38
74
|
/>
|
|
39
|
-
|
|
40
|
-
|
|
75
|
+
</PlaceholderContainer>
|
|
76
|
+
)}
|
|
41
77
|
</Layout>
|
|
42
78
|
);
|
|
43
79
|
}
|
|
@@ -1,61 +1,58 @@
|
|
|
1
1
|
import type { GetStep } from '../SwapDetailsAlerts';
|
|
2
2
|
import type { PendingSwapStep } from '@rango-dev/queue-manager-rango-preset';
|
|
3
|
-
import type {
|
|
4
|
-
PriceImpactWarningLevel,
|
|
5
|
-
Step,
|
|
6
|
-
StepDetailsProps,
|
|
7
|
-
} from '@rango-dev/ui';
|
|
8
|
-
import type BigNumber from 'bignumber.js';
|
|
3
|
+
import type { Step, StepDetailsProps } from '@rango-dev/ui';
|
|
9
4
|
|
|
10
5
|
import React from 'react';
|
|
11
6
|
|
|
7
|
+
import {
|
|
8
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
9
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
10
|
+
} from '../../constants/routing';
|
|
11
|
+
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
12
12
|
import { numberToString } from '../../utils/numbers';
|
|
13
13
|
import { isNetworkStatusInWarningState } from '../../utils/swap';
|
|
14
14
|
import { SwapDetailsAlerts } from '../SwapDetailsAlerts';
|
|
15
15
|
|
|
16
|
-
export const LOW_PRICE_IMPACT = 3;
|
|
17
|
-
export const HIGHT_PRICE_IMPACT = 10;
|
|
18
16
|
export const RESET_INTERVAL = 2_000;
|
|
19
|
-
export const MIN_DECIMALS = 0;
|
|
20
|
-
export const AMOUNT_DECIMALS = 4;
|
|
21
|
-
export const PERCENT_DECIMALS = 2;
|
|
22
17
|
export const SECONDS = 60;
|
|
23
18
|
|
|
24
|
-
export const getSteps = ({ swap, ...args }: GetStep): Step[] => {
|
|
19
|
+
export const getSteps = ({ swap, blockchains, ...args }: GetStep): Step[] => {
|
|
25
20
|
const hasAlreadyProceededToSign = swap.hasAlreadyProceededToSign !== false;
|
|
26
21
|
return swap.steps.map((step, index) => {
|
|
27
22
|
const amountToConvert =
|
|
28
23
|
index === 0 ? swap.inputAmount : swap.steps[index - 1].outputAmount;
|
|
29
24
|
return {
|
|
30
25
|
from: {
|
|
31
|
-
token: { displayName: step.fromSymbol, image: step.fromLogo },
|
|
26
|
+
token: { displayName: step.fromSymbol, image: step.fromLogo ?? '' },
|
|
32
27
|
chain: {
|
|
33
|
-
displayName:
|
|
34
|
-
|
|
28
|
+
displayName:
|
|
29
|
+
getBlockchainShortNameFor(step.fromBlockchain, blockchains) ?? '',
|
|
30
|
+
image: step.fromBlockchainLogo ?? '',
|
|
35
31
|
},
|
|
36
32
|
price: {
|
|
37
33
|
value: numberToString(
|
|
38
34
|
amountToConvert,
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
36
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
41
37
|
),
|
|
42
38
|
},
|
|
43
39
|
},
|
|
44
40
|
to: {
|
|
45
41
|
token: { displayName: step.toSymbol, image: step.toLogo },
|
|
46
42
|
chain: {
|
|
47
|
-
displayName:
|
|
48
|
-
|
|
43
|
+
displayName:
|
|
44
|
+
getBlockchainShortNameFor(step.toBlockchain, blockchains) ?? '',
|
|
45
|
+
image: step.toBlockchainLogo ?? '',
|
|
49
46
|
},
|
|
50
47
|
price: {
|
|
51
48
|
value: numberToString(
|
|
52
49
|
step.outputAmount || step.expectedOutputAmountHumanReadable,
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
51
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
55
52
|
),
|
|
56
53
|
},
|
|
57
54
|
},
|
|
58
|
-
swapper: { displayName: step.swapperId, image: step.swapperLogo },
|
|
55
|
+
swapper: { displayName: step.swapperId, image: step.swapperLogo ?? '' },
|
|
59
56
|
alerts: (
|
|
60
57
|
<SwapDetailsAlerts
|
|
61
58
|
step={step}
|
|
@@ -67,17 +64,6 @@ export const getSteps = ({ swap, ...args }: GetStep): Step[] => {
|
|
|
67
64
|
});
|
|
68
65
|
};
|
|
69
66
|
|
|
70
|
-
export const getPriceImpactWarningLevel = (
|
|
71
|
-
priceImpact: BigNumber | null
|
|
72
|
-
): PriceImpactWarningLevel | undefined => {
|
|
73
|
-
if (!priceImpact) {
|
|
74
|
-
return undefined;
|
|
75
|
-
} else if (priceImpact.lt(LOW_PRICE_IMPACT)) {
|
|
76
|
-
return 'low';
|
|
77
|
-
}
|
|
78
|
-
return 'high';
|
|
79
|
-
};
|
|
80
|
-
|
|
81
67
|
export function getStepState(step: PendingSwapStep): StepDetailsProps['state'] {
|
|
82
68
|
if (
|
|
83
69
|
isNetworkStatusInWarningState(step) &&
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { styled } from '@rango-dev/ui';
|
|
1
|
+
import { darkTheme, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const Container = styled('div', {
|
|
4
4
|
display: 'flex',
|
|
5
5
|
width: '100%',
|
|
6
6
|
flexDirection: 'column',
|
|
7
|
-
justifyContent: 'center',
|
|
8
7
|
alignItems: 'center',
|
|
9
8
|
height: '0',
|
|
10
9
|
flexGrow: 1,
|
|
@@ -13,8 +12,13 @@ export const Container = styled('div', {
|
|
|
13
12
|
width: '100%',
|
|
14
13
|
justifyContent: 'space-between',
|
|
15
14
|
alignItems: 'center',
|
|
16
|
-
padding: '$10 $
|
|
17
|
-
borderBottom: '1px solid
|
|
15
|
+
padding: '$10 $20',
|
|
16
|
+
borderBottom: '1px solid',
|
|
17
|
+
$$color: '$colors$neutral300',
|
|
18
|
+
[`.${darkTheme} &`]: {
|
|
19
|
+
$$color: '$colors$neutral400',
|
|
20
|
+
},
|
|
21
|
+
borderColor: '$$color',
|
|
18
22
|
color: '$neutral500',
|
|
19
23
|
},
|
|
20
24
|
'& .request-id': {
|
|
@@ -37,20 +41,12 @@ export const Container = styled('div', {
|
|
|
37
41
|
},
|
|
38
42
|
});
|
|
39
43
|
|
|
40
|
-
export const Separator = styled('div', {
|
|
41
|
-
height: '$12',
|
|
42
|
-
marginRight: '$10',
|
|
43
|
-
borderLeft: '1px solid $neutral900',
|
|
44
|
-
marginLeft: '$14',
|
|
45
|
-
});
|
|
46
|
-
|
|
47
44
|
export const HeaderDetails = styled('div', {
|
|
48
45
|
width: '100%',
|
|
49
|
-
padding: '0px 15px',
|
|
50
46
|
});
|
|
51
47
|
|
|
52
48
|
export const StepsList = styled('div', {
|
|
53
|
-
padding: '0 $20 $20',
|
|
49
|
+
padding: '$0 $20 $20 $20',
|
|
54
50
|
width: '100%',
|
|
55
51
|
overflow: 'auto',
|
|
56
52
|
});
|
|
@@ -64,7 +60,7 @@ export const PlaceholderContainer = styled('div', {
|
|
|
64
60
|
height: '450px',
|
|
65
61
|
display: 'flex',
|
|
66
62
|
alignItems: 'center',
|
|
67
|
-
|
|
63
|
+
justifyContent: 'center',
|
|
68
64
|
});
|
|
69
65
|
|
|
70
66
|
export const LoaderContainer = styled('div', {
|