@0xsquid/react-hooks 8.12.1-beta-arc.0 → 8.12.1-beta-arc.1

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 (36) hide show
  1. package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +0 -3
  2. package/dist/hooks/transaction/useArcFeeCheck.d.ts +5 -0
  3. package/dist/{index-BBJD55XX.js → index-8RIq6GyB.js} +127 -368
  4. package/dist/index-8RIq6GyB.js.map +1 -0
  5. package/dist/{index-CLzjMzS_.js → index-BVneqIL5.js} +128 -367
  6. package/dist/index-BVneqIL5.js.map +1 -0
  7. package/dist/{index.es-BiK_wjSb.js → index.es-Bm5GQH70.js} +2 -2
  8. package/dist/{index.es-BiK_wjSb.js.map → index.es-Bm5GQH70.js.map} +1 -1
  9. package/dist/{index.es-BVCh4tlV.js → index.es-CnV3EYrQ.js} +2 -2
  10. package/dist/{index.es-BVCh4tlV.js.map → index.es-CnV3EYrQ.js.map} +1 -1
  11. package/dist/index.esm.js +1 -1
  12. package/dist/index.js +1 -3
  13. package/dist/index.js.map +1 -1
  14. package/dist/{secretService-BZ06HTOJ.js → secretService-C6GiPeC8.js} +2 -2
  15. package/dist/{secretService-BZ06HTOJ.js.map → secretService-C6GiPeC8.js.map} +1 -1
  16. package/dist/{secretService-DkE9yz1o.js → secretService-D8ySaXvX.js} +2 -2
  17. package/dist/{secretService-DkE9yz1o.js.map → secretService-D8ySaXvX.js.map} +1 -1
  18. package/dist/services/internal/arcService.d.ts +5 -3
  19. package/dist/services/internal/assetsService.d.ts +2 -8
  20. package/dist/services/internal/configService.d.ts +3 -14
  21. package/dist/services/internal/estimateService.d.ts +2 -12
  22. package/dist/services/internal/tempoService.d.ts +0 -2
  23. package/dist/services/internal/walletService.d.ts +1 -1
  24. package/dist/{stellarService.client-fnyXRadt.js → stellarService.client-DkBWS3eX.js} +2 -2
  25. package/dist/{stellarService.client-fnyXRadt.js.map → stellarService.client-DkBWS3eX.js.map} +1 -1
  26. package/dist/{stellarService.client-DtA9zkRt.js → stellarService.client-IiUZ6NO6.js} +2 -2
  27. package/dist/{stellarService.client-DtA9zkRt.js.map → stellarService.client-IiUZ6NO6.js.map} +1 -1
  28. package/package.json +1 -1
  29. package/dist/index-BBJD55XX.js.map +0 -1
  30. package/dist/index-CLzjMzS_.js.map +0 -1
  31. package/dist/tests/arcWalletService.test.d.ts +0 -1
  32. package/dist/tests/useArcApproval.test.d.ts +0 -1
  33. package/dist/tests/useArcSendEstimate.test.d.ts +0 -1
  34. package/dist/tests/useNativeTokenForChain.test.d.ts +0 -1
  35. package/dist/tests/useSwapArcSelection.test.d.ts +0 -1
  36. /package/dist/tests/{arcConfigService.test.d.ts → sourceChainGas.test.d.ts} +0 -0
@@ -20965,24 +20965,6 @@ const isBitcoinAddressValid = (address) => {
20965
20965
  }
20966
20966
  };
20967
20967
 
20968
- const arcUsdcTokenAddress = "0x3600000000000000000000000000000000000000";
20969
- const isArcChain = (chainId) => chainId === CHAIN_IDS.ARC;
20970
- const isArcUsdcToken = (token) => isArcChain(token?.chainId) &&
20971
- token?.address.toLowerCase() === arcUsdcTokenAddress;
20972
- const isArcNativeToken = (token) => isArcChain(token?.chainId) &&
20973
- token?.address.toLowerCase() === nativeEvmTokenAddress;
20974
- const normalizeArcTokenAddress = (chainId, address) => isArcChain(chainId) && address?.toLowerCase() === nativeEvmTokenAddress
20975
- ? arcUsdcTokenAddress
20976
- : address;
20977
- const deduplicateArcBalances = (tokens) => {
20978
- const canonicalChains = new Set(tokens
20979
- .filter((token) => isArcChain(token.chainId) &&
20980
- token.address?.toLowerCase() === arcUsdcTokenAddress)
20981
- .map((token) => token.chainId));
20982
- return tokens.filter((token) => !(canonicalChains.has(token.chainId) &&
20983
- token.address?.toLowerCase() === nativeEvmTokenAddress));
20984
- };
20985
-
20986
20968
  function getCantonCommandId(memo) {
20987
20969
  return `canton-${memo}`;
20988
20970
  }
@@ -22219,7 +22201,7 @@ function sortAddressBook(a, b, selectedAddress) {
22219
22201
  return 0;
22220
22202
  }
