@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.
Files changed (88) hide show
  1. package/dist/App.d.ts +3 -3
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/QueueManager.d.ts.map +1 -1
  4. package/dist/components/AppRouter.d.ts +1 -7
  5. package/dist/components/AppRouter.d.ts.map +1 -1
  6. package/dist/components/AppRoutes.d.ts +2 -2
  7. package/dist/components/AppRoutes.d.ts.map +1 -1
  8. package/dist/components/Layout.d.ts +3 -3
  9. package/dist/components/Layout.d.ts.map +1 -1
  10. package/dist/components/PercentageChange.d.ts +9 -0
  11. package/dist/components/PercentageChange.d.ts.map +1 -0
  12. package/dist/components/TokenInfo.d.ts.map +1 -1
  13. package/dist/components/TokenPreview.d.ts +2 -1
  14. package/dist/components/TokenPreview.d.ts.map +1 -1
  15. package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
  16. package/dist/hooks/useTheme.d.ts +2 -5
  17. package/dist/hooks/useTheme.d.ts.map +1 -1
  18. package/dist/lib.d.ts +2 -2
  19. package/dist/lib.d.ts.map +1 -1
  20. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  21. package/dist/pages/Home.d.ts +1 -7
  22. package/dist/pages/Home.d.ts.map +1 -1
  23. package/dist/pages/LiquiditySourcesPage.d.ts +1 -2
  24. package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
  25. package/dist/pages/SelectChainPage.d.ts +1 -2
  26. package/dist/pages/SelectChainPage.d.ts.map +1 -1
  27. package/dist/pages/SelectTokenPage.d.ts +2 -2
  28. package/dist/pages/SelectTokenPage.d.ts.map +1 -1
  29. package/dist/pages/SettingsPage.d.ts +1 -2
  30. package/dist/pages/SettingsPage.d.ts.map +1 -1
  31. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  32. package/dist/pages/WalletsPage.d.ts +1 -1
  33. package/dist/pages/WalletsPage.d.ts.map +1 -1
  34. package/dist/services/httpService.d.ts +2 -1
  35. package/dist/services/httpService.d.ts.map +1 -1
  36. package/dist/store/bestRoute.d.ts +1 -0
  37. package/dist/store/bestRoute.d.ts.map +1 -1
  38. package/dist/store/meta.d.ts.map +1 -1
  39. package/dist/store/settings.d.ts +2 -0
  40. package/dist/store/settings.d.ts.map +1 -1
  41. package/dist/types/config.d.ts +27 -29
  42. package/dist/types/config.d.ts.map +1 -1
  43. package/dist/types/routing.d.ts +14 -1
  44. package/dist/types/routing.d.ts.map +1 -1
  45. package/dist/utils/configs.d.ts +7 -0
  46. package/dist/utils/configs.d.ts.map +1 -0
  47. package/dist/utils/routing.d.ts +2 -2
  48. package/dist/utils/routing.d.ts.map +1 -1
  49. package/dist/utils/swap.d.ts +2 -6
  50. package/dist/utils/swap.d.ts.map +1 -1
  51. package/dist/widget-embedded.cjs.development.js +232 -223
  52. package/dist/widget-embedded.cjs.development.js.map +1 -1
  53. package/dist/widget-embedded.cjs.production.min.js +232 -223
  54. package/dist/widget-embedded.cjs.production.min.js.map +1 -1
  55. package/dist/widget-embedded.esm.js +232 -223
  56. package/dist/widget-embedded.esm.js.map +1 -1
  57. package/package.json +6 -4
  58. package/readme.md +1 -1
  59. package/src/App.tsx +36 -14
  60. package/src/QueueManager.tsx +9 -3
  61. package/src/components/AppRouter.tsx +7 -16
  62. package/src/components/AppRoutes.tsx +13 -32
  63. package/src/components/HeaderButtons.tsx +1 -1
  64. package/src/components/Layout.tsx +37 -27
  65. package/src/components/PercentageChange.tsx +33 -0
  66. package/src/components/TokenInfo.tsx +24 -12
  67. package/src/components/TokenPreview.tsx +19 -15
  68. package/src/hooks/useConfirmSwap.ts +6 -5
  69. package/src/hooks/useTheme.ts +21 -9
  70. package/src/lib.tsx +30 -36
  71. package/src/pages/ConfirmSwapPage.tsx +14 -7
  72. package/src/pages/Home.tsx +10 -22
  73. package/src/pages/LiquiditySourcesPage.tsx +3 -6
  74. package/src/pages/SelectChainPage.tsx +6 -6
  75. package/src/pages/SelectTokenPage.tsx +16 -18
  76. package/src/pages/SettingsPage.tsx +8 -18
  77. package/src/pages/SwapDetailsPage.tsx +2 -4
  78. package/src/pages/WalletsPage.tsx +2 -2
  79. package/src/services/httpService.ts +12 -3
  80. package/src/store/bestRoute.ts +39 -9
  81. package/src/store/meta.ts +6 -4
  82. package/src/store/settings.ts +7 -0
  83. package/src/store/wallets.ts +1 -1
  84. package/src/types/config.ts +28 -29
  85. package/src/types/routing.ts +17 -1
  86. package/src/utils/configs.ts +24 -0
  87. package/src/utils/routing.ts +29 -23
  88. package/src/utils/swap.ts +5 -97
