@rango-dev/widget-embedded 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/CHANGELOG.md +1 -113
  2. package/dist/QueueManager.d.ts +2 -5
  3. package/dist/QueueManager.d.ts.map +1 -1
  4. package/dist/Wallets.d.ts +17 -0
  5. package/dist/Wallets.d.ts.map +1 -0
  6. package/dist/Widget.d.ts +9 -0
  7. package/dist/Widget.d.ts.map +1 -0
  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/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
  13. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -1
  14. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  15. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
  16. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  17. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +62 -691
  18. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  19. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  20. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
  21. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  22. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  23. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
  24. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  25. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
  26. package/dist/components/Layout/Layout.d.ts.map +1 -1
  27. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  28. package/dist/components/Layout/Layout.types.d.ts +2 -2
  29. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  30. package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
  31. package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
  32. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
  33. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +0 -1727
  34. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  35. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
  36. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
  37. package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
  38. package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
  39. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
  40. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
  41. package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
  42. package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
  43. package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
  44. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
  45. package/dist/components/NoRoutes/index.d.ts +2 -0
  46. package/dist/components/NoRoutes/index.d.ts.map +1 -0
  47. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  48. package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
  49. package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
  50. package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
  51. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
  52. package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
  53. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
  54. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
  55. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
  56. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
  57. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
  58. package/dist/components/RouteErrors/index.d.ts +2 -0
  59. package/dist/components/RouteErrors/index.d.ts.map +1 -0
  60. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  61. package/dist/components/Slippage/Slippage.styles.d.ts +0 -158
  62. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  63. package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
  64. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  65. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
  66. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
  67. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +0 -628
  68. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  69. package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
  70. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  71. package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
  72. package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
  73. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
  74. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  75. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  76. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +0 -157
  77. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  78. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  79. package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
  80. package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
  81. package/dist/components/TokenList/TokenList.styles.d.ts +1 -1100
  82. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  83. package/dist/components/TokenList/TokenList.types.d.ts +9 -4
  84. package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
  85. package/dist/components/TokenList/index.d.ts +1 -0
  86. package/dist/components/TokenList/index.d.ts.map +1 -1
  87. package/dist/components/UpdateUrl.d.ts +6 -1
  88. package/dist/components/UpdateUrl.d.ts.map +1 -1
  89. package/dist/components/WidgetEvents.d.ts.map +1 -1
  90. package/dist/constants/errors.d.ts +4 -4
  91. package/dist/constants/errors.d.ts.map +1 -1
  92. package/dist/constants/index.d.ts +0 -1
  93. package/dist/constants/index.d.ts.map +1 -1
  94. package/dist/constants/messages.d.ts +1 -1
  95. package/dist/constants/navigationRoutes.d.ts +2 -1
  96. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  97. package/dist/constants/searchParams.d.ts +1 -2
  98. package/dist/constants/searchParams.d.ts.map +1 -1
  99. package/dist/constants/warnings.d.ts +2 -2
  100. package/dist/constants/warnings.d.ts.map +1 -1
  101. package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
  102. package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
  103. package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
  104. package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
  105. package/dist/hooks/useLanguage.d.ts +1 -1
  106. package/dist/hooks/useLanguage.d.ts.map +1 -1
  107. package/dist/hooks/useNavigateBack.d.ts +3 -1
  108. package/dist/hooks/useNavigateBack.d.ts.map +1 -1
  109. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
  110. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
  111. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
  112. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +7 -5
  113. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
  114. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +0 -1
  115. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
  116. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +1 -5
  117. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
  118. package/dist/hooks/useSwapInput.d.ts +2 -4
  119. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  120. package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
  121. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  122. package/dist/hooks/useTheme.d.ts +1 -1
  123. package/dist/hooks/useTheme.d.ts.map +1 -1
  124. package/dist/hooks/useWalletList.d.ts.map +1 -1
  125. package/dist/index.d.ts +8 -20
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +1 -1
  128. package/dist/index.js.map +4 -4
  129. package/dist/pages/ConfirmSwapPage.d.ts +6 -1
  130. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  131. package/dist/pages/HistoryPage.d.ts.map +1 -1
  132. package/dist/pages/Home.d.ts.map +1 -1
  133. package/dist/pages/LanguagePage.d.ts.map +1 -1
  134. package/dist/pages/LiquiditySourcePage.d.ts +2 -1
  135. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  136. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  137. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  138. package/dist/pages/SettingsPage.d.ts +6 -1
  139. package/dist/pages/SettingsPage.d.ts.map +1 -1
  140. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  141. package/dist/pages/ThemePage.d.ts.map +1 -1
  142. package/dist/pages/WalletsPage.d.ts +8 -1
  143. package/dist/pages/WalletsPage.d.ts.map +1 -1
  144. package/dist/store/app.d.ts +22 -41
  145. package/dist/store/app.d.ts.map +1 -1
  146. package/dist/store/bestRoute.d.ts +77 -0
  147. package/dist/store/bestRoute.d.ts.map +1 -0
  148. package/dist/store/meta.d.ts +23 -0
  149. package/dist/store/meta.d.ts.map +1 -0
  150. package/dist/store/notification.d.ts +3 -4
  151. package/dist/store/notification.d.ts.map +1 -1
  152. package/dist/store/settings.d.ts +81 -0
  153. package/dist/store/settings.d.ts.map +1 -0
  154. package/dist/store/slices/config.d.ts +2 -3
  155. package/dist/store/slices/config.d.ts.map +1 -1
  156. package/dist/store/slices/data.d.ts +2 -5
  157. package/dist/store/slices/data.d.ts.map +1 -1
  158. package/dist/store/ui.d.ts +1 -2
  159. package/dist/store/ui.d.ts.map +1 -1
  160. package/dist/store/wallets.d.ts +9 -14
  161. package/dist/store/wallets.d.ts.map +1 -1
  162. package/dist/types/config.d.ts +8 -41
  163. package/dist/types/config.d.ts.map +1 -1
  164. package/dist/types/index.d.ts +1 -1
  165. package/dist/types/index.d.ts.map +1 -1
  166. package/dist/types/routing.d.ts +65 -0
  167. package/dist/types/routing.d.ts.map +1 -0
  168. package/dist/types/swap.d.ts +14 -4
  169. package/dist/types/swap.d.ts.map +1 -1
  170. package/dist/types/wallets.d.ts +1 -15
  171. package/dist/types/wallets.d.ts.map +1 -1
  172. package/dist/utils/colors.d.ts.map +1 -1
  173. package/dist/utils/configs.d.ts +0 -1
  174. package/dist/utils/configs.d.ts.map +1 -1
  175. package/dist/utils/meta.d.ts +1 -2
  176. package/dist/utils/meta.d.ts.map +1 -1
  177. package/dist/utils/numbers.d.ts +1 -1
  178. package/dist/utils/numbers.d.ts.map +1 -1
  179. package/dist/utils/providers.d.ts +2 -2
  180. package/dist/utils/providers.d.ts.map +1 -1
  181. package/dist/utils/queue.d.ts +2 -2
  182. package/dist/utils/queue.d.ts.map +1 -1
  183. package/dist/utils/routing.d.ts +28 -0
  184. package/dist/utils/routing.d.ts.map +1 -0
  185. package/dist/utils/settings.d.ts +2 -6
  186. package/dist/utils/settings.d.ts.map +1 -1
  187. package/dist/utils/swap.d.ts +24 -35
  188. package/dist/utils/swap.d.ts.map +1 -1
  189. package/dist/utils/time.d.ts +1 -1
  190. package/dist/utils/time.d.ts.map +1 -1
  191. package/dist/utils/wallets.d.ts +10 -9
  192. package/dist/utils/wallets.d.ts.map +1 -1
  193. package/package.json +10 -12
  194. package/src/QueueManager.tsx +17 -18
  195. package/src/{containers/Wallets/Wallets.tsx → Wallets.tsx} +34 -48
  196. package/src/Widget.tsx +119 -0
  197. package/src/components/AppRouter.tsx +32 -8
  198. package/src/components/AppRoutes.tsx +69 -57
  199. package/src/components/BlockchainList/BlockchainList.styles.ts +2 -2
  200. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  201. package/src/components/BlockchainsSection/BlockchainsSection.styles.ts +1 -1
  202. package/src/components/BlockchainsSection/BlockchainsSection.tsx +17 -26
  203. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
  204. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +10 -29
  205. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +47 -43
  206. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
  207. package/src/components/ConfirmWalletsModal/WalletList.tsx +8 -9
  208. package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
  209. package/src/components/HeaderButtons/HomeButtons.tsx +18 -28
  210. package/src/components/Layout/Layout.styles.ts +0 -2
  211. package/src/components/Layout/Layout.tsx +7 -20
  212. package/src/components/Layout/Layout.types.ts +2 -2
  213. package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
  214. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +61 -65
  215. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +34 -28
  216. package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
  217. package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +16 -23
  218. package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
  219. package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +17 -12
  220. package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
  221. package/src/components/NoRoutes/index.ts +1 -0
  222. package/src/components/NotificationContent/NotificationContent.tsx +3 -5
  223. package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +1 -8
  224. package/src/components/RouteErrors/RouteErrors.tsx +79 -0
  225. package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
  226. package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
  227. package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +4 -4
  228. package/src/components/RouteErrors/index.ts +1 -0
  229. package/src/components/Slippage/Slippage.styles.ts +5 -15
  230. package/src/components/Slippage/Slippage.tsx +10 -11
  231. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +8 -5
  232. package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
  233. package/src/components/SwapDetails/SwapDetails.styles.ts +33 -36
  234. package/src/components/SwapDetails/SwapDetails.tsx +56 -41
  235. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
  236. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +3 -4
  237. package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
  238. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +8 -14
  239. package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
  240. package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
  241. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
  242. package/src/components/SwapsGroup/SwapsGroup.styles.ts +1 -10
  243. package/src/components/SwapsGroup/SwapsGroup.tsx +5 -3
  244. package/src/components/SwitchFromAndTo.tsx +2 -2
  245. package/src/components/TokenList/TokenList.helpers.ts +2 -2
  246. package/src/components/TokenList/TokenList.styles.ts +38 -74
  247. package/src/components/TokenList/TokenList.tsx +26 -35
  248. package/src/components/TokenList/TokenList.types.ts +10 -4
  249. package/src/components/TokenList/index.ts +1 -0
  250. package/src/components/UpdateUrl.tsx +30 -35
  251. package/src/components/WidgetEvents.tsx +2 -4
  252. package/src/constants/errors.ts +15 -17
  253. package/src/constants/index.ts +0 -1
  254. package/src/constants/messages.ts +1 -1
  255. package/src/constants/navigationRoutes.ts +8 -7
  256. package/src/constants/searchParams.ts +0 -1
  257. package/src/constants/warnings.ts +7 -7
  258. package/src/hooks/useConfirmSwap.ts +303 -0
  259. package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
  260. package/src/hooks/useLanguage.ts +5 -4
  261. package/src/hooks/useNavigateBack.ts +52 -3
  262. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
  263. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +7 -37
  264. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +0 -60
  265. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +3 -78
  266. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +6 -15
  267. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +1 -6
  268. package/src/hooks/useSwapInput.ts +48 -141
  269. package/src/hooks/useSyncStoresWithConfig.ts +24 -40
  270. package/src/hooks/useTheme.ts +5 -4
  271. package/src/hooks/useWalletList.ts +5 -3
  272. package/src/index.ts +5 -53
  273. package/src/pages/ConfirmSwapPage.tsx +266 -117
  274. package/src/pages/HistoryPage.tsx +7 -2
  275. package/src/pages/Home.tsx +303 -88
  276. package/src/pages/LanguagePage.tsx +5 -0
  277. package/src/pages/LiquiditySourcePage.tsx +37 -24
  278. package/src/pages/SelectBlockchainPage.tsx +24 -31
  279. package/src/pages/SelectSwapItemsPage.tsx +31 -18
  280. package/src/pages/SettingsPage.tsx +27 -32
  281. package/src/pages/SwapDetailsPage.tsx +7 -6
  282. package/src/pages/ThemePage.tsx +7 -2
  283. package/src/pages/WalletsPage.tsx +19 -9
  284. package/src/services/httpService.ts +1 -1
  285. package/src/store/app.ts +6 -44
  286. package/src/store/{quote.ts → bestRoute.ts} +64 -71
  287. package/src/store/meta.ts +39 -0
  288. package/src/store/settings.ts +158 -0
  289. package/src/store/slices/config.ts +15 -26
  290. package/src/store/slices/data.ts +35 -74
  291. package/src/store/wallets.ts +37 -68
  292. package/src/types/config.ts +8 -53
  293. package/src/types/index.ts +1 -1
  294. package/src/types/routing.ts +77 -0
  295. package/src/types/swap.ts +13 -4
  296. package/src/types/wallets.ts +1 -18
  297. package/src/utils/colors.ts +1 -2
  298. package/src/utils/configs.ts +1 -2
  299. package/src/utils/date.ts +1 -1
  300. package/src/utils/meta.ts +1 -8
  301. package/src/utils/numbers.ts +1 -1
  302. package/src/utils/providers.ts +5 -8
  303. package/src/utils/queue.ts +2 -2
  304. package/src/utils/routing.ts +321 -0
  305. package/src/utils/settings.ts +10 -17
  306. package/src/utils/swap.ts +120 -154
  307. package/src/utils/time.ts +1 -1
  308. package/src/utils/wallets.ts +161 -156
  309. package/dist/components/NoResult/NoResult.d.ts +0 -4
  310. package/dist/components/NoResult/NoResult.d.ts.map +0 -1
  311. package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
  312. package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
  313. package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
  314. package/dist/components/NoResult/index.d.ts +0 -2
  315. package/dist/components/NoResult/index.d.ts.map +0 -1
  316. package/dist/components/Quote/Quote.d.ts +0 -4
  317. package/dist/components/Quote/Quote.d.ts.map +0 -1
  318. package/dist/components/Quote/Quote.styles.d.ts +0 -2217
  319. package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
  320. package/dist/components/Quote/Quote.types.d.ts +0 -21
  321. package/dist/components/Quote/Quote.types.d.ts.map +0 -1
  322. package/dist/components/Quote/QuoteSummary.d.ts +0 -11
  323. package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
  324. package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -315
  325. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
  326. package/dist/components/Quote/index.d.ts +0 -3
  327. package/dist/components/Quote/index.d.ts.map +0 -1
  328. package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +0 -4
  329. package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +0 -1
  330. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +0 -633
  331. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +0 -1
  332. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +0 -6
  333. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +0 -1
  334. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +0 -4
  335. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +0 -1
  336. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +0 -1571
  337. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +0 -1
  338. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +0 -6
  339. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +0 -1
  340. package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +0 -4
  341. package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +0 -1
  342. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +0 -786
  343. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +0 -1
  344. package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +0 -4
  345. package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +0 -1
  346. package/dist/components/QuoteSkeleton/index.d.ts +0 -4
  347. package/dist/components/QuoteSkeleton/index.d.ts.map +0 -1
  348. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
  349. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
  350. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
  351. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
  352. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
  353. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
  354. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
  355. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
  356. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
  357. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -23
  358. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
  359. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
  360. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
  361. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
  362. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
  363. package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
  364. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
  365. package/dist/containers/App/App.d.ts +0 -3
  366. package/dist/containers/App/App.d.ts.map +0 -1
  367. package/dist/containers/App/App.styles.d.ts +0 -158
  368. package/dist/containers/App/App.styles.d.ts.map +0 -1
  369. package/dist/containers/App/index.d.ts +0 -2
  370. package/dist/containers/App/index.d.ts.map +0 -1
  371. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
  372. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
  373. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -788
  374. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
  375. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -20
  376. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
  377. package/dist/containers/QuoteInfo/index.d.ts +0 -2
  378. package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
  379. package/dist/containers/Wallets/Wallets.d.ts +0 -6
  380. package/dist/containers/Wallets/Wallets.d.ts.map +0 -1
  381. package/dist/containers/Wallets/Wallets.types.d.ts +0 -11
  382. package/dist/containers/Wallets/Wallets.types.d.ts.map +0 -1
  383. package/dist/containers/Wallets/index.d.ts +0 -2
  384. package/dist/containers/Wallets/index.d.ts.map +0 -1
  385. package/dist/containers/Widget/Widget.d.ts +0 -5
  386. package/dist/containers/Widget/Widget.d.ts.map +0 -1
  387. package/dist/containers/Widget/Widget.types.d.ts +0 -5
  388. package/dist/containers/Widget/Widget.types.d.ts.map +0 -1
  389. package/dist/containers/Widget/index.d.ts +0 -3
  390. package/dist/containers/Widget/index.d.ts.map +0 -1
  391. package/dist/containers/WidgetInfo/WidgetInfo.d.ts +0 -6
  392. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +0 -1
  393. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +0 -20
  394. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +0 -1
  395. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +0 -21
  396. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +0 -1
  397. package/dist/containers/WidgetInfo/index.d.ts +0 -2
  398. package/dist/containers/WidgetInfo/index.d.ts.map +0 -1
  399. package/dist/containers/WidgetProvider/WidgetProvider.d.ts +0 -5
  400. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +0 -1
  401. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +0 -7
  402. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +0 -1
  403. package/dist/containers/WidgetProvider/index.d.ts +0 -2
  404. package/dist/containers/WidgetProvider/index.d.ts.map +0 -1
  405. package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
  406. package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
  407. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
  408. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
  409. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -19
  410. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
  411. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
  412. package/dist/hooks/useFetchQuote.d.ts.map +0 -1
  413. package/dist/hooks/useForceAutoConnect.d.ts +0 -2
  414. package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
  415. package/dist/store/AppStore.d.ts +0 -47
  416. package/dist/store/AppStore.d.ts.map +0 -1
  417. package/dist/store/quote.d.ts +0 -89
  418. package/dist/store/quote.d.ts.map +0 -1
  419. package/dist/store/slices/settings.d.ts +0 -39
  420. package/dist/store/slices/settings.d.ts.map +0 -1
  421. package/dist/types/quote.d.ts +0 -82
  422. package/dist/types/quote.d.ts.map +0 -1
  423. package/dist/utils/quote.d.ts +0 -32
  424. package/dist/utils/quote.d.ts.map +0 -1
  425. package/src/components/NoResult/index.ts +0 -1
  426. package/src/components/Quote/Quote.styles.ts +0 -249
  427. package/src/components/Quote/Quote.tsx +0 -414
  428. package/src/components/Quote/Quote.types.ts +0 -15
  429. package/src/components/Quote/QuoteSummary.styles.ts +0 -16
  430. package/src/components/Quote/QuoteSummary.tsx +0 -46
  431. package/src/components/Quote/index.ts +0 -2
  432. package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +0 -42
  433. package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +0 -30
  434. package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +0 -5
  435. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +0 -57
  436. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +0 -76
  437. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +0 -6
  438. package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +0 -33
  439. package/src/components/QuoteSkeleton/StepSkeleton.tsx +0 -44
  440. package/src/components/QuoteSkeleton/StepSkeleton.types.ts +0 -1
  441. package/src/components/QuoteSkeleton/index.ts +0 -3
  442. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
  443. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -74
  444. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
  445. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -25
  446. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
  447. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
  448. package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
  449. package/src/containers/App/App.styles.ts +0 -18
  450. package/src/containers/App/App.tsx +0 -52
  451. package/src/containers/App/index.ts +0 -1
  452. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -31
  453. package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -99
  454. package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -20
  455. package/src/containers/QuoteInfo/index.ts +0 -1
  456. package/src/containers/Wallets/Wallets.types.ts +0 -12
  457. package/src/containers/Wallets/index.ts +0 -1
  458. package/src/containers/Widget/Widget.tsx +0 -19
  459. package/src/containers/Widget/Widget.types.ts +0 -5
  460. package/src/containers/Widget/index.ts +0 -2
  461. package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +0 -64
  462. package/src/containers/WidgetInfo/WidgetInfo.tsx +0 -62
  463. package/src/containers/WidgetInfo/WidgetInfo.types.ts +0 -21
  464. package/src/containers/WidgetInfo/index.ts +0 -1
  465. package/src/containers/WidgetProvider/WidgetProvider.tsx +0 -28
  466. package/src/containers/WidgetProvider/WidgetProvider.types.ts +0 -7
  467. package/src/containers/WidgetProvider/index.ts +0 -1
  468. package/src/hooks/useConfirmSwap/index.ts +0 -1
  469. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -172
  470. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -137
  471. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
  472. package/src/hooks/useForceAutoConnect.ts +0 -27
  473. package/src/store/AppStore.tsx +0 -41
  474. package/src/store/slices/settings.ts +0 -168
  475. package/src/types/quote.ts +0 -107
  476. package/src/utils/quote.ts +0 -338
