@0xsquid/react-hooks 8.12.0 → 8.12.1-beta-arc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/constants.d.ts +1 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +3 -0
- package/dist/{index-CJVX-7hj.js → index-BBJD55XX.js} +375 -80
- package/dist/index-BBJD55XX.js.map +1 -0
- package/dist/{index-C3owE9lb.js → index-CLzjMzS_.js} +374 -81
- package/dist/index-CLzjMzS_.js.map +1 -0
- package/dist/{index.es-CTKuR0LC.js → index.es-BVCh4tlV.js} +2 -2
- package/dist/{index.es-CTKuR0LC.js.map → index.es-BVCh4tlV.js.map} +1 -1
- package/dist/{index.es-09IsADsA.js → index.es-BiK_wjSb.js} +2 -2
- package/dist/{index.es-09IsADsA.js.map → index.es-BiK_wjSb.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/{secretService-GHdReJBs.js → secretService-BZ06HTOJ.js} +2 -2
- package/dist/{secretService-GHdReJBs.js.map → secretService-BZ06HTOJ.js.map} +1 -1
- package/dist/{secretService--tJFCkzT.js → secretService-DkE9yz1o.js} +2 -2
- package/dist/{secretService--tJFCkzT.js.map → secretService-DkE9yz1o.js.map} +1 -1
- package/dist/server.esm.js +1 -0
- package/dist/server.esm.js.map +1 -1
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/dist/services/internal/arcService.d.ts +7 -0
- package/dist/services/internal/assetsService.d.ts +8 -2
- package/dist/services/internal/configService.d.ts +14 -3
- package/dist/services/internal/estimateService.d.ts +12 -2
- package/dist/services/internal/tempoService.d.ts +2 -0
- package/dist/services/internal/walletService.d.ts +1 -1
- package/dist/{stellarService.client-DAxgO3m3.js → stellarService.client-DtA9zkRt.js} +2 -2
- package/dist/{stellarService.client-DAxgO3m3.js.map → stellarService.client-DtA9zkRt.js.map} +1 -1
- package/dist/{stellarService.client-DvA-2pXq.js → stellarService.client-fnyXRadt.js} +2 -2
- package/dist/{stellarService.client-DvA-2pXq.js.map → stellarService.client-fnyXRadt.js.map} +1 -1
- package/dist/tests/arcAssetsService.test.d.ts +1 -0
- package/dist/tests/arcConfigService.test.d.ts +1 -0
- package/dist/tests/arcGasAccounting.test.d.ts +1 -0
- package/dist/tests/arcWalletService.test.d.ts +1 -0
- package/dist/tests/fixtures/arc.d.ts +8 -0
- package/dist/tests/useArcApproval.test.d.ts +1 -0
- package/dist/tests/useArcSendEstimate.test.d.ts +1 -0
- package/dist/tests/useNativeTokenForChain.test.d.ts +1 -0
- package/dist/tests/useSwapArcSelection.test.d.ts +1 -0
- package/package.json +1 -1
- package/dist/index-C3owE9lb.js.map +0 -1
- package/dist/index-CJVX-7hj.js.map +0 -1
|
@@ -153,6 +153,7 @@ const CHAIN_IDS = {
|
|
|
153
153
|
MANTRA: "5888",
|
|
154
154
|
CITREA: "4114",
|
|
155
155
|
TEMPO: "4217",
|
|
156
|
+
ARC: "5042",
|
|
156
157
|
// others
|
|
157
158
|
BITCOIN: "bitcoin",
|
|
158
159
|
SOLANA: "solana-mainnet-beta",
|
|
@@ -20964,6 +20965,24 @@ const isBitcoinAddressValid = (address) => {
|
|
|
20964
20965
|
}
|
|
20965
20966
|
};
|
|
20966
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
|
+
|
|
20967
20986
|
function getCantonCommandId(memo) {
|
|
20968
20987
|
return `canton-${memo}`;
|
|
20969
20988
|
}
|
|
@@ -22200,7 +22219,7 @@ function sortAddressBook(a, b, selectedAddress) {
|
|
|
22200
22219
|
return 0;
|
|
22201
22220
|
}
|
|
22202
22221
|
const calculateTotalUsdBalanceUSD = (tokens) => {
|
|
22203
|
-
const totalUsd = tokens.reduce((total, token) => {
|
|
22222
|
+
const totalUsd = deduplicateArcBalances(tokens).reduce((total, token) => {
|
|
22204
22223
|
const balance = parseFloat(token.balance);
|
|
22205
22224
|
const usdPrice = token.usdPrice ?? 0;
|
|
22206
22225
|
const balanceUsd = balance * usdPrice;
|
|
@@ -23012,22 +23031,36 @@ const getFirstAvailableChainId = (config, direction, chains = []) => {
|
|
|
23012
23031
|
// if no initial chain ID is found in config, return the first available chain ID
|
|
23013
23032
|
return availableChains.length > 0 ? availableChains[0].chainId : undefined;
|
|
23014
23033
|
};
|
|
23015
|
-
const fetchHighestBalanceToken = (fetchCachedBalance, chainId) => {
|
|
23034
|
+
const fetchHighestBalanceToken = (fetchCachedBalance, chainId, selectableTokens, direction) => {
|
|
23016
23035
|
let address = undefined;
|
|
23017
23036
|
if (fetchCachedBalance) {
|
|
23018
23037
|
const queryCache = fetchCachedBalance?.queryClient?.getQueryCache();
|
|
23038
|
+
const directionCache = isArcChain(chainId) && direction
|
|
23039
|
+
? queryCache?.find(keys().allTokensBalance(fetchCachedBalance.address, squidTypes.ChainType.EVM, direction))
|
|
23040
|
+
: undefined;
|
|
23019
23041
|
// get cached balance from key
|
|
23020
|
-
const cache =
|
|
23021
|
-
|
|
23022
|
-
|
|
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
|
+
: [];
|
|
23023
23051
|
if (cacheResult.length > 0) {
|
|
23024
|
-
const tokensWithBalance = cacheResult.filter((t) => t.chainId === chainId &&
|
|
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
23058
|
if (tokensWithBalance.length > 0) {
|
|
23026
23059
|
// Return the token with the highest balance
|
|
23027
23060
|
// TODO: At the moment we're not taking into account usd price
|
|
23028
23061
|
const tokenWithHighestBalance = tokensWithBalance.reduce((prev, current) => Number(prev.balance) > Number(current.balance) ? prev : current);
|
|
23029
23062
|
if (tokenWithHighestBalance) {
|
|
23030
|
-
address = tokenWithHighestBalance.address;
|
|
23063
|
+
address = normalizeArcTokenAddress(tokenWithHighestBalance.chainId, tokenWithHighestBalance.address);
|
|
23031
23064
|
}
|
|
23032
23065
|
}
|
|
23033
23066
|
}
|
|
@@ -23038,6 +23071,21 @@ const findNativeTokenForChainType = (tokens) => {
|
|
|
23038
23071
|
return tokens.find((t) => t.address.toLowerCase() ===
|
|
23039
23072
|
chainTypeToNativeTokenAddressMap[t.type].toLowerCase());
|
|
23040
23073
|
};
|
|
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
|
+
};
|
|
23041
23089
|
/**
|
|
23042
23090
|
* Returns the default token address for a specific chain and direction based on config.
|
|
23043
23091
|
* If no default tokens are set in config, returns the native token for the specified chain
|
|
@@ -23055,6 +23103,25 @@ const getInitialOrDefaultTokenAddressForChain = ({ tokens, config, chainId, dire
|
|
|
23055
23103
|
const supportedChainIds = getSupportedChainIdsForDirection([chainId], config, direction);
|
|
23056
23104
|
if (!supportedChainIds.includes(chainId))
|
|
23057
23105
|
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
|
+
}
|
|
23058
23125
|
const configDefaultTokenForChain = config.defaultTokensPerChain?.find((token) => token.chainId == chainId);
|
|
23059
23126
|
// get default token from config
|
|
23060
23127
|
if (configDefaultTokenForChain &&
|
|
@@ -23098,6 +23165,23 @@ const getInitialTokenAddressForChain = ({ chainId, config, direction, tokens, un
|
|
|
23098
23165
|
const initialAsset = config.initialAssets?.[direction];
|
|
23099
23166
|
if (!initialAsset)
|
|
23100
23167
|
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
|
+
}
|
|
23101
23185
|
if (isNamedTokenConfig(initialAsset)) {
|
|
23102
23186
|
if (!initialAsset.symbol)
|
|
23103
23187
|
return undefined;
|
|
@@ -23312,7 +23396,39 @@ const handleDestinationAddressOnSwapChange = ({ fromChainId, fromTokenAddress, t
|
|
|
23312
23396
|
if (destinationTokensFiltered.find((t) => t.address === lowerCaseDestinationTokenAddress) === undefined) {
|
|
23313
23397
|
destinationTokenAddress = defaultToAddress;
|
|
23314
23398
|
}
|
|
23315
|
-
return
|
|
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
23432
|
};
|
|
23317
23433
|
/**
|
|
23318
23434
|
* When user changes something from the SwapView
|
|
@@ -23324,10 +23440,19 @@ const handleDestinationAddressOnSwapChange = ({ fromChainId, fromTokenAddress, t
|
|
|
23324
23440
|
* If only destination token is changed but source is not, and they were the same, then source token updates to something else
|
|
23325
23441
|
*
|
|
23326
23442
|
*/
|
|
23327
|
-
const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chains, config, queryClient, connectedSourceAddress, }) => {
|
|
23328
|
-
const
|
|
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;
|
|
23329
23452
|
const srcChainId = fromChainId ?? initialSwapRoute?.fromChainId;
|
|
23330
23453
|
const destinationChainId = toChainId ?? initialSwapRoute?.toChainId;
|
|
23454
|
+
const fromTokenAddress = normalizeArcTokenAddress(srcChainId, inputParams.fromTokenAddress);
|
|
23455
|
+
const toTokenAddress = normalizeArcTokenAddress(destinationChainId, inputParams.toTokenAddress);
|
|
23331
23456
|
const defaultFromAddress = getInitialOrDefaultTokenAddressForChain({
|
|
23332
23457
|
tokens,
|
|
23333
23458
|
config,
|
|
@@ -23403,15 +23528,20 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23403
23528
|
const newDepositRefundAddress = sourceChainChanged
|
|
23404
23529
|
? undefined
|
|
23405
23530
|
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23406
|
-
return {
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
|
|
23411
|
-
|
|
23412
|
-
|
|
23413
|
-
|
|
23414
|
-
|
|
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
|
+
});
|
|
23415
23545
|
};
|
|
23416
23546
|
/* Sorts tokens based on the following order:
|
|
23417
23547
|
* 1. Native token on chain ID "1" (Ethereum) comes first.
|
|
@@ -23469,8 +23599,10 @@ const sortAllTokens = (tokenA, tokenB) => {
|
|
|
23469
23599
|
return 0;
|
|
23470
23600
|
};
|
|
23471
23601
|
const findToken = (tokens, chainId, address) => tokens.find((t) => t.chainId === chainId && t.address === address);
|
|
23472
|
-
const findNativeToken = (tokens, chain) => tokens.find((t) => t.
|
|
23473
|
-
|
|
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()));
|
|
23474
23606
|
const normalizeIbcAddress = (address) => {
|
|
23475
23607
|
if (!address.toLowerCase().startsWith("ibc/")) {
|
|
23476
23608
|
return address;
|
|
@@ -23540,9 +23672,7 @@ function selectGroupDefaultInfo(tokens) {
|
|
|
23540
23672
|
const groupTokensBySymbol = (tokens, chainType) => {
|
|
23541
23673
|
const groups = {};
|
|
23542
23674
|
// Filter tokens by chain type if specified
|
|
23543
|
-
const filteredTokens = chainType
|
|
23544
|
-
? tokens.filter((token) => token.type === chainType)
|
|
23545
|
-
: tokens;
|
|
23675
|
+
const filteredTokens = deduplicateArcBalances(chainType ? tokens.filter((token) => token.type === chainType) : tokens);
|
|
23546
23676
|
// First pass: group by coingeckoId or symbol
|
|
23547
23677
|
filteredTokens.forEach((token) => {
|
|
23548
23678
|
const groupKey = token.coingeckoId || token.symbol.split(".")[0];
|
|
@@ -23618,7 +23748,7 @@ const groupTokensBySymbol = (tokens, chainType) => {
|
|
|
23618
23748
|
*/
|
|
23619
23749
|
const groupTokensByChainId = (tokens, chains) => {
|
|
23620
23750
|
const groups = {};
|
|
23621
|
-
tokens.forEach((token) => {
|
|
23751
|
+
deduplicateArcBalances(tokens).forEach((token) => {
|
|
23622
23752
|
const chainData = chains.find((chain) => chain.chainId === token.chainId);
|
|
23623
23753
|
const groupKey = token.chainId;
|
|
23624
23754
|
if (!groups[groupKey]) {
|
|
@@ -23666,6 +23796,8 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23666
23796
|
{ chainId: CHAIN_IDS.DCHAIN, address: nativeEvmTokenAddress },
|
|
23667
23797
|
];
|
|
23668
23798
|
return (tokens.filter((token) => {
|
|
23799
|
+
if (isArcNativeToken(token))
|
|
23800
|
+
return false;
|
|
23669
23801
|
if (direction) {
|
|
23670
23802
|
const parsedDirection = getParsedDirection(direction);
|
|
23671
23803
|
const availableTokensForDirection = config.availableTokens?.[parsedDirection];
|
|
@@ -23681,7 +23813,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23681
23813
|
};
|
|
23682
23814
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23683
23815
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23684
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23816
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BZ06HTOJ.js'); });
|
|
23685
23817
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23686
23818
|
};
|
|
23687
23819
|
function getTokenAssetsKey(token) {
|
|
@@ -28108,7 +28240,7 @@ function useStellarWallets() {
|
|
|
28108
28240
|
try {
|
|
28109
28241
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
28110
28242
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
28111
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
28243
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-fnyXRadt.js'); });
|
|
28112
28244
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
28113
28245
|
const promises = modules.map(async (module) => {
|
|
28114
28246
|
const isAvailable = await module.isAvailable();
|
|
@@ -29036,12 +29168,27 @@ const useMultiChainWallet = (chain) => {
|
|
|
29036
29168
|
};
|
|
29037
29169
|
|
|
29038
29170
|
const useSwap = () => {
|
|
29039
|
-
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
|
|
29171
|
+
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, availableTokens, } = useConfigStore((state) => state.config);
|
|
29040
29172
|
const fromPrice = useTransactionStore((state) => state.fromPrice);
|
|
29041
|
-
const { swapRoute } = useSwapRoutePersistStore();
|
|
29173
|
+
const { swapRoute: storedSwapRoute } = useSwapRoutePersistStore();
|
|
29042
29174
|
const { tokens } = useSquidTokens();
|
|
29043
29175
|
const queryClient = reactQuery.useQueryClient();
|
|
29044
29176
|
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
|
+
]);
|
|
29045
29192
|
const sourceChainId = React.useMemo(() => swapRoute?.fromChainId ??
|
|
29046
29193
|
(initialAssets?.from
|
|
29047
29194
|
? resolveChainIdFromAsset(initialAssets.from, supportedSourceChains)
|
|
@@ -29052,13 +29199,23 @@ const useSwap = () => {
|
|
|
29052
29199
|
: undefined), [swapRoute?.toChainId, supportedDestinationChains, initialAssets?.to]);
|
|
29053
29200
|
const fromChain = React.useMemo(() => supportedSourceChains.find((c) => c.chainId === swapRoute?.fromChainId), [swapRoute?.fromChainId, supportedSourceChains]);
|
|
29054
29201
|
const toChain = React.useMemo(() => supportedDestinationChains.find((c) => c.chainId === swapRoute?.toChainId), [swapRoute?.toChainId, supportedDestinationChains]);
|
|
29055
|
-
const fromTokens = React.useMemo(() =>
|
|
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
29208
|
const fromToken = React.useMemo(() => fromTokens.find((t) => t.address.toLowerCase() === swapRoute?.fromTokenAddress?.toLowerCase()), [fromTokens, swapRoute?.fromTokenAddress]);
|
|
29057
|
-
const toTokens = React.useMemo(() =>
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
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]);
|
|
29062
29219
|
const toToken = React.useMemo(() => toTokens.find((t) => t.address.toLowerCase() === swapRoute?.toTokenAddress?.toLowerCase()), [toTokens, swapRoute?.toTokenAddress]);
|
|
29063
29220
|
const isSameChain = sourceChainId === destChainId;
|
|
29064
29221
|
const tokenItems = React.useMemo(() => ({ from: fromTokens, to: toTokens }), [fromTokens, toTokens]);
|
|
@@ -29106,6 +29263,7 @@ const useSwap = () => {
|
|
|
29106
29263
|
defaultTokensPerChain,
|
|
29107
29264
|
disabledChains,
|
|
29108
29265
|
availableChains,
|
|
29266
|
+
availableTokens,
|
|
29109
29267
|
},
|
|
29110
29268
|
queryClient,
|
|
29111
29269
|
connectedSourceAddress: connectedSourceAddress.address,
|
|
@@ -29145,6 +29303,7 @@ const useSwap = () => {
|
|
|
29145
29303
|
defaultTokensPerChain,
|
|
29146
29304
|
disabledChains,
|
|
29147
29305
|
availableChains,
|
|
29306
|
+
availableTokens,
|
|
29148
29307
|
initialAssets,
|
|
29149
29308
|
queryClient,
|
|
29150
29309
|
swapRoute,
|
|
@@ -29200,6 +29359,10 @@ const useSwap = () => {
|
|
|
29200
29359
|
},
|
|
29201
29360
|
direction: "to",
|
|
29202
29361
|
});
|
|
29362
|
+
if ([defaultFromChainId, defaultToChainId].some((chainId) => isArcChain(chainId) &&
|
|
29363
|
+
!tokens.some((token) => token.chainId === chainId && !isArcNativeToken(token)))) {
|
|
29364
|
+
return;
|
|
29365
|
+
}
|
|
29203
29366
|
const fromTokenAddress = getInitialOrDefaultTokenAddressForChain({
|
|
29204
29367
|
tokens,
|
|
29205
29368
|
config: {
|
|
@@ -29207,6 +29370,7 @@ const useSwap = () => {
|
|
|
29207
29370
|
defaultTokensPerChain,
|
|
29208
29371
|
disabledChains,
|
|
29209
29372
|
availableChains,
|
|
29373
|
+
availableTokens,
|
|
29210
29374
|
},
|
|
29211
29375
|
chainId: defaultFromChainId,
|
|
29212
29376
|
direction: "from",
|
|
@@ -29218,6 +29382,7 @@ const useSwap = () => {
|
|
|
29218
29382
|
defaultTokensPerChain,
|
|
29219
29383
|
disabledChains,
|
|
29220
29384
|
availableChains,
|
|
29385
|
+
availableTokens,
|
|
29221
29386
|
},
|
|
29222
29387
|
chainId: defaultToChainId,
|
|
29223
29388
|
direction: "to",
|
|
@@ -29242,6 +29407,7 @@ const useSwap = () => {
|
|
|
29242
29407
|
initialAssets,
|
|
29243
29408
|
disabledChains,
|
|
29244
29409
|
availableChains,
|
|
29410
|
+
availableTokens,
|
|
29245
29411
|
defaultTokensPerChain,
|
|
29246
29412
|
tokens,
|
|
29247
29413
|
]);
|
|
@@ -31033,17 +31199,18 @@ function useNativeTokenForChain(chain) {
|
|
|
31033
31199
|
return cantonTokens;
|
|
31034
31200
|
}
|
|
31035
31201
|
};
|
|
31202
|
+
const tokens = getTokensForChainType();
|
|
31036
31203
|
const nativeTokenForChainType = React.useMemo(() => {
|
|
31037
31204
|
if (!chain)
|
|
31038
31205
|
return undefined;
|
|
31039
|
-
return findNativeToken(
|
|
31040
|
-
}, [chain]);
|
|
31206
|
+
return findNativeToken(tokens, chain);
|
|
31207
|
+
}, [chain, tokens]);
|
|
31041
31208
|
return { nativeToken: nativeTokenForChainType };
|
|
31042
31209
|
}
|
|
31043
31210
|
|
|
31044
31211
|
const useEvmNativeBalance = ({ address, chain, }) => {
|
|
31045
31212
|
const { isChainTypeConnected } = useWallet();
|
|
31046
|
-
const { data: nativeEvmBalance, isLoading } = wagmi.useBalance({
|
|
31213
|
+
const { data: nativeEvmBalance, isLoading, isError, } = wagmi.useBalance({
|
|
31047
31214
|
address: address,
|
|
31048
31215
|
chainId: Number(chain?.chainId),
|
|
31049
31216
|
query: {
|
|
@@ -31055,6 +31222,8 @@ const useEvmNativeBalance = ({ address, chain, }) => {
|
|
|
31055
31222
|
},
|
|
31056
31223
|
});
|
|
31057
31224
|
const balance = React.useMemo(() => {
|
|
31225
|
+
if (isArcChain(chain?.chainId) && isError)
|
|
31226
|
+
return undefined;
|
|
31058
31227
|
if (nativeEvmBalance?.decimals != null && nativeEvmBalance?.value != null) {
|
|
31059
31228
|
if (chain?.chainId === CHAIN_IDS.HEDERA) {
|
|
31060
31229
|
return {
|
|
@@ -31068,7 +31237,12 @@ const useEvmNativeBalance = ({ address, chain, }) => {
|
|
|
31068
31237
|
};
|
|
31069
31238
|
}
|
|
31070
31239
|
return;
|
|
31071
|
-
}, [
|
|
31240
|
+
}, [
|
|
31241
|
+
nativeEvmBalance?.decimals,
|
|
31242
|
+
nativeEvmBalance?.value,
|
|
31243
|
+
chain?.chainId,
|
|
31244
|
+
isError,
|
|
31245
|
+
]);
|
|
31072
31246
|
return {
|
|
31073
31247
|
balance,
|
|
31074
31248
|
isLoading,
|
|
@@ -31555,7 +31729,7 @@ function hederaWalletConnect(parameters) {
|
|
|
31555
31729
|
const optionalChains = config.chains.map((x) => x.id);
|
|
31556
31730
|
if (!optionalChains.length)
|
|
31557
31731
|
return;
|
|
31558
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
31732
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-BVCh4tlV.js'); });
|
|
31559
31733
|
const rawProvider = await EthereumProvider.init({
|
|
31560
31734
|
...restParameters,
|
|
31561
31735
|
disableProviderPing: true,
|
|
@@ -32870,6 +33044,27 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
|
|
|
32870
33044
|
normalizeFee: convertTempoFeeToStablecoinUnits,
|
|
32871
33045
|
};
|
|
32872
33046
|
}
|
|
33047
|
+
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)) {
|
|
33054
|
+
return null;
|
|
33055
|
+
}
|
|
33056
|
+
return {
|
|
33057
|
+
fromTokenPaysGasFees: isUsdc || isNative,
|
|
33058
|
+
gasTokenBalanceWei: nativeBalance.value,
|
|
33059
|
+
normalizeFee: (fee) => fee,
|
|
33060
|
+
fromAmountToGasUnits: isUsdc
|
|
33061
|
+
? (amount) => amount * 10n ** 12n
|
|
33062
|
+
: undefined,
|
|
33063
|
+
gasUnitsToFromAmount: isUsdc
|
|
33064
|
+
? (amount) => amount / 10n ** 12n
|
|
33065
|
+
: undefined,
|
|
33066
|
+
};
|
|
33067
|
+
}
|
|
32873
33068
|
return {
|
|
32874
33069
|
fromTokenPaysGasFees: fromToken.address.toLowerCase() ===
|
|
32875
33070
|
chainTypeToNativeTokenAddressMap[fromToken.type].toLowerCase(),
|
|
@@ -32877,10 +33072,10 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
|
|
|
32877
33072
|
normalizeFee: (fee) => fee,
|
|
32878
33073
|
};
|
|
32879
33074
|
}, [
|
|
32880
|
-
fromToken
|
|
32881
|
-
fromToken?.type,
|
|
33075
|
+
fromToken,
|
|
32882
33076
|
fromChain?.chainId,
|
|
32883
33077
|
nativeBalance?.value,
|
|
33078
|
+
nativeBalance?.decimals,
|
|
32884
33079
|
tempoFeeData,
|
|
32885
33080
|
]);
|
|
32886
33081
|
/**
|
|
@@ -32895,9 +33090,20 @@ function useSourceChainGasToken({ fromChain, fromToken, }) {
|
|
|
32895
33090
|
return evmTokens.find((t) => t.chainId === fromChain.chainId &&
|
|
32896
33091
|
t.address.toLowerCase() === tempoFeeData.gasTokenAddress.toLowerCase());
|
|
32897
33092
|
}
|
|
33093
|
+
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;
|
|
33101
|
+
}
|
|
32898
33102
|
return nativeToken;
|
|
32899
33103
|
}, [
|
|
32900
33104
|
fromChain?.chainId,
|
|
33105
|
+
fromChain?.nativeCurrency.symbol,
|
|
33106
|
+
fromChain?.nativeCurrency.name,
|
|
32901
33107
|
fromToken?.address,
|
|
32902
33108
|
nativeToken,
|
|
32903
33109
|
tempoFeeData,
|
|
@@ -33056,22 +33262,57 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
|
|
|
33056
33262
|
(sameTokenBetweenFees
|
|
33057
33263
|
? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
|
|
33058
33264
|
: 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
|
+
};
|
|
33059
33296
|
const checkIsGasBalanceEnough = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
|
|
33060
33297
|
if (!chainFeeParams)
|
|
33061
33298
|
return false;
|
|
33062
|
-
|
|
33063
|
-
|
|
33064
|
-
|
|
33065
|
-
|
|
33066
|
-
|
|
33299
|
+
const total = calculateTotalGasBalanceNeeded({
|
|
33300
|
+
fromAmount,
|
|
33301
|
+
networkFeesWei,
|
|
33302
|
+
chainFeeParams,
|
|
33303
|
+
});
|
|
33304
|
+
return total != null && total <= chainFeeParams.gasTokenBalanceWei;
|
|
33067
33305
|
};
|
|
33068
33306
|
const calculateMinAmountValueWarnMsg = ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }) => {
|
|
33069
|
-
if (!chainFeeParams?.fromTokenPaysGasFees)
|
|
33307
|
+
if (!chainFeeParams?.fromTokenPaysGasFees || networkFeesWei == null)
|
|
33070
33308
|
return undefined;
|
|
33071
33309
|
const minAmount = chainFeeParams.gasTokenBalanceWei - networkFeesWei;
|
|
33072
33310
|
if (minAmount <= BigInt(0))
|
|
33073
33311
|
return undefined;
|
|
33074
|
-
|
|
33312
|
+
const amountInTokenUnits = chainFeeParams.gasUnitsToFromAmount?.(minAmount) ?? minAmount;
|
|
33313
|
+
if (amountInTokenUnits <= 0n)
|
|
33314
|
+
return undefined;
|
|
33315
|
+
return formatBNToReadable(amountInTokenUnits, fromTokenDecimals);
|
|
33075
33316
|
};
|
|
33076
33317
|
/**
|
|
33077
33318
|
* Calculates the estimated duration of a route
|
|
@@ -33120,14 +33361,22 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
33120
33361
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
33121
33362
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
33122
33363
|
firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
|
|
33123
|
-
const totalNativeFees =
|
|
33124
|
-
|
|
33125
|
-
|
|
33126
|
-
|
|
33127
|
-
|
|
33128
|
-
|
|
33129
|
-
|
|
33130
|
-
|
|
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);
|
|
33131
33380
|
const isGasBalanceEnough = checkIsGasBalanceEnough({
|
|
33132
33381
|
chainFeeParams,
|
|
33133
33382
|
fromAmount,
|
|
@@ -33143,10 +33392,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
33143
33392
|
estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
|
|
33144
33393
|
isSingleChainRoute,
|
|
33145
33394
|
});
|
|
33146
|
-
|
|
33147
|
-
|
|
33148
|
-
|
|
33149
|
-
|
|
33395
|
+
const totalGasBalanceNeeded = calculateTotalGasBalanceNeeded({
|
|
33396
|
+
fromAmount,
|
|
33397
|
+
networkFeesWei,
|
|
33398
|
+
chainFeeParams,
|
|
33399
|
+
});
|
|
33400
|
+
const gasBalanceNeeded = gasToken && totalGasBalanceNeeded != null
|
|
33150
33401
|
? formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals)
|
|
33151
33402
|
: undefined;
|
|
33152
33403
|
return {
|
|
@@ -33168,7 +33419,7 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
33168
33419
|
expectedGasRefundCostUSD,
|
|
33169
33420
|
sameTokenBetweenFees,
|
|
33170
33421
|
fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
33171
|
-
totalNativeFees,
|
|
33422
|
+
totalNativeFees: totalNativeFees ?? 0n,
|
|
33172
33423
|
isGasBalanceEnough,
|
|
33173
33424
|
minAmountValueWarnMsg,
|
|
33174
33425
|
estimatedRouteDuration,
|
|
@@ -33217,8 +33468,12 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
33217
33468
|
case squidTypes.ChainType.EVM: {
|
|
33218
33469
|
const client = await getClient(chain);
|
|
33219
33470
|
const feeData = await client.getFeeData();
|
|
33220
|
-
if (!feeData.maxFeePerGas)
|
|
33471
|
+
if (!feeData.maxFeePerGas) {
|
|
33472
|
+
if (isArcChain(chain.chainId)) {
|
|
33473
|
+
throw new Error("Gas price is unavailable");
|
|
33474
|
+
}
|
|
33221
33475
|
return BigInt(0);
|
|
33476
|
+
}
|
|
33222
33477
|
let maxFeePerGas = feeData.maxFeePerGas;
|
|
33223
33478
|
if (token.chainId === CHAIN_IDS.HEDERA) {
|
|
33224
33479
|
maxFeePerGas = scaleWeiToHbar(BigInt(feeData.maxFeePerGas));
|
|
@@ -33238,6 +33493,9 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
33238
33493
|
value: 1,
|
|
33239
33494
|
chainId: chain.chainId,
|
|
33240
33495
|
});
|
|
33496
|
+
if (isArcChain(chain.chainId) && gas <= 0n) {
|
|
33497
|
+
throw new Error("Gas estimate is unavailable");
|
|
33498
|
+
}
|
|
33241
33499
|
return gas * maxFeePerGas;
|
|
33242
33500
|
}
|
|
33243
33501
|
const erc20Interface = new ethers.Interface(viem.erc20Abi);
|
|
@@ -33252,6 +33510,9 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
33252
33510
|
chainId: chain.chainId,
|
|
33253
33511
|
});
|
|
33254
33512
|
const feeWei = gas * maxFeePerGas;
|
|
33513
|
+
if (isArcChain(chain.chainId) && feeWei <= 0n) {
|
|
33514
|
+
throw new Error("Gas estimate is unavailable");
|
|
33515
|
+
}
|
|
33255
33516
|
// Tempo gas fees are denominated 18 units,
|
|
33256
33517
|
// this value needs to be scaled to 6 decimals
|
|
33257
33518
|
if (chain.chainId === CHAIN_IDS.TEMPO) {
|
|
@@ -33299,35 +33560,45 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
33299
33560
|
}
|
|
33300
33561
|
|
|
33301
33562
|
function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
33302
|
-
const { data
|
|
33563
|
+
const { data, isLoading, isFetching, isError, refetch } = useSendTransactionGas({
|
|
33303
33564
|
chain,
|
|
33304
33565
|
token,
|
|
33305
33566
|
from,
|
|
33306
33567
|
});
|
|
33568
|
+
const estimatedGas = isError || isFetching ? undefined : data;
|
|
33569
|
+
const networkFeesWei = estimatedGas == null
|
|
33570
|
+
? undefined
|
|
33571
|
+
: isArcChain(chain?.chainId)
|
|
33572
|
+
? addGasReserve(estimatedGas)
|
|
33573
|
+
: estimatedGas;
|
|
33307
33574
|
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
33308
33575
|
fromChain: chain,
|
|
33309
33576
|
fromToken: token,
|
|
33310
33577
|
});
|
|
33311
33578
|
const isGasBalanceEnough = React.useMemo(() => {
|
|
33312
|
-
if (!amount ||
|
|
33579
|
+
if (!amount || token?.decimals == null || !gasToken)
|
|
33313
33580
|
return false;
|
|
33314
33581
|
return checkIsGasBalanceEnough({
|
|
33315
33582
|
fromAmount: parseToBigInt(amount, token.decimals).toString(),
|
|
33316
|
-
networkFeesWei
|
|
33583
|
+
networkFeesWei,
|
|
33317
33584
|
chainFeeParams,
|
|
33318
33585
|
});
|
|
33319
|
-
}, [amount,
|
|
33586
|
+
}, [amount, networkFeesWei, token, chainFeeParams, gasToken]);
|
|
33320
33587
|
const gasBalanceNeeded = React.useMemo(() => {
|
|
33321
|
-
if (!amount ||
|
|
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)
|
|
33322
33596
|
return undefined;
|
|
33323
|
-
// gas fees + fromAmount (if fromToken is gas token)
|
|
33324
|
-
const totalGasBalanceNeeded = estimatedGas +
|
|
33325
|
-
parseToBigInt(chainFeeParams?.fromTokenPaysGasFees ? (amount ?? "0") : "0", token.decimals);
|
|
33326
33597
|
return formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals);
|
|
33327
33598
|
}, [
|
|
33328
33599
|
amount,
|
|
33329
|
-
chainFeeParams
|
|
33330
|
-
|
|
33600
|
+
chainFeeParams,
|
|
33601
|
+
networkFeesWei,
|
|
33331
33602
|
gasToken?.decimals,
|
|
33332
33603
|
token?.decimals,
|
|
33333
33604
|
]);
|
|
@@ -33338,20 +33609,22 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
33338
33609
|
parseToBigInt(amount, token.decimals));
|
|
33339
33610
|
}, [amount, balance, token?.decimals]);
|
|
33340
33611
|
const minAmountValueWarnMsg = React.useMemo(() => {
|
|
33341
|
-
if (!token?.address || !
|
|
33612
|
+
if (!token?.address || !gasToken || !chainFeeParams)
|
|
33342
33613
|
return undefined;
|
|
33343
33614
|
return calculateMinAmountValueWarnMsg({
|
|
33344
33615
|
chainFeeParams,
|
|
33345
|
-
networkFeesWei
|
|
33616
|
+
networkFeesWei,
|
|
33346
33617
|
fromTokenDecimals: token.decimals,
|
|
33347
33618
|
});
|
|
33348
|
-
}, [
|
|
33619
|
+
}, [networkFeesWei, token, chainFeeParams, gasToken]);
|
|
33349
33620
|
return {
|
|
33350
33621
|
estimatedGas,
|
|
33351
33622
|
gasBalanceNeeded,
|
|
33352
33623
|
isBalanceEnough,
|
|
33353
33624
|
tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
33354
|
-
isLoading,
|
|
33625
|
+
isLoading: isLoading || isFetching,
|
|
33626
|
+
isError,
|
|
33627
|
+
refetchGasEstimate: refetch,
|
|
33355
33628
|
isGasBalanceEnough,
|
|
33356
33629
|
minAmountValueWarnMsg,
|
|
33357
33630
|
};
|
|
@@ -34252,6 +34525,19 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
34252
34525
|
const { getChainType } = useSquidChains();
|
|
34253
34526
|
const { switchChainAsync } = wagmi.useSwitchChain();
|
|
34254
34527
|
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
|
+
});
|
|
34255
34541
|
const isSagaEvmSameChainSwap = isSameChain &&
|
|
34256
34542
|
fromChain?.chainId.toString() === CHAIN_IDS.SAGA_EVM.toString();
|
|
34257
34543
|
// Swaps on SagaEVM are regular EVM transactions, following the standard ERC20 approve/allowance mechanism.
|
|
@@ -34412,13 +34698,20 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
34412
34698
|
return false;
|
|
34413
34699
|
}
|
|
34414
34700
|
}, {
|
|
34415
|
-
onSuccess: async () => {
|
|
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
|
+
}
|
|
34416
34709
|
await allowanceQuery?.refetch();
|
|
34417
34710
|
queryClient.invalidateQueries(getPrefixKey(exports.QueryKeys.RouteApproved));
|
|
34418
34711
|
// After an approval, we refetch the transaction query with all required parameters
|
|
34419
34712
|
// This is to ensure we're using the latest expiry timestamp
|
|
34420
34713
|
if (squidRoute) {
|
|
34421
|
-
queryClient.refetchQueries({
|
|
34714
|
+
await queryClient.refetchQueries({
|
|
34422
34715
|
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,
|
|
34423
34716
|
// TODO: update types
|
|
34424
34717
|
squidRoute.params?.overrideGasRefundAddress),
|
|
@@ -39293,6 +39586,7 @@ exports.getStepsInfos = getStepsInfos;
|
|
|
39293
39586
|
exports.getSuggestedAmountsForCurrency = getSuggestedAmountsForCurrency;
|
|
39294
39587
|
exports.getSupportedChainIdsForDirection = getSupportedChainIdsForDirection;
|
|
39295
39588
|
exports.getSwapTxStatusRefetchInterval = getSwapTxStatusRefetchInterval;
|
|
39589
|
+
exports.getTokenAddressForSelection = getTokenAddressForSelection;
|
|
39296
39590
|
exports.getTokenAssetsKey = getTokenAssetsKey;
|
|
39297
39591
|
exports.getTokenImage = getTokenImage;
|
|
39298
39592
|
exports.getTokensForChain = getTokensForChain;
|
|
@@ -39349,6 +39643,7 @@ exports.nativeSuiTokenAddress = nativeSuiTokenAddress;
|
|
|
39349
39643
|
exports.nativeXrplTokenAddress = nativeXrplTokenAddress;
|
|
39350
39644
|
exports.normalizeError = normalizeError;
|
|
39351
39645
|
exports.normalizeIbcAddress = normalizeIbcAddress;
|
|
39646
|
+
exports.normalizeSwapParamsForSelection = normalizeSwapParamsForSelection;
|
|
39352
39647
|
exports.normalizeTokenSymbol = normalizeTokenSymbol;
|
|
39353
39648
|
exports.parseEvmAddress = parseEvmAddress;
|
|
39354
39649
|
exports.parseInitialAssetsFromUrl = parseInitialAssetsFromUrl;
|
|
@@ -39462,4 +39757,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
39462
39757
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
39463
39758
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
39464
39759
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
39465
|
-
//# sourceMappingURL=index-
|
|
39760
|
+
//# sourceMappingURL=index-BBJD55XX.js.map
|