@0xsquid/react-hooks 8.6.1 → 8.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/core/types/history.d.ts +1 -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-DQERpZr8.js} +280 -155
- package/dist/index-DQERpZr8.js.map +1 -0
- package/dist/{index--gt66OVO.js → index-Dgqm3ZeG.js} +280 -155
- package/dist/index-Dgqm3ZeG.js.map +1 -0
- package/dist/{index.es-DXYyLkwM.js → index.es-BKxEl9R1.js} +2 -2
- package/dist/{index.es-DXYyLkwM.js.map → index.es-BKxEl9R1.js.map} +1 -1
- package/dist/{index.es-zgttb4RJ.js → index.es-DOFFrTzb.js} +2 -2
- package/dist/{index.es-zgttb4RJ.js.map → index.es-DOFFrTzb.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{secretService-BoIRJAyQ.js → secretService-CqdaN_la.js} +2 -2
- package/dist/{secretService-BoIRJAyQ.js.map → secretService-CqdaN_la.js.map} +1 -1
- package/dist/{secretService-C3pLXo0u.js → secretService-DXExZJnA.js} +2 -2
- package/dist/{secretService-C3pLXo0u.js.map → secretService-DXExZJnA.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-BmkrPHkP.js} +2 -2
- package/dist/{stellarService.client-DYLHIsR1.js.map → stellarService.client-BmkrPHkP.js.map} +1 -1
- package/dist/{stellarService.client-8vhPwFQb.js → stellarService.client-eK7yYyOR.js} +2 -2
- package/dist/{stellarService.client-8vhPwFQb.js.map → stellarService.client-eK7yYyOR.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",
|
|
@@ -21050,6 +21053,7 @@ const formatSwapTxStatusResponseForStorage = (sr) => {
|
|
|
21050
21053
|
}
|
|
21051
21054
|
return {
|
|
21052
21055
|
axelarTransactionUrl: sr.axelarTransactionUrl,
|
|
21056
|
+
coralTransactionUrl: sr.coralTransactionUrl,
|
|
21053
21057
|
toChain: sr.toChain?.transactionUrl
|
|
21054
21058
|
? {
|
|
21055
21059
|
transactionUrl: sr.toChain?.transactionUrl,
|
|
@@ -22388,7 +22392,7 @@ const keys = () => ({
|
|
|
22388
22392
|
// ============
|
|
22389
22393
|
// Transactions
|
|
22390
22394
|
// ============
|
|
22391
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage,
|
|
22395
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
|
|
22392
22396
|
...keys().transactions(),
|
|
22393
22397
|
QueryKeys.Transaction,
|
|
22394
22398
|
fromChainId,
|
|
@@ -22397,7 +22401,6 @@ const keys = () => ({
|
|
|
22397
22401
|
fromTokenAddress,
|
|
22398
22402
|
price,
|
|
22399
22403
|
slippage,
|
|
22400
|
-
getGasOnDestination,
|
|
22401
22404
|
sourceUserAddress,
|
|
22402
22405
|
degenMode,
|
|
22403
22406
|
destinationAddress,
|
|
@@ -22586,7 +22589,6 @@ const getConfigWithDefaults = (config) => {
|
|
|
22586
22589
|
integratorId: get$2(config, "integratorId", defaultConfigValues.integratorId),
|
|
22587
22590
|
slippage: get$2(config, "slippage", defaultConfigValues.slippage),
|
|
22588
22591
|
collectFees: get$2(config, "collectFees", defaultConfigValues.collectFees),
|
|
22589
|
-
enableGetGasOnDestination: get$2(config, "enableGetGasOnDestination", defaultConfigValues.enableGetGasOnDestination),
|
|
22590
22592
|
apiUrl: get$2(config, "apiUrl", defaultConfigValues.apiUrl),
|
|
22591
22593
|
priceImpactWarnings: get$2(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
|
|
22592
22594
|
initialAssets: get$2(config, "initialAssets", defaultConfigValues.initialAssets),
|
|
@@ -23080,8 +23082,8 @@ const sortAllTokens = (tokenA, tokenB) => {
|
|
|
23080
23082
|
return 0;
|
|
23081
23083
|
};
|
|
23082
23084
|
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
|
|
23085
|
+
const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase() &&
|
|
23086
|
+
t.chainId == chain.chainId);
|
|
23085
23087
|
const normalizeIbcAddress = (address) => {
|
|
23086
23088
|
if (!address.toLowerCase().startsWith("ibc/")) {
|
|
23087
23089
|
return address;
|
|
@@ -23292,7 +23294,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23292
23294
|
};
|
|
23293
23295
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23294
23296
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23295
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23297
|
+
const { fetchAllSecretBalances } = await import('./secretService-CqdaN_la.js');
|
|
23296
23298
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23297
23299
|
};
|
|
23298
23300
|
function getTokenAssetsKey(token) {
|
|
@@ -26690,7 +26692,7 @@ function useStellarWallets() {
|
|
|
26690
26692
|
try {
|
|
26691
26693
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26692
26694
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26693
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26695
|
+
const { formatStellarWallet } = await import('./stellarService.client-BmkrPHkP.js');
|
|
26694
26696
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26695
26697
|
const promises = modules.map(async (module) => {
|
|
26696
26698
|
const isAvailable = await module.isAvailable();
|
|
@@ -29331,8 +29333,8 @@ function timeout(ms, promise) {
|
|
|
29331
29333
|
return Promise.race([promise, timeoutPromise]);
|
|
29332
29334
|
}
|
|
29333
29335
|
|
|
29334
|
-
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
29335
|
-
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29336
|
+
const DEFAULT_REFRESH_INTERVAL_MS$1 = 15000;
|
|
29337
|
+
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29336
29338
|
const { isChainTypeConnected } = useWallet();
|
|
29337
29339
|
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
29338
29340
|
const userAddressParsed = userAddress;
|
|
@@ -29383,7 +29385,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29383
29385
|
isLoading: isErc20Loading,
|
|
29384
29386
|
};
|
|
29385
29387
|
};
|
|
29386
|
-
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29388
|
+
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29387
29389
|
const { isConnected } = useCosmosContext();
|
|
29388
29390
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29389
29391
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
@@ -29407,7 +29409,7 @@ const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
29407
29409
|
});
|
|
29408
29410
|
return { balance, isLoading };
|
|
29409
29411
|
};
|
|
29410
|
-
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29412
|
+
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29411
29413
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29412
29414
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29413
29415
|
queryFn: async () => {
|
|
@@ -29438,7 +29440,7 @@ const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
|
29438
29440
|
}, [balanceBn]);
|
|
29439
29441
|
return { balance, isLoading };
|
|
29440
29442
|
};
|
|
29441
|
-
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29443
|
+
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29442
29444
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29443
29445
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29444
29446
|
queryFn: async () => {
|
|
@@ -29461,7 +29463,7 @@ const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29461
29463
|
});
|
|
29462
29464
|
return { balance, isLoading };
|
|
29463
29465
|
};
|
|
29464
|
-
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29466
|
+
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29465
29467
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29466
29468
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29467
29469
|
queryFn: async () => {
|
|
@@ -29481,7 +29483,7 @@ const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs
|
|
|
29481
29483
|
});
|
|
29482
29484
|
return { balance, isLoading };
|
|
29483
29485
|
};
|
|
29484
|
-
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29486
|
+
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29485
29487
|
const { data: balance = "0", isLoading } = useQuery({
|
|
29486
29488
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29487
29489
|
queryFn: async () => {
|
|
@@ -29525,6 +29527,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29525
29527
|
}
|
|
29526
29528
|
};
|
|
29527
29529
|
const nativeTokenForChainType = useMemo(() => {
|
|
29530
|
+
if (!chain)
|
|
29531
|
+
return undefined;
|
|
29528
29532
|
return findNativeToken(getTokensForChainType(), chain);
|
|
29529
29533
|
}, [chain]);
|
|
29530
29534
|
return { nativeToken: nativeTokenForChainType };
|
|
@@ -30008,7 +30012,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30008
30012
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30009
30013
|
if (!optionalChains.length)
|
|
30010
30014
|
return;
|
|
30011
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30015
|
+
const { EthereumProvider } = await import('./index.es-DOFFrTzb.js');
|
|
30012
30016
|
const rawProvider = await EthereumProvider.init({
|
|
30013
30017
|
...restParameters,
|
|
30014
30018
|
disableProviderPing: true,
|
|
@@ -31157,6 +31161,155 @@ const useSingleTokenPrice = (tokenData) => {
|
|
|
31157
31161
|
return { tokenPrice, getUSDValue };
|
|
31158
31162
|
};
|
|
31159
31163
|
|
|
31164
|
+
/**
|
|
31165
|
+
* @docs https://docs.tempo.xyz/protocol/fees/spec-fee-amm#2-feemanager-contract
|
|
31166
|
+
*/
|
|
31167
|
+
const TEMPO_FEE_MANAGER_ADDRESS = "0xfeec000000000000000000000000000000000000";
|
|
31168
|
+
const feeManagerAbi = [
|
|
31169
|
+
{
|
|
31170
|
+
name: "userTokens",
|
|
31171
|
+
type: "function",
|
|
31172
|
+
stateMutability: "view",
|
|
31173
|
+
inputs: [{ type: "address", name: "user" }],
|
|
31174
|
+
outputs: [{ type: "address" }],
|
|
31175
|
+
},
|
|
31176
|
+
];
|
|
31177
|
+
const isTempoChain = (chainId) => chainId === CHAIN_IDS.TEMPO;
|
|
31178
|
+
/**
|
|
31179
|
+
* Convert a gas fee amount from 18 decimals (attodollars)
|
|
31180
|
+
* to 6-decimal TIP-20 stablecoin units (microdollars).
|
|
31181
|
+
* All TIP-20 tokens on Tempo have 6 decimals.
|
|
31182
|
+
* @docs https://docs.tempo.xyz/protocol/fees/spec-fee#fee-units
|
|
31183
|
+
*/
|
|
31184
|
+
const convertTempoFeeToStablecoinUnits = (feeIn18Dec) => feeIn18Dec / BigInt(10 ** 12);
|
|
31185
|
+
|
|
31186
|
+
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
31187
|
+
/**
|
|
31188
|
+
* Returns raw on-chain gas token data for Tempo chains, or null when the source
|
|
31189
|
+
* chain is not Tempo.
|
|
31190
|
+
*/
|
|
31191
|
+
const useTempoFeeCheck = ({ fromChain, fromToken, }) => {
|
|
31192
|
+
const { connectedAddresses } = useWallet();
|
|
31193
|
+
const evmAddress = parseEvmAddress(connectedAddresses[ChainType.EVM]);
|
|
31194
|
+
const isTempo = isTempoChain(fromChain?.chainId);
|
|
31195
|
+
const chainId = Number(fromChain?.chainId);
|
|
31196
|
+
// Read account-level gas token preference from FeeManager precompile
|
|
31197
|
+
// See docs: https://docs.tempo.xyz/protocol/fees/spec-fee#account-level
|
|
31198
|
+
const { data: accountGasTokenAddress } = useReadContract({
|
|
31199
|
+
address: TEMPO_FEE_MANAGER_ADDRESS,
|
|
31200
|
+
abi: feeManagerAbi,
|
|
31201
|
+
functionName: "userTokens",
|
|
31202
|
+
args: evmAddress ? [evmAddress] : undefined,
|
|
31203
|
+
chainId,
|
|
31204
|
+
query: {
|
|
31205
|
+
enabled: isTempo && !!evmAddress,
|
|
31206
|
+
staleTime: 30_000,
|
|
31207
|
+
},
|
|
31208
|
+
});
|
|
31209
|
+
const hasAccountFeePreference = !!accountGasTokenAddress &&
|
|
31210
|
+
// By default, the zero address is returned when the user has no preference set
|
|
31211
|
+
zeroAddress$1.toLowerCase() !== accountGasTokenAddress.toLowerCase();
|
|
31212
|
+
// Fetch balance of the account-preferred gas token (if set)
|
|
31213
|
+
const { data: accountGasTokenBalance } = useBalance({
|
|
31214
|
+
address: evmAddress,
|
|
31215
|
+
token: hasAccountFeePreference ? accountGasTokenAddress : undefined,
|
|
31216
|
+
chainId,
|
|
31217
|
+
query: {
|
|
31218
|
+
enabled: isTempo && hasAccountFeePreference && !!evmAddress,
|
|
31219
|
+
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
|
|
31220
|
+
retry: 2,
|
|
31221
|
+
},
|
|
31222
|
+
});
|
|
31223
|
+
const fromTokenAddress = parseEvmAddress(fromToken?.address);
|
|
31224
|
+
const { data: fromTokenBalance } = useBalance({
|
|
31225
|
+
address: evmAddress,
|
|
31226
|
+
token: fromTokenAddress,
|
|
31227
|
+
chainId,
|
|
31228
|
+
query: {
|
|
31229
|
+
enabled: isTempo && !!evmAddress,
|
|
31230
|
+
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
|
|
31231
|
+
retry: 2,
|
|
31232
|
+
},
|
|
31233
|
+
});
|
|
31234
|
+
if (!isTempo)
|
|
31235
|
+
return null;
|
|
31236
|
+
if (hasAccountFeePreference) {
|
|
31237
|
+
if (!accountGasTokenAddress || !accountGasTokenBalance)
|
|
31238
|
+
return null;
|
|
31239
|
+
return {
|
|
31240
|
+
gasTokenAddress: accountGasTokenAddress,
|
|
31241
|
+
gasBalance: accountGasTokenBalance.value,
|
|
31242
|
+
};
|
|
31243
|
+
}
|
|
31244
|
+
if (!fromTokenAddress || !fromTokenBalance)
|
|
31245
|
+
return null;
|
|
31246
|
+
return {
|
|
31247
|
+
gasTokenAddress: fromTokenAddress,
|
|
31248
|
+
gasBalance: fromTokenBalance.value,
|
|
31249
|
+
};
|
|
31250
|
+
};
|
|
31251
|
+
|
|
31252
|
+
/**
|
|
31253
|
+
* Hook that returns the gas token and chain fee params for a given source chain and token.
|
|
31254
|
+
*/
|
|
31255
|
+
function useSourceChainGasToken({ fromChain, fromToken, }) {
|
|
31256
|
+
const { nativeToken } = useNativeTokenForChain(fromChain);
|
|
31257
|
+
const { evmTokens } = useSquidTokens();
|
|
31258
|
+
const { nativeBalance } = useNativeBalance(fromChain);
|
|
31259
|
+
const tempoFeeData = useTempoFeeCheck({ fromChain, fromToken });
|
|
31260
|
+
const chainFeeParams = useMemo(() => {
|
|
31261
|
+
if (fromToken?.address == null ||
|
|
31262
|
+
fromChain?.chainId == null ||
|
|
31263
|
+
nativeBalance?.value == null) {
|
|
31264
|
+
return null;
|
|
31265
|
+
}
|
|
31266
|
+
if (isTempoChain(fromChain.chainId)) {
|
|
31267
|
+
if (!tempoFeeData)
|
|
31268
|
+
return null;
|
|
31269
|
+
const fromTokenPaysGasFees = tempoFeeData.gasTokenAddress.toLowerCase() ===
|
|
31270
|
+
fromToken.address.toLowerCase();
|
|
31271
|
+
return {
|
|
31272
|
+
fromTokenPaysGasFees,
|
|
31273
|
+
gasTokenBalanceWei: tempoFeeData.gasBalance,
|
|
31274
|
+
normalizeFee: convertTempoFeeToStablecoinUnits,
|
|
31275
|
+
};
|
|
31276
|
+
}
|
|
31277
|
+
return {
|
|
31278
|
+
fromTokenPaysGasFees: fromToken.address.toLowerCase() ===
|
|
31279
|
+
chainTypeToNativeTokenAddressMap[fromToken.type].toLowerCase(),
|
|
31280
|
+
gasTokenBalanceWei: nativeBalance.value,
|
|
31281
|
+
normalizeFee: (fee) => fee,
|
|
31282
|
+
};
|
|
31283
|
+
}, [
|
|
31284
|
+
fromToken?.address,
|
|
31285
|
+
fromToken?.type,
|
|
31286
|
+
fromChain?.chainId,
|
|
31287
|
+
nativeBalance?.value,
|
|
31288
|
+
tempoFeeData,
|
|
31289
|
+
]);
|
|
31290
|
+
/**
|
|
31291
|
+
* The token to pay for gas on the source chain.
|
|
31292
|
+
*/
|
|
31293
|
+
const gasToken = useMemo(() => {
|
|
31294
|
+
if (fromChain?.chainId == null || fromToken?.address == null)
|
|
31295
|
+
return undefined;
|
|
31296
|
+
if (isTempoChain(fromChain.chainId)) {
|
|
31297
|
+
if (!tempoFeeData)
|
|
31298
|
+
return undefined;
|
|
31299
|
+
return evmTokens.find((t) => t.chainId === fromChain.chainId &&
|
|
31300
|
+
t.address.toLowerCase() === tempoFeeData.gasTokenAddress.toLowerCase());
|
|
31301
|
+
}
|
|
31302
|
+
return nativeToken;
|
|
31303
|
+
}, [
|
|
31304
|
+
fromChain?.chainId,
|
|
31305
|
+
fromToken?.address,
|
|
31306
|
+
nativeToken,
|
|
31307
|
+
tempoFeeData,
|
|
31308
|
+
evmTokens,
|
|
31309
|
+
]);
|
|
31310
|
+
return { gasToken, chainFeeParams };
|
|
31311
|
+
}
|
|
31312
|
+
|
|
31160
31313
|
const MAX_COINGECKO_QUERY_TOKENS = 100;
|
|
31161
31314
|
const fetchHistoricalData = async (coingeckoId, timeFrame) => {
|
|
31162
31315
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -31307,24 +31460,23 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
|
|
|
31307
31460
|
(sameTokenBetweenFees
|
|
31308
31461
|
? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
|
|
31309
31462
|
: BigInt(firstGasCost?.amount ?? "0"));
|
|
31310
|
-
const
|
|
31311
|
-
|
|
31312
|
-
|
|
31313
|
-
|
|
31314
|
-
|
|
31315
|
-
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
|
|
31319
|
-
}
|
|
31320
|
-
|
|
31321
|
-
|
|
31322
|
-
|
|
31323
|
-
|
|
31324
|
-
|
|
31325
|
-
|
|
31326
|
-
|
|
31327
|
-
: undefined;
|
|
31463
|
+
const checkIsGasBalanceEnough = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
|
|
31464
|
+
if (!chainFeeParams)
|
|
31465
|
+
return false;
|
|
31466
|
+
if (chainFeeParams.fromTokenPaysGasFees) {
|
|
31467
|
+
return (BigInt(fromAmount ?? "0") + networkFeesWei <=
|
|
31468
|
+
chainFeeParams.gasTokenBalanceWei);
|
|
31469
|
+
}
|
|
31470
|
+
return networkFeesWei <= chainFeeParams.gasTokenBalanceWei;
|
|
31471
|
+
};
|
|
31472
|
+
const calculateMinAmountValueWarnMsg = ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }) => {
|
|
31473
|
+
if (!chainFeeParams?.fromTokenPaysGasFees)
|
|
31474
|
+
return undefined;
|
|
31475
|
+
const minAmount = chainFeeParams.gasTokenBalanceWei - networkFeesWei;
|
|
31476
|
+
if (minAmount <= BigInt(0))
|
|
31477
|
+
return undefined;
|
|
31478
|
+
return formatBNToReadable(minAmount, fromTokenDecimals);
|
|
31479
|
+
};
|
|
31328
31480
|
/**
|
|
31329
31481
|
* Calculates the estimated duration of a route
|
|
31330
31482
|
*
|
|
@@ -31363,12 +31515,10 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
|
|
|
31363
31515
|
* @returns {Object} An object containing various estimate results and calculations, including token information,
|
|
31364
31516
|
* amounts, fees, gas costs, and other relevant data for the transaction.
|
|
31365
31517
|
*/
|
|
31366
|
-
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees,
|
|
31518
|
+
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
|
|
31367
31519
|
const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
|
|
31368
31520
|
const fromAmount = squidRoute?.estimate?.fromAmount;
|
|
31369
31521
|
const fromAmountFormatted = formatAmount(fromAmount, fromToken?.decimals);
|
|
31370
|
-
const sourceChainNativeToken = findNativeToken(tokens, fromChain);
|
|
31371
|
-
const destChainNativeToken = findNativeToken(tokens, toChain);
|
|
31372
31522
|
const toAmountUSD = squidRoute?.estimate?.toAmountUSD;
|
|
31373
31523
|
const exchangeRate = squidRoute?.estimate.exchangeRate ?? "0";
|
|
31374
31524
|
const toAmountMinUSD = squidRoute?.estimate.toAmountMinUSD ?? "0";
|
|
@@ -31387,10 +31537,6 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31387
31537
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
31388
31538
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
31389
31539
|
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
31540
|
const totalNativeFees = calculateTotalNativeFees({
|
|
31395
31541
|
expressFeeCost,
|
|
31396
31542
|
firstFeeCost,
|
|
@@ -31398,30 +31544,32 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31398
31544
|
sameTokenBetweenFees,
|
|
31399
31545
|
});
|
|
31400
31546
|
const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
|
|
31401
|
-
const
|
|
31402
|
-
|
|
31547
|
+
const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
|
|
31548
|
+
const isGasBalanceEnough = checkIsGasBalanceEnough({
|
|
31549
|
+
chainFeeParams,
|
|
31403
31550
|
fromAmount,
|
|
31404
|
-
|
|
31405
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31406
|
-
nativeTokenBalanceFromChainWei,
|
|
31551
|
+
networkFeesWei,
|
|
31407
31552
|
});
|
|
31408
31553
|
const minAmountValueWarnMsg = calculateMinAmountValueWarnMsg({
|
|
31409
|
-
|
|
31410
|
-
|
|
31411
|
-
|
|
31412
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31554
|
+
chainFeeParams,
|
|
31555
|
+
networkFeesWei,
|
|
31556
|
+
fromTokenDecimals: fromToken?.decimals,
|
|
31413
31557
|
});
|
|
31414
31558
|
const isSingleChainRoute = fromChain?.chainId === toChain?.chainId;
|
|
31415
31559
|
const estimatedRouteDuration = formatEstimatedRouteDuration({
|
|
31416
31560
|
estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
|
|
31417
31561
|
isSingleChainRoute,
|
|
31418
31562
|
});
|
|
31563
|
+
// gas fees + fromAmount (if fromToken is gas token)
|
|
31564
|
+
const totalGasBalanceNeeded = networkFeesWei +
|
|
31565
|
+
BigInt(chainFeeParams?.fromTokenPaysGasFees ? fromAmount ?? 0 : 0);
|
|
31566
|
+
const gasBalanceNeeded = gasToken
|
|
31567
|
+
? formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals)
|
|
31568
|
+
: undefined;
|
|
31419
31569
|
return {
|
|
31420
31570
|
fromToken,
|
|
31421
31571
|
fromAmount,
|
|
31422
31572
|
fromAmountFormatted,
|
|
31423
|
-
sourceChainNativeToken,
|
|
31424
|
-
destChainNativeToken,
|
|
31425
31573
|
toAmountUSD,
|
|
31426
31574
|
exchangeRate,
|
|
31427
31575
|
toAmountMinUSD,
|
|
@@ -31436,12 +31584,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31436
31584
|
expectedGasRefundCost,
|
|
31437
31585
|
expectedGasRefundCostUSD,
|
|
31438
31586
|
sameTokenBetweenFees,
|
|
31439
|
-
|
|
31587
|
+
fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31440
31588
|
totalNativeFees,
|
|
31441
|
-
|
|
31442
|
-
fromBalanceEnoughToSwap,
|
|
31589
|
+
isGasBalanceEnough,
|
|
31443
31590
|
minAmountValueWarnMsg,
|
|
31444
31591
|
estimatedRouteDuration,
|
|
31592
|
+
gasBalanceNeeded,
|
|
31445
31593
|
};
|
|
31446
31594
|
};
|
|
31447
31595
|
/**
|
|
@@ -31475,28 +31623,6 @@ const calculateTotalWithRefundEstimate = (allFeeCosts, expectedGasRefundCost, ge
|
|
|
31475
31623
|
feeToken: firstFeeCost?.token,
|
|
31476
31624
|
};
|
|
31477
31625
|
};
|
|
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
31626
|
|
|
31501
31627
|
function useSendTransactionGas({ chain, token, from, }) {
|
|
31502
31628
|
return useQuery({
|
|
@@ -31518,7 +31644,11 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31518
31644
|
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
31519
31645
|
// so we'll try to use the user provided address when possible
|
|
31520
31646
|
const sender = from || dummyAddress;
|
|
31521
|
-
|
|
31647
|
+
// Tempo has no native token, so `value` transfers are rejected by the EVM.
|
|
31648
|
+
// All transfers are ERC20 transfers
|
|
31649
|
+
const supportsNativeTransfers = chain.chainId !== CHAIN_IDS.TEMPO;
|
|
31650
|
+
const isNativeToken = token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
31651
|
+
if (isNativeToken && supportsNativeTransfers) {
|
|
31522
31652
|
const gas = await client.estimateGas({
|
|
31523
31653
|
from: sender,
|
|
31524
31654
|
to: dummyAddress,
|
|
@@ -31538,7 +31668,13 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31538
31668
|
data,
|
|
31539
31669
|
chainId: chain.chainId,
|
|
31540
31670
|
});
|
|
31541
|
-
|
|
31671
|
+
const feeWei = gas * maxFeePerGas;
|
|
31672
|
+
// Tempo gas fees are denominated 18 units,
|
|
31673
|
+
// this value needs to be scaled to 6 decimals
|
|
31674
|
+
if (chain.chainId === CHAIN_IDS.TEMPO) {
|
|
31675
|
+
return convertTempoFeeToStablecoinUnits(feeWei);
|
|
31676
|
+
}
|
|
31677
|
+
return feeWei;
|
|
31542
31678
|
}
|
|
31543
31679
|
case ChainType.COSMOS: {
|
|
31544
31680
|
// TODO: get gas estimation from backend
|
|
@@ -31585,19 +31721,33 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31585
31721
|
token,
|
|
31586
31722
|
from,
|
|
31587
31723
|
});
|
|
31588
|
-
const {
|
|
31589
|
-
|
|
31590
|
-
|
|
31724
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
31725
|
+
fromChain: chain,
|
|
31726
|
+
fromToken: token,
|
|
31727
|
+
});
|
|
31728
|
+
const isGasBalanceEnough = useMemo(() => {
|
|
31729
|
+
if (!amount || !token?.decimals)
|
|
31591
31730
|
return false;
|
|
31592
|
-
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
31599
|
-
|
|
31600
|
-
|
|
31731
|
+
return checkIsGasBalanceEnough({
|
|
31732
|
+
fromAmount: parseToBigInt(amount, token.decimals).toString(),
|
|
31733
|
+
networkFeesWei: estimatedGas,
|
|
31734
|
+
chainFeeParams,
|
|
31735
|
+
});
|
|
31736
|
+
}, [amount, estimatedGas, token, chainFeeParams]);
|
|
31737
|
+
const gasBalanceNeeded = useMemo(() => {
|
|
31738
|
+
if (!amount || !token?.decimals || !gasToken?.decimals)
|
|
31739
|
+
return undefined;
|
|
31740
|
+
// gas fees + fromAmount (if fromToken is gas token)
|
|
31741
|
+
const totalGasBalanceNeeded = estimatedGas +
|
|
31742
|
+
parseToBigInt(chainFeeParams?.fromTokenPaysGasFees ? amount ?? "0" : "0", token.decimals);
|
|
31743
|
+
return formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals);
|
|
31744
|
+
}, [
|
|
31745
|
+
amount,
|
|
31746
|
+
chainFeeParams?.fromTokenPaysGasFees,
|
|
31747
|
+
estimatedGas,
|
|
31748
|
+
gasToken?.decimals,
|
|
31749
|
+
token?.decimals,
|
|
31750
|
+
]);
|
|
31601
31751
|
const isBalanceEnough = useMemo(() => {
|
|
31602
31752
|
if (token?.decimals == null || !balance || !amount)
|
|
31603
31753
|
return false;
|
|
@@ -31605,28 +31755,21 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31605
31755
|
parseToBigInt(amount, token.decimals));
|
|
31606
31756
|
}, [amount, balance, token?.decimals]);
|
|
31607
31757
|
const minAmountValueWarnMsg = useMemo(() => {
|
|
31608
|
-
if (!token?.address || !
|
|
31758
|
+
if (!token?.address || !estimatedGas || !chainFeeParams)
|
|
31609
31759
|
return undefined;
|
|
31610
|
-
const isFromTokenNative = token.address.toLowerCase() ===
|
|
31611
|
-
chainTypeToNativeTokenAddressMap[token.type].toLowerCase();
|
|
31612
31760
|
return calculateMinAmountValueWarnMsg({
|
|
31613
|
-
|
|
31614
|
-
|
|
31615
|
-
|
|
31616
|
-
totalFeesInNativeTokenPlusRatio: estimatedGas,
|
|
31761
|
+
chainFeeParams,
|
|
31762
|
+
networkFeesWei: estimatedGas,
|
|
31763
|
+
fromTokenDecimals: token.decimals,
|
|
31617
31764
|
});
|
|
31618
|
-
}, [
|
|
31619
|
-
estimatedGas,
|
|
31620
|
-
nativeBalance?.decimals,
|
|
31621
|
-
nativeBalance?.value,
|
|
31622
|
-
token?.address,
|
|
31623
|
-
token?.type,
|
|
31624
|
-
]);
|
|
31765
|
+
}, [estimatedGas, token, chainFeeParams]);
|
|
31625
31766
|
return {
|
|
31626
31767
|
estimatedGas,
|
|
31768
|
+
gasBalanceNeeded,
|
|
31627
31769
|
isBalanceEnough,
|
|
31770
|
+
tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31628
31771
|
isLoading,
|
|
31629
|
-
|
|
31772
|
+
isGasBalanceEnough,
|
|
31630
31773
|
minAmountValueWarnMsg,
|
|
31631
31774
|
};
|
|
31632
31775
|
}
|
|
@@ -32688,7 +32831,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32688
32831
|
// This is to ensure we're using the latest expiry timestamp
|
|
32689
32832
|
if (squidRoute) {
|
|
32690
32833
|
queryClient.refetchQueries({
|
|
32691
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.
|
|
32834
|
+
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
32835
|
// TODO: update types
|
|
32693
32836
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32694
32837
|
});
|
|
@@ -32707,17 +32850,30 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32707
32850
|
const useEstimate = (squidRoute) => {
|
|
32708
32851
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32709
32852
|
const { tokens } = useSquidTokens();
|
|
32710
|
-
const { fromChain, toChain } = useSwap();
|
|
32711
|
-
const
|
|
32853
|
+
const { fromChain, toChain, fromPrice } = useSwap();
|
|
32854
|
+
const fromToken = useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32855
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32856
|
+
fromChain,
|
|
32857
|
+
fromToken,
|
|
32858
|
+
});
|
|
32712
32859
|
const estimateResults = useMemo(() => calculateEstimateResults({
|
|
32713
32860
|
squidRoute,
|
|
32714
32861
|
tokens,
|
|
32715
32862
|
fromChain,
|
|
32716
32863
|
toChain,
|
|
32717
32864
|
collectFees: !!collectFees && collectFees.fee > 0,
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
|
|
32865
|
+
chainFeeParams,
|
|
32866
|
+
gasToken,
|
|
32867
|
+
}), [
|
|
32868
|
+
squidRoute,
|
|
32869
|
+
tokens,
|
|
32870
|
+
fromChain,
|
|
32871
|
+
toChain,
|
|
32872
|
+
collectFees,
|
|
32873
|
+
chainFeeParams,
|
|
32874
|
+
gasToken,
|
|
32875
|
+
]);
|
|
32876
|
+
const fromBalanceFormatted = useMultiChainBalance({
|
|
32721
32877
|
chain: fromChain,
|
|
32722
32878
|
token: estimateResults.fromToken,
|
|
32723
32879
|
userAddress: squidRoute?.params.fromAddress ?? "",
|
|
@@ -32729,7 +32885,6 @@ const useEstimate = (squidRoute) => {
|
|
|
32729
32885
|
estimateResults.expectedGasRefundCost,
|
|
32730
32886
|
getUSDValue,
|
|
32731
32887
|
]);
|
|
32732
|
-
const proposedGasDestinationAmount = useMemo(() => getProposedGasDestinationAmount(estimateResults.destChainNativeToken?.symbol), [estimateResults.destChainNativeToken]);
|
|
32733
32888
|
const { feeCostsFormatted, totalFeeCostsUsd } = useMemo(() => {
|
|
32734
32889
|
const feeCosts = squidRoute?.estimate.feeCosts ?? [];
|
|
32735
32890
|
const feeCostsRenamed = [];
|
|
@@ -32788,21 +32943,21 @@ const useEstimate = (squidRoute) => {
|
|
|
32788
32943
|
totalFeeCostsUsd: totalFeeCostsUsdFormatted,
|
|
32789
32944
|
};
|
|
32790
32945
|
}, [squidRoute?.estimate.feeCosts]);
|
|
32791
|
-
const slippageFormatted =
|
|
32792
|
-
|
|
32793
|
-
|
|
32794
|
-
|
|
32795
|
-
|
|
32796
|
-
|
|
32946
|
+
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32947
|
+
const fromBalanceEnoughToSwap = useMemo(() => {
|
|
32948
|
+
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32949
|
+
const fromPriceNum = Number(fromPrice ?? 0);
|
|
32950
|
+
return fromBalanceNum >= fromPriceNum;
|
|
32951
|
+
}, [fromBalanceFormatted, fromPrice]);
|
|
32797
32952
|
return {
|
|
32798
32953
|
...estimateResults,
|
|
32799
|
-
|
|
32954
|
+
fromBalanceFormatted,
|
|
32800
32955
|
slippageFormatted,
|
|
32801
32956
|
totalWithRefundEstimate,
|
|
32802
|
-
|
|
32803
|
-
enoughBalanceToSwap,
|
|
32957
|
+
fromBalanceEnoughToSwap,
|
|
32804
32958
|
feeCostsFormatted,
|
|
32805
32959
|
totalFeeCostsUsd,
|
|
32960
|
+
gasToken,
|
|
32806
32961
|
};
|
|
32807
32962
|
};
|
|
32808
32963
|
|
|
@@ -36570,7 +36725,7 @@ const useGetRoute = () => {
|
|
|
36570
36725
|
});
|
|
36571
36726
|
// Cache the route data
|
|
36572
36727
|
// Useful when the getRoute mutation is called from another hook
|
|
36573
|
-
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage,
|
|
36728
|
+
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
36729
|
return route;
|
|
36575
36730
|
});
|
|
36576
36731
|
};
|
|
@@ -36593,14 +36748,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36593
36748
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36594
36749
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36595
36750
|
: sourceConnectedAddress;
|
|
36596
|
-
const squidRouteQueryKeys = useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage,
|
|
36751
|
+
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
36752
|
fromChain?.chainId,
|
|
36598
36753
|
toChain?.chainId,
|
|
36599
36754
|
toToken?.address,
|
|
36600
36755
|
fromToken?.address,
|
|
36601
36756
|
fromPrice,
|
|
36602
36757
|
config.slippage,
|
|
36603
|
-
config.enableGetGasOnDestination,
|
|
36604
36758
|
sourceUserAddress,
|
|
36605
36759
|
config.degenMode,
|
|
36606
36760
|
destinationAddress,
|
|
@@ -36872,35 +37026,6 @@ const useAvatar = (seed = zeroAddress) => {
|
|
|
36872
37026
|
return avatar || "";
|
|
36873
37027
|
};
|
|
36874
37028
|
|
|
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
37029
|
const useAddToken = (chainToCompare, tokenToCompare) => {
|
|
36905
37030
|
const { chain: currentEvmChain } = useAccount();
|
|
36906
37031
|
const { connector } = useAccount();
|
|
@@ -37328,5 +37453,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37328
37453
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37329
37454
|
};
|
|
37330
37455
|
|
|
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
|
|
37456
|
+
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 };
|
|
37457
|
+
//# sourceMappingURL=index-Dgqm3ZeG.js.map
|