@rango-dev/widget-embedded 0.1.10-next.92 → 0.1.10-next.94
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/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +5 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmSwapErrors.d.ts +3 -2
- package/dist/components/ConfirmSwapErrors.d.ts.map +1 -1
- package/dist/components/ConfirmSwapWarnings.d.ts +3 -2
- package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -1
- package/dist/components/Layout.d.ts +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo.d.ts +1 -1
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/warnings/BalanceWarnings.d.ts.map +1 -1
- package/dist/components/warnings/ConfirmSwapExtraMessages.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts +11 -0
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/usePrevious.d.ts +1 -1
- package/dist/hooks/usePrevious.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/SelectChainPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +25 -0
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/settings.d.ts +15 -0
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/{store/confirmSwap.d.ts → types/routing.d.ts} +14 -5
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/utils/numbers.d.ts +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +11 -5
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +4 -3
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +7 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +581 -492
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +581 -492
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +582 -493
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/QueueManager.tsx +1 -0
- package/src/components/AppRoutes.tsx +54 -21
- package/src/components/ChangeSlippageButton.tsx +1 -1
- package/src/components/ConfirmSwapErrors.tsx +1 -1
- package/src/components/ConfirmSwapWarnings.tsx +1 -4
- package/src/components/Header.tsx +1 -1
- package/src/components/Layout.tsx +10 -11
- package/src/components/UpdateUrl.tsx +13 -22
- package/src/components/warnings/BalanceWarnings.tsx +27 -4
- package/src/components/warnings/ConfirmSwapExtraMessages.tsx +7 -1
- package/src/components/warnings/HighSlippageWarning.tsx +1 -1
- package/src/components/warnings/MinRequiredSlippage.tsx +2 -2
- package/src/hooks/useConfirmSwap.ts +260 -0
- package/src/pages/ConfirmSwapPage.tsx +17 -8
- package/src/pages/ConfirmWalletsPage.tsx +1 -1
- package/src/pages/Home.tsx +0 -1
- package/src/pages/SelectChainPage.tsx +2 -7
- package/src/pages/SelectTokenPage.tsx +22 -57
- package/src/pages/SettingsPage.tsx +8 -9
- package/src/pages/WalletsPage.tsx +16 -6
- package/src/store/bestRoute.ts +82 -37
- package/src/store/settings.ts +2 -2
- package/src/store/wallets.ts +26 -0
- package/src/types/index.ts +1 -0
- package/src/types/routing.ts +60 -0
- package/src/utils/numbers.ts +38 -17
- package/src/utils/routing.ts +115 -24
- package/src/utils/swap.ts +19 -11
- package/src/utils/wallets.ts +117 -73
- package/dist/store/confirmSwap.d.ts.map +0 -1
- package/src/store/confirmSwap.ts +0 -342
|
@@ -4,15 +4,15 @@ import { useInRouterContext as useInRouterContext$1, MemoryRouter, useLocation a
|
|
|
4
4
|
import { useSearchParams, useLocation, createSearchParams, useNavigate, useInRouterContext, useRoutes } from 'react-router-dom';
|
|
5
5
|
import { create } from 'zustand';
|
|
6
6
|
import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js';
|
|
7
|
-
import {
|
|
8
|
-
import { RangoClient, isEvmBlockchain } from 'rango-sdk';
|
|
9
|
-
import { Network, isEvmAddress, KEPLR_COMPATIBLE_WALLETS, WalletType, getCosmosExperimentalChainInfo, convertEvmBlockchainMetaToEvmChainInfo } from '@rango-dev/wallets-shared';
|
|
7
|
+
import { Network, isEvmAddress, detectInstallLink, KEPLR_COMPATIBLE_WALLETS, WalletType, getCosmosExperimentalChainInfo, detectMobileScreens, convertEvmBlockchainMetaToEvmChainInfo } from '@rango-dev/wallets-shared';
|
|
10
8
|
import { isCosmosBlockchain } from 'rango-types';
|
|
11
9
|
import { readAccountAddress, useWallets, Provider as Provider$1, Events } from '@rango-dev/wallets-core';
|
|
10
|
+
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
|
11
|
+
import { RangoClient, isEvmBlockchain } from 'rango-sdk';
|
|
12
|
+
import { shallow } from 'zustand/shallow';
|
|
12
13
|
import { useTranslation, initReactI18next } from 'react-i18next';
|
|
13
14
|
import { styled as styled$1 } from '@rango-dev/ui/src/theme';
|
|
14
15
|
import { allProviders } from '@rango-dev/provider-all';
|
|
15
|
-
import { shallow } from 'zustand/shallow';
|
|
16
16
|
import { useManager, Provider } from '@rango-dev/queue-manager-react';
|
|
17
17
|
import copy from 'copy-to-clipboard';
|
|
18
18
|
import i18n from 'i18next';
|
|
@@ -62,117 +62,6 @@ function shadeColor(color, percent) {
|
|
|
62
62
|
return '#' + RR + GG + BB;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const getBestRouteToTokenUsdPrice = bestRoute => bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.usdPrice;
|
|
66
|
-
function isNumberOfSwapsChanged(route1, route2) {
|
|
67
|
-
const route1Swaps = route1.result?.swaps || [];
|
|
68
|
-
const route2Swaps = route2.result?.swaps || [];
|
|
69
|
-
return route1Swaps.length !== route2Swaps.length;
|
|
70
|
-
}
|
|
71
|
-
function isRouteSwappersUpdated(route1, route2) {
|
|
72
|
-
const route1Swappers = route1.result?.swaps.map(swap => swap.swapperId) || [];
|
|
73
|
-
const route2Swappers = route2.result?.swaps.map(swap => swap.swapperId) || [];
|
|
74
|
-
return !areEqual(route1Swappers, route2Swappers);
|
|
75
|
-
}
|
|
76
|
-
function isRouteInternalCoinsUpdated(route1, route2) {
|
|
77
|
-
const route1InternalCoins = route1.result?.swaps.map(swap => swap.to.symbol) || [];
|
|
78
|
-
const route2InternalCoins = route2.result?.swaps.map(swap => swap.to.symbol) || [];
|
|
79
|
-
return !areEqual(route1InternalCoins, route2InternalCoins);
|
|
80
|
-
}
|
|
81
|
-
const isRouteChanged = (route1, route2) => {
|
|
82
|
-
return isNumberOfSwapsChanged(route1, route2) || isRouteSwappersUpdated(route1, route2) || isRouteInternalCoinsUpdated(route1, route2);
|
|
83
|
-
};
|
|
84
|
-
const getRequiredBalanceOfWallet = (selectedWallet, fee) => {
|
|
85
|
-
if (fee === null) return null;
|
|
86
|
-
const relatedFeeStatus = fee?.find(item => item.blockchain === selectedWallet.chain)?.wallets.find(wallet => wallet.address?.toLowerCase() === selectedWallet.address.toLowerCase());
|
|
87
|
-
if (!relatedFeeStatus) return null;
|
|
88
|
-
return relatedFeeStatus.requiredAssets;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const createSelectors = _store => {
|
|
92
|
-
let store = _store;
|
|
93
|
-
store.use = {};
|
|
94
|
-
for (let k of Object.keys(store.getState())) {
|
|
95
|
-
store.use[k] = () => store(s => s[k]);
|
|
96
|
-
}
|
|
97
|
-
return store;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const httpService = /*#__PURE__*/new RangoClient(process.env.REACT_APP_API_KEY);
|
|
101
|
-
|
|
102
|
-
const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
|
|
103
|
-
const DEFAULT_SLIPPAGE = 1;
|
|
104
|
-
const HIGH_SLIPPAGE = 5;
|
|
105
|
-
const MAX_SLIPPAGE = 100;
|
|
106
|
-
const MIN_SLIPPGAE = 0;
|
|
107
|
-
|
|
108
|
-
const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set => ({
|
|
109
|
-
meta: {
|
|
110
|
-
blockchains: [],
|
|
111
|
-
popularTokens: [],
|
|
112
|
-
swappers: [],
|
|
113
|
-
tokens: []
|
|
114
|
-
},
|
|
115
|
-
loadingStatus: 'loading',
|
|
116
|
-
fetchMeta: async () => {
|
|
117
|
-
try {
|
|
118
|
-
const response = await httpService.getAllMetadata();
|
|
119
|
-
const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
|
|
120
|
-
const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
|
|
121
|
-
response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
|
|
122
|
-
set({
|
|
123
|
-
meta: response,
|
|
124
|
-
loadingStatus: 'success'
|
|
125
|
-
});
|
|
126
|
-
} catch (error) {
|
|
127
|
-
set({
|
|
128
|
-
loadingStatus: 'failed'
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})));
|
|
133
|
-
|
|
134
|
-
const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/persist( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
135
|
-
slippage: DEFAULT_SLIPPAGE,
|
|
136
|
-
customSlippage: null,
|
|
137
|
-
infiniteApprove: false,
|
|
138
|
-
disabledLiquiditySources: [],
|
|
139
|
-
theme: 'auto',
|
|
140
|
-
setSlippage: slippage => set(() => ({
|
|
141
|
-
slippage: slippage
|
|
142
|
-
})),
|
|
143
|
-
setCustomSlippage: customSlippage => set(() => ({
|
|
144
|
-
customSlippage: customSlippage
|
|
145
|
-
})),
|
|
146
|
-
toggleAllLiquiditySources: () => set(state => {
|
|
147
|
-
const {
|
|
148
|
-
swappers
|
|
149
|
-
} = useMetaStore.getState().meta;
|
|
150
|
-
const swappersGroup = removeDuplicateFrom(swappers.map(swapper => swapper.swapperGroup));
|
|
151
|
-
if (swappersGroup.length === state.disabledLiquiditySources.length) return {
|
|
152
|
-
disabledLiquiditySources: []
|
|
153
|
-
};else {
|
|
154
|
-
return {
|
|
155
|
-
disabledLiquiditySources: swappersGroup
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}),
|
|
159
|
-
toggleInfiniteApprove: () => set(state => ({
|
|
160
|
-
infiniteApprove: !state.infiniteApprove
|
|
161
|
-
})),
|
|
162
|
-
toggleLiquiditySource: name => set(state => {
|
|
163
|
-
if (state.disabledLiquiditySources.includes(name)) return {
|
|
164
|
-
disabledLiquiditySources: state.disabledLiquiditySources.filter(liquiditySource => liquiditySource != name)
|
|
165
|
-
};else return {
|
|
166
|
-
disabledLiquiditySources: state.disabledLiquiditySources.concat(name)
|
|
167
|
-
};
|
|
168
|
-
}),
|
|
169
|
-
setTheme: theme => set(() => ({
|
|
170
|
-
theme
|
|
171
|
-
}))
|
|
172
|
-
})), {
|
|
173
|
-
name: 'user-settings'
|
|
174
|
-
})));
|
|
175
|
-
|
|
176
65
|
const secondsToString = s => {
|
|
177
66
|
const seconds = (s % 60).toString().padStart(2, '0');
|
|
178
67
|
const minutes = parseInt((s / 60).toString()).toString().padStart(2, '0');
|
|
@@ -231,15 +120,17 @@ function getlistWallet(getState, getWalletInfo, list) {
|
|
|
231
120
|
const {
|
|
232
121
|
name,
|
|
233
122
|
img: image,
|
|
234
|
-
installLink
|
|
123
|
+
installLink,
|
|
124
|
+
showOnMobile
|
|
235
125
|
} = getWalletInfo(type);
|
|
236
126
|
const state = getStateWallet(getState(type));
|
|
237
127
|
return {
|
|
238
128
|
name,
|
|
239
129
|
image,
|
|
240
|
-
installLink,
|
|
130
|
+
installLink: detectInstallLink(installLink),
|
|
241
131
|
state,
|
|
242
|
-
type
|
|
132
|
+
type,
|
|
133
|
+
showOnMobile: typeof showOnMobile === 'undefined' ? false : true
|
|
243
134
|
};
|
|
244
135
|
});
|
|
245
136
|
}
|
|
@@ -387,18 +278,12 @@ function numberWithThousandSeperator(number) {
|
|
|
387
278
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
388
279
|
return parts.join('.');
|
|
389
280
|
}
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const compareBalance = (tokenA, tokenB, wallet) => {
|
|
397
|
-
if (!tokenA.usdPrice || !tokenB.usdPrice) return 0;
|
|
398
|
-
const tokenAUsdValue = new BigNumber(getBalanceFromWallet(wallet, tokenA.blockchain, tokenA.symbol, tokenA.address)?.amount || ZERO).multipliedBy(tokenA.usdPrice);
|
|
399
|
-
const tokenBUsdValue = new BigNumber(getBalanceFromWallet(wallet, tokenB.blockchain, tokenB.symbol, tokenB.address)?.amount || ZERO).multipliedBy(tokenB.usdPrice);
|
|
400
|
-
if (tokenAUsdValue.gt(tokenBUsdValue)) return -1;
|
|
401
|
-
return 1;
|
|
281
|
+
const sortTokens = tokens => {
|
|
282
|
+
let walletConnected = !!tokens.some(token => token.balance);
|
|
283
|
+
if (!walletConnected) {
|
|
284
|
+
return tokens.filter(token => !token.address).concat(tokens.filter(token => token.address && !token.isSecondaryCoin), tokens.filter(token => token.isSecondaryCoin));
|
|
285
|
+
}
|
|
286
|
+
return tokens.filter(token => !!token.balance).sort((tokenA, tokenB) => parseFloat(tokenB.balance?.usdValue || '0') - parseFloat(tokenA.balance?.usdValue || '0')).concat(tokens.filter(token => !token.balance && !token.isSecondaryCoin), tokens.filter(token => !token.balance && token.isSecondaryCoin));
|
|
402
287
|
};
|
|
403
288
|
const getUsdPrice = (blockchain, symbol, address, allTokens) => {
|
|
404
289
|
const token = allTokens?.find(t => t.blockchain === blockchain && t.symbol?.toUpperCase() === symbol?.toUpperCase() && t.address === address);
|
|
@@ -415,6 +300,45 @@ const getKeplrCompatibleConnectedWallets = selectableWallets => {
|
|
|
415
300
|
const connectedWalletTypes = new Set(selectableWallets.map(a => a.walletType.toString()));
|
|
416
301
|
return KEPLR_COMPATIBLE_WALLETS.filter(compatibleWallet => connectedWalletTypes.has(compatibleWallet));
|
|
417
302
|
};
|
|
303
|
+
function getTokensWithBalance(tokens, balances) {
|
|
304
|
+
return tokens.map(_ref2 => {
|
|
305
|
+
let {
|
|
306
|
+
balance,
|
|
307
|
+
...otherProps
|
|
308
|
+
} = _ref2;
|
|
309
|
+
const tokenAmount = numberToString(new BigNumber(getBalanceFromWallet(balances, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO));
|
|
310
|
+
let tokenUsdValue = '';
|
|
311
|
+
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber(getBalanceFromWallet(balances, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO).multipliedBy(otherProps.usdPrice));
|
|
312
|
+
return {
|
|
313
|
+
...otherProps,
|
|
314
|
+
...(tokenAmount !== '0' && {
|
|
315
|
+
balance: {
|
|
316
|
+
amount: tokenAmount,
|
|
317
|
+
usdValue: tokenUsdValue
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function getSortedTokens(chain, tokens, balances, otherChainTokens) {
|
|
324
|
+
const fromChainEqueulsToToChain = chain?.name === otherChainTokens[0]?.name;
|
|
325
|
+
if (fromChainEqueulsToToChain) return otherChainTokens;
|
|
326
|
+
const filteredTokens = tokens.filter(token => token.blockchain === chain?.name);
|
|
327
|
+
return sortTokens(getTokensWithBalance(filteredTokens, balances));
|
|
328
|
+
}
|
|
329
|
+
function tokensAreEqual(tokenA, tokenB) {
|
|
330
|
+
return tokenA?.blockchain === tokenB?.blockchain && tokenA?.name === tokenB?.name && tokenA?.address === tokenB?.address;
|
|
331
|
+
}
|
|
332
|
+
function getDefaultToken(sortedTokens, otherToken) {
|
|
333
|
+
let selectedToken;
|
|
334
|
+
const firstToken = sortedTokens[0];
|
|
335
|
+
const secondToken = sortedTokens[1];
|
|
336
|
+
if (sortedTokens.length === 1) selectedToken = firstToken;else if (tokensAreEqual(firstToken, otherToken)) selectedToken = secondToken;else selectedToken = firstToken;
|
|
337
|
+
return selectedToken;
|
|
338
|
+
}
|
|
339
|
+
function sortWalletsBasedOnState(wallets) {
|
|
340
|
+
return wallets.sort((a, b) => Number(b.state === WalletState.CONNECTED) - Number(a.state === WalletState.CONNECTED) || Number(b.state === WalletState.DISCONNECTED) - Number(a.state === WalletState.DISCONNECTED));
|
|
341
|
+
}
|
|
418
342
|
|
|
419
343
|
function getOutputRatio(inputUsdValue, outputUsdValue) {
|
|
420
344
|
if (inputUsdValue.lte(ZERO) || outputUsdValue.lte(ZERO)) return 0;
|
|
@@ -582,10 +506,10 @@ function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validat
|
|
|
582
506
|
transferTransaction: null,
|
|
583
507
|
diagnosisUrl: null,
|
|
584
508
|
internalSteps: null,
|
|
585
|
-
fromBlockchainLogo: fromBlockchain
|
|
586
|
-
toBlockchainLogo: toBlockchain
|
|
587
|
-
swapperLogo: swapper?.logo,
|
|
588
|
-
swapperType: swapperType
|
|
509
|
+
fromBlockchainLogo: fromBlockchain?.logo || '',
|
|
510
|
+
toBlockchainLogo: toBlockchain?.logo || '',
|
|
511
|
+
swapperLogo: swapper?.logo || '',
|
|
512
|
+
swapperType: swapperType || ''
|
|
589
513
|
};
|
|
590
514
|
}) || []
|
|
591
515
|
};
|
|
@@ -629,7 +553,8 @@ function getMinRequiredSlippage(route) {
|
|
|
629
553
|
}
|
|
630
554
|
function hasProperSlippage(userSlippage, minRequiredSlippage) {
|
|
631
555
|
if (!minRequiredSlippage) return true;
|
|
632
|
-
|
|
556
|
+
//@ts-ignore
|
|
557
|
+
return parseFloat(userSlippage) >= parseFloat(minRequiredSlippage);
|
|
633
558
|
}
|
|
634
559
|
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites) {
|
|
635
560
|
const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
|
|
@@ -671,9 +596,10 @@ function getWalletsForNewSwap(selectedWallets) {
|
|
|
671
596
|
return wallets;
|
|
672
597
|
}
|
|
673
598
|
function getRouteOutputAmount(route) {
|
|
674
|
-
return route
|
|
599
|
+
return route?.result?.outputAmount || null;
|
|
675
600
|
}
|
|
676
601
|
function getPercentageChange(oldValue, newValue) {
|
|
602
|
+
if (!oldValue || !newValue) return null;
|
|
677
603
|
return new BigNumber(newValue).div(new BigNumber(oldValue)).minus(1).multipliedBy(100);
|
|
678
604
|
}
|
|
679
605
|
function isOutputAmountChangedALot(oldRoute, newRoute) {
|
|
@@ -681,6 +607,7 @@ function isOutputAmountChangedALot(oldRoute, newRoute) {
|
|
|
681
607
|
const newOutputAmount = getRouteOutputAmount(newRoute);
|
|
682
608
|
if (!oldOutputAmount || !newOutputAmount) return false;
|
|
683
609
|
const percentageChange = getPercentageChange(oldOutputAmount, newOutputAmount);
|
|
610
|
+
if (!percentageChange) return true;
|
|
684
611
|
return percentageChange.toNumber() <= -1;
|
|
685
612
|
}
|
|
686
613
|
function getBalanceWarnings(route, selectedWallets) {
|
|
@@ -698,7 +625,242 @@ function getBalanceWarnings(route, selectedWallets) {
|
|
|
698
625
|
const warningMessage = `Needs ≈ ${requiredAmount} ${symbol}${reason}, but you have ${currentAmount} ${symbol} in your ${asset.asset.blockchain} wallet.`;
|
|
699
626
|
return warningMessage;
|
|
700
627
|
});
|
|
701
|
-
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function searchParamsToToken(tokens, searchParams, chain) {
|
|
631
|
+
if (!chain) return null;
|
|
632
|
+
return tokens.find(token => {
|
|
633
|
+
const symbolAndAddress = searchParams?.split('--');
|
|
634
|
+
if (symbolAndAddress?.length === 1) return token.symbol === symbolAndAddress[0] && token.address === null && token.blockchain === chain.name;
|
|
635
|
+
return token.symbol === symbolAndAddress?.[0] && token.address === symbolAndAddress?.[1] && token.blockchain === chain.name;
|
|
636
|
+
}) || null;
|
|
637
|
+
}
|
|
638
|
+
function getBestRouteToTokenUsdPrice(bestRoute) {
|
|
639
|
+
return bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.usdPrice;
|
|
640
|
+
}
|
|
641
|
+
function isNumberOfSwapsChanged(route1, route2) {
|
|
642
|
+
const route1Swaps = route1.result?.swaps || [];
|
|
643
|
+
const route2Swaps = route2.result?.swaps || [];
|
|
644
|
+
return route1Swaps.length !== route2Swaps.length;
|
|
645
|
+
}
|
|
646
|
+
function isRouteSwappersUpdated(route1, route2) {
|
|
647
|
+
const route1Swappers = route1.result?.swaps.map(swap => swap.swapperId) || [];
|
|
648
|
+
const route2Swappers = route2.result?.swaps.map(swap => swap.swapperId) || [];
|
|
649
|
+
return !areEqual(route1Swappers, route2Swappers);
|
|
650
|
+
}
|
|
651
|
+
function isRouteInternalCoinsUpdated(route1, route2) {
|
|
652
|
+
const route1InternalCoins = route1.result?.swaps.map(swap => swap.to.symbol) || [];
|
|
653
|
+
const route2InternalCoins = route2.result?.swaps.map(swap => swap.to.symbol) || [];
|
|
654
|
+
return !areEqual(route1InternalCoins, route2InternalCoins);
|
|
655
|
+
}
|
|
656
|
+
function isRouteChanged(route1, route2) {
|
|
657
|
+
return isNumberOfSwapsChanged(route1, route2) || isRouteSwappersUpdated(route1, route2) || isRouteInternalCoinsUpdated(route1, route2);
|
|
658
|
+
}
|
|
659
|
+
function getRequiredBalanceOfWallet(selectedWallet, fee) {
|
|
660
|
+
if (fee === null) return null;
|
|
661
|
+
const relatedFeeStatus = fee?.find(item => item.blockchain === selectedWallet.chain)?.wallets.find(wallet => wallet.address?.toLowerCase() === selectedWallet.address.toLowerCase());
|
|
662
|
+
if (!relatedFeeStatus) return null;
|
|
663
|
+
return relatedFeeStatus.requiredAssets;
|
|
664
|
+
}
|
|
665
|
+
function isRouteParametersChanged(prevParams, currentParams) {
|
|
666
|
+
return prevParams.fromChain?.name !== currentParams.fromChain?.name || prevParams.toChain?.name !== currentParams.toChain?.name || prevParams.fromToken?.symbol !== currentParams.fromToken?.symbol || prevParams.toToken?.symbol !== currentParams.toToken?.symbol || prevParams.fromToken?.blockchain !== currentParams.fromToken?.blockchain || prevParams.toToken?.blockchain !== currentParams.toToken?.blockchain || prevParams.fromToken?.address !== currentParams.fromToken?.address || prevParams.toToken?.address !== currentParams.toToken?.address || prevParams.inputAmount !== currentParams.inputAmount || prevParams.slippage !== currentParams.slippage || prevParams.customSlippage !== currentParams.customSlippage || prevParams.disabledLiquiditySources?.length !== currentParams.disabledLiquiditySources?.length;
|
|
667
|
+
}
|
|
668
|
+
function getBestRouteWithCalculatedFees(bestRoute, tokens) {
|
|
669
|
+
if (!bestRoute || !bestRoute.result) return null;
|
|
670
|
+
const swapsWithFee = (bestRoute?.result?.swaps || []).map(swap => ({
|
|
671
|
+
...swap,
|
|
672
|
+
feeInUsd: numberToString(getUsdFeeOfStep(swap, tokens), 0, 2)
|
|
673
|
+
}));
|
|
674
|
+
return {
|
|
675
|
+
...bestRoute,
|
|
676
|
+
result: {
|
|
677
|
+
...bestRoute.result,
|
|
678
|
+
swaps: swapsWithFee
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const createSelectors = _store => {
|
|
684
|
+
let store = _store;
|
|
685
|
+
store.use = {};
|
|
686
|
+
for (let k of Object.keys(store.getState())) {
|
|
687
|
+
store.use[k] = () => store(s => s[k]);
|
|
688
|
+
}
|
|
689
|
+
return store;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const httpService = /*#__PURE__*/new RangoClient(process.env.REACT_APP_API_KEY);
|
|
693
|
+
|
|
694
|
+
const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
|
|
695
|
+
const DEFAULT_SLIPPAGE = 1;
|
|
696
|
+
const HIGH_SLIPPAGE = 5;
|
|
697
|
+
const MAX_SLIPPAGE = 100;
|
|
698
|
+
const MIN_SLIPPGAE = 0;
|
|
699
|
+
|
|
700
|
+
const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set => ({
|
|
701
|
+
meta: {
|
|
702
|
+
blockchains: [],
|
|
703
|
+
popularTokens: [],
|
|
704
|
+
swappers: [],
|
|
705
|
+
tokens: []
|
|
706
|
+
},
|
|
707
|
+
loadingStatus: 'loading',
|
|
708
|
+
fetchMeta: async () => {
|
|
709
|
+
try {
|
|
710
|
+
const response = await httpService.getAllMetadata();
|
|
711
|
+
const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
|
|
712
|
+
const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
|
|
713
|
+
response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
|
|
714
|
+
set({
|
|
715
|
+
meta: response,
|
|
716
|
+
loadingStatus: 'success'
|
|
717
|
+
});
|
|
718
|
+
} catch (error) {
|
|
719
|
+
set({
|
|
720
|
+
loadingStatus: 'failed'
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
})));
|
|
725
|
+
|
|
726
|
+
const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/persist( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
727
|
+
slippage: DEFAULT_SLIPPAGE,
|
|
728
|
+
customSlippage: null,
|
|
729
|
+
infiniteApprove: false,
|
|
730
|
+
disabledLiquiditySources: [],
|
|
731
|
+
theme: 'auto',
|
|
732
|
+
setSlippage: slippage => set(() => ({
|
|
733
|
+
slippage: slippage
|
|
734
|
+
})),
|
|
735
|
+
setCustomSlippage: customSlippage => set(() => ({
|
|
736
|
+
customSlippage: customSlippage
|
|
737
|
+
})),
|
|
738
|
+
toggleAllLiquiditySources: () => set(state => {
|
|
739
|
+
const {
|
|
740
|
+
swappers
|
|
741
|
+
} = useMetaStore.getState().meta;
|
|
742
|
+
const swappersGroup = removeDuplicateFrom(swappers.map(swapper => swapper.swapperGroup));
|
|
743
|
+
if (swappersGroup.length === state.disabledLiquiditySources.length) return {
|
|
744
|
+
disabledLiquiditySources: []
|
|
745
|
+
};else {
|
|
746
|
+
return {
|
|
747
|
+
disabledLiquiditySources: swappersGroup
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
}),
|
|
751
|
+
toggleInfiniteApprove: () => set(state => ({
|
|
752
|
+
infiniteApprove: !state.infiniteApprove
|
|
753
|
+
})),
|
|
754
|
+
toggleLiquiditySource: name => set(state => {
|
|
755
|
+
if (state.disabledLiquiditySources.includes(name)) return {
|
|
756
|
+
disabledLiquiditySources: state.disabledLiquiditySources.filter(liquiditySource => liquiditySource != name)
|
|
757
|
+
};else return {
|
|
758
|
+
disabledLiquiditySources: state.disabledLiquiditySources.concat(name)
|
|
759
|
+
};
|
|
760
|
+
}),
|
|
761
|
+
setTheme: theme => set(() => ({
|
|
762
|
+
theme
|
|
763
|
+
}))
|
|
764
|
+
})), {
|
|
765
|
+
name: 'user-settings'
|
|
766
|
+
})));
|
|
767
|
+
|
|
768
|
+
const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
769
|
+
accounts: [],
|
|
770
|
+
balances: [],
|
|
771
|
+
selectedWallets: [],
|
|
772
|
+
connectWallet: accounts => {
|
|
773
|
+
const tokens = useMetaStore.getState().meta.tokens;
|
|
774
|
+
set(state => ({
|
|
775
|
+
accounts: state.accounts.concat(accounts),
|
|
776
|
+
balances: state.balances.concat(accounts.map(account => ({
|
|
777
|
+
balances: [],
|
|
778
|
+
address: account.address,
|
|
779
|
+
chain: account.chain,
|
|
780
|
+
loading: true,
|
|
781
|
+
walletType: account.walletType,
|
|
782
|
+
error: false,
|
|
783
|
+
explorerUrl: null
|
|
784
|
+
})))
|
|
785
|
+
}));
|
|
786
|
+
accounts.forEach(async account => {
|
|
787
|
+
try {
|
|
788
|
+
const response = await httpService.getWalletsDetails([{
|
|
789
|
+
address: account.address,
|
|
790
|
+
blockchain: account.chain
|
|
791
|
+
}]);
|
|
792
|
+
const retrivedBalance = response.wallets[0];
|
|
793
|
+
if (retrivedBalance) {
|
|
794
|
+
set(state => ({
|
|
795
|
+
balances: state.balances.map(balance => {
|
|
796
|
+
return isAccountAndBalanceMatched(account, balance) ? makeBalanceFor(account, retrivedBalance, tokens) : balance;
|
|
797
|
+
})
|
|
798
|
+
}));
|
|
799
|
+
} else throw new Error('Wallet not found');
|
|
800
|
+
} catch (error) {
|
|
801
|
+
set(state => ({
|
|
802
|
+
balances: state.balances.map(balance => {
|
|
803
|
+
return isAccountAndBalanceMatched(account, balance) ? resetBalanceState(balance) : balance;
|
|
804
|
+
})
|
|
805
|
+
}));
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
},
|
|
809
|
+
disconnectWallet: walletType => {
|
|
810
|
+
set(state => ({
|
|
811
|
+
accounts: state.accounts.filter(account => account.walletType !== walletType),
|
|
812
|
+
balances: state.balances.filter(balance => balance.walletType !== walletType),
|
|
813
|
+
selectedWallets: state.selectedWallets.filter(wallet => wallet.walletType != walletType)
|
|
814
|
+
}));
|
|
815
|
+
},
|
|
816
|
+
initSelectedWallets: () => set(state => {
|
|
817
|
+
const requiredChains = getRequiredChains(useBestRouteStore.getState().bestRoute);
|
|
818
|
+
const connectedWallets = state.accounts;
|
|
819
|
+
const selectedWallets = [];
|
|
820
|
+
requiredChains.forEach(chain => {
|
|
821
|
+
const anyWalletSelected = !!state.selectedWallets.find(wallet => wallet.chain === chain);
|
|
822
|
+
if (!anyWalletSelected) {
|
|
823
|
+
const firstWalletWithMatchedChain = connectedWallets.find(wallet => wallet.chain === chain);
|
|
824
|
+
if (!!firstWalletWithMatchedChain) selectedWallets.push({
|
|
825
|
+
address: firstWalletWithMatchedChain.address,
|
|
826
|
+
chain: firstWalletWithMatchedChain.chain,
|
|
827
|
+
walletType: firstWalletWithMatchedChain.walletType
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
return {
|
|
832
|
+
selectedWallets: state.selectedWallets.concat(selectedWallets)
|
|
833
|
+
};
|
|
834
|
+
}),
|
|
835
|
+
setSelectedWallet: wallet => set(state => ({
|
|
836
|
+
selectedWallets: state.selectedWallets.filter(selectedWallet => selectedWallet.chain !== wallet.chain).concat({
|
|
837
|
+
chain: wallet.chain,
|
|
838
|
+
address: wallet.address,
|
|
839
|
+
walletType: wallet.walletType
|
|
840
|
+
})
|
|
841
|
+
})),
|
|
842
|
+
clearConnectedWallet: () => set(() => ({
|
|
843
|
+
accounts: [],
|
|
844
|
+
balances: [],
|
|
845
|
+
selectedWallets: []
|
|
846
|
+
}))
|
|
847
|
+
}))));
|
|
848
|
+
useWalletsStore.subscribe(state => state.balances, balances => {
|
|
849
|
+
useBestRouteStore.setState(_ref => {
|
|
850
|
+
let {
|
|
851
|
+
sourceTokens,
|
|
852
|
+
destinationTokens
|
|
853
|
+
} = _ref;
|
|
854
|
+
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens, balances);
|
|
855
|
+
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens, balances);
|
|
856
|
+
return {
|
|
857
|
+
sourceTokens: sortTokens(sourceTokensWithBalance),
|
|
858
|
+
destinationTokens: sortTokens(destinationTokensWithBalance)
|
|
859
|
+
};
|
|
860
|
+
});
|
|
861
|
+
}, {
|
|
862
|
+
equalityFn: shallow
|
|
863
|
+
});
|
|
702
864
|
|
|
703
865
|
const getUsdValue = (token, amount) => new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0);
|
|
704
866
|
const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
@@ -713,6 +875,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
713
875
|
bestRoute: null,
|
|
714
876
|
loading: false,
|
|
715
877
|
error: '',
|
|
878
|
+
sourceTokens: [],
|
|
879
|
+
destinationTokens: [],
|
|
716
880
|
setBestRoute: bestRoute => set(state => {
|
|
717
881
|
let outputAmount = null;
|
|
718
882
|
let outputUsdValue = ZERO;
|
|
@@ -728,27 +892,62 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
728
892
|
})
|
|
729
893
|
};
|
|
730
894
|
}),
|
|
731
|
-
setFromChain: chain
|
|
732
|
-
|
|
733
|
-
|
|
895
|
+
setFromChain: (chain, setDefaultToken) => {
|
|
896
|
+
set(state => {
|
|
897
|
+
if (state.fromChain?.name === chain?.name) return {};
|
|
898
|
+
const tokens = useMetaStore.getState().meta.tokens;
|
|
899
|
+
const balances = useWalletsStore.getState().balances;
|
|
900
|
+
const sortedTokens = getSortedTokens(chain, tokens, balances, state.destinationTokens);
|
|
901
|
+
const fromToken = getDefaultToken(sortedTokens, state.toToken);
|
|
902
|
+
return {
|
|
903
|
+
fromChain: chain,
|
|
904
|
+
sourceTokens: sortedTokens,
|
|
905
|
+
...(setDefaultToken && {
|
|
906
|
+
fromToken
|
|
907
|
+
}),
|
|
908
|
+
...(!!state.inputAmount && {
|
|
909
|
+
inputUsdValue: getUsdValue(fromToken, state.inputAmount)
|
|
910
|
+
})
|
|
911
|
+
};
|
|
912
|
+
});
|
|
913
|
+
},
|
|
734
914
|
setFromToken: token => set(state => ({
|
|
735
915
|
fromToken: token,
|
|
736
916
|
...(!!state.inputAmount && {
|
|
737
917
|
inputUsdValue: getUsdValue(token, state.inputAmount)
|
|
738
918
|
})
|
|
739
919
|
})),
|
|
740
|
-
setToChain: chain
|
|
741
|
-
|
|
742
|
-
|
|
920
|
+
setToChain: (chain, setDefaultToken) => {
|
|
921
|
+
set(state => {
|
|
922
|
+
if (state.toChain?.name === chain?.name) return {};
|
|
923
|
+
const tokens = useMetaStore.getState().meta.tokens;
|
|
924
|
+
const balances = useWalletsStore.getState().balances;
|
|
925
|
+
const sortedTokens = getSortedTokens(chain, tokens, balances, state.destinationTokens);
|
|
926
|
+
return {
|
|
927
|
+
toChain: chain,
|
|
928
|
+
destinationTokens: sortedTokens,
|
|
929
|
+
...(setDefaultToken && {
|
|
930
|
+
toToken: getDefaultToken(sortedTokens, state.fromToken)
|
|
931
|
+
})
|
|
932
|
+
};
|
|
933
|
+
});
|
|
934
|
+
},
|
|
743
935
|
setToToken: token => set(() => ({
|
|
744
936
|
toToken: token
|
|
745
937
|
})),
|
|
746
|
-
setInputAmount: amount =>
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
938
|
+
setInputAmount: amount => {
|
|
939
|
+
set(state => ({
|
|
940
|
+
inputAmount: amount,
|
|
941
|
+
...(!amount && {
|
|
942
|
+
outputAmount: new BigNumber(0),
|
|
943
|
+
outputUsdValue: new BigNumber(0),
|
|
944
|
+
bestRoute: null
|
|
945
|
+
}),
|
|
946
|
+
...(!!state.fromToken && {
|
|
947
|
+
inputUsdValue: getUsdValue(state.fromToken, amount)
|
|
948
|
+
})
|
|
949
|
+
}));
|
|
950
|
+
}
|
|
752
951
|
}))));
|
|
753
952
|
const bestRoute = (bestRouteStore, settingsStore) => {
|
|
754
953
|
let abortController = null;
|
|
@@ -766,11 +965,13 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
766
965
|
if (!fromToken || !toToken || !inputAmount) return;
|
|
767
966
|
abortController?.abort();
|
|
768
967
|
abortController = new AbortController();
|
|
769
|
-
const userSlippage = customSlippage
|
|
968
|
+
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
770
969
|
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
771
970
|
bestRouteStore.setState({
|
|
772
971
|
loading: true,
|
|
773
|
-
bestRoute: null
|
|
972
|
+
bestRoute: null,
|
|
973
|
+
outputAmount: null,
|
|
974
|
+
outputUsdValue: new BigNumber(0)
|
|
774
975
|
});
|
|
775
976
|
httpService.getBestRoute(requestBody, {
|
|
776
977
|
signal: abortController.signal
|
|
@@ -799,7 +1000,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
799
1000
|
inputAmount: state.inputAmount
|
|
800
1001
|
}), fetchBestRoute.bind(null), {
|
|
801
1002
|
equalityFn: (prevState, state) => {
|
|
802
|
-
if (prevState
|
|
1003
|
+
if (isRouteParametersChanged(prevState, state)) return false;else return true;
|
|
803
1004
|
}
|
|
804
1005
|
});
|
|
805
1006
|
useSettingsStore.subscribe(state => ({
|
|
@@ -808,7 +1009,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
808
1009
|
disabledLiquiditySources: state.disabledLiquiditySources
|
|
809
1010
|
}), fetchBestRoute.bind(null), {
|
|
810
1011
|
equalityFn: (prevState, state) => {
|
|
811
|
-
if (prevState
|
|
1012
|
+
if (isRouteParametersChanged(prevState, state)) return false;else return true;
|
|
812
1013
|
}
|
|
813
1014
|
});
|
|
814
1015
|
return {
|
|
@@ -839,13 +1040,6 @@ const useUiStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set => ({
|
|
|
839
1040
|
})
|
|
840
1041
|
})));
|
|
841
1042
|
|
|
842
|
-
function searchParamsToToken(tokens, searchParams) {
|
|
843
|
-
return tokens.find(token => {
|
|
844
|
-
const symbolAndAddress = searchParams?.split('--');
|
|
845
|
-
if (symbolAndAddress?.length === 1) return token.symbol === symbolAndAddress[0] && token.address === null;
|
|
846
|
-
return token.symbol === symbolAndAddress?.[0] && token.address === symbolAndAddress?.[1];
|
|
847
|
-
}) || null;
|
|
848
|
-
}
|
|
849
1043
|
function UpdateUrl() {
|
|
850
1044
|
const firstRender = useRef(true);
|
|
851
1045
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
@@ -953,15 +1147,15 @@ function UpdateUrl() {
|
|
|
953
1147
|
}, [location.pathname, inputAmount]);
|
|
954
1148
|
useEffect(() => {
|
|
955
1149
|
if (loadingStatus === 'success') {
|
|
956
|
-
const
|
|
1150
|
+
const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
|
|
957
1151
|
const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
|
|
958
1152
|
const toChainString = searchParams.get(SearchParams.TO_CHAIN);
|
|
959
1153
|
const toTokenString = searchParams.get(SearchParams.TO_TOKEN);
|
|
960
1154
|
const fromAmount = searchParams.get(SearchParams.FROM_AMOUNT);
|
|
961
|
-
const fromChain = blockchains.find(blockchain => blockchain.name ===
|
|
962
|
-
const fromToken = searchParamsToToken(tokens, fromTokenString);
|
|
1155
|
+
const fromChain = blockchains.find(blockchain => blockchain.name === fromChainString);
|
|
1156
|
+
const fromToken = searchParamsToToken(tokens, fromTokenString, fromChain || null);
|
|
963
1157
|
const toChain = blockchains.find(blockchain => blockchain.name === toChainString);
|
|
964
|
-
const toToken = searchParamsToToken(tokens, toTokenString);
|
|
1158
|
+
const toToken = searchParamsToToken(tokens, toTokenString, toChain || null);
|
|
965
1159
|
if (!!fromChain) {
|
|
966
1160
|
setFromChain(fromChain);
|
|
967
1161
|
if (!!fromToken) setFromToken(fromToken);
|
|
@@ -1032,92 +1226,11 @@ function Header(props) {
|
|
|
1032
1226
|
return React.createElement(HeaderContainer, null, React.createElement(Typography, {
|
|
1033
1227
|
variant: "h4",
|
|
1034
1228
|
className: titleStyle()
|
|
1035
|
-
}, t(title.toLocaleLowerCase())
|
|
1229
|
+
}, title ? t(title.toLocaleLowerCase()) : ''), React.createElement(HeaderButtons, {
|
|
1036
1230
|
onClickRefresh: onClickRefresh
|
|
1037
1231
|
}));
|
|
1038
1232
|
}
|
|
1039
1233
|
|
|
1040
|
-
const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
1041
|
-
accounts: [],
|
|
1042
|
-
balances: [],
|
|
1043
|
-
selectedWallets: [],
|
|
1044
|
-
connectWallet: accounts => {
|
|
1045
|
-
const tokens = useMetaStore.getState().meta.tokens;
|
|
1046
|
-
set(state => ({
|
|
1047
|
-
accounts: state.accounts.concat(accounts),
|
|
1048
|
-
balances: state.balances.concat(accounts.map(account => ({
|
|
1049
|
-
balances: [],
|
|
1050
|
-
address: account.address,
|
|
1051
|
-
chain: account.chain,
|
|
1052
|
-
loading: true,
|
|
1053
|
-
walletType: account.walletType,
|
|
1054
|
-
error: false,
|
|
1055
|
-
explorerUrl: null
|
|
1056
|
-
})))
|
|
1057
|
-
}));
|
|
1058
|
-
accounts.forEach(async account => {
|
|
1059
|
-
try {
|
|
1060
|
-
const response = await httpService.getWalletsDetails([{
|
|
1061
|
-
address: account.address,
|
|
1062
|
-
blockchain: account.chain
|
|
1063
|
-
}]);
|
|
1064
|
-
const retrivedBalance = response.wallets[0];
|
|
1065
|
-
if (retrivedBalance) {
|
|
1066
|
-
set(state => ({
|
|
1067
|
-
balances: state.balances.map(balance => {
|
|
1068
|
-
return isAccountAndBalanceMatched(account, balance) ? makeBalanceFor(account, retrivedBalance, tokens) : balance;
|
|
1069
|
-
})
|
|
1070
|
-
}));
|
|
1071
|
-
} else throw new Error('Wallet not found');
|
|
1072
|
-
} catch (error) {
|
|
1073
|
-
set(state => ({
|
|
1074
|
-
balances: state.balances.map(balance => {
|
|
1075
|
-
return isAccountAndBalanceMatched(account, balance) ? resetBalanceState(balance) : balance;
|
|
1076
|
-
})
|
|
1077
|
-
}));
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
|
-
},
|
|
1081
|
-
disconnectWallet: walletType => {
|
|
1082
|
-
set(state => ({
|
|
1083
|
-
accounts: state.accounts.filter(account => account.walletType !== walletType),
|
|
1084
|
-
balances: state.balances.filter(balance => balance.walletType !== walletType),
|
|
1085
|
-
selectedWallets: state.selectedWallets.filter(wallet => wallet.walletType != walletType)
|
|
1086
|
-
}));
|
|
1087
|
-
},
|
|
1088
|
-
initSelectedWallets: () => set(state => {
|
|
1089
|
-
const requiredChains = getRequiredChains(useBestRouteStore.getState().bestRoute);
|
|
1090
|
-
const connectedWallets = state.accounts;
|
|
1091
|
-
const selectedWallets = [];
|
|
1092
|
-
requiredChains.forEach(chain => {
|
|
1093
|
-
const anyWalletSelected = !!state.selectedWallets.find(wallet => wallet.chain === chain);
|
|
1094
|
-
if (!anyWalletSelected) {
|
|
1095
|
-
const firstWalletWithMatchedChain = connectedWallets.find(wallet => wallet.chain === chain);
|
|
1096
|
-
if (!!firstWalletWithMatchedChain) selectedWallets.push({
|
|
1097
|
-
address: firstWalletWithMatchedChain.address,
|
|
1098
|
-
chain: firstWalletWithMatchedChain.chain,
|
|
1099
|
-
walletType: firstWalletWithMatchedChain.walletType
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
});
|
|
1103
|
-
return {
|
|
1104
|
-
selectedWallets: state.selectedWallets.concat(selectedWallets)
|
|
1105
|
-
};
|
|
1106
|
-
}),
|
|
1107
|
-
setSelectedWallet: wallet => set(state => ({
|
|
1108
|
-
selectedWallets: state.selectedWallets.filter(selectedWallet => selectedWallet.chain !== wallet.chain).concat({
|
|
1109
|
-
chain: wallet.chain,
|
|
1110
|
-
address: wallet.address,
|
|
1111
|
-
walletType: wallet.walletType
|
|
1112
|
-
})
|
|
1113
|
-
})),
|
|
1114
|
-
clearConnectedWallet: () => set(() => ({
|
|
1115
|
-
accounts: [],
|
|
1116
|
-
balances: [],
|
|
1117
|
-
selectedWallets: []
|
|
1118
|
-
}))
|
|
1119
|
-
}))));
|
|
1120
|
-
|
|
1121
1234
|
const Box = /*#__PURE__*/styled('div', {
|
|
1122
1235
|
display: 'flex',
|
|
1123
1236
|
flexDirection: 'column',
|
|
@@ -1535,7 +1648,7 @@ function ChangeSlippageButton() {
|
|
|
1535
1648
|
type: "primary",
|
|
1536
1649
|
variant: "contained",
|
|
1537
1650
|
size: "small",
|
|
1538
|
-
onClick: navigate
|
|
1651
|
+
onClick: () => navigate(navigationRoutes.settings)
|
|
1539
1652
|
}, "Change Slippage");
|
|
1540
1653
|
}
|
|
1541
1654
|
|
|
@@ -1547,7 +1660,7 @@ function HighSlippageWarning(props) {
|
|
|
1547
1660
|
type: "warning"
|
|
1548
1661
|
}, React.createElement(Typography, {
|
|
1549
1662
|
variant: "body2"
|
|
1550
|
-
}, "
|
|
1663
|
+
}, "Caution, your slippage is high (=", selectedSlippage, "). Your trade may be front run.", React.createElement(ChangeSlippageButton, null)));
|
|
1551
1664
|
}
|
|
1552
1665
|
|
|
1553
1666
|
function ConfirmSwapExtraMessages(props) {
|
|
@@ -1581,12 +1694,6 @@ function useNavigateBack() {
|
|
|
1581
1694
|
};
|
|
1582
1695
|
}
|
|
1583
1696
|
|
|
1584
|
-
const useConfirmSwapStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(() => ({
|
|
1585
|
-
loading: false,
|
|
1586
|
-
errors: [],
|
|
1587
|
-
warnings: [],
|
|
1588
|
-
proceedAnyway: false
|
|
1589
|
-
}))));
|
|
1590
1697
|
var ConfirmSwapErrorTypes;
|
|
1591
1698
|
(function (ConfirmSwapErrorTypes) {
|
|
1592
1699
|
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["NO_ROUTE"] = 0] = "NO_ROUTE";
|
|
@@ -1602,161 +1709,6 @@ var ConfirmSwapWarningTypes;
|
|
|
1602
1709
|
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_AND_OUTPUT_AMOUNT_UPDATED"] = 3] = "ROUTE_AND_OUTPUT_AMOUNT_UPDATED";
|
|
1603
1710
|
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["INSUFFICIENT_BALANCE"] = 4] = "INSUFFICIENT_BALANCE";
|
|
1604
1711
|
})(ConfirmSwapWarningTypes || (ConfirmSwapWarningTypes = {}));
|
|
1605
|
-
const confirmSwap = async () => {
|
|
1606
|
-
const {
|
|
1607
|
-
fromToken,
|
|
1608
|
-
toToken,
|
|
1609
|
-
inputAmount,
|
|
1610
|
-
bestRoute: initialRoute,
|
|
1611
|
-
inputUsdValue,
|
|
1612
|
-
setBestRoute
|
|
1613
|
-
} = useBestRouteStore.getState();
|
|
1614
|
-
const {
|
|
1615
|
-
accounts,
|
|
1616
|
-
selectedWallets
|
|
1617
|
-
} = useWalletsStore.getState();
|
|
1618
|
-
const {
|
|
1619
|
-
proceedAnyway
|
|
1620
|
-
} = useConfirmSwapStore.getState();
|
|
1621
|
-
const {
|
|
1622
|
-
disabledLiquiditySources,
|
|
1623
|
-
slippage,
|
|
1624
|
-
customSlippage
|
|
1625
|
-
} = useSettingsStore.getState();
|
|
1626
|
-
const {
|
|
1627
|
-
meta
|
|
1628
|
-
} = useMetaStore.getState();
|
|
1629
|
-
const userSlippage = customSlippage || slippage;
|
|
1630
|
-
if (!fromToken || !toToken || !inputAmount || !initialRoute) return undefined;
|
|
1631
|
-
if (proceedAnyway) {
|
|
1632
|
-
const swapSettings = {
|
|
1633
|
-
slippage: userSlippage.toString(),
|
|
1634
|
-
disabledSwappersGroups: disabledLiquiditySources
|
|
1635
|
-
};
|
|
1636
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), initialRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
1637
|
-
console.log('new swap:', newSwap);
|
|
1638
|
-
// queueManager?.create('swap', { swapDetails: newSwap });
|
|
1639
|
-
useConfirmSwapStore.setState({
|
|
1640
|
-
errors: [],
|
|
1641
|
-
warnings: [],
|
|
1642
|
-
proceedAnyway: false
|
|
1643
|
-
});
|
|
1644
|
-
return newSwap;
|
|
1645
|
-
}
|
|
1646
|
-
let abortController = new AbortController();
|
|
1647
|
-
useConfirmSwapStore.setState({
|
|
1648
|
-
loading: true
|
|
1649
|
-
});
|
|
1650
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
1651
|
-
const unsubscribeFromBestRouteStore = useBestRouteStore.subscribe(state => state.bestRoute, () => {
|
|
1652
|
-
abortController.abort();
|
|
1653
|
-
}, {
|
|
1654
|
-
equalityFn: shallow
|
|
1655
|
-
});
|
|
1656
|
-
const unsubscribeFromWalletsStore = useWalletsStore.subscribe(state => state.selectedWallets, () => {
|
|
1657
|
-
abortController?.abort();
|
|
1658
|
-
}, {
|
|
1659
|
-
equalityFn: (prevState, state) => {
|
|
1660
|
-
const selectedWalletsChanged = !state.every(wallet => !!prevState.find(prevWallet => wallet.address === prevWallet.address && wallet.chain === prevWallet.chain));
|
|
1661
|
-
if (selectedWalletsChanged) return false;else return true;
|
|
1662
|
-
}
|
|
1663
|
-
});
|
|
1664
|
-
const newSwap = await httpService.getBestRoute(requestBody, {
|
|
1665
|
-
signal: abortController.signal
|
|
1666
|
-
}).then(confiremedRoute => {
|
|
1667
|
-
useConfirmSwapStore.setState({
|
|
1668
|
-
loading: false
|
|
1669
|
-
});
|
|
1670
|
-
if (!confiremedRoute.result || !new BigNumber(confiremedRoute.requestAmount).isEqualTo(new BigNumber(inputAmount || '-1'))) {
|
|
1671
|
-
useConfirmSwapStore.setState(prevState => ({
|
|
1672
|
-
errors: prevState.errors.concat({
|
|
1673
|
-
type: ConfirmSwapErrorTypes.NO_ROUTE
|
|
1674
|
-
})
|
|
1675
|
-
}));
|
|
1676
|
-
return undefined;
|
|
1677
|
-
}
|
|
1678
|
-
const confirmSwap = {
|
|
1679
|
-
loading: false,
|
|
1680
|
-
errors: [],
|
|
1681
|
-
warnings: [],
|
|
1682
|
-
proceedAnyway
|
|
1683
|
-
};
|
|
1684
|
-
const routeChanged = isRouteChanged(initialRoute, confiremedRoute);
|
|
1685
|
-
if (routeChanged) {
|
|
1686
|
-
setBestRoute(confiremedRoute);
|
|
1687
|
-
const newRouteOutputUsdValue = new BigNumber(confiremedRoute.result?.outputAmount || '0').multipliedBy(toToken.usdPrice || 0);
|
|
1688
|
-
const outputRatio = getOutputRatio(inputUsdValue, newRouteOutputUsdValue);
|
|
1689
|
-
const highValueLoss = outputRatioHasWarning(inputUsdValue, outputRatio);
|
|
1690
|
-
if (isNumberOfSwapsChanged(initialRoute, confiremedRoute)) confirmSwap.warnings.push({
|
|
1691
|
-
type: ConfirmSwapWarningTypes.ROUTE_UPDATED
|
|
1692
|
-
});else if (isRouteSwappersUpdated(initialRoute, confiremedRoute)) confirmSwap.warnings.push({
|
|
1693
|
-
type: ConfirmSwapWarningTypes.ROUTE_SWAPPERS_UPDATED
|
|
1694
|
-
});else isRouteInternalCoinsUpdated(initialRoute, confiremedRoute);
|
|
1695
|
-
confirmSwap.warnings.push({
|
|
1696
|
-
type: ConfirmSwapWarningTypes.ROUTE_COINS_UPDATED
|
|
1697
|
-
});
|
|
1698
|
-
if (highValueLoss) confirmSwap.errors.push({
|
|
1699
|
-
type: ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS
|
|
1700
|
-
});else if (isOutputAmountChangedALot(initialRoute, confiremedRoute)) confirmSwap.warnings.push({
|
|
1701
|
-
type: ConfirmSwapWarningTypes.ROUTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
1702
|
-
newOutputAmount: numberToString(getRouteOutputAmount(confiremedRoute)),
|
|
1703
|
-
percentageChange: numberToString(getPercentageChange(getRouteOutputAmount(initialRoute), getRouteOutputAmount(confiremedRoute)), null, 2)
|
|
1704
|
-
});
|
|
1705
|
-
}
|
|
1706
|
-
const balanceWarnings = getBalanceWarnings(confiremedRoute, selectedWallets);
|
|
1707
|
-
const enoughBalance = balanceWarnings.length === 0;
|
|
1708
|
-
if (!enoughBalance) confirmSwap.warnings.push({
|
|
1709
|
-
type: ConfirmSwapWarningTypes.INSUFFICIENT_BALANCE,
|
|
1710
|
-
messages: balanceWarnings
|
|
1711
|
-
});
|
|
1712
|
-
const minRequiredSlippage = getMinRequiredSlippage(initialRoute);
|
|
1713
|
-
if (!hasProperSlippage(userSlippage.toString(), minRequiredSlippage)) confirmSwap.errors.push({
|
|
1714
|
-
type: ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE,
|
|
1715
|
-
minRequiredSlippage
|
|
1716
|
-
});
|
|
1717
|
-
const noErrors = confirmSwap.errors.length === 0;
|
|
1718
|
-
const noWarnings = confirmSwap.warnings.length === 0;
|
|
1719
|
-
if ((noErrors || !noErrors && proceedAnyway) && (noWarnings || !noWarnings && proceedAnyway)) {
|
|
1720
|
-
const swapSettings = {
|
|
1721
|
-
slippage: userSlippage.toString(),
|
|
1722
|
-
disabledSwappersGroups: disabledLiquiditySources
|
|
1723
|
-
};
|
|
1724
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
1725
|
-
console.log('new swap:', newSwap);
|
|
1726
|
-
return newSwap;
|
|
1727
|
-
} else if (!proceedAnyway) {
|
|
1728
|
-
confirmSwap.proceedAnyway = true;
|
|
1729
|
-
useConfirmSwapStore.setState(confirmSwap);
|
|
1730
|
-
}
|
|
1731
|
-
return undefined;
|
|
1732
|
-
}).then(result => {
|
|
1733
|
-
abortController = null;
|
|
1734
|
-
unsubscribeFromBestRouteStore();
|
|
1735
|
-
unsubscribeFromWalletsStore();
|
|
1736
|
-
return result;
|
|
1737
|
-
}).catch(error => {
|
|
1738
|
-
abortController = null;
|
|
1739
|
-
if (error.code === 'ERR_CANCELED') {
|
|
1740
|
-
useConfirmSwapStore.setState({
|
|
1741
|
-
errors: [],
|
|
1742
|
-
warnings: [],
|
|
1743
|
-
loading: false,
|
|
1744
|
-
proceedAnyway: false
|
|
1745
|
-
});
|
|
1746
|
-
unsubscribeFromBestRouteStore();
|
|
1747
|
-
unsubscribeFromWalletsStore();
|
|
1748
|
-
}
|
|
1749
|
-
const status = error.response?.status;
|
|
1750
|
-
useConfirmSwapStore.setState(prevState => ({
|
|
1751
|
-
loading: false,
|
|
1752
|
-
errors: prevState.errors.concat({
|
|
1753
|
-
type: ConfirmSwapErrorTypes.REQUEST_FAILED,
|
|
1754
|
-
status
|
|
1755
|
-
})
|
|
1756
|
-
}));
|
|
1757
|
-
});
|
|
1758
|
-
return newSwap || undefined;
|
|
1759
|
-
};
|
|
1760
1712
|
|
|
1761
1713
|
function MinRequiredSlippage(_ref) {
|
|
1762
1714
|
let {
|
|
@@ -1764,7 +1716,7 @@ function MinRequiredSlippage(_ref) {
|
|
|
1764
1716
|
} = _ref;
|
|
1765
1717
|
return React.createElement(Typography, {
|
|
1766
1718
|
variant: "body2"
|
|
1767
|
-
}, "
|
|
1719
|
+
}, "We recommend you to increase slippage to at least \u00A0", minRequiredSlippage, "\u00A0 for this route.", React.createElement(ChangeSlippageButton, null));
|
|
1768
1720
|
}
|
|
1769
1721
|
|
|
1770
1722
|
function ConfirmSwapErrors(errors) {
|
|
@@ -1792,13 +1744,40 @@ function ConfirmSwapErrors(errors) {
|
|
|
1792
1744
|
});
|
|
1793
1745
|
}
|
|
1794
1746
|
|
|
1747
|
+
const List = /*#__PURE__*/styled('ul', {
|
|
1748
|
+
variants: {
|
|
1749
|
+
showListStyle: {
|
|
1750
|
+
true: {
|
|
1751
|
+
paddingLeft: '$24'
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1756
|
+
const ListItem = /*#__PURE__*/styled('li', {
|
|
1757
|
+
variants: {
|
|
1758
|
+
showListStyle: {
|
|
1759
|
+
true: {
|
|
1760
|
+
listStyleType: 'disc',
|
|
1761
|
+
listStylePosition: 'outside'
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
const Message = /*#__PURE__*/styled(Typography, {
|
|
1767
|
+
display: 'block'
|
|
1768
|
+
});
|
|
1795
1769
|
function BalanceWarnings(_ref) {
|
|
1796
1770
|
let {
|
|
1797
1771
|
messages
|
|
1798
1772
|
} = _ref;
|
|
1799
|
-
|
|
1773
|
+
const showListStyle = messages.length > 1;
|
|
1774
|
+
return React.createElement(List, {
|
|
1775
|
+
showListStyle: showListStyle
|
|
1776
|
+
}, messages.map(warning => React.createElement(ListItem, {
|
|
1777
|
+
showListStyle: showListStyle
|
|
1778
|
+
}, React.createElement(Message, {
|
|
1800
1779
|
variant: "body2"
|
|
1801
|
-
}, warning)));
|
|
1780
|
+
}, warning))));
|
|
1802
1781
|
}
|
|
1803
1782
|
|
|
1804
1783
|
function ConfirmSwapWarnings(warnings) {
|
|
@@ -1831,6 +1810,137 @@ function ConfirmSwapWarnings(warnings) {
|
|
|
1831
1810
|
});
|
|
1832
1811
|
}
|
|
1833
1812
|
|
|
1813
|
+
function useConfirmSwap() {
|
|
1814
|
+
const fromToken = useBestRouteStore.use.fromToken();
|
|
1815
|
+
const toToken = useBestRouteStore.use.toToken();
|
|
1816
|
+
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1817
|
+
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
1818
|
+
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
1819
|
+
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1820
|
+
const accounts = useWalletsStore.use.accounts();
|
|
1821
|
+
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1822
|
+
const meta = useMetaStore.use.meta();
|
|
1823
|
+
const customSlippage = useSettingsStore.use.customSlippage();
|
|
1824
|
+
const slippage = useSettingsStore.use.slippage();
|
|
1825
|
+
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
1826
|
+
const userSlippage = customSlippage || slippage;
|
|
1827
|
+
const proceedAnywayRef = useRef(false);
|
|
1828
|
+
const confiremedRouteRef = useRef(null);
|
|
1829
|
+
let abortControllerRef = useRef(null);
|
|
1830
|
+
const [loading, setLoading] = useState(false);
|
|
1831
|
+
const [errors, setErrors] = useState([]);
|
|
1832
|
+
const [warnings, setWarnings] = useState([]);
|
|
1833
|
+
useEffect(() => {
|
|
1834
|
+
return () => abortControllerRef.current?.abort();
|
|
1835
|
+
}, []);
|
|
1836
|
+
if (!fromToken || !toToken || !inputAmount || !initialRoute) return {
|
|
1837
|
+
loading: false,
|
|
1838
|
+
warnings: [],
|
|
1839
|
+
errors: [],
|
|
1840
|
+
confirmSwap: null
|
|
1841
|
+
};
|
|
1842
|
+
const confirmSwap = async () => {
|
|
1843
|
+
if (proceedAnywayRef.current) {
|
|
1844
|
+
const swapSettings = {
|
|
1845
|
+
slippage: userSlippage.toString(),
|
|
1846
|
+
disabledSwappersGroups: disabledLiquiditySources
|
|
1847
|
+
};
|
|
1848
|
+
if (errors.length > 0) setErrors([]);
|
|
1849
|
+
if (warnings.length > 0) setWarnings([]);
|
|
1850
|
+
proceedAnywayRef.current = false;
|
|
1851
|
+
if (confiremedRouteRef.current) {
|
|
1852
|
+
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
1853
|
+
return newSwap;
|
|
1854
|
+
}
|
|
1855
|
+
return;
|
|
1856
|
+
}
|
|
1857
|
+
abortControllerRef.current = new AbortController();
|
|
1858
|
+
setLoading(true);
|
|
1859
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
1860
|
+
try {
|
|
1861
|
+
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
1862
|
+
signal: abortControllerRef.current?.signal
|
|
1863
|
+
});
|
|
1864
|
+
abortControllerRef.current = null;
|
|
1865
|
+
setLoading(false);
|
|
1866
|
+
if (!confiremedRoute.result || !new BigNumber(confiremedRoute.requestAmount).isEqualTo(new BigNumber(inputAmount || '-1'))) {
|
|
1867
|
+
setErrors(prevState => prevState.concat({
|
|
1868
|
+
type: ConfirmSwapErrorTypes.NO_ROUTE
|
|
1869
|
+
}));
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
const confirmSwapState = {
|
|
1873
|
+
errors: [],
|
|
1874
|
+
warnings: []
|
|
1875
|
+
};
|
|
1876
|
+
const routeChanged = isRouteChanged(initialRoute, confiremedRoute);
|
|
1877
|
+
if (routeChanged) {
|
|
1878
|
+
setBestRoute(confiremedRoute);
|
|
1879
|
+
const newRouteOutputUsdValue = new BigNumber(confiremedRoute.result?.outputAmount || '0').multipliedBy(toToken.usdPrice || 0);
|
|
1880
|
+
const outputRatio = getOutputRatio(inputUsdValue, newRouteOutputUsdValue);
|
|
1881
|
+
const highValueLoss = outputRatioHasWarning(inputUsdValue, outputRatio);
|
|
1882
|
+
if (highValueLoss) confirmSwapState.errors.push({
|
|
1883
|
+
type: ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS
|
|
1884
|
+
});else if (isOutputAmountChangedALot(initialRoute, confiremedRoute)) confirmSwapState.warnings.push({
|
|
1885
|
+
type: ConfirmSwapWarningTypes.ROUTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
1886
|
+
newOutputAmount: numberToString(getRouteOutputAmount(confiremedRoute)),
|
|
1887
|
+
percentageChange: numberToString(getPercentageChange(getRouteOutputAmount(initialRoute), getRouteOutputAmount(confiremedRoute)), null, 2)
|
|
1888
|
+
});else if (isRouteInternalCoinsUpdated(initialRoute, confiremedRoute)) confirmSwapState.warnings.push({
|
|
1889
|
+
type: ConfirmSwapWarningTypes.ROUTE_COINS_UPDATED
|
|
1890
|
+
});else if (isNumberOfSwapsChanged(initialRoute, confiremedRoute)) confirmSwapState.warnings.push({
|
|
1891
|
+
type: ConfirmSwapWarningTypes.ROUTE_UPDATED
|
|
1892
|
+
});else if (isRouteSwappersUpdated(initialRoute, confiremedRoute)) confirmSwapState.warnings.push({
|
|
1893
|
+
type: ConfirmSwapWarningTypes.ROUTE_SWAPPERS_UPDATED
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
const balanceWarnings = getBalanceWarnings(confiremedRoute, selectedWallets);
|
|
1897
|
+
const enoughBalance = balanceWarnings.length === 0;
|
|
1898
|
+
if (!enoughBalance) confirmSwapState.warnings.push({
|
|
1899
|
+
type: ConfirmSwapWarningTypes.INSUFFICIENT_BALANCE,
|
|
1900
|
+
messages: balanceWarnings
|
|
1901
|
+
});
|
|
1902
|
+
const minRequiredSlippage = getMinRequiredSlippage(initialRoute);
|
|
1903
|
+
if (!hasProperSlippage(userSlippage.toString(), minRequiredSlippage)) confirmSwapState.errors.push({
|
|
1904
|
+
type: ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE,
|
|
1905
|
+
minRequiredSlippage
|
|
1906
|
+
});
|
|
1907
|
+
const noErrors = confirmSwapState.errors.length === 0;
|
|
1908
|
+
const noWarnings = confirmSwapState.warnings.length === 0;
|
|
1909
|
+
if ((noErrors || !noErrors && proceedAnywayRef.current) && (noWarnings || !noWarnings && proceedAnywayRef.current)) {
|
|
1910
|
+
const swapSettings = {
|
|
1911
|
+
slippage: userSlippage.toString(),
|
|
1912
|
+
disabledSwappersGroups: disabledLiquiditySources
|
|
1913
|
+
};
|
|
1914
|
+
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
1915
|
+
return newSwap;
|
|
1916
|
+
} else if (!proceedAnywayRef.current) {
|
|
1917
|
+
proceedAnywayRef.current = true;
|
|
1918
|
+
setErrors(confirmSwapState.errors);
|
|
1919
|
+
setWarnings(confirmSwapState.warnings);
|
|
1920
|
+
confiremedRouteRef.current = confiremedRoute;
|
|
1921
|
+
}
|
|
1922
|
+
return;
|
|
1923
|
+
} catch (error) {
|
|
1924
|
+
if (error?.code === 'ERR_CANCELED') {
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
const status = error?.response?.status;
|
|
1928
|
+
setLoading(false);
|
|
1929
|
+
setErrors([{
|
|
1930
|
+
type: ConfirmSwapErrorTypes.REQUEST_FAILED,
|
|
1931
|
+
status
|
|
1932
|
+
}]);
|
|
1933
|
+
return;
|
|
1934
|
+
}
|
|
1935
|
+
};
|
|
1936
|
+
return {
|
|
1937
|
+
loading,
|
|
1938
|
+
warnings,
|
|
1939
|
+
errors,
|
|
1940
|
+
confirmSwap
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1834
1944
|
function ConfirmSwapPage() {
|
|
1835
1945
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
1836
1946
|
const {
|
|
@@ -1841,15 +1951,23 @@ function ConfirmSwapPage() {
|
|
|
1841
1951
|
} = useManager();
|
|
1842
1952
|
const navigate = useNavigate();
|
|
1843
1953
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
1844
|
-
const
|
|
1845
|
-
const
|
|
1846
|
-
|
|
1954
|
+
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
1955
|
+
const {
|
|
1956
|
+
tokens
|
|
1957
|
+
} = useMetaStore.use.meta();
|
|
1847
1958
|
const slippage = useSettingsStore.use.slippage();
|
|
1848
1959
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
1849
1960
|
const selectedSlippage = customSlippage || slippage;
|
|
1961
|
+
const {
|
|
1962
|
+
loading,
|
|
1963
|
+
errors,
|
|
1964
|
+
warnings,
|
|
1965
|
+
confirmSwap
|
|
1966
|
+
} = useConfirmSwap();
|
|
1967
|
+
const showHighSlippageWarning = !errors.find(error => error.type === ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE);
|
|
1850
1968
|
return React.createElement(ConfirmSwap, {
|
|
1851
1969
|
onConfirm: () => {
|
|
1852
|
-
confirmSwap().then(swap => {
|
|
1970
|
+
confirmSwap?.().then(swap => {
|
|
1853
1971
|
if (swap) {
|
|
1854
1972
|
manager?.create('swap', {
|
|
1855
1973
|
swapDetails: swap
|
|
@@ -1862,15 +1980,15 @@ function ConfirmSwapPage() {
|
|
|
1862
1980
|
});
|
|
1863
1981
|
},
|
|
1864
1982
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
1865
|
-
bestRoute: bestRoute,
|
|
1983
|
+
bestRoute: getBestRouteWithCalculatedFees(bestRoute, tokens),
|
|
1866
1984
|
loading: loading,
|
|
1867
1985
|
errors: ConfirmSwapErrors(errors),
|
|
1868
1986
|
warnings: ConfirmSwapWarnings(warnings),
|
|
1869
|
-
extraMessages: React.createElement(ConfirmSwapExtraMessages, {
|
|
1987
|
+
extraMessages: showHighSlippageWarning && React.createElement(ConfirmSwapExtraMessages, {
|
|
1870
1988
|
selectedSlippage: selectedSlippage
|
|
1871
1989
|
}),
|
|
1872
1990
|
confirmButtonTitle: warnings.length > 0 || errors.length > 0 ? 'Proceed anyway!' : 'Confirm swap!',
|
|
1873
|
-
confirmButtonDisabled:
|
|
1991
|
+
confirmButtonDisabled: fetchingBestRoute
|
|
1874
1992
|
});
|
|
1875
1993
|
}
|
|
1876
1994
|
|
|
@@ -1963,8 +2081,6 @@ function SelectChainPage(props) {
|
|
|
1963
2081
|
const toChain = useBestRouteStore.use.toChain();
|
|
1964
2082
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
1965
2083
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
1966
|
-
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1967
|
-
const setToToken = useBestRouteStore.use.setToToken();
|
|
1968
2084
|
const {
|
|
1969
2085
|
navigateBackFrom
|
|
1970
2086
|
} = useNavigateBack();
|
|
@@ -1974,9 +2090,7 @@ function SelectChainPage(props) {
|
|
|
1974
2090
|
selected: type === 'from' ? fromChain : toChain,
|
|
1975
2091
|
loadingStatus: loadingStatus,
|
|
1976
2092
|
onChange: chain => {
|
|
1977
|
-
if (type === 'from') setFromChain(chain);else setToChain(chain);
|
|
1978
|
-
if (type === 'from' && fromChain?.name != chain.name) setFromToken(null);
|
|
1979
|
-
if (type === 'to' && toChain?.name != chain.name) setToToken(null);
|
|
2093
|
+
if (type === 'from') setFromChain(chain, true);else setToChain(chain, true);
|
|
1980
2094
|
navigateBackFrom(navigationRoutes.fromChain);
|
|
1981
2095
|
},
|
|
1982
2096
|
onBack: navigateBackFrom.bind(null, navigationRoutes.fromChain)
|
|
@@ -1991,34 +2105,18 @@ function SelectTokenPage(props) {
|
|
|
1991
2105
|
type,
|
|
1992
2106
|
supportedTokens
|
|
1993
2107
|
} = props;
|
|
1994
|
-
const
|
|
1995
|
-
const
|
|
1996
|
-
const
|
|
2108
|
+
const sourceTokens = useBestRouteStore.use.sourceTokens();
|
|
2109
|
+
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2110
|
+
const supportedSourceTokens = supportedTokens === 'all' ? sourceTokens : sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token)));
|
|
2111
|
+
const supportedDestinationTokens = supportedTokens === 'all' ? destinationTokens : destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token)));
|
|
2112
|
+
console.log(supportedSourceTokens);
|
|
1997
2113
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
1998
2114
|
const toToken = useBestRouteStore.use.toToken();
|
|
1999
2115
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
2000
2116
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
2001
|
-
const balance = useWalletsStore.use.balances();
|
|
2002
|
-
const tokenWithSelectedChain = tokens.filter(token => {
|
|
2003
|
-
if (type === 'from') return token.blockchain === fromChain?.name;
|
|
2004
|
-
return token.blockchain === toChain?.name;
|
|
2005
|
-
});
|
|
2006
|
-
const TokensWithBalance = tokenWithSelectedChain.map(token => {
|
|
2007
|
-
const tokenAmount = numberToString(new BigNumber(getBalanceFromWallet(balance, token.blockchain, token.symbol, token.address)?.amount || ZERO));
|
|
2008
|
-
let tokenUsdValue = '';
|
|
2009
|
-
if (token.usdPrice) tokenUsdValue = numberToString(new BigNumber(getBalanceFromWallet(balance, token.blockchain, token.symbol, token.address)?.amount || ZERO).multipliedBy(token.usdPrice));
|
|
2010
|
-
return {
|
|
2011
|
-
...token,
|
|
2012
|
-
balance: {
|
|
2013
|
-
amount: tokenAmount !== '0' ? tokenAmount : '',
|
|
2014
|
-
usdValue: tokenUsdValue !== '0' ? tokenUsdValue : ''
|
|
2015
|
-
}
|
|
2016
|
-
};
|
|
2017
|
-
});
|
|
2018
|
-
const sortedTokenList = sortedTokens(TokensWithBalance, type, balance);
|
|
2019
2117
|
return React.createElement(TokenSelector, {
|
|
2020
2118
|
type: type === 'from' ? 'Source' : 'Destination',
|
|
2021
|
-
list:
|
|
2119
|
+
list: type == 'from' ? supportedSourceTokens : supportedDestinationTokens,
|
|
2022
2120
|
selected: type === 'from' ? fromToken : toToken,
|
|
2023
2121
|
onChange: token => {
|
|
2024
2122
|
if (type === 'from') setFromToken(token);else setToToken(token);
|
|
@@ -2067,7 +2165,7 @@ function SettingsPage(_ref) {
|
|
|
2067
2165
|
slippages: SLIPPAGES,
|
|
2068
2166
|
selectedSlippage: slippage,
|
|
2069
2167
|
onSlippageChange: slippage => setSlippage(slippage),
|
|
2070
|
-
onLiquiditySourcesClick: navigate
|
|
2168
|
+
onLiquiditySourcesClick: () => navigate(navigationRoutes.liquiditySources),
|
|
2071
2169
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2072
2170
|
liquiditySources: supportedUniqueSwappersGroups,
|
|
2073
2171
|
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
@@ -2108,6 +2206,8 @@ function WalletsPage(_ref) {
|
|
|
2108
2206
|
connect
|
|
2109
2207
|
} = useWallets();
|
|
2110
2208
|
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets);
|
|
2209
|
+
let sortedWallets = detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2210
|
+
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
2111
2211
|
const [walletErrorMessage, setWalletErrorMessage] = useState('');
|
|
2112
2212
|
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2113
2213
|
const {
|
|
@@ -2126,7 +2226,7 @@ function WalletsPage(_ref) {
|
|
|
2126
2226
|
await connect(type);
|
|
2127
2227
|
}
|
|
2128
2228
|
} catch (e) {
|
|
2129
|
-
setWalletErrorMessage('Error: ' + e
|
|
2229
|
+
setWalletErrorMessage('Error: ' + e?.message);
|
|
2130
2230
|
}
|
|
2131
2231
|
};
|
|
2132
2232
|
useEffect(() => {
|
|
@@ -2134,15 +2234,15 @@ function WalletsPage(_ref) {
|
|
|
2134
2234
|
return () => toggleConnectWalletsButton();
|
|
2135
2235
|
}, []);
|
|
2136
2236
|
return React.createElement(SecondaryPage, {
|
|
2137
|
-
title: t('Select Wallet'),
|
|
2237
|
+
title: t('Select Wallet') || '',
|
|
2138
2238
|
textField: false,
|
|
2139
2239
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2140
2240
|
}, React.createElement(React.Fragment, null, walletErrorMessage && React.createElement(AlertContainer, null, React.createElement(Alert, {
|
|
2141
2241
|
type: "error"
|
|
2142
2242
|
}, React.createElement(Typography, {
|
|
2143
2243
|
variant: "body2"
|
|
2144
|
-
}, walletErrorMessage))), React.createElement(ListContainer, null,
|
|
2145
|
-
key: index
|
|
2244
|
+
}, walletErrorMessage))), React.createElement(ListContainer, null, sortedWallets.map((wallet, index) => React.createElement(Wallet, Object.assign({}, wallet, {
|
|
2245
|
+
key: `${index}-${wallet.type}`,
|
|
2146
2246
|
onClick: onSelectWallet
|
|
2147
2247
|
}))))));
|
|
2148
2248
|
}
|
|
@@ -2240,59 +2340,50 @@ function SwapDetailsPage() {
|
|
|
2240
2340
|
});
|
|
2241
2341
|
}
|
|
2242
2342
|
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
fromTokens = 'all',
|
|
2248
|
-
toTokens = 'all',
|
|
2249
|
-
liquiditySources = 'all',
|
|
2250
|
-
wallets = 'all',
|
|
2251
|
-
title,
|
|
2252
|
-
multiWallets = true,
|
|
2253
|
-
titleSize,
|
|
2254
|
-
titleWeight
|
|
2255
|
-
} = _ref;
|
|
2343
|
+
function AppRoutes(props) {
|
|
2344
|
+
const {
|
|
2345
|
+
configs
|
|
2346
|
+
} = props;
|
|
2256
2347
|
return useRoutes([{
|
|
2257
2348
|
path: navigationRoutes.home,
|
|
2258
2349
|
element: React.createElement(Home, {
|
|
2259
|
-
title: title,
|
|
2260
|
-
titleSize: titleSize,
|
|
2261
|
-
titleWeight: titleWeight
|
|
2350
|
+
title: configs?.title,
|
|
2351
|
+
titleSize: configs?.titleSize,
|
|
2352
|
+
titleWeight: configs?.titleWeight
|
|
2262
2353
|
})
|
|
2263
2354
|
}, {
|
|
2264
2355
|
path: navigationRoutes.fromChain,
|
|
2265
2356
|
element: React.createElement(SelectChainPage, {
|
|
2266
2357
|
type: "from",
|
|
2267
|
-
supportedChains: fromChains
|
|
2358
|
+
supportedChains: configs?.fromChains || 'all'
|
|
2268
2359
|
})
|
|
2269
2360
|
}, {
|
|
2270
2361
|
path: navigationRoutes.toChain,
|
|
2271
2362
|
element: React.createElement(SelectChainPage, {
|
|
2272
2363
|
type: "to",
|
|
2273
|
-
supportedChains: toChains
|
|
2364
|
+
supportedChains: configs?.toChains || 'all'
|
|
2274
2365
|
})
|
|
2275
2366
|
}, {
|
|
2276
2367
|
path: navigationRoutes.fromToken + '/*',
|
|
2277
2368
|
element: React.createElement(SelectTokenPage, {
|
|
2278
2369
|
type: "from",
|
|
2279
|
-
supportedTokens: fromTokens
|
|
2370
|
+
supportedTokens: configs?.fromTokens || 'all'
|
|
2280
2371
|
})
|
|
2281
2372
|
}, {
|
|
2282
2373
|
path: navigationRoutes.toToken,
|
|
2283
2374
|
element: React.createElement(SelectTokenPage, {
|
|
2284
2375
|
type: "to",
|
|
2285
|
-
supportedTokens: toTokens
|
|
2376
|
+
supportedTokens: configs?.toTokens || 'all'
|
|
2286
2377
|
})
|
|
2287
2378
|
}, {
|
|
2288
2379
|
path: navigationRoutes.settings,
|
|
2289
2380
|
element: React.createElement(SettingsPage, {
|
|
2290
|
-
supportedSwappers: liquiditySources
|
|
2381
|
+
supportedSwappers: configs?.liquiditySources || 'all'
|
|
2291
2382
|
})
|
|
2292
2383
|
}, {
|
|
2293
2384
|
path: navigationRoutes.liquiditySources,
|
|
2294
2385
|
element: React.createElement(LiquiditySourcePage, {
|
|
2295
|
-
supportedSwappers: liquiditySources
|
|
2386
|
+
supportedSwappers: configs?.liquiditySources || 'all'
|
|
2296
2387
|
})
|
|
2297
2388
|
}, {
|
|
2298
2389
|
path: navigationRoutes.swaps,
|
|
@@ -2303,8 +2394,8 @@ const AppRoutes = _ref => {
|
|
|
2303
2394
|
}, {
|
|
2304
2395
|
path: navigationRoutes.wallets,
|
|
2305
2396
|
element: React.createElement(WalletsPage, {
|
|
2306
|
-
supportedWallets: wallets,
|
|
2307
|
-
multiWallets: multiWallets
|
|
2397
|
+
supportedWallets: configs?.wallets || 'all',
|
|
2398
|
+
multiWallets: typeof configs?.multiWallets === 'undefined' ? true : configs.multiWallets
|
|
2308
2399
|
})
|
|
2309
2400
|
}, {
|
|
2310
2401
|
path: navigationRoutes.confirmSwap,
|
|
@@ -2313,7 +2404,7 @@ const AppRoutes = _ref => {
|
|
|
2313
2404
|
path: navigationRoutes.confirmWallets,
|
|
2314
2405
|
element: React.createElement(ConfirmWalletsPage, null)
|
|
2315
2406
|
}]);
|
|
2316
|
-
}
|
|
2407
|
+
}
|
|
2317
2408
|
|
|
2318
2409
|
const Header$1 = /*#__PURE__*/styled('div', {
|
|
2319
2410
|
display: 'flex',
|
|
@@ -2341,13 +2432,6 @@ function Layout(_ref) {
|
|
|
2341
2432
|
getWalletInfo
|
|
2342
2433
|
} = useWallets();
|
|
2343
2434
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2344
|
-
const {
|
|
2345
|
-
fromChain,
|
|
2346
|
-
toChain,
|
|
2347
|
-
toToken,
|
|
2348
|
-
fromToken,
|
|
2349
|
-
fromAmount
|
|
2350
|
-
} = configs;
|
|
2351
2435
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
2352
2436
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
2353
2437
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
@@ -2359,16 +2443,16 @@ function Layout(_ref) {
|
|
|
2359
2443
|
t
|
|
2360
2444
|
} = useTranslation();
|
|
2361
2445
|
useEffect(() => {
|
|
2362
|
-
setToChain(toChain);
|
|
2363
|
-
setToToken(toToken);
|
|
2364
|
-
}, [toChain, toToken]);
|
|
2446
|
+
setToChain(configs?.toChain || null);
|
|
2447
|
+
setToToken(configs?.toToken || null);
|
|
2448
|
+
}, [configs?.toChain, configs?.toToken]);
|
|
2365
2449
|
useEffect(() => {
|
|
2366
|
-
setInputAmount(fromAmount
|
|
2367
|
-
}, [fromAmount]);
|
|
2450
|
+
setInputAmount(configs?.fromAmount?.toString() || '');
|
|
2451
|
+
}, [configs?.fromAmount]);
|
|
2368
2452
|
useEffect(() => {
|
|
2369
|
-
setFromToken(fromToken);
|
|
2370
|
-
setFromChain(fromChain);
|
|
2371
|
-
}, [fromToken, fromChain]);
|
|
2453
|
+
setFromToken(configs?.fromToken || null);
|
|
2454
|
+
setFromChain(configs?.fromChain || null);
|
|
2455
|
+
}, [configs?.fromToken, configs?.fromChain]);
|
|
2372
2456
|
return React.createElement(React.Fragment, null, React.createElement(Header$1, null, React.createElement(Button, {
|
|
2373
2457
|
size: "small",
|
|
2374
2458
|
suffix: React.createElement(AddWalletIcon, {
|
|
@@ -2384,7 +2468,9 @@ function Layout(_ref) {
|
|
|
2384
2468
|
src: walletImage
|
|
2385
2469
|
})) : React.createElement(React.Fragment, null), React.createElement(Typography, {
|
|
2386
2470
|
variant: "body2"
|
|
2387
|
-
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React.createElement(AppRoutes,
|
|
2471
|
+
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React.createElement(AppRoutes, {
|
|
2472
|
+
configs: configs
|
|
2473
|
+
}));
|
|
2388
2474
|
}
|
|
2389
2475
|
|
|
2390
2476
|
const globalStyles = /*#__PURE__*/globalCss({
|
|
@@ -2659,7 +2745,10 @@ function QueueManager(props) {
|
|
|
2659
2745
|
console.log('[notifier]', message);
|
|
2660
2746
|
}
|
|
2661
2747
|
};
|
|
2662
|
-
return React.createElement(Provider
|
|
2748
|
+
return React.createElement(Provider
|
|
2749
|
+
//@ts-ignore
|
|
2750
|
+
, {
|
|
2751
|
+
//@ts-ignore
|
|
2663
2752
|
queuesDefs: [swapQueueDef],
|
|
2664
2753
|
context: context,
|
|
2665
2754
|
onPersistedDataLoaded: _manager => {},
|