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

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 (195) 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/constants/errors.d.ts +4 -4
  54. package/dist/constants/errors.d.ts.map +1 -1
  55. package/dist/constants/messages.d.ts +1 -1
  56. package/dist/constants/warnings.d.ts +2 -2
  57. package/dist/constants/warnings.d.ts.map +1 -1
  58. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
  59. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
  60. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +472 -0
  61. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
  62. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +17 -0
  63. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
  64. package/dist/containers/QuoteInfo/index.d.ts +2 -0
  65. package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
  66. package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
  67. package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
  68. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
  69. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
  70. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +16 -0
  71. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
  72. package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
  73. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
  74. package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
  75. package/dist/hooks/useFetchQuote.d.ts.map +1 -0
  76. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  77. package/dist/hooks/useSwapInput.d.ts +4 -2
  78. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  79. package/dist/index.js +1 -1
  80. package/dist/index.js.map +4 -4
  81. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  82. package/dist/pages/Home.d.ts.map +1 -1
  83. package/dist/store/app.d.ts +2 -2
  84. package/dist/store/{bestRoute.d.ts → quote.d.ts} +25 -20
  85. package/dist/store/quote.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +1 -1
  87. package/dist/types/index.d.ts.map +1 -1
  88. package/dist/types/quote.d.ts +82 -0
  89. package/dist/types/quote.d.ts.map +1 -0
  90. package/dist/utils/numbers.d.ts +1 -1
  91. package/dist/utils/numbers.d.ts.map +1 -1
  92. package/dist/utils/{routing.d.ts → quote.d.ts} +16 -12
  93. package/dist/utils/quote.d.ts.map +1 -0
  94. package/dist/utils/settings.d.ts +1 -1
  95. package/dist/utils/swap.d.ts +22 -20
  96. package/dist/utils/swap.d.ts.map +1 -1
  97. package/dist/utils/wallets.d.ts +1 -1
  98. package/package.json +2 -2
  99. package/src/components/BlockchainsSection/BlockchainsSection.tsx +3 -3
  100. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
  101. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +23 -26
  102. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -1
  103. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
  104. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
  105. package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +16 -9
  106. package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
  107. package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +7 -12
  108. package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
  109. package/src/components/NoResult/index.ts +1 -0
  110. package/src/components/Quote/Quote.styles.ts +212 -0
  111. package/src/components/Quote/Quote.tsx +347 -0
  112. package/src/components/Quote/Quote.types.ts +16 -0
  113. package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
  114. package/src/components/Quote/QuoteSkeleton.tsx +108 -0
  115. package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
  116. package/src/components/Quote/QuoteSummary.styles.ts +15 -0
  117. package/src/components/Quote/QuoteSummary.tsx +46 -0
  118. package/src/components/Quote/index.ts +3 -0
  119. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
  120. package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +3 -3
  121. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +67 -0
  122. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
  123. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +24 -0
  124. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
  125. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
  126. package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
  127. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  128. package/src/components/SwapDetails/SwapDetails.tsx +13 -16
  129. package/src/components/SwitchFromAndTo.tsx +2 -2
  130. package/src/components/UpdateUrl.tsx +12 -12
  131. package/src/constants/errors.ts +8 -10
  132. package/src/constants/messages.ts +1 -1
  133. package/src/constants/warnings.ts +7 -7
  134. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +15 -0
  135. package/src/containers/QuoteInfo/QuoteInfo.tsx +97 -0
  136. package/src/containers/QuoteInfo/QuoteInfo.types.ts +17 -0
  137. package/src/containers/QuoteInfo/index.ts +1 -0
  138. package/src/hooks/useConfirmSwap/index.ts +1 -0
  139. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +168 -0
  140. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +136 -0
  141. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
  142. package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
  143. package/src/hooks/useNavigateBack.ts +3 -3
  144. package/src/hooks/useSwapInput.ts +57 -23
  145. package/src/hooks/useSyncStoresWithConfig.ts +2 -2
  146. package/src/pages/ConfirmSwapPage.tsx +58 -227
  147. package/src/pages/HistoryPage.tsx +1 -1
  148. package/src/pages/Home.tsx +52 -241
  149. package/src/pages/LanguagePage.tsx +1 -1
  150. package/src/pages/LiquiditySourcePage.tsx +1 -1
  151. package/src/pages/SelectBlockchainPage.tsx +3 -3
  152. package/src/pages/SelectSwapItemsPage.tsx +2 -2
  153. package/src/pages/SettingsPage.tsx +1 -1
  154. package/src/pages/ThemePage.tsx +1 -1
  155. package/src/pages/WalletsPage.tsx +1 -1
  156. package/src/store/{bestRoute.ts → quote.ts} +42 -38
  157. package/src/types/index.ts +1 -1
  158. package/src/types/quote.ts +107 -0
  159. package/src/utils/numbers.ts +1 -1
  160. package/src/utils/quote.ts +338 -0
  161. package/src/utils/swap.ts +99 -69
  162. package/src/utils/wallets.ts +2 -2
  163. package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
  164. package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
  165. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
  166. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
  167. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
  168. package/dist/components/NoRoutes/index.d.ts +0 -2
  169. package/dist/components/NoRoutes/index.d.ts.map +0 -1
  170. package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
  171. package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
  172. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
  173. package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
  174. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
  175. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
  176. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
  177. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
  178. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
  179. package/dist/components/RouteErrors/index.d.ts +0 -2
  180. package/dist/components/RouteErrors/index.d.ts.map +0 -1
  181. package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
  182. package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
  183. package/dist/store/bestRoute.d.ts.map +0 -1
  184. package/dist/types/routing.d.ts +0 -65
  185. package/dist/types/routing.d.ts.map +0 -1
  186. package/dist/utils/routing.d.ts.map +0 -1
  187. package/src/components/NoRoutes/index.ts +0 -1
  188. package/src/components/RouteErrors/RouteErrors.tsx +0 -79
  189. package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
  190. package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
  191. package/src/components/RouteErrors/index.ts +0 -1
  192. package/src/hooks/useConfirmSwap.ts +0 -303
  193. package/src/types/routing.ts +0 -77
  194. package/src/utils/routing.ts +0 -321
  195. /package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +0 -0
