@lifi/widget 3.13.2 → 3.14.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 (122) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/esm/AppDrawer.style.d.ts +1 -1
  3. package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +1 -1
  4. package/dist/esm/components/AlertMessage/AlertMessage.d.ts +2 -2
  5. package/dist/esm/components/AlertMessage/AlertMessage.js +1 -1
  6. package/dist/esm/components/AlertMessage/AlertMessage.js.map +1 -1
  7. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
  8. package/dist/esm/components/AmountInput/PriceFormHelperText.js +7 -4
  9. package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
  10. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +2 -2
  11. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
  12. package/dist/esm/components/ButtonTertiary.d.ts +1 -1
  13. package/dist/esm/components/ButtonTertiary.js +4 -5
  14. package/dist/esm/components/ButtonTertiary.js.map +1 -1
  15. package/dist/esm/components/Card/CardHeader.d.ts +1 -1
  16. package/dist/esm/components/Card/CardIconButton.d.ts +1 -1
  17. package/dist/esm/components/Card/CardLabel.js +0 -1
  18. package/dist/esm/components/Card/CardLabel.js.map +1 -1
  19. package/dist/esm/components/FeeBreakdownTooltip.js +3 -4
  20. package/dist/esm/components/FeeBreakdownTooltip.js.map +1 -1
  21. package/dist/esm/components/GasMessage/FundsSufficiencyMessage.js +1 -1
  22. package/dist/esm/components/GasMessage/FundsSufficiencyMessage.js.map +1 -1
  23. package/dist/esm/components/Header/Header.style.d.ts +1 -1
  24. package/dist/esm/components/Header/SettingsButton.style.d.ts +1 -1
  25. package/dist/esm/components/RouteCard/RouteCard.js +8 -3
  26. package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
  27. package/dist/esm/components/RouteCard/getMatchingLabels.d.ts +3 -0
  28. package/dist/esm/components/RouteCard/getMatchingLabels.js +34 -0
  29. package/dist/esm/components/RouteCard/getMatchingLabels.js.map +1 -0
  30. package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
  31. package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  32. package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +2 -2
  33. package/dist/esm/components/Step/Step.js +17 -8
  34. package/dist/esm/components/Step/Step.js.map +1 -1
  35. package/dist/esm/components/StepActions/StepActions.js +8 -8
  36. package/dist/esm/components/StepActions/StepActions.js.map +1 -1
  37. package/dist/esm/components/ToAddressRequiredMessage.js +1 -1
  38. package/dist/esm/components/ToAddressRequiredMessage.js.map +1 -1
  39. package/dist/esm/components/Token/Token.js +3 -3
  40. package/dist/esm/components/Token/Token.js.map +1 -1
  41. package/dist/esm/components/TokenList/TokenList.style.d.ts +1 -1
  42. package/dist/esm/components/TokenList/TokenListItem.js +4 -6
  43. package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
  44. package/dist/esm/components/TokenRate/TokenRate.js +5 -7
  45. package/dist/esm/components/TokenRate/TokenRate.js.map +1 -1
  46. package/dist/esm/components/TransactionDetails.js +3 -7
  47. package/dist/esm/components/TransactionDetails.js.map +1 -1
  48. package/dist/esm/config/version.d.ts +1 -1
  49. package/dist/esm/config/version.js +1 -1
  50. package/dist/esm/i18n/en.json +4 -2
  51. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +1 -2
  52. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
  53. package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.d.ts +1 -0
  54. package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js +6 -4
  55. package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js.map +1 -1
  56. package/dist/esm/pages/SendToWallet/SendToWalletPage.js +5 -3
  57. package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
  58. package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +2 -2
  59. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js +2 -2
  60. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
  61. package/dist/esm/providers/I18nProvider/I18nProvider.js +3 -1
  62. package/dist/esm/providers/I18nProvider/I18nProvider.js.map +1 -1
  63. package/dist/esm/stores/routes/useExecutingRoutesIds.js +2 -2
  64. package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
  65. package/dist/esm/themes/createTheme.js +4 -5
  66. package/dist/esm/themes/createTheme.js.map +1 -1
  67. package/dist/esm/types/widget.d.ts +18 -1
  68. package/dist/esm/types/widget.js.map +1 -1
  69. package/dist/esm/utils/compactNumberFormatter.d.ts +10 -0
  70. package/dist/esm/utils/compactNumberFormatter.js +81 -0
  71. package/dist/esm/utils/compactNumberFormatter.js.map +1 -0
  72. package/dist/esm/utils/compactNumberFormatter.test.d.ts +1 -0
  73. package/dist/esm/utils/compactNumberFormatter.test.js +64 -0
  74. package/dist/esm/utils/compactNumberFormatter.test.js.map +1 -0
  75. package/dist/esm/utils/converters.js +2 -2
  76. package/dist/esm/utils/converters.js.map +1 -1
  77. package/dist/esm/utils/fees.js +2 -3
  78. package/dist/esm/utils/fees.js.map +1 -1
  79. package/dist/esm/utils/format.d.ts +1 -10
  80. package/dist/esm/utils/format.js +8 -47
  81. package/dist/esm/utils/format.js.map +1 -1
  82. package/dist/esm/utils/getPriceImpact.js +7 -6
  83. package/dist/esm/utils/getPriceImpact.js.map +1 -1
  84. package/dist/esm/utils/percentFormatter.js.map +1 -0
  85. package/package.json +13 -14
  86. package/src/components/AlertMessage/AlertMessage.tsx +3 -3
  87. package/src/components/AmountInput/PriceFormHelperText.tsx +8 -4
  88. package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -3
  89. package/src/components/ButtonTertiary.tsx +4 -5
  90. package/src/components/Card/CardLabel.tsx +0 -1
  91. package/src/components/FeeBreakdownTooltip.tsx +3 -4
  92. package/src/components/GasMessage/FundsSufficiencyMessage.tsx +1 -1
  93. package/src/components/RouteCard/RouteCard.tsx +12 -2
  94. package/src/components/RouteCard/getMatchingLabels.ts +53 -0
  95. package/src/components/Step/Step.tsx +23 -12
  96. package/src/components/StepActions/StepActions.tsx +16 -13
  97. package/src/components/ToAddressRequiredMessage.tsx +1 -1
  98. package/src/components/Token/Token.tsx +7 -2
  99. package/src/components/TokenList/TokenListItem.tsx +9 -9
  100. package/src/components/TokenRate/TokenRate.tsx +5 -11
  101. package/src/components/TransactionDetails.tsx +4 -8
  102. package/src/config/version.ts +1 -1
  103. package/src/i18n/en.json +4 -2
  104. package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +2 -3
  105. package/src/pages/SendToWallet/ConfirmAddressSheet.tsx +28 -6
  106. package/src/pages/SendToWallet/SendToWalletPage.tsx +8 -2
  107. package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +2 -2
  108. package/src/providers/I18nProvider/I18nProvider.tsx +3 -1
  109. package/src/stores/routes/useExecutingRoutesIds.ts +2 -2
  110. package/src/themes/createTheme.ts +6 -8
  111. package/src/themes/types.ts +0 -1
  112. package/src/types/widget.ts +22 -0
  113. package/src/utils/compactNumberFormatter.test.ts +67 -0
  114. package/src/utils/compactNumberFormatter.ts +91 -0
  115. package/src/utils/converters.ts +6 -4
  116. package/src/utils/fees.ts +6 -4
  117. package/src/utils/format.ts +14 -60
  118. package/src/utils/getPriceImpact.ts +15 -6
  119. package/dist/esm/providers/I18nProvider/percentFormatter.js.map +0 -1
  120. /package/dist/esm/{providers/I18nProvider → utils}/percentFormatter.d.ts +0 -0
  121. /package/dist/esm/{providers/I18nProvider → utils}/percentFormatter.js +0 -0
  122. /package/src/{providers/I18nProvider → utils}/percentFormatter.ts +0 -0
