@rango-dev/widget-embedded 0.17.1-next.2 → 0.17.1-next.4

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 (197) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -3
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +1 -1
  5. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  6. package/dist/components/NoResult/NoResult.d.ts +4 -0
  7. package/dist/components/NoResult/NoResult.d.ts.map +1 -0
  8. package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
  9. package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
  10. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
  11. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
  12. package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
  13. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
  14. package/dist/components/NoResult/index.d.ts +2 -0
  15. package/dist/components/NoResult/index.d.ts.map +1 -0
  16. package/dist/components/Quote/Quote.d.ts +4 -0
  17. package/dist/components/Quote/Quote.d.ts.map +1 -0
  18. package/dist/components/Quote/Quote.styles.d.ts +1429 -0
  19. package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
  20. package/dist/components/Quote/Quote.types.d.ts +22 -0
  21. package/dist/components/Quote/Quote.types.d.ts.map +1 -0
  22. package/dist/components/Quote/QuoteSkeleton.d.ts +4 -0
  23. package/dist/components/Quote/QuoteSkeleton.d.ts.map +1 -0
  24. package/dist/components/Quote/QuoteSkeleton.styles.d.ts +319 -0
  25. package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +1 -0
  26. package/dist/components/Quote/QuoteSkeleton.types.d.ts +6 -0
  27. package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +1 -0
  28. package/dist/components/Quote/QuoteSummary.d.ts +11 -0
  29. package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
  30. package/dist/components/Quote/QuoteSummary.styles.d.ts +158 -0
  31. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
  32. package/dist/components/Quote/index.d.ts +4 -0
  33. package/dist/components/Quote/index.d.ts.map +1 -0
  34. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
  35. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
  36. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
  37. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
  38. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
  39. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
  40. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
  41. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
  42. package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
  43. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
  44. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +22 -0
  45. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
  46. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
  47. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
  48. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
  49. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
  50. package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
  51. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
  52. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  53. package/dist/components/WidgetEvents.d.ts.map +1 -1
  54. package/dist/constants/errors.d.ts +4 -4
  55. package/dist/constants/errors.d.ts.map +1 -1
  56. package/dist/constants/messages.d.ts +1 -1
  57. package/dist/constants/warnings.d.ts +2 -2
  58. package/dist/constants/warnings.d.ts.map +1 -1
  59. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
  60. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
  61. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +472 -0
  62. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
  63. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +17 -0
  64. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
  65. package/dist/containers/QuoteInfo/index.d.ts +2 -0
  66. package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
  67. package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
  68. package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
  69. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
  70. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
  71. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +16 -0
  72. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
  73. package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
  74. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
  75. package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
  76. package/dist/hooks/useFetchQuote.d.ts.map +1 -0
  77. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  78. package/dist/hooks/useSwapInput.d.ts +4 -2
  79. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  80. package/dist/index.js +1 -1
  81. package/dist/index.js.map +4 -4
  82. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  83. package/dist/pages/Home.d.ts.map +1 -1
  84. package/dist/store/app.d.ts +2 -2
  85. package/dist/store/{bestRoute.d.ts → quote.d.ts} +25 -20
  86. package/dist/store/quote.d.ts.map +1 -0
  87. package/dist/types/index.d.ts +1 -1
  88. package/dist/types/index.d.ts.map +1 -1
  89. package/dist/types/quote.d.ts +82 -0
  90. package/dist/types/quote.d.ts.map +1 -0
  91. package/dist/utils/numbers.d.ts +1 -1
  92. package/dist/utils/numbers.d.ts.map +1 -1
  93. package/dist/utils/{routing.d.ts → quote.d.ts} +16 -12
  94. package/dist/utils/quote.d.ts.map +1 -0
  95. package/dist/utils/settings.d.ts +1 -1
  96. package/dist/utils/swap.d.ts +22 -20
  97. package/dist/utils/swap.d.ts.map +1 -1
  98. package/dist/utils/wallets.d.ts +1 -1
  99. package/package.json +3 -3
  100. package/src/components/BlockchainsSection/BlockchainsSection.tsx +3 -3
  101. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
  102. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +23 -26
  103. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -1
  104. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
  105. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
  106. package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +16 -9
  107. package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
  108. package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +7 -12
  109. package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
  110. package/src/components/NoResult/index.ts +1 -0
  111. package/src/components/Quote/Quote.styles.ts +212 -0
  112. package/src/components/Quote/Quote.tsx +347 -0
  113. package/src/components/Quote/Quote.types.ts +16 -0
  114. package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
  115. package/src/components/Quote/QuoteSkeleton.tsx +108 -0
  116. package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
  117. package/src/components/Quote/QuoteSummary.styles.ts +15 -0
  118. package/src/components/Quote/QuoteSummary.tsx +46 -0
  119. package/src/components/Quote/index.ts +3 -0
  120. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
  121. package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +3 -3
  122. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +67 -0
  123. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
  124. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +24 -0
  125. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
  126. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
  127. package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
  128. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  129. package/src/components/SwapDetails/SwapDetails.tsx +13 -16
  130. package/src/components/SwitchFromAndTo.tsx +2 -2
  131. package/src/components/UpdateUrl.tsx +12 -12
  132. package/src/components/WidgetEvents.tsx +2 -3
  133. package/src/constants/errors.ts +8 -10
  134. package/src/constants/messages.ts +1 -1
  135. package/src/constants/warnings.ts +7 -7
  136. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +15 -0
  137. package/src/containers/QuoteInfo/QuoteInfo.tsx +97 -0
  138. package/src/containers/QuoteInfo/QuoteInfo.types.ts +17 -0
  139. package/src/containers/QuoteInfo/index.ts +1 -0
  140. package/src/hooks/useConfirmSwap/index.ts +1 -0
  141. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +168 -0
  142. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +136 -0
  143. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
  144. package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
  145. package/src/hooks/useNavigateBack.ts +3 -3
  146. package/src/hooks/useSwapInput.ts +57 -23
  147. package/src/hooks/useSyncStoresWithConfig.ts +2 -2
  148. package/src/pages/ConfirmSwapPage.tsx +58 -227
  149. package/src/pages/HistoryPage.tsx +1 -1
  150. package/src/pages/Home.tsx +52 -241
  151. package/src/pages/LanguagePage.tsx +1 -1
  152. package/src/pages/LiquiditySourcePage.tsx +1 -1
  153. package/src/pages/SelectBlockchainPage.tsx +3 -3
  154. package/src/pages/SelectSwapItemsPage.tsx +2 -2
  155. package/src/pages/SettingsPage.tsx +1 -1
  156. package/src/pages/ThemePage.tsx +1 -1
  157. package/src/pages/WalletsPage.tsx +1 -1
  158. package/src/store/{bestRoute.ts → quote.ts} +42 -38
  159. package/src/types/index.ts +1 -1
  160. package/src/types/quote.ts +107 -0
  161. package/src/utils/numbers.ts +1 -1
  162. package/src/utils/quote.ts +338 -0
  163. package/src/utils/swap.ts +99 -69
  164. package/src/utils/wallets.ts +2 -2
  165. package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
  166. package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
  167. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
  168. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
  169. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
  170. package/dist/components/NoRoutes/index.d.ts +0 -2
  171. package/dist/components/NoRoutes/index.d.ts.map +0 -1
  172. package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
  173. package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
  174. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
  175. package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
  176. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
  177. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
  178. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
  179. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
  180. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
  181. package/dist/components/RouteErrors/index.d.ts +0 -2
  182. package/dist/components/RouteErrors/index.d.ts.map +0 -1
  183. package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
  184. package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
  185. package/dist/store/bestRoute.d.ts.map +0 -1
  186. package/dist/types/routing.d.ts +0 -65
  187. package/dist/types/routing.d.ts.map +0 -1
  188. package/dist/utils/routing.d.ts.map +0 -1
  189. package/src/components/NoRoutes/index.ts +0 -1
  190. package/src/components/RouteErrors/RouteErrors.tsx +0 -79
  191. package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
  192. package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
  193. package/src/components/RouteErrors/index.ts +0 -1
  194. package/src/hooks/useConfirmSwap.ts +0 -303
  195. package/src/types/routing.ts +0 -77
  196. package/src/utils/routing.ts +0 -321
  197. /package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +0 -0
