@0xsquid/react-hooks 8.6.1 → 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-uxBoqobR.js → index-BOMoTOCH.js} +279 -155
- package/dist/index-BOMoTOCH.js.map +1 -0
- package/dist/{index--gt66OVO.js → index-CpHc3uRR.js} +279 -155
- package/dist/index-CpHc3uRR.js.map +1 -0
- package/dist/{index.es-DXYyLkwM.js → index.es-Bx1b09ob.js} +2 -2
- package/dist/{index.es-DXYyLkwM.js.map → index.es-Bx1b09ob.js.map} +1 -1
- package/dist/{index.es-zgttb4RJ.js → index.es-DYEb3pTJ.js} +2 -2
- package/dist/{index.es-zgttb4RJ.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-C3pLXo0u.js → secretService-0Y9Bj_Ic.js} +2 -2
- package/dist/{secretService-C3pLXo0u.js.map → secretService-0Y9Bj_Ic.js.map} +1 -1
- package/dist/{secretService-BoIRJAyQ.js → secretService-DnKMq9Ib.js} +2 -2
- package/dist/{secretService-BoIRJAyQ.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-DYLHIsR1.js → stellarService.client-B3kAxROD.js} +2 -2
- package/dist/{stellarService.client-DYLHIsR1.js.map → stellarService.client-B3kAxROD.js.map} +1 -1
- package/dist/{stellarService.client-8vhPwFQb.js → stellarService.client-Dyichswq.js} +2 -2
- package/dist/{stellarService.client-8vhPwFQb.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--gt66OVO.js.map +0 -1
- package/dist/index-uxBoqobR.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,
|
|
@@ -31157,6 +31160,155 @@ const useSingleTokenPrice = (tokenData) => {
|
|
|
31157
31160
|
return { tokenPrice, getUSDValue };
|
|
31158
31161
|
};
|
|
31159
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
|
+
|
|
31160
31312
|
const MAX_COINGECKO_QUERY_TOKENS = 100;
|
|
31161
31313
|
const fetchHistoricalData = async (coingeckoId, timeFrame) => {
|
|
31162
31314
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -31307,24 +31459,23 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
|
|
|
31307
31459
|
(sameTokenBetweenFees
|
|
31308
31460
|
? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
|
|
31309
31461
|
: BigInt(firstGasCost?.amount ?? "0"));
|
|
31310
|
-
const
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
|
|
31314
|
-
|
|
31315
|
-
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
}
|
|
31320
|
-
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31325
|
-
|
|
31326
|
-
|
|
31327
|
-
: 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
|
+
};
|
|
31328
31479
|
/**
|
|
31329
31480
|
* Calculates the estimated duration of a route
|
|
31330
31481
|
*
|
|
@@ -31363,12 +31514,10 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
|
|
|
31363
31514
|
* @returns {Object} An object containing various estimate results and calculations, including token information,
|
|
31364
31515
|
* amounts, fees, gas costs, and other relevant data for the transaction.
|
|
31365
31516
|
*/
|
|
31366
|
-
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees,
|
|
31517
|
+
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
|
|
31367
31518
|
const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
|
|
31368
31519
|
const fromAmount = squidRoute?.estimate?.fromAmount;
|
|
31369
31520
|
const fromAmountFormatted = formatAmount(fromAmount, fromToken?.decimals);
|
|
31370
|
-
const sourceChainNativeToken = findNativeToken(tokens, fromChain);
|
|
31371
|
-
const destChainNativeToken = findNativeToken(tokens, toChain);
|
|
31372
31521
|
const toAmountUSD = squidRoute?.estimate?.toAmountUSD;
|
|
31373
31522
|
const exchangeRate = squidRoute?.estimate.exchangeRate ?? "0";
|
|
31374
31523
|
const toAmountMinUSD = squidRoute?.estimate.toAmountMinUSD ?? "0";
|
|
@@ -31387,10 +31536,6 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31387
31536
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
31388
31537
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
31389
31538
|
firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
|
|
31390
|
-
const isFromTokenNative =
|
|
31391
|
-
// TODO: temporary fix, currently nativeCurrency.symbol is not always in uppercase
|
|
31392
|
-
fromToken?.symbol.toUpperCase() ===
|
|
31393
|
-
fromChain?.nativeCurrency.symbol.toUpperCase();
|
|
31394
31539
|
const totalNativeFees = calculateTotalNativeFees({
|
|
31395
31540
|
expressFeeCost,
|
|
31396
31541
|
firstFeeCost,
|
|
@@ -31398,30 +31543,32 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31398
31543
|
sameTokenBetweenFees,
|
|
31399
31544
|
});
|
|
31400
31545
|
const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
|
|
31401
|
-
const
|
|
31402
|
-
|
|
31546
|
+
const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
|
|
31547
|
+
const isGasBalanceEnough = checkIsGasBalanceEnough({
|
|
31548
|
+
chainFeeParams,
|
|
31403
31549
|
fromAmount,
|
|
31404
|
-
|
|
31405
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31406
|
-
nativeTokenBalanceFromChainWei,
|
|
31550
|
+
networkFeesWei,
|
|
31407
31551
|
});
|
|
31408
31552
|
const minAmountValueWarnMsg = calculateMinAmountValueWarnMsg({
|
|
31409
|
-
|
|
31410
|
-
|
|
31411
|
-
|
|
31412
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31553
|
+
chainFeeParams,
|
|
31554
|
+
networkFeesWei,
|
|
31555
|
+
fromTokenDecimals: fromToken?.decimals,
|
|
31413
31556
|
});
|
|
31414
31557
|
const isSingleChainRoute = fromChain?.chainId === toChain?.chainId;
|
|
31415
31558
|
const estimatedRouteDuration = formatEstimatedRouteDuration({
|
|
31416
31559
|
estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
|
|
31417
31560
|
isSingleChainRoute,
|
|
31418
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;
|
|
31419
31568
|
return {
|
|
31420
31569
|
fromToken,
|
|
31421
31570
|
fromAmount,
|
|
31422
31571
|
fromAmountFormatted,
|
|
31423
|
-
sourceChainNativeToken,
|
|
31424
|
-
destChainNativeToken,
|
|
31425
31572
|
toAmountUSD,
|
|
31426
31573
|
exchangeRate,
|
|
31427
31574
|
toAmountMinUSD,
|
|
@@ -31436,12 +31583,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31436
31583
|
expectedGasRefundCost,
|
|
31437
31584
|
expectedGasRefundCostUSD,
|
|
31438
31585
|
sameTokenBetweenFees,
|
|
31439
|
-
|
|
31586
|
+
fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31440
31587
|
totalNativeFees,
|
|
31441
|
-
|
|
31442
|
-
fromBalanceEnoughToSwap,
|
|
31588
|
+
isGasBalanceEnough,
|
|
31443
31589
|
minAmountValueWarnMsg,
|
|
31444
31590
|
estimatedRouteDuration,
|
|
31591
|
+
gasBalanceNeeded,
|
|
31445
31592
|
};
|
|
31446
31593
|
};
|
|
31447
31594
|
/**
|
|
@@ -31475,28 +31622,6 @@ const calculateTotalWithRefundEstimate = (allFeeCosts, expectedGasRefundCost, ge
|
|
|
31475
31622
|
feeToken: firstFeeCost?.token,
|
|
31476
31623
|
};
|
|
31477
31624
|
};
|
|
31478
|
-
/**
|
|
31479
|
-
* Calculates the proposed gas amount for the destination chain.
|
|
31480
|
-
*
|
|
31481
|
-
* @param destChainNativeToken - The symbol of the native token for the destination chain.
|
|
31482
|
-
* @returns An object containing the proposed gas amount value and the currency symbol.
|
|
31483
|
-
*/
|
|
31484
|
-
const getProposedGasDestinationAmount = (destChainNativeToken) => {
|
|
31485
|
-
const gasAmounts = {
|
|
31486
|
-
GLMR: 5.289,
|
|
31487
|
-
ETH: 0.0009,
|
|
31488
|
-
AVAX: 0.115,
|
|
31489
|
-
BNB: 0.00425,
|
|
31490
|
-
FTM: 4.45,
|
|
31491
|
-
CELO: 3.052,
|
|
31492
|
-
KAVA: 2.339,
|
|
31493
|
-
MATIC: 1.795,
|
|
31494
|
-
};
|
|
31495
|
-
return {
|
|
31496
|
-
value: gasAmounts[destChainNativeToken ?? ""] ?? 0,
|
|
31497
|
-
currency: destChainNativeToken,
|
|
31498
|
-
};
|
|
31499
|
-
};
|
|
31500
31625
|
|
|
31501
31626
|
function useSendTransactionGas({ chain, token, from, }) {
|
|
31502
31627
|
return useQuery({
|
|
@@ -31518,7 +31643,11 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31518
31643
|
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
31519
31644
|
// so we'll try to use the user provided address when possible
|
|
31520
31645
|
const sender = from || dummyAddress;
|
|
31521
|
-
|
|
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) {
|
|
31522
31651
|
const gas = await client.estimateGas({
|
|
31523
31652
|
from: sender,
|
|
31524
31653
|
to: dummyAddress,
|
|
@@ -31538,7 +31667,13 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31538
31667
|
data,
|
|
31539
31668
|
chainId: chain.chainId,
|
|
31540
31669
|
});
|
|
31541
|
-
|
|
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;
|
|
31542
31677
|
}
|
|
31543
31678
|
case ChainType.COSMOS: {
|
|
31544
31679
|
// TODO: get gas estimation from backend
|
|
@@ -31585,19 +31720,33 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31585
31720
|
token,
|
|
31586
31721
|
from,
|
|
31587
31722
|
});
|
|
31588
|
-
const {
|
|
31589
|
-
|
|
31590
|
-
|
|
31723
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
31724
|
+
fromChain: chain,
|
|
31725
|
+
fromToken: token,
|
|
31726
|
+
});
|
|
31727
|
+
const isGasBalanceEnough = useMemo(() => {
|
|
31728
|
+
if (!amount || !token?.decimals)
|
|
31591
31729
|
return false;
|
|
31592
|
-
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
31599
|
-
|
|
31600
|
-
|
|
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
|
+
]);
|
|
31601
31750
|
const isBalanceEnough = useMemo(() => {
|
|
31602
31751
|
if (token?.decimals == null || !balance || !amount)
|
|
31603
31752
|
return false;
|
|
@@ -31605,28 +31754,21 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31605
31754
|
parseToBigInt(amount, token.decimals));
|
|
31606
31755
|
}, [amount, balance, token?.decimals]);
|
|
31607
31756
|
const minAmountValueWarnMsg = useMemo(() => {
|
|
31608
|
-
if (!token?.address || !
|
|
31757
|
+
if (!token?.address || !estimatedGas || !chainFeeParams)
|
|
31609
31758
|
return undefined;
|
|
31610
|
-
const isFromTokenNative = token.address.toLowerCase() ===
|
|
31611
|
-
chainTypeToNativeTokenAddressMap[token.type].toLowerCase();
|
|
31612
31759
|
return calculateMinAmountValueWarnMsg({
|
|
31613
|
-
|
|
31614
|
-
|
|
31615
|
-
|
|
31616
|
-
totalFeesInNativeTokenPlusRatio: estimatedGas,
|
|
31760
|
+
chainFeeParams,
|
|
31761
|
+
networkFeesWei: estimatedGas,
|
|
31762
|
+
fromTokenDecimals: token.decimals,
|
|
31617
31763
|
});
|
|
31618
|
-
}, [
|
|
31619
|
-
estimatedGas,
|
|
31620
|
-
nativeBalance?.decimals,
|
|
31621
|
-
nativeBalance?.value,
|
|
31622
|
-
token?.address,
|
|
31623
|
-
token?.type,
|
|
31624
|
-
]);
|
|
31764
|
+
}, [estimatedGas, token, chainFeeParams]);
|
|
31625
31765
|
return {
|
|
31626
31766
|
estimatedGas,
|
|
31767
|
+
gasBalanceNeeded,
|
|
31627
31768
|
isBalanceEnough,
|
|
31769
|
+
tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31628
31770
|
isLoading,
|
|
31629
|
-
|
|
31771
|
+
isGasBalanceEnough,
|
|
31630
31772
|
minAmountValueWarnMsg,
|
|
31631
31773
|
};
|
|
31632
31774
|
}
|
|
@@ -32688,7 +32830,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32688
32830
|
// This is to ensure we're using the latest expiry timestamp
|
|
32689
32831
|
if (squidRoute) {
|
|
32690
32832
|
queryClient.refetchQueries({
|
|
32691
|
-
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,
|
|
32692
32834
|
// TODO: update types
|
|
32693
32835
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32694
32836
|
});
|
|
@@ -32707,17 +32849,30 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32707
32849
|
const useEstimate = (squidRoute) => {
|
|
32708
32850
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32709
32851
|
const { tokens } = useSquidTokens();
|
|
32710
|
-
const { fromChain, toChain } = useSwap();
|
|
32711
|
-
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
|
+
});
|
|
32712
32858
|
const estimateResults = useMemo(() => calculateEstimateResults({
|
|
32713
32859
|
squidRoute,
|
|
32714
32860
|
tokens,
|
|
32715
32861
|
fromChain,
|
|
32716
32862
|
toChain,
|
|
32717
32863
|
collectFees: !!collectFees && collectFees.fee > 0,
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
|
|
32864
|
+
chainFeeParams,
|
|
32865
|
+
gasToken,
|
|
32866
|
+
}), [
|
|
32867
|
+
squidRoute,
|
|
32868
|
+
tokens,
|
|
32869
|
+
fromChain,
|
|
32870
|
+
toChain,
|
|
32871
|
+
collectFees,
|
|
32872
|
+
chainFeeParams,
|
|
32873
|
+
gasToken,
|
|
32874
|
+
]);
|
|
32875
|
+
const fromBalanceFormatted = useMultiChainBalance({
|
|
32721
32876
|
chain: fromChain,
|
|
32722
32877
|
token: estimateResults.fromToken,
|
|
32723
32878
|
userAddress: squidRoute?.params.fromAddress ?? "",
|
|
@@ -32729,7 +32884,6 @@ const useEstimate = (squidRoute) => {
|
|
|
32729
32884
|
estimateResults.expectedGasRefundCost,
|
|
32730
32885
|
getUSDValue,
|
|
32731
32886
|
]);
|
|
32732
|
-
const proposedGasDestinationAmount = useMemo(() => getProposedGasDestinationAmount(estimateResults.destChainNativeToken?.symbol), [estimateResults.destChainNativeToken]);
|
|
32733
32887
|
const { feeCostsFormatted, totalFeeCostsUsd } = useMemo(() => {
|
|
32734
32888
|
const feeCosts = squidRoute?.estimate.feeCosts ?? [];
|
|
32735
32889
|
const feeCostsRenamed = [];
|
|
@@ -32788,21 +32942,21 @@ const useEstimate = (squidRoute) => {
|
|
|
32788
32942
|
totalFeeCostsUsd: totalFeeCostsUsdFormatted,
|
|
32789
32943
|
};
|
|
32790
32944
|
}, [squidRoute?.estimate.feeCosts]);
|
|
32791
|
-
const slippageFormatted =
|
|
32792
|
-
|
|
32793
|
-
|
|
32794
|
-
|
|
32795
|
-
|
|
32796
|
-
|
|
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]);
|
|
32797
32951
|
return {
|
|
32798
32952
|
...estimateResults,
|
|
32799
|
-
|
|
32953
|
+
fromBalanceFormatted,
|
|
32800
32954
|
slippageFormatted,
|
|
32801
32955
|
totalWithRefundEstimate,
|
|
32802
|
-
|
|
32803
|
-
enoughBalanceToSwap,
|
|
32956
|
+
fromBalanceEnoughToSwap,
|
|
32804
32957
|
feeCostsFormatted,
|
|
32805
32958
|
totalFeeCostsUsd,
|
|
32959
|
+
gasToken,
|
|
32806
32960
|
};
|
|
32807
32961
|
};
|
|
32808
32962
|
|
|
@@ -36570,7 +36724,7 @@ const useGetRoute = () => {
|
|
|
36570
36724
|
});
|
|
36571
36725
|
// Cache the route data
|
|
36572
36726
|
// Useful when the getRoute mutation is called from another hook
|
|
36573
|
-
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);
|
|
36574
36728
|
return route;
|
|
36575
36729
|
});
|
|
36576
36730
|
};
|
|
@@ -36593,14 +36747,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36593
36747
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36594
36748
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36595
36749
|
: sourceConnectedAddress;
|
|
36596
|
-
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), [
|
|
36597
36751
|
fromChain?.chainId,
|
|
36598
36752
|
toChain?.chainId,
|
|
36599
36753
|
toToken?.address,
|
|
36600
36754
|
fromToken?.address,
|
|
36601
36755
|
fromPrice,
|
|
36602
36756
|
config.slippage,
|
|
36603
|
-
config.enableGetGasOnDestination,
|
|
36604
36757
|
sourceUserAddress,
|
|
36605
36758
|
config.degenMode,
|
|
36606
36759
|
destinationAddress,
|
|
@@ -36872,35 +37025,6 @@ const useAvatar = (seed = zeroAddress) => {
|
|
|
36872
37025
|
return avatar || "";
|
|
36873
37026
|
};
|
|
36874
37027
|
|
|
36875
|
-
const useUserParams = () => {
|
|
36876
|
-
const enableGetGasOnDestination = useConfigStore((state) => state.config.enableGetGasOnDestination);
|
|
36877
|
-
const { fromToken, toToken, toChain, fromChain } = useSwap();
|
|
36878
|
-
// =============
|
|
36879
|
-
// GAS
|
|
36880
|
-
// =============
|
|
36881
|
-
const getGasOnDestSupportedForThisRoute = useMemo(() =>
|
|
36882
|
-
// Not supporting get gas on dest for same chains
|
|
36883
|
-
fromChain?.chainId !== toChain?.chainId &&
|
|
36884
|
-
// If the destination chain is cosmos, we don't support getting gas there
|
|
36885
|
-
toChain?.chainType !== ChainType.COSMOS &&
|
|
36886
|
-
// Not supporting get gas on dest for same tokens (bridge)
|
|
36887
|
-
((fromToken?.subGraphIds?.some((sgi) => !!toToken?.subGraphIds?.includes(sgi)) &&
|
|
36888
|
-
toToken?.subGraphIds?.some((sgi) => !!fromToken?.subGraphIds?.includes(sgi))) ||
|
|
36889
|
-
// Except for uusdc -> uusdc
|
|
36890
|
-
(fromToken?.subGraphIds?.includes("uusdc") &&
|
|
36891
|
-
toToken?.subGraphIds?.includes("uusdc"))), [
|
|
36892
|
-
fromChain?.chainId,
|
|
36893
|
-
fromToken?.subGraphIds,
|
|
36894
|
-
toChain?.chainId,
|
|
36895
|
-
toToken?.subGraphIds,
|
|
36896
|
-
toChain?.chainType,
|
|
36897
|
-
]);
|
|
36898
|
-
return {
|
|
36899
|
-
gasEnabled: enableGetGasOnDestination && getGasOnDestSupportedForThisRoute,
|
|
36900
|
-
getGasOnDestSupportedForThisRoute,
|
|
36901
|
-
};
|
|
36902
|
-
};
|
|
36903
|
-
|
|
36904
37028
|
const useAddToken = (chainToCompare, tokenToCompare) => {
|
|
36905
37029
|
const { chain: currentEvmChain } = useAccount();
|
|
36906
37030
|
const { connector } = useAccount();
|
|
@@ -37328,5 +37452,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37328
37452
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37329
37453
|
};
|
|
37330
37454
|
|
|
37331
|
-
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,
|
|
37332
|
-
//# 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
|