@rango-dev/widget-embedded 0.17.1-next.9 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/QueueManager.d.ts +1 -2
  3. package/dist/QueueManager.d.ts.map +1 -1
  4. package/dist/Wallets.d.ts +0 -1
  5. package/dist/Wallets.d.ts.map +1 -1
  6. package/dist/Widget.d.ts +1 -1
  7. package/dist/Widget.d.ts.map +1 -1
  8. package/dist/components/AppRouter.d.ts +2 -0
  9. package/dist/components/AppRouter.d.ts.map +1 -1
  10. package/dist/components/AppRoutes.d.ts +6 -1
  11. package/dist/components/AppRoutes.d.ts.map +1 -1
  12. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
  13. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  14. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  15. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  16. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
  17. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  18. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  19. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
  20. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  21. package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
  22. package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
  23. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
  24. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
  25. package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
  26. package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
  27. package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
  28. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
  29. package/dist/components/NoRoutes/index.d.ts +2 -0
  30. package/dist/components/NoRoutes/index.d.ts.map +1 -0
  31. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  32. package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
  33. package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
  34. package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
  35. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
  36. package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
  37. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
  38. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
  39. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
  40. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
  41. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
  42. package/dist/components/RouteErrors/index.d.ts +2 -0
  43. package/dist/components/RouteErrors/index.d.ts.map +1 -0
  44. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  45. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  46. package/dist/components/UpdateUrl.d.ts +6 -1
  47. package/dist/components/UpdateUrl.d.ts.map +1 -1
  48. package/dist/components/WidgetEvents.d.ts.map +1 -1
  49. package/dist/constants/errors.d.ts +4 -4
  50. package/dist/constants/errors.d.ts.map +1 -1
  51. package/dist/constants/messages.d.ts +1 -1
  52. package/dist/constants/searchParams.d.ts +1 -2
  53. package/dist/constants/searchParams.d.ts.map +1 -1
  54. package/dist/constants/warnings.d.ts +2 -2
  55. package/dist/constants/warnings.d.ts.map +1 -1
  56. package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
  57. package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
  58. package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
  59. package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
  60. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  61. package/dist/hooks/useSwapInput.d.ts +2 -4
  62. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  63. package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
  64. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  65. package/dist/hooks/useWalletList.d.ts.map +1 -1
  66. package/dist/index.js +1 -1
  67. package/dist/index.js.map +4 -4
  68. package/dist/pages/ConfirmSwapPage.d.ts +6 -1
  69. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  70. package/dist/pages/Home.d.ts.map +1 -1
  71. package/dist/pages/LiquiditySourcePage.d.ts +2 -1
  72. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  73. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  74. package/dist/pages/SettingsPage.d.ts +6 -1
  75. package/dist/pages/SettingsPage.d.ts.map +1 -1
  76. package/dist/pages/WalletsPage.d.ts +8 -1
  77. package/dist/pages/WalletsPage.d.ts.map +1 -1
  78. package/dist/store/app.d.ts +23 -5
  79. package/dist/store/app.d.ts.map +1 -1
  80. package/dist/store/{quote.d.ts → bestRoute.d.ts} +27 -39
  81. package/dist/store/bestRoute.d.ts.map +1 -0
  82. package/dist/store/meta.d.ts +23 -0
  83. package/dist/store/meta.d.ts.map +1 -0
  84. package/dist/store/settings.d.ts +2 -3
  85. package/dist/store/settings.d.ts.map +1 -1
  86. package/dist/store/slices/config.d.ts +2 -3
  87. package/dist/store/slices/config.d.ts.map +1 -1
  88. package/dist/store/slices/data.d.ts +0 -3
  89. package/dist/store/slices/data.d.ts.map +1 -1
  90. package/dist/store/wallets.d.ts +4 -5
  91. package/dist/store/wallets.d.ts.map +1 -1
  92. package/dist/types/config.d.ts +5 -5
  93. package/dist/types/config.d.ts.map +1 -1
  94. package/dist/types/index.d.ts +1 -1
  95. package/dist/types/index.d.ts.map +1 -1
  96. package/dist/types/routing.d.ts +65 -0
  97. package/dist/types/routing.d.ts.map +1 -0
  98. package/dist/utils/numbers.d.ts +1 -1
  99. package/dist/utils/numbers.d.ts.map +1 -1
  100. package/dist/utils/{quote.d.ts → routing.d.ts} +12 -16
  101. package/dist/utils/routing.d.ts.map +1 -0
  102. package/dist/utils/settings.d.ts +2 -3
  103. package/dist/utils/settings.d.ts.map +1 -1
  104. package/dist/utils/swap.d.ts +22 -25
  105. package/dist/utils/swap.d.ts.map +1 -1
  106. package/dist/utils/wallets.d.ts +2 -2
  107. package/dist/utils/wallets.d.ts.map +1 -1
  108. package/package.json +8 -8
  109. package/src/QueueManager.tsx +14 -14
  110. package/src/Wallets.tsx +15 -35
  111. package/src/Widget.tsx +24 -11
  112. package/src/components/AppRouter.tsx +5 -6
  113. package/src/components/AppRoutes.tsx +39 -6
  114. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  115. package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
  116. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
  117. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +40 -28
  118. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
  119. package/src/components/ConfirmWalletsModal/WalletList.tsx +5 -6
  120. package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
  121. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
  122. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
  123. package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +9 -16
  124. package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
  125. package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +12 -10
  126. package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
  127. package/src/components/NoRoutes/index.ts +1 -0
  128. package/src/components/NotificationContent/NotificationContent.tsx +2 -3
  129. package/src/components/RouteErrors/RouteErrors.tsx +79 -0
  130. package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
  131. package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
  132. package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +3 -3
  133. package/src/components/RouteErrors/index.ts +1 -0
  134. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  135. package/src/components/SwapDetails/SwapDetails.tsx +22 -18
  136. package/src/components/SwitchFromAndTo.tsx +2 -2
  137. package/src/components/TokenList/TokenList.tsx +6 -5
  138. package/src/components/UpdateUrl.tsx +26 -36
  139. package/src/components/WidgetEvents.tsx +2 -4
  140. package/src/constants/errors.ts +10 -8
  141. package/src/constants/messages.ts +1 -1
  142. package/src/constants/searchParams.ts +0 -1
  143. package/src/constants/warnings.ts +7 -7
  144. package/src/hooks/useConfirmSwap.ts +303 -0
  145. package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
  146. package/src/hooks/useNavigateBack.ts +3 -3
  147. package/src/hooks/useSwapInput.ts +23 -58
  148. package/src/hooks/useSyncStoresWithConfig.ts +19 -22
  149. package/src/hooks/useWalletList.ts +5 -3
  150. package/src/pages/ConfirmSwapPage.tsx +235 -58
  151. package/src/pages/HistoryPage.tsx +1 -1
  152. package/src/pages/Home.tsx +247 -58
  153. package/src/pages/LanguagePage.tsx +1 -1
  154. package/src/pages/LiquiditySourcePage.tsx +32 -23
  155. package/src/pages/SelectBlockchainPage.tsx +7 -6
  156. package/src/pages/SelectSwapItemsPage.tsx +5 -5
  157. package/src/pages/SettingsPage.tsx +13 -9
  158. package/src/pages/SwapDetailsPage.tsx +3 -3
  159. package/src/pages/ThemePage.tsx +1 -1
  160. package/src/pages/WalletsPage.tsx +12 -5
  161. package/src/store/app.ts +6 -18
  162. package/src/store/{quote.ts → bestRoute.ts} +60 -68
  163. package/src/store/meta.ts +39 -0
  164. package/src/store/settings.ts +4 -7
  165. package/src/store/slices/config.ts +15 -25
  166. package/src/store/slices/data.ts +29 -64
  167. package/src/store/wallets.ts +8 -11
  168. package/src/types/config.ts +5 -5
  169. package/src/types/index.ts +1 -1
  170. package/src/types/routing.ts +77 -0
  171. package/src/utils/numbers.ts +1 -1
  172. package/src/utils/routing.ts +321 -0
  173. package/src/utils/settings.ts +7 -8
  174. package/src/utils/swap.ts +85 -113
  175. package/src/utils/wallets.ts +17 -29
  176. package/dist/components/NoResult/NoResult.d.ts +0 -4
  177. package/dist/components/NoResult/NoResult.d.ts.map +0 -1
  178. package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
  179. package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
  180. package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
  181. package/dist/components/NoResult/index.d.ts +0 -2
  182. package/dist/components/NoResult/index.d.ts.map +0 -1
  183. package/dist/components/Quote/Quote.d.ts +0 -4
  184. package/dist/components/Quote/Quote.d.ts.map +0 -1
  185. package/dist/components/Quote/Quote.styles.d.ts +0 -1429
  186. package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
  187. package/dist/components/Quote/Quote.types.d.ts +0 -22
  188. package/dist/components/Quote/Quote.types.d.ts.map +0 -1
  189. package/dist/components/Quote/QuoteSkeleton.d.ts +0 -4
  190. package/dist/components/Quote/QuoteSkeleton.d.ts.map +0 -1
  191. package/dist/components/Quote/QuoteSkeleton.styles.d.ts +0 -319
  192. package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +0 -1
  193. package/dist/components/Quote/QuoteSkeleton.types.d.ts +0 -6
  194. package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +0 -1
  195. package/dist/components/Quote/QuoteSummary.d.ts +0 -11
  196. package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
  197. package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -158
  198. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
  199. package/dist/components/Quote/index.d.ts +0 -4
  200. package/dist/components/Quote/index.d.ts.map +0 -1
  201. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
  202. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
  203. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
  204. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
  205. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
  206. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
  207. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
  208. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
  209. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
  210. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -22
  211. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
  212. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
  213. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
  214. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
  215. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
  216. package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
  217. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
  218. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
  219. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
  220. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -472
  221. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
  222. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -17
  223. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
  224. package/dist/containers/QuoteInfo/index.d.ts +0 -2
  225. package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
  226. package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
  227. package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
  228. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
  229. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
  230. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -16
  231. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
  232. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
  233. package/dist/hooks/useFetchQuote.d.ts.map +0 -1
  234. package/dist/hooks/useForceAutoConnect.d.ts +0 -2
  235. package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
  236. package/dist/store/AppStore.d.ts +0 -11
  237. package/dist/store/AppStore.d.ts.map +0 -1
  238. package/dist/store/quote.d.ts.map +0 -1
  239. package/dist/types/quote.d.ts +0 -82
  240. package/dist/types/quote.d.ts.map +0 -1
  241. package/dist/utils/quote.d.ts.map +0 -1
  242. package/src/components/NoResult/index.ts +0 -1
  243. package/src/components/Quote/Quote.styles.ts +0 -212
  244. package/src/components/Quote/Quote.tsx +0 -345
  245. package/src/components/Quote/Quote.types.ts +0 -16
  246. package/src/components/Quote/QuoteSkeleton.styles.ts +0 -110
  247. package/src/components/Quote/QuoteSkeleton.tsx +0 -108
  248. package/src/components/Quote/QuoteSkeleton.types.ts +0 -5
  249. package/src/components/Quote/QuoteSummary.styles.ts +0 -15
  250. package/src/components/Quote/QuoteSummary.tsx +0 -46
  251. package/src/components/Quote/index.ts +0 -3
  252. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
  253. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -67
  254. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
  255. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -24
  256. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
  257. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
  258. package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
  259. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -15
  260. package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -97
  261. package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -17
  262. package/src/containers/QuoteInfo/index.ts +0 -1
  263. package/src/hooks/useConfirmSwap/index.ts +0 -1
  264. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -168
  265. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -136
  266. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
  267. package/src/hooks/useForceAutoConnect.ts +0 -27
  268. package/src/store/AppStore.tsx +0 -35
  269. package/src/types/quote.ts +0 -107
  270. package/src/utils/quote.ts +0 -338
  271. /package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +0 -0