@@ -1,32 +1,16 @@
1
- import type { SwapResult } from 'rango-sdk';
2
-
3
1
  import { i18n } from '@lingui/core';
4
- import {
5
- Alert,
6
- BestRoute,
7
- BestRouteSkeleton,
8
- Button,
9
- Divider,
10
- styled,
11
- SwapInput,
12
- Typography,
13
- WarningIcon,
14
- } from '@rango-dev/ui';
2
+ import { Button, styled, SwapInput, WarningIcon } from '@rango-dev/ui';
15
3
  import React, { useEffect, useRef, useState } from 'react';
16
4
  import { useNavigate } from 'react-router-dom';
17
5
 
18
6
  import { HomeButtons } from '../components/HeaderButtons';
19
7
  import { Layout } from '../components/Layout';
20
- import { NoRoutes } from '../components/NoRoutes';
21
- import { RouteErrors } from '../components/RouteErrors';
22
8
  import { SwitchFromAndToButton } from '../components/SwitchFromAndTo';
23
9
  import { errorMessages } from '../constants/errors';
24
10
  import { navigationRoutes } from '../constants/navigationRoutes';
25
11
  import {
26
12
  BALANCE_MAX_DECIMALS,
27
13
  BALANCE_MIN_DECIMALS,
28
- GAS_FEE_MAX_DECIMALS,
29
- GAS_FEE_MIN_DECIMALS,
30
14
  PERCENTAGE_CHANGE_MAX_DECIMALS,
31
15
  PERCENTAGE_CHANGE_MIN_DECIMALS,
32
16
  TOKEN_AMOUNT_MAX_DECIMALS,
@@ -34,29 +18,22 @@ import {
34
18
  USD_VALUE_MAX_DECIMALS,
35
19
  USD_VALUE_MIN_DECIMALS,
36
20
  } from '../constants/routing';
21
+ import { QuoteInfo } from '../containers/QuoteInfo';
37
22
  import { useSwapInput } from '../hooks/useSwapInput';
38
- import { useBestRouteStore } from '../store/bestRoute';
39
23
  import { useMetaStore } from '../store/meta';
24
+ import { useQuoteStore } from '../store/quote';
40
25
  import { useUiStore } from '../store/ui';
41
26
  import { useWalletsStore } from '../store/wallets';
42
27
  import { ButtonState } from '../types';
43
- import { getContainer } from '../utils/common';
44
- import { getBlockchainShortNameFor } from '../utils/meta';
45
- import {
46
- numberToString,
47
- secondsToString,
48
- totalArrivalTime,
49
- } from '../utils/numbers';
50
- import { getFormattedBestRoute, getPriceImpactLevel } from '../utils/routing';
28
+ import { numberToString } from '../utils/numbers';
29
+ import { getPriceImpact, getPriceImpactLevel } from '../utils/quote';
51
30
  import {
52
31
  canComputePriceImpact,
53
32
  getOutputRatio,
54
33
  getPercentageChange,
55
34
  getSwapButtonState,
56
- getTotalFeeInUsd,
35
+ hasHighValueLoss,
57
36
  hasLimitError,
58
- LimitErrorMessage,
59
- outputRatioHasWarning,
60
37
  } from '../utils/swap';
61
38
  import { getBalanceFromWallet } from '../utils/wallets';
62
39
 
@@ -76,27 +53,13 @@ const InputsContainer = styled('div', {
76
53
  gap: 5,
77
54
  alignSelf: 'stretch',
78
55
  });
79
-
80
- const BestRouteContainer = styled('div', {
81
- width: '100%',
82
- paddingTop: '$2',
83
- });
84
-
85
- const FooterStepAlarm = styled('div', {
86
- paddingBottom: '$15',
87
- });
88
-
89
- const FooterAlert = styled('div', {
90
- width: '100%',
91
- display: 'flex',
92
- });
93
-
94
56
  export function Home() {
95
57
  const navigate = useNavigate();
96
58
  const {
97
- fetch: refetchBestRoute,
98
- loading: fetchingBestRoute,
99
- error: bestRouteError,
59
+ fetch: fetchQuote,
60
+ loading: fetchingQuote,
61
+ error: quoteError,
62
+ warning: quoteWarning,
100
63
  } = useSwapInput();
101
64
  const {
102
65
  fromToken,
@@ -108,51 +71,40 @@ export function Home() {
108
71
  inputUsdValue,
109
72
  outputAmount,
110
73
  outputUsdValue,
111
- bestRoute,
112
- resetRouteWallets,
113
- } = useBestRouteStore();
74
+ quote,
75
+ resetQuoteWallets,
76
+ setQuoteWarningsConfirmed,
77
+ } = useQuoteStore();
114
78
 
115
- const {
116
- meta: { tokens, blockchains },
117
- loadingStatus: loadingMetaStatus,
118
- } = useMetaStore();
79
+ const { loadingStatus: loadingMetaStatus } = useMetaStore();
119
80
 
120
81
  const connectedWallets = useWalletsStore.use.connectedWallets();
121
82
  const setCurrentPage = useUiStore.use.setCurrentPage();
122
- const [openWarningModal, setOpenWarningModal] = useState(false);
123
- const {
124
- fromAmountRangeError,
125
- swap: swapHasError,
126
- recommendation,
127
- } = LimitErrorMessage(bestRoute);
83
+ const [showQuoteWarningModal, setShowQuoteWarningModal] = useState(false);
128
84
  const layoutRef = useRef<HTMLDivElement>(null);
129
85
 
130
- const showBestRoute =
131
- !!Number(inputAmount) &&
132
- (!!bestRoute || fetchingBestRoute || !!bestRouteError);
133
-
134
86
  const needsToWarnEthOnPath = false;
135
87
 
136
88
  const outToInRatio = getOutputRatio(inputUsdValue, outputUsdValue);
137
- const highValueLoss = outputRatioHasWarning(inputUsdValue, outToInRatio);
89
+ const highValueLoss = hasHighValueLoss(inputUsdValue, outToInRatio);
138
90
 
139
91
  const priceImpactInputCanNotBeComputed = !canComputePriceImpact(
140
- bestRoute,
92
+ quote,
141
93
  inputAmount,
142
94
  inputUsdValue
143
95
  );
144
96
 
145
97
  const priceImpactOutputCanNotBeComputed = !canComputePriceImpact(
146
- bestRoute,
98
+ quote,
147
99
  inputAmount,
148
100
  outputUsdValue
149
101
  );
150
102
  const swapButtonState = getSwapButtonState(
151
103
  loadingMetaStatus,
152
104
  connectedWallets,
153
- fetchingBestRoute,
154
- bestRoute,
155
- hasLimitError(bestRoute),
105
+ fetchingQuote,
106
+ quote,
107
+ hasLimitError(quote),
156
108
  highValueLoss,
157
109
  priceImpactInputCanNotBeComputed || priceImpactOutputCanNotBeComputed,
158
110
  needsToWarnEthOnPath,
@@ -193,7 +145,7 @@ export function Home() {
193
145
 
194
146
  useEffect(() => {
195
147
  setCurrentPage(navigationRoutes.home);
196
- resetRouteWallets();
148
+ resetQuoteWallets();
197
149
  return setCurrentPage.bind(null, '');
198
150
  }, []);
199
151
 
@@ -201,83 +153,9 @@ export function Home() {
201
153
  !inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)
202
154
  ? null
203
155
  : getPercentageChange(
204
- inputUsdValue.toNumber(),
205
- outputUsdValue.toNumber()
156
+ inputUsdValue.toString(),
157
+ outputUsdValue.toString()
206
158
  );
207
-
208
- const getBestRouteSteps = (swaps: SwapResult[]) => {
209
- return swaps.map((swap, index) => ({
210
- swapper: { displayName: swap.swapperId, image: swap.swapperLogo },
211
- from: {
212
- token: { displayName: swap.from.symbol, image: swap.from.logo },
213
- chain: {
214
- displayName:
215
- getBlockchainShortNameFor(swap.from.blockchain, blockchains) ?? '',
216
- image: swap.from.blockchainLogo,
217
- },
218
- price: {
219
- value:
220
- index === 0
221
- ? numberToString(
222
- inputAmount,
223
- TOKEN_AMOUNT_MIN_DECIMALS,
224
- TOKEN_AMOUNT_MAX_DECIMALS
225
- )
226
- : swap.fromAmount,
227
- },
228
- },
229
- to: {
230
- token: { displayName: swap.to.symbol, image: swap.to.logo },
231
- chain: {
232
- displayName:
233
- getBlockchainShortNameFor(swap.to.blockchain, blockchains) ?? '',
234
- image: swap.to.blockchainLogo,
235
- },
236
- price: {
237
- value: swap.toAmount,
238
- },
239
- },
240
- alerts:
241
- swap.swapperId === swapHasError?.swapperId ? (
242
- <FooterStepAlarm>
243
- <Alert
244
- type="error"
245
- title={recommendation}
246
- footer={
247
- <FooterAlert>
248
- <Typography size="xsmall" variant="body" color="neutral700">
249
- {fromAmountRangeError}
250
- </Typography>
251
- <Divider direction="horizontal" size={8} />
252
- <Typography size="xsmall" variant="body" color="neutral700">
253
- |
254
- </Typography>
255
- <Divider direction="horizontal" size={8} />
256
- <Typography size="xsmall" variant="body" color="neutral700">
257
- {i18n.t({
258
- id: 'Yours: {amount} {symbol}',
259
- values: {
260
- amount: numberToString(
261
- swapHasError?.fromAmount || null,
262
- TOKEN_AMOUNT_MIN_DECIMALS,
263
- TOKEN_AMOUNT_MAX_DECIMALS
264
- ),
265
- symbol: swap?.from.symbol,
266
- },
267
- })}
268
- </Typography>
269
- </FooterAlert>
270
- }
271
- />
272
- </FooterStepAlarm>
273
- ) : undefined,
274
- }));
275
- };
276
-
277
- const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
278
-
279
- const bestRouteData = getFormattedBestRoute(bestRoute);
280
-
281
159
  return (
282
160
  <Layout
283
161
  ref={layoutRef}
@@ -296,8 +174,8 @@ export function Home() {
296
174
  onClick={() => {
297
175
  if (swapButtonState.state === ButtonState.WAITFORCONNECTING) {
298
176
  navigate(navigationRoutes.wallets);
299
- } else if (swapButtonState.state === ButtonState.NEEDTOCONFIRM) {
300
- setOpenWarningModal(true);
177
+ } else if (quoteWarning) {
178
+ setShowQuoteWarningModal(true);
301
179
  } else {
302
180
  navigate(navigationRoutes.confirmSwap);
303
181
  }
@@ -311,9 +189,7 @@ export function Home() {
311
189
  suffix: (
312
190
  <HomeButtons
313
191
  layoutRef={layoutRef.current}
314
- onClickRefresh={
315
- !!bestRoute || bestRouteError ? refetchBestRoute : undefined
316
- }
192
+ onClickRefresh={!!quote || quoteError ? fetchQuote : undefined}
317
193
  onClickHistory={() => navigate(navigationRoutes.swaps)}
318
194
  onClickSettings={() => navigate(navigationRoutes.settings)}
319
195
  />
@@ -324,6 +200,8 @@ export function Home() {
324
200
  <FromContainer>
325
201
  <SwapInput
326
202
  label={i18n.t('From')}
203
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
204
+ //@ts-ignore
327
205
  mode="From"
328
206
  onInputChange={setInputAmount}
329
207
  balance={tokenBalance}
@@ -360,7 +238,7 @@ export function Home() {
360
238
  <SwitchFromAndToButton />
361
239
  </FromContainer>
362
240
  <SwapInput
363
- sharpBottomStyle={!!bestRoute?.result || fetchingBestRoute}
241
+ sharpBottomStyle={!!quote?.result || fetchingQuote}
364
242
  label={i18n.t('To')}
365
243
  mode="To"
366
244
  chain={{
@@ -371,18 +249,12 @@ export function Home() {
371
249
  displayName: toToken?.symbol || '',
372
250
  image: toToken?.image || '',
373
251
  }}
374
- percentageChange={
375
- !!percentageChange?.lt(0)
376
- ? numberToString(
377
- percentageChange,
378
- PERCENTAGE_CHANGE_MIN_DECIMALS,
379
- PERCENTAGE_CHANGE_MAX_DECIMALS
380
- )
381
- : null
382
- }
383
- warningLevel={getPriceImpactLevel(
384
- percentageChange?.toNumber() ?? 0
252
+ percentageChange={numberToString(
253
+ getPriceImpact(inputUsdValue, outputUsdValue),
254
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
255
+ PERCENTAGE_CHANGE_MAX_DECIMALS
385
256
  )}
257
+ warningLevel={getPriceImpactLevel(percentageChange ?? 0)}
386
258
  price={{
387
259
  value: numberToString(
388
260
  outputAmount,
@@ -405,84 +277,23 @@ export function Home() {
405
277
  loading={loadingMetaStatus === 'loading'}
406
278
  />
407
279
  </InputsContainer>
408
- {fetchingBestRoute && (
409
- <BestRouteContainer>
410
- <BestRouteSkeleton type="basic" />
411
- </BestRouteContainer>
412
- )}
413
- {showBestRoute &&
414
- !fetchingBestRoute &&
415
- bestRouteData?.result?.swaps?.length ? (
416
- <BestRouteContainer>
417
- <BestRoute
418
- type="basic"
419
- recommended={true}
420
- tooltipContainer={getContainer()}
421
- input={{
422
- value: numberToString(
423
- inputAmount,
424
- TOKEN_AMOUNT_MIN_DECIMALS,
425
- TOKEN_AMOUNT_MAX_DECIMALS
426
- ),
427
- usdValue: numberToString(
428
- inputUsdValue,
429
- USD_VALUE_MIN_DECIMALS,
430
- USD_VALUE_MAX_DECIMALS
431
- ),
432
- }}
433
- output={{
434
- value: numberToString(
435
- outputAmount,
436
- TOKEN_AMOUNT_MIN_DECIMALS,
437
- TOKEN_AMOUNT_MAX_DECIMALS
438
- ),
439
- usdValue: numberToString(
440
- outputUsdValue,
441
- USD_VALUE_MIN_DECIMALS,
442
- USD_VALUE_MAX_DECIMALS
443
- ),
444
- }}
445
- steps={getBestRouteSteps(bestRouteData.result.swaps)}
446
- percentageChange={numberToString(
447
- percentageChange,
448
- PERCENTAGE_CHANGE_MIN_DECIMALS,
449
- PERCENTAGE_CHANGE_MAX_DECIMALS
450
- )}
451
- totalFee={numberToString(
452
- totalFeeInUsd,
453
- GAS_FEE_MIN_DECIMALS,
454
- GAS_FEE_MAX_DECIMALS
455
- )}
456
- totalTime={secondsToString(
457
- totalArrivalTime(bestRoute?.result?.swaps)
458
- )}
459
- />
460
- </BestRouteContainer>
461
- ) : showBestRoute && !fetchingBestRoute ? (
462
- <>
463
- <Divider size={20} />
464
- <NoRoutes
465
- diagnosisMessage={bestRouteData?.diagnosisMessages?.[0]}
466
- fetch={refetchBestRoute}
467
- error={!!bestRouteError}
468
- />
469
- </>
470
- ) : null}
280
+ <QuoteInfo
281
+ quote={quote}
282
+ loading={fetchingQuote}
283
+ error={quoteError}
284
+ warning={quoteWarning}
285
+ type="basic"
286
+ refetchQuote={fetchQuote}
287
+ showWarningModal={showQuoteWarningModal}
288
+ onOpenWarningModal={() => setShowQuoteWarningModal(true)}
289
+ onCloseWarningModal={() => setShowQuoteWarningModal(false)}
290
+ onConfirmWarningModal={() => {
291
+ setShowQuoteWarningModal(false);
292
+ setQuoteWarningsConfirmed(true);
293
+ navigate(navigationRoutes.confirmSwap);
294
+ }}
295
+ />
471
296
  </Container>
472
- <RouteErrors
473
- openModal={openWarningModal}
474
- onToggle={setOpenWarningModal}
475
- totalFeeInUsd={totalFeeInUsd}
476
- outputUsdValue={outputUsdValue}
477
- inputUsdValue={inputUsdValue}
478
- percentageChange={percentageChange}
479
- highValueLoss={highValueLoss}
480
- priceImpactCanNotBeComputed={
481
- priceImpactInputCanNotBeComputed || priceImpactOutputCanNotBeComputed
482
- }
483
- loading={fetchingBestRoute || loadingMetaStatus === 'loading'}
484
- extraSpace={!!bestRoute?.result || !bestRoute}
485
- />
486
297
  </Layout>
487
298
  );
488
299
  }
@@ -38,7 +38,7 @@ export function LanguagePage() {
38
38
  return (
39
39
  <Layout
40
40
  header={{
41
- onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
41
+ onBack: () => navigateBackFrom(navigationRoutes.settings),
42
42
  title: i18n.t('Language'),
43
43
  }}>
44
44
  <SettingsContainer>
@@ -111,7 +111,7 @@ export function LiquiditySourcePage({
111
111
  return (
112
112
  <Layout
113
113
  header={{
114
- onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
114
+ onBack: () => navigateBackFrom(navigationRoutes.settings),
115
115
  title: i18n.t(sourceType),
116
116
  suffix: (
117
117
  <LiquiditySourceSuffix>
@@ -8,8 +8,8 @@ import { SearchInput } from '../components/SearchInput';
8
8
  import { navigationRoutes } from '../constants/navigationRoutes';
9
9
  import { useNavigateBack } from '../hooks/useNavigateBack';
10
10
  import { useAppStore } from '../store/app';
11
- import { useBestRouteStore } from '../store/bestRoute';
12
11
  import { useMetaStore } from '../store/meta';
12
+ import { useQuoteStore } from '../store/quote';
13
13
 
14
14
  interface PropTypes {
15
15
  type: 'source' | 'destination';
@@ -20,8 +20,8 @@ export function SelectBlockchainPage(props: PropTypes) {
20
20
  const { navigateBackFrom } = useNavigateBack();
21
21
  const [searchedFor, setSearchedFor] = useState<string>('');
22
22
  const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
23
- const setToBlockchain = useBestRouteStore.use.setToBlockchain();
24
- const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
23
+ const setToBlockchain = useQuoteStore.use.setToBlockchain();
24
+ const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
25
25
  const { loadingStatus } = useMetaStore();
26
26
 
27
27
  const blockchains = useAppStore().blockchains({
@@ -12,7 +12,7 @@ import { TokenList } from '../components/TokenList/TokenList';
12
12
  import { navigationRoutes } from '../constants/navigationRoutes';
13
13
  import { useNavigateBack } from '../hooks/useNavigateBack';
14
14
  import { useAppStore } from '../store/app';
15
- import { useBestRouteStore } from '../store/bestRoute';
15
+ import { useQuoteStore } from '../store/quote';
16
16
  import { useWalletsStore } from '../store/wallets';
17
17
  import { getTokensBalanceFromWalletAndSort } from '../utils/wallets';
18
18
 
@@ -31,7 +31,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
31
31
  setToToken,
32
32
  setFromBlockchain,
33
33
  setToBlockchain,
34
- } = useBestRouteStore();
34
+ } = useQuoteStore();
35
35
  const { connectedWallets } = useWalletsStore();
36
36
  const [searchedFor, setSearchedFor] = useState<string>('');
37
37
 
@@ -175,7 +175,7 @@ export function SettingsPage({ supportedSwappers, singleTheme }: PropTypes) {
175
175
  return (
176
176
  <Layout
177
177
  header={{
178
- onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
178
+ onBack: () => navigateBackFrom(navigationRoutes.settings),
179
179
  title: i18n.t('Setting'),
180
180
  }}>
181
181
  <SettingsContainer>
@@ -72,7 +72,7 @@ export function ThemePage() {
72
72
  return (
73
73
  <Layout
74
74
  header={{
75
- onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
75
+ onBack: () => navigateBackFrom(navigationRoutes.settings),
76
76
  title: i18n.t('Theme'),
77
77
  }}>
78
78
  <SettingsContainer>
@@ -71,7 +71,7 @@ export function WalletsPage({ config }: PropTypes) {
71
71
  <Layout
72
72
  header={{
73
73
  title: i18n.t('Connect Wallets'),
74
- onBack: navigateBackFrom.bind(null, navigationRoutes.wallets),
74
+ onBack: () => navigateBackFrom(navigationRoutes.wallets),
75
75
  }}>
76
76
  <Container>
77
77
  <Typography variant="title" size="xmedium" align="center">