@lifi/widget 3.14.0-beta.0 → 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.
- package/CHANGELOG.md +15 -0
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js +0 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js.map +1 -1
- package/dist/esm/components/AlertMessage/AlertMessage.d.ts +2 -2
- package/dist/esm/components/AlertMessage/AlertMessage.js +1 -1
- package/dist/esm/components/AlertMessage/AlertMessage.js.map +1 -1
- package/dist/esm/components/AmountInput/PriceFormHelperText.js +7 -4
- package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
- package/dist/esm/components/FeeBreakdownTooltip.js +3 -4
- package/dist/esm/components/FeeBreakdownTooltip.js.map +1 -1
- package/dist/esm/components/GasMessage/FundsSufficiencyMessage.js +1 -1
- package/dist/esm/components/GasMessage/FundsSufficiencyMessage.js.map +1 -1
- package/dist/esm/components/RouteCard/RouteCard.js +4 -8
- package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
- package/dist/esm/components/Step/CircularProgress.js +1 -2
- package/dist/esm/components/Step/CircularProgress.js.map +1 -1
- package/dist/esm/components/Step/CircularProgress.style.js +2 -13
- package/dist/esm/components/Step/CircularProgress.style.js.map +1 -1
- package/dist/esm/components/Step/StepProcess.js +1 -2
- package/dist/esm/components/Step/StepProcess.js.map +1 -1
- package/dist/esm/components/Step/StepTimer.js +1 -2
- package/dist/esm/components/Step/StepTimer.js.map +1 -1
- package/dist/esm/components/StepActions/StepActions.js +8 -8
- package/dist/esm/components/StepActions/StepActions.js.map +1 -1
- package/dist/esm/components/ToAddressRequiredMessage.js +1 -1
- package/dist/esm/components/ToAddressRequiredMessage.js.map +1 -1
- package/dist/esm/components/Token/Token.js +3 -3
- package/dist/esm/components/Token/Token.js.map +1 -1
- package/dist/esm/components/TokenList/TokenListItem.js +4 -6
- package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
- package/dist/esm/components/TokenRate/TokenRate.js +5 -7
- package/dist/esm/components/TokenRate/TokenRate.js.map +1 -1
- package/dist/esm/components/TransactionDetails.js +3 -7
- package/dist/esm/components/TransactionDetails.js.map +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useProcessMessage.js +6 -18
- package/dist/esm/hooks/useProcessMessage.js.map +1 -1
- package/dist/esm/hooks/useRoutes.d.ts +2 -2
- package/dist/esm/hooks/useRoutes.js +58 -99
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/i18n/en.json +14 -16
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.d.ts +1 -0
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js +6 -4
- package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js +5 -3
- package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js +2 -2
- package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js +3 -1
- package/dist/esm/providers/I18nProvider/I18nProvider.js.map +1 -1
- package/dist/esm/providers/WalletProvider/SDKProviders.js +15 -2
- package/dist/esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.d.ts +8 -0
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js +95 -0
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js.map +1 -0
- package/dist/esm/types/widget.d.ts +0 -1
- package/dist/esm/utils/compactNumberFormatter.d.ts +10 -0
- package/dist/esm/utils/compactNumberFormatter.js +81 -0
- package/dist/esm/utils/compactNumberFormatter.js.map +1 -0
- package/dist/esm/utils/compactNumberFormatter.test.d.ts +1 -0
- package/dist/esm/utils/compactNumberFormatter.test.js +64 -0
- package/dist/esm/utils/compactNumberFormatter.test.js.map +1 -0
- package/dist/esm/utils/converters.js +2 -2
- package/dist/esm/utils/converters.js.map +1 -1
- package/dist/esm/utils/fees.js +2 -3
- package/dist/esm/utils/fees.js.map +1 -1
- package/dist/esm/utils/format.d.ts +1 -10
- package/dist/esm/utils/format.js +8 -47
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/getPriceImpact.js +7 -6
- package/dist/esm/utils/getPriceImpact.js.map +1 -1
- package/dist/esm/utils/percentFormatter.js.map +1 -0
- package/package.json +8 -8
- package/src/components/ActiveTransactions/ActiveTransactionItem.tsx +0 -1
- package/src/components/AlertMessage/AlertMessage.tsx +3 -3
- package/src/components/AmountInput/PriceFormHelperText.tsx +8 -4
- package/src/components/FeeBreakdownTooltip.tsx +3 -4
- package/src/components/GasMessage/FundsSufficiencyMessage.tsx +1 -1
- package/src/components/RouteCard/RouteCard.tsx +6 -9
- package/src/components/Step/CircularProgress.style.tsx +2 -13
- package/src/components/Step/CircularProgress.tsx +1 -2
- package/src/components/Step/StepProcess.tsx +1 -2
- package/src/components/Step/StepTimer.tsx +1 -3
- package/src/components/StepActions/StepActions.tsx +16 -13
- package/src/components/ToAddressRequiredMessage.tsx +1 -1
- package/src/components/Token/Token.tsx +7 -2
- package/src/components/TokenList/TokenListItem.tsx +9 -9
- package/src/components/TokenRate/TokenRate.tsx +5 -11
- package/src/components/TransactionDetails.tsx +4 -8
- package/src/config/version.ts +1 -1
- package/src/hooks/useProcessMessage.ts +5 -24
- package/src/hooks/useRoutes.ts +66 -127
- package/src/i18n/en.json +14 -16
- package/src/pages/SendToWallet/ConfirmAddressSheet.tsx +28 -6
- package/src/pages/SendToWallet/SendToWalletPage.tsx +8 -2
- package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +2 -2
- package/src/providers/I18nProvider/I18nProvider.tsx +3 -1
- package/src/providers/WalletProvider/SDKProviders.tsx +16 -2
- package/src/providers/WalletProvider/getSafeMultisigConfig.ts +144 -0
- package/src/types/widget.ts +0 -1
- package/src/utils/compactNumberFormatter.test.ts +67 -0
- package/src/utils/compactNumberFormatter.ts +91 -0
- package/src/utils/converters.ts +6 -4
- package/src/utils/fees.ts +6 -4
- package/src/utils/format.ts +14 -60
- package/src/utils/getPriceImpact.ts +15 -6
- package/dist/esm/providers/I18nProvider/percentFormatter.js.map +0 -1
- /package/dist/esm/{providers/I18nProvider → utils}/percentFormatter.d.ts +0 -0
- /package/dist/esm/{providers/I18nProvider → utils}/percentFormatter.js +0 -0
- /package/src/{providers/I18nProvider → utils}/percentFormatter.ts +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const precisionFormatter: Intl.NumberFormat;
|
|
2
1
|
/**
|
|
3
2
|
* Format token amount to at least 6 decimals.
|
|
4
3
|
* @param amount amount to format.
|
|
@@ -7,12 +6,4 @@ export declare const precisionFormatter: Intl.NumberFormat;
|
|
|
7
6
|
export declare function formatTokenAmount(amount: bigint | undefined, decimals: number): string;
|
|
8
7
|
export declare function formatSlippage(slippage?: string, defaultValue?: string, returnInitial?: boolean): string;
|
|
9
8
|
export declare function formatInputAmount(amount: string, decimals?: number | null, returnInitial?: boolean): string;
|
|
10
|
-
export declare function formatTokenPrice(amount?: string, price?: string): number;
|
|
11
|
-
/**
|
|
12
|
-
* Converts a number to a subscript format if it contains leading zeros in the fractional part.
|
|
13
|
-
*
|
|
14
|
-
* @param {number} value - The number to be converted.
|
|
15
|
-
* @param {Intl.NumberFormatOptions} options An object that contains one or more properties that specify comparison options.
|
|
16
|
-
* @returns {string} - The number formatted as a string, with subscripts for leading zeros if applicable.
|
|
17
|
-
*/
|
|
18
|
-
export declare function convertToSubscriptFormat(value: number, options?: Intl.NumberFormatOptions): string;
|
|
9
|
+
export declare function formatTokenPrice(amount?: string | bigint, price?: string, decimals?: number): number;
|
package/dist/esm/utils/format.js
CHANGED
|
@@ -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
|
|
10
|
+
if (!parsedAmount || Number.isNaN(Number(formattedAmount))) {
|
|
19
11
|
return '0';
|
|
20
12
|
}
|
|
21
|
-
return
|
|
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
|
-
|
|
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(
|
|
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
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatTokenPrice } from './format.js';
|
|
2
2
|
export const getPriceImpact = ({ fromToken, toToken, fromAmount, toAmount, }) => {
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
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,
|
|
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.14.0
|
|
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",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@bigmi/core": "^0.1.0",
|
|
35
35
|
"@emotion/react": "^11.14.0",
|
|
36
36
|
"@emotion/styled": "^11.14.0",
|
|
37
|
-
"@lifi/sdk": "3.
|
|
37
|
+
"@lifi/sdk": "^3.5.2",
|
|
38
38
|
"@mui/icons-material": "6.0.2",
|
|
39
|
-
"@mui/material": "^6.4.
|
|
40
|
-
"@mui/system": "^6.4.
|
|
39
|
+
"@mui/material": "^6.4.1",
|
|
40
|
+
"@mui/system": "^6.4.1",
|
|
41
41
|
"@solana/wallet-adapter-base": "^0.9.23",
|
|
42
42
|
"@solana/web3.js": "^1.98.0",
|
|
43
43
|
"@tanstack/react-virtual": "^3.11.2",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"microdiff": "^1.5.0",
|
|
46
46
|
"mitt": "^3.0.1",
|
|
47
47
|
"react-i18next": "^15.4.0",
|
|
48
|
-
"react-intersection-observer": "^9.15.
|
|
48
|
+
"react-intersection-observer": "^9.15.1",
|
|
49
49
|
"react-router-dom": "^6.28.0",
|
|
50
|
-
"viem": "^2.22.
|
|
50
|
+
"viem": "^2.22.11",
|
|
51
51
|
"zustand": "^5.0.3",
|
|
52
|
-
"@lifi/wallet-management": "^3.6.0
|
|
52
|
+
"@lifi/wallet-management": "^3.6.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@bigmi/react": ">=0.0
|
|
55
|
+
"@bigmi/react": ">=0.1.0",
|
|
56
56
|
"@solana/wallet-adapter-react": "^0.15.35",
|
|
57
57
|
"@tanstack/react-query": "^5.62.0",
|
|
58
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
|
-
|
|
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
|
-
|
|
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={
|
|
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
|
|
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:
|
|
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.
|
|
78
|
-
value:
|
|
81
|
+
{`/ ${t('format.tokenAmount', {
|
|
82
|
+
value: tokenAmount,
|
|
79
83
|
})}`}
|
|
80
84
|
</Typography>
|
|
81
85
|
) : null}
|
|
@@ -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.
|
|
64
|
-
value:
|
|
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>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TokenAmount } from '@lifi/sdk'
|
|
2
|
-
import { isEVMPermitStep } from '@lifi/sdk'
|
|
3
2
|
import { ExpandLess, ExpandMore } from '@mui/icons-material'
|
|
4
3
|
import { Box, Collapse } from '@mui/material'
|
|
5
4
|
import type { MouseEventHandler } from 'react'
|
|
@@ -46,12 +45,9 @@ export const RouteCard: React.FC<
|
|
|
46
45
|
: undefined
|
|
47
46
|
|
|
48
47
|
const customLabels = getMatchingLabels(route, routeLabels)
|
|
49
|
-
const tags
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (hasRelayerSupport) {
|
|
53
|
-
tags.push('GASLESS')
|
|
54
|
-
}
|
|
48
|
+
const tags = route.tags?.filter(
|
|
49
|
+
(tag) => tag === 'CHEAPEST' || tag === 'FASTEST'
|
|
50
|
+
)
|
|
55
51
|
|
|
56
52
|
const cardContent = (
|
|
57
53
|
<Box
|
|
@@ -59,7 +55,8 @@ export const RouteCard: React.FC<
|
|
|
59
55
|
flex: 1,
|
|
60
56
|
}}
|
|
61
57
|
>
|
|
62
|
-
{subvariant !== 'refuel' &&
|
|
58
|
+
{subvariant !== 'refuel' &&
|
|
59
|
+
(route.tags?.length || customLabels.length) ? (
|
|
63
60
|
<Box
|
|
64
61
|
sx={{
|
|
65
62
|
display: 'flex',
|
|
@@ -69,7 +66,7 @@ export const RouteCard: React.FC<
|
|
|
69
66
|
flexWrap: 'wrap',
|
|
70
67
|
}}
|
|
71
68
|
>
|
|
72
|
-
{tags
|
|
69
|
+
{tags?.length ? (
|
|
73
70
|
<CardLabel type={active ? 'active' : undefined}>
|
|
74
71
|
<CardLabelTypography>
|
|
75
72
|
{t(`main.tags.${tags[0].toLowerCase()}` as any)}
|
|
@@ -15,7 +15,6 @@ const getStatusColor = (
|
|
|
15
15
|
substatus?: Substatus
|
|
16
16
|
) => {
|
|
17
17
|
switch (status) {
|
|
18
|
-
case 'PERMIT_REQUIRED':
|
|
19
18
|
case 'ACTION_REQUIRED':
|
|
20
19
|
return alpha(theme.palette.info.main, 0.12)
|
|
21
20
|
case 'DONE':
|
|
@@ -34,22 +33,12 @@ export const CircularIcon = styled(Box, {
|
|
|
34
33
|
shouldForwardProp: (prop: string) => !['status', 'substatus'].includes(prop),
|
|
35
34
|
})<{ status?: ProcessStatus; substatus?: Substatus }>(
|
|
36
35
|
({ theme, status, substatus }) => ({
|
|
37
|
-
backgroundColor: [
|
|
38
|
-
'PERMIT_REQUIRED',
|
|
39
|
-
'ACTION_REQUIRED',
|
|
40
|
-
'DONE',
|
|
41
|
-
'FAILED',
|
|
42
|
-
].includes(status!)
|
|
36
|
+
backgroundColor: ['ACTION_REQUIRED', 'DONE', 'FAILED'].includes(status!)
|
|
43
37
|
? getStatusColor(theme, status, substatus)
|
|
44
38
|
: theme.palette.background.paper,
|
|
45
39
|
borderStyle: 'solid',
|
|
46
40
|
borderColor: getStatusColor(theme, status, substatus),
|
|
47
|
-
borderWidth: ![
|
|
48
|
-
'PERMIT_REQUIRED',
|
|
49
|
-
'ACTION_REQUIRED',
|
|
50
|
-
'DONE',
|
|
51
|
-
'FAILED',
|
|
52
|
-
].includes(status!)
|
|
41
|
+
borderWidth: !['ACTION_REQUIRED', 'DONE', 'FAILED'].includes(status!)
|
|
53
42
|
? 3
|
|
54
43
|
: 0,
|
|
55
44
|
display: 'grid',
|
|
@@ -17,8 +17,7 @@ export function CircularProgress({ process }: { process: Process }) {
|
|
|
17
17
|
{process.status === 'STARTED' || process.status === 'PENDING' ? (
|
|
18
18
|
<CircularProgressPending size={40} />
|
|
19
19
|
) : null}
|
|
20
|
-
{process.status === '
|
|
21
|
-
process.status === 'ACTION_REQUIRED' ? (
|
|
20
|
+
{process.status === 'ACTION_REQUIRED' ? (
|
|
22
21
|
<InfoRounded
|
|
23
22
|
color="info"
|
|
24
23
|
sx={{
|
|
@@ -44,9 +44,7 @@ export const StepTimer: React.FC<{
|
|
|
44
44
|
return
|
|
45
45
|
}
|
|
46
46
|
const shouldRestart = executionProcess.status === 'FAILED'
|
|
47
|
-
const shouldPause =
|
|
48
|
-
executionProcess.status === 'PERMIT_REQUIRED' ||
|
|
49
|
-
executionProcess.status === 'ACTION_REQUIRED'
|
|
47
|
+
const shouldPause = executionProcess.status === 'ACTION_REQUIRED'
|
|
50
48
|
const shouldStart =
|
|
51
49
|
executionProcess.status === 'STARTED' ||
|
|
52
50
|
executionProcess.status === 'PENDING'
|
|
@@ -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
|
-
?
|
|
219
|
-
:
|
|
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
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
273
|
-
|
|
272
|
+
value: formatTokenPrice(
|
|
273
|
+
fromAmount,
|
|
274
|
+
step.action.fromToken.priceUSD,
|
|
275
|
+
step.action.fromToken.decimals
|
|
276
|
+
),
|
|
274
277
|
})})`
|
|
275
278
|
)}
|
|
276
279
|
</Typography>
|
|
@@ -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(
|
|
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.
|
|
142
|
+
{t('format.tokenAmount', {
|
|
138
143
|
value: tokenAmount,
|
|
139
144
|
})}
|
|
140
145
|
</TextFitter>
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import type { MouseEventHandler } from 'react'
|
|
14
14
|
import { useRef, useState } from 'react'
|
|
15
15
|
import { useTranslation } from 'react-i18next'
|
|
16
|
-
import { formatUnits } from 'viem'
|
|
17
16
|
import { useExplorer } from '../../hooks/useExplorer.js'
|
|
18
17
|
import { formatTokenAmount, formatTokenPrice } from '../../utils/format.js'
|
|
19
18
|
import { shortenAddress } from '../../utils/wallet.js'
|
|
@@ -66,12 +65,6 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
66
65
|
const { t } = useTranslation()
|
|
67
66
|
const { getAddressLink } = useExplorer()
|
|
68
67
|
|
|
69
|
-
const tokenPrice = token.amount
|
|
70
|
-
? formatTokenPrice(
|
|
71
|
-
formatUnits(token.amount, token.decimals),
|
|
72
|
-
token.priceUSD
|
|
73
|
-
)
|
|
74
|
-
: undefined
|
|
75
68
|
const container = useRef(null)
|
|
76
69
|
const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
|
|
77
70
|
const [showAddress, setShowAddress] = useState(false)
|
|
@@ -93,6 +86,12 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
93
86
|
setShowAddress(false)
|
|
94
87
|
}
|
|
95
88
|
}
|
|
89
|
+
const tokenAmount = formatTokenAmount(token.amount, token.decimals)
|
|
90
|
+
const tokenPrice = formatTokenPrice(
|
|
91
|
+
token.amount,
|
|
92
|
+
token.priceUSD,
|
|
93
|
+
token.decimals
|
|
94
|
+
)
|
|
96
95
|
|
|
97
96
|
return (
|
|
98
97
|
<ListItemButton
|
|
@@ -186,9 +185,10 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
|
|
|
186
185
|
sx={{
|
|
187
186
|
fontWeight: 600,
|
|
188
187
|
}}
|
|
188
|
+
title={tokenAmount}
|
|
189
189
|
>
|
|
190
|
-
{t('format.
|
|
191
|
-
value:
|
|
190
|
+
{t('format.tokenAmount', {
|
|
191
|
+
value: tokenAmount,
|
|
192
192
|
})}
|
|
193
193
|
</Typography>
|
|
194
194
|
) : null}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { RouteExtended } from '@lifi/sdk'
|
|
2
2
|
import type { TypographyProps } from '@mui/material'
|
|
3
3
|
import type { MouseEventHandler } from 'react'
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
4
5
|
import { formatUnits } from 'viem'
|
|
5
6
|
import { create } from 'zustand'
|
|
6
|
-
import {
|
|
7
|
-
convertToSubscriptFormat,
|
|
8
|
-
precisionFormatter,
|
|
9
|
-
} from '../../utils/format.js'
|
|
10
7
|
import { TokenRateTypography } from './TokenRate.style.js'
|
|
11
8
|
|
|
12
9
|
interface TokenRateProps extends TypographyProps {
|
|
@@ -24,6 +21,7 @@ const useTokenRate = create<TokenRateState>((set) => ({
|
|
|
24
21
|
}))
|
|
25
22
|
|
|
26
23
|
export const TokenRate: React.FC<TokenRateProps> = ({ route }) => {
|
|
24
|
+
const { t } = useTranslation()
|
|
27
25
|
const { isForward, toggleIsForward } = useTokenRate()
|
|
28
26
|
|
|
29
27
|
const toggleRate: MouseEventHandler<HTMLSpanElement> = (e) => {
|
|
@@ -54,16 +52,12 @@ export const TokenRate: React.FC<TokenRateProps> = ({ route }) => {
|
|
|
54
52
|
Number.parseFloat(formatUnits(toToken.amount!, toToken.decimals))
|
|
55
53
|
|
|
56
54
|
const rateText = isForward
|
|
57
|
-
? `1 ${fromToken.symbol} ≈ ${
|
|
58
|
-
: `1 ${toToken.symbol} ≈ ${
|
|
59
|
-
|
|
60
|
-
const rateTitle = isForward
|
|
61
|
-
? `1 ${fromToken.symbol} ≈ ${precisionFormatter.format(fromToRate)} ${toToken.symbol}`
|
|
62
|
-
: `1 ${toToken.symbol} ≈ ${precisionFormatter.format(toFromRate)} ${fromToken.symbol}`
|
|
55
|
+
? `1 ${fromToken.symbol} ≈ ${t('format.tokenAmount', { value: fromToRate })} ${toToken.symbol}`
|
|
56
|
+
: `1 ${toToken.symbol} ≈ ${t('format.tokenAmount', { value: toFromRate })} ${fromToken.symbol}`
|
|
63
57
|
|
|
64
58
|
return (
|
|
65
59
|
// biome-ignore lint/a11y/useSemanticElements:
|
|
66
|
-
<TokenRateTypography onClick={toggleRate} role="button"
|
|
60
|
+
<TokenRateTypography onClick={toggleRate} role="button">
|
|
67
61
|
{rateText}
|
|
68
62
|
</TokenRateTypography>
|
|
69
63
|
)
|
|
@@ -8,11 +8,10 @@ import type { CardProps } from '@mui/material'
|
|
|
8
8
|
import { Box, Collapse, Tooltip, Typography } from '@mui/material'
|
|
9
9
|
import { useState } from 'react'
|
|
10
10
|
import { useTranslation } from 'react-i18next'
|
|
11
|
-
import { formatUnits } from 'viem'
|
|
12
11
|
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
|
|
13
12
|
import { isRouteDone } from '../stores/routes/utils.js'
|
|
14
13
|
import { getAccumulatedFeeCostsBreakdown } from '../utils/fees.js'
|
|
15
|
-
import { formatTokenAmount } from '../utils/format.js'
|
|
14
|
+
import { formatTokenAmount, formatTokenPrice } from '../utils/format.js'
|
|
16
15
|
import { getPriceImpact } from '../utils/getPriceImpact.js'
|
|
17
16
|
import { Card } from './Card/Card.js'
|
|
18
17
|
import { CardIconButton } from './Card/CardIconButton.js'
|
|
@@ -56,14 +55,11 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
|
|
|
56
55
|
BigInt(feeCollectionStep.estimate.fromAmount) -
|
|
57
56
|
BigInt(feeCollectionStep.estimate.toAmount)
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
feeAmountUSD = formatTokenPrice(
|
|
60
59
|
estimatedFromAmount,
|
|
60
|
+
feeCollectionStep.action.fromToken.priceUSD,
|
|
61
61
|
feeCollectionStep.action.fromToken.decimals
|
|
62
62
|
)
|
|
63
|
-
|
|
64
|
-
feeAmountUSD =
|
|
65
|
-
Number.parseFloat(feeAmount) *
|
|
66
|
-
Number.parseFloat(feeCollectionStep.action.fromToken.priceUSD)
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
const showIntegratorFeeCollectionDetails =
|
|
@@ -245,7 +241,7 @@ export const TransactionDetails: React.FC<TransactionDetailsProps> = ({
|
|
|
245
241
|
sx={{ cursor: 'help' }}
|
|
246
242
|
>
|
|
247
243
|
<Typography variant="body2">
|
|
248
|
-
{t('format.
|
|
244
|
+
{t('format.tokenAmount', {
|
|
249
245
|
value: formatTokenAmount(
|
|
250
246
|
BigInt(route.toAmountMin),
|
|
251
247
|
route.toToken.decimals
|
package/src/config/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget'
|
|
2
|
-
export const version = '3.14.0
|
|
2
|
+
export const version = '3.14.0'
|