@0xsquid/react-hooks 8.6.0 → 8.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/constants.d.ts +3 -0
- package/dist/core/queries/queries-keys.d.ts +1 -1
- package/dist/core/types/config.d.ts +0 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/tokens/useSourceChainGasToken.d.ts +13 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +11 -2
- package/dist/hooks/transaction/useEstimate.d.ts +7 -12
- package/dist/hooks/transaction/useTempoFeeCheck.d.ts +11 -0
- package/dist/{index-BvAot66c.js → index-BOMoTOCH.js} +282 -157
- package/dist/index-BOMoTOCH.js.map +1 -0
- package/dist/{index-Ck3Byj7H.js → index-CpHc3uRR.js} +282 -157
- package/dist/index-CpHc3uRR.js.map +1 -0
- package/dist/{index.es-C_BgGjLx.js → index.es-Bx1b09ob.js} +2 -2
- package/dist/{index.es-C_BgGjLx.js.map → index.es-Bx1b09ob.js.map} +1 -1
- package/dist/{index.es-83oSJcJe.js → index.es-DYEb3pTJ.js} +2 -2
- package/dist/{index.es-83oSJcJe.js.map → index.es-DYEb3pTJ.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{secretService-Cj_HK_on.js → secretService-0Y9Bj_Ic.js} +2 -2
- package/dist/{secretService-Cj_HK_on.js.map → secretService-0Y9Bj_Ic.js.map} +1 -1
- package/dist/{secretService-zFFQM-jC.js → secretService-DnKMq9Ib.js} +2 -2
- package/dist/{secretService-zFFQM-jC.js.map → secretService-DnKMq9Ib.js.map} +1 -1
- package/dist/server.esm.js +3 -0
- package/dist/server.esm.js.map +1 -1
- package/dist/server.js +3 -0
- package/dist/server.js.map +1 -1
- package/dist/services/internal/assetsService.d.ts +2 -2
- package/dist/services/internal/estimateService.d.ts +15 -28
- package/dist/services/internal/tempoService.d.ts +42 -0
- package/dist/{stellarService.client-CI86BfjV.js → stellarService.client-B3kAxROD.js} +2 -2
- package/dist/{stellarService.client-CI86BfjV.js.map → stellarService.client-B3kAxROD.js.map} +1 -1
- package/dist/{stellarService.client-CBzr6pLs.js → stellarService.client-Dyichswq.js} +2 -2
- package/dist/{stellarService.client-CBzr6pLs.js.map → stellarService.client-Dyichswq.js.map} +1 -1
- package/package.json +1 -1
- package/dist/hooks/user/useUserParams.d.ts +0 -4
- package/dist/index-BvAot66c.js.map +0 -1
- package/dist/index-Ck3Byj7H.js.map +0 -1
|
@@ -145,6 +145,9 @@ const CHAIN_IDS = {
|
|
|
145
145
|
SONEIUM: "1868",
|
|
146
146
|
PEAQ: "3338",
|
|
147
147
|
HEDERA: "295",
|
|
148
|
+
MANTRA: "5888",
|
|
149
|
+
CITREA: "4114",
|
|
150
|
+
TEMPO: "4217",
|
|
148
151
|
// others
|
|
149
152
|
BITCOIN: "bitcoin",
|
|
150
153
|
SOLANA: "solana-mainnet-beta",
|
|
@@ -22409,7 +22412,7 @@ const keys = () => ({
|
|
|
22409
22412
|
// ============
|
|
22410
22413
|
// Transactions
|
|
22411
22414
|
// ============
|
|
22412
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage,
|
|
22415
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
|
|
22413
22416
|
...keys().transactions(),
|
|
22414
22417
|
exports.QueryKeys.Transaction,
|
|
22415
22418
|
fromChainId,
|
|
@@ -22418,7 +22421,6 @@ const keys = () => ({
|
|
|
22418
22421
|
fromTokenAddress,
|
|
22419
22422
|
price,
|
|
22420
22423
|
slippage,
|
|
22421
|
-
getGasOnDestination,
|
|
22422
22424
|
sourceUserAddress,
|
|
22423
22425
|
degenMode,
|
|
22424
22426
|
destinationAddress,
|
|
@@ -22607,7 +22609,6 @@ const getConfigWithDefaults = (config) => {
|
|
|
22607
22609
|
integratorId: get$2(config, "integratorId", defaultConfigValues.integratorId),
|
|
22608
22610
|
slippage: get$2(config, "slippage", defaultConfigValues.slippage),
|
|
22609
22611
|
collectFees: get$2(config, "collectFees", defaultConfigValues.collectFees),
|
|
22610
|
-
enableGetGasOnDestination: get$2(config, "enableGetGasOnDestination", defaultConfigValues.enableGetGasOnDestination),
|
|
22611
22612
|
apiUrl: get$2(config, "apiUrl", defaultConfigValues.apiUrl),
|
|
22612
22613
|
priceImpactWarnings: get$2(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
|
|
22613
22614
|
initialAssets: get$2(config, "initialAssets", defaultConfigValues.initialAssets),
|
|
@@ -23101,8 +23102,8 @@ const sortAllTokens = (tokenA, tokenB) => {
|
|
|
23101
23102
|
return 0;
|
|
23102
23103
|
};
|
|
23103
23104
|
const findToken = (tokens, chainId, address) => tokens.find((t) => t.chainId === chainId && t.address === address);
|
|
23104
|
-
const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain
|
|
23105
|
-
t.chainId == chain
|
|
23105
|
+
const findNativeToken = (tokens, chain) => tokens.find((t) => t.symbol.toUpperCase() === chain.nativeCurrency.symbol.toUpperCase() &&
|
|
23106
|
+
t.chainId == chain.chainId);
|
|
23106
23107
|
const normalizeIbcAddress = (address) => {
|
|
23107
23108
|
if (!address.toLowerCase().startsWith("ibc/")) {
|
|
23108
23109
|
return address;
|
|
@@ -23313,7 +23314,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23313
23314
|
};
|
|
23314
23315
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23315
23316
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23316
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23317
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-0Y9Bj_Ic.js'); });
|
|
23317
23318
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23318
23319
|
};
|
|
23319
23320
|
function getTokenAssetsKey(token) {
|
|
@@ -26711,7 +26712,7 @@ function useStellarWallets() {
|
|
|
26711
26712
|
try {
|
|
26712
26713
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26713
26714
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26714
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26715
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-Dyichswq.js'); });
|
|
26715
26716
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26716
26717
|
const promises = modules.map(async (module) => {
|
|
26717
26718
|
const isAvailable = await module.isAvailable();
|
|
@@ -29352,8 +29353,8 @@ function timeout(ms, promise) {
|
|
|
29352
29353
|
return Promise.race([promise, timeoutPromise]);
|
|
29353
29354
|
}
|
|
29354
29355
|
|
|
29355
|
-
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
29356
|
-
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29356
|
+
const DEFAULT_REFRESH_INTERVAL_MS$1 = 15000;
|
|
29357
|
+
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29357
29358
|
const { isChainTypeConnected } = useWallet();
|
|
29358
29359
|
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
29359
29360
|
const userAddressParsed = userAddress;
|
|
@@ -29404,7 +29405,7 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29404
29405
|
isLoading: isErc20Loading,
|
|
29405
29406
|
};
|
|
29406
29407
|
};
|
|
29407
|
-
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29408
|
+
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29408
29409
|
const { isConnected } = useCosmosContext();
|
|
29409
29410
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
29410
29411
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
@@ -29428,7 +29429,7 @@ const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
29428
29429
|
});
|
|
29429
29430
|
return { balance, isLoading };
|
|
29430
29431
|
};
|
|
29431
|
-
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29432
|
+
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29432
29433
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
29433
29434
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29434
29435
|
queryFn: async () => {
|
|
@@ -29459,7 +29460,7 @@ const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
|
29459
29460
|
}, [balanceBn]);
|
|
29460
29461
|
return { balance, isLoading };
|
|
29461
29462
|
};
|
|
29462
|
-
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29463
|
+
const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29463
29464
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
29464
29465
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29465
29466
|
queryFn: async () => {
|
|
@@ -29482,7 +29483,7 @@ const useSuiBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
29482
29483
|
});
|
|
29483
29484
|
return { balance, isLoading };
|
|
29484
29485
|
};
|
|
29485
|
-
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29486
|
+
const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29486
29487
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
29487
29488
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29488
29489
|
queryFn: async () => {
|
|
@@ -29502,7 +29503,7 @@ const useXrplBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs
|
|
|
29502
29503
|
});
|
|
29503
29504
|
return { balance, isLoading };
|
|
29504
29505
|
};
|
|
29505
|
-
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS, }) => {
|
|
29506
|
+
const useStellarBalance = ({ userAddress, chain, enabled, token, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
29506
29507
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
29507
29508
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
29508
29509
|
queryFn: async () => {
|
|
@@ -29546,6 +29547,8 @@ function useNativeTokenForChain(chain) {
|
|
|
29546
29547
|
}
|
|
29547
29548
|
};
|
|
29548
29549
|
const nativeTokenForChainType = React.useMemo(() => {
|
|
29550
|
+
if (!chain)
|
|
29551
|
+
return undefined;
|
|
29549
29552
|
return findNativeToken(getTokensForChainType(), chain);
|
|
29550
29553
|
}, [chain]);
|
|
29551
29554
|
return { nativeToken: nativeTokenForChainType };
|
|
@@ -30029,7 +30032,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30029
30032
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30030
30033
|
if (!optionalChains.length)
|
|
30031
30034
|
return;
|
|
30032
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30035
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-Bx1b09ob.js'); });
|
|
30033
30036
|
const rawProvider = await EthereumProvider.init({
|
|
30034
30037
|
...restParameters,
|
|
30035
30038
|
disableProviderPing: true,
|
|
@@ -30605,8 +30608,9 @@ function useStellarTrustLine({ address, chain, token, amount }) {
|
|
|
30605
30608
|
if (token?.type !== squidTypes.ChainType.STELLAR) {
|
|
30606
30609
|
return true;
|
|
30607
30610
|
}
|
|
30608
|
-
//
|
|
30609
|
-
|
|
30611
|
+
// Only stellar issued tokens need a trust line
|
|
30612
|
+
// (e.g. not needed for native or contract tokens)
|
|
30613
|
+
if (!isStellarIssuedToken(token)) {
|
|
30610
30614
|
return true;
|
|
30611
30615
|
}
|
|
30612
30616
|
if (!amount) {
|
|
@@ -31177,6 +31181,155 @@ const useSingleTokenPrice = (tokenData) => {
|
|
|
31177
31181
|
return { tokenPrice, getUSDValue };
|
|
31178
31182
|
};
|
|
31179
31183
|
|
|
31184
|
+
/**
|
|
31185
|
+
* @docs https://docs.tempo.xyz/protocol/fees/spec-fee-amm#2-feemanager-contract
|
|
31186
|
+
*/
|
|
31187
|
+
const TEMPO_FEE_MANAGER_ADDRESS = "0xfeec000000000000000000000000000000000000";
|
|
31188
|
+
const feeManagerAbi = [
|
|
31189
|
+
{
|
|
31190
|
+
name: "userTokens",
|
|
31191
|
+
type: "function",
|
|
31192
|
+
stateMutability: "view",
|
|
31193
|
+
inputs: [{ type: "address", name: "user" }],
|
|
31194
|
+
outputs: [{ type: "address" }],
|
|
31195
|
+
},
|
|
31196
|
+
];
|
|
31197
|
+
const isTempoChain = (chainId) => chainId === CHAIN_IDS.TEMPO;
|
|
31198
|
+
/**
|
|
31199
|
+
* Convert a gas fee amount from 18 decimals (attodollars)
|
|
31200
|
+
* to 6-decimal TIP-20 stablecoin units (microdollars).
|
|
31201
|
+
* All TIP-20 tokens on Tempo have 6 decimals.
|
|
31202
|
+
* @docs https://docs.tempo.xyz/protocol/fees/spec-fee#fee-units
|
|
31203
|
+
*/
|
|
31204
|
+
const convertTempoFeeToStablecoinUnits = (feeIn18Dec) => feeIn18Dec / BigInt(10 ** 12);
|
|
31205
|
+
|
|
31206
|
+
const DEFAULT_REFRESH_INTERVAL_MS = 15000;
|
|
31207
|
+
/**
|
|
31208
|
+
* Returns raw on-chain gas token data for Tempo chains, or null when the source
|
|
31209
|
+
* chain is not Tempo.
|
|
31210
|
+
*/
|
|
31211
|
+
const useTempoFeeCheck = ({ fromChain, fromToken, }) => {
|
|
31212
|
+
const { connectedAddresses } = useWallet();
|
|
31213
|
+
const evmAddress = parseEvmAddress(connectedAddresses[squidTypes.ChainType.EVM]);
|
|
31214
|
+
const isTempo = isTempoChain(fromChain?.chainId);
|
|
31215
|
+
const chainId = Number(fromChain?.chainId);
|
|
31216
|
+
// Read account-level gas token preference from FeeManager precompile
|
|
31217
|
+
// See docs: https://docs.tempo.xyz/protocol/fees/spec-fee#account-level
|
|
31218
|
+
const { data: accountGasTokenAddress } = wagmi.useReadContract({
|
|
31219
|
+
address: TEMPO_FEE_MANAGER_ADDRESS,
|
|
31220
|
+
abi: feeManagerAbi,
|
|
31221
|
+
functionName: "userTokens",
|
|
31222
|
+
args: evmAddress ? [evmAddress] : undefined,
|
|
31223
|
+
chainId,
|
|
31224
|
+
query: {
|
|
31225
|
+
enabled: isTempo && !!evmAddress,
|
|
31226
|
+
staleTime: 30_000,
|
|
31227
|
+
},
|
|
31228
|
+
});
|
|
31229
|
+
const hasAccountFeePreference = !!accountGasTokenAddress &&
|
|
31230
|
+
// By default, the zero address is returned when the user has no preference set
|
|
31231
|
+
viem.zeroAddress.toLowerCase() !== accountGasTokenAddress.toLowerCase();
|
|
31232
|
+
// Fetch balance of the account-preferred gas token (if set)
|
|
31233
|
+
const { data: accountGasTokenBalance } = wagmi.useBalance({
|
|
31234
|
+
address: evmAddress,
|
|
31235
|
+
token: hasAccountFeePreference ? accountGasTokenAddress : undefined,
|
|
31236
|
+
chainId,
|
|
31237
|
+
query: {
|
|
31238
|
+
enabled: isTempo && hasAccountFeePreference && !!evmAddress,
|
|
31239
|
+
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
|
|
31240
|
+
retry: 2,
|
|
31241
|
+
},
|
|
31242
|
+
});
|
|
31243
|
+
const fromTokenAddress = parseEvmAddress(fromToken?.address);
|
|
31244
|
+
const { data: fromTokenBalance } = wagmi.useBalance({
|
|
31245
|
+
address: evmAddress,
|
|
31246
|
+
token: fromTokenAddress,
|
|
31247
|
+
chainId,
|
|
31248
|
+
query: {
|
|
31249
|
+
enabled: isTempo && !!evmAddress,
|
|
31250
|
+
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
|
|
31251
|
+
retry: 2,
|
|
31252
|
+
},
|
|
31253
|
+
});
|
|
31254
|
+
if (!isTempo)
|
|
31255
|
+
return null;
|
|
31256
|
+
if (hasAccountFeePreference) {
|
|
31257
|
+
if (!accountGasTokenAddress || !accountGasTokenBalance)
|
|
31258
|
+
return null;
|
|
31259
|
+
return {
|
|
31260
|
+
gasTokenAddress: accountGasTokenAddress,
|
|
31261
|
+
gasBalance: accountGasTokenBalance.value,
|
|
31262
|
+
};
|
|
31263
|
+
}
|
|
31264
|
+
if (!fromTokenAddress || !fromTokenBalance)
|
|
31265
|
+
return null;
|
|
31266
|
+
return {
|
|
31267
|
+
gasTokenAddress: fromTokenAddress,
|
|
31268
|
+
gasBalance: fromTokenBalance.value,
|
|
31269
|
+
};
|
|
31270
|
+
};
|
|
31271
|
+
|
|
31272
|
+
/**
|
|
31273
|
+
* Hook that returns the gas token and chain fee params for a given source chain and token.
|
|
31274
|
+
*/
|
|
31275
|
+
function useSourceChainGasToken({ fromChain, fromToken, }) {
|
|
31276
|
+
const { nativeToken } = useNativeTokenForChain(fromChain);
|
|
31277
|
+
const { evmTokens } = useSquidTokens();
|
|
31278
|
+
const { nativeBalance } = useNativeBalance(fromChain);
|
|
31279
|
+
const tempoFeeData = useTempoFeeCheck({ fromChain, fromToken });
|
|
31280
|
+
const chainFeeParams = React.useMemo(() => {
|
|
31281
|
+
if (fromToken?.address == null ||
|
|
31282
|
+
fromChain?.chainId == null ||
|
|
31283
|
+
nativeBalance?.value == null) {
|
|
31284
|
+
return null;
|
|
31285
|
+
}
|
|
31286
|
+
if (isTempoChain(fromChain.chainId)) {
|
|
31287
|
+
if (!tempoFeeData)
|
|
31288
|
+
return null;
|
|
31289
|
+
const fromTokenPaysGasFees = tempoFeeData.gasTokenAddress.toLowerCase() ===
|
|
31290
|
+
fromToken.address.toLowerCase();
|
|
31291
|
+
return {
|
|
31292
|
+
fromTokenPaysGasFees,
|
|
31293
|
+
gasTokenBalanceWei: tempoFeeData.gasBalance,
|
|
31294
|
+
normalizeFee: convertTempoFeeToStablecoinUnits,
|
|
31295
|
+
};
|
|
31296
|
+
}
|
|
31297
|
+
return {
|
|
31298
|
+
fromTokenPaysGasFees: fromToken.address.toLowerCase() ===
|
|
31299
|
+
chainTypeToNativeTokenAddressMap[fromToken.type].toLowerCase(),
|
|
31300
|
+
gasTokenBalanceWei: nativeBalance.value,
|
|
31301
|
+
normalizeFee: (fee) => fee,
|
|
31302
|
+
};
|
|
31303
|
+
}, [
|
|
31304
|
+
fromToken?.address,
|
|
31305
|
+
fromToken?.type,
|
|
31306
|
+
fromChain?.chainId,
|
|
31307
|
+
nativeBalance?.value,
|
|
31308
|
+
tempoFeeData,
|
|
31309
|
+
]);
|
|
31310
|
+
/**
|
|
31311
|
+
* The token to pay for gas on the source chain.
|
|
31312
|
+
*/
|
|
31313
|
+
const gasToken = React.useMemo(() => {
|
|
31314
|
+
if (fromChain?.chainId == null || fromToken?.address == null)
|
|
31315
|
+
return undefined;
|
|
31316
|
+
if (isTempoChain(fromChain.chainId)) {
|
|
31317
|
+
if (!tempoFeeData)
|
|
31318
|
+
return undefined;
|
|
31319
|
+
return evmTokens.find((t) => t.chainId === fromChain.chainId &&
|
|
31320
|
+
t.address.toLowerCase() === tempoFeeData.gasTokenAddress.toLowerCase());
|
|
31321
|
+
}
|
|
31322
|
+
return nativeToken;
|
|
31323
|
+
}, [
|
|
31324
|
+
fromChain?.chainId,
|
|
31325
|
+
fromToken?.address,
|
|
31326
|
+
nativeToken,
|
|
31327
|
+
tempoFeeData,
|
|
31328
|
+
evmTokens,
|
|
31329
|
+
]);
|
|
31330
|
+
return { gasToken, chainFeeParams };
|
|
31331
|
+
}
|
|
31332
|
+
|
|
31180
31333
|
const MAX_COINGECKO_QUERY_TOKENS = 100;
|
|
31181
31334
|
const fetchHistoricalData = async (coingeckoId, timeFrame) => {
|
|
31182
31335
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -31327,24 +31480,23 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
|
|
|
31327
31480
|
(sameTokenBetweenFees
|
|
31328
31481
|
? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
|
|
31329
31482
|
: BigInt(firstGasCost?.amount ?? "0"));
|
|
31330
|
-
const
|
|
31331
|
-
|
|
31332
|
-
|
|
31333
|
-
|
|
31334
|
-
|
|
31335
|
-
|
|
31336
|
-
|
|
31337
|
-
|
|
31338
|
-
|
|
31339
|
-
}
|
|
31340
|
-
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31346
|
-
|
|
31347
|
-
: undefined;
|
|
31483
|
+
const checkIsGasBalanceEnough = ({ fromAmount, networkFeesWei, chainFeeParams, }) => {
|
|
31484
|
+
if (!chainFeeParams)
|
|
31485
|
+
return false;
|
|
31486
|
+
if (chainFeeParams.fromTokenPaysGasFees) {
|
|
31487
|
+
return (BigInt(fromAmount ?? "0") + networkFeesWei <=
|
|
31488
|
+
chainFeeParams.gasTokenBalanceWei);
|
|
31489
|
+
}
|
|
31490
|
+
return networkFeesWei <= chainFeeParams.gasTokenBalanceWei;
|
|
31491
|
+
};
|
|
31492
|
+
const calculateMinAmountValueWarnMsg = ({ networkFeesWei, chainFeeParams, fromTokenDecimals, }) => {
|
|
31493
|
+
if (!chainFeeParams?.fromTokenPaysGasFees)
|
|
31494
|
+
return undefined;
|
|
31495
|
+
const minAmount = chainFeeParams.gasTokenBalanceWei - networkFeesWei;
|
|
31496
|
+
if (minAmount <= BigInt(0))
|
|
31497
|
+
return undefined;
|
|
31498
|
+
return formatBNToReadable(minAmount, fromTokenDecimals);
|
|
31499
|
+
};
|
|
31348
31500
|
/**
|
|
31349
31501
|
* Calculates the estimated duration of a route
|
|
31350
31502
|
*
|
|
@@ -31383,12 +31535,10 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
|
|
|
31383
31535
|
* @returns {Object} An object containing various estimate results and calculations, including token information,
|
|
31384
31536
|
* amounts, fees, gas costs, and other relevant data for the transaction.
|
|
31385
31537
|
*/
|
|
31386
|
-
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees,
|
|
31538
|
+
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
|
|
31387
31539
|
const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
|
|
31388
31540
|
const fromAmount = squidRoute?.estimate?.fromAmount;
|
|
31389
31541
|
const fromAmountFormatted = formatAmount(fromAmount, fromToken?.decimals);
|
|
31390
|
-
const sourceChainNativeToken = findNativeToken(tokens, fromChain);
|
|
31391
|
-
const destChainNativeToken = findNativeToken(tokens, toChain);
|
|
31392
31542
|
const toAmountUSD = squidRoute?.estimate?.toAmountUSD;
|
|
31393
31543
|
const exchangeRate = squidRoute?.estimate.exchangeRate ?? "0";
|
|
31394
31544
|
const toAmountMinUSD = squidRoute?.estimate.toAmountMinUSD ?? "0";
|
|
@@ -31407,10 +31557,6 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31407
31557
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
31408
31558
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
31409
31559
|
firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
|
|
31410
|
-
const isFromTokenNative =
|
|
31411
|
-
// TODO: temporary fix, currently nativeCurrency.symbol is not always in uppercase
|
|
31412
|
-
fromToken?.symbol.toUpperCase() ===
|
|
31413
|
-
fromChain?.nativeCurrency.symbol.toUpperCase();
|
|
31414
31560
|
const totalNativeFees = calculateTotalNativeFees({
|
|
31415
31561
|
expressFeeCost,
|
|
31416
31562
|
firstFeeCost,
|
|
@@ -31418,30 +31564,32 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31418
31564
|
sameTokenBetweenFees,
|
|
31419
31565
|
});
|
|
31420
31566
|
const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
|
|
31421
|
-
const
|
|
31422
|
-
|
|
31567
|
+
const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
|
|
31568
|
+
const isGasBalanceEnough = checkIsGasBalanceEnough({
|
|
31569
|
+
chainFeeParams,
|
|
31423
31570
|
fromAmount,
|
|
31424
|
-
|
|
31425
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31426
|
-
nativeTokenBalanceFromChainWei,
|
|
31571
|
+
networkFeesWei,
|
|
31427
31572
|
});
|
|
31428
31573
|
const minAmountValueWarnMsg = calculateMinAmountValueWarnMsg({
|
|
31429
|
-
|
|
31430
|
-
|
|
31431
|
-
|
|
31432
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31574
|
+
chainFeeParams,
|
|
31575
|
+
networkFeesWei,
|
|
31576
|
+
fromTokenDecimals: fromToken?.decimals,
|
|
31433
31577
|
});
|
|
31434
31578
|
const isSingleChainRoute = fromChain?.chainId === toChain?.chainId;
|
|
31435
31579
|
const estimatedRouteDuration = formatEstimatedRouteDuration({
|
|
31436
31580
|
estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
|
|
31437
31581
|
isSingleChainRoute,
|
|
31438
31582
|
});
|
|
31583
|
+
// gas fees + fromAmount (if fromToken is gas token)
|
|
31584
|
+
const totalGasBalanceNeeded = networkFeesWei +
|
|
31585
|
+
BigInt(chainFeeParams?.fromTokenPaysGasFees ? fromAmount ?? 0 : 0);
|
|
31586
|
+
const gasBalanceNeeded = gasToken
|
|
31587
|
+
? formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals)
|
|
31588
|
+
: undefined;
|
|
31439
31589
|
return {
|
|
31440
31590
|
fromToken,
|
|
31441
31591
|
fromAmount,
|
|
31442
31592
|
fromAmountFormatted,
|
|
31443
|
-
sourceChainNativeToken,
|
|
31444
|
-
destChainNativeToken,
|
|
31445
31593
|
toAmountUSD,
|
|
31446
31594
|
exchangeRate,
|
|
31447
31595
|
toAmountMinUSD,
|
|
@@ -31456,12 +31604,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31456
31604
|
expectedGasRefundCost,
|
|
31457
31605
|
expectedGasRefundCostUSD,
|
|
31458
31606
|
sameTokenBetweenFees,
|
|
31459
|
-
|
|
31607
|
+
fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31460
31608
|
totalNativeFees,
|
|
31461
|
-
|
|
31462
|
-
fromBalanceEnoughToSwap,
|
|
31609
|
+
isGasBalanceEnough,
|
|
31463
31610
|
minAmountValueWarnMsg,
|
|
31464
31611
|
estimatedRouteDuration,
|
|
31612
|
+
gasBalanceNeeded,
|
|
31465
31613
|
};
|
|
31466
31614
|
};
|
|
31467
31615
|
/**
|
|
@@ -31495,28 +31643,6 @@ const calculateTotalWithRefundEstimate = (allFeeCosts, expectedGasRefundCost, ge
|
|
|
31495
31643
|
feeToken: firstFeeCost?.token,
|
|
31496
31644
|
};
|
|
31497
31645
|
};
|
|
31498
|
-
/**
|
|
31499
|
-
* Calculates the proposed gas amount for the destination chain.
|
|
31500
|
-
*
|
|
31501
|
-
* @param destChainNativeToken - The symbol of the native token for the destination chain.
|
|
31502
|
-
* @returns An object containing the proposed gas amount value and the currency symbol.
|
|
31503
|
-
*/
|
|
31504
|
-
const getProposedGasDestinationAmount = (destChainNativeToken) => {
|
|
31505
|
-
const gasAmounts = {
|
|
31506
|
-
GLMR: 5.289,
|
|
31507
|
-
ETH: 0.0009,
|
|
31508
|
-
AVAX: 0.115,
|
|
31509
|
-
BNB: 0.00425,
|
|
31510
|
-
FTM: 4.45,
|
|
31511
|
-
CELO: 3.052,
|
|
31512
|
-
KAVA: 2.339,
|
|
31513
|
-
MATIC: 1.795,
|
|
31514
|
-
};
|
|
31515
|
-
return {
|
|
31516
|
-
value: gasAmounts[destChainNativeToken ?? ""] ?? 0,
|
|
31517
|
-
currency: destChainNativeToken,
|
|
31518
|
-
};
|
|
31519
|
-
};
|
|
31520
31646
|
|
|
31521
31647
|
function useSendTransactionGas({ chain, token, from, }) {
|
|
31522
31648
|
return reactQuery.useQuery({
|
|
@@ -31538,7 +31664,11 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31538
31664
|
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
31539
31665
|
// so we'll try to use the user provided address when possible
|
|
31540
31666
|
const sender = from || dummyAddress;
|
|
31541
|
-
|
|
31667
|
+
// Tempo has no native token, so `value` transfers are rejected by the EVM.
|
|
31668
|
+
// All transfers are ERC20 transfers
|
|
31669
|
+
const supportsNativeTransfers = chain.chainId !== CHAIN_IDS.TEMPO;
|
|
31670
|
+
const isNativeToken = token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
31671
|
+
if (isNativeToken && supportsNativeTransfers) {
|
|
31542
31672
|
const gas = await client.estimateGas({
|
|
31543
31673
|
from: sender,
|
|
31544
31674
|
to: dummyAddress,
|
|
@@ -31558,7 +31688,13 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31558
31688
|
data,
|
|
31559
31689
|
chainId: chain.chainId,
|
|
31560
31690
|
});
|
|
31561
|
-
|
|
31691
|
+
const feeWei = gas * maxFeePerGas;
|
|
31692
|
+
// Tempo gas fees are denominated 18 units,
|
|
31693
|
+
// this value needs to be scaled to 6 decimals
|
|
31694
|
+
if (chain.chainId === CHAIN_IDS.TEMPO) {
|
|
31695
|
+
return convertTempoFeeToStablecoinUnits(feeWei);
|
|
31696
|
+
}
|
|
31697
|
+
return feeWei;
|
|
31562
31698
|
}
|
|
31563
31699
|
case squidTypes.ChainType.COSMOS: {
|
|
31564
31700
|
// TODO: get gas estimation from backend
|
|
@@ -31605,19 +31741,33 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31605
31741
|
token,
|
|
31606
31742
|
from,
|
|
31607
31743
|
});
|
|
31608
|
-
const {
|
|
31609
|
-
|
|
31610
|
-
|
|
31744
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
31745
|
+
fromChain: chain,
|
|
31746
|
+
fromToken: token,
|
|
31747
|
+
});
|
|
31748
|
+
const isGasBalanceEnough = React.useMemo(() => {
|
|
31749
|
+
if (!amount || !token?.decimals)
|
|
31611
31750
|
return false;
|
|
31612
|
-
|
|
31613
|
-
|
|
31614
|
-
|
|
31615
|
-
|
|
31616
|
-
|
|
31617
|
-
|
|
31618
|
-
|
|
31619
|
-
|
|
31620
|
-
|
|
31751
|
+
return checkIsGasBalanceEnough({
|
|
31752
|
+
fromAmount: parseToBigInt(amount, token.decimals).toString(),
|
|
31753
|
+
networkFeesWei: estimatedGas,
|
|
31754
|
+
chainFeeParams,
|
|
31755
|
+
});
|
|
31756
|
+
}, [amount, estimatedGas, token, chainFeeParams]);
|
|
31757
|
+
const gasBalanceNeeded = React.useMemo(() => {
|
|
31758
|
+
if (!amount || !token?.decimals || !gasToken?.decimals)
|
|
31759
|
+
return undefined;
|
|
31760
|
+
// gas fees + fromAmount (if fromToken is gas token)
|
|
31761
|
+
const totalGasBalanceNeeded = estimatedGas +
|
|
31762
|
+
parseToBigInt(chainFeeParams?.fromTokenPaysGasFees ? amount ?? "0" : "0", token.decimals);
|
|
31763
|
+
return formatBNToReadable(totalGasBalanceNeeded, gasToken.decimals);
|
|
31764
|
+
}, [
|
|
31765
|
+
amount,
|
|
31766
|
+
chainFeeParams?.fromTokenPaysGasFees,
|
|
31767
|
+
estimatedGas,
|
|
31768
|
+
gasToken?.decimals,
|
|
31769
|
+
token?.decimals,
|
|
31770
|
+
]);
|
|
31621
31771
|
const isBalanceEnough = React.useMemo(() => {
|
|
31622
31772
|
if (token?.decimals == null || !balance || !amount)
|
|
31623
31773
|
return false;
|
|
@@ -31625,28 +31775,21 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31625
31775
|
parseToBigInt(amount, token.decimals));
|
|
31626
31776
|
}, [amount, balance, token?.decimals]);
|
|
31627
31777
|
const minAmountValueWarnMsg = React.useMemo(() => {
|
|
31628
|
-
if (!token?.address || !
|
|
31778
|
+
if (!token?.address || !estimatedGas || !chainFeeParams)
|
|
31629
31779
|
return undefined;
|
|
31630
|
-
const isFromTokenNative = token.address.toLowerCase() ===
|
|
31631
|
-
chainTypeToNativeTokenAddressMap[token.type].toLowerCase();
|
|
31632
31780
|
return calculateMinAmountValueWarnMsg({
|
|
31633
|
-
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
totalFeesInNativeTokenPlusRatio: estimatedGas,
|
|
31781
|
+
chainFeeParams,
|
|
31782
|
+
networkFeesWei: estimatedGas,
|
|
31783
|
+
fromTokenDecimals: token.decimals,
|
|
31637
31784
|
});
|
|
31638
|
-
}, [
|
|
31639
|
-
estimatedGas,
|
|
31640
|
-
nativeBalance?.decimals,
|
|
31641
|
-
nativeBalance?.value,
|
|
31642
|
-
token?.address,
|
|
31643
|
-
token?.type,
|
|
31644
|
-
]);
|
|
31785
|
+
}, [estimatedGas, token, chainFeeParams]);
|
|
31645
31786
|
return {
|
|
31646
31787
|
estimatedGas,
|
|
31788
|
+
gasBalanceNeeded,
|
|
31647
31789
|
isBalanceEnough,
|
|
31790
|
+
tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31648
31791
|
isLoading,
|
|
31649
|
-
|
|
31792
|
+
isGasBalanceEnough,
|
|
31650
31793
|
minAmountValueWarnMsg,
|
|
31651
31794
|
};
|
|
31652
31795
|
}
|
|
@@ -32708,7 +32851,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32708
32851
|
// This is to ensure we're using the latest expiry timestamp
|
|
32709
32852
|
if (squidRoute) {
|
|
32710
32853
|
queryClient.refetchQueries({
|
|
32711
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.
|
|
32854
|
+
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,
|
|
32712
32855
|
// TODO: update types
|
|
32713
32856
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32714
32857
|
});
|
|
@@ -32727,17 +32870,30 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32727
32870
|
const useEstimate = (squidRoute) => {
|
|
32728
32871
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32729
32872
|
const { tokens } = useSquidTokens();
|
|
32730
|
-
const { fromChain, toChain } = useSwap();
|
|
32731
|
-
const
|
|
32873
|
+
const { fromChain, toChain, fromPrice } = useSwap();
|
|
32874
|
+
const fromToken = React.useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32875
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32876
|
+
fromChain,
|
|
32877
|
+
fromToken,
|
|
32878
|
+
});
|
|
32732
32879
|
const estimateResults = React.useMemo(() => calculateEstimateResults({
|
|
32733
32880
|
squidRoute,
|
|
32734
32881
|
tokens,
|
|
32735
32882
|
fromChain,
|
|
32736
32883
|
toChain,
|
|
32737
32884
|
collectFees: !!collectFees && collectFees.fee > 0,
|
|
32738
|
-
|
|
32739
|
-
|
|
32740
|
-
|
|
32885
|
+
chainFeeParams,
|
|
32886
|
+
gasToken,
|
|
32887
|
+
}), [
|
|
32888
|
+
squidRoute,
|
|
32889
|
+
tokens,
|
|
32890
|
+
fromChain,
|
|
32891
|
+
toChain,
|
|
32892
|
+
collectFees,
|
|
32893
|
+
chainFeeParams,
|
|
32894
|
+
gasToken,
|
|
32895
|
+
]);
|
|
32896
|
+
const fromBalanceFormatted = useMultiChainBalance({
|
|
32741
32897
|
chain: fromChain,
|
|
32742
32898
|
token: estimateResults.fromToken,
|
|
32743
32899
|
userAddress: squidRoute?.params.fromAddress ?? "",
|
|
@@ -32749,7 +32905,6 @@ const useEstimate = (squidRoute) => {
|
|
|
32749
32905
|
estimateResults.expectedGasRefundCost,
|
|
32750
32906
|
getUSDValue,
|
|
32751
32907
|
]);
|
|
32752
|
-
const proposedGasDestinationAmount = React.useMemo(() => getProposedGasDestinationAmount(estimateResults.destChainNativeToken?.symbol), [estimateResults.destChainNativeToken]);
|
|
32753
32908
|
const { feeCostsFormatted, totalFeeCostsUsd } = React.useMemo(() => {
|
|
32754
32909
|
const feeCosts = squidRoute?.estimate.feeCosts ?? [];
|
|
32755
32910
|
const feeCostsRenamed = [];
|
|
@@ -32808,21 +32963,21 @@ const useEstimate = (squidRoute) => {
|
|
|
32808
32963
|
totalFeeCostsUsd: totalFeeCostsUsdFormatted,
|
|
32809
32964
|
};
|
|
32810
32965
|
}, [squidRoute?.estimate.feeCosts]);
|
|
32811
|
-
const slippageFormatted =
|
|
32812
|
-
|
|
32813
|
-
|
|
32814
|
-
|
|
32815
|
-
|
|
32816
|
-
|
|
32966
|
+
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32967
|
+
const fromBalanceEnoughToSwap = React.useMemo(() => {
|
|
32968
|
+
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32969
|
+
const fromPriceNum = Number(fromPrice ?? 0);
|
|
32970
|
+
return fromBalanceNum >= fromPriceNum;
|
|
32971
|
+
}, [fromBalanceFormatted, fromPrice]);
|
|
32817
32972
|
return {
|
|
32818
32973
|
...estimateResults,
|
|
32819
|
-
|
|
32974
|
+
fromBalanceFormatted,
|
|
32820
32975
|
slippageFormatted,
|
|
32821
32976
|
totalWithRefundEstimate,
|
|
32822
|
-
|
|
32823
|
-
enoughBalanceToSwap,
|
|
32977
|
+
fromBalanceEnoughToSwap,
|
|
32824
32978
|
feeCostsFormatted,
|
|
32825
32979
|
totalFeeCostsUsd,
|
|
32980
|
+
gasToken,
|
|
32826
32981
|
};
|
|
32827
32982
|
};
|
|
32828
32983
|
|
|
@@ -36590,7 +36745,7 @@ const useGetRoute = () => {
|
|
|
36590
36745
|
});
|
|
36591
36746
|
// Cache the route data
|
|
36592
36747
|
// Useful when the getRoute mutation is called from another hook
|
|
36593
|
-
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage,
|
|
36748
|
+
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);
|
|
36594
36749
|
return route;
|
|
36595
36750
|
});
|
|
36596
36751
|
};
|
|
@@ -36613,14 +36768,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36613
36768
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36614
36769
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36615
36770
|
: sourceConnectedAddress;
|
|
36616
|
-
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage,
|
|
36771
|
+
const squidRouteQueryKeys = React.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), [
|
|
36617
36772
|
fromChain?.chainId,
|
|
36618
36773
|
toChain?.chainId,
|
|
36619
36774
|
toToken?.address,
|
|
36620
36775
|
fromToken?.address,
|
|
36621
36776
|
fromPrice,
|
|
36622
36777
|
config.slippage,
|
|
36623
|
-
config.enableGetGasOnDestination,
|
|
36624
36778
|
sourceUserAddress,
|
|
36625
36779
|
config.degenMode,
|
|
36626
36780
|
destinationAddress,
|
|
@@ -36892,35 +37046,6 @@ const useAvatar = (seed = zeroAddress) => {
|
|
|
36892
37046
|
return avatar || "";
|
|
36893
37047
|
};
|
|
36894
37048
|
|
|
36895
|
-
const useUserParams = () => {
|
|
36896
|
-
const enableGetGasOnDestination = useConfigStore((state) => state.config.enableGetGasOnDestination);
|
|
36897
|
-
const { fromToken, toToken, toChain, fromChain } = useSwap();
|
|
36898
|
-
// =============
|
|
36899
|
-
// GAS
|
|
36900
|
-
// =============
|
|
36901
|
-
const getGasOnDestSupportedForThisRoute = React.useMemo(() =>
|
|
36902
|
-
// Not supporting get gas on dest for same chains
|
|
36903
|
-
fromChain?.chainId !== toChain?.chainId &&
|
|
36904
|
-
// If the destination chain is cosmos, we don't support getting gas there
|
|
36905
|
-
toChain?.chainType !== squidTypes.ChainType.COSMOS &&
|
|
36906
|
-
// Not supporting get gas on dest for same tokens (bridge)
|
|
36907
|
-
((fromToken?.subGraphIds?.some((sgi) => !!toToken?.subGraphIds?.includes(sgi)) &&
|
|
36908
|
-
toToken?.subGraphIds?.some((sgi) => !!fromToken?.subGraphIds?.includes(sgi))) ||
|
|
36909
|
-
// Except for uusdc -> uusdc
|
|
36910
|
-
(fromToken?.subGraphIds?.includes("uusdc") &&
|
|
36911
|
-
toToken?.subGraphIds?.includes("uusdc"))), [
|
|
36912
|
-
fromChain?.chainId,
|
|
36913
|
-
fromToken?.subGraphIds,
|
|
36914
|
-
toChain?.chainId,
|
|
36915
|
-
toToken?.subGraphIds,
|
|
36916
|
-
toChain?.chainType,
|
|
36917
|
-
]);
|
|
36918
|
-
return {
|
|
36919
|
-
gasEnabled: enableGetGasOnDestination && getGasOnDestSupportedForThisRoute,
|
|
36920
|
-
getGasOnDestSupportedForThisRoute,
|
|
36921
|
-
};
|
|
36922
|
-
};
|
|
36923
|
-
|
|
36924
37049
|
const useAddToken = (chainToCompare, tokenToCompare) => {
|
|
36925
37050
|
const { chain: currentEvmChain } = wagmi.useAccount();
|
|
36926
37051
|
const { connector } = wagmi.useAccount();
|
|
@@ -37585,6 +37710,7 @@ exports.useSendTransactionStore = useSendTransactionStore;
|
|
|
37585
37710
|
exports.useSigner = useSigner;
|
|
37586
37711
|
exports.useSingleTokenPrice = useSingleTokenPrice;
|
|
37587
37712
|
exports.useSolanaNativeBalance = useSolanaNativeBalance;
|
|
37713
|
+
exports.useSourceChainGasToken = useSourceChainGasToken;
|
|
37588
37714
|
exports.useSquid = useSquid;
|
|
37589
37715
|
exports.useSquidChains = useSquidChains;
|
|
37590
37716
|
exports.useSquidQueryClient = useSquidQueryClient;
|
|
@@ -37602,7 +37728,6 @@ exports.useTokensData = useTokensData;
|
|
|
37602
37728
|
exports.useTrackSearchEmpty = useTrackSearchEmpty;
|
|
37603
37729
|
exports.useTransactionStore = useTransactionStore;
|
|
37604
37730
|
exports.useUrlSwapParams = useUrlSwapParams;
|
|
37605
|
-
exports.useUserParams = useUserParams;
|
|
37606
37731
|
exports.useWallet = useWallet;
|
|
37607
37732
|
exports.useWalletStore = useWalletStore;
|
|
37608
37733
|
exports.useWallets = useWallets;
|
|
@@ -37611,4 +37736,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37611
37736
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37612
37737
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37613
37738
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37614
|
-
//# sourceMappingURL=index-
|
|
37739
|
+
//# sourceMappingURL=index-BOMoTOCH.js.map
|