22221
22203
  const calculateTotalUsdBalanceUSD = (tokens) => {
22222
- const totalUsd = deduplicateArcBalances(tokens).reduce((total, token) => {
22204
+ const totalUsd = tokens.reduce((total, token) => {
22223
22205
  const balance = parseFloat(token.balance);
22224
22206
  const usdPrice = token.usdPrice ?? 0;
22225
22207
  const balanceUsd = balance * usdPrice;
@@ -23031,36 +23013,22 @@ const getFirstAvailableChainId = (config, direction, chains = []) => {
23031
23013
  // if no initial chain ID is found in config, return the first available chain ID
23032
23014
  return availableChains.length > 0 ? availableChains[0].chainId : undefined;
23033
23015
  };
23034
- const fetchHighestBalanceToken = (fetchCachedBalance, chainId, selectableTokens, direction) => {
23016
+ const fetchHighestBalanceToken = (fetchCachedBalance, chainId) => {
23035
23017
  let address = undefined;
23036
23018
  if (fetchCachedBalance) {
23037
23019
  const queryCache = fetchCachedBalance?.queryClient?.getQueryCache();
23038
- const directionCache = isArcChain(chainId) && direction
23039
- ? queryCache?.find(keys().allTokensBalance(fetchCachedBalance.address, squidTypes.ChainType.EVM, direction))
23040
- : undefined;
23041
23020
  // get cached balance from key
23042
- const cache = directionCache?.state.data !== undefined
23043
- ? directionCache
23044
- : queryCache?.find(keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? squidTypes.ChainType.EVM : squidTypes.ChainType.COSMOS));
23045
- const cacheData = cache?.state.data;
23046
- const cacheResult = Array.isArray(cacheData)
23047
- ? cacheData
23048
- : isArcChain(chainId)
23049
- ? (cacheData?.tokens ?? [])
23050
- : [];
23021
+ const cache = queryCache?.find(keys().allTokensBalance(fetchCachedBalance?.address, !isNaN(Number(chainId)) ? squidTypes.ChainType.EVM : squidTypes.ChainType.COSMOS));
23022
+ // Parse result to TokenWithBalance[]
23023
+ const cacheResult = cache?.state.data ?? [];
23051
23024
  if (cacheResult.length > 0) {
23052
- const tokensWithBalance = deduplicateArcBalances(cacheResult).filter((t) => t.chainId === chainId &&
23053
- Number(t.balance) > 0 &&
23054
- (!selectableTokens ||
23055
- selectableTokens.some((token) => token.chainId === t.chainId &&
23056
- token.address.toLowerCase() ===
23057
- normalizeArcTokenAddress(t.chainId, t.address)?.toLowerCase())));
23025
+ const tokensWithBalance = cacheResult.filter((t) => t.chainId === chainId && Number(t.balance) > 0);
23058
23026
  if (tokensWithBalance.length > 0) {
23059
23027
  // Return the token with the highest balance
23060
23028
  // TODO: At the moment we're not taking into account usd price
23061
23029
  const tokenWithHighestBalance = tokensWithBalance.reduce((prev, current) => Number(prev.balance) > Number(current.balance) ? prev : current);
23062
23030
  if (tokenWithHighestBalance) {
23063
- address = normalizeArcTokenAddress(tokenWithHighestBalance.chainId, tokenWithHighestBalance.address);
23031
+ address = tokenWithHighestBalance.address;
23064
23032
  }
23065
23033
  }
23066
23034
  }
@@ -23071,21 +23039,6 @@ const findNativeTokenForChainType = (tokens) => {
23071
23039
  return tokens.find((t) => t.address.toLowerCase() ===
23072
23040
  chainTypeToNativeTokenAddressMap[t.type].toLowerCase());
23073
23041
  };
23074
- const getTokenAddressForSelection = ({ tokens, config, chainId, address, direction, excludeToken, }) => {
23075
- if (!isArcChain(chainId))
23076
- return address;
23077
- const normalizedAddress = normalizeArcTokenAddress(chainId, address);
23078
- const excludedAddress = normalizeArcTokenAddress(excludeToken?.chainId, excludeToken?.address);
23079
- if (!chainId ||
23080
- !normalizedAddress ||
23081
- (excludeToken?.chainId === chainId &&
23082
- normalizedAddress.toLowerCase() === excludedAddress?.toLowerCase()) ||
23083
- !getSupportedChainIdsForDirection([chainId], config, direction).includes(chainId)) {
23084
- return undefined;
23085
- }
23086
- return filterViewableTokens(tokens, config, direction).find((token) => token.chainId === chainId &&
23087
- token.address.toLowerCase() === normalizedAddress.toLowerCase())?.address;
23088
- };
23089
23042
  /**
23090
23043
  * Returns the default token address for a specific chain and direction based on config.
23091
23044
  * If no default tokens are set in config, returns the native token for the specified chain
@@ -23103,25 +23056,6 @@ const getInitialOrDefaultTokenAddressForChain = ({ tokens, config, chainId, dire
23103
23056
  const supportedChainIds = getSupportedChainIdsForDirection([chainId], config, direction);
23104
23057
  if (!supportedChainIds.includes(chainId))
23105
23058
  return;
23106
- if (isArcChain(chainId)) {
23107
- const selectAddress = (address) => getTokenAddressForSelection({
23108
- tokens,
23109
- config,
23110
- chainId,
23111
- address,
23112
- direction,
23113
- excludeToken,
23114
- });
23115
- const selectableTokens = tokens.filter((token) => token.chainId === chainId &&
23116
- !isArcNativeToken(token) &&
23117
- selectAddress(token.address) !== undefined);
23118
- return (selectAddress(config.defaultTokensPerChain?.find((token) => token.chainId === chainId)
23119
- ?.address) ??
23120
- selectAddress(getInitialTokenAddressForChain({ tokens, config, chainId, direction })) ??
23121
- selectAddress(fetchHighestBalanceToken(fetchCachedBalance, chainId, selectableTokens, direction)) ??
23122
- selectAddress(arcUsdcTokenAddress) ??
23123
- selectableTokens[0]?.address);
23124
- }
23125
23059
  const configDefaultTokenForChain = config.defaultTokensPerChain?.find((token) => token.chainId == chainId);
23126
23060
  // get default token from config
23127
23061
  if (configDefaultTokenForChain &&
@@ -23165,23 +23099,6 @@ const getInitialTokenAddressForChain = ({ chainId, config, direction, tokens, un
23165
23099
  const initialAsset = config.initialAssets?.[direction];
23166
23100
  if (!initialAsset)
23167
23101
  return undefined;
23168
- if (isArcChain(chainId)) {
23169
- const address = isNamedTokenConfig(initialAsset)
23170
- ? tokens.find((token) => token.chainId === chainId &&
23171
- !isArcNativeToken(token) &&
23172
- token.symbol.toLowerCase() === initialAsset.symbol?.toLowerCase())?.address
23173
- : initialAsset.chainId === chainId
23174
- ? initialAsset.address
23175
- : undefined;
23176
- return getTokenAddressForSelection({
23177
- tokens,
23178
- config,
23179
- chainId,
23180
- address,
23181
- direction,
23182
- excludeToken: { chainId, address: unavailableTokenAddress },
23183
- });
23184
- }
23185
23102
  if (isNamedTokenConfig(initialAsset)) {
23186
23103
  if (!initialAsset.symbol)
23187
23104
  return undefined;
@@ -23396,39 +23313,7 @@ const handleDestinationAddressOnSwapChange = ({ fromChainId, fromTokenAddress, t
23396
23313
  if (destinationTokensFiltered.find((t) => t.address === lowerCaseDestinationTokenAddress) === undefined) {
23397
23314
  destinationTokenAddress = defaultToAddress;
23398
23315
  }
23399
- return isArcChain(toChainId ?? swapRoute?.toChainId)
23400
- ? destinationTokenAddress?.toLowerCase()
23401
- : lowerCaseDestinationTokenAddress;
23402
- };
23403
- const normalizeSwapParamsForSelection = ({ swapParams, tokens, chains, config, }) => {
23404
- const fromTokenAddress = getTokenAddressForSelection({
23405
- tokens,
23406
- config,
23407
- chainId: swapParams.fromChainId,
23408
- address: swapParams.fromTokenAddress,
23409
- direction: "from",
23410
- });
23411
- const fromToken = tokens.find((token) => token.chainId === swapParams.fromChainId &&
23412
- token.address.toLowerCase() === fromTokenAddress?.toLowerCase());
23413
- const toTokenAddress = getTokenAddressForSelection({
23414
- tokens: isArcChain(swapParams.toChainId)
23415
- ? filterTokensForDestination({
23416
- tokens,
23417
- selectedDestinationChain: chains.find((chain) => chain.chainId === swapParams.toChainId),
23418
- selectedSourceToken: fromToken,
23419
- removeSourceToken: true,
23420
- })
23421
- : tokens,
23422
- config,
23423
- chainId: swapParams.toChainId,
23424
- address: swapParams.toTokenAddress,
23425
- direction: "to",
23426
- excludeToken: {
23427
- chainId: swapParams.fromChainId,
23428
- address: fromTokenAddress,
23429
- },
23430
- });
23431
- return { ...swapParams, fromTokenAddress, toTokenAddress };
23316
+ return lowerCaseDestinationTokenAddress;
23432
23317
  };
23433
23318
  /**
23434
23319
  * When user changes something from the SwapView
@@ -23440,19 +23325,10 @@ const normalizeSwapParamsForSelection = ({ swapParams, tokens, chains, config, }
23440
23325
  * If only destination token is changed but source is not, and they were the same, then source token updates to something else
23441
23326
  *
23442
23327
  */
23443
- const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute: storedSwapRoute, tokens, chains, config, queryClient, connectedSourceAddress, }) => {
23444
- const initialSwapRoute = storedSwapRoute
23445
- ? {
23446
- ...storedSwapRoute,
23447
- fromTokenAddress: normalizeArcTokenAddress(storedSwapRoute.fromChainId, storedSwapRoute.fromTokenAddress),
23448
- toTokenAddress: normalizeArcTokenAddress(storedSwapRoute.toChainId, storedSwapRoute.toTokenAddress),
23449
- }
23450
- : undefined;
23451
- const { fromChainId, toChainId, destinationAddress, fallbackAddress, depositRefundAddress, } = inputParams;
23328
+ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chains, config, queryClient, connectedSourceAddress, }) => {
23329
+ const { fromChainId, fromTokenAddress, toChainId, toTokenAddress, destinationAddress, fallbackAddress, depositRefundAddress, } = inputParams;
23452
23330
  const srcChainId = fromChainId ?? initialSwapRoute?.fromChainId;
23453
23331
  const destinationChainId = toChainId ?? initialSwapRoute?.toChainId;
23454
- const fromTokenAddress = normalizeArcTokenAddress(srcChainId, inputParams.fromTokenAddress);
23455
- const toTokenAddress = normalizeArcTokenAddress(destinationChainId, inputParams.toTokenAddress);
23456
23332
  const defaultFromAddress = getInitialOrDefaultTokenAddressForChain({
23457
23333
  tokens,
23458
23334
  config,
@@ -23528,20 +23404,15 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute: storedSwapRo
23528
23404
  const newDepositRefundAddress = sourceChainChanged
23529
23405
  ? undefined
23530
23406
  : depositRefundAddress || initialSwapRoute?.depositRefundAddress;
23531
- return normalizeSwapParamsForSelection({
23532
- swapParams: {
23533
- fromChainId: srcChainId,
23534
- fromTokenAddress: sourceTokenAddress,
23535
- toChainId: destinationChainId,
23536
- toTokenAddress: destinationTokenAddress,
23537
- destinationAddress: newDestinationAddress,
23538
- fallbackAddress: newFallbackAddress,
23539
- depositRefundAddress: newDepositRefundAddress,
23540
- },
23541
- tokens,
23542
- chains,
23543
- config,
23544
- });
23407
+ return {
23408
+ fromChainId: srcChainId,
23409
+ fromTokenAddress: sourceTokenAddress,
23410
+ toChainId: destinationChainId,
23411
+ toTokenAddress: destinationTokenAddress,
23412
+ destinationAddress: newDestinationAddress,
23413
+ fallbackAddress: newFallbackAddress,
23414
+ depositRefundAddress: newDepositRefundAddress,
23415
+ };
23545
23416
  };
23546
23417
  /* Sorts tokens based on the following order:
23547
23418
  * 1. Native token on chain ID "1" (Ethereum) comes first.
@@ -23599,10 +23470,8 @@ const sortAllTokens = (tokenA, tokenB) => {
23599
23470
  return 0;
23600
23471
  };
23601
23472
  const findToken = (tokens, chainId, address) => tokens.find((t) => t.chainId === chainId && t.address === address);
23602
- const findNativeToken = (tokens, chain) => tokens.find((t) => t.chainId === chain.chainId &&
23603
- (isArcChain(chain.chainId)
23604
- ? isArcNativeToken(t)
23605
- : t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase()));
23473
+ const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase() &&
23474
+ t.chainId == chain.chainId);
23606
23475
  const normalizeIbcAddress = (address) => {
23607
23476
  if (!address.toLowerCase().startsWith("ibc/")) {
23608
23477
  return address;
@@ -23672,7 +23541,9 @@ function selectGroupDefaultInfo(tokens) {
23672
23541
  const groupTokensBySymbol = (tokens, chainType) => {
23673
23542
  const groups = {};
23674
23543
  // Filter tokens by chain type if specified
23675
- const filteredTokens = deduplicateArcBalances(chainType ? tokens.filter((token) => token.type === chainType) : tokens);
23544
+ const filteredTokens = chainType
23545
+ ? tokens.filter((token) => token.type === chainType)
23546
+ : tokens;
23676
23547
  // First pass: group by coingeckoId or symbol
23677
23548
  filteredTokens.forEach((token) => {
23678
23549
  const groupKey = token.coingeckoId || token.symbol.split(".")[0];
@@ -23748,7 +23619,7 @@ const groupTokensBySymbol = (tokens, chainType) => {
23748
23619
  */
23749
23620
  const groupTokensByChainId = (tokens, chains) => {
23750
23621
  const groups = {};
23751
- deduplicateArcBalances(tokens).forEach((token) => {
23622
+ tokens.forEach((token) => {
23752
23623
  const chainData = chains.find((chain) => chain.chainId === token.chainId);
23753
23624
  const groupKey = token.chainId;
23754
23625
  if (!groups[groupKey]) {
@@ -23788,16 +23659,14 @@ const groupTokensByChainId = (tokens, chains) => {
23788
23659
  */
23789
23660
  const filterViewableTokens = (tokens, config, direction) => {
23790
23661
  const disabledTokens = [
23791
- // On Celo, native token & custom address tokens are returned
23792
- // so we should hide the native one but keep receiving it to use gas balance
23662
+ // Both interfaces share one balance; show only the ERC20 token.
23793
23663
  { chainId: CHAIN_IDS.CELO, address: nativeEvmTokenAddress },
23664
+ { chainId: CHAIN_IDS.ARC, address: nativeEvmTokenAddress },
23794
23665
  // SagaEVM is gasless, so the native token is not used
23795
23666
  { chainId: CHAIN_IDS.SAGA_EVM, address: nativeEvmTokenAddress },
23796
23667
  { chainId: CHAIN_IDS.DCHAIN, address: nativeEvmTokenAddress },
23797
23668
  ];
23798
23669
  return (tokens.filter((token) => {
23799
- if (isArcNativeToken(token))
23800
- return false;
23801
23670
  if (direction) {
23802
23671
  const parsedDirection = getParsedDirection(direction);
23803
23672
  const availableTokensForDirection = config.availableTokens?.[parsedDirection];
@@ -23813,7 +23682,7 @@ const filterViewableTokens = (tokens, config, direction) => {
23813
23682
  };
23814
23683
  const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
23815
23684
  const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
23816
- const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BZ06HTOJ.js'); });
23685
+ const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-C6GiPeC8.js'); });
23817
23686
  return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
23818
23687
  };
23819
23688
  function getTokenAssetsKey(token) {
@@ -28240,7 +28109,7 @@ function useStellarWallets() {
28240
28109
  try {
28241
28110
  const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
28242
28111
  const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
28243
- const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-fnyXRadt.js'); });
28112
+ const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-DkBWS3eX.js'); });
28244
28113
  const modules = [...initializeAllModules(), new LedgerModule()];
28245
28114
  const promises = modules.map(async (module) => {
28246
28115
  const isAvailable = await module.isAvailable();
@@ -29168,27 +29037,12 @@ const useMultiChainWallet = (chain) => {
29168
29037
  };
29169
29038
 
29170
29039
  const useSwap = () => {
29171
- const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, availableTokens, } = useConfigStore((state) => state.config);
29040
+ const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
29172
29041
  const fromPrice = useTransactionStore((state) => state.fromPrice);
29173
- const { swapRoute: storedSwapRoute } = useSwapRoutePersistStore();
29042
+ const { swapRoute } = useSwapRoutePersistStore();
29174
29043
  const { tokens } = useSquidTokens();
29175
29044
  const queryClient = reactQuery.useQueryClient();
29176
29045
  const { chains, supportedDestinationChains, supportedSourceChains } = useSquidChains();
29177
- const swapRoute = React.useMemo(() => storedSwapRoute
29178
- ? normalizeSwapParamsForSelection({
29179
- swapParams: storedSwapRoute,
29180
- tokens,
29181
- chains,
29182
- config: { disabledChains, availableChains, availableTokens },
29183
- })
29184
- : undefined, [
29185
- storedSwapRoute,
29186
- tokens,
29187
- chains,
29188
- disabledChains,
29189
- availableChains,
29190
- availableTokens,
29191
- ]);
29192
29046
  const sourceChainId = React.useMemo(() => swapRoute?.fromChainId ??
29193
29047
  (initialAssets?.from
29194
29048
  ? resolveChainIdFromAsset(initialAssets.from, supportedSourceChains)
@@ -29199,23 +29053,13 @@ const useSwap = () => {
29199
29053
  : undefined), [swapRoute?.toChainId, supportedDestinationChains, initialAssets?.to]);
29200
29054
  const fromChain = React.useMemo(() => supportedSourceChains.find((c) => c.chainId === swapRoute?.fromChainId), [swapRoute?.fromChainId, supportedSourceChains]);
29201
29055
  const toChain = React.useMemo(() => supportedDestinationChains.find((c) => c.chainId === swapRoute?.toChainId), [swapRoute?.toChainId, supportedDestinationChains]);
29202
- const fromTokens = React.useMemo(() => {
29203
- const chainTokens = getTokensForChain(tokens, sourceChainId);
29204
- return isArcChain(sourceChainId)
29205
- ? filterViewableTokens(chainTokens, { availableTokens }, "from")
29206
- : chainTokens;
29207
- }, [tokens, sourceChainId, availableTokens]);
29056
+ const fromTokens = React.useMemo(() => getTokensForChain(tokens, sourceChainId), [tokens, sourceChainId]);
29208
29057
  const fromToken = React.useMemo(() => fromTokens.find((t) => t.address.toLowerCase() === swapRoute?.fromTokenAddress?.toLowerCase()), [fromTokens, swapRoute?.fromTokenAddress]);
29209
- const toTokens = React.useMemo(() => {
29210
- const destinationTokens = filterTokensForDestination({
29211
- tokens: getTokensForChain(tokens, destChainId),
29212
- selectedDestinationChain: toChain,
29213
- selectedSourceToken: fromToken,
29214
- });
29215
- return isArcChain(destChainId)
29216
- ? filterViewableTokens(destinationTokens, { availableTokens }, "to")
29217
- : destinationTokens;
29218
- }, [destChainId, toChain, fromToken, tokens, availableTokens]);
29058
+ const toTokens = React.useMemo(() => filterTokensForDestination({
29059
+ tokens: getTokensForChain(tokens, destChainId),
29060
+ selectedDestinationChain: toChain,
29061
+ selectedSourceToken: fromToken,
29062
+ }), [destChainId, toChain, fromToken, tokens]);
29219
29063
  const toToken = React.useMemo(() => toTokens.find((t) => t.address.toLowerCase() === swapRoute?.toTokenAddress?.toLowerCase()), [toTokens, swapRoute?.toTokenAddress]);
29220
29064
  const isSameChain = sourceChainId === destChainId;
29221
29065
  const tokenItems = React.useMemo(() => ({ from: fromTokens, to: toTokens }), [fromTokens, toTokens]);
@@ -29263,7 +29107,6 @@ const useSwap = () => {
29263
29107
  defaultTokensPerChain,
29264
29108
  disabledChains,
29265
29109
  availableChains,
29266
- availableTokens,
29267
29110
  },
29268
29111
  queryClient,
29269
29112
  connectedSourceAddress: connectedSourceAddress.address,
@@ -29303,7 +29146,6 @@ const useSwap = () => {
29303
29146
  defaultTokensPerChain,
29304
29147
  disabledChains,
29305
29148
  availableChains,
29306
- availableTokens,
29307
29149
  initialAssets,
29308
29150
  queryClient,
29309
29151
  swapRoute,
@@ -29359,10 +29201,6 @@ const useSwap = () => {
29359
29201
  },
29360
29202
  direction: "to",
29361
29203
  });
29362
- if ([defaultFromChainId, defaultToChainId].some((chainId) => isArcChain(chainId) &&
29363
- !tokens.some((token) => token.chainId === chainId && !isArcNativeToken(token)))) {
29364
- return;
29365
- }
29366
29204
  const fromTokenAddress = getInitialOrDefaultTokenAddressForChain({
29367
29205
  tokens,
29368
29206
  config: {
@@ -29370,7 +29208,6 @@ const useSwap = () => {
29370
29208
  defaultTokensPerChain,
29371
29209
  disabledChains,
29372
29210
  availableChains,
29373
- availableTokens,
29374
29211
  },
29375
29212
  chainId: defaultFromChainId,
29376
29213
  direction: "from",
@@ -29382,7 +29219,6 @@ const useSwap = () => {
29382
29219
  defaultTokensPerChain,
29383
29220
  disabledChains,
29384
29221
  availableChains,
29385
- availableTokens,
29386
29222
  },
29387
29223
  chainId: defaultToChainId,
29388
29224
  direction: "to",
@@ -29407,7 +29243,6 @@ const useSwap = () => {
29407
29243
  initialAssets,
29408
29244
  disabledChains,
29409
29245
  availableChains,
29410
- availableTokens,
29411
29246
  defaultTokensPerChain,
29412
29247
  tokens,
29413
29248
  ]);
@@ -31199,18 +31034,17 @@ function useNativeTokenForChain(chain) {
31199
31034
  return cantonTokens;
31200
31035
  }
31201
31036
  };
31202
- const tokens = getTokensForChainType();
31203
31037
  const nativeTokenForChainType = React.useMemo(() => {
31204
31038
  if (!chain)
31205
31039
  return undefined;
31206
- return findNativeToken(tokens, chain);
31207
- }, [chain, tokens]);
31040
+ return findNativeToken(getTokensForChainType(), chain);
31041
+ }, [chain]);
31208
31042
  return { nativeToken: nativeTokenForChainType };
31209
31043
  }
31210
31044
 
31211
31045
  const useEvmNativeBalance = ({ address, chain, }) => {
31212
31046
  const { isChainTypeConnected } = useWallet();
31213
- const { data: nativeEvmBalance, isLoading, isError, } = wagmi.useBalance({
31047
+ const { data: nativeEvmBalance, isLoading } = wagmi.useBalance({
31214
31048
  address: address,
31215
31049
  chainId: Number(chain?.chainId),
31216
31050
  query: {
@@ -31222,8 +31056,6 @@ const useEvmNativeBalance = ({ address, chain, }) => {
31222
31056
  },
31223
31057
  });
31224
31058
  const balance = React.useMemo(() => {
31225
- if (isArcChain(chain?.chainId) && isError)
31226
- return undefined;
31227
31059
  if (nativeEvmBalance?.decimals != null && nativeEvmBalance?.value != null) {
31228
31060
  if (chain?.chainId === CHAIN_IDS.HEDERA) {
31229
31061
  return {
@@ -31237,12 +31069,7 @@ const useEvmNativeBalance = ({ address, chain, }) => {
31237
31069
  };
31238
31070
  }
31239
31071
  return;
31240
- }, [
31241
- nativeEvmBalance?.decimals,
31242
- nativeEvmBalance?.value,
31243
- chain?.chainId,
31244
- isError,
31245
- ]);
31072
+ }, [nativeEvmBalance?.decimals, nativeEvmBalance?.value, chain?.chainId]);
31246
31073
  return {
31247
31074
  balance,
31248
31075
  isLoading,
@@ -31729,7 +31556,7 @@ function hederaWalletConnect(parameters) {
31729
31556
  const optionalChains = config.chains.map((x) => x.id);
31730
31557
  if (!optionalChains.length)
31731
31558
  return;
31732
- const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-BVCh4tlV.js'); });
31559
+ const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-CnV3EYrQ.js'); });
31733
31560
  const rawProvider = await EthereumProvider.init({
31734
31561
  ...restParameters,
31735
31562
  disableProviderPing: true,
@@ -32953,6 +32780,12 @@ const isTempoChain = (chainId) => chainId === CHAIN_IDS.TEMPO;
32953
32780
  */
32954
32781
  const convertTempoFeeToStablecoinUnits = (feeIn18Dec) => feeIn18Dec / BigInt(10 ** 12);
32955
32782
 
32783
+ const arcUsdcTokenAddress = "0x3600000000000000000000000000000000000000";
32784
+ const isArcChain = (chainId) => chainId === CHAIN_IDS.ARC;
32785
+ const isArcUsdcToken = (token) => isArcChain(token?.chainId) &&
32786
+ token?.address.toLowerCase() === arcUsdcTokenAddress;
32787
+ const convertArcGasToUsdcUnits = (fee) => (fee + 10n ** 12n - 1n) / 10n ** 12n;
32788
+
32956
32789
  const DEFAULT_REFRESH_INTERVAL_MS = 15000;
32957
32790
  /**
32958
32791
  * Returns raw on-chain gas token data for Tempo chains, or null when the source
@@ -33019,6 +32852,30 @@ const useTempoFeeCheck = ({ fromChain, fromToken, }) => {
33019
32852
  };
33020
32853
  };
33021
32854
 
32855
+ const useArcFeeCheck = ({ fromChain, }) => {
32856
+ const { connectedAddresses } = useWallet();
32857
+ const { evmTokens } = useSquidTokens();
32858
+ const isArc = isArcChain(fromChain?.chainId);
32859
+ const gasToken = React.useMemo(() => {
32860
+ if (!isArc)
32861
+ return undefined;
32862
+ return evmTokens.find(isArcUsdcToken);
32863
+ }, [isArc, evmTokens]);
32864
+ const userAddress = connectedAddresses[squidTypes.ChainType.EVM];
32865
+ const { balance, isLoading } = useEvmBalance({
32866
+ chain: fromChain,
32867
+ token: gasToken,
32868
+ userAddress,
32869
+ enabled: isArc && !!gasToken,
32870
+ });
32871
+ if (!isArc || !gasToken || !userAddress || isLoading)
32872
+ return null;
32873
+ return {
32874
+ gasTokenAddress: gasToken.address,
32875
+ gasBalance: parseToBigInt(balance, gasToken.decimals),
32876
+ };
32877
+ };
32878
+
33022
32879
  /**
33023
32880
  * Hook that returns the gas token and chain fee params for a given source chain and token.
33024
32881
  */
@@ -33027,6 +32884,7 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
33027
32884
  const { evmTokens } = useSquidTokens();
33028
32885
  const { nativeBalance } = useNativeBalance(fromChain);
33029
32886
  const tempoFeeData = useTempoFeeCheck({ fromChain, fromToken });
32887
+ const arcFeeData = useArcFeeCheck({ fromChain });
33030
32888
  const chainFeeParams = React.useMemo(() => {
33031
32889
  if (fromToken?.address == null ||
33032
32890
  fromChain?.chainId == null ||
@@ -33045,24 +32903,14 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
33045
32903
  };
33046
32904
  }
33047
32905
  if (isArcChain(fromChain.chainId)) {
33048
- const isUsdc = isArcUsdcToken(fromToken);
33049
- const isNative = isArcNativeToken(fromToken);
33050
- if (fromToken.chainId !== fromChain.chainId ||
33051
- nativeBalance.decimals !== 18 ||
33052
- (isUsdc && fromToken.decimals !== 6) ||
33053
- (isNative && fromToken.decimals !== 18)) {
32906
+ if (!arcFeeData)
33054
32907
  return null;
33055
- }
32908
+ const fromTokenPaysGasFees = arcFeeData.gasTokenAddress.toLowerCase() ===
32909
+ fromToken.address.toLowerCase();
33056
32910
  return {
33057
- fromTokenPaysGasFees: isUsdc || isNative,
33058
- gasTokenBalanceWei: nativeBalance.value,
32911
+ fromTokenPaysGasFees,
32912
+ gasTokenBalanceWei: arcFeeData.gasBalance,
33059
32913
  normalizeFee: (fee) => fee,
33060
- fromAmountToGasUnits: isUsdc
33061
- ? (amount) => amount * 10n ** 12n
33062
- : undefined,
33063
- gasUnitsToFromAmount: isUsdc
33064
- ? (amount) => amount / 10n ** 12n
33065
- : undefined,
33066
32914
  };
33067
32915
  }
33068
32916
  return {
@@ -33072,11 +32920,12 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
33072
32920
  normalizeFee: (fee) => fee,
33073
32921
  };
33074
32922
  }, [
33075
- fromToken,
32923
+ fromToken?.address,
32924
+ fromToken?.type,
33076
32925
  fromChain?.chainId,
33077
32926
  nativeBalance?.value,
33078
- nativeBalance?.decimals,
33079
32927
  tempoFeeData,
32928
+ arcFeeData,
33080
32929
  ]);
33081
32930
  /**
33082
32931
  * The token to pay for gas on the source chain.
@@ -33091,22 +32940,18 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
33091
32940
  t.address.toLowerCase() === tempoFeeData.gasTokenAddress.toLowerCase());
33092
32941
  }
33093
32942
  if (isArcChain(fromChain.chainId)) {
33094
- return nativeToken?.decimals === 18
33095
- ? {
33096
- ...nativeToken,
33097
- symbol: fromChain.nativeCurrency.symbol,
33098
- name: fromChain.nativeCurrency.name,
33099
- }
33100
- : undefined;
32943
+ if (!arcFeeData)
32944
+ return undefined;
32945
+ return evmTokens.find((t) => t.chainId === fromChain.chainId &&
32946
+ t.address.toLowerCase() === arcFeeData.gasTokenAddress.toLowerCase());
33101
32947
  }
33102
32948
  return nativeToken;
33103
32949
  }, [
33104
32950
  fromChain?.chainId,
33105
- fromChain?.nativeCurrency.symbol,
33106
- fromChain?.nativeCurrency.name,
33107
32951
  fromToken?.address,
33108
32952
  nativeToken,
33109
32953
  tempoFeeData,
32954
+ arcFeeData,
33110
32955
  evmTokens,
33111
32956
  ]);
33112
32957
  return { gasToken, chainFeeParams };
@@ -33262,57 +33107,22 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
33262
33107
  (sameTokenBetweenFees
33263
33108
  ? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
33264
33109
  : BigInt(firstGasCost?.amount ?? "0"));
33265
- const addGasReserve = (fee) => (fee * 110n + 99n) / 100n;
33266
- const calculateArcGasCosts = (gasCosts) => {
33267
- const sourceGasCosts = gasCosts.filter((cost) => isArcChain(cost.token.chainId));
33268
- if (sourceGasCosts.length === 0)
33269
- return undefined;
33270
- let total = 0n;
33271
- for (const { amount, token } of sourceGasCosts) {
33272
- const fee = BigInt(amount);
33273
- if (fee <= 0n)
33274
- return undefined;
33275
- if (isArcUsdcToken(token) && token.decimals === 6) {
33276
- total += fee * 10n ** 12n;
33277
- }
33278
- else if (isArcNativeToken(token) && token.decimals === 18) {
33279
- total += fee;
33280
- }
33281
- else {
33282
- return undefined;
33283
- }
33284
- }
33285
- return total;
33286
- };
33287
- const calculateTotalGasBalanceNeeded = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
33288
- if (!chainFeeParams || networkFeesWei == null)
33289
- return undefined;
33290
- if (!chainFeeParams.fromTokenPaysGasFees)
33291
- return networkFeesWei;
33292
- const amount = BigInt(fromAmount ?? "0");
33293
- const amountInGasUnits = chainFeeParams.fromAmountToGasUnits?.(amount) ?? amount;
33294
- return amountInGasUnits + networkFeesWei;
33295
- };
33296
33110
  const checkIsGasBalanceEnough = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
33297
33111
  if (!chainFeeParams)
33298
33112
  return false;
33299
- const total = calculateTotalGasBalanceNeeded({
33300
- fromAmount,
33301
- networkFeesWei,
33302
- chainFeeParams,
33303
- });
33304
- return total != null && total <= chainFeeParams.gasTokenBalanceWei;
33113
+ if (chainFeeParams.fromTokenPaysGasFees) {
33114
+ return (BigInt(fromAmount ?? "0") + networkFeesWei <=
33115
+ chainFeeParams.gasTokenBalanceWei);
33116
+ }
33117
+ return networkFeesWei <= chainFeeParams.gasTokenBalanceWei;
33305
33118
  };
33306
33119
  const calculateMinAmountValueWarnMsg = ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }) => {
33307
- if (!chainFeeParams?.fromTokenPaysGasFees || networkFeesWei == null)
33120
+ if (!chainFeeParams?.fromTokenPaysGasFees)
33308
33121
  return undefined;
33309
33122
  const minAmount = chainFeeParams.gasTokenBalanceWei - networkFeesWei;
33310
33123
  if (minAmount <= BigInt(0))
33311
33124
  return undefined;
33312
- const amountInTokenUnits = chainFeeParams.gasUnitsToFromAmount?.(minAmount) ?? minAmount;
33313
- if (amountInTokenUnits <= 0n)
33314
- return undefined;
33315
- return formatBNToReadable(amountInTokenUnits, fromTokenDecimals);
33125
+ return formatBNToReadable(minAmount, fromTokenDecimals);
33316
33126
  };
33317
33127
  /**
33318
33128
  * Calculates the estimated duration of a route
@@ -33361,22 +33171,14 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
33361
33171
  const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
33362
33172
  const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
33363
33173
  firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
33364
- const totalNativeFees = isArcChain(fromChain?.chainId)
33365
- ? calculateArcGasCosts(allGasCosts)
33366
- : calculateTotalNativeFees({
33367
- expressFeeCost,
33368
- firstFeeCost,
33369
- firstGasCost,
33370
- sameTokenBetweenFees,
33371
- });
33372
- const totalFeesInNativeTokenPlusRatio = totalNativeFees == null
33373
- ? undefined
33374
- : isArcChain(fromChain?.chainId)
33375
- ? addGasReserve(totalNativeFees)
33376
- : (totalNativeFees * BigInt(110)) / BigInt(100);
33377
- const networkFeesWei = totalFeesInNativeTokenPlusRatio == null
33378
- ? undefined
33379
- : chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio);
33174
+ const totalNativeFees = calculateTotalNativeFees({
33175
+ expressFeeCost,
33176
+ firstFeeCost,
33177
+ firstGasCost,
33178
+ sameTokenBetweenFees,
33179
+ });
33180
+ const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
33181
+ const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
33380
33182
  const isGasBalanceEnough = checkIsGasBalanceEnough({
33381
33183
  chainFeeParams,
33382
33184
  fromAmount,
@@ -33392,12 +33194,10 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
33392
33194
  estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
33393
33195
  isSingleChainRoute,
33394
33196
  });
33395
- const totalGasBalanceNeeded = calculateTotalGasBalanceNeeded({
33396
- fromAmount,
33397
- networkFeesWei,
33398
- chainFeeParams,
33399
- });
33400
- const gasBalanceNeeded = gasToken && totalGasBalanceNeeded != null
33197
+ // gas fees + fromAmount (if fromToken is gas token)
33198
+ const totalGasBalanceNeeded = networkFeesWei +
33199
+ BigInt(chainFeeParams?.fromTokenPaysGasFees ? (fromAmount ?? 0) : 0);
33200
+ const gasBalanceNeeded = gasToken
33401
33201
  ? formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals)
33402
33202
  : undefined;
33403
33203
  return {
@@ -33419,7 +33219,7 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
33419
33219
  expectedGasRefundCostUSD,
33420
33220
  sameTokenBetweenFees,
33421
33221
  fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
33422
- totalNativeFees: totalNativeFees ?? 0n,
33222
+ totalNativeFees,
33423
33223
  isGasBalanceEnough,
33424
33224
  minAmountValueWarnMsg,
33425
33225
  estimatedRouteDuration,
@@ -33468,12 +33268,8 @@ function useSendTransactionGas({ chain, token, from, }) {
33468
33268
  case squidTypes.ChainType.EVM: {
33469
33269
  const client = await getClient(chain);
33470
33270
  const feeData = await client.getFeeData();
33471
- if (!feeData.maxFeePerGas) {
33472
- if (isArcChain(chain.chainId)) {
33473
- throw new Error("Gas price is unavailable");
33474
- }
33271
+ if (!feeData.maxFeePerGas)
33475
33272
  return BigInt(0);
33476
- }
33477
33273
  let maxFeePerGas = feeData.maxFeePerGas;
33478
33274
  if (token.chainId === CHAIN_IDS.HEDERA) {
33479
33275
  maxFeePerGas = scaleWeiToHbar(BigInt(feeData.maxFeePerGas));
@@ -33493,9 +33289,6 @@ function useSendTransactionGas({ chain, token, from, }) {
33493
33289
  value: 1,
33494
33290
  chainId: chain.chainId,
33495
33291
  });
33496
- if (isArcChain(chain.chainId) && gas <= 0n) {
33497
- throw new Error("Gas estimate is unavailable");
33498
- }
33499
33292
  return gas * maxFeePerGas;
33500
33293
  }
33501
33294
  const erc20Interface = new ethers.Interface(viem.erc20Abi);
@@ -33510,14 +33303,14 @@ function useSendTransactionGas({ chain, token, from, }) {
33510
33303
  chainId: chain.chainId,
33511
33304
  });
33512
33305
  const feeWei = gas * maxFeePerGas;
33513
- if (isArcChain(chain.chainId) && feeWei <= 0n) {
33514
- throw new Error("Gas estimate is unavailable");
33515
- }
33516
33306
  // Tempo gas fees are denominated 18 units,
33517
33307
  // this value needs to be scaled to 6 decimals
33518
33308
  if (chain.chainId === CHAIN_IDS.TEMPO) {
33519
33309
  return convertTempoFeeToStablecoinUnits(feeWei);
33520
33310
  }
33311
+ if (isArcChain(chain.chainId)) {
33312
+ return convertArcGasToUsdcUnits(feeWei);
33313
+ }
33521
33314
  return feeWei;
33522
33315
  }
33523
33316
  case squidTypes.ChainType.COSMOS: {
@@ -33560,45 +33353,35 @@ function useSendTransactionGas({ chain, token, from, }) {
33560
33353
  }
33561
33354
 
33562
33355
  function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
33563
- const { data, isLoading, isFetching, isError, refetch } = useSendTransactionGas({
33356
+ const { data: estimatedGas = BigInt(0), isLoading } = useSendTransactionGas({
33564
33357
  chain,
33565
33358
  token,
33566
33359
  from,
33567
33360
  });
33568
- const estimatedGas = isError || isFetching ? undefined : data;
33569
- const networkFeesWei = estimatedGas == null
33570
- ? undefined
33571
- : isArcChain(chain?.chainId)
33572
- ? addGasReserve(estimatedGas)
33573
- : estimatedGas;
33574
33361
  const { chainFeeParams, gasToken } = useSourceChainGasToken({
33575
33362
  fromChain: chain,
33576
33363
  fromToken: token,
33577
33364
  });
33578
33365
  const isGasBalanceEnough = React.useMemo(() => {
33579
- if (!amount || token?.decimals == null || !gasToken)
33366
+ if (!amount || !token?.decimals)
33580
33367
  return false;
33581
33368
  return checkIsGasBalanceEnough({
33582
33369
  fromAmount: parseToBigInt(amount, token.decimals).toString(),
33583
- networkFeesWei,
33370
+ networkFeesWei: estimatedGas,
33584
33371
  chainFeeParams,
33585
33372
  });
33586
- }, [amount, networkFeesWei, token, chainFeeParams, gasToken]);
33373
+ }, [amount, estimatedGas, token, chainFeeParams]);
33587
33374
  const gasBalanceNeeded = React.useMemo(() => {
33588
- if (!amount || token?.decimals == null || gasToken?.decimals == null)
33589
- return undefined;
33590
- const totalGasBalanceNeeded = calculateTotalGasBalanceNeeded({
33591
- fromAmount: parseToBigInt(amount, token.decimals).toString(),
33592
- networkFeesWei,
33593
- chainFeeParams,
33594
- });
33595
- if (totalGasBalanceNeeded == null)
33375
+ if (!amount || !token?.decimals || !gasToken?.decimals)
33596
33376
  return undefined;
33377
+ // gas fees + fromAmount (if fromToken is gas token)
33378
+ const totalGasBalanceNeeded = estimatedGas +
33379
+ parseToBigInt(chainFeeParams?.fromTokenPaysGasFees ? (amount ?? "0") : "0", token.decimals);
33597
33380
  return formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals);
33598
33381
  }, [
33599
33382
  amount,
33600
- chainFeeParams,
33601
- networkFeesWei,
33383
+ chainFeeParams?.fromTokenPaysGasFees,
33384
+ estimatedGas,
33602
33385
  gasToken?.decimals,
33603
33386
  token?.decimals,
33604
33387
  ]);
@@ -33609,22 +33392,20 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
33609
33392
  parseToBigInt(amount, token.decimals));
33610
33393
  }, [amount, balance, token?.decimals]);
33611
33394
  const minAmountValueWarnMsg = React.useMemo(() => {
33612
- if (!token?.address || !gasToken || !chainFeeParams)
33395
+ if (!token?.address || !estimatedGas || !chainFeeParams)
33613
33396
  return undefined;
33614
33397
  return calculateMinAmountValueWarnMsg({
33615
33398
  chainFeeParams,
33616
- networkFeesWei,
33399
+ networkFeesWei: estimatedGas,
33617
33400
  fromTokenDecimals: token.decimals,
33618
33401
  });
33619
- }, [networkFeesWei, token, chainFeeParams, gasToken]);
33402
+ }, [estimatedGas, token, chainFeeParams]);
33620
33403
  return {
33621
33404
  estimatedGas,
33622
33405
  gasBalanceNeeded,
33623
33406
  isBalanceEnough,
33624
33407
  tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
33625
- isLoading: isLoading || isFetching,
33626
- isError,
33627
- refetchGasEstimate: refetch,
33408
+ isLoading,
33628
33409
  isGasBalanceEnough,
33629
33410
  minAmountValueWarnMsg,
33630
33411
  };
@@ -34525,19 +34306,6 @@ const useApproval = ({ squidRoute, }) => {
34525
34306
  const { getChainType } = useSquidChains();
34526
34307
  const { switchChainAsync } = wagmi.useSwitchChain();
34527
34308
  const { connectedAddress: { address: sourceUserAddress }, } = useMultiChainWallet(fromChain);
34528
- const arcNativeBalanceQuery = wagmi.useBalance({
34529
- address: sourceUserAddress,
34530
- chainId: Number(fromChain?.chainId),
34531
- query: { enabled: false },
34532
- });
34533
- const arcTokenBalanceQuery = wagmi.useReadContract({
34534
- address: fromToken?.address,
34535
- abi: viem.erc20Abi,
34536
- functionName: "balanceOf",
34537
- args: [sourceUserAddress],
34538
- chainId: Number(fromChain?.chainId),
34539
- query: { enabled: false },
34540
- });
34541
34309
  const isSagaEvmSameChainSwap = isSameChain &&
34542
34310
  fromChain?.chainId.toString() === CHAIN_IDS.SAGA_EVM.toString();
34543
34311
  // Swaps on SagaEVM are regular EVM transactions, following the standard ERC20 approve/allowance mechanism.
@@ -34698,20 +34466,13 @@ const useApproval = ({ squidRoute, }) => {
34698
34466
  return false;
34699
34467
  }
34700
34468
  }, {
34701
- onSuccess: async (approved) => {
34702
- if (approved && isArcChain(fromChain?.chainId)) {
34703
- await Promise.all([
34704
- arcNativeBalanceQuery.refetch({ throwOnError: true }),
34705
- arcTokenBalanceQuery.refetch({ throwOnError: true }),
34706
- ]);
34707
- queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.AllTokensBalance));
34708
- }
34469
+ onSuccess: async () => {
34709
34470
  await allowanceQuery?.refetch();
34710
34471
  queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.RouteApproved));
34711
34472
  // After an approval, we refetch the transaction query with all required parameters
34712
34473
  // This is to ensure we're using the latest expiry timestamp
34713
34474
  if (squidRoute) {
34714
- await queryClient.refetchQueries({
34475
+ queryClient.refetchQueries({
34715
34476
  queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain), squidRoute.params.preHook, squidRoute.params.postHook,
34716
34477
  // TODO: update types
34717
34478
  squidRoute.params?.overrideGasRefundAddress),
@@ -39586,7 +39347,6 @@ exports.getStepsInfos = getStepsInfos;
39586
39347
  exports.getSuggestedAmountsForCurrency = getSuggestedAmountsForCurrency;
39587
39348
  exports.getSupportedChainIdsForDirection = getSupportedChainIdsForDirection;
39588
39349
  exports.getSwapTxStatusRefetchInterval = getSwapTxStatusRefetchInterval;
39589
- exports.getTokenAddressForSelection = getTokenAddressForSelection;
39590
39350
  exports.getTokenAssetsKey = getTokenAssetsKey;
39591
39351
  exports.getTokenImage = getTokenImage;
39592
39352
  exports.getTokensForChain = getTokensForChain;
@@ -39643,7 +39403,6 @@ exports.nativeSuiTokenAddress = nativeSuiTokenAddress;
39643
39403
  exports.nativeXrplTokenAddress = nativeXrplTokenAddress;
39644
39404
  exports.normalizeError = normalizeError;
39645
39405
  exports.normalizeIbcAddress = normalizeIbcAddress;
39646
- exports.normalizeSwapParamsForSelection = normalizeSwapParamsForSelection;
39647
39406
  exports.normalizeTokenSymbol = normalizeTokenSymbol;
39648
39407
  exports.parseEvmAddress = parseEvmAddress;
39649
39408
  exports.parseInitialAssetsFromUrl = parseInitialAssetsFromUrl;
@@ -39757,4 +39516,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
39757
39516
  exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
39758
39517
  exports.walletIconBaseUrl = walletIconBaseUrl;
39759
39518
  exports.walletSupportsChainType = walletSupportsChainType;
39760
- //# sourceMappingURL=index-BBJD55XX.js.map
39519
+ //# sourceMappingURL=index-8RIq6GyB.js.map