@@ -1,12 +1,4 @@
1
1
  import { formatUnits } from 'viem';
2
- const subscriptMap = ['₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉'];
3
- export const precisionFormatter = new Intl.NumberFormat('en', {
4
- notation: 'standard',
5
- roundingPriority: 'morePrecision',
6
- maximumSignificantDigits: 6,
7
- maximumFractionDigits: 6,
8
- useGrouping: false,
9
- });
10
2
  /**
11
3
  * Format token amount to at least 6 decimals.
12
4
  * @param amount amount to format.
@@ -15,10 +7,10 @@ export const precisionFormatter = new Intl.NumberFormat('en', {
15
7
  export function formatTokenAmount(amount, decimals) {
16
8
  const formattedAmount = amount ? formatUnits(amount, decimals) : '0';
17
9
  const parsedAmount = Number.parseFloat(formattedAmount);
18
- if (parsedAmount === 0 || Number.isNaN(Number(formattedAmount))) {
10
+ if (!parsedAmount || Number.isNaN(Number(formattedAmount))) {
19
11
  return '0';
20
12
  }
21
- return precisionFormatter.format(parsedAmount);
13
+ return formattedAmount;
22
14
  }
23
15
  export function formatSlippage(slippage = '', defaultValue = '', returnInitial = false) {
24
16
  if (!slippage) {
@@ -68,47 +60,16 @@ export function formatInputAmount(amount, decimals = null, returnInitial = false
68
60
  fraction = fraction.replace(/(0+)$/, '');
69
61
  return `${integer || (fraction ? '0' : '')}${fraction ? `.${fraction}` : ''}`;
70
62
  }
71
- export function formatTokenPrice(amount, price) {
63
+ export function formatTokenPrice(amount, price, decimals) {
72
64
  if (!amount || !price) {
73
65
  return 0;
74
66
  }
75
- if (Number.isNaN(Number(amount)) || Number.isNaN(Number(price))) {
67
+ const formattedAmount = typeof amount === 'bigint' && decimals !== undefined
68
+ ? formatUnits(amount, decimals)
69
+ : amount.toString();
70
+ if (Number.isNaN(Number(formattedAmount)) || Number.isNaN(Number(price))) {
76
71
  return 0;
77
72
  }
78
- return Number.parseFloat(amount) * Number.parseFloat(price);
79
- }
80
- /**
81
- * Converts a number to a subscript format if it contains leading zeros in the fractional part.
82
- *
83
- * @param {number} value - The number to be converted.
84
- * @param {Intl.NumberFormatOptions} options An object that contains one or more properties that specify comparison options.
85
- * @returns {string} - The number formatted as a string, with subscripts for leading zeros if applicable.
86
- */
87
- export function convertToSubscriptFormat(value, options) {
88
- let formattedValue;
89
- if (options) {
90
- formattedValue = value.toLocaleString('en', options);
91
- }
92
- else {
93
- formattedValue = precisionFormatter.format(value);
94
- }
95
- // Calculate the number of zeros after the decimal point
96
- const d = Math.ceil(Math.log10(Math.abs(value)));
97
- // If the value does not have significant leading zeros in the fractional part, return the formatted value as is
98
- if (d > -3 || !value) {
99
- return formattedValue;
100
- }
101
- // Calculate the number of leading zeros in the fractional part
102
- const leadingZeros = Math.abs(d);
103
- const fractionalPartExtractor = value > 0 ? 2 : 3;
104
- // Extract the fractional part of the formatted value, excluding the leading zeros and "0." or "-0."
105
- const fractionalPart = formattedValue.slice(leadingZeros + fractionalPartExtractor);
106
- // Convert the number of leading zeros to their corresponding Unicode subscript characters
107
- const subscript = leadingZeros
108
- .toString()
109
- .split('')
110
- .map((digit) => subscriptMap[digit])
111
- .join('');
112
- return `${value > 0 ? '' : '-'}0.0${subscript}${fractionalPart}`;
73
+ return Number.parseFloat(formattedAmount) * Number.parseFloat(price);
113
74
  }
