@rango-dev/widget-embedded 0.1.10 → 0.1.11-next.10
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/App.d.ts +3 -3
- package/dist/App.d.ts.map +1 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +1 -7
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +2 -2
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/Layout.d.ts +3 -3
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/PercentageChange.d.ts +9 -0
- package/dist/components/PercentageChange.d.ts.map +1 -0
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts +2 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +2 -5
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/lib.d.ts +2 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts +1 -7
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts +1 -2
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectChainPage.d.ts +1 -2
- package/dist/pages/SelectChainPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts +2 -2
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -2
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +2 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +1 -0
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/settings.d.ts +2 -0
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/types/config.d.ts +27 -29
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/routing.d.ts +14 -1
- package/dist/types/routing.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +7 -0
- package/dist/utils/configs.d.ts.map +1 -0
- package/dist/utils/routing.d.ts +2 -2
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -6
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +232 -223
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +232 -223
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +232 -223
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +6 -4
- package/readme.md +1 -1
- package/src/App.tsx +36 -14
- package/src/QueueManager.tsx +9 -3
- package/src/components/AppRouter.tsx +7 -16
- package/src/components/AppRoutes.tsx +13 -32
- package/src/components/HeaderButtons.tsx +1 -1
- package/src/components/Layout.tsx +37 -27
- package/src/components/PercentageChange.tsx +33 -0
- package/src/components/TokenInfo.tsx +24 -12
- package/src/components/TokenPreview.tsx +19 -15
- package/src/hooks/useConfirmSwap.ts +6 -5
- package/src/hooks/useTheme.ts +21 -9
- package/src/lib.tsx +30 -36
- package/src/pages/ConfirmSwapPage.tsx +14 -7
- package/src/pages/Home.tsx +10 -22
- package/src/pages/LiquiditySourcesPage.tsx +3 -6
- package/src/pages/SelectChainPage.tsx +6 -6
- package/src/pages/SelectTokenPage.tsx +16 -18
- package/src/pages/SettingsPage.tsx +8 -18
- package/src/pages/SwapDetailsPage.tsx +2 -4
- package/src/pages/WalletsPage.tsx +2 -2
- package/src/services/httpService.ts +12 -3
- package/src/store/bestRoute.ts +39 -9
- package/src/store/meta.ts +6 -4
- package/src/store/settings.ts +7 -0
- package/src/store/wallets.ts +1 -1
- package/src/types/config.ts +28 -29
- package/src/types/routing.ts +17 -1
- package/src/utils/configs.ts +24 -0
- package/src/utils/routing.ts +29 -23
- package/src/utils/swap.ts +5 -97
|
@@ -445,7 +445,7 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
445
445
|
};else if (inputIsZero) return {
|
|
446
446
|
title: 'Enter an amount',
|
|
447
447
|
disabled: true
|
|
448
|
-
};else if (!bestRoute) return {
|
|
448
|
+
};else if (!bestRoute || !bestRoute.result) return {
|
|
449
449
|
title: 'Swap',
|
|
450
450
|
disabled: true
|
|
451
451
|
};else if (hasLimitError) return {
|
|
@@ -470,80 +470,6 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
470
470
|
function canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue) {
|
|
471
471
|
return !((inputUsdValue.lte(ZERO) || outputUsdValue.lte(ZERO)) && !!bestRoute?.result && !!inputAmount && inputAmount !== '0' && parseFloat(inputAmount || '0') !== 0 && !!bestRoute.result);
|
|
472
472
|
}
|
|
473
|
-
function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validateBalanceOrFee, meta) {
|
|
474
|
-
const simulationResult = bestRoute.result;
|
|
475
|
-
if (!simulationResult) throw Error('Simulation result should not be null');
|
|
476
|
-
return {
|
|
477
|
-
creationTime: new Date().getTime().toString(),
|
|
478
|
-
finishTime: null,
|
|
479
|
-
requestId: bestRoute.requestId || '',
|
|
480
|
-
inputAmount: inputAmount,
|
|
481
|
-
//@ts-ignore
|
|
482
|
-
wallets,
|
|
483
|
-
status: 'running',
|
|
484
|
-
isPaused: false,
|
|
485
|
-
extraMessage: null,
|
|
486
|
-
extraMessageSeverity: null,
|
|
487
|
-
extraMessageDetail: null,
|
|
488
|
-
extraMessageErrorCode: null,
|
|
489
|
-
networkStatusExtraMessage: null,
|
|
490
|
-
networkStatusExtraMessageDetail: null,
|
|
491
|
-
lastNotificationTime: null,
|
|
492
|
-
//@ts-ignore
|
|
493
|
-
settings: settings,
|
|
494
|
-
simulationResult: simulationResult,
|
|
495
|
-
validateBalanceOrFee,
|
|
496
|
-
//@ts-ignore
|
|
497
|
-
steps: bestRoute.result?.swaps?.map((swap, index) => {
|
|
498
|
-
const swapper = meta.swappers.find(swapper => swapper.id === swap.swapperId);
|
|
499
|
-
const swapperType = swapper?.types[0];
|
|
500
|
-
const fromBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.from.blockchain);
|
|
501
|
-
const toBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.to.blockchain);
|
|
502
|
-
return {
|
|
503
|
-
id: index + 1,
|
|
504
|
-
fromBlockchain: swap.from.blockchain,
|
|
505
|
-
fromSymbol: swap.from.symbol,
|
|
506
|
-
fromSymbolAddress: swap.from.address,
|
|
507
|
-
fromDecimals: swap.from.decimals,
|
|
508
|
-
fromAmountPrecision: swap.fromAmountPrecision,
|
|
509
|
-
fromAmountMinValue: swap.fromAmountMinValue,
|
|
510
|
-
fromAmountMaxValue: swap.fromAmountMaxValue,
|
|
511
|
-
toBlockchain: swap.to.blockchain,
|
|
512
|
-
fromLogo: swap.from.logo,
|
|
513
|
-
toSymbol: swap.to.symbol,
|
|
514
|
-
toSymbolAddress: swap.to.address,
|
|
515
|
-
toDecimals: swap.to.decimals,
|
|
516
|
-
toLogo: swap.to.logo,
|
|
517
|
-
startTransactionTime: new Date().getTime(),
|
|
518
|
-
swapperId: swap.swapperId,
|
|
519
|
-
feeInUsd: numberToString(getUsdFeeOfStep(swap, meta.tokens), null, 2),
|
|
520
|
-
expectedOutputAmountHumanReadable: swap.toAmount,
|
|
521
|
-
outputAmount: '',
|
|
522
|
-
status: 'created',
|
|
523
|
-
networkStatus: null,
|
|
524
|
-
executedTransactionId: null,
|
|
525
|
-
externalTransactionId: null,
|
|
526
|
-
explorerUrl: null,
|
|
527
|
-
trackingCode: null,
|
|
528
|
-
cosmosTransaction: null,
|
|
529
|
-
solanaTransaction: null,
|
|
530
|
-
starknetTransaction: null,
|
|
531
|
-
starknetApprovalTransaction: null,
|
|
532
|
-
tronTransaction: null,
|
|
533
|
-
tronApprovalTransaction: null,
|
|
534
|
-
evmTransaction: null,
|
|
535
|
-
evmApprovalTransaction: null,
|
|
536
|
-
transferTransaction: null,
|
|
537
|
-
diagnosisUrl: null,
|
|
538
|
-
internalSteps: null,
|
|
539
|
-
fromBlockchainLogo: fromBlockchain?.logo || '',
|
|
540
|
-
toBlockchainLogo: toBlockchain?.logo || '',
|
|
541
|
-
swapperLogo: swapper?.logo || '',
|
|
542
|
-
swapperType: swapperType || ''
|
|
543
|
-
};
|
|
544
|
-
}) || []
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
473
|
function requiredWallets(route) {
|
|
548
474
|
const wallets = [];
|
|
549
475
|
route?.result?.swaps.forEach(swap => {
|
|
@@ -585,7 +511,7 @@ function hasProperSlippage(userSlippage, minRequiredSlippage) {
|
|
|
585
511
|
if (!minRequiredSlippage) return true;
|
|
586
512
|
return parseFloat(userSlippage) >= parseFloat(minRequiredSlippage);
|
|
587
513
|
}
|
|
588
|
-
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites) {
|
|
514
|
+
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites, affiliateRef) {
|
|
589
515
|
const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
|
|
590
516
|
const connectedWallets = [];
|
|
591
517
|
wallets.forEach(wallet => {
|
|
@@ -598,6 +524,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
598
524
|
const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
|
|
599
525
|
const requestBody = {
|
|
600
526
|
amount: inputAmount.toString(),
|
|
527
|
+
affiliateRef,
|
|
601
528
|
checkPrerequisites,
|
|
602
529
|
from: {
|
|
603
530
|
address: fromToken.address,
|
|
@@ -753,8 +680,21 @@ function getRequiredBalanceOfWallet(selectedWallet, fee) {
|
|
|
753
680
|
if (!relatedFeeStatus) return null;
|
|
754
681
|
return relatedFeeStatus.requiredAssets;
|
|
755
682
|
}
|
|
756
|
-
function isRouteParametersChanged(
|
|
757
|
-
|
|
683
|
+
function isRouteParametersChanged(params) {
|
|
684
|
+
if (params.store === 'bestRoute') {
|
|
685
|
+
const {
|
|
686
|
+
prevState,
|
|
687
|
+
currentState
|
|
688
|
+
} = params;
|
|
689
|
+
return !!currentState.fromToken && !!currentState.toToken && (prevState.fromChain?.name !== currentState.fromChain?.name || prevState.toChain?.name !== currentState.toChain?.name || prevState.fromToken?.symbol !== currentState.fromToken?.symbol || prevState.toToken?.symbol !== currentState.toToken?.symbol || prevState.fromToken?.blockchain !== prevState.fromToken?.blockchain || prevState.toToken?.blockchain !== currentState.toToken?.blockchain || prevState.fromToken?.address !== currentState.fromToken?.address || prevState.toToken?.address !== currentState.toToken?.address || prevState.inputAmount !== currentState.inputAmount);
|
|
690
|
+
} else if (params.store === 'settings') {
|
|
691
|
+
const {
|
|
692
|
+
prevState,
|
|
693
|
+
currentState
|
|
694
|
+
} = params;
|
|
695
|
+
return prevState.slippage !== currentState.slippage || prevState.customSlippage !== currentState.customSlippage || prevState.disabledLiquiditySources?.length !== currentState.disabledLiquiditySources?.length || prevState.infiniteApprove || currentState.infiniteApprove;
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
758
698
|
}
|
|
759
699
|
//todo: refactor bestRoute store and add loadingStatus
|
|
760
700
|
const getBestRouteStatus = (loading, error) => {
|
|
@@ -771,7 +711,20 @@ const createSelectors = _store => {
|
|
|
771
711
|
return store;
|
|
772
712
|
};
|
|
773
713
|
|
|
774
|
-
const
|
|
714
|
+
const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
|
|
715
|
+
let configs = {
|
|
716
|
+
API_KEY: RANGO_PUBLIC_API_KEY
|
|
717
|
+
};
|
|
718
|
+
function getConfig(name) {
|
|
719
|
+
return configs[name];
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
let rango = undefined;
|
|
723
|
+
const httpService = () => {
|
|
724
|
+
if (rango) return rango;
|
|
725
|
+
rango = new rangoSdk.RangoClient(getConfig('API_KEY'));
|
|
726
|
+
return rango;
|
|
727
|
+
};
|
|
775
728
|
|
|
776
729
|
const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
|
|
777
730
|
const DEFAULT_SLIPPAGE = 1;
|
|
@@ -789,7 +742,7 @@ const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.create()
|
|
|
789
742
|
loadingStatus: 'loading',
|
|
790
743
|
fetchMeta: async () => {
|
|
791
744
|
try {
|
|
792
|
-
const response = await httpService.getAllMetadata();
|
|
745
|
+
const response = await httpService().getAllMetadata();
|
|
793
746
|
const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
|
|
794
747
|
const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
|
|
795
748
|
response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
|
|
@@ -809,6 +762,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
809
762
|
slippage: DEFAULT_SLIPPAGE,
|
|
810
763
|
customSlippage: null,
|
|
811
764
|
infiniteApprove: false,
|
|
765
|
+
affiliateRef: null,
|
|
812
766
|
disabledLiquiditySources: [],
|
|
813
767
|
theme: 'auto',
|
|
814
768
|
setSlippage: slippage => set(() => ({
|
|
@@ -817,6 +771,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
817
771
|
setCustomSlippage: customSlippage => set(() => ({
|
|
818
772
|
customSlippage: customSlippage
|
|
819
773
|
})),
|
|
774
|
+
setAffiliateRef: affiliateRef => set(() => ({
|
|
775
|
+
affiliateRef
|
|
776
|
+
})),
|
|
820
777
|
toggleAllLiquiditySources: () => set(state => {
|
|
821
778
|
const {
|
|
822
779
|
swappers
|
|
@@ -867,7 +824,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
867
824
|
}));
|
|
868
825
|
accounts.forEach(async account => {
|
|
869
826
|
try {
|
|
870
|
-
const response = await httpService.getWalletsDetails([{
|
|
827
|
+
const response = await httpService().getWalletsDetails([{
|
|
871
828
|
address: account.address,
|
|
872
829
|
blockchain: account.chain
|
|
873
830
|
}]);
|
|
@@ -1020,7 +977,6 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1020
977
|
toToken: token
|
|
1021
978
|
})),
|
|
1022
979
|
setInputAmount: amount => {
|
|
1023
|
-
console.log(amount, typeof amount);
|
|
1024
980
|
set(state => ({
|
|
1025
981
|
inputAmount: amount,
|
|
1026
982
|
...(!amount && {
|
|
@@ -1073,7 +1029,17 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1073
1029
|
sourceTokens: sortedSourceTokens,
|
|
1074
1030
|
destinationTokens: sortedDestinationTokens
|
|
1075
1031
|
});
|
|
1076
|
-
}
|
|
1032
|
+
},
|
|
1033
|
+
switchFromAndTo: () => set(state => ({
|
|
1034
|
+
fromChain: state.toChain,
|
|
1035
|
+
fromToken: state.toToken,
|
|
1036
|
+
toChain: state.fromChain,
|
|
1037
|
+
toToken: state.fromToken,
|
|
1038
|
+
sourceTokens: state.destinationTokens,
|
|
1039
|
+
destinationTokens: state.sourceTokens,
|
|
1040
|
+
inputAmount: state.outputAmount?.toString() || '',
|
|
1041
|
+
inputUsdValue: getUsdValue(state.toToken, state.outputAmount?.toString() || '')
|
|
1042
|
+
}))
|
|
1077
1043
|
}))));
|
|
1078
1044
|
const bestRoute = (bestRouteStore, settingsStore) => {
|
|
1079
1045
|
let abortController = null;
|
|
@@ -1086,20 +1052,21 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1086
1052
|
const {
|
|
1087
1053
|
slippage,
|
|
1088
1054
|
customSlippage,
|
|
1089
|
-
disabledLiquiditySources
|
|
1055
|
+
disabledLiquiditySources,
|
|
1056
|
+
affiliateRef
|
|
1090
1057
|
} = settingsStore.getState();
|
|
1091
1058
|
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1092
1059
|
abortController?.abort();
|
|
1093
1060
|
abortController = new AbortController();
|
|
1094
1061
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1095
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
1062
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false, affiliateRef);
|
|
1096
1063
|
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1097
1064
|
loading: true,
|
|
1098
1065
|
bestRoute: null,
|
|
1099
1066
|
outputAmount: null,
|
|
1100
1067
|
outputUsdValue: new BigNumber__default(0)
|
|
1101
1068
|
});
|
|
1102
|
-
httpService.getBestRoute(requestBody, {
|
|
1069
|
+
httpService().getBestRoute(requestBody, {
|
|
1103
1070
|
signal: abortController.signal
|
|
1104
1071
|
}).then(res => {
|
|
1105
1072
|
const {
|
|
@@ -1126,7 +1093,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1126
1093
|
inputAmount,
|
|
1127
1094
|
inputUsdValue
|
|
1128
1095
|
} = useBestRouteStore.getState();
|
|
1129
|
-
if (!inputAmount || inputAmount === '0') return;
|
|
1096
|
+
if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0)) return;
|
|
1130
1097
|
if (tokensAreEqual(fromToken, toToken)) return bestRouteStore.setState({
|
|
1131
1098
|
loading: false,
|
|
1132
1099
|
bestRoute: null,
|
|
@@ -1148,17 +1115,26 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1148
1115
|
toToken: state.toToken,
|
|
1149
1116
|
inputAmount: state.inputAmount
|
|
1150
1117
|
}), bestRouteParamsListener, {
|
|
1151
|
-
equalityFn: (prevState,
|
|
1152
|
-
if (isRouteParametersChanged(
|
|
1118
|
+
equalityFn: (prevState, currentState) => {
|
|
1119
|
+
if (isRouteParametersChanged({
|
|
1120
|
+
store: 'bestRoute',
|
|
1121
|
+
prevState,
|
|
1122
|
+
currentState
|
|
1123
|
+
})) return false;else return true;
|
|
1153
1124
|
}
|
|
1154
1125
|
});
|
|
1155
1126
|
useSettingsStore.subscribe(state => ({
|
|
1156
1127
|
slippage: state.slippage,
|
|
1157
1128
|
customSlippage: state.customSlippage,
|
|
1158
|
-
disabledLiquiditySources: state.disabledLiquiditySources
|
|
1129
|
+
disabledLiquiditySources: state.disabledLiquiditySources,
|
|
1130
|
+
infiniteApprove: state.infiniteApprove
|
|
1159
1131
|
}), bestRouteParamsListener, {
|
|
1160
|
-
equalityFn: (prevState,
|
|
1161
|
-
if (isRouteParametersChanged(
|
|
1132
|
+
equalityFn: (prevState, currentState) => {
|
|
1133
|
+
if (isRouteParametersChanged({
|
|
1134
|
+
store: 'settings',
|
|
1135
|
+
prevState,
|
|
1136
|
+
currentState
|
|
1137
|
+
})) return false;else return true;
|
|
1162
1138
|
}
|
|
1163
1139
|
});
|
|
1164
1140
|
return {
|
|
@@ -1323,6 +1299,20 @@ function UpdateUrl() {
|
|
|
1323
1299
|
return null;
|
|
1324
1300
|
}
|
|
1325
1301
|
|
|
1302
|
+
function PercentageChange(props) {
|
|
1303
|
+
const {
|
|
1304
|
+
inputUsdValue,
|
|
1305
|
+
outputUsdValue
|
|
1306
|
+
} = props;
|
|
1307
|
+
if (!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)) return null;
|
|
1308
|
+
const percentageChange = getPercentageChange(inputUsdValue.toNumber(), outputUsdValue.toNumber());
|
|
1309
|
+
const showPercentageChange = percentageChange?.lt(0);
|
|
1310
|
+
return React__default.createElement(React__default.Fragment, null, showPercentageChange && React__default.createElement(ui.Typography, {
|
|
1311
|
+
variant: "caption",
|
|
1312
|
+
color: "$error500"
|
|
1313
|
+
}, `(${numberToString(percentageChange, 0, 2)}%)`));
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1326
1316
|
const Box = /*#__PURE__*/ui.styled('div', {
|
|
1327
1317
|
display: 'flex',
|
|
1328
1318
|
flexDirection: 'column',
|
|
@@ -1366,12 +1356,15 @@ const Container = /*#__PURE__*/ui.styled('div', {
|
|
|
1366
1356
|
'.amount': {
|
|
1367
1357
|
width: '30%'
|
|
1368
1358
|
}
|
|
1359
|
+
},
|
|
1360
|
+
'.output-usd': {
|
|
1361
|
+
display: 'flex',
|
|
1362
|
+
div: {
|
|
1363
|
+
display: 'flex',
|
|
1364
|
+
paddingLeft: '$8'
|
|
1365
|
+
}
|
|
1369
1366
|
}
|
|
1370
1367
|
});
|
|
1371
|
-
const StyledImage = /*#__PURE__*/ui.styled('img', {
|
|
1372
|
-
width: '$24',
|
|
1373
|
-
maxHeight: '$24'
|
|
1374
|
-
});
|
|
1375
1368
|
const Options = /*#__PURE__*/ui.styled('div', {
|
|
1376
1369
|
display: 'flex',
|
|
1377
1370
|
justifyContent: 'flex-end',
|
|
@@ -1450,10 +1443,15 @@ function TokenInfo(props) {
|
|
|
1450
1443
|
type: "primary",
|
|
1451
1444
|
variant: "ghost",
|
|
1452
1445
|
size: "compact"
|
|
1453
|
-
}, t('Max')))) : React__default.createElement(
|
|
1446
|
+
}, t('Max')))) : React__default.createElement("div", {
|
|
1447
|
+
className: "output-usd"
|
|
1448
|
+
}, React__default.createElement(PercentageChange, {
|
|
1449
|
+
inputUsdValue: inputUsdValue,
|
|
1450
|
+
outputUsdValue: props.outputUsdValue
|
|
1451
|
+
}), React__default.createElement("div", null, React__default.createElement(ui.Typography, {
|
|
1454
1452
|
variant: "caption",
|
|
1455
1453
|
color: "neutrals600"
|
|
1456
|
-
}, `$${numberToString(props.outputUsdValue)}`)), React__default.createElement("div", {
|
|
1454
|
+
}, `$${numberToString(props.outputUsdValue)}`)))), React__default.createElement("div", {
|
|
1457
1455
|
className: "form"
|
|
1458
1456
|
}, React__default.createElement(ui.Button, {
|
|
1459
1457
|
className: "selectors",
|
|
@@ -1463,8 +1461,9 @@ function TokenInfo(props) {
|
|
|
1463
1461
|
variant: "outlined",
|
|
1464
1462
|
disabled: loadingStatus === 'failed',
|
|
1465
1463
|
loading: loadingStatus === 'loading',
|
|
1466
|
-
prefix: loadingStatus === 'success' && chain ? React__default.createElement(
|
|
1467
|
-
src: chain.logo
|
|
1464
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(ui.Image, {
|
|
1465
|
+
src: chain.logo,
|
|
1466
|
+
size: 24
|
|
1468
1467
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1469
1468
|
suffix: ItemSuffix,
|
|
1470
1469
|
align: "start",
|
|
@@ -1479,8 +1478,9 @@ function TokenInfo(props) {
|
|
|
1479
1478
|
variant: "outlined",
|
|
1480
1479
|
disabled: loadingStatus === 'failed' || type === 'From' && !fromChain || type === 'To' && !toChain,
|
|
1481
1480
|
loading: loadingStatus === 'loading',
|
|
1482
|
-
prefix: loadingStatus === 'success' && token ? React__default.createElement(
|
|
1483
|
-
src: token.image
|
|
1481
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(ui.Image, {
|
|
1482
|
+
src: token.image,
|
|
1483
|
+
size: 24
|
|
1484
1484
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1485
1485
|
suffix: ItemSuffix,
|
|
1486
1486
|
size: "large",
|
|
@@ -1625,7 +1625,8 @@ function HeaderButtons(props) {
|
|
|
1625
1625
|
onClick: onClickRefresh,
|
|
1626
1626
|
disabled: !onClickRefresh
|
|
1627
1627
|
}, React__default.createElement(ui.RetryIcon, {
|
|
1628
|
-
size: 24
|
|
1628
|
+
size: 24,
|
|
1629
|
+
disabled: !onClickRefresh
|
|
1629
1630
|
}))), React__default.createElement(ui.Tooltip, {
|
|
1630
1631
|
content: "Transactions History"
|
|
1631
1632
|
}, React__default.createElement(ui.Button, {
|
|
@@ -1665,10 +1666,7 @@ const Alerts = /*#__PURE__*/ui.styled('div', {
|
|
|
1665
1666
|
width: '100%',
|
|
1666
1667
|
paddingTop: '$16'
|
|
1667
1668
|
});
|
|
1668
|
-
function Home(
|
|
1669
|
-
const {
|
|
1670
|
-
title = 'SWAP'
|
|
1671
|
-
} = props;
|
|
1669
|
+
function Home() {
|
|
1672
1670
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1673
1671
|
const navigate = reactRouterDom.useNavigate();
|
|
1674
1672
|
const [count, setCount] = React.useState(0);
|
|
@@ -1676,10 +1674,6 @@ function Home(props) {
|
|
|
1676
1674
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
1677
1675
|
const toChain = useBestRouteStore.use.toChain();
|
|
1678
1676
|
const toToken = useBestRouteStore.use.toToken();
|
|
1679
|
-
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
1680
|
-
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1681
|
-
const setToChain = useBestRouteStore.use.setToChain();
|
|
1682
|
-
const setToToken = useBestRouteStore.use.setToToken();
|
|
1683
1677
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1684
1678
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1685
1679
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
@@ -1692,14 +1686,7 @@ function Home(props) {
|
|
|
1692
1686
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1693
1687
|
const accounts = useWalletsStore.use.accounts();
|
|
1694
1688
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
1695
|
-
const
|
|
1696
|
-
setFromChain(toChain);
|
|
1697
|
-
setFromToken(toToken);
|
|
1698
|
-
setToChain(fromChain);
|
|
1699
|
-
setToToken(fromToken);
|
|
1700
|
-
setInputAmount(outputAmount?.toString() || '');
|
|
1701
|
-
setCount(prev => prev + 1);
|
|
1702
|
-
};
|
|
1689
|
+
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
1703
1690
|
const errorMessage = loadingMetaStatus === 'failed' ? errorMessages.genericServerError : bestRouteError;
|
|
1704
1691
|
const needsToWarnEthOnPath = false;
|
|
1705
1692
|
const showBestRoute = inputAmount && (!!bestRoute || fetchingBestRoute || bestRouteError);
|
|
@@ -1720,7 +1707,7 @@ function Home(props) {
|
|
|
1720
1707
|
return setCurrentPage.bind(null, '');
|
|
1721
1708
|
}, []);
|
|
1722
1709
|
return React__default.createElement(Container$2, null, React__default.createElement(ui.Header, {
|
|
1723
|
-
title:
|
|
1710
|
+
title: "SWAP",
|
|
1724
1711
|
suffix: React__default.createElement(HeaderButtons, {
|
|
1725
1712
|
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1726
1713
|
})
|
|
@@ -1732,7 +1719,10 @@ function Home(props) {
|
|
|
1732
1719
|
inputAmount: inputAmount
|
|
1733
1720
|
}), React__default.createElement(SwitchButtonContainer, null, React__default.createElement(ui.Button, {
|
|
1734
1721
|
variant: "ghost",
|
|
1735
|
-
onClick:
|
|
1722
|
+
onClick: () => {
|
|
1723
|
+
switchFromAndTo();
|
|
1724
|
+
setCount(prev => prev + 1);
|
|
1725
|
+
}
|
|
1736
1726
|
}, React__default.createElement(ui.VerticalSwapIcon, {
|
|
1737
1727
|
size: 32
|
|
1738
1728
|
}), isRouterInContext && React__default.createElement(SwithFromAndTo, {
|
|
@@ -1778,8 +1768,7 @@ function Home(props) {
|
|
|
1778
1768
|
|
|
1779
1769
|
const Route = _ref => {
|
|
1780
1770
|
let {
|
|
1781
|
-
children
|
|
1782
|
-
...props
|
|
1771
|
+
children
|
|
1783
1772
|
} = _ref;
|
|
1784
1773
|
const location = reactRouter.useLocation();
|
|
1785
1774
|
const navigate = reactRouter.useNavigate();
|
|
@@ -1790,7 +1779,7 @@ const Route = _ref => {
|
|
|
1790
1779
|
});
|
|
1791
1780
|
ref.current = false;
|
|
1792
1781
|
}, []);
|
|
1793
|
-
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home,
|
|
1782
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home, null);
|
|
1794
1783
|
return React__default.createElement(React__default.Fragment, null, " ", children);
|
|
1795
1784
|
};
|
|
1796
1785
|
function AppRouter(_ref2) {
|
|
@@ -1862,7 +1851,10 @@ const Container$3 = /*#__PURE__*/ui.styled('div', {
|
|
|
1862
1851
|
display: 'flex',
|
|
1863
1852
|
justifyContent: 'space-between',
|
|
1864
1853
|
alignItems: 'center',
|
|
1865
|
-
minHeight: '32px'
|
|
1854
|
+
minHeight: '32px',
|
|
1855
|
+
'.usd-value': {
|
|
1856
|
+
paddingLeft: '$8'
|
|
1857
|
+
}
|
|
1866
1858
|
},
|
|
1867
1859
|
'.form': {
|
|
1868
1860
|
display: 'flex',
|
|
@@ -1881,10 +1873,6 @@ const Container$3 = /*#__PURE__*/ui.styled('div', {
|
|
|
1881
1873
|
}
|
|
1882
1874
|
}
|
|
1883
1875
|
});
|
|
1884
|
-
const StyledImage$1 = /*#__PURE__*/ui.styled('img', {
|
|
1885
|
-
width: '$24',
|
|
1886
|
-
maxHeight: '$24'
|
|
1887
|
-
});
|
|
1888
1876
|
const ImagePlaceholder$1 = /*#__PURE__*/ui.styled('span', {
|
|
1889
1877
|
width: '24px',
|
|
1890
1878
|
height: '24px',
|
|
@@ -1907,7 +1895,8 @@ function TokenPreview(props) {
|
|
|
1907
1895
|
const {
|
|
1908
1896
|
chain,
|
|
1909
1897
|
token,
|
|
1910
|
-
loadingStatus
|
|
1898
|
+
loadingStatus,
|
|
1899
|
+
percentageChange
|
|
1911
1900
|
} = props;
|
|
1912
1901
|
const {
|
|
1913
1902
|
t
|
|
@@ -1929,17 +1918,19 @@ function TokenPreview(props) {
|
|
|
1929
1918
|
}, React__default.createElement(ui.Typography, {
|
|
1930
1919
|
variant: "body2",
|
|
1931
1920
|
color: "neutrals800"
|
|
1932
|
-
}, props.label), props.usdValue && React__default.createElement(ui.Typography, {
|
|
1921
|
+
}, props.label), React__default.createElement("div", null, percentageChange, props.usdValue && React__default.createElement(ui.Typography, {
|
|
1933
1922
|
variant: "caption",
|
|
1934
|
-
color: "neutrals600"
|
|
1935
|
-
|
|
1923
|
+
color: "neutrals600",
|
|
1924
|
+
className: "usd-value"
|
|
1925
|
+
}, `$${numberToString(props.usdValue)}`))), React__default.createElement("div", {
|
|
1936
1926
|
className: "form"
|
|
1937
1927
|
}, React__default.createElement(ui.Button, {
|
|
1938
1928
|
className: "selectors",
|
|
1939
1929
|
variant: "outlined",
|
|
1940
1930
|
loading: loadingStatus === 'loading',
|
|
1941
|
-
prefix: loadingStatus === 'success' && chain ? React__default.createElement(
|
|
1942
|
-
src: chain.logo
|
|
1931
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(ui.Image, {
|
|
1932
|
+
src: chain.logo,
|
|
1933
|
+
size: 24
|
|
1943
1934
|
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
1944
1935
|
suffix: ItemSuffix,
|
|
1945
1936
|
align: "start",
|
|
@@ -1950,8 +1941,9 @@ function TokenPreview(props) {
|
|
|
1950
1941
|
className: "selectors",
|
|
1951
1942
|
variant: "outlined",
|
|
1952
1943
|
loading: loadingStatus === 'loading',
|
|
1953
|
-
prefix: loadingStatus === 'success' && token ? React__default.createElement(
|
|
1954
|
-
src: token.image
|
|
1944
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(ui.Image, {
|
|
1945
|
+
src: token.image,
|
|
1946
|
+
size: 24
|
|
1955
1947
|
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
1956
1948
|
suffix: ItemSuffix,
|
|
1957
1949
|
size: "large",
|
|
@@ -2029,6 +2021,7 @@ function useConfirmSwap() {
|
|
|
2029
2021
|
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
2030
2022
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
2031
2023
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2024
|
+
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
2032
2025
|
const accounts = useWalletsStore.use.accounts();
|
|
2033
2026
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2034
2027
|
const meta = useMetaStore.use.meta();
|
|
@@ -2061,17 +2054,16 @@ function useConfirmSwap() {
|
|
|
2061
2054
|
if (warnings.length > 0) setWarnings([]);
|
|
2062
2055
|
proceedAnywayRef.current = false;
|
|
2063
2056
|
if (confiremedRouteRef.current) {
|
|
2064
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2065
|
-
//@ts-ignore
|
|
2057
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2066
2058
|
return newSwap;
|
|
2067
2059
|
}
|
|
2068
2060
|
return;
|
|
2069
2061
|
}
|
|
2070
2062
|
abortControllerRef.current = new AbortController();
|
|
2071
2063
|
setLoading(true);
|
|
2072
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
2064
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true, affiliateRef);
|
|
2073
2065
|
try {
|
|
2074
|
-
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
2066
|
+
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
2075
2067
|
signal: abortControllerRef.current?.signal
|
|
2076
2068
|
});
|
|
2077
2069
|
abortControllerRef.current = null;
|
|
@@ -2124,8 +2116,7 @@ function useConfirmSwap() {
|
|
|
2124
2116
|
slippage: userSlippage.toString(),
|
|
2125
2117
|
disabledSwappersGroups: disabledLiquiditySources
|
|
2126
2118
|
};
|
|
2127
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2128
|
-
//@ts-ignore
|
|
2119
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2129
2120
|
return newSwap;
|
|
2130
2121
|
} else if (!proceedAnywayRef.current) {
|
|
2131
2122
|
proceedAnywayRef.current = true;
|
|
@@ -2311,6 +2302,8 @@ function ConfirmSwapPage() {
|
|
|
2311
2302
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
2312
2303
|
const slippage = useSettingsStore.use.slippage();
|
|
2313
2304
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2305
|
+
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2306
|
+
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
2314
2307
|
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
2315
2308
|
const {
|
|
2316
2309
|
manager
|
|
@@ -2341,7 +2334,10 @@ function ConfirmSwapPage() {
|
|
|
2341
2334
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2342
2335
|
};
|
|
2343
2336
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2344
|
-
return React__default.createElement(ui.ConfirmSwap
|
|
2337
|
+
return React__default.createElement(ui.ConfirmSwap
|
|
2338
|
+
// @ts-ignore
|
|
2339
|
+
, {
|
|
2340
|
+
// @ts-ignore
|
|
2345
2341
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2346
2342
|
selectableWallets: selectableWallets,
|
|
2347
2343
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
@@ -2350,7 +2346,9 @@ function ConfirmSwapPage() {
|
|
|
2350
2346
|
if (swap) {
|
|
2351
2347
|
manager?.create('swap', {
|
|
2352
2348
|
swapDetails: swap
|
|
2353
|
-
},
|
|
2349
|
+
},
|
|
2350
|
+
// @ts-ignore
|
|
2351
|
+
{
|
|
2354
2352
|
id: swap.requestId
|
|
2355
2353
|
});
|
|
2356
2354
|
setSelectedSwap(swap.requestId);
|
|
@@ -2373,7 +2371,7 @@ function ConfirmSwapPage() {
|
|
|
2373
2371
|
symbol: firstStep?.from.symbol || '',
|
|
2374
2372
|
image: firstStep?.from.logo || ''
|
|
2375
2373
|
},
|
|
2376
|
-
usdValue:
|
|
2374
|
+
usdValue: inputUsdValue,
|
|
2377
2375
|
amount: fromAmount,
|
|
2378
2376
|
label: i18n.t('From'),
|
|
2379
2377
|
loadingStatus: bestRouteloadingStatus
|
|
@@ -2389,10 +2387,14 @@ function ConfirmSwapPage() {
|
|
|
2389
2387
|
symbol: lastStep?.to.symbol || '',
|
|
2390
2388
|
image: lastStep?.to.logo || ''
|
|
2391
2389
|
},
|
|
2392
|
-
usdValue:
|
|
2390
|
+
usdValue: outputUsdValue,
|
|
2393
2391
|
amount: toAmount,
|
|
2394
2392
|
label: i18n.t('To'),
|
|
2395
|
-
loadingStatus: bestRouteloadingStatus
|
|
2393
|
+
loadingStatus: bestRouteloadingStatus,
|
|
2394
|
+
percentageChange: React__default.createElement(PercentageChange, {
|
|
2395
|
+
inputUsdValue: inputUsdValue,
|
|
2396
|
+
outputUsdValue: outputUsdValue
|
|
2397
|
+
})
|
|
2396
2398
|
})),
|
|
2397
2399
|
previewRoutes: React__default.createElement(RoutesOverview, {
|
|
2398
2400
|
routes: bestRoute,
|
|
@@ -2504,7 +2506,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2504
2506
|
});
|
|
2505
2507
|
return React__default.createElement(ui.LiquiditySourcesSelector, {
|
|
2506
2508
|
toggleAll: toggleAllLiquiditySources,
|
|
2507
|
-
list: supportedSwappers
|
|
2509
|
+
list: supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups,
|
|
2508
2510
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2509
2511
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2510
2512
|
loadingStatus: loadingMetaStatus
|
|
@@ -2516,7 +2518,7 @@ function SelectChainPage(props) {
|
|
|
2516
2518
|
type,
|
|
2517
2519
|
supportedChains
|
|
2518
2520
|
} = props;
|
|
2519
|
-
const blockchains = supportedChains
|
|
2521
|
+
const blockchains = supportedChains ? useMetaStore.use.meta().blockchains.filter(chain => supportedChains.includes(chain.name)) : useMetaStore.use.meta().blockchains;
|
|
2520
2522
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
2521
2523
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
2522
2524
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -2548,8 +2550,8 @@ function SelectTokenPage(props) {
|
|
|
2548
2550
|
} = props;
|
|
2549
2551
|
const sourceTokens = useBestRouteStore.use.sourceTokens();
|
|
2550
2552
|
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2551
|
-
const supportedSourceTokens = supportedTokens
|
|
2552
|
-
const supportedDestinationTokens = supportedTokens
|
|
2553
|
+
const supportedSourceTokens = supportedTokens ? sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : sourceTokens;
|
|
2554
|
+
const supportedDestinationTokens = supportedTokens ? destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : destinationTokens;
|
|
2553
2555
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
2554
2556
|
const toToken = useBestRouteStore.use.toToken();
|
|
2555
2557
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
@@ -2602,8 +2604,8 @@ function SettingsPage(_ref) {
|
|
|
2602
2604
|
}
|
|
2603
2605
|
}
|
|
2604
2606
|
});
|
|
2605
|
-
supportedSwappers
|
|
2606
|
-
const supportedUniqueSwappersGroups = supportedSwappers
|
|
2607
|
+
supportedSwappers && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0);
|
|
2608
|
+
const supportedUniqueSwappersGroups = supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups;
|
|
2607
2609
|
return React__default.createElement(ui.Settings, {
|
|
2608
2610
|
slippages: SLIPPAGES,
|
|
2609
2611
|
selectedSlippage: slippage,
|
|
@@ -2656,7 +2658,7 @@ function WalletsPage(_ref) {
|
|
|
2656
2658
|
getWalletInfo,
|
|
2657
2659
|
connect
|
|
2658
2660
|
} = walletsCore.useWallets();
|
|
2659
|
-
const wallets = getlistWallet(state, getWalletInfo, supportedWallets
|
|
2661
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets || Object.values(walletsShared.WalletType));
|
|
2660
2662
|
const walletsRef = React.useRef();
|
|
2661
2663
|
let sortedWallets = walletsShared.detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2662
2664
|
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
@@ -2865,7 +2867,7 @@ function SwapDetailsPage() {
|
|
|
2865
2867
|
}), React__default.createElement(TokenPreview, {
|
|
2866
2868
|
chain: {
|
|
2867
2869
|
displayName: lastStep?.toBlockchain || '',
|
|
2868
|
-
|
|
2870
|
+
//@ts-ignore
|
|
2869
2871
|
logo: lastStep?.toBlockchainLogo || ''
|
|
2870
2872
|
},
|
|
2871
2873
|
token: {
|
|
@@ -2877,7 +2879,6 @@ function SwapDetailsPage() {
|
|
|
2877
2879
|
loadingStatus: 'success'
|
|
2878
2880
|
})),
|
|
2879
2881
|
//todo: move PendingSwap type to rango-types
|
|
2880
|
-
//@ts-ignore
|
|
2881
2882
|
pendingSwap: swap,
|
|
2882
2883
|
onCopy: handleCopy,
|
|
2883
2884
|
isCopied: isCopied,
|
|
@@ -2907,48 +2908,44 @@ function SwapDetailsPage() {
|
|
|
2907
2908
|
const getAbsolutePath = path => path.replace('/', '');
|
|
2908
2909
|
function AppRoutes(props) {
|
|
2909
2910
|
const {
|
|
2910
|
-
|
|
2911
|
+
config
|
|
2911
2912
|
} = props;
|
|
2912
2913
|
return reactRouterDom.useRoutes([{
|
|
2913
2914
|
path: getAbsolutePath(navigationRoutes.home),
|
|
2914
|
-
element: React__default.createElement(Home,
|
|
2915
|
-
title: configs?.title,
|
|
2916
|
-
titleSize: configs?.titleSize,
|
|
2917
|
-
titleWeight: configs?.titleWeight
|
|
2918
|
-
})
|
|
2915
|
+
element: React__default.createElement(Home, null)
|
|
2919
2916
|
}, {
|
|
2920
2917
|
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2921
2918
|
element: React__default.createElement(SelectChainPage, {
|
|
2922
2919
|
type: "from",
|
|
2923
|
-
supportedChains:
|
|
2920
|
+
supportedChains: config?.from?.blockchains
|
|
2924
2921
|
})
|
|
2925
2922
|
}, {
|
|
2926
2923
|
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2927
2924
|
element: React__default.createElement(SelectChainPage, {
|
|
2928
2925
|
type: "to",
|
|
2929
|
-
supportedChains:
|
|
2926
|
+
supportedChains: config?.to?.blockchains
|
|
2930
2927
|
})
|
|
2931
2928
|
}, {
|
|
2932
2929
|
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2933
2930
|
element: React__default.createElement(SelectTokenPage, {
|
|
2934
2931
|
type: "from",
|
|
2935
|
-
supportedTokens:
|
|
2932
|
+
supportedTokens: config?.from?.tokens
|
|
2936
2933
|
})
|
|
2937
2934
|
}, {
|
|
2938
2935
|
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2939
2936
|
element: React__default.createElement(SelectTokenPage, {
|
|
2940
2937
|
type: "to",
|
|
2941
|
-
supportedTokens:
|
|
2938
|
+
supportedTokens: config?.to?.tokens
|
|
2942
2939
|
})
|
|
2943
2940
|
}, {
|
|
2944
2941
|
path: getAbsolutePath(navigationRoutes.settings),
|
|
2945
2942
|
element: React__default.createElement(SettingsPage, {
|
|
2946
|
-
supportedSwappers:
|
|
2943
|
+
supportedSwappers: config?.liquiditySources
|
|
2947
2944
|
})
|
|
2948
2945
|
}, {
|
|
2949
2946
|
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
2950
2947
|
element: React__default.createElement(LiquiditySourcePage, {
|
|
2951
|
-
supportedSwappers:
|
|
2948
|
+
supportedSwappers: config?.liquiditySources
|
|
2952
2949
|
})
|
|
2953
2950
|
}, {
|
|
2954
2951
|
path: getAbsolutePath(navigationRoutes.swaps),
|
|
@@ -2959,8 +2956,8 @@ function AppRoutes(props) {
|
|
|
2959
2956
|
}, {
|
|
2960
2957
|
path: getAbsolutePath(navigationRoutes.wallets),
|
|
2961
2958
|
element: React__default.createElement(WalletsPage, {
|
|
2962
|
-
supportedWallets:
|
|
2963
|
-
multiWallets: typeof
|
|
2959
|
+
supportedWallets: config?.wallets,
|
|
2960
|
+
multiWallets: typeof config?.multiWallets === 'undefined' ? true : config.multiWallets
|
|
2964
2961
|
})
|
|
2965
2962
|
}, {
|
|
2966
2963
|
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
@@ -2976,16 +2973,14 @@ const Header = /*#__PURE__*/ui.styled('div', {
|
|
|
2976
2973
|
display: 'flex'
|
|
2977
2974
|
}
|
|
2978
2975
|
});
|
|
2979
|
-
const
|
|
2980
|
-
width: '$24',
|
|
2981
|
-
height: '$24',
|
|
2976
|
+
const WalletImageContainer = /*#__PURE__*/ui.styled('div', {
|
|
2982
2977
|
marginLeft: -15,
|
|
2983
2978
|
marginRight: '$6',
|
|
2984
2979
|
borderRadius: '99999px'
|
|
2985
2980
|
});
|
|
2986
2981
|
function Layout(_ref) {
|
|
2987
2982
|
let {
|
|
2988
|
-
|
|
2983
|
+
config
|
|
2989
2984
|
} = _ref;
|
|
2990
2985
|
const navigate = reactRouterDom.useNavigate();
|
|
2991
2986
|
const {
|
|
@@ -2997,11 +2992,16 @@ function Layout(_ref) {
|
|
|
2997
2992
|
getWalletInfo
|
|
2998
2993
|
} = walletsCore.useWallets();
|
|
2999
2994
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2995
|
+
const {
|
|
2996
|
+
blockchains,
|
|
2997
|
+
tokens
|
|
2998
|
+
} = useMetaStore.use.meta();
|
|
3000
2999
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
3001
3000
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
3002
3001
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
3003
3002
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
3004
3003
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
3004
|
+
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
3005
3005
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
3006
3006
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
3007
3007
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
@@ -3010,22 +3010,23 @@ function Layout(_ref) {
|
|
|
3010
3010
|
t
|
|
3011
3011
|
} = reactI18next.useTranslation();
|
|
3012
3012
|
React.useEffect(() => {
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3013
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
3014
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
3015
|
+
setToChain(chain || null);
|
|
3016
|
+
setToToken(token || null);
|
|
3017
|
+
}, [config?.to?.token, config?.to?.blockchain]);
|
|
3016
3018
|
React.useEffect(() => {
|
|
3017
|
-
setInputAmount(
|
|
3018
|
-
}, [
|
|
3019
|
+
setInputAmount(config?.amount?.toString() || '');
|
|
3020
|
+
}, [config?.amount]);
|
|
3019
3021
|
React.useEffect(() => {
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3022
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
3023
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
3024
|
+
setFromChain(chain || null);
|
|
3025
|
+
setFromToken(token || null);
|
|
3026
|
+
}, [config?.from?.token, config?.from?.blockchain]);
|
|
3023
3027
|
React.useEffect(() => {
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
setFromToken(null);
|
|
3027
|
-
setToToken(null);
|
|
3028
|
-
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
3028
|
+
setAffiliateRef(config?.affiliateRef || null);
|
|
3029
|
+
}, [config?.affiliateRef]);
|
|
3029
3030
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Header, null, React__default.createElement(ui.Button, {
|
|
3030
3031
|
size: "small",
|
|
3031
3032
|
suffix: React__default.createElement(ui.AddWalletIcon, {
|
|
@@ -3038,15 +3039,17 @@ function Layout(_ref) {
|
|
|
3038
3039
|
onClick: () => {
|
|
3039
3040
|
if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
|
|
3040
3041
|
}
|
|
3041
|
-
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React__default.createElement(
|
|
3042
|
-
key: index
|
|
3043
|
-
|
|
3044
|
-
|
|
3042
|
+
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React__default.createElement(WalletImageContainer, {
|
|
3043
|
+
key: index
|
|
3044
|
+
}, React__default.createElement(ui.Image, {
|
|
3045
|
+
src: walletImage,
|
|
3046
|
+
size: 24
|
|
3047
|
+
}))) : React__default.createElement(React__default.Fragment, null), React__default.createElement("div", {
|
|
3045
3048
|
className: "balance"
|
|
3046
3049
|
}, React__default.createElement(ui.Typography, {
|
|
3047
3050
|
variant: "body2"
|
|
3048
3051
|
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React__default.createElement(ui.Spinner, null)))), React__default.createElement(AppRoutes, {
|
|
3049
|
-
|
|
3052
|
+
config: config
|
|
3050
3053
|
}));
|
|
3051
3054
|
}
|
|
3052
3055
|
|
|
@@ -3089,17 +3092,20 @@ function usePrevious(value) {
|
|
|
3089
3092
|
|
|
3090
3093
|
function useTheme(_ref) {
|
|
3091
3094
|
let {
|
|
3092
|
-
|
|
3093
|
-
background = '#fff',
|
|
3094
|
-
foreground = '#000',
|
|
3095
|
-
error = '#FF0000',
|
|
3096
|
-
warning = '#F5A623',
|
|
3097
|
-
success = '#0070F3',
|
|
3095
|
+
colors: themeColors,
|
|
3098
3096
|
fontFamily = 'Robot',
|
|
3099
|
-
borderRadius = 8
|
|
3097
|
+
borderRadius = 8,
|
|
3098
|
+
mode = 'auto'
|
|
3100
3099
|
} = _ref;
|
|
3101
3100
|
const theme = useSettingsStore.use.theme();
|
|
3102
3101
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3102
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
3103
|
+
const primary = themeColors?.primary || '#5FA425',
|
|
3104
|
+
background = themeColors?.background || '#fff',
|
|
3105
|
+
foreground = themeColors?.foreground || '#000',
|
|
3106
|
+
error = themeColors?.error || '#FF0000',
|
|
3107
|
+
warning = themeColors?.warning || '#F5A623',
|
|
3108
|
+
success = themeColors?.success || '#0070F3';
|
|
3103
3109
|
const colors = {
|
|
3104
3110
|
neutrals200: '#FAFAFA',
|
|
3105
3111
|
neutrals300: '#f2f2f2',
|
|
@@ -3141,6 +3147,9 @@ function useTheme(_ref) {
|
|
|
3141
3147
|
colors,
|
|
3142
3148
|
radii: {
|
|
3143
3149
|
5: `${borderRadius}px`
|
|
3150
|
+
},
|
|
3151
|
+
shadows: {
|
|
3152
|
+
s: '0px 3px 5px 3px #f0f2f5, 0px 6px 10px 3px #f0f2f5, 0px 1px 18px 3px #f0f2f5'
|
|
3144
3153
|
}
|
|
3145
3154
|
});
|
|
3146
3155
|
const customeDarkTheme = ui.createTheme({
|
|
@@ -3159,6 +3168,9 @@ function useTheme(_ref) {
|
|
|
3159
3168
|
},
|
|
3160
3169
|
radii: {
|
|
3161
3170
|
5: `${borderRadius}px`
|
|
3171
|
+
},
|
|
3172
|
+
shadows: {
|
|
3173
|
+
s: '0px 3px 5px 3px #222, 0px 6px 10px 3px #222, 0px 1px 18px 3px #222'
|
|
3162
3174
|
}
|
|
3163
3175
|
});
|
|
3164
3176
|
const [OSTheme, setOSTheme] = React.useState(customeLightTheme);
|
|
@@ -3177,6 +3189,9 @@ function useTheme(_ref) {
|
|
|
3177
3189
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
3178
3190
|
};
|
|
3179
3191
|
}, []);
|
|
3192
|
+
React.useEffect(() => {
|
|
3193
|
+
if (mode !== 'auto') setTheme(mode);
|
|
3194
|
+
}, [mode]);
|
|
3180
3195
|
const prevFont = usePrevious(fontFamily);
|
|
3181
3196
|
React.useLayoutEffect(() => {
|
|
3182
3197
|
const {
|
|
@@ -3281,6 +3296,11 @@ function QueueManager(props) {
|
|
|
3281
3296
|
canSwitchNetworkTo,
|
|
3282
3297
|
getWalletInfo
|
|
3283
3298
|
} = walletsCore.useWallets();
|
|
3299
|
+
const swapQueueDef = React.useMemo(() => {
|
|
3300
|
+
return queueManagerRangoPreset.makeQueueDefinition({
|
|
3301
|
+
API_KEY: getConfig('API_KEY')
|
|
3302
|
+
});
|
|
3303
|
+
}, []);
|
|
3284
3304
|
const {
|
|
3285
3305
|
blockchains
|
|
3286
3306
|
} = useMetaStore.use.meta();
|
|
@@ -3330,7 +3350,7 @@ function QueueManager(props) {
|
|
|
3330
3350
|
//@ts-ignore
|
|
3331
3351
|
, {
|
|
3332
3352
|
//@ts-ignore
|
|
3333
|
-
queuesDefs: [
|
|
3353
|
+
queuesDefs: [swapQueueDef],
|
|
3334
3354
|
context: context,
|
|
3335
3355
|
onPersistedDataLoaded: manager => {
|
|
3336
3356
|
queueManagerRangoPreset.checkWaitingForNetworkChange(manager);
|
|
@@ -3341,29 +3361,27 @@ function QueueManager(props) {
|
|
|
3341
3361
|
|
|
3342
3362
|
const SwapBox = _ref => {
|
|
3343
3363
|
let {
|
|
3344
|
-
|
|
3364
|
+
config
|
|
3345
3365
|
} = _ref;
|
|
3346
3366
|
globalStyles();
|
|
3347
|
-
globalFont(
|
|
3367
|
+
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
3348
3368
|
const {
|
|
3349
3369
|
activeTheme
|
|
3350
3370
|
} = useTheme({
|
|
3351
|
-
...
|
|
3352
|
-
borderRadius: configs?.borderRadius,
|
|
3353
|
-
fontFamily: configs?.fontFamily
|
|
3371
|
+
...config?.theme
|
|
3354
3372
|
});
|
|
3355
3373
|
const {
|
|
3356
3374
|
blockchains
|
|
3357
3375
|
} = useMetaStore.use.meta();
|
|
3358
3376
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
3359
3377
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
3360
|
-
const setTheme = useSettingsStore.use.setTheme();
|
|
3361
3378
|
const {
|
|
3362
3379
|
changeLanguage
|
|
3363
3380
|
} = useSelectLanguage();
|
|
3364
3381
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
3365
3382
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = React.useState('');
|
|
3366
3383
|
const [disconnectedWallet, setDisconnectedWallet] = React.useState();
|
|
3384
|
+
const currentPage = useUiStore.use.currentPage();
|
|
3367
3385
|
const evmBasedChainNames = blockchains.filter(rangoSdk.isEvmBlockchain).map(chain => chain.name);
|
|
3368
3386
|
const onUpdateState = (type, event, value, state, supportedChains) => {
|
|
3369
3387
|
if (event === walletsCore.Events.ACCOUNTS) {
|
|
@@ -3388,19 +3406,16 @@ const SwapBox = _ref => {
|
|
|
3388
3406
|
};
|
|
3389
3407
|
let providers = providerAll.allProviders();
|
|
3390
3408
|
React.useEffect(() => {
|
|
3391
|
-
|
|
3392
|
-
}, [configs.theme]);
|
|
3393
|
-
React.useEffect(() => {
|
|
3394
|
-
const wallets = configs.wallets;
|
|
3409
|
+
const wallets = config?.wallets;
|
|
3395
3410
|
clearConnectedWallet();
|
|
3396
|
-
providers = wallets
|
|
3411
|
+
providers = !wallets ? providerAll.allProviders() : providerAll.allProviders().filter(provider => {
|
|
3397
3412
|
const type = provider.config.type;
|
|
3398
3413
|
return wallets.find(w => w === type);
|
|
3399
3414
|
});
|
|
3400
|
-
}, [
|
|
3415
|
+
}, [config?.wallets]);
|
|
3401
3416
|
React.useEffect(() => {
|
|
3402
|
-
changeLanguage(
|
|
3403
|
-
}, [
|
|
3417
|
+
changeLanguage(config?.language || 'en');
|
|
3418
|
+
}, [config?.language]);
|
|
3404
3419
|
return React__default.createElement(walletsCore.Provider, {
|
|
3405
3420
|
allBlockChains: blockchains,
|
|
3406
3421
|
providers: providers,
|
|
@@ -3409,21 +3424,15 @@ const SwapBox = _ref => {
|
|
|
3409
3424
|
id: "pageContainer",
|
|
3410
3425
|
className: activeTheme
|
|
3411
3426
|
}, React__default.createElement(QueueManager, null, React__default.createElement(ui.SwapContainer, {
|
|
3412
|
-
|
|
3413
|
-
width: configs?.width || 'auto',
|
|
3414
|
-
height: configs?.height || 'auto'
|
|
3415
|
-
}
|
|
3427
|
+
fixedHeight: currentPage !== navigationRoutes.home
|
|
3416
3428
|
}, React__default.createElement(AppRouter, {
|
|
3417
|
-
title: configs.title,
|
|
3418
|
-
titleSize: configs.titleSize,
|
|
3419
|
-
titleWeight: configs.titleWeight,
|
|
3420
3429
|
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
3421
3430
|
disconnectedWallet: disconnectedWallet,
|
|
3422
3431
|
clearDisconnectedWallet: () => {
|
|
3423
3432
|
setDisconnectedWallet(undefined);
|
|
3424
3433
|
}
|
|
3425
3434
|
}, React__default.createElement(Layout, {
|
|
3426
|
-
|
|
3435
|
+
config: config
|
|
3427
3436
|
}))))));
|
|
3428
3437
|
};
|
|
3429
3438
|
|