@@ -1,7 +1,7 @@
1
- import { WalletState, InfoCircleIcon, AngleDownIcon, Typography, Spacer, Button, TextField, styled, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, Alert, ChevronRightIcon, GasIcon, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, LoadingFailedAlert, Wallet, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
2
- import React, { useRef, useEffect, useState, useLayoutEffect } from 'react';
1
+ import { WalletState, Typography, InfoCircleIcon, AngleDownIcon, Spacer, Button, Image, TextField, styled, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, Alert, ChevronRightIcon, GasIcon, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, LoadingFailedAlert, Wallet, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
2
+ import React, { useRef, useEffect, useState, useLayoutEffect, useMemo } from 'react';
3
3
  import { useInRouterContext as useInRouterContext$1, MemoryRouter, useLocation as useLocation$1, useNavigate as useNavigate$1 } from 'react-router';
4
- import { PendingSwapNetworkStatus, useQueueManager, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, swapQueueDef, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
4
+ import { PendingSwapNetworkStatus, useQueueManager, calculatePendingSwap, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, makeQueueDefinition, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
5
5
  import { isCosmosBlockchain, isEvmBlockchain } from 'rango-types';
6
6
  import { useSearchParams, useLocation, createSearchParams, useNavigate, useInRouterContext, useRoutes } from 'react-router-dom';
7
7
  import { create } from 'zustand';
@@ -436,7 +436,7 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
436
436
  };else if (inputIsZero) return {
437
437
  title: 'Enter an amount',
438
438
  disabled: true
439
- };else if (!bestRoute) return {
439
+ };else if (!bestRoute || !bestRoute.result) return {
440
440
  title: 'Swap',
441
441
  disabled: true
442
442
  };else if (hasLimitError) return {
@@ -461,80 +461,6 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
461
461
  function canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue) {
462
462
  return !((inputUsdValue.lte(ZERO) || outputUsdValue.lte(ZERO)) && !!bestRoute?.result && !!inputAmount && inputAmount !== '0' && parseFloat(inputAmount || '0') !== 0 && !!bestRoute.result);
463
463
  }
464
- function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validateBalanceOrFee, meta) {
465
- const simulationResult = bestRoute.result;
466
- if (!simulationResult) throw Error('Simulation result should not be null');
467
- return {
468
- creationTime: new Date().getTime().toString(),
469
- finishTime: null,
470
- requestId: bestRoute.requestId || '',
471
- inputAmount: inputAmount,
472
- //@ts-ignore
473
- wallets,
474
- status: 'running',
475
- isPaused: false,
476
- extraMessage: null,
477
- extraMessageSeverity: null,
478
- extraMessageDetail: null,
479
- extraMessageErrorCode: null,
480
- networkStatusExtraMessage: null,
481
- networkStatusExtraMessageDetail: null,
482
- lastNotificationTime: null,
483
- //@ts-ignore
484
- settings: settings,
485
- simulationResult: simulationResult,
486
- validateBalanceOrFee,
487
- //@ts-ignore
488
- steps: bestRoute.result?.swaps?.map((swap, index) => {
489
- const swapper = meta.swappers.find(swapper => swapper.id === swap.swapperId);
490
- const swapperType = swapper?.types[0];
491
- const fromBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.from.blockchain);
492
- const toBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.to.blockchain);
493
- return {
494
- id: index + 1,
495
- fromBlockchain: swap.from.blockchain,
496
- fromSymbol: swap.from.symbol,
497
- fromSymbolAddress: swap.from.address,
498
- fromDecimals: swap.from.decimals,
499
- fromAmountPrecision: swap.fromAmountPrecision,
500
- fromAmountMinValue: swap.fromAmountMinValue,
501
- fromAmountMaxValue: swap.fromAmountMaxValue,
502
- toBlockchain: swap.to.blockchain,
503
- fromLogo: swap.from.logo,
504
- toSymbol: swap.to.symbol,
505
- toSymbolAddress: swap.to.address,
506
- toDecimals: swap.to.decimals,
507
- toLogo: swap.to.logo,
508
- startTransactionTime: new Date().getTime(),
509
- swapperId: swap.swapperId,
510
- feeInUsd: numberToString(getUsdFeeOfStep(swap, meta.tokens), null, 2),
511
- expectedOutputAmountHumanReadable: swap.toAmount,
512
- outputAmount: '',
513
- status: 'created',
514
- networkStatus: null,
515
- executedTransactionId: null,
516
- externalTransactionId: null,
517
- explorerUrl: null,
518
- trackingCode: null,
519
- cosmosTransaction: null,
520
- solanaTransaction: null,
521
- starknetTransaction: null,
522
- starknetApprovalTransaction: null,
523
- tronTransaction: null,
524
- tronApprovalTransaction: null,
525
- evmTransaction: null,
526
- evmApprovalTransaction: null,
527
- transferTransaction: null,
528
- diagnosisUrl: null,
529
- internalSteps: null,
530
- fromBlockchainLogo: fromBlockchain?.logo || '',
531
- toBlockchainLogo: toBlockchain?.logo || '',
532
- swapperLogo: swapper?.logo || '',
533
- swapperType: swapperType || ''
534
- };
535
- }) || []
536
- };
537
- }
538
464
  function requiredWallets(route) {
539
465
  const wallets = [];
540
466
  route?.result?.swaps.forEach(swap => {
@@ -576,7 +502,7 @@ function hasProperSlippage(userSlippage, minRequiredSlippage) {
576
502
  if (!minRequiredSlippage) return true;
577
503
  return parseFloat(userSlippage) >= parseFloat(minRequiredSlippage);
578
504
  }
579
- function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites) {
505
+ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites, affiliateRef) {
580
506
  const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
581
507
  const connectedWallets = [];
582
508
  wallets.forEach(wallet => {
@@ -589,6 +515,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
589
515
  const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
590
516
  const requestBody = {
591
517
  amount: inputAmount.toString(),
518
+ affiliateRef,
592
519
  checkPrerequisites,
593
520
  from: {
594
521
  address: fromToken.address,
@@ -744,8 +671,21 @@ function getRequiredBalanceOfWallet(selectedWallet, fee) {
744
671
  if (!relatedFeeStatus) return null;
745
672
  return relatedFeeStatus.requiredAssets;
746
673
  }
747
- function isRouteParametersChanged(prevParams, currentParams) {
748
- return !!currentParams.fromToken && !!currentParams.toToken && (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);
674
+ function isRouteParametersChanged(params) {
675
+ if (params.store === 'bestRoute') {
676
+ const {
677
+ prevState,
678
+ currentState
679
+ } = params;
680
+ 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);
681
+ } else if (params.store === 'settings') {
682
+ const {
683
+ prevState,
684
+ currentState
685
+ } = params;
686
+ return prevState.slippage !== currentState.slippage || prevState.customSlippage !== currentState.customSlippage || prevState.disabledLiquiditySources?.length !== currentState.disabledLiquiditySources?.length || prevState.infiniteApprove || currentState.infiniteApprove;
687
+ }
688
+ return false;
749
689
  }
750
690
  //todo: refactor bestRoute store and add loadingStatus
751
691
  const getBestRouteStatus = (loading, error) => {
@@ -762,7 +702,20 @@ const createSelectors = _store => {
762
702
  return store;
763
703
  };
764
704
 
765
- const httpService = /*#__PURE__*/new RangoClient(process.env.REACT_APP_API_KEY);
705
+ const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
706
+ let configs = {
707
+ API_KEY: RANGO_PUBLIC_API_KEY
708
+ };
709
+ function getConfig(name) {
710
+ return configs[name];
711
+ }
712
+
713
+ let rango = undefined;
714
+ const httpService = () => {
715
+ if (rango) return rango;
716
+ rango = new RangoClient(getConfig('API_KEY'));
717
+ return rango;
718
+ };
766
719
 
767
720
  const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
768
721
  const DEFAULT_SLIPPAGE = 1;
@@ -780,7 +733,7 @@ const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set =>
780
733
  loadingStatus: 'loading',
781
734
  fetchMeta: async () => {
782
735
  try {
783
- const response = await httpService.getAllMetadata();
736
+ const response = await httpService().getAllMetadata();
784
737
  const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
785
738
  const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
786
739
  response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
@@ -800,6 +753,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*
800
753
  slippage: DEFAULT_SLIPPAGE,
801
754
  customSlippage: null,
802
755
  infiniteApprove: false,
756
+ affiliateRef: null,
803
757
  disabledLiquiditySources: [],
804
758
  theme: 'auto',
805
759
  setSlippage: slippage => set(() => ({
@@ -808,6 +762,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*
808
762
  setCustomSlippage: customSlippage => set(() => ({
809
763
  customSlippage: customSlippage
810
764
  })),
765
+ setAffiliateRef: affiliateRef => set(() => ({
766
+ affiliateRef
767
+ })),
811
768
  toggleAllLiquiditySources: () => set(state => {
812
769
  const {
813
770
  swappers
@@ -858,7 +815,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
858
815
  }));
859
816
  accounts.forEach(async account => {
860
817
  try {
861
- const response = await httpService.getWalletsDetails([{
818
+ const response = await httpService().getWalletsDetails([{
862
819
  address: account.address,
863
820
  blockchain: account.chain
864
821
  }]);
@@ -1011,7 +968,6 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
1011
968
  toToken: token
1012
969
  })),
1013
970
  setInputAmount: amount => {
1014
- console.log(amount, typeof amount);
1015
971
  set(state => ({
1016
972
  inputAmount: amount,
1017
973
  ...(!amount && {
@@ -1064,7 +1020,17 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
1064
1020
  sourceTokens: sortedSourceTokens,
1065
1021
  destinationTokens: sortedDestinationTokens
1066
1022
  });
1067
- }
1023
+ },
1024
+ switchFromAndTo: () => set(state => ({
1025
+ fromChain: state.toChain,
1026
+ fromToken: state.toToken,
1027
+ toChain: state.fromChain,
1028
+ toToken: state.fromToken,
1029
+ sourceTokens: state.destinationTokens,
1030
+ destinationTokens: state.sourceTokens,
1031
+ inputAmount: state.outputAmount?.toString() || '',
1032
+ inputUsdValue: getUsdValue(state.toToken, state.outputAmount?.toString() || '')
1033
+ }))
1068
1034
  }))));
1069
1035
  const bestRoute = (bestRouteStore, settingsStore) => {
1070
1036
  let abortController = null;
@@ -1077,20 +1043,21 @@ const bestRoute = (bestRouteStore, settingsStore) => {
1077
1043
  const {
1078
1044
  slippage,
1079
1045
  customSlippage,
1080
- disabledLiquiditySources
1046
+ disabledLiquiditySources,
1047
+ affiliateRef
1081
1048
  } = settingsStore.getState();
1082
1049
  if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
1083
1050
  abortController?.abort();
1084
1051
  abortController = new AbortController();
1085
1052
  const userSlippage = !!customSlippage ? customSlippage : slippage;
1086
- const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
1053
+ const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false, affiliateRef);
1087
1054
  if (!bestRouteStore.getState().loading) bestRouteStore.setState({
1088
1055
  loading: true,
1089
1056
  bestRoute: null,
1090
1057
  outputAmount: null,
1091
1058
  outputUsdValue: new BigNumber(0)
1092
1059
  });
1093
- httpService.getBestRoute(requestBody, {
1060
+ httpService().getBestRoute(requestBody, {
1094
1061
  signal: abortController.signal
1095
1062
  }).then(res => {
1096
1063
  const {
@@ -1117,7 +1084,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
1117
1084
  inputAmount,
1118
1085
  inputUsdValue
1119
1086
  } = useBestRouteStore.getState();
1120
- if (!inputAmount || inputAmount === '0') return;
1087
+ if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0)) return;
1121
1088
  if (tokensAreEqual(fromToken, toToken)) return bestRouteStore.setState({
1122
1089
  loading: false,
1123
1090
  bestRoute: null,
@@ -1139,17 +1106,26 @@ const bestRoute = (bestRouteStore, settingsStore) => {
1139
1106
  toToken: state.toToken,
1140
1107
  inputAmount: state.inputAmount
1141
1108
  }), bestRouteParamsListener, {
1142
- equalityFn: (prevState, state) => {
1143
- if (isRouteParametersChanged(prevState, state)) return false;else return true;
1109
+ equalityFn: (prevState, currentState) => {
1110
+ if (isRouteParametersChanged({
1111
+ store: 'bestRoute',
1112
+ prevState,
1113
+ currentState
1114
+ })) return false;else return true;
1144
1115
  }
1145
1116
  });
1146
1117
  useSettingsStore.subscribe(state => ({
1147
1118
  slippage: state.slippage,
1148
1119
  customSlippage: state.customSlippage,
1149
- disabledLiquiditySources: state.disabledLiquiditySources
1120
+ disabledLiquiditySources: state.disabledLiquiditySources,
1121
+ infiniteApprove: state.infiniteApprove
1150
1122
  }), bestRouteParamsListener, {
1151
- equalityFn: (prevState, state) => {
1152
- if (isRouteParametersChanged(prevState, state)) return false;else return true;
1123
+ equalityFn: (prevState, currentState) => {
1124
+ if (isRouteParametersChanged({
1125
+ store: 'settings',
1126
+ prevState,
1127
+ currentState
1128
+ })) return false;else return true;
1153
1129
  }
1154
1130
  });
1155
1131
  return {
@@ -1314,6 +1290,20 @@ function UpdateUrl() {
1314
1290
  return null;
1315
1291
  }
1316
1292
 
1293
+ function PercentageChange(props) {
1294
+ const {
1295
+ inputUsdValue,
1296
+ outputUsdValue
1297
+ } = props;
1298
+ if (!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)) return null;
1299
+ const percentageChange = getPercentageChange(inputUsdValue.toNumber(), outputUsdValue.toNumber());
1300
+ const showPercentageChange = percentageChange?.lt(0);
1301
+ return React.createElement(React.Fragment, null, showPercentageChange && React.createElement(Typography, {
1302
+ variant: "caption",
1303
+ color: "$error500"
1304
+ }, `(${numberToString(percentageChange, 0, 2)}%)`));
1305
+ }
1306
+
1317
1307
  const Box = /*#__PURE__*/styled('div', {
1318
1308
  display: 'flex',
1319
1309
  flexDirection: 'column',
@@ -1357,12 +1347,15 @@ const Container = /*#__PURE__*/styled('div', {
1357
1347
  '.amount': {
1358
1348
  width: '30%'
1359
1349
  }
1350
+ },
1351
+ '.output-usd': {
1352
+ display: 'flex',
1353
+ div: {
1354
+ display: 'flex',
1355
+ paddingLeft: '$8'
1356
+ }
1360
1357
  }
1361
1358
  });
1362
- const StyledImage = /*#__PURE__*/styled('img', {
1363
- width: '$24',
1364
- maxHeight: '$24'
1365
- });
1366
1359
  const Options = /*#__PURE__*/styled('div', {
1367
1360
  display: 'flex',
1368
1361
  justifyContent: 'flex-end',
@@ -1441,10 +1434,15 @@ function TokenInfo(props) {
1441
1434
  type: "primary",
1442
1435
  variant: "ghost",
1443
1436
  size: "compact"
1444
- }, t('Max')))) : React.createElement(Typography, {
1437
+ }, t('Max')))) : React.createElement("div", {
1438
+ className: "output-usd"
1439
+ }, React.createElement(PercentageChange, {
1440
+ inputUsdValue: inputUsdValue,
1441
+ outputUsdValue: props.outputUsdValue
1442
+ }), React.createElement("div", null, React.createElement(Typography, {
1445
1443
  variant: "caption",
1446
1444
  color: "neutrals600"
1447
- }, `$${numberToString(props.outputUsdValue)}`)), React.createElement("div", {
1445
+ }, `$${numberToString(props.outputUsdValue)}`)))), React.createElement("div", {
1448
1446
  className: "form"
1449
1447
  }, React.createElement(Button, {
1450
1448
  className: "selectors",
@@ -1454,8 +1452,9 @@ function TokenInfo(props) {
1454
1452
  variant: "outlined",
1455
1453
  disabled: loadingStatus === 'failed',
1456
1454
  loading: loadingStatus === 'loading',
1457
- prefix: loadingStatus === 'success' && chain ? React.createElement(StyledImage, {
1458
- src: chain.logo
1455
+ prefix: loadingStatus === 'success' && chain ? React.createElement(Image, {
1456
+ src: chain.logo,
1457
+ size: 24
1459
1458
  }) : React.createElement(ImagePlaceholder, null),
1460
1459
  suffix: ItemSuffix,
1461
1460
  align: "start",
@@ -1470,8 +1469,9 @@ function TokenInfo(props) {
1470
1469
  variant: "outlined",
1471
1470
  disabled: loadingStatus === 'failed' || type === 'From' && !fromChain || type === 'To' && !toChain,
1472
1471
  loading: loadingStatus === 'loading',
1473
- prefix: loadingStatus === 'success' && token ? React.createElement(StyledImage, {
1474
- src: token.image
1472
+ prefix: loadingStatus === 'success' && token ? React.createElement(Image, {
1473
+ src: token.image,
1474
+ size: 24
1475
1475
  }) : React.createElement(ImagePlaceholder, null),
1476
1476
  suffix: ItemSuffix,
1477
1477
  size: "large",
@@ -1616,7 +1616,8 @@ function HeaderButtons(props) {
1616
1616
  onClick: onClickRefresh,
1617
1617
  disabled: !onClickRefresh
1618
1618
  }, React.createElement(RetryIcon, {
1619
- size: 24
1619
+ size: 24,
1620
+ disabled: !onClickRefresh
1620
1621
  }))), React.createElement(Tooltip, {
1621
1622
  content: "Transactions History"
1622
1623
  }, React.createElement(Button, {
@@ -1656,10 +1657,7 @@ const Alerts = /*#__PURE__*/styled('div', {
1656
1657
  width: '100%',
1657
1658
  paddingTop: '$16'
1658
1659
  });
1659
- function Home(props) {
1660
- const {
1661
- title = 'SWAP'
1662
- } = props;
1660
+ function Home() {
1663
1661
  const isRouterInContext = useInRouterContext();
1664
1662
  const navigate = useNavigate();
1665
1663
  const [count, setCount] = useState(0);
@@ -1667,10 +1665,6 @@ function Home(props) {
1667
1665
  const fromToken = useBestRouteStore.use.fromToken();
1668
1666
  const toChain = useBestRouteStore.use.toChain();
1669
1667
  const toToken = useBestRouteStore.use.toToken();
1670
- const setFromChain = useBestRouteStore.use.setFromChain();
1671
- const setFromToken = useBestRouteStore.use.setFromToken();
1672
- const setToChain = useBestRouteStore.use.setToChain();
1673
- const setToToken = useBestRouteStore.use.setToToken();
1674
1668
  const setInputAmount = useBestRouteStore.use.setInputAmount();
1675
1669
  const inputUsdValue = useBestRouteStore.use.inputUsdValue();
1676
1670
  const inputAmount = useBestRouteStore.use.inputAmount();
@@ -1683,14 +1677,7 @@ function Home(props) {
1683
1677
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
1684
1678
  const accounts = useWalletsStore.use.accounts();
1685
1679
  const setCurrentPage = useUiStore.use.setCurrentPage();
1686
- const swithFromAndTo = () => {
1687
- setFromChain(toChain);
1688
- setFromToken(toToken);
1689
- setToChain(fromChain);
1690
- setToToken(fromToken);
1691
- setInputAmount(outputAmount?.toString() || '');
1692
- setCount(prev => prev + 1);
1693
- };
1680
+ const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
1694
1681
  const errorMessage = loadingMetaStatus === 'failed' ? errorMessages.genericServerError : bestRouteError;
1695
1682
  const needsToWarnEthOnPath = false;
1696
1683
  const showBestRoute = inputAmount && (!!bestRoute || fetchingBestRoute || bestRouteError);
@@ -1711,7 +1698,7 @@ function Home(props) {
1711
1698
  return setCurrentPage.bind(null, '');
1712
1699
  }, []);
1713
1700
  return React.createElement(Container$2, null, React.createElement(Header$1, {
1714
- title: title,
1701
+ title: "SWAP",
1715
1702
  suffix: React.createElement(HeaderButtons, {
1716
1703
  onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
1717
1704
  })
@@ -1723,7 +1710,10 @@ function Home(props) {
1723
1710
  inputAmount: inputAmount
1724
1711
  }), React.createElement(SwitchButtonContainer, null, React.createElement(Button, {
1725
1712
  variant: "ghost",
1726
- onClick: swithFromAndTo
1713
+ onClick: () => {
1714
+ switchFromAndTo();
1715
+ setCount(prev => prev + 1);
1716
+ }
1727
1717
  }, React.createElement(VerticalSwapIcon, {
1728
1718
  size: 32
1729
1719
  }), isRouterInContext && React.createElement(SwithFromAndTo, {
@@ -1769,8 +1759,7 @@ function Home(props) {
1769
1759
 
1770
1760
  const Route = _ref => {
1771
1761
  let {
1772
- children,
1773
- ...props
1762
+ children
1774
1763
  } = _ref;
1775
1764
  const location = useLocation$1();
1776
1765
  const navigate = useNavigate$1();
@@ -1781,7 +1770,7 @@ const Route = _ref => {
1781
1770
  });
1782
1771
  ref.current = false;
1783
1772
  }, []);
1784
- if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home, Object.assign({}, props));
1773
+ if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home, null);
1785
1774
  return React.createElement(React.Fragment, null, " ", children);
1786
1775
  };
1787
1776
  function AppRouter(_ref2) {
@@ -1853,7 +1842,10 @@ const Container$3 = /*#__PURE__*/styled('div', {
1853
1842
  display: 'flex',
1854
1843
  justifyContent: 'space-between',
1855
1844
  alignItems: 'center',
1856
- minHeight: '32px'
1845
+ minHeight: '32px',
1846
+ '.usd-value': {
1847
+ paddingLeft: '$8'
1848
+ }
1857
1849
  },
1858
1850
  '.form': {
1859
1851
  display: 'flex',
@@ -1872,10 +1864,6 @@ const Container$3 = /*#__PURE__*/styled('div', {
1872
1864
  }
1873
1865
  }
1874
1866
  });
1875
- const StyledImage$1 = /*#__PURE__*/styled('img', {
1876
- width: '$24',
1877
- maxHeight: '$24'
1878
- });
1879
1867
  const ImagePlaceholder$1 = /*#__PURE__*/styled('span', {
1880
1868
  width: '24px',
1881
1869
  height: '24px',
@@ -1898,7 +1886,8 @@ function TokenPreview(props) {
1898
1886
  const {
1899
1887
  chain,
1900
1888
  token,
1901
- loadingStatus
1889
+ loadingStatus,
1890
+ percentageChange
1902
1891
  } = props;
1903
1892
  const {
1904
1893
  t
@@ -1920,17 +1909,19 @@ function TokenPreview(props) {
1920
1909
  }, React.createElement(Typography, {
1921
1910
  variant: "body2",
1922
1911
  color: "neutrals800"
1923
- }, props.label), props.usdValue && React.createElement(Typography, {
1912
+ }, props.label), React.createElement("div", null, percentageChange, props.usdValue && React.createElement(Typography, {
1924
1913
  variant: "caption",
1925
- color: "neutrals600"
1926
- }, `$${numberToString(props.usdValue)}`)), React.createElement("div", {
1914
+ color: "neutrals600",
1915
+ className: "usd-value"
1916
+ }, `$${numberToString(props.usdValue)}`))), React.createElement("div", {
1927
1917
  className: "form"
1928
1918
  }, React.createElement(Button, {
1929
1919
  className: "selectors",
1930
1920
  variant: "outlined",
1931
1921
  loading: loadingStatus === 'loading',
1932
- prefix: loadingStatus === 'success' && chain ? React.createElement(StyledImage$1, {
1933
- src: chain.logo
1922
+ prefix: loadingStatus === 'success' && chain ? React.createElement(Image, {
1923
+ src: chain.logo,
1924
+ size: 24
1934
1925
  }) : React.createElement(ImagePlaceholder$1, null),
1935
1926
  suffix: ItemSuffix,
1936
1927
  align: "start",
@@ -1941,8 +1932,9 @@ function TokenPreview(props) {
1941
1932
  className: "selectors",
1942
1933
  variant: "outlined",
1943
1934
  loading: loadingStatus === 'loading',
1944
- prefix: loadingStatus === 'success' && token ? React.createElement(StyledImage$1, {
1945
- src: token.image
1935
+ prefix: loadingStatus === 'success' && token ? React.createElement(Image, {
1936
+ src: token.image,
1937
+ size: 24
1946
1938
  }) : React.createElement(ImagePlaceholder$1, null),
1947
1939
  suffix: ItemSuffix,
1948
1940
  size: "large",
@@ -2020,6 +2012,7 @@ function useConfirmSwap() {
2020
2012
  const initialRoute = useBestRouteStore.use.bestRoute();
2021
2013
  const setBestRoute = useBestRouteStore.use.setBestRoute();
2022
2014
  const inputUsdValue = useBestRouteStore.use.inputUsdValue();
2015
+ const affiliateRef = useSettingsStore.use.affiliateRef();
2023
2016
  const accounts = useWalletsStore.use.accounts();
2024
2017
  const selectedWallets = useWalletsStore.use.selectedWallets();
2025
2018
  const meta = useMetaStore.use.meta();
@@ -2053,16 +2046,15 @@ function useConfirmSwap() {
2053
2046
  proceedAnywayRef.current = false;
2054
2047
  if (confiremedRouteRef.current) {
2055
2048
  const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
2056
- //@ts-ignore
2057
2049
  return newSwap;
2058
2050
  }
2059
2051
  return;
2060
2052
  }
2061
2053
  abortControllerRef.current = new AbortController();
2062
2054
  setLoading(true);
2063
- const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
2055
+ const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true, affiliateRef);
2064
2056
  try {
2065
- const confiremedRoute = await httpService.getBestRoute(requestBody, {
2057
+ const confiremedRoute = await httpService().getBestRoute(requestBody, {
2066
2058
  signal: abortControllerRef.current?.signal
2067
2059
  });
2068
2060
  abortControllerRef.current = null;
@@ -2116,7 +2108,6 @@ function useConfirmSwap() {
2116
2108
  disabledSwappersGroups: disabledLiquiditySources
2117
2109
  };
2118
2110
  const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
2119
- //@ts-ignore
2120
2111
  return newSwap;
2121
2112
  } else if (!proceedAnywayRef.current) {
2122
2113
  proceedAnywayRef.current = true;
@@ -2302,6 +2293,8 @@ function ConfirmSwapPage() {
2302
2293
  const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
2303
2294
  const slippage = useSettingsStore.use.slippage();
2304
2295
  const customSlippage = useSettingsStore.use.customSlippage();
2296
+ const inputUsdValue = useBestRouteStore.use.inputUsdValue();
2297
+ const outputUsdValue = useBestRouteStore.use.outputUsdValue();
2305
2298
  const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
2306
2299
  const {
2307
2300
  manager
@@ -2332,7 +2325,10 @@ function ConfirmSwapPage() {
2332
2325
  getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
2333
2326
  };
2334
2327
  const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
2335
- return React.createElement(ConfirmSwap, {
2328
+ return React.createElement(ConfirmSwap
2329
+ // @ts-ignore
2330
+ , {
2331
+ // @ts-ignore
2336
2332
  requiredWallets: getRequiredChains(bestRoute),
2337
2333
  selectableWallets: selectableWallets,
2338
2334
  onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
@@ -2341,7 +2337,9 @@ function ConfirmSwapPage() {
2341
2337
  if (swap) {
2342
2338
  manager?.create('swap', {
2343
2339
  swapDetails: swap
2344
- }, {
2340
+ },
2341
+ // @ts-ignore
2342
+ {
2345
2343
  id: swap.requestId
2346
2344
  });
2347
2345
  setSelectedSwap(swap.requestId);
@@ -2364,7 +2362,7 @@ function ConfirmSwapPage() {
2364
2362
  symbol: firstStep?.from.symbol || '',
2365
2363
  image: firstStep?.from.logo || ''
2366
2364
  },
2367
- usdValue: calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice),
2365
+ usdValue: inputUsdValue,
2368
2366
  amount: fromAmount,
2369
2367
  label: t('From'),
2370
2368
  loadingStatus: bestRouteloadingStatus
@@ -2380,10 +2378,14 @@ function ConfirmSwapPage() {
2380
2378
  symbol: lastStep?.to.symbol || '',
2381
2379
  image: lastStep?.to.logo || ''
2382
2380
  },
2383
- usdValue: calcOutputUsdValue(toAmount, lastStep?.to.usdPrice),
2381
+ usdValue: outputUsdValue,
2384
2382
  amount: toAmount,
2385
2383
  label: t('To'),
2386
- loadingStatus: bestRouteloadingStatus
2384
+ loadingStatus: bestRouteloadingStatus,
2385
+ percentageChange: React.createElement(PercentageChange, {
2386
+ inputUsdValue: inputUsdValue,
2387
+ outputUsdValue: outputUsdValue
2388
+ })
2387
2389
  })),
2388
2390
  previewRoutes: React.createElement(RoutesOverview, {
2389
2391
  routes: bestRoute,
@@ -2495,7 +2497,7 @@ function LiquiditySourcePage(_ref) {
2495
2497
  });
2496
2498
  return React.createElement(LiquiditySourcesSelector, {
2497
2499
  toggleAll: toggleAllLiquiditySources,
2498
- list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
2500
+ list: supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups,
2499
2501
  onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
2500
2502
  onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
2501
2503
  loadingStatus: loadingMetaStatus
@@ -2507,7 +2509,7 @@ function SelectChainPage(props) {
2507
2509
  type,
2508
2510
  supportedChains
2509
2511
  } = props;
2510
- const blockchains = supportedChains === 'all' ? useMetaStore.use.meta().blockchains : supportedChains;
2512
+ const blockchains = supportedChains ? useMetaStore.use.meta().blockchains.filter(chain => supportedChains.includes(chain.name)) : useMetaStore.use.meta().blockchains;
2511
2513
  const loadingStatus = useMetaStore.use.loadingStatus();
2512
2514
  const fromChain = useBestRouteStore.use.fromChain();
2513
2515
  const toChain = useBestRouteStore.use.toChain();
@@ -2539,8 +2541,8 @@ function SelectTokenPage(props) {
2539
2541
  } = props;
2540
2542
  const sourceTokens = useBestRouteStore.use.sourceTokens();
2541
2543
  const destinationTokens = useBestRouteStore.use.destinationTokens();
2542
- const supportedSourceTokens = supportedTokens === 'all' ? sourceTokens : sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token)));
2543
- const supportedDestinationTokens = supportedTokens === 'all' ? destinationTokens : destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token)));
2544
+ const supportedSourceTokens = supportedTokens ? sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : sourceTokens;
2545
+ const supportedDestinationTokens = supportedTokens ? destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : destinationTokens;
2544
2546
  const fromToken = useBestRouteStore.use.fromToken();
2545
2547
  const toToken = useBestRouteStore.use.toToken();
2546
2548
  const setFromToken = useBestRouteStore.use.setFromToken();
@@ -2593,8 +2595,8 @@ function SettingsPage(_ref) {
2593
2595
  }
2594
2596
  }
2595
2597
  });
2596
- supportedSwappers !== 'all' && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0);
2597
- const supportedUniqueSwappersGroups = supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups;
2598
+ supportedSwappers && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0);
2599
+ const supportedUniqueSwappersGroups = supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups;
2598
2600
  return React.createElement(Settings, {
2599
2601
  slippages: SLIPPAGES,
2600
2602
  selectedSlippage: slippage,
@@ -2647,7 +2649,7 @@ function WalletsPage(_ref) {
2647
2649
  getWalletInfo,
2648
2650
  connect
2649
2651
  } = useWallets();
2650
- const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets);
2652
+ const wallets = getlistWallet(state, getWalletInfo, supportedWallets || Object.values(WalletType));
2651
2653
  const walletsRef = useRef();
2652
2654
  let sortedWallets = detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
2653
2655
  sortedWallets = sortWalletsBasedOnState(sortedWallets);
@@ -2856,7 +2858,7 @@ function SwapDetailsPage() {
2856
2858
  }), React.createElement(TokenPreview, {
2857
2859
  chain: {
2858
2860
  displayName: lastStep?.toBlockchain || '',
2859
- // @ts-ignore
2861
+ //@ts-ignore
2860
2862
  logo: lastStep?.toBlockchainLogo || ''
2861
2863
  },
2862
2864
  token: {
@@ -2868,7 +2870,6 @@ function SwapDetailsPage() {
2868
2870
  loadingStatus: 'success'
2869
2871
  })),
2870
2872
  //todo: move PendingSwap type to rango-types
2871
- //@ts-ignore
2872
2873
  pendingSwap: swap,
2873
2874
  onCopy: handleCopy,
2874
2875
  isCopied: isCopied,
@@ -2898,48 +2899,44 @@ function SwapDetailsPage() {
2898
2899
  const getAbsolutePath = path => path.replace('/', '');
2899
2900
  function AppRoutes(props) {
2900
2901
  const {
2901
- configs
2902
+ config
2902
2903
  } = props;
2903
2904
  return useRoutes([{
2904
2905
  path: getAbsolutePath(navigationRoutes.home),
2905
- element: React.createElement(Home, {
2906
- title: configs?.title,
2907
- titleSize: configs?.titleSize,
2908
- titleWeight: configs?.titleWeight
2909
- })
2906
+ element: React.createElement(Home, null)
2910
2907
  }, {
2911
2908
  path: getAbsolutePath(navigationRoutes.fromChain),
2912
2909
  element: React.createElement(SelectChainPage, {
2913
2910
  type: "from",
2914
- supportedChains: configs?.fromChains || 'all'
2911
+ supportedChains: config?.from?.blockchains
2915
2912
  })
2916
2913
  }, {
2917
2914
  path: getAbsolutePath(navigationRoutes.toChain),
2918
2915
  element: React.createElement(SelectChainPage, {
2919
2916
  type: "to",
2920
- supportedChains: configs?.toChains || 'all'
2917
+ supportedChains: config?.to?.blockchains
2921
2918
  })
2922
2919
  }, {
2923
2920
  path: getAbsolutePath(navigationRoutes.fromToken),
2924
2921
  element: React.createElement(SelectTokenPage, {
2925
2922
  type: "from",
2926
- supportedTokens: configs?.fromTokens || 'all'
2923
+ supportedTokens: config?.from?.tokens
2927
2924
  })
2928
2925
  }, {
2929
2926
  path: getAbsolutePath(navigationRoutes.toToken),
2930
2927
  element: React.createElement(SelectTokenPage, {
2931
2928
  type: "to",
2932
- supportedTokens: configs?.toTokens || 'all'
2929
+ supportedTokens: config?.to?.tokens
2933
2930
  })
2934
2931
  }, {
2935
2932
  path: getAbsolutePath(navigationRoutes.settings),
2936
2933
  element: React.createElement(SettingsPage, {
2937
- supportedSwappers: configs?.liquiditySources || 'all'
2934
+ supportedSwappers: config?.liquiditySources
2938
2935
  })
2939
2936
  }, {
2940
2937
  path: getAbsolutePath(navigationRoutes.liquiditySources),
2941
2938
  element: React.createElement(LiquiditySourcePage, {
2942
- supportedSwappers: configs?.liquiditySources || 'all'
2939
+ supportedSwappers: config?.liquiditySources
2943
2940
  })
2944
2941
  }, {
2945
2942
  path: getAbsolutePath(navigationRoutes.swaps),
@@ -2950,8 +2947,8 @@ function AppRoutes(props) {
2950
2947
  }, {
2951
2948
  path: getAbsolutePath(navigationRoutes.wallets),
2952
2949
  element: React.createElement(WalletsPage, {
2953
- supportedWallets: configs?.wallets || 'all',
2954
- multiWallets: typeof configs?.multiWallets === 'undefined' ? true : configs.multiWallets
2950
+ supportedWallets: config?.wallets,
2951
+ multiWallets: typeof config?.multiWallets === 'undefined' ? true : config.multiWallets
2955
2952
  })
2956
2953
  }, {
2957
2954
  path: getAbsolutePath(navigationRoutes.confirmSwap),
@@ -2967,16 +2964,14 @@ const Header = /*#__PURE__*/styled('div', {
2967
2964
  display: 'flex'
2968
2965
  }
2969
2966
  });
2970
- const WalletImage = /*#__PURE__*/styled('img', {
2971
- width: '$24',
2972
- height: '$24',
2967
+ const WalletImageContainer = /*#__PURE__*/styled('div', {
2973
2968
  marginLeft: -15,
2974
2969
  marginRight: '$6',
2975
2970
  borderRadius: '99999px'
2976
2971
  });
2977
2972
  function Layout(_ref) {
2978
2973
  let {
2979
- configs
2974
+ config
2980
2975
  } = _ref;
2981
2976
  const navigate = useNavigate();
2982
2977
  const {
@@ -2988,11 +2983,16 @@ function Layout(_ref) {
2988
2983
  getWalletInfo
2989
2984
  } = useWallets();
2990
2985
  const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
2986
+ const {
2987
+ blockchains,
2988
+ tokens
2989
+ } = useMetaStore.use.meta();
2991
2990
  const setFromChain = useBestRouteStore.use.setFromChain();
2992
2991
  const setFromToken = useBestRouteStore.use.setFromToken();
2993
2992
  const setToChain = useBestRouteStore.use.setToChain();
2994
2993
  const setToToken = useBestRouteStore.use.setToToken();
2995
2994
  const setInputAmount = useBestRouteStore.use.setInputAmount();
2995
+ const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
2996
2996
  const totalBalance = calculateWalletUsdValue(balances);
2997
2997
  const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
2998
2998
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
@@ -3001,22 +3001,23 @@ function Layout(_ref) {
3001
3001
  t
3002
3002
  } = useTranslation();
3003
3003
  useEffect(() => {
3004
- setToChain(configs?.toChain || null);
3005
- setToToken(configs?.toToken || null);
3006
- }, [configs?.toChain, configs?.toToken]);
3004
+ const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
3005
+ const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
3006
+ setToChain(chain || null);
3007
+ setToToken(token || null);
3008
+ }, [config?.to?.token, config?.to?.blockchain]);
3007
3009
  useEffect(() => {
3008
- setInputAmount(configs?.fromAmount?.toString() || '');
3009
- }, [configs?.fromAmount]);
3010
+ setInputAmount(config?.amount?.toString() || '');
3011
+ }, [config?.amount]);
3010
3012
  useEffect(() => {
3011
- setFromToken(configs?.fromToken || null);
3012
- setFromChain(configs?.fromChain || null);
3013
- }, [configs?.fromToken, configs?.fromChain]);
3013
+ const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
3014
+ const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
3015
+ setFromChain(chain || null);
3016
+ setFromToken(token || null);
3017
+ }, [config?.from?.token, config?.from?.blockchain]);
3014
3018
  useEffect(() => {
3015
- setToChain(null);
3016
- setFromChain(null);
3017
- setFromToken(null);
3018
- setToToken(null);
3019
- }, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
3019
+ setAffiliateRef(config?.affiliateRef || null);
3020
+ }, [config?.affiliateRef]);
3020
3021
  return React.createElement(React.Fragment, null, React.createElement(Header, null, React.createElement(Button, {
3021
3022
  size: "small",
3022
3023
  suffix: React.createElement(AddWalletIcon, {
@@ -3029,15 +3030,17 @@ function Layout(_ref) {
3029
3030
  onClick: () => {
3030
3031
  if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
3031
3032
  }
3032
- }, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React.createElement(WalletImage, {
3033
- key: index,
3034
- src: walletImage
3035
- })) : React.createElement(React.Fragment, null), React.createElement("div", {
3033
+ }, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React.createElement(WalletImageContainer, {
3034
+ key: index
3035
+ }, React.createElement(Image, {
3036
+ src: walletImage,
3037
+ size: 24
3038
+ }))) : React.createElement(React.Fragment, null), React.createElement("div", {
3036
3039
  className: "balance"
3037
3040
  }, React.createElement(Typography, {
3038
3041
  variant: "body2"
3039
3042
  }, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
3040
- configs: configs
3043
+ config: config
3041
3044
  }));
3042
3045
  }
3043
3046
 
@@ -3080,17 +3083,20 @@ function usePrevious(value) {
3080
3083
 
3081
3084
  function useTheme(_ref) {
3082
3085
  let {
3083
- primary = '#5FA425',
3084
- background = '#fff',
3085
- foreground = '#000',
3086
- error = '#FF0000',
3087
- warning = '#F5A623',
3088
- success = '#0070F3',
3086
+ colors: themeColors,
3089
3087
  fontFamily = 'Robot',
3090
- borderRadius = 8
3088
+ borderRadius = 8,
3089
+ mode = 'auto'
3091
3090
  } = _ref;
3092
3091
  const theme = useSettingsStore.use.theme();
3093
3092
  const fetchMeta = useMetaStore.use.fetchMeta();
3093
+ const setTheme = useSettingsStore.use.setTheme();
3094
+ const primary = themeColors?.primary || '#5FA425',
3095
+ background = themeColors?.background || '#fff',
3096
+ foreground = themeColors?.foreground || '#000',
3097
+ error = themeColors?.error || '#FF0000',
3098
+ warning = themeColors?.warning || '#F5A623',
3099
+ success = themeColors?.success || '#0070F3';
3094
3100
  const colors = {
3095
3101
  neutrals200: '#FAFAFA',
3096
3102
  neutrals300: '#f2f2f2',
@@ -3132,6 +3138,9 @@ function useTheme(_ref) {
3132
3138
  colors,
3133
3139
  radii: {
3134
3140
  5: `${borderRadius}px`
3141
+ },
3142
+ shadows: {
3143
+ s: '0px 3px 5px 3px #f0f2f5, 0px 6px 10px 3px #f0f2f5, 0px 1px 18px 3px #f0f2f5'
3135
3144
  }
3136
3145
  });
3137
3146
  const customeDarkTheme = createTheme({
@@ -3150,6 +3159,9 @@ function useTheme(_ref) {
3150
3159
  },
3151
3160
  radii: {
3152
3161
  5: `${borderRadius}px`
3162
+ },
3163
+ shadows: {
3164
+ s: '0px 3px 5px 3px #222, 0px 6px 10px 3px #222, 0px 1px 18px 3px #222'
3153
3165
  }
3154
3166
  });
3155
3167
  const [OSTheme, setOSTheme] = useState(customeLightTheme);
@@ -3168,6 +3180,9 @@ function useTheme(_ref) {
3168
3180
  window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
3169
3181
  };
3170
3182
  }, []);
3183
+ useEffect(() => {
3184
+ if (mode !== 'auto') setTheme(mode);
3185
+ }, [mode]);
3171
3186
  const prevFont = usePrevious(fontFamily);
3172
3187
  useLayoutEffect(() => {
3173
3188
  const {
@@ -3272,6 +3287,11 @@ function QueueManager(props) {
3272
3287
  canSwitchNetworkTo,
3273
3288
  getWalletInfo
3274
3289
  } = useWallets();
3290
+ const swapQueueDef = useMemo(() => {
3291
+ return makeQueueDefinition({
3292
+ API_KEY: getConfig('API_KEY')
3293
+ });
3294
+ }, []);
3275
3295
  const {
3276
3296
  blockchains
3277
3297
  } = useMetaStore.use.meta();
@@ -3332,29 +3352,27 @@ function QueueManager(props) {
3332
3352
 
3333
3353
  const SwapBox = _ref => {
3334
3354
  let {
3335
- configs
3355
+ config
3336
3356
  } = _ref;
3337
3357
  globalStyles();
3338
- globalFont(configs?.fontFamily || 'Roboto');
3358
+ globalFont(config?.theme?.fontFamily || 'Roboto');
3339
3359
  const {
3340
3360
  activeTheme
3341
3361
  } = useTheme({
3342
- ...configs.colors,
3343
- borderRadius: configs?.borderRadius,
3344
- fontFamily: configs?.fontFamily
3362
+ ...config?.theme
3345
3363
  });
3346
3364
  const {
3347
3365
  blockchains
3348
3366
  } = useMetaStore.use.meta();
3349
3367
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
3350
3368
  const connectWallet = useWalletsStore.use.connectWallet();
3351
- const setTheme = useSettingsStore.use.setTheme();
3352
3369
  const {
3353
3370
  changeLanguage
3354
3371
  } = useSelectLanguage();
3355
3372
  const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
3356
3373
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = useState('');
3357
3374
  const [disconnectedWallet, setDisconnectedWallet] = useState();
3375
+ const currentPage = useUiStore.use.currentPage();
3358
3376
  const evmBasedChainNames = blockchains.filter(isEvmBlockchain$1).map(chain => chain.name);
3359
3377
  const onUpdateState = (type, event, value, state, supportedChains) => {
3360
3378
  if (event === Events.ACCOUNTS) {
@@ -3379,19 +3397,16 @@ const SwapBox = _ref => {
3379
3397
  };
3380
3398
  let providers = allProviders();
3381
3399
  useEffect(() => {
3382
- if (configs.theme !== 'auto') setTheme(configs.theme);
3383
- }, [configs.theme]);
3384
- useEffect(() => {
3385
- const wallets = configs.wallets;
3400
+ const wallets = config?.wallets;
3386
3401
  clearConnectedWallet();
3387
- providers = wallets === 'all' ? allProviders() : allProviders().filter(provider => {
3402
+ providers = !wallets ? allProviders() : allProviders().filter(provider => {
3388
3403
  const type = provider.config.type;
3389
3404
  return wallets.find(w => w === type);
3390
3405
  });
3391
- }, [configs?.wallets]);
3406
+ }, [config?.wallets]);
3392
3407
  useEffect(() => {
3393
- changeLanguage(configs?.languege);
3394
- }, [configs?.languege]);
3408
+ changeLanguage(config?.language || 'en');
3409
+ }, [config?.language]);
3395
3410
  return React.createElement(Provider$1, {
3396
3411
  allBlockChains: blockchains,
3397
3412
  providers: providers,
@@ -3400,21 +3415,15 @@ const SwapBox = _ref => {
3400
3415
  id: "pageContainer",
3401
3416
  className: activeTheme
3402
3417
  }, React.createElement(QueueManager, null, React.createElement(SwapContainer, {
3403
- style: {
3404
- width: configs?.width || 'auto',
3405
- height: configs?.height || 'auto'
3406
- }
3418
+ fixedHeight: currentPage !== navigationRoutes.home
3407
3419
  }, React.createElement(AppRouter, {
3408
- title: configs.title,
3409
- titleSize: configs.titleSize,
3410
- titleWeight: configs.titleWeight,
3411
3420
  lastConnectedWallet: lastConnectedWalletWithNetwork,
3412
3421
  disconnectedWallet: disconnectedWallet,
3413
3422
  clearDisconnectedWallet: () => {
3414
3423
  setDisconnectedWallet(undefined);
3415
3424
  }
3416
3425
  }, React.createElement(Layout, {
3417
- configs: configs
3426
+ config: config
3418
3427
  }))))));
3419
3428
  };
3420
3429