114
75
  //# sourceMappingURL=format.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;IAC5D,QAAQ,EAAE,UAAU;IACpB,gBAAgB,EAAE,eAAe;IACjC,wBAAwB,EAAE,CAAC;IAC3B,qBAAqB,EAAE,CAAC;IACxB,WAAW,EAAE,KAAK;CACnB,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CA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AAQ,EAAE,CAAA;IAEvB,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACzE,OAAO,CAAC,CAAA;IACV,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AACtE,CAAC"}
@@ -1,10 +1,11 @@
1
- import { formatTokenAmount, formatTokenPrice } from './format.js';
1
+ import { formatTokenPrice } from './format.js';
2
2
  export const getPriceImpact = ({ fromToken, toToken, fromAmount, toAmount, }) => {
3
- const fromTokenAmount = formatTokenAmount(fromAmount, fromToken.decimals);
4
- const fromTokenPrice = formatTokenPrice(fromTokenAmount, fromToken.priceUSD);
5
- const toTokenAmount = formatTokenAmount(toAmount, toToken.decimals);
6
- const toTokenPrice = formatTokenPrice(toTokenAmount, toToken.priceUSD) || 0.01;
3
+ const fromTokenPrice = formatTokenPrice(fromAmount, fromToken.priceUSD, fromToken.decimals);
4
+ const toTokenPrice = formatTokenPrice(toAmount, toToken.priceUSD, toToken.decimals);
5
+ if (!fromTokenPrice) {
6
+ return 0;
7
+ }
7
8
  const priceImpact = toTokenPrice / fromTokenPrice - 1;
8
- return Number(priceImpact);
9
+ return priceImpact;
9
10
  };
