@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
|
@@ -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,
|
|
@@ -31178,6 +31181,155 @@ const useSingleTokenPrice = (tokenData) => {
|
|
|
31178
31181
|
return { tokenPrice, getUSDValue };
|
|
31179
31182
|
};
|
|
31180
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
|
+
|
|
31181
31333
|
const MAX_COINGECKO_QUERY_TOKENS = 100;
|
|
31182
31334
|
const fetchHistoricalData = async (coingeckoId, timeFrame) => {
|
|
31183
31335
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -31328,24 +31480,23 @@ const calculateTotalNativeFees = ({ expressFeeCost, firstFeeCost, firstGasCost,
|
|
|
31328
31480
|
(sameTokenBetweenFees
|
|
31329
31481
|
? BigInt(firstFeeCost?.amount ?? "0") + BigInt(firstGasCost?.amount ?? "0")
|
|
31330
31482
|
: BigInt(firstGasCost?.amount ?? "0"));
|
|
31331
|
-
const
|
|
31332
|
-
|
|
31333
|
-
|
|
31334
|
-
|
|
31335
|
-
|
|
31336
|
-
|
|
31337
|
-
|
|
31338
|
-
|
|
31339
|
-
|
|
31340
|
-
}
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31346
|
-
|
|
31347
|
-
|
|
31348
|
-
: 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
|
+
};
|
|
31349
31500
|
/**
|
|
31350
31501
|
* Calculates the estimated duration of a route
|
|
31351
31502
|
*
|
|
@@ -31384,12 +31535,10 @@ const formatEstimatedRouteDuration = ({ estimatedRouteDuration, isSingleChainRou
|
|
|
31384
31535
|
* @returns {Object} An object containing various estimate results and calculations, including token information,
|
|
31385
31536
|
* amounts, fees, gas costs, and other relevant data for the transaction.
|
|
31386
31537
|
*/
|
|
31387
|
-
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees,
|
|
31538
|
+
const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, collectFees, chainFeeParams, gasToken, }) => {
|
|
31388
31539
|
const fromToken = findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken);
|
|
31389
31540
|
const fromAmount = squidRoute?.estimate?.fromAmount;
|
|
31390
31541
|
const fromAmountFormatted = formatAmount(fromAmount, fromToken?.decimals);
|
|
31391
|
-
const sourceChainNativeToken = findNativeToken(tokens, fromChain);
|
|
31392
|
-
const destChainNativeToken = findNativeToken(tokens, toChain);
|
|
31393
31542
|
const toAmountUSD = squidRoute?.estimate?.toAmountUSD;
|
|
31394
31543
|
const exchangeRate = squidRoute?.estimate.exchangeRate ?? "0";
|
|
31395
31544
|
const toAmountMinUSD = squidRoute?.estimate.toAmountMinUSD ?? "0";
|
|
@@ -31408,10 +31557,6 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31408
31557
|
const expectedGasRefundCostUSD = convertTokenAmountToUSD(formatBNToReadable(expectedGasRefundCost, firstFeeCost?.token.decimals ?? 18), firstFeeCost?.token.usdPrice ?? "0");
|
|
31409
31558
|
const sameTokenBetweenFees = firstFeeCost?.token.address === firstGasCost?.token.address &&
|
|
31410
31559
|
firstFeeCost?.token.chainId === firstGasCost?.token.chainId;
|
|
31411
|
-
const isFromTokenNative =
|
|
31412
|
-
// TODO: temporary fix, currently nativeCurrency.symbol is not always in uppercase
|
|
31413
|
-
fromToken?.symbol.toUpperCase() ===
|
|
31414
|
-
fromChain?.nativeCurrency.symbol.toUpperCase();
|
|
31415
31560
|
const totalNativeFees = calculateTotalNativeFees({
|
|
31416
31561
|
expressFeeCost,
|
|
31417
31562
|
firstFeeCost,
|
|
@@ -31419,30 +31564,32 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31419
31564
|
sameTokenBetweenFees,
|
|
31420
31565
|
});
|
|
31421
31566
|
const totalFeesInNativeTokenPlusRatio = (totalNativeFees * BigInt(110)) / BigInt(100);
|
|
31422
|
-
const
|
|
31423
|
-
|
|
31567
|
+
const networkFeesWei = chainFeeParams?.normalizeFee(totalFeesInNativeTokenPlusRatio) ?? BigInt(0);
|
|
31568
|
+
const isGasBalanceEnough = checkIsGasBalanceEnough({
|
|
31569
|
+
chainFeeParams,
|
|
31424
31570
|
fromAmount,
|
|
31425
|
-
|
|
31426
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31427
|
-
nativeTokenBalanceFromChainWei,
|
|
31571
|
+
networkFeesWei,
|
|
31428
31572
|
});
|
|
31429
31573
|
const minAmountValueWarnMsg = calculateMinAmountValueWarnMsg({
|
|
31430
|
-
|
|
31431
|
-
|
|
31432
|
-
|
|
31433
|
-
totalFeesInNativeTokenPlusRatio,
|
|
31574
|
+
chainFeeParams,
|
|
31575
|
+
networkFeesWei,
|
|
31576
|
+
fromTokenDecimals: fromToken?.decimals,
|
|
31434
31577
|
});
|
|
31435
31578
|
const isSingleChainRoute = fromChain?.chainId === toChain?.chainId;
|
|
31436
31579
|
const estimatedRouteDuration = formatEstimatedRouteDuration({
|
|
31437
31580
|
estimatedRouteDuration: squidRoute?.estimate?.estimatedRouteDuration,
|
|
31438
31581
|
isSingleChainRoute,
|
|
31439
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;
|
|
31440
31589
|
return {
|
|
31441
31590
|
fromToken,
|
|
31442
31591
|
fromAmount,
|
|
31443
31592
|
fromAmountFormatted,
|
|
31444
|
-
sourceChainNativeToken,
|
|
31445
|
-
destChainNativeToken,
|
|
31446
31593
|
toAmountUSD,
|
|
31447
31594
|
exchangeRate,
|
|
31448
31595
|
toAmountMinUSD,
|
|
@@ -31457,12 +31604,12 @@ const calculateEstimateResults = ({ squidRoute, tokens, fromChain, toChain, coll
|
|
|
31457
31604
|
expectedGasRefundCost,
|
|
31458
31605
|
expectedGasRefundCostUSD,
|
|
31459
31606
|
sameTokenBetweenFees,
|
|
31460
|
-
|
|
31607
|
+
fromTokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31461
31608
|
totalNativeFees,
|
|
31462
|
-
|
|
31463
|
-
fromBalanceEnoughToSwap,
|
|
31609
|
+
isGasBalanceEnough,
|
|
31464
31610
|
minAmountValueWarnMsg,
|
|
31465
31611
|
estimatedRouteDuration,
|
|
31612
|
+
gasBalanceNeeded,
|
|
31466
31613
|
};
|
|
31467
31614
|
};
|
|
31468
31615
|
/**
|
|
@@ -31496,28 +31643,6 @@ const calculateTotalWithRefundEstimate = (allFeeCosts, expectedGasRefundCost, ge
|
|
|
31496
31643
|
feeToken: firstFeeCost?.token,
|
|
31497
31644
|
};
|
|
31498
31645
|
};
|
|
31499
|
-
/**
|
|
31500
|
-
* Calculates the proposed gas amount for the destination chain.
|
|
31501
|
-
*
|
|
31502
|
-
* @param destChainNativeToken - The symbol of the native token for the destination chain.
|
|
31503
|
-
* @returns An object containing the proposed gas amount value and the currency symbol.
|
|
31504
|
-
*/
|
|
31505
|
-
const getProposedGasDestinationAmount = (destChainNativeToken) => {
|
|
31506
|
-
const gasAmounts = {
|
|
31507
|
-
GLMR: 5.289,
|
|
31508
|
-
ETH: 0.0009,
|
|
31509
|
-
AVAX: 0.115,
|
|
31510
|
-
BNB: 0.00425,
|
|
31511
|
-
FTM: 4.45,
|
|
31512
|
-
CELO: 3.052,
|
|
31513
|
-
KAVA: 2.339,
|
|
31514
|
-
MATIC: 1.795,
|
|
31515
|
-
};
|
|
31516
|
-
return {
|
|
31517
|
-
value: gasAmounts[destChainNativeToken ?? ""] ?? 0,
|
|
31518
|
-
currency: destChainNativeToken,
|
|
31519
|
-
};
|
|
31520
|
-
};
|
|
31521
31646
|
|
|
31522
31647
|
function useSendTransactionGas({ chain, token, from, }) {
|
|
31523
31648
|
return reactQuery.useQuery({
|
|
@@ -31539,7 +31664,11 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31539
31664
|
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
31540
31665
|
// so we'll try to use the user provided address when possible
|
|
31541
31666
|
const sender = from || dummyAddress;
|
|
31542
|
-
|
|
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) {
|
|
31543
31672
|
const gas = await client.estimateGas({
|
|
31544
31673
|
from: sender,
|
|
31545
31674
|
to: dummyAddress,
|
|
@@ -31559,7 +31688,13 @@ function useSendTransactionGas({ chain, token, from, }) {
|
|
|
31559
31688
|
data,
|
|
31560
31689
|
chainId: chain.chainId,
|
|
31561
31690
|
});
|
|
31562
|
-
|
|
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;
|
|
31563
31698
|
}
|
|
31564
31699
|
case squidTypes.ChainType.COSMOS: {
|
|
31565
31700
|
// TODO: get gas estimation from backend
|
|
@@ -31606,19 +31741,33 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31606
31741
|
token,
|
|
31607
31742
|
from,
|
|
31608
31743
|
});
|
|
31609
|
-
const {
|
|
31610
|
-
|
|
31611
|
-
|
|
31744
|
+
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
31745
|
+
fromChain: chain,
|
|
31746
|
+
fromToken: token,
|
|
31747
|
+
});
|
|
31748
|
+
const isGasBalanceEnough = React.useMemo(() => {
|
|
31749
|
+
if (!amount || !token?.decimals)
|
|
31612
31750
|
return false;
|
|
31613
|
-
|
|
31614
|
-
|
|
31615
|
-
|
|
31616
|
-
|
|
31617
|
-
|
|
31618
|
-
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
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
|
+
]);
|
|
31622
31771
|
const isBalanceEnough = React.useMemo(() => {
|
|
31623
31772
|
if (token?.decimals == null || !balance || !amount)
|
|
31624
31773
|
return false;
|
|
@@ -31626,28 +31775,21 @@ function useEstimateSendTransaction({ chain, token, amount, balance, from, }) {
|
|
|
31626
31775
|
parseToBigInt(amount, token.decimals));
|
|
31627
31776
|
}, [amount, balance, token?.decimals]);
|
|
31628
31777
|
const minAmountValueWarnMsg = React.useMemo(() => {
|
|
31629
|
-
if (!token?.address || !
|
|
31778
|
+
if (!token?.address || !estimatedGas || !chainFeeParams)
|
|
31630
31779
|
return undefined;
|
|
31631
|
-
const isFromTokenNative = token.address.toLowerCase() ===
|
|
31632
|
-
chainTypeToNativeTokenAddressMap[token.type].toLowerCase();
|
|
31633
31780
|
return calculateMinAmountValueWarnMsg({
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
|
|
31637
|
-
totalFeesInNativeTokenPlusRatio: estimatedGas,
|
|
31781
|
+
chainFeeParams,
|
|
31782
|
+
networkFeesWei: estimatedGas,
|
|
31783
|
+
fromTokenDecimals: token.decimals,
|
|
31638
31784
|
});
|
|
31639
|
-
}, [
|
|
31640
|
-
estimatedGas,
|
|
31641
|
-
nativeBalance?.decimals,
|
|
31642
|
-
nativeBalance?.value,
|
|
31643
|
-
token?.address,
|
|
31644
|
-
token?.type,
|
|
31645
|
-
]);
|
|
31785
|
+
}, [estimatedGas, token, chainFeeParams]);
|
|
31646
31786
|
return {
|
|
31647
31787
|
estimatedGas,
|
|
31788
|
+
gasBalanceNeeded,
|
|
31648
31789
|
isBalanceEnough,
|
|
31790
|
+
tokenPaysGasFees: chainFeeParams?.fromTokenPaysGasFees ?? false,
|
|
31649
31791
|
isLoading,
|
|
31650
|
-
|
|
31792
|
+
isGasBalanceEnough,
|
|
31651
31793
|
minAmountValueWarnMsg,
|
|
31652
31794
|
};
|
|
31653
31795
|
}
|
|
@@ -32709,7 +32851,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32709
32851
|
// This is to ensure we're using the latest expiry timestamp
|
|
32710
32852
|
if (squidRoute) {
|
|
32711
32853
|
queryClient.refetchQueries({
|
|
32712
|
-
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,
|
|
32713
32855
|
// TODO: update types
|
|
32714
32856
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32715
32857
|
});
|
|
@@ -32728,17 +32870,30 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32728
32870
|
const useEstimate = (squidRoute) => {
|
|
32729
32871
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32730
32872
|
const { tokens } = useSquidTokens();
|
|
32731
|
-
const { fromChain, toChain } = useSwap();
|
|
32732
|
-
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
|
+
});
|
|
32733
32879
|
const estimateResults = React.useMemo(() => calculateEstimateResults({
|
|
32734
32880
|
squidRoute,
|
|
32735
32881
|
tokens,
|
|
32736
32882
|
fromChain,
|
|
32737
32883
|
toChain,
|
|
32738
32884
|
collectFees: !!collectFees && collectFees.fee > 0,
|
|
32739
|
-
|
|
32740
|
-
|
|
32741
|
-
|
|
32885
|
+
chainFeeParams,
|
|
32886
|
+
gasToken,
|
|
32887
|
+
}), [
|
|
32888
|
+
squidRoute,
|
|
32889
|
+
tokens,
|
|
32890
|
+
fromChain,
|
|
32891
|
+
toChain,
|
|
32892
|
+
collectFees,
|
|
32893
|
+
chainFeeParams,
|
|
32894
|
+
gasToken,
|
|
32895
|
+
]);
|
|
32896
|
+
const fromBalanceFormatted = useMultiChainBalance({
|
|
32742
32897
|
chain: fromChain,
|
|
32743
32898
|
token: estimateResults.fromToken,
|
|
32744
32899
|
userAddress: squidRoute?.params.fromAddress ?? "",
|
|
@@ -32750,7 +32905,6 @@ const useEstimate = (squidRoute) => {
|
|
|
32750
32905
|
estimateResults.expectedGasRefundCost,
|
|
32751
32906
|
getUSDValue,
|
|
32752
32907
|
]);
|
|
32753
|
-
const proposedGasDestinationAmount = React.useMemo(() => getProposedGasDestinationAmount(estimateResults.destChainNativeToken?.symbol), [estimateResults.destChainNativeToken]);
|
|
32754
32908
|
const { feeCostsFormatted, totalFeeCostsUsd } = React.useMemo(() => {
|
|
32755
32909
|
const feeCosts = squidRoute?.estimate.feeCosts ?? [];
|
|
32756
32910
|
const feeCostsRenamed = [];
|
|
@@ -32809,21 +32963,21 @@ const useEstimate = (squidRoute) => {
|
|
|
32809
32963
|
totalFeeCostsUsd: totalFeeCostsUsdFormatted,
|
|
32810
32964
|
};
|
|
32811
32965
|
}, [squidRoute?.estimate.feeCosts]);
|
|
32812
|
-
const slippageFormatted =
|
|
32813
|
-
|
|
32814
|
-
|
|
32815
|
-
|
|
32816
|
-
|
|
32817
|
-
|
|
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]);
|
|
32818
32972
|
return {
|
|
32819
32973
|
...estimateResults,
|
|
32820
|
-
|
|
32974
|
+
fromBalanceFormatted,
|
|
32821
32975
|
slippageFormatted,
|
|
32822
32976
|
totalWithRefundEstimate,
|
|
32823
|
-
|
|
32824
|
-
enoughBalanceToSwap,
|
|
32977
|
+
fromBalanceEnoughToSwap,
|
|
32825
32978
|
feeCostsFormatted,
|
|
32826
32979
|
totalFeeCostsUsd,
|
|
32980
|
+
gasToken,
|
|
32827
32981
|
};
|
|
32828
32982
|
};
|
|
32829
32983
|
|
|
@@ -36591,7 +36745,7 @@ const useGetRoute = () => {
|
|
|
36591
36745
|
});
|
|
36592
36746
|
// Cache the route data
|
|
36593
36747
|
// Useful when the getRoute mutation is called from another hook
|
|
36594
|
-
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);
|
|
36595
36749
|
return route;
|
|
36596
36750
|
});
|
|
36597
36751
|
};
|
|
@@ -36614,14 +36768,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36614
36768
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36615
36769
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36616
36770
|
: sourceConnectedAddress;
|
|
36617
|
-
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), [
|
|
36618
36772
|
fromChain?.chainId,
|
|
36619
36773
|
toChain?.chainId,
|
|
36620
36774
|
toToken?.address,
|
|
36621
36775
|
fromToken?.address,
|
|
36622
36776
|
fromPrice,
|
|
36623
36777
|
config.slippage,
|
|
36624
|
-
config.enableGetGasOnDestination,
|
|
36625
36778
|
sourceUserAddress,
|
|
36626
36779
|
config.degenMode,
|
|
36627
36780
|
destinationAddress,
|
|
@@ -36893,35 +37046,6 @@ const useAvatar = (seed = zeroAddress) => {
|
|
|
36893
37046
|
return avatar || "";
|
|
36894
37047
|
};
|
|
36895
37048
|
|
|
36896
|
-
const useUserParams = () => {
|
|
36897
|
-
const enableGetGasOnDestination = useConfigStore((state) => state.config.enableGetGasOnDestination);
|
|
36898
|
-
const { fromToken, toToken, toChain, fromChain } = useSwap();
|
|
36899
|
-
// =============
|
|
36900
|
-
// GAS
|
|
36901
|
-
// =============
|
|
36902
|
-
const getGasOnDestSupportedForThisRoute = React.useMemo(() =>
|
|
36903
|
-
// Not supporting get gas on dest for same chains
|
|
36904
|
-
fromChain?.chainId !== toChain?.chainId &&
|
|
36905
|
-
// If the destination chain is cosmos, we don't support getting gas there
|
|
36906
|
-
toChain?.chainType !== squidTypes.ChainType.COSMOS &&
|
|
36907
|
-
// Not supporting get gas on dest for same tokens (bridge)
|
|
36908
|
-
((fromToken?.subGraphIds?.some((sgi) => !!toToken?.subGraphIds?.includes(sgi)) &&
|
|
36909
|
-
toToken?.subGraphIds?.some((sgi) => !!fromToken?.subGraphIds?.includes(sgi))) ||
|
|
36910
|
-
// Except for uusdc -> uusdc
|
|
36911
|
-
(fromToken?.subGraphIds?.includes("uusdc") &&
|
|
36912
|
-
toToken?.subGraphIds?.includes("uusdc"))), [
|
|
36913
|
-
fromChain?.chainId,
|
|
36914
|
-
fromToken?.subGraphIds,
|
|
36915
|
-
toChain?.chainId,
|
|
36916
|
-
toToken?.subGraphIds,
|
|
36917
|
-
toChain?.chainType,
|
|
36918
|
-
]);
|
|
36919
|
-
return {
|
|
36920
|
-
gasEnabled: enableGetGasOnDestination && getGasOnDestSupportedForThisRoute,
|
|
36921
|
-
getGasOnDestSupportedForThisRoute,
|
|
36922
|
-
};
|
|
36923
|
-
};
|
|
36924
|
-
|
|
36925
37049
|
const useAddToken = (chainToCompare, tokenToCompare) => {
|
|
36926
37050
|
const { chain: currentEvmChain } = wagmi.useAccount();
|
|
36927
37051
|
const { connector } = wagmi.useAccount();
|
|
@@ -37586,6 +37710,7 @@ exports.useSendTransactionStore = useSendTransactionStore;
|
|
|
37586
37710
|
exports.useSigner = useSigner;
|
|
37587
37711
|
exports.useSingleTokenPrice = useSingleTokenPrice;
|
|
37588
37712
|
exports.useSolanaNativeBalance = useSolanaNativeBalance;
|
|
37713
|
+
exports.useSourceChainGasToken = useSourceChainGasToken;
|
|
37589
37714
|
exports.useSquid = useSquid;
|
|
37590
37715
|
exports.useSquidChains = useSquidChains;
|
|
37591
37716
|
exports.useSquidQueryClient = useSquidQueryClient;
|
|
@@ -37603,7 +37728,6 @@ exports.useTokensData = useTokensData;
|
|
|
37603
37728
|
exports.useTrackSearchEmpty = useTrackSearchEmpty;
|
|
37604
37729
|
exports.useTransactionStore = useTransactionStore;
|
|
37605
37730
|
exports.useUrlSwapParams = useUrlSwapParams;
|
|
37606
|
-
exports.useUserParams = useUserParams;
|
|
37607
37731
|
exports.useWallet = useWallet;
|
|
37608
37732
|
exports.useWalletStore = useWalletStore;
|
|
37609
37733
|
exports.useWallets = useWallets;
|
|
@@ -37612,4 +37736,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37612
37736
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37613
37737
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37614
37738
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37615
|
-
//# sourceMappingURL=index-
|
|
37739
|
+
//# sourceMappingURL=index-BOMoTOCH.js.map
|