@rango-dev/widget-embedded 0.17.1-next.9 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/QueueManager.d.ts +1 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +0 -1
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/Widget.d.ts +1 -1
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +2 -0
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +6 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
- package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
- package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
- package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/index.d.ts +2 -0
- package/dist/components/NoRoutes/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
- package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/RouteErrors/index.d.ts +2 -0
- package/dist/components/RouteErrors/index.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +4 -4
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/searchParams.d.ts +1 -2
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/warnings.d.ts +2 -2
- package/dist/constants/warnings.d.ts.map +1 -1
- package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
- package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
- package/dist/hooks/useSwapInput.d.ts +2 -4
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +6 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +2 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +6 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +8 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +23 -5
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/{quote.d.ts → bestRoute.d.ts} +27 -39
- package/dist/store/bestRoute.d.ts.map +1 -0
- package/dist/store/meta.d.ts +23 -0
- package/dist/store/meta.d.ts.map +1 -0
- package/dist/store/settings.d.ts +2 -3
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +2 -3
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +0 -3
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +4 -5
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/routing.d.ts +65 -0
- 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/{quote.d.ts → routing.d.ts} +12 -16
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +2 -3
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +22 -25
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/QueueManager.tsx +14 -14
- package/src/Wallets.tsx +15 -35
- package/src/Widget.tsx +24 -11
- package/src/components/AppRouter.tsx +5 -6
- package/src/components/AppRoutes.tsx +39 -6
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +40 -28
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.tsx +5 -6
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
- package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +9 -16
- package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
- package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +12 -10
- package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
- package/src/components/NoRoutes/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +2 -3
- package/src/components/RouteErrors/RouteErrors.tsx +79 -0
- package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
- package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
- package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +3 -3
- package/src/components/RouteErrors/index.ts +1 -0
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +22 -18
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.tsx +6 -5
- package/src/components/UpdateUrl.tsx +26 -36
- package/src/components/WidgetEvents.tsx +2 -4
- package/src/constants/errors.ts +10 -8
- package/src/constants/messages.ts +1 -1
- package/src/constants/searchParams.ts +0 -1
- package/src/constants/warnings.ts +7 -7
- package/src/hooks/useConfirmSwap.ts +303 -0
- package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
- package/src/hooks/useNavigateBack.ts +3 -3
- package/src/hooks/useSwapInput.ts +23 -58
- package/src/hooks/useSyncStoresWithConfig.ts +19 -22
- package/src/hooks/useWalletList.ts +5 -3
- package/src/pages/ConfirmSwapPage.tsx +235 -58
- package/src/pages/HistoryPage.tsx +1 -1
- package/src/pages/Home.tsx +247 -58
- package/src/pages/LanguagePage.tsx +1 -1
- package/src/pages/LiquiditySourcePage.tsx +32 -23
- package/src/pages/SelectBlockchainPage.tsx +7 -6
- package/src/pages/SelectSwapItemsPage.tsx +5 -5
- package/src/pages/SettingsPage.tsx +13 -9
- package/src/pages/SwapDetailsPage.tsx +3 -3
- package/src/pages/ThemePage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +12 -5
- package/src/store/app.ts +6 -18
- package/src/store/{quote.ts → bestRoute.ts} +60 -68
- package/src/store/meta.ts +39 -0
- package/src/store/settings.ts +4 -7
- package/src/store/slices/config.ts +15 -25
- package/src/store/slices/data.ts +29 -64
- package/src/store/wallets.ts +8 -11
- package/src/types/config.ts +5 -5
- package/src/types/index.ts +1 -1
- package/src/types/routing.ts +77 -0
- package/src/utils/numbers.ts +1 -1
- package/src/utils/routing.ts +321 -0
- package/src/utils/settings.ts +7 -8
- package/src/utils/swap.ts +85 -113
- package/src/utils/wallets.ts +17 -29
- package/dist/components/NoResult/NoResult.d.ts +0 -4
- package/dist/components/NoResult/NoResult.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
- package/dist/components/NoResult/index.d.ts +0 -2
- package/dist/components/NoResult/index.d.ts.map +0 -1
- package/dist/components/Quote/Quote.d.ts +0 -4
- package/dist/components/Quote/Quote.d.ts.map +0 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -1429
- package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -22
- package/dist/components/Quote/Quote.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSkeleton.d.ts +0 -4
- package/dist/components/Quote/QuoteSkeleton.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts +0 -319
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSkeleton.types.d.ts +0 -6
- package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.d.ts +0 -11
- package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -158
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
- package/dist/components/Quote/index.d.ts +0 -4
- package/dist/components/Quote/index.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -22
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -472
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -17
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/index.d.ts +0 -2
- package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
- package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -16
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
- package/dist/hooks/useFetchQuote.d.ts.map +0 -1
- package/dist/hooks/useForceAutoConnect.d.ts +0 -2
- package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
- package/dist/store/AppStore.d.ts +0 -11
- package/dist/store/AppStore.d.ts.map +0 -1
- package/dist/store/quote.d.ts.map +0 -1
- package/dist/types/quote.d.ts +0 -82
- package/dist/types/quote.d.ts.map +0 -1
- package/dist/utils/quote.d.ts.map +0 -1
- package/src/components/NoResult/index.ts +0 -1
- package/src/components/Quote/Quote.styles.ts +0 -212
- package/src/components/Quote/Quote.tsx +0 -345
- package/src/components/Quote/Quote.types.ts +0 -16
- package/src/components/Quote/QuoteSkeleton.styles.ts +0 -110
- package/src/components/Quote/QuoteSkeleton.tsx +0 -108
- package/src/components/Quote/QuoteSkeleton.types.ts +0 -5
- package/src/components/Quote/QuoteSummary.styles.ts +0 -15
- package/src/components/Quote/QuoteSummary.tsx +0 -46
- package/src/components/Quote/index.ts +0 -3
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -67
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -24
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
- package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -15
- package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -97
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -17
- package/src/containers/QuoteInfo/index.ts +0 -1
- package/src/hooks/useConfirmSwap/index.ts +0 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -168
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -136
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
- package/src/hooks/useForceAutoConnect.ts +0 -27
- package/src/store/AppStore.tsx +0 -35
- package/src/types/quote.ts +0 -107
- package/src/utils/quote.ts +0 -338
- /package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +0 -0
package/src/store/wallets.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Wallet } from '../types';
|
|
2
2
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
-
import type { Token } from 'rango-sdk';
|
|
4
3
|
|
|
5
4
|
import { create } from 'zustand';
|
|
6
5
|
import { subscribeWithSelector } from 'zustand/middleware';
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
resetConnectedWalletState,
|
|
13
12
|
} from '../utils/wallets';
|
|
14
13
|
|
|
14
|
+
import { useMetaStore } from './meta';
|
|
15
15
|
import createSelectors from './selectors';
|
|
16
16
|
|
|
17
17
|
export type TokenBalance = {
|
|
@@ -38,15 +38,11 @@ interface WalletsStore {
|
|
|
38
38
|
connectedWallets: ConnectedWallet[];
|
|
39
39
|
customDestination: string;
|
|
40
40
|
loading: boolean;
|
|
41
|
-
connectWallet: (accounts: Wallet[]
|
|
41
|
+
connectWallet: (accounts: Wallet[]) => void;
|
|
42
42
|
disconnectWallet: (walletType: WalletType) => void;
|
|
43
43
|
selectWallets: (wallets: { walletType: string; chain: string }[]) => void;
|
|
44
44
|
clearConnectedWallet: () => void;
|
|
45
|
-
getWalletsDetails: (
|
|
46
|
-
accounts: Wallet[],
|
|
47
|
-
tokens: Token[],
|
|
48
|
-
shouldRetry?: boolean
|
|
49
|
-
) => void;
|
|
45
|
+
getWalletsDetails: (accounts: Wallet[], shouldRetry?: boolean) => void;
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
export const useWalletsStore = createSelectors(
|
|
@@ -55,7 +51,7 @@ export const useWalletsStore = createSelectors(
|
|
|
55
51
|
connectedWallets: [],
|
|
56
52
|
customDestination: '',
|
|
57
53
|
loading: false,
|
|
58
|
-
connectWallet: (accounts
|
|
54
|
+
connectWallet: (accounts) => {
|
|
59
55
|
const getWalletsDetails = get().getWalletsDetails;
|
|
60
56
|
set((state) => ({
|
|
61
57
|
loading: true,
|
|
@@ -81,7 +77,7 @@ export const useWalletsStore = createSelectors(
|
|
|
81
77
|
})
|
|
82
78
|
),
|
|
83
79
|
}));
|
|
84
|
-
getWalletsDetails(accounts
|
|
80
|
+
getWalletsDetails(accounts);
|
|
85
81
|
},
|
|
86
82
|
disconnectWallet: (walletType) => {
|
|
87
83
|
set((state) => {
|
|
@@ -139,8 +135,9 @@ export const useWalletsStore = createSelectors(
|
|
|
139
135
|
connectedWallets: [],
|
|
140
136
|
selectedWallets: [],
|
|
141
137
|
})),
|
|
142
|
-
getWalletsDetails: async (accounts,
|
|
138
|
+
getWalletsDetails: async (accounts, shouldRetry = true) => {
|
|
143
139
|
const getWalletsDetails = get().getWalletsDetails;
|
|
140
|
+
const { tokens } = useMetaStore.getState().meta;
|
|
144
141
|
set((state) => ({
|
|
145
142
|
loading: true,
|
|
146
143
|
connectedWallets: state.connectedWallets.map((wallet) => {
|
|
@@ -176,7 +173,7 @@ export const useWalletsStore = createSelectors(
|
|
|
176
173
|
matchedAccount &&
|
|
177
174
|
shouldRetry
|
|
178
175
|
) {
|
|
179
|
-
getWalletsDetails([matchedAccount],
|
|
176
|
+
getWalletsDetails([matchedAccount], false);
|
|
180
177
|
}
|
|
181
178
|
return matchedAccount && retrievedBalanceAccount
|
|
182
179
|
? {
|
package/src/types/config.ts
CHANGED
|
@@ -61,7 +61,7 @@ export type WidgetTheme = {
|
|
|
61
61
|
* @property {{ [key: string]: string }} wallets - If you want to change the default affiliate wallet
|
|
62
62
|
* addresses, you can provide new values here. (Map of route blockchains to affiliate address)
|
|
63
63
|
*/
|
|
64
|
-
export type
|
|
64
|
+
export type WidgeAffiliate = {
|
|
65
65
|
ref?: string;
|
|
66
66
|
percent?: number;
|
|
67
67
|
wallets?: { [key: string]: string };
|
|
@@ -91,7 +91,7 @@ export type BlockchainAndTokenConfig = {
|
|
|
91
91
|
* and theme.
|
|
92
92
|
*
|
|
93
93
|
* @property {string} apiKey - The API key used to communicate with Rango API
|
|
94
|
-
* @property {
|
|
94
|
+
* @property {WidgeAffiliate} affiliate - If you want to charge users fee per transaction, you should
|
|
95
95
|
* pass `WidgetAffiliate` including affiliateRef, affiliatePercent, and affiliateWallets.
|
|
96
96
|
* @property {number} amount - The default input amount.
|
|
97
97
|
* @property {BlockchainAndTokenConfig} from - The `from` property is an optional property of type
|
|
@@ -121,13 +121,13 @@ export type BlockchainAndTokenConfig = {
|
|
|
121
121
|
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
122
122
|
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
123
123
|
* you could use to pin tokens of your choice to the top of the token list.
|
|
124
|
-
* @property {boolean}
|
|
124
|
+
* @property {boolean} includeNewLiquiditySources - The `includeNewLiquiditySources` property is a boolean value that when you
|
|
125
125
|
* set it to true, whenever a new liquidity source is added, it will be added to your list as well.
|
|
126
126
|
*/
|
|
127
127
|
export type WidgetConfig = {
|
|
128
128
|
apiKey: string;
|
|
129
129
|
walletConnectProjectId?: string;
|
|
130
|
-
affiliate?:
|
|
130
|
+
affiliate?: WidgeAffiliate;
|
|
131
131
|
amount?: number;
|
|
132
132
|
from?: BlockchainAndTokenConfig;
|
|
133
133
|
to?: BlockchainAndTokenConfig;
|
|
@@ -139,5 +139,5 @@ export type WidgetConfig = {
|
|
|
139
139
|
theme?: WidgetTheme;
|
|
140
140
|
externalWallets?: boolean;
|
|
141
141
|
pinnedTokens?: Asset[];
|
|
142
|
-
|
|
142
|
+
includeNewLiquiditySources?: boolean;
|
|
143
143
|
};
|
package/src/types/index.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-enum-initializers */
|
|
2
|
+
import type { RouteState } from '../store/bestRoute';
|
|
3
|
+
import type { SettingsState } from '../store/settings';
|
|
4
|
+
|
|
5
|
+
interface BestRouteStoreParams {
|
|
6
|
+
fromBlockchain?: RouteState['fromBlockchain'];
|
|
7
|
+
toBlockchain?: RouteState['toBlockchain'];
|
|
8
|
+
fromToken?: RouteState['fromToken'];
|
|
9
|
+
toToken?: RouteState['toToken'];
|
|
10
|
+
inputAmount?: RouteState['inputAmount'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface SettingsStoreParams {
|
|
14
|
+
slippage?: SettingsState['slippage'];
|
|
15
|
+
customSlippage?: SettingsState['customSlippage'];
|
|
16
|
+
disabledLiquiditySources?: SettingsState['disabledLiquiditySources'];
|
|
17
|
+
infiniteApprove?: SettingsState['infiniteApprove'];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type BestRouteEqualityParams =
|
|
21
|
+
| {
|
|
22
|
+
store: 'bestRoute';
|
|
23
|
+
prevState: BestRouteStoreParams;
|
|
24
|
+
currentState: BestRouteStoreParams;
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
store: 'settings';
|
|
28
|
+
prevState: SettingsStoreParams;
|
|
29
|
+
currentState: SettingsStoreParams;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export enum ConfirmSwapErrorTypes {
|
|
33
|
+
NO_ROUTE,
|
|
34
|
+
ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS,
|
|
35
|
+
REQUEST_FAILED,
|
|
36
|
+
REQUEST_CANCELED,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type ConfirmSwapError =
|
|
40
|
+
| {
|
|
41
|
+
type: ConfirmSwapErrorTypes.NO_ROUTE;
|
|
42
|
+
diagnosisMessage?: string;
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
type: Exclude<ConfirmSwapErrorTypes, ConfirmSwapErrorTypes.NO_ROUTE>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export enum RouteWarningType {
|
|
49
|
+
ROUTE_UPDATED,
|
|
50
|
+
ROUTE_SWAPPERS_UPDATED,
|
|
51
|
+
ROUTE_COINS_UPDATED,
|
|
52
|
+
ROUTE_AND_OUTPUT_AMOUNT_UPDATED,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type RouteWarning =
|
|
56
|
+
| {
|
|
57
|
+
type: RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED;
|
|
58
|
+
newOutputAmount: string;
|
|
59
|
+
percentageChange: string;
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
type: Exclude<
|
|
63
|
+
RouteWarningType,
|
|
64
|
+
RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED
|
|
65
|
+
>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export enum SlippageWarningType {
|
|
69
|
+
INSUFFICIENT_SLIPPAGE,
|
|
70
|
+
HIGH_SLIPPAGE,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type ConfirmSwapWarnings = {
|
|
74
|
+
route: RouteWarning | null;
|
|
75
|
+
balance: { messages: string[] } | null;
|
|
76
|
+
slippage: { type: SlippageWarningType; slippage: string | null } | null;
|
|
77
|
+
};
|
package/src/utils/numbers.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const secondsToString = (s: number): string => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export const numberToString = (
|
|
19
|
-
number: BigNumber | string |
|
|
19
|
+
number: BigNumber | string | null | undefined,
|
|
20
20
|
minDecimals: number | null = null,
|
|
21
21
|
maxDecimals: number | null = null
|
|
22
22
|
): string => {
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
+
import type { BestRouteEqualityParams, Wallet } from '../types';
|
|
3
|
+
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
4
|
+
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
5
|
+
import type {
|
|
6
|
+
SimulationAssetAndAmount,
|
|
7
|
+
SimulationValidationStatus,
|
|
8
|
+
} from '@rango-dev/ui/dist/widget/ui/src/types/swaps';
|
|
9
|
+
import type {
|
|
10
|
+
Asset,
|
|
11
|
+
BestRouteResponse,
|
|
12
|
+
BlockchainMeta,
|
|
13
|
+
Token,
|
|
14
|
+
} from 'rango-sdk';
|
|
15
|
+
|
|
16
|
+
import { getLastSuccessfulStep } from '@rango-dev/queue-manager-rango-preset';
|
|
17
|
+
import BigNumber from 'bignumber.js';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
GAS_FEE_MAX_DECIMALS,
|
|
21
|
+
GAS_FEE_MIN_DECIMALS,
|
|
22
|
+
HIGHT_PRICE_IMPACT,
|
|
23
|
+
LOW_PRICE_IMPACT,
|
|
24
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
25
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
26
|
+
} from '../constants/routing';
|
|
27
|
+
|
|
28
|
+
import { areEqual } from './common';
|
|
29
|
+
import { findBlockchain, findToken } from './meta';
|
|
30
|
+
import { numberToString } from './numbers';
|
|
31
|
+
|
|
32
|
+
export function searchParamsToToken(
|
|
33
|
+
tokens: Token[],
|
|
34
|
+
searchParams: string | null,
|
|
35
|
+
chain: BlockchainMeta | null
|
|
36
|
+
): Token | null {
|
|
37
|
+
if (!chain) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return (
|
|
41
|
+
tokens.find((token) => {
|
|
42
|
+
const symbolAndAddress = searchParams?.split('--');
|
|
43
|
+
if (symbolAndAddress?.length === 1) {
|
|
44
|
+
return (
|
|
45
|
+
token.symbol === symbolAndAddress[0] &&
|
|
46
|
+
token.address === null &&
|
|
47
|
+
token.blockchain === chain.name
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return (
|
|
51
|
+
token.symbol === symbolAndAddress?.[0] &&
|
|
52
|
+
token.address === symbolAndAddress?.[1] &&
|
|
53
|
+
token.blockchain === chain.name
|
|
54
|
+
);
|
|
55
|
+
}) || null
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getBestRouteToTokenUsdPrice(
|
|
60
|
+
bestRoute: BestRouteResponse | null
|
|
61
|
+
): number | null | undefined {
|
|
62
|
+
return bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to
|
|
63
|
+
.usdPrice;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function isNumberOfSwapsChanged(
|
|
67
|
+
route1: BestRouteResponse,
|
|
68
|
+
route2: BestRouteResponse
|
|
69
|
+
) {
|
|
70
|
+
const route1Swaps = route1.result?.swaps || [];
|
|
71
|
+
const route2Swaps = route2.result?.swaps || [];
|
|
72
|
+
return route1Swaps.length !== route2Swaps.length;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function isRouteSwappersUpdated(
|
|
76
|
+
route1: BestRouteResponse,
|
|
77
|
+
route2: BestRouteResponse
|
|
78
|
+
) {
|
|
79
|
+
const route1Swappers =
|
|
80
|
+
route1.result?.swaps.map((swap) => swap.swapperId) || [];
|
|
81
|
+
const route2Swappers =
|
|
82
|
+
route2.result?.swaps.map((swap) => swap.swapperId) || [];
|
|
83
|
+
return !areEqual(route1Swappers, route2Swappers);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function isRouteInternalCoinsUpdated(
|
|
87
|
+
route1: BestRouteResponse,
|
|
88
|
+
route2: BestRouteResponse
|
|
89
|
+
) {
|
|
90
|
+
const route1InternalCoins =
|
|
91
|
+
route1.result?.swaps.map((swap) => swap.to.symbol) || [];
|
|
92
|
+
const route2InternalCoins =
|
|
93
|
+
route2.result?.swaps.map((swap) => swap.to.symbol) || [];
|
|
94
|
+
return !areEqual(route1InternalCoins, route2InternalCoins);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function isRouteChanged(
|
|
98
|
+
route1: BestRouteResponse,
|
|
99
|
+
route2: BestRouteResponse
|
|
100
|
+
): boolean {
|
|
101
|
+
return (
|
|
102
|
+
isNumberOfSwapsChanged(route1, route2) ||
|
|
103
|
+
isRouteSwappersUpdated(route1, route2) ||
|
|
104
|
+
isRouteInternalCoinsUpdated(route1, route2)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function outToRatioHasWarning(
|
|
109
|
+
fromUsdValue: BigNumber | null,
|
|
110
|
+
outToInRatio: BigNumber | 0
|
|
111
|
+
) {
|
|
112
|
+
return (
|
|
113
|
+
(parseInt(outToInRatio?.toFixed(2) || '0') <= -10 &&
|
|
114
|
+
(fromUsdValue === null || fromUsdValue.gte(new BigNumber(200)))) ||
|
|
115
|
+
(parseInt(outToInRatio?.toFixed(2) || '0') <= -5 &&
|
|
116
|
+
(fromUsdValue === null || fromUsdValue.gte(new BigNumber(1000))))
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function getRequiredBalanceOfWallet(
|
|
121
|
+
selectedWallet: Wallet,
|
|
122
|
+
fee: SimulationValidationStatus[] | null
|
|
123
|
+
): SimulationAssetAndAmount[] | null {
|
|
124
|
+
if (fee === null) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const relatedFeeStatus = fee
|
|
128
|
+
?.find((item) => item.blockchain === selectedWallet.chain)
|
|
129
|
+
?.wallets.find(
|
|
130
|
+
(wallet) =>
|
|
131
|
+
wallet.address?.toLowerCase() === selectedWallet.address.toLowerCase()
|
|
132
|
+
);
|
|
133
|
+
if (!relatedFeeStatus) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return relatedFeeStatus.requiredAssets;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function isRouteParametersChanged(params: BestRouteEqualityParams) {
|
|
140
|
+
if (params.store === 'bestRoute') {
|
|
141
|
+
const { prevState, currentState } = params;
|
|
142
|
+
return (
|
|
143
|
+
!!currentState.fromToken &&
|
|
144
|
+
!!currentState.toToken &&
|
|
145
|
+
(prevState.fromBlockchain?.name !== currentState.fromBlockchain?.name ||
|
|
146
|
+
prevState.toBlockchain?.name !== currentState.toBlockchain?.name ||
|
|
147
|
+
prevState.fromToken?.symbol !== currentState.fromToken?.symbol ||
|
|
148
|
+
prevState.toToken?.symbol !== currentState.toToken?.symbol ||
|
|
149
|
+
prevState.fromToken?.blockchain !== prevState.fromToken?.blockchain ||
|
|
150
|
+
prevState.toToken?.blockchain !== currentState.toToken?.blockchain ||
|
|
151
|
+
prevState.fromToken?.address !== currentState.fromToken?.address ||
|
|
152
|
+
prevState.toToken?.address !== currentState.toToken?.address ||
|
|
153
|
+
prevState.inputAmount !== currentState.inputAmount)
|
|
154
|
+
);
|
|
155
|
+
} else if (params.store === 'settings') {
|
|
156
|
+
const { prevState, currentState } = params;
|
|
157
|
+
return (
|
|
158
|
+
prevState.slippage !== currentState.slippage ||
|
|
159
|
+
prevState.customSlippage !== currentState.customSlippage ||
|
|
160
|
+
prevState.disabledLiquiditySources?.length !==
|
|
161
|
+
currentState.disabledLiquiditySources?.length ||
|
|
162
|
+
prevState.infiniteApprove ||
|
|
163
|
+
currentState.infiniteApprove
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function getFormattedBestRoute(
|
|
170
|
+
bestRoute: BestRouteResponse | null
|
|
171
|
+
): BestRouteResponse | null {
|
|
172
|
+
if (!bestRoute) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const formattedSwaps = (bestRoute.result?.swaps || []).map((swap) => ({
|
|
177
|
+
...swap,
|
|
178
|
+
fromAmount: numberToString(
|
|
179
|
+
swap.fromAmount,
|
|
180
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
181
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
182
|
+
),
|
|
183
|
+
toAmount: numberToString(
|
|
184
|
+
swap.toAmount,
|
|
185
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
186
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
187
|
+
),
|
|
188
|
+
}));
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
...bestRoute,
|
|
192
|
+
...(bestRoute.result && {
|
|
193
|
+
result: { ...bestRoute.result, swaps: formattedSwaps },
|
|
194
|
+
}),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function getFormattedPendingSwap(pendingSwap: PendingSwap): PendingSwap {
|
|
199
|
+
const formattedSteps = pendingSwap.steps.map((step) => ({
|
|
200
|
+
...step,
|
|
201
|
+
feeInUsd: numberToString(
|
|
202
|
+
step.feeInUsd,
|
|
203
|
+
GAS_FEE_MIN_DECIMALS,
|
|
204
|
+
GAS_FEE_MAX_DECIMALS
|
|
205
|
+
),
|
|
206
|
+
outputAmount: numberToString(
|
|
207
|
+
step.outputAmount,
|
|
208
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
209
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
210
|
+
),
|
|
211
|
+
expectedOutputAmountHumanReadable: numberToString(
|
|
212
|
+
step.expectedOutputAmountHumanReadable,
|
|
213
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
214
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
215
|
+
),
|
|
216
|
+
}));
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
...pendingSwap,
|
|
220
|
+
inputAmount: numberToString(
|
|
221
|
+
pendingSwap.inputAmount,
|
|
222
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
223
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
224
|
+
),
|
|
225
|
+
steps: formattedSteps,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//todo: refactor bestRoute store and add loadingStatus
|
|
230
|
+
export const getBestRouteStatus = (loading: boolean, error: boolean) => {
|
|
231
|
+
if (loading) {
|
|
232
|
+
return 'loading';
|
|
233
|
+
}
|
|
234
|
+
if (error) {
|
|
235
|
+
return 'failed';
|
|
236
|
+
}
|
|
237
|
+
return 'success';
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export function getPriceImpactLevel(
|
|
241
|
+
priceImpact: number
|
|
242
|
+
): PriceImpactWarningLevel {
|
|
243
|
+
let warningLevel: PriceImpactWarningLevel = undefined;
|
|
244
|
+
if (priceImpact <= LOW_PRICE_IMPACT && priceImpact > HIGHT_PRICE_IMPACT) {
|
|
245
|
+
warningLevel = 'low';
|
|
246
|
+
} else if (priceImpact <= HIGHT_PRICE_IMPACT) {
|
|
247
|
+
warningLevel = 'high';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return warningLevel;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function findCommonTokens<T extends Asset[], R extends Asset[]>(
|
|
254
|
+
listA: T,
|
|
255
|
+
listB: R
|
|
256
|
+
) {
|
|
257
|
+
const tokenToString = (token: Asset): string =>
|
|
258
|
+
`${token.symbol}-${token.blockchain}-${token.address ?? ''}`;
|
|
259
|
+
|
|
260
|
+
const set = new Set();
|
|
261
|
+
|
|
262
|
+
listA.forEach((token) => set.add(tokenToString(token)));
|
|
263
|
+
|
|
264
|
+
return listB.filter((token) => set.has(tokenToString(token))) as R;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function createRetryRoute(
|
|
268
|
+
pendingSwap: PendingSwap,
|
|
269
|
+
blockchains: BlockchainMeta[],
|
|
270
|
+
tokens: Token[]
|
|
271
|
+
): {
|
|
272
|
+
fromBlockchain: BlockchainMeta | null;
|
|
273
|
+
fromToken: Token | null;
|
|
274
|
+
toBlockchain: BlockchainMeta | null;
|
|
275
|
+
toToken: Token | null;
|
|
276
|
+
inputAmount: string;
|
|
277
|
+
} {
|
|
278
|
+
const firstStep = pendingSwap.steps[0];
|
|
279
|
+
const lastStep = pendingSwap.steps[pendingSwap.steps.length - 1];
|
|
280
|
+
const lastSuccessfulStep = getLastSuccessfulStep(pendingSwap.steps);
|
|
281
|
+
|
|
282
|
+
const toToken = {
|
|
283
|
+
blockchain: lastStep.toBlockchain,
|
|
284
|
+
symbol: lastStep.toSymbol,
|
|
285
|
+
address: lastStep.toSymbolAddress,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const fromBlockchainMeta = findBlockchain(
|
|
289
|
+
lastSuccessfulStep
|
|
290
|
+
? lastSuccessfulStep.toBlockchain
|
|
291
|
+
: firstStep.fromBlockchain,
|
|
292
|
+
blockchains
|
|
293
|
+
);
|
|
294
|
+
const toBlockchainMeta = findBlockchain(lastStep.toBlockchain, blockchains);
|
|
295
|
+
const fromTokenMeta = findToken(
|
|
296
|
+
lastSuccessfulStep
|
|
297
|
+
? {
|
|
298
|
+
blockchain: fromBlockchainMeta?.name ?? '',
|
|
299
|
+
symbol: lastSuccessfulStep.toSymbol,
|
|
300
|
+
address: lastSuccessfulStep.toSymbolAddress,
|
|
301
|
+
}
|
|
302
|
+
: {
|
|
303
|
+
blockchain: fromBlockchainMeta?.name ?? '',
|
|
304
|
+
symbol: firstStep.fromSymbol,
|
|
305
|
+
address: firstStep.fromSymbolAddress,
|
|
306
|
+
},
|
|
307
|
+
tokens
|
|
308
|
+
);
|
|
309
|
+
const toTokenMeta = findToken(toToken, tokens);
|
|
310
|
+
const inputAmount = lastSuccessfulStep
|
|
311
|
+
? lastSuccessfulStep.outputAmount ?? ''
|
|
312
|
+
: pendingSwap.inputAmount;
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
fromBlockchain: fromBlockchainMeta,
|
|
316
|
+
fromToken: fromTokenMeta,
|
|
317
|
+
toBlockchain: toBlockchainMeta,
|
|
318
|
+
toToken: toTokenMeta,
|
|
319
|
+
inputAmount,
|
|
320
|
+
};
|
|
321
|
+
}
|
package/src/utils/settings.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { useMetaStore } from '../store/meta';
|
|
3
2
|
import { useSettingsStore } from '../store/settings';
|
|
4
3
|
|
|
5
4
|
import { removeDuplicateFrom } from './common';
|
|
@@ -15,11 +14,11 @@ export type UniqueSwappersGroupType = {
|
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export function getUniqueSwappersGroups(
|
|
18
|
-
|
|
17
|
+
supportedSwappers?: string[]
|
|
19
18
|
): UniqueSwappersGroupType[] {
|
|
19
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
20
20
|
const disabledLiquiditySources =
|
|
21
21
|
useSettingsStore.use.disabledLiquiditySources();
|
|
22
|
-
const supportedSwappers = swappers.map((swapper) => swapper.swapperGroup);
|
|
23
22
|
|
|
24
23
|
const uniqueSupportedSwappersGroups: Array<UniqueSwappersGroupType> = [];
|
|
25
24
|
|
|
@@ -58,14 +57,14 @@ export function getUniqueSwappersGroups(
|
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
export function sortLiquiditySourcesByGroupTitle(
|
|
61
|
-
a:
|
|
62
|
-
b:
|
|
60
|
+
a: UniqueSwappersGroupType,
|
|
61
|
+
b: UniqueSwappersGroupType
|
|
63
62
|
) {
|
|
64
|
-
if (a.
|
|
63
|
+
if (a.groupTitle < b.groupTitle) {
|
|
65
64
|
return -1;
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
if (a.
|
|
67
|
+
if (a.groupTitle > b.groupTitle) {
|
|
69
68
|
return 1;
|
|
70
69
|
}
|
|
71
70
|
|