@0xsquid/react-hooks 8.6.0 → 8.7.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 +3 -0
- package/dist/core/queries/queries-keys.d.ts +1 -1
- package/dist/core/types/config.d.ts +0 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/tokens/useSourceChainGasToken.d.ts +13 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +11 -2
- package/dist/hooks/transaction/useEstimate.d.ts +7 -12
- package/dist/hooks/transaction/useTempoFeeCheck.d.ts +11 -0
- package/dist/{index-BvAot66c.js → index-BOMoTOCH.js} +282 -157
- package/dist/index-BOMoTOCH.js.map +1 -0
- package/dist/{index-Ck3Byj7H.js → index-CpHc3uRR.js} +282 -157
- package/dist/index-CpHc3uRR.js.map +1 -0
- package/dist/{index.es-C_BgGjLx.js → index.es-Bx1b09ob.js} +2 -2
- package/dist/{index.es-C_BgGjLx.js.map → index.es-Bx1b09ob.js.map} +1 -1
- package/dist/{index.es-83oSJcJe.js → index.es-DYEb3pTJ.js} +2 -2
- package/dist/{index.es-83oSJcJe.js.map → index.es-DYEb3pTJ.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{secretService-Cj_HK_on.js → secretService-0Y9Bj_Ic.js} +2 -2
- package/dist/{secretService-Cj_HK_on.js.map → secretService-0Y9Bj_Ic.js.map} +1 -1
- package/dist/{secretService-zFFQM-jC.js → secretService-DnKMq9Ib.js} +2 -2
- package/dist/{secretService-zFFQM-jC.js.map → secretService-DnKMq9Ib.js.map} +1 -1
- package/dist/server.esm.js +3 -0
- package/dist/server.esm.js.map +1 -1
- package/dist/server.js +3 -0
- package/dist/server.js.map +1 -1
- package/dist/services/internal/assetsService.d.ts +2 -2
- package/dist/services/internal/estimateService.d.ts +15 -28
- package/dist/services/internal/tempoService.d.ts +42 -0
- package/dist/{stellarService.client-CI86BfjV.js → stellarService.client-B3kAxROD.js} +2 -2
- package/dist/{stellarService.client-CI86BfjV.js.map → stellarService.client-B3kAxROD.js.map} +1 -1
- package/dist/{stellarService.client-CBzr6pLs.js → stellarService.client-Dyichswq.js} +2 -2
- package/dist/{stellarService.client-CBzr6pLs.js.map → stellarService.client-Dyichswq.js.map} +1 -1
- package/package.json +1 -1
- package/dist/hooks/user/useUserParams.d.ts +0 -4
- package/dist/index-BvAot66c.js.map +0 -1
- package/dist/index-Ck3Byj7H.js.map +0 -1
|
@@ -124,6 +124,9 @@ const CHAIN_IDS = {
|
|
|
124
124
|
SONEIUM: "1868",
|
|
125
125
|
PEAQ: "3338",
|
|
126
126
|
HEDERA: "295",
|
|
127
|
+
MANTRA: "5888",
|
|
128
|
+
CITREA: "4114",
|
|
129
|
+
TEMPO: "4217",
|
|
127
130
|
// others
|
|
128
131
|
BITCOIN: "bitcoin",
|
|
129
132
|
SOLANA: "solana-mainnet-beta",
|
|
@@ -22388,7 +22391,7 @@ const keys = () => ({
|
|
|
22388
22391
|
// ============
|
|
22389
22392
|
// Transactions
|
|
22390
22393
|
// ============
|
|
22391
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage,
|
|
22394
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
|
|
22392
22395
|
...keys().transactions(),
|
|
22393
22396
|
QueryKeys.Transaction,
|
|
22394
22397
|
fromChainId,
|
|
@@ -22397,7 +22400,6 @@ const keys = () => ({
|
|
|
22397
22400
|
fromTokenAddress,
|
|
22398
22401
|
price,
|
|
22399
22402
|
slippage,
|
|
22400
|
-
getGasOnDestination,
|
|
22401
22403
|
sourceUserAddress,
|
|
22402
22404
|
degenMode,
|
|
22403
22405
|
destinationAddress,
|
|
@@ -22586,7 +22588,6 @@ const getConfigWithDefaults = (config) => {
|
|
|
22586
22588
|
integratorId: get$2(config, "integratorId", defaultConfigValues.integratorId),
|
|
22587
22589
|
slippage: get$2(config, "slippage", defaultConfigValues.slippage),
|
|
22588
22590
|
collectFees: get$2(config, "collectFees", defaultConfigValues.collectFees),
|
|
22589
|
-
enableGetGasOnDestination: get$2(config, "enableGetGasOnDestination", defaultConfigValues.enableGetGasOnDestination),
|
|
22590
22591
|
apiUrl: get$2(config, "apiUrl", defaultConfigValues.apiUrl),
|
|
22591
22592
|
priceImpactWarnings: get$2(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
|
|
22592
22593
|
initialAssets: get$2(config, "initialAssets", defaultConfigValues.initialAssets),
|
|
@@ -23080,8 +23081,8 @@ const sortAllTokens = (tokenA, tokenB) => {
|
|
|
23080
23081
|
return 0;
|
|
23081
23082
|
};
|
|
23082
23083
|
const findToken = (tokens, chainId, address) => tokens.find((t) => t.chainId === chainId && t.address === address);
|
|
23083
|
-
const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain
|
|
23084
|
-
t.chainId == chain
|
|
23084
|
+
const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase() &&
|
|
23085
|
+
t.chainId == chain.chainId);
|
|
23085
23086
|
const normalizeIbcAddress = (address) => {
|
|
23086
23087
|
if (!address.toLowerCase().startsWith("ibc/")) {
|
|
23087
23088
|
return address;
|
|
@@ -23292,7 +23293,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23292
23293
|
};
|
|
23293
23294
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23294
23295
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23295
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23296
|
+
const { fetchAllSecretBalances } = await import('./secretService-DnKMq9Ib.js');
|
|
23296
23297
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23297
23298
|
};
|
|
23298
23299
|
function getTokenAssetsKey(token) {
|
|
@@ -26690,7 +26691,7 @@ function useStellarWallets() {
|
|
|
26690
26691
|
try {
|
|
26691
26692
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26692
26693
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26693
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26694
|
+
const { formatStellarWallet } = await import('./stellarService.client-B3kAxROD.js');
|
|
26694
26695
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26695
26696
|
const promises = modules.map(async (module) => {
|
|
26696
26697
|
const isAvailable = await module.isAvailable();
|
|
@@ -29331,8 +29332,8 @@ function timeout(ms, promise) {
|
|
|
29331
29332
|
return Promise.race([promise, timeoutPromise]);
|
|
29332
29333
|
}
|
|
29333
29334
|
|
|
29334
|
-
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
29335
|
-
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29335
|
+
const DEFAULT_REFRESH_INTERVAL_MS$1 = 15000;
|
|
29336
|
+
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29336
29337
|
const { isChainTypeConnected } = useWallet();
|
|
29337
29338
|
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
29338
29339
|
const userAddressParsed = userAddress;
|
|
@@ -29383,7 +29384,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29383
29384
|
isLoading: isErc20Loading,
|
|
29384
29385
|
};
|
|
29385
29386
|
};
|
|
29386
|
-
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29387
|
+
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29387
29388
|
const { isConnected } = useCosmosContext();
|
|
29388
29389
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29389
29390
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
@@ -29407,7 +29408,7 @@ const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
29407
29408
|
});
|
|
29408
29409
|
return { balance, isLoading };
|
|
29409
29410
|
};
|
|
29410
|
-
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29411
|
+
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29411
29412
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29412
29413
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29413
29414
|
queryFn: async () => {
|
|
@@ -29438,7 +29439,7 @@ const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
|
29438
29439
|
}, [balanceBn]);
|
|
29439
29440
|
return { balance, isLoading };
|
|
29440
29441
|
};
|
|
29441
|
-
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29442
|
+
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29442
29443
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29443
29444
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29444
29445
|
queryFn: async () => {
|
|
@@ -29461,7 +29462,7 @@ const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29461
29462
|
});
|
|
29462
29463
|
return { balance, isLoading };
|
|
29463
29464
|
};
|
|
29464
|
-
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29465
|
+
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29465
29466
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29466
29467
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29467
29468
|
queryFn: async () => {
|
|
@@ -29481,7 +29482,7 @@ const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs
|
|
|
29481
29482
|
});
|
|
29482
29483
|
return { balance, isLoading };
|
|
29483
29484
|
};
|
|
29484
|
-
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29485
|
+
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29485
29486
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29486
29487
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29487
29488
|
queryFn: async () => {
|
|
@@ -29525,6 +29526,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29525
29526
|
}
|
|
29526
29527
|
};
|
|
29527
29528
|
const nativeTokenForChainType = useMemo(() => {
|
|
29529
|
+
if (!chain)
|
|
29530
|
+
return undefined;
|
|
29528
29531
|
return findNativeToken(getTokensForChainType(), chain);
|
|
29529
29532
|
}, [chain]);
|
|
29530
29533
|
return { nativeToken: nativeTokenForChainType };
|
|
@@ -30008,7 +30011,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30008
30011
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30009
30012
|
if (!optionalChains.length)
|
|
30010
30013
|
return;
|
|
30011
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30014
|
+
const { EthereumProvider } = await import('./index.es-DYEb3pTJ.js');
|
|
30012
30015
|
const rawProvider = await EthereumProvider.init({
|
|
30013
30016
|
...restParameters,
|
|
30014
30017
|
disableProviderPing: true,
|
|
@@ -30584,8 +30587,9 @@ function useStellarTrustLine({ address, chain, token, amount }) {
|
|
|
30584
30587
|
if (token?.type !== ChainType.STELLAR) {
|
|
30585
30588
|
return true;
|
|
30586
30589
|
}
|
|
30587
|
-
//
|
|
30588
|
-
|
|
30590
|
+
// Only stellar issued tokens need a trust line
|
|
30591
|
+
// (e.g. not needed for native or contract tokens)
|
|
30592
|
+
if (!isStellarIssuedToken(token)) {
|
|
30589
30593
|
return true;
|
|
30590
30594
|
}
|
|
30591
30595
|
if (!amount) {
|
|
@@ -31156,6 +31160,155 @@ const useSingleTokenPrice = (tokenData) => {
|
|
|
31156
31160
|
return { tokenPrice, getUSDValue };
|
|
31157
31161
|
};
|
|
31158
31162
|
|
|
31163
|
+
/**
|
|
31164
|
+
* @docs https://docs.tempo.xyz/protocol/fees/spec-fee-amm#2-feemanager-contract
|
|
31165
|
+
*/
|
|
31166
|
+
const TEMPO_FEE_MANAGER_ADDRESS = "0xfeec000000000000000000000000000000000000";
|
|
31167
|
+
const feeManagerAbi = [
|
|
31168
|
+
{
|
|
31169
|
+
name: "userTokens",
|
|
31170
|
+
type: "function",
|
|
31171
|
+
stateMutability: "view",
|
|
31172
|
+
inputs: [{ type: "address", name: "user" }],
|
|
31173
|
+
outputs: [{ type: "address" }],
|
|
31174
|
+
},
|
|
31175
|
+
];
|
|
31176
|
+
const isTempoChain = (chainId) => chainId === CHAIN_IDS.TEMPO;
|
|
31177
|
+
/**
|
|
31178
|
+
* Convert a gas fee amount from 18 decimals (attodollars)
|
|
31179
|
+
* to 6-decimal TIP-20 stablecoin units (microdollars).
|
|
31180
|
+
* All TIP-20 tokens on Tempo have 6 decimals.
|
|
31181
|
+
* @docs https://docs.tempo.xyz/protocol/fees/spec-fee#fee-units
|
|
31182
|
+
*/
|
|
31183
|
+
const convertTempoFeeToStablecoinUnits = (feeIn18Dec) => feeIn18Dec / BigInt(10 ** 12);
|
|
31184
|
+
|
|
31185
|
+
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
31186
|
+
/**
|
|
31187
|
+
* Returns raw on-chain gas token data for Tempo chains, or null when the source
|
|
31188
|
+
* chain is not Tempo.
|
|
31189
|
+
*/
|
|
31190
|
+
const useTempoFeeCheck = ({ fromChain, fromToken, }) => {
|
|
31191
|
+
const { connectedAddresses } = useWallet();
|
|
31192
|
+
const evmAddress = parseEvmAddress(connectedAddresses[ChainType.EVM]);
|
|
31193
|
+
const isTempo = isTempoChain(fromChain?.chainId);
|
|
31194
|
+
const chainId = Number(fromChain?.chainId);
|
|
31195
|
+
// Read account-level gas token preference from FeeManager precompile
|
|
31196
|
+
// See docs: https://docs.tempo.xyz/protocol/fees/spec-fee#account-level
|
|
31197
|
+
const { data: accountGasTokenAddress } = useReadContract({
|
|
31198
|
+
address: TEMPO_FEE_MANAGER_ADDRESS,
|
|
31199
|
+
abi: feeManagerAbi,
|
|
31200
|
+
functionName: "userTokens",
|
|
31201
|
+
args: evmAddress ? [evmAddress] : undefined,
|
|
31202
|
+
chainId,
|
|
31203
|
+
query: {
|
|
31204
|
+
enabled: isTempo && !!evmAddress,
|
|
31205
|
+
staleTime: 30_000,
|
|
31206
|
+
},
|
|
31207
|
+
});
|
|
31208
|
+
const hasAccountFeePreference = !!accountGasTokenAddress &&
|
|
31209
|
+
// By default, the zero address is returned when the user has no preference set
|
|
31210
|
+
zeroAddress$1.toLowerCase() !== accountGasTokenAddress.toLowerCase();
|
|
31211
|
+
// Fetch balance of the account-preferred gas token (if set)
|
|
31212
|
+
const { data: accountGasTokenBalance } = useBalance({
|
|
31213
|
+
address: evmAddress,
|
|
31214
|
+
token: hasAccountFeePreference ? accountGasTokenAddress : undefined,
|
|
31215
|
+
chainId,
|
|
31216
|
+
query: {
|
|
31217
|
+
enabled: isTempo && hasAccountFeePreference && !!evmAddress,
|
|
31218
|
+
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
|
|
31219
|
+
retry: 2,
|
|
31220
|
+
},
|
|
31221
|
+
});
|
|
31222
|
+
const fromTokenAddress = parseEvmAddress(fromToken?.address);
|
|
31223
|
+
const { data: fromTokenBalance } = useBalance({
|
|
31224
|
+
address: evmAddress,
|
|
31225
|
+
token: fromTokenAddress,
|
|
31226
|
+
chainId,
|
|
31227
|
+
query: {
|
|
31228
|
+
enabled: isTempo && !!evmAddress,
|
|
31229
|
+
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
|
|
31230
|
+
retry: 2,
|
|
31231
|
+
},
|
|
31232
|
+
});
|
|
31233
|
+
if (!isTempo)
|
|
31234
|
+
return null;
|
|
31235
|
+
if (hasAccountFeePreference) {
|
|
31236
|
+
if (!accountGasTokenAddress || !accountGasTokenBalance)
|
|
31237
|
+
return null;
|
|
31238
|
+
return {
|
|
31239
|
+
gasTokenAddress: accountGasTokenAddress,
|
|
31240
|
+
gasBalance: accountGasTokenBalance.value,
|
|
31241
|
+
};
|
|
31242
|
+
}
|
|
31243
|
+
if (!fromTokenAddress || !fromTokenBalance)
|
|
31244
|
+
return null;
|
|
31245
|
+
return {
|
|
31246
|
+
gasTokenAddress: fromTokenAddress,
|
|
31247
|
+
gasBalance: fromTokenBalance.value,
|
|
31248
|
+
};
|
|
31249
|
+
};
|
|
31250
|
+
|
|
31251
|
+
/**
|
|
31252
|
+
* Hook that returns the gas token and chain fee params for a given source chain and token.
|
|
31253
|
+
*/
|
|
31254
|
+
function useSourceChainGasToken({ fromChain, fromToken, }) {
|
|
31255
|
+
const { nativeToken } = useNativeTokenForChain(fromChain);
|
|
31256
|
+
const { evmTokens } = useSquidTokens();
|
|
31257
|
+
const { nativeBalance } = useNativeBalance(fromChain);
|
|
31258
|
+
const tempoFeeData = useTempoFeeCheck({ fromChain, fromToken });
|
|
31259
|
+
const chainFeeParams = useMemo(() => {
|
|
31260
|
+
if (fromToken?.address == null ||
|
|
31261
|
+
fromChain?.chainId == null ||
|
|
31262
|
+
nativeBalance?.value == null) {
|
|
31263
|
+
return null;
|
|
31264
|
+
}
|
|
31265
|
+
if (isTempoChain(fromChain.chainId)) {
|
|
31266
|
+
if (!tempoFeeData)
|
|
31267
|
+
return null;
|
|
31268
|
+
const fromTokenPaysGasFees = tempoFeeData.gasTokenAddress.toLowerCase() ===
|
|
31269
|
+
fromToken.address.toLowerCase();
|
|
31270
|
+
return {
|
|
31271
|
+
fromTokenPaysGasFees,
|
|
31272
|
+
gasTokenBalanceWei: tempoFeeData.gasBalance,
|
|
31273
|
+
normalizeFee: convertTempoFeeToStablecoinUnits,
|
|
31274
|
+
};
|
|
31275
|
+
}
|
|
31276
|
+
return {
|
|
31277
|
+
fromTokenPaysGasFees: fromToken.address.toLowerCase() ===
|
|
31278
|
+
chainTypeToNativeTokenAddressMap[fromToken.type].toLowerCase(),
|
|
31279
|
+
gasTokenBalanceWei: nativeBalance.value,
|
|
31280
|
+
normalizeFee: (fee) => fee,
|
|
31281
|
+
};
|
|
31282
|
+
}, [
|
|
31283
|
+
fromToken?.address,
|
|
31284
|
+
fromToken?.type,
|
|
31285
|
+
fromChain?.chainId,
|
|
31286
|
+
nativeBalance?.value,
|
|
31287
|
+
tempoFeeData,
|
|
31288
|
+
]);
|
|
31289
|
+
/**
|
|
31290
|
+
* The token to pay for gas on the source chain.
|
|
31291
|
+
*/
|
|
31292
|
+
const gasToken = useMemo(() => {
|
|
31293
|
+
if (fromChain?.chainId == null || fromToken?.address == null)
|
|
31294
|
+
return undefined;
|
|
31295
|
+
if (isTempoChain(fromChain.chainId)) {
|
|
31296
|
+
if (!tempoFeeData)
|
|
31297
|
+
return undefined;
|
|
31298
|
+
return evmTokens.find((t) => t.chainId === fromChain.chainId &&
|
|
31299
|
+
t.address.toLowerCase() === tempoFeeData.gasTokenAddress.toLowerCase());
|
|
31300
|
+
}
|
|
31301
|
+
return nativeToken;
|
|
31302
|
+
}, [
|
|
31303
|
+
fromChain?.chainId,
|
|
31304
|
+
fromToken?.address,
|
|
31305
|
+
nativeToken,
|
|
31306
|
+
tempoFeeData,
|
|
31307
|
+
evmTokens,
|
|
31308
|
+
]);
|
|
31309
|
+
return { gasToken, chainFeeParams };
|
|
31310
|
+
}
|
|
31311
|
+
|
|
31159
31312
|
const MAX_COINGECKO_QUERY_TOKENS = 100;
|
|
31160
31313
|
const fetchHistoricalData = async (coingeckoId, timeFrame) => {
|
|
31161
31314
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -31306,24 +31459,23 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
|
|
|
31306
31459
|
(sameTokenBetweenFees
|
|
31307
31460
|
? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
|
|
31308
31461
|
: BigInt(firstGasCost?.amount ?? "0"));
|
|
31309
|
-
const
|
|
31310
|
-
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
|
|
31314
|
-
|
|
31315
|
-
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
}
|
|
31319
|
-
|
|
31320
|
-
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31325
|
-
|
|
31326
|
-
: undefined;
|
|
31462
|
+
const checkIsGasBalanceEnough = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
|
|
31463
|
+
if (!chainFeeParams)
|
|
31464
|
+
return false;
|
|
31465
|
+
if (chainFeeParams.fromTokenPaysGasFees) {
|
|
31466
|
+
return (BigInt(fromAmount ?? "0") + networkFeesWei <=
|
|
31467
|
+
chainFeeParams.gasTokenBalanceWei);
|
|
31468
|
+
}
|
|
31469
|
+
return networkFeesWei <= chainFeeParams.gasTokenBalanceWei;
|
|
31470
|
+
};
|
|
31471
|
+
const calculateMinAmountValueWarnMsg = ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }) => {
|
|
31472
|
+
if (!chainFeeParams?.fromTokenPaysGasFees)
|
|
31473
|
+
return undefined;
|
|
31474
|
+
const minAmount = chainFeeParams.gasTokenBalanceWei - networkFeesWei;
|
|
31475
|
+
if (minAmount <= BigInt(0))
|
|
31476
|
+
return undefined;
|
|
31477
|
+
return formatBNToReadable(minAmount, fromTokenDecimals);
|
|
31478
|
+
};
|
|
31327
31479
|
/**
|
|
31328
31480
|
* Calculates the estimated duration of a route
|
|
31329
31481
|
*
|
|
@@ -31362,12 +31514,10 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
|
|
|
31362
31514
|
* @returns {Object} An object containing various estimate results and calculations, including token information,
|
|
31363
31515
|
* amounts, fees, gas costs, and other relevant data for the transaction.
|
|
31364
31516
|
*/
|
|
31365
|
-
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees,
|
|
31517
|
+
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
|
|
31366
31518
|
const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
|
|
31367
31519
|
const fromAmount = squidRoute?.estimate?.fromAmount;
|
|
31368
31520
|
const fromAmountFormatted = formatAmount(fromAmount, fromToken?.decimals);
|
|
31369
|
-
const sourceChainNativeToken = findNativeToken(tokens, fromChain);
|
|
31370
|
-
const destChainNativeToken = findNativeToken(tokens, toChain);
|
|
31371
31521
|
const toAmountUSD = squidRoute?.estimate?.toAmountUSD;
|
|
31372
31522
|
const exchangeRate = squidRoute?.estimate.exchangeRate ?? "0";
|
|
31373
31523
|
const toAmountMinUSD = squidRoute?.estimate.toAmountMinUSD ?? "0";
|
|
@@ -31386,10 +31536,6 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31386
31536
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
31387
31537
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
31388
31538
|
firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
|
|
31389
|
-
const isFromTokenNative =
|
|
31390
|
-
// TODO: temporary fix, currently nativeCurrency.symbol is not always in uppercase
|
|
31391
|
-
fromToken?.symbol.toUpperCase() ===
|
|
31392
|
-
fromChain?.nativeCurrency.symbol.toUpperCase();
|
|
31393
31539
|
const totalNativeFees = calculateTotalNativeFees({
|
|
31394
31540
|
expressFeeCost,
|
|
31395
31541
|
firstFeeCost,
|
|
@@ -31397,30 +31543,32 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31397
31543
|
sameTokenBetweenFees,
|
|
31398
31544
|
});
|
|
31399
31545
|
const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
|
|
31400
|
-
const
|
|
31401
|
-
|
|
31546
|
+
const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
|
|
31547
|
+
const isGasBalanceEnough = checkIsGasBalanceEnough({
|
|
31548
|
+
chainFeeParams,
|
|
31402
31549
|
fromAmount,
|
|
31403
|
-
|
|
31404
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31405
|
-
nativeTokenBalanceFromChainWei,
|
|
31550
|
+
networkFeesWei,
|
|
31406
31551
|
});
|
|
31407
31552
|
const minAmountValueWarnMsg = calculateMinAmountValueWarnMsg({
|
|
31408
|
-
|
|
31409
|
-
|
|
31410
|
-
|
|
31411
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31553
|
+
chainFeeParams,
|
|
31554
|
+
networkFeesWei,
|
|
31555
|
+
fromTokenDecimals: fromToken?.decimals,
|
|
31412
31556
|
});
|
|
31413
31557
|
const isSingleChainRoute = fromChain?.chainId === toChain?.chainId;
|
|
31414
31558
|
const estimatedRouteDuration = formatEstimatedRouteDuration({
|
|
31415
31559
|
estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
|
|
31416
31560
|
isSingleChainRoute,
|
|
31417
31561
|
});
|
|
31562
|
+
// gas fees + fromAmount (if fromToken is gas token)
|
|
31563
|
+
const totalGasBalanceNeeded = networkFeesWei +
|
|
31564
|
+
BigInt(chainFeeParams?.fromTokenPaysGasFees ? fromAmount ?? 0 : 0);
|
|
31565
|
+
const gasBalanceNeeded = gasToken
|
|
31566
|
+
? formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals)
|
|
31567
|
+
: undefined;
|
|
31418
31568
|
return {
|
|
31419
31569
|
fromToken,
|
|
31420
31570
|
fromAmount,
|
|
31421
31571
|
fromAmountFormatted,
|
|
31422
|
-
sourceChainNativeToken,
|
|
31423
|
-
destChainNativeToken,
|
|
31424
31572
|
toAmountUSD,
|
|
31425
31573
|
exchangeRate,
|
|
31426
31574
|
toAmountMinUSD,
|
|
@@ -31435,12 +31583,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31435
31583
|
expectedGasRefundCost,
|
|
31436
31584
|
expectedGasRefundCostUSD,
|
|
31437
31585
|
sameTokenBetweenFees,
|
|
31438
|
-
|
|
31586
|
+
fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31439
31587
|
totalNativeFees,
|
|
31440
|
-
|
|
31441
|
-
fromBalanceEnoughToSwap,
|
|
31588
|
+
isGasBalanceEnough,
|
|
31442
31589
|
minAmountValueWarnMsg,
|
|
31443
31590
|
estimatedRouteDuration,
|
|
31591
|
+
gasBalanceNeeded,
|
|
31444
31592
|
};
|
|
31445
31593
|
};
|
|
31446
31594
|
/**
|
|
@@ -31474,28 +31622,6 @@ const calculateTotalWithRefundEstimate = (allFeeCosts, expectedGasRefundCost, ge
|
|
|
31474
31622
|
feeToken: firstFeeCost?.token,
|
|
31475
31623
|
};
|
|
31476
31624
|
};
|
|
31477
|
-
/**
|
|
31478
|
-
* Calculates the proposed gas amount for the destination chain.
|
|
31479
|
-
*
|
|
31480
|
-
* @param destChainNativeToken - The symbol of the native token for the destination chain.
|
|
31481
|
-
* @returns An object containing the proposed gas amount value and the currency symbol.
|
|
31482
|
-
*/
|
|
31483
|
-
const getProposedGasDestinationAmount = (destChainNativeToken) => {
|
|
31484
|
-
const gasAmounts = {
|
|
31485
|
-
GLMR: 5.289,
|
|
31486
|
-
ETH: 0.0009,
|
|
31487
|
-
AVAX: 0.115,
|
|
31488
|
-
BNB: 0.00425,
|
|
31489
|
-
FTM: 4.45,
|
|
31490
|
-
CELO: 3.052,
|
|
31491
|
-
KAVA: 2.339,
|
|
31492
|
-
MATIC: 1.795,
|
|
31493
|
-
};
|
|
31494
|
-
return {
|
|
31495
|
-
value: gasAmounts[destChainNativeToken ?? ""] ?? 0,
|
|
31496
|
-
currency: destChainNativeToken,
|
|
31497
|
-
};
|
|
31498
|
-
};
|
|
31499
31625
|
|
|
31500
31626
|
function useSendTransactionGas({ chain, token, from, }) {
|
|
31501
31627
|
return useQuery({
|
|
@@ -31517,7 +31643,11 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31517
31643
|
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
31518
31644
|
// so we'll try to use the user provided address when possible
|
|
31519
31645
|
const sender = from || dummyAddress;
|
|
31520
|
-
|
|
31646
|
+
// Tempo has no native token, so `value` transfers are rejected by the EVM.
|
|
31647
|
+
// All transfers are ERC20 transfers
|
|
31648
|
+
const supportsNativeTransfers = chain.chainId !== CHAIN_IDS.TEMPO;
|
|
31649
|
+
const isNativeToken = token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
31650
|
+
if (isNativeToken && supportsNativeTransfers) {
|
|
31521
31651
|
const gas = await client.estimateGas({
|
|
31522
31652
|
from: sender,
|
|
31523
31653
|
to: dummyAddress,
|
|
@@ -31537,7 +31667,13 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31537
31667
|
data,
|
|
31538
31668
|
chainId: chain.chainId,
|
|
31539
31669
|
});
|
|
31540
|
-
|
|
31670
|
+
const feeWei = gas * maxFeePerGas;
|
|
31671
|
+
// Tempo gas fees are denominated 18 units,
|
|
31672
|
+
// this value needs to be scaled to 6 decimals
|
|
31673
|
+
if (chain.chainId === CHAIN_IDS.TEMPO) {
|
|
31674
|
+
return convertTempoFeeToStablecoinUnits(feeWei);
|
|
31675
|
+
}
|
|
31676
|
+
return feeWei;
|
|
31541
31677
|
}
|
|
31542
31678
|
case ChainType.COSMOS: {
|
|
31543
31679
|
// TODO: get gas estimation from backend
|
|
@@ -31584,19 +31720,33 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31584
31720
|
token,
|
|
31585
31721
|
from,
|
|
31586
31722
|
});
|
|
31587
|
-
const {
|
|
31588
|
-
|
|
31589
|
-
|
|
31723
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
31724
|
+
fromChain: chain,
|
|
31725
|
+
fromToken: token,
|
|
31726
|
+
});
|
|
31727
|
+
const isGasBalanceEnough = useMemo(() => {
|
|
31728
|
+
if (!amount || !token?.decimals)
|
|
31590
31729
|
return false;
|
|
31591
|
-
|
|
31592
|
-
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
31599
|
-
|
|
31730
|
+
return checkIsGasBalanceEnough({
|
|
31731
|
+
fromAmount: parseToBigInt(amount, token.decimals).toString(),
|
|
31732
|
+
networkFeesWei: estimatedGas,
|
|
31733
|
+
chainFeeParams,
|
|
31734
|
+
});
|
|
31735
|
+
}, [amount, estimatedGas, token, chainFeeParams]);
|
|
31736
|
+
const gasBalanceNeeded = useMemo(() => {
|
|
31737
|
+
if (!amount || !token?.decimals || !gasToken?.decimals)
|
|
31738
|
+
return undefined;
|
|
31739
|
+
// gas fees + fromAmount (if fromToken is gas token)
|
|
31740
|
+
const totalGasBalanceNeeded = estimatedGas +
|
|
31741
|
+
parseToBigInt(chainFeeParams?.fromTokenPaysGasFees ? amount ?? "0" : "0", token.decimals);
|
|
31742
|
+
return formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals);
|
|
31743
|
+
}, [
|
|
31744
|
+
amount,
|
|
31745
|
+
chainFeeParams?.fromTokenPaysGasFees,
|
|
31746
|
+
estimatedGas,
|
|
31747
|
+
gasToken?.decimals,
|
|
31748
|
+
token?.decimals,
|
|
31749
|
+
]);
|
|
31600
31750
|
const isBalanceEnough = useMemo(() => {
|
|
31601
31751
|
if (token?.decimals == null || !balance || !amount)
|
|
31602
31752
|
return false;
|
|
@@ -31604,28 +31754,21 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31604
31754
|
parseToBigInt(amount, token.decimals));
|
|
31605
31755
|
}, [amount, balance, token?.decimals]);
|
|
31606
31756
|
const minAmountValueWarnMsg = useMemo(() => {
|
|
31607
|
-
if (!token?.address || !
|
|
31757
|
+
if (!token?.address || !estimatedGas || !chainFeeParams)
|
|
31608
31758
|
return undefined;
|
|
31609
|
-
const isFromTokenNative = token.address.toLowerCase() ===
|
|
31610
|
-
chainTypeToNativeTokenAddressMap[token.type].toLowerCase();
|
|
31611
31759
|
return calculateMinAmountValueWarnMsg({
|
|
31612
|
-
|
|
31613
|
-
|
|
31614
|
-
|
|
31615
|
-
totalFeesInNativeTokenPlusRatio: estimatedGas,
|
|
31760
|
+
chainFeeParams,
|
|
31761
|
+
networkFeesWei: estimatedGas,
|
|
31762
|
+
fromTokenDecimals: token.decimals,
|
|
31616
31763
|
});
|
|
31617
|
-
}, [
|
|
31618
|
-
estimatedGas,
|
|
31619
|
-
nativeBalance?.decimals,
|
|
31620
|
-
nativeBalance?.value,
|
|
31621
|
-
token?.address,
|
|
31622
|
-
token?.type,
|
|
31623
|
-
]);
|
|
31764
|
+
}, [estimatedGas, token, chainFeeParams]);
|
|
31624
31765
|
return {
|
|
31625
31766
|
estimatedGas,
|
|
31767
|
+
gasBalanceNeeded,
|
|
31626
31768
|
isBalanceEnough,
|
|
31769
|
+
tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31627
31770
|
isLoading,
|
|
31628
|
-
|
|
31771
|
+
isGasBalanceEnough,
|
|
31629
31772
|
minAmountValueWarnMsg,
|
|
31630
31773
|
};
|
|
31631
31774
|
}
|
|
@@ -32687,7 +32830,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32687
32830
|
// This is to ensure we're using the latest expiry timestamp
|
|
32688
32831
|
if (squidRoute) {
|
|
32689
32832
|
queryClient.refetchQueries({
|
|
32690
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.
|
|
32833
|
+
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,
|
|
32691
32834
|
// TODO: update types
|
|
32692
32835
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32693
32836
|
});
|
|
@@ -32706,17 +32849,30 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32706
32849
|
const useEstimate = (squidRoute) => {
|
|
32707
32850
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32708
32851
|
const { tokens } = useSquidTokens();
|
|
32709
|
-
const { fromChain, toChain } = useSwap();
|
|
32710
|
-
const
|
|
32852
|
+
const { fromChain, toChain, fromPrice } = useSwap();
|
|
32853
|
+
const fromToken = useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32854
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32855
|
+
fromChain,
|
|
32856
|
+
fromToken,
|
|
32857
|
+
});
|
|
32711
32858
|
const estimateResults = useMemo(() => calculateEstimateResults({
|
|
32712
32859
|
squidRoute,
|
|
32713
32860
|
tokens,
|
|
32714
32861
|
fromChain,
|
|
32715
32862
|
toChain,
|
|
32716
32863
|
collectFees: !!collectFees && collectFees.fee > 0,
|
|
32717
|
-
|
|
32718
|
-
|
|
32719
|
-
|
|
32864
|
+
chainFeeParams,
|
|
32865
|
+
gasToken,
|
|
32866
|
+
}), [
|
|
32867
|
+
squidRoute,
|
|
32868
|
+
tokens,
|
|
32869
|
+
fromChain,
|
|
32870
|
+
toChain,
|
|
32871
|
+
collectFees,
|
|
32872
|
+
chainFeeParams,
|
|
32873
|
+
gasToken,
|
|
32874
|
+
]);
|
|
32875
|
+
const fromBalanceFormatted = useMultiChainBalance({
|
|
32720
32876
|
chain: fromChain,
|
|
32721
32877
|
token: estimateResults.fromToken,
|
|
32722
32878
|
userAddress: squidRoute?.params.fromAddress ?? "",
|
|
@@ -32728,7 +32884,6 @@ const useEstimate = (squidRoute) => {
|
|
|
32728
32884
|
estimateResults.expectedGasRefundCost,
|
|
32729
32885
|
getUSDValue,
|
|
32730
32886
|
]);
|
|
32731
|
-
const proposedGasDestinationAmount = useMemo(() => getProposedGasDestinationAmount(estimateResults.destChainNativeToken?.symbol), [estimateResults.destChainNativeToken]);
|
|
32732
32887
|
const { feeCostsFormatted, totalFeeCostsUsd } = useMemo(() => {
|
|
32733
32888
|
const feeCosts = squidRoute?.estimate.feeCosts ?? [];
|
|
32734
32889
|
const feeCostsRenamed = [];
|
|
@@ -32787,21 +32942,21 @@ const useEstimate = (squidRoute) => {
|
|
|
32787
32942
|
totalFeeCostsUsd: totalFeeCostsUsdFormatted,
|
|
32788
32943
|
};
|
|
32789
32944
|
}, [squidRoute?.estimate.feeCosts]);
|
|
32790
|
-
const slippageFormatted =
|
|
32791
|
-
|
|
32792
|
-
|
|
32793
|
-
|
|
32794
|
-
|
|
32795
|
-
|
|
32945
|
+
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32946
|
+
const fromBalanceEnoughToSwap = useMemo(() => {
|
|
32947
|
+
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32948
|
+
const fromPriceNum = Number(fromPrice ?? 0);
|
|
32949
|
+
return fromBalanceNum >= fromPriceNum;
|
|
32950
|
+
}, [fromBalanceFormatted, fromPrice]);
|
|
32796
32951
|
return {
|
|
32797
32952
|
...estimateResults,
|
|
32798
|
-
|
|
32953
|
+
fromBalanceFormatted,
|
|
32799
32954
|
slippageFormatted,
|
|
32800
32955
|
totalWithRefundEstimate,
|
|
32801
|
-
|
|
32802
|
-
enoughBalanceToSwap,
|
|
32956
|
+
fromBalanceEnoughToSwap,
|
|
32803
32957
|
feeCostsFormatted,
|
|
32804
32958
|
totalFeeCostsUsd,
|
|
32959
|
+
gasToken,
|
|
32805
32960
|
};
|
|
32806
32961
|
};
|
|
32807
32962
|
|
|
@@ -36569,7 +36724,7 @@ const useGetRoute = () => {
|
|
|
36569
36724
|
});
|
|
36570
36725
|
// Cache the route data
|
|
36571
36726
|
// Useful when the getRoute mutation is called from another hook
|
|
36572
|
-
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage,
|
|
36727
|
+
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
|
|
36573
36728
|
return route;
|
|
36574
36729
|
});
|
|
36575
36730
|
};
|
|
@@ -36592,14 +36747,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36592
36747
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36593
36748
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36594
36749
|
: sourceConnectedAddress;
|
|
36595
|
-
const squidRouteQueryKeys = useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage,
|
|
36750
|
+
const squidRouteQueryKeys = useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
|
|
36596
36751
|
fromChain?.chainId,
|
|
36597
36752
|
toChain?.chainId,
|
|
36598
36753
|
toToken?.address,
|
|
36599
36754
|
fromToken?.address,
|
|
36600
36755
|
fromPrice,
|
|
36601
36756
|
config.slippage,
|
|
36602
|
-
config.enableGetGasOnDestination,
|
|
36603
36757
|
sourceUserAddress,
|
|
36604
36758
|
config.degenMode,
|
|
36605
36759
|
destinationAddress,
|
|
@@ -36871,35 +37025,6 @@ const useAvatar = (seed = zeroAddress) => {
|
|
|
36871
37025
|
return avatar || "";
|
|
36872
37026
|
};
|
|
36873
37027
|
|
|
36874
|
-
const useUserParams = () => {
|
|
36875
|
-
const enableGetGasOnDestination = useConfigStore((state) => state.config.enableGetGasOnDestination);
|
|
36876
|
-
const { fromToken, toToken, toChain, fromChain } = useSwap();
|
|
36877
|
-
// =============
|
|
36878
|
-
// GAS
|
|
36879
|
-
// =============
|
|
36880
|
-
const getGasOnDestSupportedForThisRoute = useMemo(() =>
|
|
36881
|
-
// Not supporting get gas on dest for same chains
|
|
36882
|
-
fromChain?.chainId !== toChain?.chainId &&
|
|
36883
|
-
// If the destination chain is cosmos, we don't support getting gas there
|
|
36884
|
-
toChain?.chainType !== ChainType.COSMOS &&
|
|
36885
|
-
// Not supporting get gas on dest for same tokens (bridge)
|
|
36886
|
-
((fromToken?.subGraphIds?.some((sgi) => !!toToken?.subGraphIds?.includes(sgi)) &&
|
|
36887
|
-
toToken?.subGraphIds?.some((sgi) => !!fromToken?.subGraphIds?.includes(sgi))) ||
|
|
36888
|
-
// Except for uusdc -> uusdc
|
|
36889
|
-
(fromToken?.subGraphIds?.includes("uusdc") &&
|
|
36890
|
-
toToken?.subGraphIds?.includes("uusdc"))), [
|
|
36891
|
-
fromChain?.chainId,
|
|
36892
|
-
fromToken?.subGraphIds,
|
|
36893
|
-
toChain?.chainId,
|
|
36894
|
-
toToken?.subGraphIds,
|
|
36895
|
-
toChain?.chainType,
|
|
36896
|
-
]);
|
|
36897
|
-
return {
|
|
36898
|
-
gasEnabled: enableGetGasOnDestination && getGasOnDestSupportedForThisRoute,
|
|
36899
|
-
getGasOnDestSupportedForThisRoute,
|
|
36900
|
-
};
|
|
36901
|
-
};
|
|
36902
|
-
|
|
36903
37028
|
const useAddToken = (chainToCompare, tokenToCompare) => {
|
|
36904
37029
|
const { chain: currentEvmChain } = useAccount();
|
|
36905
37030
|
const { connector } = useAccount();
|
|
@@ -37327,5 +37452,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37327
37452
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37328
37453
|
};
|
|
37329
37454
|
|
|
37330
|
-
export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a, useGetOnrampPaymentTypes as a$, useSwap as a0, buildUrlSearchParamsFromSwapEvent as a1, parseInitialAssetsFromUrl as a2, useUrlSwapParams as a3, useAllConnectedWalletBalances as a4, useAllTokensWithBalanceForChainType as a5, useCosmosBalance as a6, useEvmBalance as a7, useMultiChainBalance as a8, useMultipleTokenPrices as a9,
|
|
37331
|
-
//# sourceMappingURL=index-
|
|
37455
|
+
export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a, useGetOnrampPaymentTypes as a$, useSwap as a0, buildUrlSearchParamsFromSwapEvent as a1, parseInitialAssetsFromUrl as a2, useUrlSwapParams as a3, useAllConnectedWalletBalances as a4, useAllTokensWithBalanceForChainType as a5, useCosmosBalance as a6, useEvmBalance as a7, useMultiChainBalance as a8, useMultipleTokenPrices as a9, useSwapTransactionStatus as aA, useAvatar as aB, useHistory as aC, useDebouncedValue as aD, useAddToken as aE, useAutoConnect as aF, useEnsDataForAddress as aG, useEnsSearch as aH, useGnosisContext as aI, useIsSameAddressAndGnosisContext as aJ, useIntegratorContext as aK, useMultiChainWallet as aL, useSigner as aM, useWallet as aN, useWallets as aO, useXrplTrustLine as aP, TX_STATUS_CONSTANTS as aQ, FINAL_TRANSACTION_STATUSES as aR, useGetFiatQuote as aS, useGetOnRampConfig as aT, useExecuteFiatQuote as aU, useFiatOnRampTxStatus as aV, useFiatTransactions as aW, useCurrencyDetails as aX, useCountryDetails as aY, useAvailableQuotes as aZ, useRecommendedQuote as a_, useBitcoinNativeBalance as aa, useCosmosNativeBalance as ab, useEvmNativeBalance as ac, useNativeBalance as ad, useSolanaNativeBalance as ae, useStellarNativeBalance as af, useSuiNativeBalance as ag, useXrplNativeBalance as ah, useNativeTokenForChain as ai, useSingleTokenPrice as aj, useSourceChainGasToken as ak, useSquidTokens as al, useHistoricalData as am, useTokensData as an, useEstimateSendTransaction as ao, useSendTransaction as ap, useSendTransactionGas as aq, useAllTransactionsStatus as ar, useApproval as as, useEstimate as at, useEstimatePriceImpact as au, useExecuteTransaction as av, useGetRoute as aw, useGetRouteWrapper as ax, useRouteWarnings as ay, useSendTransactionStatus as az, chainTypeToZeroAddressMap as b, filterWagmiConnector as b$, useSuggestedFiatAmounts as b0, SquidProvider as b1, EnsService as b2, getXummClient as b3, isXamanXAppContext as b4, getQueryHeaders as b5, getStatusCode as b6, is404Error as b7, assetsBaseUrl as b8, shareSubgraphId as b9, fetchHighestBalanceToken as bA, getInitialOrDefaultTokenAddressForChain as bB, getInitialTokenAddressForChain as bC, filterTokensForDestination as bD, getInitialChainIdFromConfig as bE, getCosmosKey as bF, getKeysSettled as bG, getAllKeysForSupportedCosmosChains as bH, isCosmosAddressValid as bI, getCosmosSigningClient as bJ, getCosmosChainInfosObject as bK, connectCosmosWallet as bL, isFallbackAddressNeeded as bM, suggestChainOrThrow as bN, normalizeError as bO, transactionErrorCode as bP, isUserRejectionError as bQ, getTransactionError as bR, handleTransactionErrorEvents as bS, isSwapRouteError as bT, isStatusError as bU, createQuoteRequestParamsHash as bV, WidgetEvents as bW, EvmNetworkNotSupportedErrorCode as bX, addEthereumChain as bY, parseEvmAddress as bZ, formatEvmWallet as b_, sortTokensBySharedSubgraphIds as ba, getSupportedChainIdsForDirection as bb, filterChains as bc, filterTokens as bd, getTokenImage as be, getNewSwapParamsFromInput as bf, sortAllTokens as bg, findToken as bh, findNativeToken as bi, normalizeIbcAddress as bj, groupTokensBySymbol as bk, groupTokensByChainId as bl, filterViewableTokens as bm, getSecretNetworkBalances as bn, getTokenAssetsKey as bo, fetchAssetsColors as bp, initializeSquidWithAssetsColors as bq, isEmptyObject as br, normalizeTokenSymbol as bs, areTokenSymbolsCompatible as bt, isEvmosChain as bu, resolveChainIdFromAsset as bv, getConfigWithDefaults as bw, randomIntFromInterval as bx, getTokensForChain as by, getFirstAvailableChainId as bz, chainTypeToNativeTokenAddressMap as c, isHistoryTransactionFailed as c$, waitForReceiptWithRetry as c0, getUserCountry as c1, getCountryData as c2, getCurrencyData as c3, adaptiveRound as c4, getSuggestedAmountsForCurrency as c5, HederaExtensionHelper as c6, convertHederaAccountIdToEvmAddress as c7, convertEvmAddressToHederaAccountId as c8, scaleHbarToWei as c9, isValidHorizonAsset as cA, formatTransactionHistoryDate as cB, getAxelarExplorerTxUrl as cC, getSourceExplorerTxUrl as cD, getMainExplorerUrl as cE, formatDistance as cF, formatSeconds as cG, formatSwapTxStatusResponseForStorage as cH, simplifyRouteAction as cI, fetchSwapTransactionStatus as cJ, compareTransactionIds as cK, isCoralBridgeAction as cL, sleep as cM, isDepositRoute as cN, isChainflipBridgeTransaction as cO, isOnChainTxData as cP, getHistoryTransactionId as cQ, getStepStatuses as cR, getHalfSuccessState as cS, getStepsInfos as cT, getSwapTxStatusRefetchInterval as cU, getSendTxStatusRefetchInterval as cV, chainflipMultihopBridgeType as cW, getBridgeType as cX, getTransactionStatus as cY, getTransactionEndStatus as cZ, isHistoryTransactionPending as c_, scaleWeiToHbar as ca, parseToBigInt as cb, roundNumericValue as cc, formatUnitsRounded as cd, formatTokenAmount as ce, formatUsdAmount as cf, trimExtraDecimals as cg, getNumericValue as ch, cleanAmount as ci, convertTokenAmountToUSD as cj, convertUSDToTokenAmount as ck, calculateTotal24hChange as cl, getRouteExpiry as cm, searchTokens as cn, filterSolanaWallets as co, isSolanaAddressValid as cp, executeSolanaSwap as cq, executeSolanaTransfer as cr, isStellarAddressValid as cs, getStellarNetwork as ct, stellarAddressToScVal as cu, getStellarTrustLineAsset as cv, isStellarToken as cw, isStellarIssuedToken as cx, getStellarHorizonApiUrl as cy, isValidIssuedAsset as cz, definedInWindow as d, isHistoryTransactionWarning as d0, isHistoryTransactionEnded as d1, formatHash as d2, isWalletAddressValid as d3, redirectToExtensionsStore as d4, accessProperty as d5, populateWallets as d6, getDefaultChain as d7, sortWallets as d8, areSameAddress as d9, sortAddressBook as da, calculateTotalUsdBalanceUSD as db, addTokenToWallet as dc, isEvmChainNotSupportedError as dd, getWalletSupportedChainTypes as de, getConnectorForChainType as df, walletSupportsChainType as dg, connectWallet as dh, cancelConnectWallet as di, isProblematicConnector as dj, mergeWallets as dk, isXionSmartContractAddress as dl, isXrplAddressValid as dm, buildXrplTrustSetTx as dn, getXrplNetwork as dp, parseXrplPaymentTx as dq, parseXrplTokenAddress as dr, er as e, formatBNToReadable as f, DEFAULT_ROUTE_REFETCH_INTERVAL as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCosmosTokenAddress as j, nativeEvmTokenAddress as k, nativeSolanaTokenAddress as l, nativeStellarTokenAddress as m, nativeBitcoinTokenAddress as n, nativeSuiTokenAddress as o, nativeXrplTokenAddress as p, CosmosProvider as q, SendTransactionStatus as r, TransactionStatus as s, useTrackSearchEmpty as t, useCosmosContext as u, useSquidChains as v, walletIconBaseUrl as w, useClient as x, useCosmosForChain as y, useHederaAccountActivation as z };
|
|
37456
|
+
//# sourceMappingURL=index-CpHc3uRR.js.map
|