@lifi/widget 1.25.1 → 1.26.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/cjs/components/ActiveSwaps/ActiveSwapItem.js +6 -3
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +1 -1
- package/cjs/components/Header/NavigationHeader.js +1 -1
- package/cjs/components/Header/WalletHeader.js +1 -1
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.js +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +3 -3
- package/cjs/components/Step/CircularProgress.js +10 -9
- package/cjs/components/Step/CircularProgress.style.d.ts +12 -3
- package/cjs/components/Step/CircularProgress.style.js +26 -10
- package/cjs/components/Step/DestinationWalletAddress.d.ts +7 -0
- package/cjs/components/Step/DestinationWalletAddress.js +32 -0
- package/cjs/components/Step/GasStepProcess.d.ts +5 -0
- package/cjs/components/Step/GasStepProcess.js +24 -0
- package/cjs/components/Step/Step.d.ts +1 -0
- package/cjs/components/Step/Step.js +18 -6
- package/cjs/components/Step/StepList.d.ts +3 -0
- package/cjs/components/Step/StepList.js +20 -0
- package/cjs/components/Step/StepProcess.js +2 -2
- package/cjs/components/Step/index.d.ts +1 -0
- package/cjs/components/Step/index.js +1 -0
- package/cjs/components/SwapButton/SwapButton.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -1
- package/cjs/config/sentry.js +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +4 -1
- package/cjs/hooks/useProcessMessage.js +47 -5
- package/cjs/hooks/useRouteExecution.d.ts +8 -2
- package/cjs/hooks/useRouteExecution.js +14 -5
- package/cjs/hooks/useSwapRoutes.d.ts +2 -2
- package/cjs/hooks/useSwapRoutes.js +7 -0
- package/cjs/hooks/useTokenBalance.js +2 -2
- package/cjs/hooks/useTools.js +2 -0
- package/cjs/i18n/en.json +44 -28
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +10 -15
- package/cjs/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.d.ts +15 -0
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +71 -0
- package/cjs/pages/SwapPage/StatusBottomSheet.js +20 -4
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +4 -4
- package/cjs/pages/SwapPage/SwapPage.js +12 -14
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +3 -2
- package/cjs/utils/navigationRoutes.js +1 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +6 -3
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +1 -1
- package/components/Header/NavigationHeader.js +2 -2
- package/components/Header/WalletHeader.js +1 -1
- package/components/ReverseTokensButton/ReverseTokensButton.style.js +1 -1
- package/components/Step/CircularProgress.d.ts +3 -3
- package/components/Step/CircularProgress.js +12 -11
- package/components/Step/CircularProgress.style.d.ts +12 -3
- package/components/Step/CircularProgress.style.js +27 -11
- package/components/Step/DestinationWalletAddress.d.ts +7 -0
- package/components/Step/DestinationWalletAddress.js +28 -0
- package/components/Step/GasStepProcess.d.ts +5 -0
- package/components/Step/GasStepProcess.js +20 -0
- package/components/Step/Step.d.ts +1 -0
- package/components/Step/Step.js +18 -6
- package/components/Step/StepList.d.ts +3 -0
- package/components/Step/StepList.js +16 -0
- package/components/Step/StepProcess.js +2 -2
- package/components/Step/index.d.ts +1 -0
- package/components/Step/index.js +1 -0
- package/components/SwapButton/SwapButton.js +1 -1
- package/components/SwapRouteCard/SwapRouteNotFoundCard.js +1 -1
- package/config/sentry.js +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +5 -2
- package/hooks/useProcessMessage.js +47 -5
- package/hooks/useRouteExecution.d.ts +8 -2
- package/hooks/useRouteExecution.js +15 -6
- package/hooks/useSwapRoutes.d.ts +2 -2
- package/hooks/useSwapRoutes.js +7 -0
- package/hooks/useTokenBalance.js +2 -2
- package/hooks/useTools.js +2 -0
- package/i18n/en.json +44 -28
- package/package.json +9 -9
- package/pages/SwapDetailsPage/SwapDetailsPage.js +14 -19
- package/pages/SwapHistoryPage/SwapHistoryEmpty.js +1 -1
- package/pages/SwapPage/ExchangeRateBottomSheet.d.ts +15 -0
- package/pages/SwapPage/ExchangeRateBottomSheet.js +67 -0
- package/pages/SwapPage/StatusBottomSheet.js +22 -6
- package/pages/SwapPage/StatusBottomSheet.style.js +4 -4
- package/pages/SwapPage/SwapPage.js +15 -17
- package/pages/SwapPage/TokenValueBottomSheet.js +3 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/utils/navigationRoutes.js +1 -0
package/hooks/useSwapRoutes.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const useSwapRoutes: () => {
|
|
2
|
-
routes: import("@lifi/
|
|
2
|
+
routes: import("@lifi/sdk").Route[] | undefined;
|
|
3
3
|
isLoading: boolean;
|
|
4
4
|
isFetching: boolean;
|
|
5
5
|
isFetched: boolean;
|
|
6
6
|
dataUpdatedAt: number;
|
|
7
7
|
refetchTime: number;
|
|
8
|
-
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/
|
|
8
|
+
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse, any>>;
|
|
9
9
|
};
|
package/hooks/useSwapRoutes.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { isAddress } from '@ethersproject/address';
|
|
11
|
+
import { LifiErrorCode } from '@lifi/sdk';
|
|
11
12
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
12
13
|
import Big from 'big.js';
|
|
13
14
|
import { useWatch } from 'react-hook-form';
|
|
@@ -107,6 +108,12 @@ export const useSwapRoutes = () => {
|
|
|
107
108
|
refetchInterval,
|
|
108
109
|
staleTime: refetchTime,
|
|
109
110
|
cacheTime: refetchTime,
|
|
111
|
+
retry(failureCount, error) {
|
|
112
|
+
if ((error === null || error === void 0 ? void 0 : error.code) === LifiErrorCode.NotFound) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
110
117
|
});
|
|
111
118
|
return {
|
|
112
119
|
routes: data === null || data === void 0 ? void 0 : data.routes,
|
package/hooks/useTokenBalance.js
CHANGED
|
@@ -82,8 +82,8 @@ export const useTokenBalance = (token, accountAddress) => {
|
|
|
82
82
|
};
|
|
83
83
|
const refetchNewBalance = useCallback(() => {
|
|
84
84
|
queryClient.setQueryDefaults(tokenBalanceQueryKey, {
|
|
85
|
-
refetchInterval:
|
|
86
|
-
staleTime:
|
|
85
|
+
refetchInterval: 250,
|
|
86
|
+
staleTime: 250,
|
|
87
87
|
});
|
|
88
88
|
}, [queryClient, tokenBalanceQueryKey]);
|
|
89
89
|
return {
|
package/hooks/useTools.js
CHANGED
|
@@ -15,6 +15,8 @@ export const useTools = () => {
|
|
|
15
15
|
.filter((exchange) => isItemAllowed(exchange.key, exchanges))
|
|
16
16
|
.map((exchange) => exchange.key));
|
|
17
17
|
},
|
|
18
|
+
refetchInterval: 180000,
|
|
19
|
+
staleTime: 180000,
|
|
18
20
|
});
|
|
19
21
|
const formattedTools = useMemo(() => ({
|
|
20
22
|
bridges: data === null || data === void 0 ? void 0 : data.bridges.reduce((bridges, bridge) => {
|
package/i18n/en.json
CHANGED
|
@@ -69,22 +69,27 @@
|
|
|
69
69
|
},
|
|
70
70
|
"swap": {
|
|
71
71
|
"crossStepDetails": "Bridge from {{from}} to {{to}} via {{tool}}",
|
|
72
|
+
"currentAmount": "Current amount",
|
|
72
73
|
"error": {
|
|
73
74
|
"message": {
|
|
74
|
-
"
|
|
75
|
+
"slippageThreshold": "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote.",
|
|
75
76
|
"transactionFailed": "Please check the block explorer for more information.",
|
|
76
|
-
"transactionNotSent": "Transaction was not sent
|
|
77
|
-
"transactionRejected": "Your signature is required to complete the transaction. {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} on {{chainName}} remain in your wallet."
|
|
77
|
+
"transactionNotSent": "Transaction was not sent. {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
78
|
+
"transactionRejected": "Your signature is required to complete the transaction. {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
79
|
+
"unknown": "Please try again or contact support."
|
|
78
80
|
},
|
|
79
81
|
"title": {
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
82
|
+
"balanceIsTooLow": "The balance is too low",
|
|
83
|
+
"chainSwitch": "Chain switch required",
|
|
84
|
+
"failed": "Swap failed",
|
|
85
|
+
"gasLimitIsTooLow": "The gas limit is too low",
|
|
86
|
+
"slippageNotMet": "Slippage conditions not met",
|
|
87
|
+
"transactionCanceled": "Transaction canceled",
|
|
88
|
+
"transactionFailed": "Transaction failed",
|
|
89
|
+
"transactionRejected": "Signature required",
|
|
90
|
+
"transactionUnderpriced": "Transaction is underpriced",
|
|
91
|
+
"transactionUnprepared": "Unable to prepare transaction",
|
|
92
|
+
"unknown": "Something went wrong",
|
|
88
93
|
"walletAddressInvalid": "Wallet address is invalid.",
|
|
89
94
|
"walletEnsAddressInvalid": "Wallet address is invalid or network doesn't support ENS."
|
|
90
95
|
}
|
|
@@ -94,6 +99,8 @@
|
|
|
94
99
|
"from": "From",
|
|
95
100
|
"fromAmount": "You pay",
|
|
96
101
|
"gasCost": "Gas cost",
|
|
102
|
+
"gasFeeEstimated": "estimated gas fee",
|
|
103
|
+
"gasFeePaid": "gas fee paid",
|
|
97
104
|
"inProgress": "in progress",
|
|
98
105
|
"info": {
|
|
99
106
|
"message": {
|
|
@@ -112,37 +119,43 @@
|
|
|
112
119
|
"otherTokens": "Other tokens",
|
|
113
120
|
"process": {
|
|
114
121
|
"crossChain": {
|
|
115
|
-
"actionRequired": "Please sign the transaction
|
|
116
|
-
"done": "
|
|
117
|
-
"pending": "Waiting for transaction
|
|
118
|
-
"started": "Preparing transaction
|
|
122
|
+
"actionRequired": "Please sign the transaction",
|
|
123
|
+
"done": "Bridge transaction confirmed",
|
|
124
|
+
"pending": "Waiting for bridge transaction",
|
|
125
|
+
"started": "Preparing bridge transaction"
|
|
119
126
|
},
|
|
120
127
|
"receivingChain": {
|
|
121
|
-
"done": "
|
|
122
|
-
"
|
|
128
|
+
"done": "Bridge completed",
|
|
129
|
+
"partial": "Bridge partially completed",
|
|
130
|
+
"pending": "Waiting for destination chain",
|
|
131
|
+
"refunded": "Bridge transaction refunded"
|
|
123
132
|
},
|
|
124
133
|
"swap": {
|
|
125
|
-
"actionRequired": "Please sign the transaction
|
|
126
|
-
"done": "Swap completed
|
|
127
|
-
"pending": "
|
|
128
|
-
"started": "Preparing swap
|
|
134
|
+
"actionRequired": "Please sign the transaction",
|
|
135
|
+
"done": "Swap completed",
|
|
136
|
+
"pending": "Waiting for swap transaction",
|
|
137
|
+
"started": "Preparing swap transaction"
|
|
129
138
|
},
|
|
130
139
|
"switchChain": {
|
|
131
|
-
"actionRequired": "Chain switch required
|
|
132
|
-
"done": "Chain switched successfully
|
|
140
|
+
"actionRequired": "Chain switch required",
|
|
141
|
+
"done": "Chain switched successfully"
|
|
133
142
|
},
|
|
134
143
|
"tokenAllowance": {
|
|
135
|
-
"done": "Token allowance approved
|
|
136
|
-
"pending": "Waiting for token allowance
|
|
137
|
-
"started": "Setting token allowance
|
|
144
|
+
"done": "Token allowance approved",
|
|
145
|
+
"pending": "Waiting for token allowance",
|
|
146
|
+
"started": "Setting token allowance"
|
|
138
147
|
}
|
|
139
148
|
},
|
|
149
|
+
"quotedAmount": "Quoted amount",
|
|
150
|
+
"rateChange": "Rate change",
|
|
140
151
|
"receiving": "Receiving",
|
|
141
152
|
"routes": "You get",
|
|
142
153
|
"selectChain": "Chain",
|
|
143
154
|
"selectChainAndToken": "Select chain and token",
|
|
144
155
|
"selectToken": "Token",
|
|
156
|
+
"sendToAddress": "Send to {{address}}",
|
|
145
157
|
"sendToWallet": "Send to a different wallet",
|
|
158
|
+
"sentToAddress": "Sent to {{address}}",
|
|
146
159
|
"stepBridge": "Bridge",
|
|
147
160
|
"stepSwap": "Swap",
|
|
148
161
|
"stepSwapAndBridge": "Swap and bridge",
|
|
@@ -153,6 +166,7 @@
|
|
|
153
166
|
},
|
|
154
167
|
"title": {
|
|
155
168
|
"gasSwapSuccessful": "Gas swap successful",
|
|
169
|
+
"refundIssued": "Refund issued",
|
|
156
170
|
"swapPartiallySuccessful": "Swap partially successful",
|
|
157
171
|
"swapSuccessful": "Swap successful"
|
|
158
172
|
}
|
|
@@ -179,14 +193,16 @@
|
|
|
179
193
|
"deleteSwapHistory": "Swap history is only stored locally and can't be recovered if you delete it.",
|
|
180
194
|
"highValueLoss": "The value of the received tokens is significantly lower than the swapped tokens and transaction cost.",
|
|
181
195
|
"insufficientFunds": "You don't have enough funds to execute the swap.",
|
|
182
|
-
"insufficientGas": "You need to add at least:"
|
|
196
|
+
"insufficientGas": "You need to add at least:",
|
|
197
|
+
"rateChanged": "The exchange rate has changed. By continuing the swap, you'll accept the new rate."
|
|
183
198
|
},
|
|
184
199
|
"title": {
|
|
185
200
|
"deleteActiveSwaps": "Delete all active swaps?",
|
|
186
201
|
"deleteSwap": "Delete this swap?",
|
|
187
202
|
"deleteSwapHistory": "Delete swap history?",
|
|
188
203
|
"highValueLoss": "High value loss",
|
|
189
|
-
"insufficientGas": "Insufficient gas"
|
|
204
|
+
"insufficientGas": "Insufficient gas",
|
|
205
|
+
"rateChanged": "Rate changed"
|
|
190
206
|
}
|
|
191
207
|
}
|
|
192
208
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.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
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@ethersproject/address": "^5.7.0",
|
|
43
43
|
"@ethersproject/experimental": "^5.7.0",
|
|
44
44
|
"@ethersproject/providers": "^5.7.2",
|
|
45
|
-
"@lifi/sdk": "^1.
|
|
45
|
+
"@lifi/sdk": "^1.7.0",
|
|
46
46
|
"@lifi/wallet-management": "^1.2.1",
|
|
47
|
-
"@mui/icons-material": "^5.10.
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.10.
|
|
50
|
-
"@sentry/integrations": "^7.
|
|
51
|
-
"@sentry/react": "^7.
|
|
52
|
-
"@sentry/tracing": "^7.
|
|
47
|
+
"@mui/icons-material": "^5.10.15",
|
|
48
|
+
"@mui/lab": "^5.0.0-alpha.109",
|
|
49
|
+
"@mui/material": "^5.10.15",
|
|
50
|
+
"@sentry/integrations": "^7.21.1",
|
|
51
|
+
"@sentry/react": "^7.21.1",
|
|
52
|
+
"@sentry/tracing": "^7.21.1",
|
|
53
53
|
"@tanstack/react-query": "^4.16.1",
|
|
54
54
|
"@tanstack/react-virtual": "^3.0.0-beta.23",
|
|
55
55
|
"big.js": "^6.2.1",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"mitt": "^3.0.0",
|
|
61
61
|
"react": "^18.2.0",
|
|
62
62
|
"react-dom": "^18.2.0",
|
|
63
|
-
"react-hook-form": "^7.39.
|
|
63
|
+
"react-hook-form": "^7.39.5",
|
|
64
64
|
"react-i18next": "^12.0.0",
|
|
65
65
|
"react-router-dom": "^6.4.3",
|
|
66
66
|
"react-timer-hook": "^3.0.5",
|
|
@@ -8,22 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { ContentCopy as ContentCopyIcon, DeleteOutline as DeleteIcon
|
|
12
|
-
import { Box, Button, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, Typography
|
|
13
|
-
import {
|
|
11
|
+
import { ContentCopy as ContentCopyIcon, DeleteOutline as DeleteIcon } from '@mui/icons-material';
|
|
12
|
+
import { Box, Button, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, Typography } from '@mui/material';
|
|
13
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useLocation } from 'react-router-dom';
|
|
16
16
|
import shallow from 'zustand/shallow';
|
|
17
17
|
import { Card, CardTitle } from '../../components/Card';
|
|
18
18
|
import { Dialog } from '../../components/Dialog';
|
|
19
19
|
import { useHeaderActionStore } from '../../components/Header';
|
|
20
|
-
import {
|
|
21
|
-
import { StepDivider } from '../../components/StepDivider';
|
|
20
|
+
import { getStepList } from '../../components/Step';
|
|
22
21
|
import { useNavigateBack } from '../../hooks';
|
|
23
22
|
import { useRouteExecutionStore } from '../../stores';
|
|
24
23
|
import { Container } from './SwapDetailsPage.style';
|
|
25
24
|
export const SwapDetailsPage = () => {
|
|
26
|
-
var _a, _b;
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
26
|
const { t, i18n } = useTranslation();
|
|
28
27
|
const { navigateBack } = useNavigateBack();
|
|
29
28
|
const { state } = useLocation();
|
|
@@ -38,29 +37,25 @@ export const SwapDetailsPage = () => {
|
|
|
38
37
|
deleteRoute(routeExecution.route.id);
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
let supportId = (_d = (_c = (_b = (_a = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps[0].execution) === null || _a === void 0 ? void 0 : _a.process.find((process) => process.txHash)) === null || _b === void 0 ? void 0 : _b.txHash) !== null && _c !== void 0 ? _c : routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id) !== null && _d !== void 0 ? _d : '';
|
|
41
|
+
if (process.env.NODE_ENV === 'development') {
|
|
42
|
+
supportId += `_${routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.id}`;
|
|
43
|
+
}
|
|
44
|
+
const copySupportId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
yield navigator.clipboard.writeText(supportId);
|
|
44
46
|
});
|
|
45
47
|
useEffect(() => {
|
|
46
48
|
return useHeaderActionStore.getState().setAction(_jsx(IconButton, Object.assign({ size: "medium", edge: "end", onClick: toggleDialog }, { children: _jsx(DeleteIcon, {}) })));
|
|
47
49
|
}, [toggleDialog]);
|
|
48
|
-
const startedAt = new Date((
|
|
50
|
+
const startedAt = new Date((_f = (_e = routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.steps[0].execution) === null || _e === void 0 ? void 0 : _e.process[0].startedAt) !== null && _f !== void 0 ? _f : 0);
|
|
49
51
|
return (_jsxs(Container, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
50
52
|
display: 'flex',
|
|
51
53
|
flex: 1,
|
|
52
54
|
justifyContent: 'space-between',
|
|
53
55
|
}, pb: 1 }, { children: [_jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, { dateStyle: 'long' }).format(startedAt) })), _jsx(Typography, Object.assign({ fontSize: 12 }, { children: new Intl.DateTimeFormat(i18n.language, {
|
|
54
56
|
timeStyle: 'short',
|
|
55
|
-
}).format(startedAt) }))] })), routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route.
|
|
56
|
-
var _a, _b, _c, _d, _e;
|
|
57
|
-
const fromToken = index === 0
|
|
58
|
-
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined;
|
|
59
|
-
const toToken = index === steps.length - 1
|
|
60
|
-
? Object.assign(Object.assign({}, ((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toToken) !== null && _b !== void 0 ? _b : (_c = step.action) === null || _c === void 0 ? void 0 : _c.toToken)), { amount: (_e = (_d = step.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : step.estimate.toAmount }) : undefined;
|
|
61
|
-
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: fromToken, toToken: toToken }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
|
|
62
|
-
}), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
57
|
+
}).format(startedAt) }))] })), getStepList(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route), _jsxs(Card, Object.assign({ mt: 2 }, { children: [_jsxs(Box, Object.assign({ sx: {
|
|
63
58
|
display: 'flex',
|
|
64
59
|
flex: 1,
|
|
65
|
-
} }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", onClick:
|
|
60
|
+
} }, { children: [_jsx(CardTitle, Object.assign({ flex: 1 }, { children: t('swap.supportId') })), _jsx(Box, Object.assign({ mr: 1, mt: 1 }, { children: _jsx(IconButton, Object.assign({ size: "medium", onClick: copySupportId }, { children: _jsx(ContentCopyIcon, { fontSize: "small" }) })) }))] })), _jsx(Typography, Object.assign({ variant: "body2", pt: 1, pb: 2, px: 2, sx: { wordBreak: 'break-all' } }, { children: supportId }))] })), _jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(Button, Object.assign({ href: "https://discord.com/channels/849912621360218112/863689862514343946", target: "_blank", rel: "nofollow noreferrer", fullWidth: true }, { children: t('button.contactSupport') })) })), _jsxs(Dialog, Object.assign({ open: open, onClose: toggleDialog }, { children: [_jsx(DialogTitle, { children: t('swap.warning.title.deleteSwap') }), _jsx(DialogContent, { children: _jsx(DialogContentText, { children: t('swap.warning.message.deleteSwapHistory') }) }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ onClick: toggleDialog }, { children: t('button.cancel') })), _jsx(Button, Object.assign({ variant: "contained", onClick: handleDeleteRoute, autoFocus: true }, { children: t('button.delete') }))] })] }))] }));
|
|
66
61
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { ReceiptLongRounded as HistoryIcon } from '@mui/icons-material';
|
|
3
3
|
import { Container, Typography } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
export const SwapHistoryEmpty = () => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExchangeRateUpdateParams, Route } from '@lifi/sdk';
|
|
3
|
+
export interface ExchangeRateBottomSheetBase {
|
|
4
|
+
isOpen(): void;
|
|
5
|
+
open(resolver: (value: boolean) => void, data: ExchangeRateUpdateParams): void;
|
|
6
|
+
close(value?: boolean): void;
|
|
7
|
+
}
|
|
8
|
+
interface ExchangeRateBottomSheetProps {
|
|
9
|
+
data?: ExchangeRateUpdateParams;
|
|
10
|
+
onContinue?(): void;
|
|
11
|
+
onCancel?(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const ExchangeRateBottomSheet: import("react").ForwardRefExoticComponent<ExchangeRateBottomSheetProps & import("react").RefAttributes<ExchangeRateBottomSheetBase>>;
|
|
14
|
+
export declare const getTokenValueLossThreshold: (route?: Route) => boolean;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { WarningRounded as WarningIcon } from '@mui/icons-material';
|
|
3
|
+
import { Box, Button, Typography } from '@mui/material';
|
|
4
|
+
import Big from 'big.js';
|
|
5
|
+
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { BottomSheet } from '../../components/BottomSheet';
|
|
8
|
+
import { useSetContentHeight } from '../../hooks';
|
|
9
|
+
import { formatTokenAmount } from '../../utils';
|
|
10
|
+
import { IconCircle, IconContainer } from './StatusBottomSheet.style';
|
|
11
|
+
export const ExchangeRateBottomSheet = forwardRef(({ onContinue, onCancel }, ref) => {
|
|
12
|
+
const [data, setData] = useState();
|
|
13
|
+
const bottomSheetRef = useRef(null);
|
|
14
|
+
const resolverRef = useRef();
|
|
15
|
+
const handleContinue = () => {
|
|
16
|
+
var _a;
|
|
17
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(true);
|
|
18
|
+
onContinue === null || onContinue === void 0 ? void 0 : onContinue();
|
|
19
|
+
};
|
|
20
|
+
const handleCancel = () => {
|
|
21
|
+
var _a;
|
|
22
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.close(false);
|
|
23
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
24
|
+
};
|
|
25
|
+
useImperativeHandle(ref, () => ({
|
|
26
|
+
isOpen: () => { var _a; return (_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen(); },
|
|
27
|
+
open: (resolver, data) => {
|
|
28
|
+
var _a;
|
|
29
|
+
setData(data);
|
|
30
|
+
resolverRef.current = resolver;
|
|
31
|
+
(_a = bottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
32
|
+
},
|
|
33
|
+
close: (value = false) => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
(_a = resolverRef.current) === null || _a === void 0 ? void 0 : _a.call(resolverRef, value);
|
|
36
|
+
(_b = bottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.close();
|
|
37
|
+
},
|
|
38
|
+
}), []);
|
|
39
|
+
return (_jsx(BottomSheet, Object.assign({ ref: bottomSheetRef }, { children: _jsx(ExchangeRateBottomSheetContent, { data: data, onContinue: handleContinue, onCancel: handleCancel }) })));
|
|
40
|
+
});
|
|
41
|
+
const ExchangeRateBottomSheetContent = ({ data, onCancel, onContinue }) => {
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
const ref = useRef();
|
|
44
|
+
useSetContentHeight(ref);
|
|
45
|
+
return (_jsxs(Box, Object.assign({ p: 3, ref: ref }, { children: [_jsxs(IconContainer, { children: [_jsx(IconCircle, Object.assign({ status: "warning", mb: 1 }, { children: _jsx(WarningIcon, { color: "warning" }) })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: t('swap.warning.title.rateChanged') }))] }), _jsx(Typography, Object.assign({ py: 1 }, { children: t('swap.warning.message.rateChanged') })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 1 }, { children: [_jsx(Typography, { children: t('swap.quotedAmount') }), _jsxs(Typography, Object.assign({ fontWeight: 600 }, { children: [t('format.number', {
|
|
46
|
+
value: formatTokenAmount(data === null || data === void 0 ? void 0 : data.oldToAmount, data === null || data === void 0 ? void 0 : data.toToken.decimals),
|
|
47
|
+
}), ' ', data === null || data === void 0 ? void 0 : data.toToken.symbol] }))] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [_jsx(Typography, { children: t('swap.currentAmount') }), _jsxs(Typography, Object.assign({ fontWeight: 600 }, { children: [t('format.number', {
|
|
48
|
+
value: formatTokenAmount(data === null || data === void 0 ? void 0 : data.newToAmount, data === null || data === void 0 ? void 0 : data.toToken.decimals),
|
|
49
|
+
}), ' ', data === null || data === void 0 ? void 0 : data.toToken.symbol] }))] })), _jsxs(Box, Object.assign({ display: "flex", justifyContent: "space-between", mt: 0.25 }, { children: [_jsx(Typography, { children: t('swap.rateChange') }), _jsxs(Typography, Object.assign({ fontWeight: 600 }, { children: [Big((data === null || data === void 0 ? void 0 : data.newToAmount) || 0)
|
|
50
|
+
.div(Big((data === null || data === void 0 ? void 0 : data.oldToAmount) || 0))
|
|
51
|
+
.minus(1)
|
|
52
|
+
.mul(100)
|
|
53
|
+
.round(2, Big.roundUp)
|
|
54
|
+
.toString(), "%"] }))] })), _jsxs(Box, Object.assign({ display: "flex", mt: 3 }, { children: [_jsx(Button, Object.assign({ variant: "text", onClick: onCancel, fullWidth: true }, { children: t('button.cancel') })), _jsx(Box, { display: "flex", p: 1 }), _jsx(Button, Object.assign({ variant: "contained", onClick: onContinue, fullWidth: true }, { children: t('button.continue') }))] }))] })));
|
|
55
|
+
};
|
|
56
|
+
export const getTokenValueLossThreshold = (route) => {
|
|
57
|
+
if (!route) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const fromAmountUSD = Big((route === null || route === void 0 ? void 0 : route.fromAmountUSD) || 0);
|
|
61
|
+
const toAmountUSD = Big((route === null || route === void 0 ? void 0 : route.toAmountUSD) || 0);
|
|
62
|
+
const gasCostUSD = Big((route === null || route === void 0 ? void 0 : route.gasCostUSD) || 0);
|
|
63
|
+
if (fromAmountUSD.eq(0) && toAmountUSD.eq(0)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return toAmountUSD.div(fromAmountUSD.plus(gasCostUSD)).lt(0.9);
|
|
67
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable consistent-return */
|
|
3
|
-
import { Done as DoneIcon,
|
|
3
|
+
import { Done as DoneIcon, ErrorRounded as ErrorIcon, InfoRounded as InfoIcon, WarningRounded as WarningIcon } from '@mui/icons-material';
|
|
4
4
|
import { Box, Button, Typography } from '@mui/material';
|
|
5
5
|
import { useEffect, useRef } from 'react';
|
|
6
6
|
import { useFormContext } from 'react-hook-form';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { BottomSheet } from '../../components/BottomSheet';
|
|
9
9
|
import { Token } from '../../components/Token';
|
|
10
|
-
import { getProcessMessage, useChains, useNavigateBack, useTokenBalance
|
|
10
|
+
import { getProcessMessage, useChains, useNavigateBack, useTokenBalance } from '../../hooks';
|
|
11
11
|
import { SwapFormKey } from '../../providers';
|
|
12
12
|
import { RouteExecutionStatus } from '../../stores';
|
|
13
|
-
import { formatTokenAmount, hasEnumFlag, navigationRoutes, shortenWalletAddress
|
|
13
|
+
import { formatTokenAmount, hasEnumFlag, navigationRoutes, shortenWalletAddress } from '../../utils';
|
|
14
14
|
import { IconCircle, IconContainer } from './StatusBottomSheet.style';
|
|
15
15
|
export const StatusBottomSheet = ({ status, route, }) => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
17
17
|
const { t } = useTranslation();
|
|
18
18
|
const { navigateBack, navigate } = useNavigateBack();
|
|
19
19
|
const ref = useRef(null);
|
|
@@ -92,9 +92,25 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
92
92
|
handlePrimaryButton = handlePartialDone;
|
|
93
93
|
break;
|
|
94
94
|
}
|
|
95
|
+
case RouteExecutionStatus.Done | RouteExecutionStatus.Refunded: {
|
|
96
|
+
title = t('swap.success.title.refundIssued');
|
|
97
|
+
primaryMessage = t('swap.success.message.swapPartiallySuccessful', {
|
|
98
|
+
tool: (_o = route.steps.at(-1)) === null || _o === void 0 ? void 0 : _o.toolDetails.name,
|
|
99
|
+
tokenSymbol: (_p = route.steps.at(-1)) === null || _p === void 0 ? void 0 : _p.action.toToken.symbol,
|
|
100
|
+
});
|
|
101
|
+
if (token) {
|
|
102
|
+
secondaryMessage = t('swap.success.message.swapSuccessful', {
|
|
103
|
+
amount: token.amount,
|
|
104
|
+
tokenSymbol: token.symbol,
|
|
105
|
+
chainName: (_q = getChainById(token.chainId)) === null || _q === void 0 ? void 0 : _q.name,
|
|
106
|
+
walletAddress: shortenWalletAddress(route.toAddress),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
95
111
|
case RouteExecutionStatus.Failed: {
|
|
96
112
|
const step = route.steps.find((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
|
|
97
|
-
const process = (
|
|
113
|
+
const process = (_r = step === null || step === void 0 ? void 0 : step.execution) === null || _r === void 0 ? void 0 : _r.process.find((process) => process.status === 'FAILED');
|
|
98
114
|
if (!step || !process) {
|
|
99
115
|
break;
|
|
100
116
|
}
|
|
@@ -120,7 +136,7 @@ export const StatusBottomSheet = ({ status, route, }) => {
|
|
|
120
136
|
}
|
|
121
137
|
}, [refetch, refetchNewBalance, status]);
|
|
122
138
|
return (_jsx(BottomSheet, Object.assign({ ref: ref }, { children: _jsxs(Box, Object.assign({ p: 3 }, { children: [_jsxs(IconContainer, { children: [_jsxs(IconCircle, Object.assign({ status: status, mb: 1 }, { children: [status === RouteExecutionStatus.Idle ? (_jsx(InfoIcon, { color: "primary" })) : null, status === RouteExecutionStatus.Done ? (_jsx(DoneIcon, { color: "success" })) : null, hasEnumFlag(status, RouteExecutionStatus.Partial) ||
|
|
123
|
-
hasEnumFlag(status, RouteExecutionStatus.Refunded) ? (_jsx(WarningIcon, { color: "warning" })) : null, hasEnumFlag(status, RouteExecutionStatus.Failed) ? (_jsx(
|
|
139
|
+
hasEnumFlag(status, RouteExecutionStatus.Refunded) ? (_jsx(WarningIcon, { color: "warning" })) : null, hasEnumFlag(status, RouteExecutionStatus.Failed) ? (_jsx(ErrorIcon, { color: "error" })) : null] })), _jsx(Typography, Object.assign({ py: 1, fontSize: 18, fontWeight: 700 }, { children: title })), hasEnumFlag(status, RouteExecutionStatus.Done) ? (_jsx(Token, { token: toToken, py: 1, disableDescription: true })) : null] }), _jsx(Typography, Object.assign({ py: 1 }, { children: primaryMessage })), secondaryMessage ? (_jsx(Typography, Object.assign({ py: 1 }, { children: secondaryMessage }))) : null, _jsx(Box, Object.assign({ mt: 2 }, { children: _jsxs(Button, Object.assign({ variant: "contained", fullWidth: true, onClick: handlePrimaryButton }, { children: [status === RouteExecutionStatus.Idle ? t('button.ok') : null, hasEnumFlag(status, RouteExecutionStatus.Done)
|
|
124
140
|
? t('button.done')
|
|
125
141
|
: null, status === RouteExecutionStatus.Failed
|
|
126
142
|
? t('button.seeDetails')
|
|
@@ -4,15 +4,15 @@ import { RouteExecutionStatus } from '../../stores';
|
|
|
4
4
|
const getStatusColor = (status, theme) => {
|
|
5
5
|
switch (status) {
|
|
6
6
|
case RouteExecutionStatus.Done:
|
|
7
|
-
return { color: theme.palette.success.main, alpha: 0.
|
|
7
|
+
return { color: theme.palette.success.main, alpha: 0.12, darken: 0 };
|
|
8
8
|
case RouteExecutionStatus.Failed:
|
|
9
|
-
return { color: theme.palette.error.main, alpha: 0.
|
|
9
|
+
return { color: theme.palette.error.main, alpha: 0.12, darken: 0 };
|
|
10
10
|
case RouteExecutionStatus.Done | RouteExecutionStatus.Partial:
|
|
11
11
|
case RouteExecutionStatus.Done | RouteExecutionStatus.Refunded:
|
|
12
12
|
case 'warning':
|
|
13
|
-
return { color: theme.palette.warning.main, alpha: 0.
|
|
13
|
+
return { color: theme.palette.warning.main, alpha: 0.48, darken: 0.32 };
|
|
14
14
|
default:
|
|
15
|
-
return { color: theme.palette.primary.main, alpha: 0.
|
|
15
|
+
return { color: theme.palette.primary.main, alpha: 0.12, darken: 0 };
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
export const IconContainer = styled(Box)(({ theme }) => ({
|
|
@@ -10,27 +10,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { Delete as DeleteIcon } from '@mui/icons-material';
|
|
12
12
|
import { Box, Button, Tooltip } from '@mui/material';
|
|
13
|
-
import {
|
|
13
|
+
import { useCallback, useRef } from 'react';
|
|
14
14
|
import { useFormContext } from 'react-hook-form';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { useLocation } from 'react-router-dom';
|
|
17
17
|
import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
|
|
18
|
-
import {
|
|
19
|
-
import { StepDivider } from '../../components/StepDivider';
|
|
18
|
+
import { getStepList } from '../../components/Step';
|
|
20
19
|
import { SwapButton } from '../../components/SwapButton';
|
|
21
20
|
import { useNavigateBack, useRouteExecution } from '../../hooks';
|
|
22
21
|
import { SwapFormKey } from '../../providers';
|
|
23
22
|
import { RouteExecutionStatus } from '../../stores';
|
|
23
|
+
import { ExchangeRateBottomSheet } from './ExchangeRateBottomSheet';
|
|
24
24
|
import { StatusBottomSheet } from './StatusBottomSheet';
|
|
25
25
|
import { Container } from './SwapPage.style';
|
|
26
|
-
import { getTokenValueLossThreshold, TokenValueBottomSheet
|
|
26
|
+
import { getTokenValueLossThreshold, TokenValueBottomSheet } from './TokenValueBottomSheet';
|
|
27
27
|
export const SwapPage = () => {
|
|
28
|
+
var _a;
|
|
28
29
|
const { t } = useTranslation();
|
|
29
30
|
const { state } = useLocation();
|
|
30
31
|
const { navigateBack } = useNavigateBack();
|
|
31
32
|
const tokenValueBottomSheetRef = useRef(null);
|
|
33
|
+
const exchangeRateBottomSheetRef = useRef(null);
|
|
32
34
|
const { setValue } = useFormContext();
|
|
33
|
-
const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution(
|
|
35
|
+
const { route, status, executeRoute, restartRoute, deleteRoute } = useRouteExecution({
|
|
36
|
+
routeId: state === null || state === void 0 ? void 0 : state.routeId,
|
|
37
|
+
onAcceptExchangeRateUpdate: (_a = exchangeRateBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.open,
|
|
38
|
+
});
|
|
34
39
|
const handleExecuteRoute = useCallback(() => {
|
|
35
40
|
var _a, _b;
|
|
36
41
|
if ((_a = tokenValueBottomSheetRef.current) === null || _a === void 0 ? void 0 : _a.isOpen()) {
|
|
@@ -40,11 +45,11 @@ export const SwapPage = () => {
|
|
|
40
45
|
setValue(SwapFormKey.FromAmount, '');
|
|
41
46
|
}, [executeRoute, setValue]);
|
|
42
47
|
const handleSwapClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
var
|
|
48
|
+
var _b;
|
|
44
49
|
if (status === RouteExecutionStatus.Idle) {
|
|
45
50
|
const thresholdExceeded = getTokenValueLossThreshold(route);
|
|
46
51
|
if (thresholdExceeded) {
|
|
47
|
-
(
|
|
52
|
+
(_b = tokenValueBottomSheetRef.current) === null || _b === void 0 ? void 0 : _b.open();
|
|
48
53
|
}
|
|
49
54
|
else {
|
|
50
55
|
handleExecuteRoute();
|
|
@@ -63,23 +68,16 @@ export const SwapPage = () => {
|
|
|
63
68
|
case RouteExecutionStatus.Idle:
|
|
64
69
|
return t('button.startSwap');
|
|
65
70
|
case RouteExecutionStatus.Failed:
|
|
66
|
-
return t('button.
|
|
71
|
+
return t('button.tryAgain');
|
|
67
72
|
default:
|
|
68
73
|
return '';
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
return (_jsxs(Container, { children: [route
|
|
72
|
-
var _a, _b, _c, _d, _e;
|
|
73
|
-
const fromToken = index === 0
|
|
74
|
-
? Object.assign(Object.assign({}, step.action.fromToken), { amount: step.action.fromAmount }) : undefined;
|
|
75
|
-
const toToken = index === steps.length - 1
|
|
76
|
-
? Object.assign(Object.assign({}, ((_b = (_a = step.execution) === null || _a === void 0 ? void 0 : _a.toToken) !== null && _b !== void 0 ? _b : (_c = step.action) === null || _c === void 0 ? void 0 : _c.toToken)), { amount: (_e = (_d = step.execution) === null || _d === void 0 ? void 0 : _d.toAmount) !== null && _e !== void 0 ? _e : step.estimate.toAmount }) : undefined;
|
|
77
|
-
return (_jsxs(Fragment, { children: [_jsx(Step, { step: step, fromToken: fromToken, toToken: toToken }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id));
|
|
78
|
-
}), status === RouteExecutionStatus.Idle ||
|
|
76
|
+
return (_jsxs(Container, { children: [getStepList(route), status === RouteExecutionStatus.Idle ||
|
|
79
77
|
status === RouteExecutionStatus.Failed ? (_jsxs(_Fragment, { children: [_jsx(GasSufficiencyMessage, { route: route, mt: 2 }), _jsxs(Box, Object.assign({ mt: 2, display: "flex" }, { children: [_jsx(SwapButton, { text: getSwapButtonText(), onClick: handleSwapClick, currentRoute: route,
|
|
80
78
|
// disable={status === 'idle' && (isValidating || !isValid)}
|
|
81
79
|
enableLoading: true }), status === RouteExecutionStatus.Failed ? (_jsx(Tooltip, Object.assign({ title: t('button.removeSwap'), placement: "bottom-end", enterDelay: 400, arrow: true }, { children: _jsx(Button, Object.assign({ onClick: handleRemoveRoute, sx: {
|
|
82
80
|
minWidth: 48,
|
|
83
81
|
marginLeft: 1,
|
|
84
|
-
} }, { children: _jsx(DeleteIcon, {}) })) }))) : null] }))] })) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null, route ? (_jsx(TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null] }));
|
|
82
|
+
} }, { children: _jsx(DeleteIcon, {}) })) }))) : null] }))] })) : null, route && status ? (_jsx(StatusBottomSheet, { status: status, route: route })) : null, route ? (_jsx(TokenValueBottomSheet, { route: route, ref: tokenValueBottomSheetRef, onContinue: handleExecuteRoute })) : null, route ? _jsx(ExchangeRateBottomSheet, { ref: exchangeRateBottomSheetRef }) : null] }));
|
|
85
83
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { WarningRounded as WarningIcon } from '@mui/icons-material';
|
|
3
3
|
import { Box, Button, Typography } from '@mui/material';
|
|
4
4
|
import Big from 'big.js';
|
|
5
5
|
import { forwardRef, useRef } from 'react';
|
|
@@ -23,7 +23,8 @@ const TokenValueBottomSheetContent = ({ route, onCancel, onContinue, }) => {
|
|
|
23
23
|
.div(Big(route.fromAmountUSD || 0).plus(Big(route.gasCostUSD || 0)))
|
|
24
24
|
.minus(1)
|
|
25
25
|
.mul(100)
|
|
26
|
-
.
|
|
26
|
+
.round(2, Big.roundUp)
|
|
27
|
+
.toString(), "%"] }))] })), _jsxs(Box, Object.assign({ display: "flex", mt: 3 }, { children: [_jsx(Button, Object.assign({ variant: "text", onClick: onCancel, fullWidth: true }, { children: t('button.cancel') })), _jsx(Box, { display: "flex", p: 1 }), _jsx(Button, Object.assign({ variant: "contained", onClick: onContinue, fullWidth: true }, { children: t('button.continue') }))] }))] })));
|
|
27
28
|
};
|
|
28
29
|
export const getTokenValueLossThreshold = (route) => {
|
|
29
30
|
if (!route) {
|