package/src/utils/swap.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
2
  import type { LoadingStatus } from '../store/meta';
3
3
  import type { ConnectedWallet } from '../store/wallets';
4
- import type { ConvertedToken, SwapButtonState, Wallet } from '../types';
4
+ import type {
5
+ ConvertedToken,
6
+ RecommendedSlippages,
7
+ SwapButtonState,
8
+ Wallet,
9
+ } from '../types';
5
10
  import type {
6
11
  PendingSwap,
7
12
  PendingSwapStep,
@@ -35,7 +40,7 @@ import { ButtonState } from '../types';
35
40
 
36
41
  import { removeDuplicateFrom } from './common';
37
42
  import { numberToString } from './numbers';
38
- import { getRequiredBalanceOfWallet } from './routing';
43
+ import { getRequiredBalanceOfWallet } from './quote';
39
44
  import { getRequiredChains } from './wallets';
40
45
 
41
46
  export function getOutputRatio(
@@ -50,25 +55,29 @@ export function getOutputRatio(
50
55
  ) {
51
56
  return 0;
52
57
  }
53
- return outputUsdValue.div(inputUsdValue).minus(1).multipliedBy(100);
58
+ return outputUsdValue
59
+ .div(inputUsdValue)
60
+ .minus(1)
61
+ .multipliedBy(100)
62
+ .toNumber();
54
63
  }
55
64
 
56
- export function outputRatioHasWarning(
65
+ export function hasHighValueLoss(
57
66
  inputUsdValue: BigNumber | null,
58
- outputRatio: BigNumber | 0
67
+ priceImpact: number
59
68
  ): boolean {
60
69
  return (
61
- ((parseInt(outputRatio.toFixed(2) || '0') <= -10 &&
70
+ ((parseInt(priceImpact.toFixed(2) || '0') <= -10 &&
62
71
  inputUsdValue?.gte(new BigNumber(400))) ||
63
- (parseInt(outputRatio.toFixed(2) || '0') <= -5 &&
72
+ (parseInt(priceImpact.toFixed(2) || '0') <= -5 &&
64
73
  inputUsdValue?.gte(new BigNumber(1000)))) ??
65
74
  false
66
75
  );
67
76
  }
68
77
 
69
- export function hasLimitError(bestRoute: BestRouteResponse | null): boolean {
78
+ export function hasLimitError(quote: BestRouteResponse | null): boolean {
70
79
  return (
71
- (bestRoute?.result?.swaps || []).filter((swap) => {
80
+ (quote?.result?.swaps || []).filter((swap) => {
72
81
  const minimum = !!swap.fromAmountMinValue
73
82
  ? new BigNumber(swap.fromAmountMinValue)
74
83
  : null;
@@ -83,16 +92,12 @@ export function hasLimitError(bestRoute: BestRouteResponse | null): boolean {
83
92
  }).length > 0
84
93
  );
85
94
  }
86
-
87
- export function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
88
- swap: SwapResult | null;
95
+ export function getLimitErrorMessage(quote: BestRouteResponse): {
96
+ swap: SwapResult;
89
97
  fromAmountRangeError: string;
90
98
  recommendation: string;
91
99
  } {
92
- if (!bestRoute) {
93
- return { swap: null, fromAmountRangeError: '', recommendation: '' };
94
- }
95
- const swap = (bestRoute?.result?.swaps || []).filter((swap) => {
100
+ const swap = (quote.result?.swaps || []).filter((swap) => {
96
101
  const minimum = !!swap.fromAmountMinValue
97
102
  ? new BigNumber(swap.fromAmountMinValue)
98
103
  : null;
@@ -105,9 +110,7 @@ export function LimitErrorMessage(bestRoute: BestRouteResponse | null): {
105
110
  }
106
111
  return minimum?.gt(swap.fromAmount) || maximum?.lt(swap.fromAmount);
107
112
  })[0];
108
- if (!swap) {
109
- return { swap: null, fromAmountRangeError: '', recommendation: '' };
110
- }
113
+
111
114
  const minimum = !!swap.fromAmountMinValue
112
115
  ? new BigNumber(swap.fromAmountMinValue)
113
116
  : null;
@@ -181,7 +184,7 @@ export function getSwapButtonState(
181
184
  loadingMetaStatus: LoadingStatus,
182
185
  connectedWallets: ConnectedWallet[],
183
186
  loading: boolean,
184
- bestRoute: BestRouteResponse | null,
187
+ quote: BestRouteResponse | null,
185
188
  hasLimitError: boolean,
186
189
  highValueLoss: boolean,
187
190
  priceImpactCanNotBeComputed: boolean,
@@ -204,8 +207,8 @@ export function getSwapButtonState(
204
207
  }
205
208
  if (
206
209
  loading ||
207
- !bestRoute ||
208
- !bestRoute.result ||
210
+ !quote ||
211
+ !quote.result ||
209
212
  hasLimitError ||
210
213
  !inputAmount ||
211
214
  inputAmount === '0'
@@ -224,7 +227,7 @@ export function getSwapButtonState(
224
227
  };
225
228
  } else if (needsToWarnEthOnPath) {
226
229
  return {
227
- title: swapButtonTitles().ethRouteWarning,
230
+ title: swapButtonTitles().ethWarning,
228
231
  disabled: false,
229
232
  hasWarning: true,
230
233
  state: ButtonState.WARNING,
@@ -238,24 +241,24 @@ export function getSwapButtonState(
238
241
  }
239
242
 
240
243
  export function canComputePriceImpact(
241
- bestRoute: BestRouteResponse | null,
244
+ quote: BestRouteResponse | null,
242
245
  inputAmount: string,
243
246
  usdValue: BigNumber | null
244
247
  ) {
245
248
  return !(
246
249
  (!usdValue || usdValue.lte(ZERO)) &&
247
- !!bestRoute?.result &&
250
+ !!quote?.result &&
248
251
  !!inputAmount &&
249
252
  inputAmount !== '0' &&
250
253
  parseFloat(inputAmount || '0') !== 0 &&
251
- !!bestRoute.result
254
+ !!quote.result
252
255
  );
253
256
  }
254
257
 
255
- export function requiredWallets(route: BestRouteResponse | null) {
258
+ export function requiredWallets(quote: BestRouteResponse | null) {
256
259
  const wallets: string[] = [];
257
260
 
258
- route?.result?.swaps.forEach((swap) => {
261
+ quote?.result?.swaps.forEach((swap) => {
259
262
  const currentStepFromBlockchain = swap.from.blockchain;
260
263
  const currentStepToBlockchain = swap.to.blockchain;
261
264
  let lastAddedWallet = wallets[wallets.length - 1];
@@ -311,15 +314,13 @@ export function getUsdFeeOfStep(
311
314
  }
312
315
 
313
316
  export function getTotalFeeInUsd(
314
- bestRoute: BestRouteResponse | null,
317
+ swaps: SwapResult[],
315
318
  allTokens: Token[]
316
- ): BigNumber | null {
317
- return (
318
- bestRoute?.result?.swaps.reduce(
319
- (totalFee: BigNumber, step) =>
320
- totalFee.plus(getUsdFeeOfStep(step, allTokens)),
321
- ZERO
322
- ) || null
319
+ ): BigNumber {
320
+ return swaps.reduce(
321
+ (totalFee: BigNumber, step) =>
322
+ totalFee.plus(getUsdFeeOfStep(step, allTokens)),
323
+ ZERO
323
324
  );
324
325
  }
325
326
 
@@ -336,10 +337,44 @@ export function hasSlippageError(
336
337
  return (slippages?.filter((s) => !!s?.error)?.length || 0) > 0;
337
338
  }
338
339
 
340
+ export function checkSlippageErrors(
341
+ quote: BestRouteResponse
342
+ ): RecommendedSlippages | null {
343
+ const recommendedSlippages: RecommendedSlippages = new Map();
344
+ quote.result?.swaps.forEach((swap, index) => {
345
+ if (swap.recommendedSlippage?.error) {
346
+ recommendedSlippages.set(index, swap.recommendedSlippage.slippage);
347
+ }
348
+ });
349
+ if (recommendedSlippages.size > 0) {
350
+ return recommendedSlippages;
351
+ }
352
+ return null;
353
+ }
354
+
355
+ export function checkSlippageWarnings(
356
+ quote: BestRouteResponse,
357
+ userSlippage: number
358
+ ): RecommendedSlippages | null {
359
+ const recommendedSlippages: RecommendedSlippages = new Map();
360
+ quote.result?.swaps.forEach((swap, index) => {
361
+ if (
362
+ swap.recommendedSlippage?.slippage &&
363
+ parseInt(swap.recommendedSlippage?.slippage) > userSlippage
364
+ ) {
365
+ recommendedSlippages.set(index, swap.recommendedSlippage.slippage);
366
+ }
367
+ });
368
+ if (recommendedSlippages.size > 0) {
369
+ return recommendedSlippages;
370
+ }
371
+ return null;
372
+ }
373
+
339
374
  export function getMinRequiredSlippage(
340
- route: BestRouteResponse
375
+ quote: BestRouteResponse
341
376
  ): string | null {
342
- const slippages = route.result?.swaps.map(
377
+ const slippages = quote.result?.swaps.map(
343
378
  (slippage) => slippage.recommendedSlippage
344
379
  );
345
380
  return (
@@ -362,10 +397,10 @@ export function hasProperSlippage(
362
397
  }
363
398
 
364
399
  export function hasEnoughBalance(
365
- route: BestRouteResponse,
400
+ quote: BestRouteResponse,
366
401
  selectedWallets: Wallet[]
367
402
  ) {
368
- const fee = route.validationStatus;
403
+ const fee = quote.validationStatus;
369
404
 
370
405
  if (fee === null || fee.length === 0) {
371
406
  return true;
@@ -389,18 +424,18 @@ export function hasEnoughBalance(
389
424
  }
390
425
 
391
426
  export function hasEnoughBalanceAndProperSlippage(
392
- route: BestRouteResponse,
427
+ quote: BestRouteResponse,
393
428
  selectedWallets: Wallet[],
394
429
  userSlippage: string,
395
430
  minRequiredSlippage: string | null
396
431
  ): boolean {
397
432
  return (
398
- hasEnoughBalance(route, selectedWallets) &&
433
+ hasEnoughBalance(quote, selectedWallets) &&
399
434
  hasProperSlippage(userSlippage, minRequiredSlippage)
400
435
  );
401
436
  }
402
437
 
403
- export function createBestRouteRequestBody(params: {
438
+ export function createQuoteRequestBody(params: {
404
439
  fromToken: Token;
405
440
  toToken: Token;
406
441
  inputAmount: string;
@@ -411,7 +446,7 @@ export function createBestRouteRequestBody(params: {
411
446
  affiliateRef: string | null;
412
447
  affiliatePercent: number | null;
413
448
  affiliateWallets: { [key: string]: string } | null;
414
- initialRoute?: BestRouteResponse;
449
+ initialQuote?: BestRouteResponse;
415
450
  destination?: string;
416
451
  }): BestRouteRequest {
417
452
  const {
@@ -425,7 +460,7 @@ export function createBestRouteRequestBody(params: {
425
460
  affiliateRef,
426
461
  affiliatePercent,
427
462
  affiliateWallets,
428
- initialRoute,
463
+ initialQuote,
429
464
  destination,
430
465
  } = params;
431
466
  const selectedWalletsMap = selectedWallets?.reduce(
@@ -455,10 +490,10 @@ export function createBestRouteRequestBody(params: {
455
490
  }
456
491
  });
457
492
 
458
- const checkPrerequisites = !!initialRoute;
493
+ const checkPrerequisites = !!initialQuote;
459
494
 
460
495
  const filteredBlockchains = removeDuplicateFrom(
461
- (initialRoute?.result?.swaps || []).reduce(
496
+ (initialQuote?.result?.swaps || []).reduce(
462
497
  (blockchains: string[], swap) => {
463
498
  blockchains.push(swap.from.blockchain, swap.to.blockchain);
464
499
  // Check if internalSwaps array exists
@@ -526,29 +561,24 @@ export function getWalletsForNewSwap(selectedWallets: Wallet[]) {
526
561
  return wallets;
527
562
  }
528
563
 
529
- export function getRouteOutputAmount(route: BestRouteResponse | null) {
530
- return route?.result?.outputAmount || null;
564
+ export function getQuoteOutputAmount(quote: BestRouteResponse) {
565
+ return quote.result?.outputAmount || null;
531
566
  }
532
567
 
533
- export function getPercentageChange(
534
- inputUsdValue: string | number | null,
535
- outputUsdValue: string | number | null
536
- ) {
537
- if (!inputUsdValue || !outputUsdValue) {
538
- return null;
539
- }
540
- return new BigNumber(outputUsdValue)
541
- .div(new BigNumber(inputUsdValue))
568
+ export function getPercentageChange(input: string, output: string) {
569
+ return new BigNumber(output)
570
+ .div(new BigNumber(input))
542
571
  .minus(1)
543
- .multipliedBy(100);
572
+ .multipliedBy(100)
573
+ .toNumber();
544
574
  }
545
575
 
546
576
  export function isOutputAmountChangedALot(
547
- oldRoute: BestRouteResponse,
548
- newRoute: BestRouteResponse
577
+ oldQuote: BestRouteResponse,
578
+ newQuote: BestRouteResponse
549
579
  ) {
550
- const oldOutputAmount = getRouteOutputAmount(oldRoute);
551
- const newOutputAmount = getRouteOutputAmount(newRoute);
580
+ const oldOutputAmount = getQuoteOutputAmount(oldQuote);
581
+ const newOutputAmount = getQuoteOutputAmount(newQuote);
552
582
  if (!oldOutputAmount || !newOutputAmount) {
553
583
  return false;
554
584
  }
@@ -560,15 +590,15 @@ export function isOutputAmountChangedALot(
560
590
  return true;
561
591
  }
562
592
 
563
- return percentageChange.toNumber() <= -1;
593
+ return percentageChange <= -1;
564
594
  }
565
595
 
566
596
  export function getBalanceWarnings(
567
- route: BestRouteResponse,
597
+ quote: BestRouteResponse,
568
598
  selectedWallets: Wallet[]
569
599
  ) {
570
- const fee = route.validationStatus;
571
- const requiredWallets = getRequiredChains(route);
600
+ const fee = quote.validationStatus;
601
+ const requiredWallets = getRequiredChains(quote);
572
602
  const walletsSortedByRequiredWallets = selectedWallets.sort(
573
603
  (selectedWallet1, selectedWallet2) =>
574
604
  requiredWallets.indexOf(selectedWallet1.chain) -
@@ -729,14 +759,14 @@ export function confirmSwapDisabled(
729
759
  fetching: boolean,
730
760
  showCustomDestination: boolean,
731
761
  customDestination: string,
732
- bestRoute: BestRouteResponse | null,
762
+ quote: BestRouteResponse | null,
733
763
  selectedWallets: { walletType: string; chain: string }[],
734
764
  lastStepToBlockchain?: BlockchainMeta
735
765
  ) {
736
766
  return (
737
767
  fetching ||
738
768
  (!showCustomDestination &&
739
- !requiredWallets(bestRoute).every((chain) =>
769
+ !requiredWallets(quote).every((chain) =>
740
770
  selectedWallets.map((wallet) => wallet.chain).includes(chain)
741
771
  )) ||
742
772
  (!!showCustomDestination && !customDestination) ||
@@ -174,10 +174,10 @@ export function prepareAccountsForWalletStore(
174
174
  return result;
175
175
  }
176
176
 
177
- export function getRequiredChains(route: BestRouteResponse | null) {
177
+ export function getRequiredChains(quote: BestRouteResponse | null) {
178
178
  const wallets: string[] = [];
179
179
 
180
- route?.result?.swaps.forEach((swap) => {
180
+ quote?.result?.swaps.forEach((swap) => {
181
181
  const currentStepFromBlockchain = swap.from.blockchain;
182
182
  const currentStepToBlockchain = swap.to.blockchain;
183
183
  if (!wallets.includes(currentStepFromBlockchain)) {
@@ -1,4 +0,0 @@
1
- import type { PropTypes } from './NoRoutes.types';
2
- import React from 'react';
3
- export declare function NoRoutes(props: PropTypes): React.JSX.Element;
4
- //# sourceMappingURL=NoRoutes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoRoutes.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/NoRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAUlD,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,qBA6DxC"}
@@ -1,3 +0,0 @@
1
- import type { Info } from './NoRoutes.types';
2
- export declare function makeInfo(diagnosisMessage: string | null, disabledLiquiditySources: string[], hasError: boolean, toggleAllLiquiditySources: (shouldReset: boolean) => void, refetchBestRoute: () => void): Info;
3
- //# sourceMappingURL=NoRoutes.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoRoutes.helper.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/NoRoutes.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAM7C,wBAAgB,QAAQ,CACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAC/B,wBAAwB,EAAE,MAAM,EAAE,EAClC,QAAQ,EAAE,OAAO,EACjB,yBAAyB,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,EACzD,gBAAgB,EAAE,MAAM,IAAI,GAC3B,IAAI,CAuCN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"NoRoutes.types.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/NoRoutes.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -1,2 +0,0 @@
1
- export { NoRoutes } from './NoRoutes';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NoRoutes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { PropTypes } from './RouteErrors.types';
2
- import React from 'react';
3
- export declare function RouteErrors(props: PropTypes): React.JSX.Element;
4
- //# sourceMappingURL=RouteErrors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouteErrors.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrors.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,qBAgE3C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouteErrors.styles.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrors.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAGjB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAMf,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAMf,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAIjB,CAAC"}
@@ -1,24 +0,0 @@
1
- import type BigNumber from 'bignumber.js';
2
- export interface PropTypes {
3
- openModal: boolean;
4
- onToggle: (open: boolean) => void;
5
- totalFeeInUsd: BigNumber | null;
6
- outputUsdValue: BigNumber | null;
7
- inputUsdValue: BigNumber | null;
8
- percentageChange: BigNumber | null;
9
- highValueLoss: boolean;
10
- priceImpactCanNotBeComputed: boolean;
11
- loading: boolean;
12
- extraSpace: boolean;
13
- }
14
- type ModalPropTypesKeys = keyof Omit<PropTypes, 'priceImpactCanNotBeComputed' | 'openModal' | 'extraSpace' | 'loading'>;
15
- export type ModalPropTypes = Pick<PropTypes, ModalPropTypesKeys> & {
16
- open: boolean;
17
- };
18
- export interface ModalContentData {
19
- title: string;
20
- value: string;
21
- valueColor?: string;
22
- }
23
- export {};
24
- //# sourceMappingURL=RouteErrors.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouteErrors.types.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrors.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC;IACvB,2BAA2B,EAAE,OAAO,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,KAAK,kBAAkB,GAAG,MAAM,IAAI,CAClC,SAAS,EACT,6BAA6B,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,CACvE,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAG;IACjE,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -1,4 +0,0 @@
1
- import type { ModalPropTypes } from './RouteErrors.types';
2
- import React from 'react';
3
- export declare function RouteErrorsModal(props: ModalPropTypes): React.JSX.Element;
4
- //# sourceMappingURL=RouteErrorsModal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouteErrorsModal.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrorsModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAW1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAmB1B,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,qBAkGrD"}
@@ -1,4 +0,0 @@
1
- import type { ModalContentData } from './RouteErrors.types';
2
- import React from 'react';
3
- export declare function RouteErrorsModalItem(props: ModalContentData): React.JSX.Element;
4
- //# sourceMappingURL=RouteErrorsModalItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RouteErrorsModalItem.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/RouteErrorsModalItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,qBAgB3D"}
@@ -1,2 +0,0 @@
1
- export { RouteErrors } from './RouteErrors';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RouteErrors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useConfirmSwap.d.ts","sourceRoot":"","sources":["../../src/hooks/useConfirmSwap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEnB,MAAM,EACP,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAwCzE,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC3D,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAoHF,wBAAgB,cAAc,IAAI,WAAW,CA4H5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFetchBestRoute.d.ts","sourceRoot":"","sources":["../../src/hooks/useFetchBestRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAMrE,UAAU,iBAAiB;IACzB,KAAK,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACrE,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAyBrD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"bestRoute.d.ts","sourceRoot":"","sources":["../../src/store/bestRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KA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IACxD,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,uBAAuB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAChD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,iBAAiB,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;gCApBV,IAAI;uCACG,IAAI;yCACF,IAAI;yCACJ,cAAc,GAAG,IAAI,KAAK,IAAI;uCAChC,cAAc,GAAG,IAAI,KAAK,IAAI;oCAEjC,KAAK,GAAG,IAAI,KAAK,IAAI;kCACvB,KAAK,GAAG,IAAI,KAAK,IAAI;uCAChB,MAAM,KAAK,IAAI;;oCAElB,iBAAiB,GAAG,IAAI,KAAK,IAAI;mCAClC,WAAW,KAAK,IAAI;qCAClB,IAAI;8CACK,OAAO,KAAK,IAAI;4CAClB,MAAM,EAAE,KAAK,IAAI;;8CAEf,MAAM,KAAK,IAAI;uCACtB,IAAI;;CA4L9B,CAAC"}
@@ -1,65 +0,0 @@
1
- import type { RouteState } from '../store/bestRoute';
2
- import type { SettingsState } from '../store/settings';
3
- interface BestRouteStoreParams {
4
- fromBlockchain?: RouteState['fromBlockchain'];
5
- toBlockchain?: RouteState['toBlockchain'];
6
- fromToken?: RouteState['fromToken'];
7
- toToken?: RouteState['toToken'];
8
- inputAmount?: RouteState['inputAmount'];
9
- }
10
- interface SettingsStoreParams {
11
- slippage?: SettingsState['slippage'];
12
- customSlippage?: SettingsState['customSlippage'];
13
- disabledLiquiditySources?: SettingsState['disabledLiquiditySources'];
14
- infiniteApprove?: SettingsState['infiniteApprove'];
15
- }
16
- export type BestRouteEqualityParams = {
17
- store: 'bestRoute';
18
- prevState: BestRouteStoreParams;
19
- currentState: BestRouteStoreParams;
20
- } | {
21
- store: 'settings';
22
- prevState: SettingsStoreParams;
23
- currentState: SettingsStoreParams;
24
- };
25
- export declare enum ConfirmSwapErrorTypes {
26
- NO_ROUTE = 0,
27
- ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS = 1,
28
- REQUEST_FAILED = 2,
29
- REQUEST_CANCELED = 3
30
- }
31
- export type ConfirmSwapError = {
32
- type: ConfirmSwapErrorTypes.NO_ROUTE;
33
- diagnosisMessage?: string;
34
- } | {
35
- type: Exclude<ConfirmSwapErrorTypes, ConfirmSwapErrorTypes.NO_ROUTE>;
36
- };
37
- export declare enum RouteWarningType {
38
- ROUTE_UPDATED = 0,
39
- ROUTE_SWAPPERS_UPDATED = 1,
40
- ROUTE_COINS_UPDATED = 2,
41
- ROUTE_AND_OUTPUT_AMOUNT_UPDATED = 3
42
- }
43
- export type RouteWarning = {
44
- type: RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED;
45
- newOutputAmount: string;
46
- percentageChange: string;
47
- } | {
48
- type: Exclude<RouteWarningType, RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED>;
49
- };
50
- export declare enum SlippageWarningType {
51
- INSUFFICIENT_SLIPPAGE = 0,
52
- HIGH_SLIPPAGE = 1
53
- }
54
- export type ConfirmSwapWarnings = {
55
- route: RouteWarning | null;
56
- balance: {
57
- messages: string[];
58
- } | null;
59
- slippage: {
60
- type: SlippageWarningType;
61
- slippage: string | null;
62
- } | null;
63
- };
64
- export {};
65
- //# sourceMappingURL=routing.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/types/routing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,U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AK,EAAE,GACd;IACD,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CA4CA"}
@@ -1 +0,0 @@
1
- export { NoRoutes } from './NoRoutes';
@@ -1,79 +0,0 @@
1
- import type { PropTypes } from './RouteErrors.types';
2
-
3
- import { Alert, Divider, InfoIcon } from '@rango-dev/ui';
4
- import React from 'react';
5
-
6
- import { errorMessages } from '../../constants/errors';
7
- import { useBestRouteStore } from '../../store/bestRoute';
8
- import { hasLimitError, LimitErrorMessage } from '../../utils/swap';
9
-
10
- import { Action, Alerts } from './RouteErrors.styles';
11
- import { RouteErrorsModal } from './RouteErrorsModal';
12
-
13
- const WARNING_LEVEL_LIMIT = -10;
14
-
15
- export function RouteErrors(props: PropTypes) {
16
- const { bestRoute } = useBestRouteStore();
17
- const {
18
- highValueLoss,
19
- percentageChange,
20
- priceImpactCanNotBeComputed,
21
- openModal,
22
- onToggle,
23
- totalFeeInUsd,
24
- outputUsdValue,
25
- inputUsdValue,
26
- loading,
27
- extraSpace,
28
- } = props;
29
- const error = hasLimitError(bestRoute);
30
- const { recommendation } = LimitErrorMessage(bestRoute);
31
-
32
- const showWarnings = !error && (highValueLoss || priceImpactCanNotBeComputed);
33
- const showAlerts = showWarnings || error;
34
-
35
- return (
36
- <>
37
- {(loading || (extraSpace && !showAlerts)) && <Divider size={20} />}
38
- {showAlerts && (
39
- <Alerts>
40
- {showWarnings && (
41
- <>
42
- <Alert
43
- title={
44
- highValueLoss
45
- ? errorMessages().highValueLossError.title
46
- : errorMessages().unknownPriceError.title
47
- }
48
- type={
49
- highValueLoss && !!percentageChange?.lt(WARNING_LEVEL_LIMIT)
50
- ? 'error'
51
- : 'warning'
52
- }
53
- variant="alarm"
54
- action={
55
- <Action onClick={() => onToggle(true)}>
56
- <InfoIcon size={12} color="gray" />
57
- </Action>
58
- }
59
- />
60
- </>
61
- )}
62
- {error && (
63
- <Alert type="error" variant="alarm" title={recommendation} />
64
- )}
65
- </Alerts>
66
- )}
67
-
68
- <RouteErrorsModal
69
- highValueLoss={highValueLoss}
70
- open={openModal}
71
- onToggle={onToggle}
72
- percentageChange={percentageChange}
73
- inputUsdValue={inputUsdValue}
74
- outputUsdValue={outputUsdValue}
75
- totalFeeInUsd={totalFeeInUsd}
76
- />
77
- </>
78
- );
79
- }