package/src/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- import type { WidgetProps } from './containers/Widget';
2
- import type { ConnectedWallet } from './store/wallets';
3
1
  import type {
4
2
  BlockchainAndTokenConfig,
5
3
  WidgetColors,
@@ -7,12 +5,10 @@ import type {
7
5
  WidgetConfig,
8
6
  WidgetTheme,
9
7
  } from './types';
8
+ import type { WidgetProps } from './Widget';
10
9
  import type {
11
- EventSeverity,
12
- PendingSwapWithQueueID,
13
10
  Route,
14
11
  RouteEvent,
15
- RouteExecutionEvents,
16
12
  RouteFailedEvent,
17
13
  RouteStartedEvent,
18
14
  RouteSucceededEvent,
@@ -31,16 +27,7 @@ import type {
31
27
  EventHandler as HandleWalletsUpdate,
32
28
  ProviderInterface,
33
29
  } from '@rango-dev/wallets-react';
34
- import type {
35
- WalletInfo,
36
- WalletState,
37
- WalletType,
38
- } from '@rango-dev/wallets-shared';
39
- import type {
40
- PendingSwap,
41
- PendingSwapNetworkStatus,
42
- PendingSwapStep,
43
- } from 'rango-types';
30
+ import type { WalletType } from '@rango-dev/wallets-shared';
44
31
 
45
32
  import {
46
33
  MainEvents,
@@ -50,18 +37,10 @@ import {
50
37
  StepExecutionEventStatus,
51
38
  useEvents as useWidgetEvents,
52
39
  } from '@rango-dev/queue-manager-rango-preset';
53
- import {
54
- readAccountAddress,
55
- useWallets,
56
- Events as WalletEvents,
57
- } from '@rango-dev/wallets-react';
58
- import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
40
+ import { useWallets } from '@rango-dev/wallets-react';
59
41
 
60
- import { WidgetWallets } from './containers/Wallets';
61
- import { Widget } from './containers/Widget';
62
- import { useWidget } from './containers/WidgetInfo';
63
- import { WidgetProvider } from './containers/WidgetProvider';
64
- import { customizedThemeTokens } from './utils/ui';
42
+ import { WidgetWallets } from './Wallets';
43
+ import { Widget } from './Widget';
65
44
 
66
45
  export type {
67
46
  WidgetConfig,
@@ -88,42 +67,15 @@ export type {
88
67
  StepApprovalTxSucceededEvent,
89
68
  StepOutputRevealedEvent,
90
69
  HandleWalletsUpdate,
91
- ConnectedWallet,
92
70
  };
93
71
  export {
94
72
  Widget,
95
- /**
96
- * @deprecated Use `WidgetProvider` instead. This component will be removed in future versions.
97
- */
98
73
  WidgetWallets,
99
- WidgetProvider,
100
- useWidget,
101
74
  useWallets,
102
75
  useWidgetEvents,
103
- customizedThemeTokens,
104
76
  MainEvents,
105
77
  RouteEventType,
106
78
  StepEventType,
107
79
  StepExecutionEventStatus,
108
80
  StepExecutionBlockedEventStatus,
109
81
  };
110
-
111
- // Internal type exports for Rango
112
- export type {
113
- WalletState,
114
- WalletInfo,
115
- PendingSwap,
116
- PendingSwapWithQueueID,
117
- PendingSwapStep,
118
- RouteExecutionEvents,
119
- EventSeverity,
120
- };
121
-
122
- // Internal function and enum exports for Rango
123
- export {
124
- readAccountAddress,
125
- Networks,
126
- WalletEvents,
127
- WalletTypes,
128
- PendingSwapNetworkStatus,
129
- };
@@ -2,16 +2,20 @@
2
2
  import type {
3
3
  ConfirmSwap,
4
4
  ConfirmSwapFetchResult,
5
- } from '../hooks/useConfirmSwap/useConfirmSwap.types';
5
+ } from '../hooks/useConfirmSwap';
6
+ import type { WidgetConfig } from '../types';
6
7
 
7
8
  import { i18n } from '@lingui/core';
8
9
  import { useManager } from '@rango-dev/queue-manager-react';
9
10
  import {
10
11
  Alert,
12
+ BestRoute,
13
+ BestRouteSkeleton,
11
14
  Button,
12
- css,
13
15
  Divider,
14
16
  IconButton,
17
+ MessageBox,
18
+ Modal,
15
19
  RefreshIcon,
16
20
  SettingsIcon,
17
21
  styled,
@@ -19,31 +23,66 @@ import {
19
23
  Typography,
20
24
  WalletIcon,
21
25
  } from '@rango-dev/ui';
22
- import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
26
+ import React, { useEffect, useState } from 'react';
23
27
  import { flushSync } from 'react-dom';
24
28
  import { useNavigate } from 'react-router-dom';
25
29
 
26
- import { getRequiredWallets } from '../components/ConfirmWalletsModal/ConfirmWallets.helpers';
30
+ import {
31
+ formatBestRoute,
32
+ getRequiredWallets,
33
+ } from '../components/ConfirmWalletsModal/ConfirmWallets.helpers';
27
34
  import { ConfirmWalletsModal } from '../components/ConfirmWalletsModal/ConfirmWalletsModal';
28
35
  import { HeaderButton } from '../components/HeaderButtons/HeaderButtons.styles';
29
36
  import { Layout } from '../components/Layout';
37
+ import { NoRoutes } from '../components/NoRoutes';
38
+ import { getConfirmSwapErrorMessage } from '../constants/errors';
30
39
  import { navigationRoutes } from '../constants/navigationRoutes';
31
- import { getQuoteUpdateWarningMessage } from '../constants/warnings';
32
- import { QuoteInfo } from '../containers/QuoteInfo';
40
+ import {
41
+ GAS_FEE_MAX_DECIMALS,
42
+ GAS_FEE_MIN_DECIMALS,
43
+ PERCENTAGE_CHANGE_MAX_DECIMALS,
44
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
45
+ TOKEN_AMOUNT_MAX_DECIMALS,
46
+ TOKEN_AMOUNT_MIN_DECIMALS,
47
+ USD_VALUE_MAX_DECIMALS,
48
+ USD_VALUE_MIN_DECIMALS,
49
+ } from '../constants/routing';
50
+ import { getRouteWarningMessage } from '../constants/warnings';
33
51
  import { useConfirmSwap } from '../hooks/useConfirmSwap';
34
- import { useAppStore } from '../store/AppStore';
35
- import { useQuoteStore } from '../store/quote';
52
+ import { useBestRouteStore } from '../store/bestRoute';
53
+ import { useMetaStore } from '../store/meta';
54
+ import { useSettingsStore } from '../store/settings';
36
55
  import { useUiStore } from '../store/ui';
37
56
  import { useWalletsStore } from '../store/wallets';
38
- import { QuoteWarningType } from '../types';
57
+ import {
58
+ ConfirmSwapErrorTypes,
59
+ RouteWarningType,
60
+ SlippageWarningType,
61
+ } from '../types';
39
62
  import { getContainer } from '../utils/common';
63
+ import {
64
+ numberToString,
65
+ secondsToString,
66
+ totalArrivalTime,
67
+ } from '../utils/numbers';
68
+ import { getPriceImpactLevel } from '../utils/routing';
69
+ import { getPercentageChange, getTotalFeeInUsd } from '../utils/swap';
40
70
 
41
71
  const Container = styled('div', {
42
72
  position: 'relative',
43
73
  width: '100%',
44
-
45
- '& .quote-update__alert': {
46
- paddingTop: '$10',
74
+ '& .description': {
75
+ display: 'flex',
76
+ justifyContent: 'space-between',
77
+ alignItems: 'center',
78
+ paddingBottom: '$10',
79
+ },
80
+ '& .icon': {
81
+ width: '$24',
82
+ height: '$24',
83
+ display: 'flex',
84
+ justifyContent: 'center',
85
+ alignItems: 'center',
47
86
  },
48
87
  });
49
88
 
@@ -51,55 +90,54 @@ const Buttons = styled('div', {
51
90
  width: '100%',
52
91
  display: 'flex',
53
92
  justifyContent: 'space-between',
93
+ '& .confirm-button': {
94
+ flexGrow: 1,
95
+ paddingRight: '$10',
96
+ },
54
97
  [`& ${IconButton}`]: {
55
98
  width: '$48',
56
99
  height: '$48',
57
100
  },
58
101
  });
59
102
 
60
- const confirmBtnStyles = css({
61
- flexGrow: 1,
62
- paddingRight: '$10',
63
- });
64
-
65
- const iconStyles = css({
66
- width: '$24',
67
- height: '$24',
68
- display: 'flex',
69
- justifyContent: 'center',
70
- alignItems: 'center',
71
- });
103
+ type PropTypes = {
104
+ config?: WidgetConfig;
105
+ };
72
106
 
73
- const descriptionStyles = css({
74
- display: 'flex',
75
- justifyContent: 'space-between',
76
- alignItems: 'center',
77
- });
78
-
79
- export function ConfirmSwapPage() {
107
+ export function ConfirmSwapPage(props: PropTypes) {
80
108
  //TODO: move component's logics to a custom hook
109
+ const { config } = props;
81
110
  const {
82
- quote,
111
+ bestRoute,
112
+ inputAmount,
113
+ outputAmount,
114
+ inputUsdValue,
115
+ outputUsdValue,
83
116
  setInputAmount,
84
117
  selectedWallets,
85
- quoteWalletsConfirmed,
86
- setQuoteWalletConfirmed,
118
+ routeWalletsConfirmed,
119
+ setRouteWalletConfirmed,
87
120
  customDestination,
88
- quoteWarningsConfirmed,
89
- } = useQuoteStore();
121
+ } = useBestRouteStore();
90
122
  const navigate = useNavigate();
91
123
  const [dbErrorMessage, setDbErrorMessage] = useState<string>('');
124
+ const [showSlippageWarning, setShowSlippageWarning] = useState(false);
92
125
 
93
126
  const { connectedWallets } = useWalletsStore();
94
- const showWalletsOnInit = !quoteWalletsConfirmed;
127
+ const showWalletsOnInit = !routeWalletsConfirmed;
95
128
  const [showWallets, setShowWallets] = useState(false);
96
129
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
97
- const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
98
- const prevDisabledLiquiditySources = useRef(disabledLiquiditySources);
130
+ const {
131
+ meta: { tokens, blockchains },
132
+ loadingStatus: loadingMetaStatus,
133
+ } = useMetaStore();
134
+ const slippage = useSettingsStore.use.slippage();
135
+ const customSlippage = useSettingsStore.use.customSlippage();
99
136
  const { manager } = useManager();
137
+ const selectedSlippage = customSlippage || slippage;
100
138
  const {
101
139
  fetch: confirmSwap,
102
- loading: fetchingConfirmationQuote,
140
+ loading: fetchingConfirmationRoute,
103
141
  cancelFetch,
104
142
  } = useConfirmSwap();
105
143
  const [confirmSwapResult, setConfirmSwapResult] =
@@ -108,8 +146,32 @@ export function ConfirmSwapPage() {
108
146
  error: null,
109
147
  warnings: null,
110
148
  });
149
+ const showSkeleton =
150
+ fetchingConfirmationRoute || loadingMetaStatus === 'loading';
151
+ const showNoRouteFound =
152
+ !fetchingConfirmationRoute &&
153
+ confirmSwapResult.error &&
154
+ [
155
+ ConfirmSwapErrorTypes.NO_ROUTE,
156
+ ConfirmSwapErrorTypes.REQUEST_FAILED,
157
+ ].includes(confirmSwapResult.error.type);
158
+ const showBestRoute =
159
+ !showNoRouteFound &&
160
+ !fetchingConfirmationRoute &&
161
+ bestRoute &&
162
+ bestRoute.result;
163
+
164
+ const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
165
+ const percentageChange = numberToString(
166
+ getPercentageChange(
167
+ inputUsdValue?.toNumber() ?? 0,
168
+ outputUsdValue?.toNumber() ?? 0
169
+ ),
170
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
171
+ PERCENTAGE_CHANGE_MAX_DECIMALS
172
+ );
111
173
 
112
- const [showQuoteWarningModal, setShowQuoteWarningModal] = useState(false);
174
+ const warningLevel = getPriceImpactLevel(parseFloat(percentageChange));
113
175
 
114
176
  const onConfirmSwap: ConfirmSwap['fetch'] = async ({
115
177
  selectedWallets,
@@ -121,7 +183,7 @@ export function ConfirmSwapPage() {
121
183
  };
122
184
 
123
185
  const addNewSwap = async () => {
124
- if (confirmSwapResult.swap && quoteWalletsConfirmed) {
186
+ if (confirmSwapResult.swap && routeWalletsConfirmed) {
125
187
  try {
126
188
  await manager?.create(
127
189
  'swap',
@@ -129,11 +191,12 @@ export function ConfirmSwapPage() {
129
191
  { id: confirmSwapResult.swap.requestId }
130
192
  );
131
193
  setSelectedSwap(confirmSwapResult.swap.requestId);
132
-
133
- const swap_url = `../${navigationRoutes.swaps}/${confirmSwapResult.swap.requestId}`;
134
- navigate(swap_url, {
135
- replace: true,
136
- });
194
+ navigate(
195
+ '/' + navigationRoutes.swaps + `/${confirmSwapResult.swap.requestId}`,
196
+ {
197
+ replace: true,
198
+ }
199
+ );
137
200
  setTimeout(() => {
138
201
  setInputAmount('');
139
202
  }, 0);
@@ -148,8 +211,8 @@ export function ConfirmSwapPage() {
148
211
  };
149
212
 
150
213
  const onStartConfirmSwap = async () => {
151
- if (confirmSwapResult?.warnings?.quote && !quoteWarningsConfirmed) {
152
- setShowQuoteWarningModal(true);
214
+ if (confirmSwapResult?.warnings?.slippage) {
215
+ setShowSlippageWarning(true);
153
216
  } else {
154
217
  await onConfirm();
155
218
  }
@@ -161,23 +224,13 @@ export function ConfirmSwapPage() {
161
224
  swap: null,
162
225
  warnings: null,
163
226
  });
164
- confirmSwap({ selectedWallets, customDestination })
227
+ confirmSwap({ selectedWallets })
165
228
  .then((res) => {
166
229
  setConfirmSwapResult(res);
167
230
  })
168
231
  .catch((error) => console.error(error));
169
232
  };
170
233
 
171
- useEffect(() => {
172
- const disabledLiquiditySourceReset =
173
- !!prevDisabledLiquiditySources.current.length &&
174
- !disabledLiquiditySources.length;
175
- if (disabledLiquiditySourceReset) {
176
- void onRefresh();
177
- }
178
- prevDisabledLiquiditySources.current = disabledLiquiditySources;
179
- }, [disabledLiquiditySources.length]);
180
-
181
234
  useEffect(() => {
182
235
  if (showWalletsOnInit) {
183
236
  cancelFetch();
@@ -199,10 +252,10 @@ export function ConfirmSwapPage() {
199
252
  }, []);
200
253
 
201
254
  useEffect(() => {
202
- const quoteChanged =
203
- confirmSwapResult.warnings?.quote?.type &&
204
- Object.values(QuoteWarningType).includes(
205
- confirmSwapResult.warnings?.quote?.type
255
+ const routeChanged =
256
+ confirmSwapResult.warnings?.route?.type &&
257
+ Object.values(RouteWarningType).includes(
258
+ confirmSwapResult.warnings?.route?.type
206
259
  );
207
260
 
208
261
  const selectedWalletDisconnected =
@@ -216,15 +269,16 @@ export function ConfirmSwapPage() {
216
269
  )
217
270
  );
218
271
 
219
- let quoteWalletsChanged = false;
272
+ let routeWalletsChanged = false;
220
273
 
221
- if (quoteChanged) {
222
- let requiredWallets = getRequiredWallets(quote);
274
+ if (routeChanged) {
275
+ let requiredWallets = getRequiredWallets(bestRoute);
223
276
 
224
277
  const lastStepToBlockchain =
225
- quote?.result?.swaps[quote.result.swaps.length - 1].to.blockchain;
278
+ bestRoute?.result?.swaps[bestRoute.result.swaps.length - 1].to
279
+ .blockchain;
226
280
 
227
- const isLastWalletRequired = !!quote?.result?.swaps.find(
281
+ const isLastWalletRequired = !!bestRoute?.result?.swaps.find(
228
282
  (swap) => swap.from.blockchain === lastStepToBlockchain
229
283
  );
230
284
 
@@ -243,34 +297,26 @@ export function ConfirmSwapPage() {
243
297
  );
244
298
 
245
299
  if (!allRequiredWalletsSelected) {
246
- quoteWalletsChanged = true;
300
+ routeWalletsChanged = true;
247
301
  }
248
302
  }
249
303
 
250
- if (quote && (selectedWalletDisconnected || quoteWalletsChanged)) {
304
+ if (bestRoute && (selectedWalletDisconnected || routeWalletsChanged)) {
251
305
  queueMicrotask(() => flushSync(setShowWallets.bind(null, true)));
252
- setQuoteWalletConfirmed(false);
306
+ setRouteWalletConfirmed(false);
253
307
  }
254
308
  }, [
255
- confirmSwapResult.warnings?.quote,
309
+ confirmSwapResult.warnings?.route,
256
310
  selectedWallets.length,
257
311
  connectedWallets.length,
258
312
  ]);
259
313
 
260
- useLayoutEffect(() => {
261
- if (!quote) {
262
- navigate(`../`);
263
- }
264
- }, []);
265
-
266
314
  return (
267
315
  <Layout
268
316
  header={{
269
317
  title: i18n.t('Confirm Swap'),
270
- onWallet: () => {
271
- const wallets_url = `../${navigationRoutes.wallets}`;
272
- navigate(wallets_url);
273
- },
318
+ onBack: navigate.bind(null, -1),
319
+ hasConnectWallet: true,
274
320
  suffix: (
275
321
  <Tooltip
276
322
  container={getContainer()}
@@ -279,7 +325,7 @@ export function ConfirmSwapPage() {
279
325
  <HeaderButton
280
326
  size="small"
281
327
  variant="ghost"
282
- onClick={() => navigate('../' + navigationRoutes.settings)}>
328
+ onClick={() => navigate('/' + navigationRoutes.settings)}>
283
329
  <SettingsIcon size={18} color="black" />
284
330
  </HeaderButton>
285
331
  </Tooltip>
@@ -287,13 +333,13 @@ export function ConfirmSwapPage() {
287
333
  }}
288
334
  footer={
289
335
  <Buttons>
290
- <div className={confirmBtnStyles()}>
336
+ <div className="confirm-button">
291
337
  <Button
292
338
  variant="contained"
293
339
  type="primary"
294
340
  size="large"
295
341
  fullWidth
296
- loading={fetchingConfirmationQuote}
342
+ loading={fetchingConfirmationRoute}
297
343
  disabled={!!confirmSwapResult.error}
298
344
  onClick={onStartConfirmSwap}>
299
345
  {i18n.t('Start Swap')}
@@ -303,33 +349,86 @@ export function ConfirmSwapPage() {
303
349
  variant="contained"
304
350
  type="primary"
305
351
  size="large"
306
- loading={fetchingConfirmationQuote}
352
+ loading={fetchingConfirmationRoute}
307
353
  onClick={setShowWallets.bind(null, true)}>
308
354
  <WalletIcon size={24} />
309
355
  </IconButton>
310
356
  </Buttons>
311
357
  }>
358
+ <Modal
359
+ anchor="bottom"
360
+ open={showSlippageWarning}
361
+ prefix={
362
+ <Button
363
+ size="small"
364
+ variant="ghost"
365
+ onClick={() => navigate('/' + navigationRoutes.settings)}>
366
+ <Typography variant="label" size="medium" color="$neutral700">
367
+ {i18n.t('Change settings')}
368
+ </Typography>
369
+ </Button>
370
+ }
371
+ container={document.querySelector('#swap-box') as HTMLDivElement}
372
+ onClose={setShowSlippageWarning.bind(null, (prevState) => !prevState)}>
373
+ {confirmSwapResult.warnings?.slippage && (
374
+ <MessageBox
375
+ type="warning"
376
+ title={
377
+ confirmSwapResult.warnings.slippage.type ===
378
+ SlippageWarningType.HIGH_SLIPPAGE
379
+ ? i18n.t('High slippage')
380
+ : i18n.t('Low slippage')
381
+ }
382
+ description={
383
+ confirmSwapResult.warnings.slippage.type ===
384
+ SlippageWarningType.HIGH_SLIPPAGE
385
+ ? i18n.t({
386
+ id: ' Caution, your slippage is high (={selectedSlippage}). Your trade may be front run.',
387
+ values: { selectedSlippage },
388
+ })
389
+ : i18n.t({
390
+ id: 'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
391
+ values: {
392
+ minRequiredSlippage:
393
+ confirmSwapResult.warnings.slippage.slippage,
394
+ },
395
+ })
396
+ }>
397
+ <Divider size={18} />
398
+ <Divider size={32} />
399
+ <Button
400
+ size="large"
401
+ type="primary"
402
+ variant="contained"
403
+ fullWidth
404
+ onClick={onConfirm}>
405
+ {i18n.t('Confirm anyway')}
406
+ </Button>
407
+ </MessageBox>
408
+ )}
409
+ </Modal>
312
410
  {showWallets && (
313
411
  <ConfirmWalletsModal
314
412
  open={showWallets}
315
413
  onClose={() => setShowWallets(false)}
316
414
  onCancel={cancelFetch}
317
- loading={fetchingConfirmationQuote}
415
+ loading={fetchingConfirmationRoute}
318
416
  onCheckBalance={onConfirmSwap}
417
+ config={config}
319
418
  />
320
419
  )}
321
420
 
322
421
  <Container>
323
- <div className={descriptionStyles()}>
422
+ <div className="description">
324
423
  <Typography variant="title" size="small">
325
424
  {i18n.t('You get')}
326
425
  </Typography>
327
426
  <Button
328
427
  style={{ padding: '0' }}
329
428
  variant="ghost"
330
- disabled={fetchingConfirmationQuote}
429
+ disabled={fetchingConfirmationRoute}
331
430
  onClick={onRefresh}>
332
- <div className={iconStyles()}>
431
+ <div className="icon">
333
432
  <RefreshIcon size={16} />
334
433
  </div>
335
434
  </Button>
@@ -340,38 +439,88 @@ export function ConfirmSwapPage() {
340
439
  <Divider size={12} />
341
440
  </>
342
441
  )}
343
- {confirmSwapResult.warnings?.quoteUpdate && (
344
- <div className="quote-update__alert">
442
+ {confirmSwapResult.warnings?.route && (
443
+ <>
345
444
  <Alert
346
445
  variant="alarm"
347
446
  type="warning"
348
- title={
349
- confirmSwapResult.warnings.quoteUpdate &&
350
- getQuoteUpdateWarningMessage(
351
- confirmSwapResult.warnings.quoteUpdate
352
- )
447
+ title={getRouteWarningMessage(confirmSwapResult.warnings.route)}
448
+ />
449
+ <Divider size={12} />
450
+ </>
451
+ )}
452
+ {showSkeleton && <BestRouteSkeleton type="swap-preview" expanded />}
453
+ {showBestRoute && (
454
+ <BestRoute
455
+ expanded={true}
456
+ tooltipContainer={getContainer()}
457
+ steps={formatBestRoute(bestRoute, blockchains) ?? []}
458
+ input={{
459
+ value: numberToString(
460
+ inputAmount,
461
+ TOKEN_AMOUNT_MIN_DECIMALS,
462
+ TOKEN_AMOUNT_MAX_DECIMALS
463
+ ),
464
+ usdValue: numberToString(
465
+ inputUsdValue,
466
+ USD_VALUE_MIN_DECIMALS,
467
+ USD_VALUE_MAX_DECIMALS
468
+ ),
469
+ }}
470
+ output={{
471
+ value: numberToString(
472
+ outputAmount,
473
+ TOKEN_AMOUNT_MIN_DECIMALS,
474
+ TOKEN_AMOUNT_MAX_DECIMALS
475
+ ),
476
+ usdValue: numberToString(
477
+ outputUsdValue,
478
+ USD_VALUE_MIN_DECIMALS,
479
+ USD_VALUE_MAX_DECIMALS
480
+ ),
481
+ }}
482
+ totalFee={numberToString(
483
+ totalFeeInUsd,
484
+ GAS_FEE_MIN_DECIMALS,
485
+ GAS_FEE_MAX_DECIMALS
486
+ )}
487
+ totalTime={secondsToString(
488
+ totalArrivalTime(bestRoute.result?.swaps)
489
+ )}
490
+ recommended={true}
491
+ type="swap-preview"
492
+ percentageChange={percentageChange}
493
+ warningLevel={warningLevel}
494
+ />
495
+ )}
496
+ {showNoRouteFound && (
497
+ <>
498
+ <Divider size={12} />
499
+ <NoRoutes
500
+ diagnosisMessage={
501
+ confirmSwapResult.error?.type === ConfirmSwapErrorTypes.NO_ROUTE
502
+ ? confirmSwapResult.error.diagnosisMessage
503
+ : undefined
353
504
  }
505
+ error={
506
+ confirmSwapResult.error?.type ===
507
+ ConfirmSwapErrorTypes.REQUEST_FAILED
508
+ }
509
+ fetch={onRefresh}
354
510
  />
355
- </div>
511
+ </>
512
+ )}
513
+ {confirmSwapResult.error?.type ===
514
+ ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS && (
515
+ <>
516
+ <Alert
517
+ variant="alarm"
518
+ type="error"
519
+ title={getConfirmSwapErrorMessage(confirmSwapResult.error)}
520
+ />
521
+ <Divider size={12} />
522
+ </>
356
523
  )}
357
- <QuoteInfo
358
- quote={quote}
359
- type="swap-preview"
360
- expanded={true}
361
- alertPosition="top"
362
- error={confirmSwapResult.error}
363
- loading={fetchingConfirmationQuote}
364
- warning={confirmSwapResult.warnings?.quote ?? null}
365
- refetchQuote={onRefresh}
366
- showWarningModal={showQuoteWarningModal}
367
- onOpenWarningModal={() => setShowQuoteWarningModal(true)}
368
- onCloseWarningModal={() => setShowQuoteWarningModal(false)}
369
- onConfirmWarningModal={async () => {
370
- setShowQuoteWarningModal(false);
371
- await addNewSwap();
372
- }}
373
- onChangeSettings={() => navigate('../' + navigationRoutes.settings)}
374
- />
375
524
  </Container>
376
525
  </Layout>
377
526
  );