@@ -0,0 +1,129 @@
1
+ import type { ModalPropTypes } from './RouteErrors.types';
2
+
3
+ import { i18n } from '@lingui/core';
4
+ import {
5
+ Button,
6
+ Divider,
7
+ MessageBox,
8
+ Modal,
9
+ Typography,
10
+ WarningIcon,
11
+ } from '@rango-dev/ui';
12
+ import React from 'react';
13
+ import { useNavigate } from 'react-router-dom';
14
+
15
+ import { errorMessages } from '../../constants/errors';
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';
26
+ import { numberToString } from '../../utils/numbers';
27
+
28
+ import { Flex } from './RouteErrors.styles';
29
+ import { RouteErrorsModalItem } from './RouteErrorsModalItem';
30
+
31
+ export function RouteErrorsModal(props: ModalPropTypes) {
32
+ const {
33
+ highValueLoss,
34
+ open,
35
+ onToggle,
36
+ percentageChange,
37
+ inputUsdValue,
38
+ outputUsdValue,
39
+ totalFeeInUsd,
40
+ } = props;
41
+ const navigate = useNavigate();
42
+ const type =
43
+ highValueLoss && !!percentageChange?.lt(HIGHT_PRICE_IMPACT)
44
+ ? 'error'
45
+ : 'warning';
46
+ const highValueLossData = [
47
+ {
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
+ ),
70
+ },
71
+ {
72
+ title: i18n.t('Price impact'),
73
+ value: numberToString(
74
+ percentageChange,
75
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
76
+ PERCENTAGE_CHANGE_MAX_DECIMALS
77
+ ),
78
+ valueColor: `${type}500`,
79
+ },
80
+ ];
81
+
82
+ return (
83
+ <Modal
84
+ open={open}
85
+ onClose={() => onToggle(false)}
86
+ container={document.getElementById('swap-box') || document.body}>
87
+ {highValueLoss ? (
88
+ <MessageBox
89
+ type={type}
90
+ title={errorMessages().highValueLossError.impactTitle}
91
+ description={errorMessages().highValueLossError.description}
92
+ />
93
+ ) : (
94
+ <MessageBox
95
+ type={type}
96
+ title={errorMessages().unknownPriceError.impactTitle}
97
+ description={errorMessages().unknownPriceError.description}
98
+ />
99
+ )}
100
+ {highValueLoss && (
101
+ <Flex>
102
+ <Divider size={20} />
103
+ <Typography size="small" variant="title">
104
+ {i18n.t('Details')}
105
+ </Typography>
106
+ <Flex>
107
+ {highValueLossData.map((item, index) => {
108
+ const key = index;
109
+ return <RouteErrorsModalItem key={key} {...item} />;
110
+ })}
111
+ </Flex>
112
+ </Flex>
113
+ )}
114
+ <Divider size={32} />
115
+ <Button
116
+ type="primary"
117
+ size="large"
118
+ prefix={<WarningIcon />}
119
+ fullWidth
120
+ onClick={() => {
121
+ navigate(navigationRoutes.confirmSwap);
122
+ }}>
123
+ {highValueLoss
124
+ ? errorMessages().highValueLossError.confirmMessage
125
+ : errorMessages().unknownPriceError.confirmMessage}
126
+ </Button>
127
+ </Modal>
128
+ );
129
+ }
@@ -1,11 +1,11 @@
1
- import type { ModalContentData } from './QuoteWarningsAndErrors.types';
1
+ import type { ModalContentData } from './RouteErrors.types';
2
2
 