10
11
  //# sourceMappingURL=getPriceImpact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPriceImpact.js","sourceRoot":"","sources":["../../../src/utils/getPriceImpact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AASjE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,GACa,EAAE,EAAE;IACzB,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;IACzE,MAAM,cAAc,GAAG,gBAAgB,CAAC,eAAe,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;IAE5E,MAAM,aAAa,GAAG,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnE,MAAM,YAAY,GAAG,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAA;IAE9E,MAAM,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,CAAC,CAAA;IAErD,OAAO,MAAM,CAAC,WAAW,CAAC,CAAA;AAC5B,CAAC,CAAA"}
1
+ {"version":3,"file":"getPriceImpact.js","sourceRoot":"","sources":["../../../src/utils/getPriceImpact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAS9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,GACa,EAAE,EAAE;IACzB,MAAM,cAAc,GAAG,gBAAgB,CACrC,UAAU,EACV,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,QAAQ,CACnB,CAAA;IACD,MAAM,YAAY,GAAG,gBAAgB,CACnC,QAAQ,EACR,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,QAAQ,CACjB,CAAA;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,CAAC,CAAA;IAErD,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percentFormatter.js","sourceRoot":"","sources":["../../../src/utils/percentFormatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAuB,EAAE,OAAY,EAAE,EAAE;IACxE,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE;QAC3C,GAAG,OAAO;QACV,KAAK,EAAE,SAAS;KACjB,CAAC,CAAA;IACF,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;QACvC,CAAC;QACD,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "3.13.2",
3
+ "version": "3.14.0",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -30,30 +30,29 @@
30
30
  "lifi"
31
31
  ],
32
32
  "dependencies": {
33
- "@bigmi/client": "^0.0.7",
34
- "@bigmi/core": "^0.0.7",
33
+ "@bigmi/client": "^0.1.0",
34
+ "@bigmi/core": "^0.1.0",
35
35
  "@emotion/react": "^11.14.0",
36
36
  "@emotion/styled": "^11.14.0",
37
- "@lifi/sdk": "^3.4.4",
37
+ "@lifi/sdk": "^3.5.2",
38
38
  "@mui/icons-material": "6.0.2",
39
- "@mui/lab": "6.0.0-beta.21",
40
- "@mui/material": "^6.3.0",
41
- "@mui/system": "^6.3.0",
39
+ "@mui/material": "^6.4.1",
40
+ "@mui/system": "^6.4.1",
42
41
  "@solana/wallet-adapter-base": "^0.9.23",
43
42
  "@solana/web3.js": "^1.98.0",
44
43
  "@tanstack/react-virtual": "^3.11.2",
45
- "i18next": "^24.2.0",
44
+ "i18next": "^24.2.1",
46
45
  "microdiff": "^1.5.0",
47
46
  "mitt": "^3.0.1",
48
- "react-i18next": "^15.2.0",
49
- "react-intersection-observer": "^9.14.0",
47
+ "react-i18next": "^15.4.0",
48
+ "react-intersection-observer": "^9.15.1",
50
49
  "react-router-dom": "^6.28.0",
51
- "viem": "^2.21.57",
52
- "zustand": "^5.0.2",
53
- "@lifi/wallet-management": "^3.5.2"
50
+ "viem": "^2.22.11",
51
+ "zustand": "^5.0.3",
52
+ "@lifi/wallet-management": "^3.6.0"
54
53
  },
55
54
  "peerDependencies": {
56
- "@bigmi/react": ">=0.0.7",
55
+ "@bigmi/react": ">=0.1.0",
57
56
  "@solana/wallet-adapter-react": "^0.15.35",
58
57
  "@tanstack/react-query": "^5.62.0",
59
58
  "react": ">=18",
@@ -9,7 +9,7 @@ import type { Severity } from './types.js'
9
9
  interface AlertMessageProps extends PropsWithChildren<Omit<BoxProps, 'title'>> {
10
10
  icon: ReactNode
11
11
  title: ReactNode
12
- multilineTitle?: boolean
12
+ multiline?: boolean
13
13
  severity?: Severity
14
14
  }
15
15
 
@@ -17,14 +17,14 @@ export const AlertMessage = ({
17
17
  title,
18
18
  icon,
19
19
  children,
20
- multilineTitle,
20
+ multiline,
21
21
  severity = 'info',
22
22
  ...rest
23
23
  }: AlertMessageProps) => (
24
24
  <AlertMessageCard severity={severity} {...rest}>
25
25
  <AlertMessageCardTitle
26
26
  severity={severity}
27
- alignItems={multilineTitle ? 'start' : 'center'}
27
+ alignItems={multiline ? 'start' : 'center'}
28
28
  >
29
29
  {icon}
30
30
  {title}
@@ -34,7 +34,10 @@ export const PriceFormHelperTextBase: React.FC<
34
34
  const { t } = useTranslation()
35
35
  const [amount] = useFieldValues(FormKeyHelper.getAmountKey(formType))
36
36
 
37
- const fromAmountTokenPrice = formatTokenPrice(amount, token?.priceUSD)
37
+ const tokenAmount = token
38
+ ? formatTokenAmount(token.amount, token.decimals)
39
+ : '0'
40
+ const tokenPrice = formatTokenPrice(amount, token?.priceUSD)
38
41
 
39
42
  return (
40
43
  <FormHelperText
@@ -59,7 +62,7 @@ export const PriceFormHelperTextBase: React.FC<
59
62
  }}
60
63
  >
61
64
  {t('format.currency', {
62
- value: fromAmountTokenPrice,
65
+ value: tokenPrice,
63
66
  })}
64
67
  </Typography>
65
68
  {isLoading && tokenAddress ? (
@@ -73,9 +76,10 @@ export const PriceFormHelperTextBase: React.FC<
73
76
  lineHeight: 1,
74
77
  pl: 0.25,
75
78
  }}
79
+ title={tokenAmount}
76
80
  >
77
- {`/ ${t('format.number', {
78
- value: formatTokenAmount(token.amount, token.decimals),
81
+ {`/ ${t('format.tokenAmount', {
82
+ value: tokenAmount,
79
83
  })}`}
80
84
  </Typography>
81
85
  ) : null}
@@ -1,5 +1,5 @@
1
1
  import { useAccount, useWalletMenu } from '@lifi/wallet-management'
2
- import { LoadingButton } from '@mui/lab'
2
+ import { Button } from '@mui/material'
3
3
  import { useTranslation } from 'react-i18next'
4
4
  import { useChain } from '../../hooks/useChain.js'
5
5
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
@@ -39,7 +39,7 @@ export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
39
39
  }
40
40
 
41
41
  return (
42
- <LoadingButton
42
+ <Button
43
43
  variant="contained"
44
44
  color="primary"
45
45
  onClick={handleClick}
@@ -49,6 +49,6 @@ export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
49
49
  fullWidth
50
50
  >
51
51
  {getButtonText()}
52
- </LoadingButton>
52
+ </Button>
53
53
  )
54
54
  }
@@ -1,8 +1,7 @@
1
- import { LoadingButton, loadingButtonClasses } from '@mui/lab'
2
- import { styled } from '@mui/material'
1
+ import { Button, buttonClasses, styled } from '@mui/material'
3
2
  import { getContrastAlphaColor } from '../utils/colors.js'
4
3
 
5
- export const ButtonTertiary = styled(LoadingButton)(({ theme }) => ({
4
+ export const ButtonTertiary = styled(Button)(({ theme }) => ({
6
5
  color: theme.palette.text.primary,
7
6
  height: 40,
8
7
  fontSize: 14,
@@ -10,10 +9,10 @@ export const ButtonTertiary = styled(LoadingButton)(({ theme }) => ({
10
9
  '&:hover, &:active': {
11
10
  backgroundColor: getContrastAlphaColor(theme, 0.08),
12
11
  },
13
- [`&.${loadingButtonClasses.loading}:disabled`]: {
12
+ [`&.${buttonClasses.loading}:disabled`]: {
14
13
  backgroundColor: getContrastAlphaColor(theme, 0.04),
15
14
  },
16
- [`.${loadingButtonClasses.loadingIndicator}`]: {
15
+ [`.${buttonClasses.loadingIndicator}`]: {
17
16
  color: theme.palette.text.primary,
18
17
  },
19
18
  }))
@@ -13,7 +13,6 @@ export const CardLabel = styled(Box, {
13
13
  minWidth: 24,
14
14
  userSelect: 'none',
15
15
  fontSize: '1rem',
16
- marginRight: theme.spacing(1),
17
16
  backgroundColor: blend(
18
17
  theme.palette.background.paper,
19
18
  theme.palette.common.white,
@@ -2,8 +2,8 @@ import { Box, Tooltip, Typography } from '@mui/material'
2
2
  import type { TFunction } from 'i18next'
3
3
  import type { ReactElement } from 'react'
4
4
  import { useTranslation } from 'react-i18next'
5
- import { formatUnits } from 'viem'
6
5
  import type { FeesBreakdown } from '../utils/fees.js'
6
+ import { formatTokenAmount } from '../utils/format.js'
7
7
 
8
8
  export interface FeeBreakdownTooltipProps {
9
9
  gasCosts?: FeesBreakdown[]
@@ -60,9 +60,8 @@ export const getFeeBreakdownTypography = (
60
60
  }}
61
61
  >
62
62
  {t('format.currency', { value: fee.amountUSD })} (
63
- {t('format.number', {
64
- value: Number.parseFloat(formatUnits(fee.amount, fee.token.decimals)),
65
- maximumFractionDigits: Math.min(fee.token.decimals, 9),
63
+ {t('format.tokenAmount', {
64
+ value: formatTokenAmount(fee.amount, fee.token.decimals),
66
65
  })}{' '}
67
66
  {fee.token.symbol})
68
67
  </Typography>
@@ -20,7 +20,7 @@ export const FundsSufficiencyMessage = () => {
20
20
  {t('warning.message.insufficientFunds')}
21
21
  </Typography>
22
22
  }
23
- multilineTitle
23
+ multiline
24
24
  />
25
25
  )
26
26
  }
@@ -14,6 +14,7 @@ import { Token } from '../Token/Token.js'
14
14
  import { TokenContainer } from './RouteCard.style.js'
15
15
  import { RouteCardEssentials } from './RouteCardEssentials.js'
16
16
  import { RouteCardEssentialsExpanded } from './RouteCardEssentialsExpanded.js'
17
+ import { getMatchingLabels } from './getMatchingLabels.js'
17
18
  import type { RouteCardProps } from './types.js'
18
19
 
19
20
  export const RouteCard: React.FC<
@@ -26,7 +27,7 @@ export const RouteCard: React.FC<
26
27
  ...other
27
28
  }) => {
28
29
  const { t } = useTranslation()
29
- const { subvariant, subvariantOptions } = useWidgetConfig()
30
+ const { subvariant, subvariantOptions, routeLabels } = useWidgetConfig()
30
31
  const [cardExpanded, setCardExpanded] = useState(defaulExpanded)
31
32
 
32
33
  const handleExpand: MouseEventHandler<HTMLButtonElement> = (e) => {
@@ -43,6 +44,7 @@ export const RouteCard: React.FC<
43
44
  ? { ...route.fromToken, amount: BigInt(route.fromAmount) }
44
45
  : undefined
45
46
 
47
+ const customLabels = getMatchingLabels(route, routeLabels)
46
48
  const tags = route.tags?.filter(
47
49
  (tag) => tag === 'CHEAPEST' || tag === 'FASTEST'
48
50
  )
@@ -53,12 +55,15 @@ export const RouteCard: React.FC<
53
55
  flex: 1,
54
56
  }}
55
57
  >
56
- {subvariant !== 'refuel' && route.tags?.length ? (
58
+ {subvariant !== 'refuel' &&
59
+ (route.tags?.length || customLabels.length) ? (
57
60
  <Box
58
61
  sx={{
59
62
  display: 'flex',
60
63
  alignItems: 'center',
61
64
  mb: 2,
65
+ gap: 1,
66
+ flexWrap: 'wrap',
62
67
  }}
63
68
  >
64
69
  {tags?.length ? (
@@ -68,6 +73,11 @@ export const RouteCard: React.FC<
68
73
  </CardLabelTypography>
69
74
  </CardLabel>
70
75
  ) : null}
76
+ {customLabels.map((label, index) => (
77
+ <CardLabel key={index} sx={label.sx}>
78
+ <CardLabelTypography>{label.text}</CardLabelTypography>
79
+ </CardLabel>
80
+ ))}
71
81
  </Box>
72
82
  ) : null}
73
83
  <TokenContainer>
@@ -0,0 +1,53 @@
1
+ import type { Route } from '@lifi/sdk'
2
+ import type { RouteLabel, RouteLabelRule } from '../../types/widget.js'
3
+ import { isItemAllowed } from '../../utils/item.js'
4
+
5
+ export const getMatchingLabels = (
6
+ route: Route,
7
+ routeLabels?: RouteLabelRule[]
8
+ ): RouteLabel[] => {
9
+ if (!routeLabels?.length) {
10
+ return []
11
+ }
12
+
13
+ return routeLabels
14
+ .filter((rule) => {
15
+ const conditions: boolean[] = []
16
+
17
+ // Check bridge/exchange matches if specified
18
+ if (rule.bridges || rule.exchanges) {
19
+ const toolNames = route.steps.flatMap((step) =>
20
+ step.includedSteps.map((s) => s.tool)
21
+ )
22
+ conditions.push(
23
+ toolNames.some(
24
+ (toolName) =>
25
+ isItemAllowed(toolName, rule.bridges) &&
26
+ isItemAllowed(toolName, rule.exchanges)
27
+ )
28
+ )
29
+ }
30
+
31
+ // Check token matches if specified
32
+ if (rule.fromTokenAddress?.length) {
33
+ conditions.push(rule.fromTokenAddress.includes(route.fromToken.address))
34
+ }
35
+
36
+ if (rule.toTokenAddress?.length) {
37
+ conditions.push(rule.toTokenAddress.includes(route.toToken.address))
38
+ }
39
+
40
+ // Check chain matches if specified
41
+ if (rule.fromChainId?.length) {
42
+ conditions.push(rule.fromChainId.includes(route.fromChainId))
43
+ }
44
+
45
+ if (rule.toChainId?.length) {
46
+ conditions.push(rule.toChainId.includes(route.toChainId))
47
+ }
48
+
49
+ // Must have at least one condition and all conditions must be true
50
+ return conditions.length && conditions.every(Boolean)
51
+ })
52
+ .map((rule) => rule.label)
53
+ }
@@ -27,36 +27,47 @@ export const Step: React.FC<{
27
27
  )
28
28
 
29
29
  const getCardTitle = () => {
30
+ const hasBridgeStep = step.includedSteps.some(
31
+ (step) => step.type === 'cross'
32
+ )
33
+ const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap')
34
+ const hasCustomStep = step.includedSteps.some(
35
+ (step) => step.type === 'custom'
36
+ )
37
+
38
+ const isCustomVariant = hasCustomStep && subvariant === 'custom'
39
+
30
40
  switch (step.type) {
31
41
  case 'lifi': {
32
- const hasBridgeStep = step.includedSteps.some(
33
- (step) => step.type === 'cross'
34
- )
35
- const hasSwapStep = step.includedSteps.some(
36
- (step) => step.type === 'swap'
37
- )
38
42
  if (hasBridgeStep && hasSwapStep) {
39
- return subvariant === 'custom'
43
+ return isCustomVariant
40
44
  ? subvariantOptions?.custom === 'deposit'
41
45
  ? t('main.stepBridgeAndDeposit')
42
46
  : t('main.stepBridgeAndBuy')
43
47
  : t('main.stepSwapAndBridge')
44
48
  }
45
49
  if (hasBridgeStep) {
46
- return subvariant === 'custom'
50
+ return isCustomVariant
47
51
  ? subvariantOptions?.custom === 'deposit'
48
52
  ? t('main.stepBridgeAndDeposit')
49
53
  : t('main.stepBridgeAndBuy')
50
54
  : t('main.stepBridge')
51
55
  }
52
- return subvariant === 'custom'
56
+ if (hasSwapStep) {
57
+ return isCustomVariant
58
+ ? subvariantOptions?.custom === 'deposit'
59
+ ? t('main.stepSwapAndDeposit')
60
+ : t('main.stepSwapAndBuy')
61
+ : t('main.stepSwap')
62
+ }
63
+ return isCustomVariant
53
64
  ? subvariantOptions?.custom === 'deposit'
54
- ? t('main.stepSwapAndDeposit')
55
- : t('main.stepSwapAndBuy')
65
+ ? t('main.stepDeposit')
66
+ : t('main.stepBuy')
56
67
  : t('main.stepSwap')
57
68
  }
58
69
  default:
59
- return subvariant === 'custom'
70
+ return isCustomVariant
60
71
  ? subvariantOptions?.custom === 'deposit'
61
72
  ? t('main.stepDeposit')
62
73
  : t('main.stepBuy')
@@ -12,12 +12,11 @@ import {
12
12
  import type { MouseEventHandler } from 'react'
13
13
  import { useState } from 'react'
14
14
  import { useTranslation } from 'react-i18next'
15
- import { formatUnits } from 'viem'
16
15
  import { useAvailableChains } from '../../hooks/useAvailableChains.js'
17
16
  import { LiFiToolLogo } from '../../icons/lifi.js'
18
17
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
19
18
  import { HiddenUI } from '../../types/widget.js'
20
- import { formatTokenAmount } from '../../utils/format.js'
19
+ import { formatTokenAmount, formatTokenPrice } from '../../utils/format.js'
21
20
  import { SmallAvatar } from '../Avatar/SmallAvatar.js'
22
21
  import { CardIconButton } from '../Card/CardIconButton.js'
23
22
  import {
@@ -215,8 +214,8 @@ export const StepDetailsContent: React.FC<{
215
214
 
216
215
  fromAmount =
217
216
  estimatedFromAmount > 0n
218
- ? formatUnits(estimatedFromAmount, step.action.fromToken.decimals)
219
- : formatUnits(
217
+ ? formatTokenAmount(estimatedFromAmount, step.action.fromToken.decimals)
218
+ : formatTokenAmount(
220
219
  BigInt(step.estimate.fromAmount),
221
220
  step.action.fromToken.decimals
222
221
  )
@@ -243,22 +242,24 @@ export const StepDetailsContent: React.FC<{
243
242
  >
244
243
  {!showToAmount ? (
245
244
  <>
246
- {formatUnits(
247
- BigInt(step.estimate.fromAmount),
248
- step.action.fromToken.decimals
249
- )}{' '}
245
+ {t('format.tokenAmount', {
246
+ value: formatTokenAmount(
247
+ BigInt(step.estimate.fromAmount),
248
+ step.action.fromToken.decimals
249
+ ),
250
+ })}{' '}
250
251
  {step.action.fromToken.symbol}
251
252
  {' - '}
252
253
  </>
253
254
  ) : null}
254
- {t('format.number', {
255
+ {t('format.tokenAmount', {
255
256
  value: fromAmount,
256
257
  })}{' '}
257
258
  {step.action.fromToken.symbol}
258
259
  {showToAmount ? (
259
260
  <>
260
261
  <ArrowForward sx={{ fontSize: 18, paddingX: 0.5, height: 12 }} />
261
- {t('format.number', {
262
+ {t('format.tokenAmount', {
262
263
  value: formatTokenAmount(
263
264
  BigInt(step.execution?.toAmount ?? step.estimate.toAmount),
264
265
  step.execution?.toToken?.decimals ?? step.action.toToken.decimals
@@ -268,9 +269,11 @@ export const StepDetailsContent: React.FC<{
268
269
  </>
269
270
  ) : (
270
271
  ` (${t('format.currency', {
271
- value:
272
- Number.parseFloat(fromAmount) *
273
- Number.parseFloat(step.action.fromToken.priceUSD),
272
+ value: formatTokenPrice(
273
+ fromAmount,
274
+ step.action.fromToken.priceUSD,
275
+ step.action.fromToken.decimals
276
+ ),
274
277
  })})`
275
278
  )}
276
279
  </Typography>
@@ -36,7 +36,7 @@ export const ToAddressRequiredMessage: React.FC<
36
36
  </Typography>
37
37
  }
38
38
  icon={<Wallet />}
39
- multilineTitle
39
+ multiline
40
40
  />
41
41
  </Box>
42
42
  </Collapse>
@@ -74,7 +74,11 @@ export const TokenBase: FC<TokenProps & BoxProps> = ({
74
74
  }
75
75
 
76
76
  const tokenAmount = formatTokenAmount(token.amount, token.decimals)
77
- const tokenPrice = formatTokenPrice(tokenAmount, token.priceUSD)
77
+ const tokenPrice = formatTokenPrice(
78
+ token.amount,
79
+ token.priceUSD,
80
+ token.decimals
81
+ )
78
82
 
79
83
  let priceImpact: number | undefined = undefined
80
84
  let priceImpactPercent: number | undefined = undefined
@@ -127,6 +131,7 @@ export const TokenBase: FC<TokenProps & BoxProps> = ({
127
131
  display: 'flex',
128
132
  alignItems: 'center',
129
133
  }}
134
+ title={tokenAmount}
130
135
  >
131
136
  <TextFitter
132
137
  height={30}
@@ -134,7 +139,7 @@ export const TokenBase: FC<TokenProps & BoxProps> = ({
134
139
  fontWeight: 700,
135
140
  }}
136
141
  >
137
- {t('format.number', {
142
+ {t('format.tokenAmount', {
138
143
  value: tokenAmount,
139
144
  })}
140
145
  </TextFitter>