3
3
  import { Typography } from '@rango-dev/ui';
4
4
  import React from 'react';
5
5
 
6
- import { Item } from './QuoteWarningsAndErrors.styles';
6
+ import { Item } from './RouteErrors.styles';
7
7
 
8
- export function QuoteErrorsModalItem(props: ModalContentData) {
8
+ export function RouteErrorsModalItem(props: ModalContentData) {
9
9
  const { title, value, valueColor } = props;
10
10
 
11
11
  return (
@@ -0,0 +1 @@
1
+ export { RouteErrors } from './RouteErrors';
@@ -31,7 +31,7 @@ export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
31
31
  noPadding
32
32
  header={{
33
33
  title: i18n.t('Swap and Bridge'),
34
- onBack: () => navigateBackFrom(navigationRoutes.swapDetails),
34
+ onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
35
35
  suffix: <SuffixContainer />,
36
36
  }}>
37
37
  {showSkeleton && (
@@ -13,7 +13,8 @@ import {
13
13
  CopyIcon,
14
14
  Divider,
15
15
  IconButton,
16
- QuoteCost,
16
+ RouteCost,
17
+ RouteSummary,
17
18
  StepDetails,
18
19
  Typography,
19
20
  useCopyToClipboard,
@@ -34,17 +35,18 @@ import {
34
35
  USD_VALUE_MIN_DECIMALS,
35
36
  } from '../../constants/routing';
36
37
  import { useNavigateBack } from '../../hooks/useNavigateBack';
37
- import { useAppStore } from '../../store/AppStore';
38
+ import { useBestRouteStore } from '../../store/bestRoute';
39
+ import { useMetaStore } from '../../store/meta';
38
40
  import { useNotificationStore } from '../../store/notification';
39
- import { useQuoteStore } from '../../store/quote';
40
41
  import {
41
42
  numberToString,
42
43
  secondsToString,
43
44
  totalArrivalTime,
44
45
  } from '../../utils/numbers';
45
- import { getPriceImpact, getPriceImpactLevel } from '../../utils/quote';
46
+ import { getPriceImpactLevel } from '../../utils/routing';
46
47
  import {
47
48
  getLastConvertedTokenInFailedSwap,
49
+ getPercentageChange,
48
50
  getSwapMessages,
49
51
  shouldRetrySwap,
50
52
  } from '../../utils/swap';
@@ -52,7 +54,6 @@ import { getSwapDate } from '../../utils/time';
52
54
  import { getConciseAddress, getUsdPrice } from '../../utils/wallets';
53
55
  import { SuffixContainer } from '../HeaderButtons/HeaderButtons.styles';
54
56
  import { Layout } from '../Layout';
55
- import { QuoteSummary } from '../Quote';
56
57
  import {
57
58
  SwapDetailsCompleteModal,
58
59
  SwapDetailsModal,
@@ -64,9 +65,7 @@ import { Container, HeaderDetails, StepsList } from './SwapDetails.styles';
64
65
  export function SwapDetails(props: SwapDetailsProps) {
65
66
  const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
66
67
  const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
67
- const blockchains = useAppStore().blockchains();
68
- const tokens = useAppStore().tokens();
69
- const retry = useQuoteStore.use.retry();
68
+ const retry = useBestRouteStore.use.retry();
70
69
  const navigate = useNavigate();
71
70
  const { navigateBackFrom } = useNavigateBack();
72
71
  const [_, handleCopy] = useCopyToClipboard(RESET_INTERVAL);
@@ -75,6 +74,9 @@ export function SwapDetails(props: SwapDetailsProps) {
75
74
  const [showCompletedModal, setShowCompletedModal] = useState<
76
75
  'success' | 'failed' | null
77
76
  >(null);
77
+ const {
78
+ meta: { tokens, blockchains },
79
+ } = useMetaStore();
78
80
 
79
81
  const onCancel = () => {
80
82
  onCancelProps();
@@ -149,7 +151,7 @@ export function SwapDetails(props: SwapDetailsProps) {
149
151
  showNetworkModal: currentStepNetworkStatus,
150
152
  setNetworkModal: setModalState,
151
153
  message: stepMessage,
152
- blockchains: blockchains,
154
+ blockchains,
153
155
  });
154
156
  const numberOfSteps = steps.length;
155
157
  const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
@@ -199,7 +201,7 @@ export function SwapDetails(props: SwapDetailsProps) {
199
201
  USD_VALUE_MAX_DECIMALS
200
202
  );
201
203
 
202
- const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
204
+ const percentageChange = getPercentageChange(inputUsdValue, outputUsdValue);
203
205
 
204
206
  const completeModalDesc =
205
207
  swap.status === 'success'
@@ -237,7 +239,7 @@ export function SwapDetails(props: SwapDetailsProps) {
237
239
  noPadding
238
240
  header={{
239
241
  title: i18n.t('Swap and Bridge'),
240
- onBack: () => navigateBackFrom(navigationRoutes.swapDetails),
242
+ onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
241
243
  onCancel:
242
244
  swap.status === 'running' ? () => setModalState('cancel') : undefined,
243
245
  suffix: swap.status !== 'running' && (
@@ -263,7 +265,7 @@ export function SwapDetails(props: SwapDetailsProps) {
263
265
  type="primary"
264
266
  size="large"
265
267
  onClick={() => {
266
- retry(swap, { blockchains: blockchains, tokens: tokens });
268
+ retry(swap);
267
269
  setTimeout(() => {
268
270
  navigate(navigationRoutes.home);
269
271
  }, 0);
@@ -300,7 +302,7 @@ export function SwapDetails(props: SwapDetailsProps) {
300
302
  </HeaderDetails>
301
303
 
302
304
  <div className="output">
303
- <QuoteCost
305
+ <RouteCost
304
306
  fee={numberToString(
305
307
  String(totalFee),
306
308
  GAS_FEE_MIN_DECIMALS,
@@ -309,7 +311,7 @@ export function SwapDetails(props: SwapDetailsProps) {
309
311
  time={secondsToString(totalArrivalTime(swap.steps))}
310
312
  steps={numberOfSteps}
311
313
  />
312
- <QuoteSummary
314
+ <RouteSummary
313
315
  from={{
314
316
  price: {
315
317
  value: numberToString(
@@ -347,11 +349,13 @@ export function SwapDetails(props: SwapDetailsProps) {
347
349
  },
348
350
  }}
349
351
  percentageChange={numberToString(
350
- String(percentageChange),
352
+ percentageChange,
351
353
  PERCENTAGE_CHANGE_MIN_DECIMALS,
352
354
  PERCENTAGE_CHANGE_MAX_DECIMALS
353
355
  )}
354
- warningLevel={getPriceImpactLevel(percentageChange ?? 0)}
356
+ warningLevel={getPriceImpactLevel(
357
+ percentageChange?.toNumber() ?? 0
358
+ )}
355
359
  />
356
360
  </div>
357
361
  <div className="title-steps">
@@ -373,7 +377,7 @@ export function SwapDetails(props: SwapDetailsProps) {
373
377
  <StepDetails
374
378
  key={key}
375
379
  step={step}
376
- type="swap-progress"
380
+ type="route-progress"
377
381
  ref={listRef}
378
382
  state={state}
379
383
  hasSeparator={index !== 0}
@@ -405,7 +409,7 @@ export function SwapDetails(props: SwapDetailsProps) {
405
409
  )}
406
410
  usdValue={outputUsdValue}
407
411
  percentageChange={numberToString(
408
- String(percentageChange),
412
+ percentageChange,
409
413
  PERCENTAGE_CHANGE_MIN_DECIMALS,
410
414
  PERCENTAGE_CHANGE_MAX_DECIMALS
411
415
  )}
@@ -1,7 +1,7 @@
1
1
  import { ReverseIcon, styled } from '@rango-dev/ui';
2
2
  import React from 'react';
3
3
 
4
- import { useQuoteStore } from '../store/quote';
4
+ import { useBestRouteStore } from '../store/bestRoute';
5
5
 
6
6
  const SwitchButtonContainer = styled('div', {
7
7
  position: 'absolute',
@@ -27,7 +27,7 @@ const StyledButton = styled('div', {
27
27
  });
28
28
 
29
29
  export function SwitchFromAndToButton() {
30
- const switchFromAndTo = useQuoteStore.use.switchFromAndTo();
30
+ const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
31
31
 
32
32
  return (
33
33
  <SwitchButtonContainer>
@@ -21,7 +21,8 @@ import {
21
21
  } from '@rango-dev/ui';
22
22
  import React, { forwardRef, useEffect, useState } from 'react';
23
23
 
24
- import { useAppStore } from '../../store/AppStore';
24
+ import { useAppStore } from '../../store/app';
25
+ import { useMetaStore } from '../../store/meta';
25
26
  import { useWalletsStore } from '../../store/wallets';
26
27
  import { generateRangeColors } from '../../utils/colors';
27
28
 
@@ -86,10 +87,10 @@ export function TokenList(props: PropTypes) {
86
87
  const { list, searchedFor = '', onChange, selectedBlockchain } = props;
87
88
 
88
89
  const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
89
- const fetchStatus = useAppStore().fetchStatus;
90
- const blockchains = useAppStore().blockchains();
90
+ const loadingStatus = useMetaStore.use.loadingStatus();
91
91
  const [hasNextPage, setHasNextPage] = useState<boolean>(true);
92
92
  const loadingWallet = useWalletsStore.use.loading();
93
+ const { blockchains } = useMetaStore.use.meta();
93
94
  const { isTokenPinned } = useAppStore();
94
95
 
95
96
  // eslint-disable-next-line react/display-name
@@ -267,8 +268,8 @@ export function TokenList(props: PropTypes) {
267
268
  {i18n.t('Select Token')}
268
269
  </Typography>
269
270
  <Divider size={4} />
270
- {fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
271
- {fetchStatus === 'success' && <List>{renderList()}</List>}
271
+ {loadingStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
272
+ {loadingStatus === 'success' && <List>{renderList()}</List>}
272
273
  </Container>
273
274
  );
274
275
  }
@@ -1,3 +1,5 @@
1
+ import type { WidgetConfig } from '../types';
2
+
1
3
  import { useEffect, useRef } from 'react';
2
4
  import {
3
5
  createSearchParams,
@@ -8,32 +10,33 @@ import {
8
10
  import { navigationRoutes } from '../constants/navigationRoutes';
9
11
  import { SearchParams } from '../constants/searchParams';
10
12
  import { useSyncStoresWithConfig } from '../hooks/useSyncStoresWithConfig';
11
- import { useAppStore } from '../store/AppStore';
12
- import { useQuoteStore } from '../store/quote';
13
+ import { useBestRouteStore } from '../store/bestRoute';
14
+ import { useMetaStore } from '../store/meta';
13
15
  import { useUiStore } from '../store/ui';
14
- import { searchParamsToToken } from '../utils/quote';
16
+ import { searchParamsToToken } from '../utils/routing';
17
+
18
+ type Props = { config: WidgetConfig | undefined };
15
19
 
16
- export function UpdateUrl() {
20
+ export function UpdateUrl(props: Props) {
17
21
  const firstRender = useRef(true);
18
22
  const [searchParams, setSearchParams] = useSearchParams();
19
23
  const location = useLocation();
20
24
  const firstRenderSearchParams = useRef(location.search);
21
25
  const searchParamsRef = useRef<Record<string, string>>({});
22
- const fromBlockchain = useQuoteStore.use.fromBlockchain();
23
- const toBlockchain = useQuoteStore.use.toBlockchain();
24
- const fromToken = useQuoteStore.use.fromToken();
25
- const toToken = useQuoteStore.use.toToken();
26
- const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
27
- const setFromToken = useQuoteStore.use.setFromToken();
28
- const setToBlockchain = useQuoteStore.use.setToBlockchain();
29
- const setToToken = useQuoteStore.use.setToToken();
30
- const inputAmount = useQuoteStore.use.inputAmount();
31
- const setInputAmount = useQuoteStore.use.setInputAmount();
32
- const fetchMetaStatus = useAppStore().fetchStatus;
33
- const blockchains = useAppStore().blockchains();
34
- const tokens = useAppStore().tokens();
26
+ const fromBlockchain = useBestRouteStore.use.fromBlockchain();
27
+ const toBlockchain = useBestRouteStore.use.toBlockchain();
28
+ const fromToken = useBestRouteStore.use.fromToken();
29
+ const toToken = useBestRouteStore.use.toToken();
30
+ const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
31
+ const setFromToken = useBestRouteStore.use.setFromToken();
32
+ const setToBlockchain = useBestRouteStore.use.setToBlockchain();
33
+ const setToToken = useBestRouteStore.use.setToToken();
34
+ const inputAmount = useBestRouteStore.use.inputAmount();
35
+ const setInputAmount = useBestRouteStore.use.setInputAmount();
36
+ const loadingStatus = useMetaStore.use.loadingStatus();
37
+ const { blockchains, tokens } = useMetaStore.use.meta();
35
38
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
36
- useSyncStoresWithConfig();
39
+ useSyncStoresWithConfig(props.config);
37
40
 
38
41
  useEffect(() => {
39
42
  const params: Record<string, string> = {};
@@ -57,8 +60,7 @@ export function UpdateUrl() {
57
60
  toChainString = '',
58
61
  toTokenString = '',
59
62
  fromAmount = '';
60
- const autoConnect = searchParamsRef.current[SearchParams.AUTO_CONNECT];
61
- if (fetchMetaStatus !== 'success') {
63
+ if (loadingStatus !== 'success') {
62
64
  fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
63
65
  fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
64
66
  toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
@@ -92,9 +94,6 @@ export function UpdateUrl() {
92
94
  ...(fromAmount && {
93
95
  [SearchParams.FROM_AMOUNT]: fromAmount.toString(),
94
96
  }),
95
- ...(autoConnect && {
96
- [SearchParams.AUTO_CONNECT]: autoConnect,
97
- }),
98
97
  },
99
98
  { replace: true }
100
99
  );
@@ -110,7 +109,7 @@ export function UpdateUrl() {
110
109
  ]);
111
110
 
112
111
  useEffect(() => {
113
- if (fetchMetaStatus === 'success') {
112
+ if (loadingStatus === 'success') {
114
113
  const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
115
114
  const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
116
115
  const toChainString = searchParams.get(SearchParams.TO_CHAIN);
@@ -135,29 +134,20 @@ export function UpdateUrl() {
135
134
  if (!!fromBlockchain) {
136
135
  setFromBlockchain(fromBlockchain);
137
136
  if (!!fromToken) {
138
- setFromToken({
139
- token: fromToken,
140
- meta: {
141
- blockchains: blockchains,
142
- tokens: tokens,
143
- },
144
- });
137
+ setFromToken(fromToken);
145
138
  }
146
139
  }
147
140
  if (!!toBlockchain) {
148
141
  setToBlockchain(toBlockchain);
149
142
  if (!!toToken) {
150
- setToToken({
151
- token: toToken,
152
- meta: { blockchains: blockchains, tokens: tokens },
153
- });
143
+ setToToken(toToken);
154
144
  }
155
145
  }
156
146
  if (fromAmount) {
157
147
  setInputAmount(fromAmount);
158
148
  }
159
149
  }
160
- }, [fetchMetaStatus]);
150
+ }, [loadingStatus]);
161
151
 
162
152
  return null;
163
153
  }
@@ -8,13 +8,11 @@ import {
8
8
  } from '@rango-dev/queue-manager-rango-preset';
9
9
  import { useEffect } from 'react';
10
10
 
11
- import { useAppStore } from '../store/AppStore';
12
11
  import { useNotificationStore } from '../store/notification';
13
12
  import { useWalletsStore } from '../store/wallets';
14
13
  import { validBlockedStatuses } from '../types/notification';
15
14
 
16
15
  export function WidgetEvents() {
17
- const tokens = useAppStore().tokens();
18
16
  const connectedWallets = useWalletsStore.use.connectedWallets();
19
17
  const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
20
18
  const setNotification = useNotificationStore.use.setNotification();
@@ -40,8 +38,8 @@ export function WidgetEvents() {
40
38
  (wallet) => wallet.chain === step?.toBlockchain
41
39
  );
42
40
 
43
- fromAccount && getWalletsDetails([fromAccount], tokens);
44
- toAccount && getWalletsDetails([toAccount], tokens);
41
+ fromAccount && getWalletsDetails([fromAccount]);
42
+ toAccount && getWalletsDetails([toAccount]);
45
43
  }
46
44
  if (
47
45
  (event.type === StepEventType.TX_EXECUTION_BLOCKED &&
@@ -1,8 +1,8 @@
1
- import type { QuoteError } from '../types';
1
+ import type { ConfirmSwapError } from '../types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
 
5
- import { QuoteErrorType } from '../types';
5
+ import { ConfirmSwapErrorTypes } from '../types';
6
6
 
7
7
  export const errorMessages = () => {
8
8
  return {
@@ -13,7 +13,7 @@ export const errorMessages = () => {
13
13
  'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources'
14
14
  ),
15
15
  },
16
- noResultError: {
16
+ noRoutesError: {
17
17
  title: i18n.t('No Routes Found'),
18
18
  description: i18n.t(
19
19
  "Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination."
@@ -31,7 +31,7 @@ export const errorMessages = () => {
31
31
  ),
32
32
  confirmMessage: i18n.t('Confirm High price impact'),
33
33
  },
34
- quoteUpdatedWithHighValueLoss: {
34
+ routeUpdatedWithHighValueLoss: {
35
35
  title: i18n.t(
36
36
  'Route updated and price impact is too high, try again later!'
37
37
  ),
@@ -47,12 +47,14 @@ export const errorMessages = () => {
47
47
  };
48
48
  };
49
49
 
50
- export function getQuoteErrorMessage(error: QuoteError) {
50
+ export function getConfirmSwapErrorMessage(error: ConfirmSwapError) {
51
51
  switch (error.type) {
52
- case QuoteErrorType.NO_RESULT:
53
- return error.diagnosisMessage ?? errorMessages().noResultError.title;
54
- case QuoteErrorType.REQUEST_FAILED:
52
+ case ConfirmSwapErrorTypes.NO_ROUTE:
53
+ return error.diagnosisMessage ?? errorMessages().noRoutesError.title;
54
+ case ConfirmSwapErrorTypes.REQUEST_FAILED:
55
55
  return errorMessages().genericServerError;
56
+ case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
57
+ return errorMessages().routeUpdatedWithHighValueLoss.title;
56
58
  default:
57
59
  return '';
58
60
  }
@@ -5,6 +5,6 @@ export const swapButtonTitles = () => {
5
5
  connectWallet: i18n.t('Connect Wallet'),
6
6
  swap: i18n.t('Swap'),
7
7
  swapAnyway: i18n.t('Swap anyway'),
8
- ethWarning: i18n.t('The route goes through Ethereum. Continue?'),
8
+ ethRouteWarning: i18n.t('The route goes through Ethereum. Continue?'),
9
9
  };
10
10
  };
@@ -4,5 +4,4 @@ export enum SearchParams {
4
4
  'TO_CHAIN' = 'toBlockchain',
5
5
  'TO_TOKEN' = 'toToken',
6
6
  'FROM_AMOUNT' = 'fromAmount',
7
- 'AUTO_CONNECT' = 'autoConnect',
8
7
  }
@@ -1,14 +1,14 @@
1
- import type { QuoteUpdateWarning } from '../types';
1
+ import type { RouteWarning } from '../types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
 
5
- import { QuoteUpdateType } from '../types';
5
+ import { RouteWarningType } from '../types';
6
6
 
7
- export function getQuoteUpdateWarningMessage(warning: QuoteUpdateWarning) {
7
+ export function getRouteWarningMessage(warning: RouteWarning) {
8
8
  switch (warning.type) {
9
- case QuoteUpdateType.QUOTE_UPDATED:
9
+ case RouteWarningType.ROUTE_UPDATED:
10
10
  return i18n.t('Route has been updated.');
11
- case QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED:
11
+ case RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED:
12
12
  return i18n.t(
13
13
  'Output amount changed to {newOutputAmount} ({percentageChange}% change).',
14
14
  {
@@ -16,9 +16,9 @@ export function getQuoteUpdateWarningMessage(warning: QuoteUpdateWarning) {
16
16
  percentageChange: warning.percentageChange,
17
17
  }
18
18
  );
19
- case QuoteUpdateType.QUOTE_SWAPPERS_UPDATED:
19
+ case RouteWarningType.ROUTE_SWAPPERS_UPDATED:
20
20
  return i18n.t('Route swappers has been updated.');
21
- case QuoteUpdateType.QUOTE_COINS_UPDATED:
21
+ case RouteWarningType.ROUTE_COINS_UPDATED:
22
22
  return i18n.t('Route internal coins has been updated.');
23
23
  default:
24
24
  return '';