@0xsquid/react-hooks 8.7.2-beta-interactive-to-amount.1 → 8.7.2
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/queries/queries-keys.d.ts +1 -1
- package/dist/core/types/config.d.ts +1 -2
- package/dist/core/types/event.d.ts +2 -1
- package/dist/core/types/route.d.ts +4 -0
- package/dist/hooks/store/useSquidStore.d.ts +1 -2
- package/dist/hooks/swap/useSwap.d.ts +2 -4
- package/dist/hooks/transaction/useGetRoute.d.ts +8 -9
- package/dist/{index-B9EnYPpR.js → index-D3bbd13Z.js} +36 -69
- package/dist/index-D3bbd13Z.js.map +1 -0
- package/dist/{index-BL3rpZzC.js → index-DaYYG81O.js} +37 -69
- package/dist/index-DaYYG81O.js.map +1 -0
- package/dist/{index.es-Da6lPGPH.js → index.es-Bn83pLT9.js} +2 -2
- package/dist/{index.es-Da6lPGPH.js.map → index.es-Bn83pLT9.js.map} +1 -1
- package/dist/{index.es-C93MXP-M.js → index.es-Ds1lt_e4.js} +2 -2
- package/dist/{index.es-C93MXP-M.js.map → index.es-Ds1lt_e4.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/{secretService-Bp_azQsY.js → secretService-CKReaNYo.js} +2 -2
- package/dist/{secretService-Bp_azQsY.js.map → secretService-CKReaNYo.js.map} +1 -1
- package/dist/{secretService-CO9haOur.js → secretService-CM6noWhX.js} +2 -2
- package/dist/{secretService-CO9haOur.js.map → secretService-CM6noWhX.js.map} +1 -1
- package/dist/services/internal/eventService.d.ts +2 -1
- package/dist/services/internal/numberService.d.ts +0 -1
- package/dist/{stellarService.client-CrlGBSG9.js → stellarService.client-0dfuo3PJ.js} +3 -3
- package/dist/{stellarService.client-CrlGBSG9.js.map → stellarService.client-0dfuo3PJ.js.map} +1 -1
- package/dist/{stellarService.client-B-EC09rP.js → stellarService.client-Ko2roGXL.js} +3 -3
- package/dist/{stellarService.client-B-EC09rP.js.map → stellarService.client-Ko2roGXL.js.map} +1 -1
- package/package.json +3 -3
- package/dist/index-B9EnYPpR.js.map +0 -1
- package/dist/index-BL3rpZzC.js.map +0 -1
|
@@ -56,7 +56,7 @@ export declare const keys: () => {
|
|
|
56
56
|
tokenData: (token?: TokenWithBalance) => (string | undefined)[];
|
|
57
57
|
balance: (chainId?: number | string, tokenAddress?: string, userAddress?: string) => (string | number | undefined)[];
|
|
58
58
|
allTokensBalance: (address: string | undefined, chainType: ChainType | undefined, direction?: SwapDirection) => (string | undefined)[];
|
|
59
|
-
transaction: (fromChainId: string | undefined, toChainId: string | undefined, toTokenAddress: string | undefined, fromTokenAddress: string | undefined,
|
|
59
|
+
transaction: (fromChainId: string | undefined, toChainId: string | undefined, toTokenAddress: string | undefined, fromTokenAddress: string | undefined, price: string | undefined, slippage: SlippageOption | undefined, sourceUserAddress: string | undefined, degenMode: boolean | undefined, destinationAddress: string | undefined, fallbackAddress: string | undefined, quoteOnly: boolean | undefined, fromChainType: ChainType | undefined, preHook: AppConfig["preHook"] | undefined, postHook: AppConfig["postHook"] | undefined, overrideGasRefundAddress: AppConfig["overrideGasRefundAddress"] | undefined) => (string | number | boolean | Omit<import("@0xsquid/squid-types").Hook, "fundAmount" | "fundToken"> | undefined)[];
|
|
60
60
|
swapTransactionStatus: (transactionId: string | undefined) => (string | undefined)[];
|
|
61
61
|
fiatToCryptoStatus: (transactionId?: string) => (string | undefined)[];
|
|
62
62
|
sendTransactionStatus: (txHash: string | undefined, chainId: string | undefined) => (string | undefined)[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RouteRequest } from "
|
|
1
|
+
import { RouteRequest } from "./route";
|
|
2
2
|
export type SlippageOption = RouteRequest["slippage"];
|
|
3
3
|
export type TokenConfig = {
|
|
4
4
|
address: string;
|
|
@@ -72,5 +72,4 @@ export interface AppConfig {
|
|
|
72
72
|
* Override the default gas refund address in Axelar routes
|
|
73
73
|
*/
|
|
74
74
|
overrideGasRefundAddress?: RouteRequest["overrideGasRefundAddress"];
|
|
75
|
-
prefer?: string[];
|
|
76
75
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouteResponse } from "@0xsquid/squid-types";
|
|
2
2
|
import { TransactionErrorWithMessage } from "./error";
|
|
3
3
|
import { ExecuteQuoteServer } from "./onramps";
|
|
4
|
+
import { RouteRequest } from "./route";
|
|
4
5
|
type BaseSwapEventParams = Pick<RouteRequest, "fromAddress" | "toAddress" | "fromChain" | "toChain" | "fromToken" | "toToken" | "fromAmount">;
|
|
5
6
|
type BaseSendTransactionEventParams = {
|
|
6
7
|
fromAddress: string;
|
|
@@ -21,8 +21,7 @@ export interface ConfigState {
|
|
|
21
21
|
}
|
|
22
22
|
export declare const useConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigState>>;
|
|
23
23
|
interface TransactionState {
|
|
24
|
-
|
|
25
|
-
toAmount?: string;
|
|
24
|
+
fromPrice?: string;
|
|
26
25
|
txLocalId?: string;
|
|
27
26
|
transactions: Record<string, TransactionParams>;
|
|
28
27
|
currentTransaction?: TransactionParams;
|
|
@@ -7,10 +7,8 @@ export declare const useSwap: () => {
|
|
|
7
7
|
};
|
|
8
8
|
onSwapChange: (inputSwapParams: SwapParams) => SwapParams;
|
|
9
9
|
invertSwaps: (() => SwapParams) | undefined;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fromAmountChanged: (amount: string) => void;
|
|
13
|
-
toAmountChanged: (amount: string) => void;
|
|
10
|
+
fromPrice: string | undefined;
|
|
11
|
+
fromPriceChanged: (price: string) => void;
|
|
14
12
|
toToken: import("../../core").Token | undefined;
|
|
15
13
|
fromToken: import("../../core").Token | undefined;
|
|
16
14
|
fromChain: import("@0xsquid/squid-types").ChainData | undefined;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RouteResponse } from "@0xsquid/sdk/dist/types";
|
|
2
|
-
import { ChainType,
|
|
2
|
+
import { ChainType, Token } from "@0xsquid/squid-types";
|
|
3
3
|
import { QueryObserverOptions } from "@tanstack/react-query";
|
|
4
4
|
import type { AppConfig } from "../../core/types/config";
|
|
5
|
+
import { RouteRequest } from "../../core/types/route";
|
|
5
6
|
export declare const useGetRoute: () => import("@tanstack/react-query").UseMutationResult<{
|
|
6
7
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
7
8
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
8
|
-
params: RouteRequest;
|
|
9
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
9
10
|
quoteId: string;
|
|
10
11
|
} | undefined, unknown, {
|
|
11
12
|
fromChain: RouteRequest["fromChain"] | undefined;
|
|
@@ -15,29 +16,27 @@ export declare const useGetRoute: () => import("@tanstack/react-query").UseMutat
|
|
|
15
16
|
sourceUserAddress: string | undefined;
|
|
16
17
|
destinationAddress: string | undefined;
|
|
17
18
|
fromPrice: string | undefined;
|
|
18
|
-
toPrice: string | undefined;
|
|
19
19
|
bypassGuardrails: RouteRequest["bypassGuardrails"] | undefined;
|
|
20
20
|
quoteOnly: boolean | undefined;
|
|
21
21
|
fromChainType: ChainType | undefined;
|
|
22
22
|
preHook: AppConfig["preHook"];
|
|
23
23
|
postHook: AppConfig["postHook"];
|
|
24
24
|
overrideGasRefundAddress: AppConfig["overrideGasRefundAddress"];
|
|
25
|
-
prefer: AppConfig["prefer"];
|
|
26
25
|
}, unknown>;
|
|
27
26
|
export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refetchOnWindowFocus, refetchIntervalInBackground, refetchInterval, quoteOnly, }: Pick<QueryObserverOptions<{
|
|
28
27
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
29
28
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
30
|
-
params: RouteRequest;
|
|
29
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
31
30
|
quoteId: string;
|
|
32
31
|
} | undefined, unknown, {
|
|
33
32
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
34
33
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
35
|
-
params: RouteRequest;
|
|
34
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
36
35
|
quoteId: string;
|
|
37
36
|
} | undefined, {
|
|
38
37
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
39
38
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
40
|
-
params: RouteRequest;
|
|
39
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
41
40
|
quoteId: string;
|
|
42
41
|
} | undefined, import("@tanstack/react-query").QueryKey>, "cacheTime" | "enabled" | "staleTime" | "refetchInterval" | "refetchIntervalInBackground" | "refetchOnWindowFocus"> & {
|
|
43
42
|
quoteOnly?: boolean | undefined;
|
|
@@ -45,7 +44,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
45
44
|
squidRoute: import("@tanstack/react-query").UseQueryResult<{
|
|
46
45
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
47
46
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
48
|
-
params: RouteRequest;
|
|
47
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
49
48
|
quoteId: string;
|
|
50
49
|
} | undefined, unknown>;
|
|
51
50
|
showLoading: boolean;
|
|
@@ -53,7 +52,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
53
52
|
routeData: {
|
|
54
53
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
55
54
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
56
|
-
params: RouteRequest;
|
|
55
|
+
params: import("@0xsquid/squid-types").RouteRequest;
|
|
57
56
|
quoteId: string;
|
|
58
57
|
} | undefined;
|
|
59
58
|
};
|
|
@@ -3971,9 +3971,6 @@ const getNumericValue = ({ value, precision, useComaEvery3Digits = true, hideIfZ
|
|
|
3971
3971
|
const finalValue = `${isNegative ? "-" : ""}${prefix}${formattedIfVerySmall}${suffix ? ` ${suffix}` : ""}`;
|
|
3972
3972
|
return wrapInParens ? `(${finalValue})` : finalValue;
|
|
3973
3973
|
};
|
|
3974
|
-
function isZeroAmount(amount) {
|
|
3975
|
-
return !amount || amount === "0";
|
|
3976
|
-
}
|
|
3977
3974
|
|
|
3978
3975
|
/**
|
|
3979
3976
|
* Creates a hash string from quote request parameters to track changes
|
|
@@ -22416,15 +22413,14 @@ const keys = () => ({
|
|
|
22416
22413
|
// ============
|
|
22417
22414
|
// Transactions
|
|
22418
22415
|
// ============
|
|
22419
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress,
|
|
22416
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, price, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
|
|
22420
22417
|
...keys().transactions(),
|
|
22421
22418
|
exports.QueryKeys.Transaction,
|
|
22422
22419
|
fromChainId,
|
|
22423
22420
|
toChainId,
|
|
22424
22421
|
toTokenAddress,
|
|
22425
22422
|
fromTokenAddress,
|
|
22426
|
-
|
|
22427
|
-
toAmount,
|
|
22423
|
+
price,
|
|
22428
22424
|
slippage,
|
|
22429
22425
|
sourceUserAddress,
|
|
22430
22426
|
degenMode,
|
|
@@ -22435,7 +22431,6 @@ const keys = () => ({
|
|
|
22435
22431
|
preHook,
|
|
22436
22432
|
postHook,
|
|
22437
22433
|
overrideGasRefundAddress,
|
|
22438
|
-
prefer,
|
|
22439
22434
|
],
|
|
22440
22435
|
swapTransactionStatus: (transactionId) => [
|
|
22441
22436
|
...keys().transactions(),
|
|
@@ -22627,7 +22622,6 @@ const getConfigWithDefaults = (config) => {
|
|
|
22627
22622
|
preHook: get$2(config, "preHook", defaultConfigValues.preHook),
|
|
22628
22623
|
postHook: get$2(config, "postHook", defaultConfigValues.postHook),
|
|
22629
22624
|
overrideGasRefundAddress: get$2(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
|
|
22630
|
-
prefer: get$2(config, "prefer", defaultConfigValues.prefer),
|
|
22631
22625
|
};
|
|
22632
22626
|
};
|
|
22633
22627
|
const randomIntFromInterval = (min, max) => {
|
|
@@ -23321,7 +23315,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23321
23315
|
};
|
|
23322
23316
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23323
23317
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23324
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23318
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-CKReaNYo.js'); });
|
|
23325
23319
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23326
23320
|
};
|
|
23327
23321
|
function getTokenAssetsKey(token) {
|
|
@@ -25178,7 +25172,10 @@ const useConfigStore = zustand.create(() => ({
|
|
|
25178
25172
|
isInitialized: false,
|
|
25179
25173
|
}));
|
|
25180
25174
|
const useTransactionStore = zustand.create((set, get) => ({
|
|
25175
|
+
fromPrice: undefined,
|
|
25176
|
+
txLocalId: undefined,
|
|
25181
25177
|
transactions: {},
|
|
25178
|
+
currentTransaction: undefined,
|
|
25182
25179
|
setTransactionState(txId, tx) {
|
|
25183
25180
|
if (!txId)
|
|
25184
25181
|
return;
|
|
@@ -26715,8 +26712,8 @@ function useStellarWallets() {
|
|
|
26715
26712
|
return;
|
|
26716
26713
|
try {
|
|
26717
26714
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26718
|
-
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26719
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26715
|
+
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26716
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-0dfuo3PJ.js'); });
|
|
26720
26717
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26721
26718
|
const promises = modules.map(async (module) => {
|
|
26722
26719
|
const isAvailable = await module.isAvailable();
|
|
@@ -27615,8 +27612,7 @@ const useMultiChainWallet = (chain) => {
|
|
|
27615
27612
|
|
|
27616
27613
|
const useSwap = () => {
|
|
27617
27614
|
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
|
|
27618
|
-
const
|
|
27619
|
-
const toAmount = useTransactionStore((state) => state.toAmount);
|
|
27615
|
+
const fromPrice = useTransactionStore((state) => state.fromPrice);
|
|
27620
27616
|
const { swapRoute } = useSwapRoutePersistStore();
|
|
27621
27617
|
const { tokens } = useSquidTokens();
|
|
27622
27618
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -27668,17 +27664,8 @@ const useSwap = () => {
|
|
|
27668
27664
|
}),
|
|
27669
27665
|
};
|
|
27670
27666
|
}, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
|
|
27671
|
-
const
|
|
27672
|
-
useTransactionStore.setState({
|
|
27673
|
-
fromAmount: amount || undefined,
|
|
27674
|
-
toAmount: undefined,
|
|
27675
|
-
});
|
|
27676
|
-
}, []);
|
|
27677
|
-
const toAmountChanged = React.useCallback((amount) => {
|
|
27678
|
-
useTransactionStore.setState({
|
|
27679
|
-
toAmount: amount || undefined,
|
|
27680
|
-
fromAmount: undefined,
|
|
27681
|
-
});
|
|
27667
|
+
const fromPriceChanged = React.useCallback((price) => {
|
|
27668
|
+
useTransactionStore.setState({ fromPrice: price || undefined });
|
|
27682
27669
|
}, []);
|
|
27683
27670
|
/**
|
|
27684
27671
|
* When user changes something from the SwapView
|
|
@@ -27838,10 +27825,8 @@ const useSwap = () => {
|
|
|
27838
27825
|
tokenItems,
|
|
27839
27826
|
onSwapChange,
|
|
27840
27827
|
invertSwaps,
|
|
27841
|
-
|
|
27842
|
-
|
|
27843
|
-
fromAmountChanged,
|
|
27844
|
-
toAmountChanged,
|
|
27828
|
+
fromPrice,
|
|
27829
|
+
fromPriceChanged,
|
|
27845
27830
|
toToken,
|
|
27846
27831
|
fromToken,
|
|
27847
27832
|
fromChain,
|
|
@@ -30048,7 +30033,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30048
30033
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30049
30034
|
if (!optionalChains.length)
|
|
30050
30035
|
return;
|
|
30051
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30036
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-Ds1lt_e4.js'); });
|
|
30052
30037
|
const rawProvider = await EthereumProvider.init({
|
|
30053
30038
|
...restParameters,
|
|
30054
30039
|
disableProviderPing: true,
|
|
@@ -30185,6 +30170,7 @@ const createWagmiConfig = (squidChains, hederaExtensions) => {
|
|
|
30185
30170
|
description: SQUID_METADATA.description,
|
|
30186
30171
|
};
|
|
30187
30172
|
return wagmi.createConfig({
|
|
30173
|
+
ssr: true,
|
|
30188
30174
|
chains: wagmiChains,
|
|
30189
30175
|
transports: Object.fromEntries(wagmiChains.map((chain) => [
|
|
30190
30176
|
chain.id,
|
|
@@ -32453,7 +32439,7 @@ const useHistory = (txType) => {
|
|
|
32453
32439
|
fromChain: tx.params.fromChain,
|
|
32454
32440
|
fromToken: tx.params.fromToken,
|
|
32455
32441
|
fromAddress: tx.params.fromAddress,
|
|
32456
|
-
fromAmount: tx.params.fromAmount
|
|
32442
|
+
fromAmount: tx.params.fromAmount,
|
|
32457
32443
|
toChain: tx.params.toChain,
|
|
32458
32444
|
toToken: tx.params.toToken,
|
|
32459
32445
|
toAddress: tx.params.toAddress,
|
|
@@ -32694,7 +32680,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32694
32680
|
const publicClient = wagmi.usePublicClient();
|
|
32695
32681
|
const queryClient = reactQuery.useQueryClient();
|
|
32696
32682
|
const squid = useSquidStore((state) => state.squid);
|
|
32697
|
-
const { fromChain, fromToken,
|
|
32683
|
+
const { fromChain, fromToken, fromPrice, isSameChain } = useSwap();
|
|
32698
32684
|
const { evmSigner } = useSigner({ chain: fromChain });
|
|
32699
32685
|
const { connector: activeConnector } = wagmi.useAccount();
|
|
32700
32686
|
const { getChainType } = useSquidChains();
|
|
@@ -32867,9 +32853,9 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32867
32853
|
// This is to ensure we're using the latest expiry timestamp
|
|
32868
32854
|
if (squidRoute) {
|
|
32869
32855
|
queryClient.refetchQueries({
|
|
32870
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken,
|
|
32856
|
+
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,
|
|
32871
32857
|
// TODO: update types
|
|
32872
|
-
squidRoute.params?.overrideGasRefundAddress
|
|
32858
|
+
squidRoute.params?.overrideGasRefundAddress),
|
|
32873
32859
|
});
|
|
32874
32860
|
}
|
|
32875
32861
|
},
|
|
@@ -32886,7 +32872,7 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32886
32872
|
const useEstimate = (squidRoute) => {
|
|
32887
32873
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32888
32874
|
const { tokens } = useSquidTokens();
|
|
32889
|
-
const { fromChain, toChain,
|
|
32875
|
+
const { fromChain, toChain, fromPrice } = useSwap();
|
|
32890
32876
|
const fromToken = React.useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32891
32877
|
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32892
32878
|
fromChain,
|
|
@@ -32982,9 +32968,9 @@ const useEstimate = (squidRoute) => {
|
|
|
32982
32968
|
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32983
32969
|
const fromBalanceEnoughToSwap = React.useMemo(() => {
|
|
32984
32970
|
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32985
|
-
const
|
|
32986
|
-
return fromBalanceNum >=
|
|
32987
|
-
}, [fromBalanceFormatted,
|
|
32971
|
+
const fromPriceNum = Number(fromPrice ?? 0);
|
|
32972
|
+
return fromBalanceNum >= fromPriceNum;
|
|
32973
|
+
}, [fromBalanceFormatted, fromPrice]);
|
|
32988
32974
|
return {
|
|
32989
32975
|
...estimateResults,
|
|
32990
32976
|
fromBalanceFormatted,
|
|
@@ -36203,12 +36189,8 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36203
36189
|
if (!depositData?.depositAddress) {
|
|
36204
36190
|
throw new Error("Deposit address is required");
|
|
36205
36191
|
}
|
|
36206
|
-
const fromAmount = route.params.fromAmount || route.estimate.fromAmount;
|
|
36207
|
-
if (isZeroAmount(fromAmount)) {
|
|
36208
|
-
throw new Error("fromAmount is required for Solana transfer");
|
|
36209
|
-
}
|
|
36210
36192
|
const signature = await executeSolanaTransfer({
|
|
36211
|
-
amount: BigInt(fromAmount),
|
|
36193
|
+
amount: BigInt(route.params.fromAmount),
|
|
36212
36194
|
target: depositData.depositAddress,
|
|
36213
36195
|
signer: solanaSigner,
|
|
36214
36196
|
connection: solanaConnection,
|
|
@@ -36718,12 +36700,8 @@ const useGetRoute = () => {
|
|
|
36718
36700
|
* These data will be used to trigger the transaction
|
|
36719
36701
|
* @returns {Route} Route data
|
|
36720
36702
|
*/
|
|
36721
|
-
return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice
|
|
36722
|
-
if (!fromChain ||
|
|
36723
|
-
!toChain ||
|
|
36724
|
-
!fromToken ||
|
|
36725
|
-
!toToken ||
|
|
36726
|
-
(!fromPrice && !toPrice)) {
|
|
36703
|
+
return reactQuery.useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
|
|
36704
|
+
if (!fromChain || !toChain || !fromToken || !toToken || !fromPrice) {
|
|
36727
36705
|
return undefined;
|
|
36728
36706
|
}
|
|
36729
36707
|
// Dispatch requestQuote event
|
|
@@ -36733,7 +36711,6 @@ const useGetRoute = () => {
|
|
|
36733
36711
|
fromToken: fromToken.address,
|
|
36734
36712
|
toToken: toToken.address,
|
|
36735
36713
|
fromAmount: fromPrice,
|
|
36736
|
-
toAmount: toPrice,
|
|
36737
36714
|
fromAddress: sourceUserAddress,
|
|
36738
36715
|
toAddress: destinationAddress,
|
|
36739
36716
|
});
|
|
@@ -36742,13 +36719,13 @@ const useGetRoute = () => {
|
|
|
36742
36719
|
const fromTokenAddress = fromToken.address;
|
|
36743
36720
|
const toTokenAddress = toToken.address;
|
|
36744
36721
|
const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
|
|
36745
|
-
const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
|
|
36746
36722
|
const fromAddress = sourceUserAddress ??
|
|
36747
36723
|
chainTypeToZeroAddressMap[fromChainType ?? squidTypes.ChainType.EVM];
|
|
36748
36724
|
const params = {
|
|
36749
36725
|
fromChain,
|
|
36750
36726
|
fromToken: fromTokenAddress,
|
|
36751
36727
|
fromAddress,
|
|
36728
|
+
fromAmount,
|
|
36752
36729
|
toChain,
|
|
36753
36730
|
toToken: toTokenAddress,
|
|
36754
36731
|
toAddress: destinationAddress ?? "",
|
|
@@ -36765,19 +36742,12 @@ const useGetRoute = () => {
|
|
|
36765
36742
|
cosmosFallbackAddresses[0].address) {
|
|
36766
36743
|
params.fallbackAddresses = cosmosFallbackAddresses;
|
|
36767
36744
|
}
|
|
36768
|
-
if (!isZeroAmount(fromAmount)) {
|
|
36769
|
-
params.fromAmount = fromAmount;
|
|
36770
|
-
}
|
|
36771
|
-
else if (!isZeroAmount(toAmount)) {
|
|
36772
|
-
params.toAmount = toAmount;
|
|
36773
|
-
}
|
|
36774
36745
|
const { route } = await squid.getRoute({
|
|
36775
36746
|
...params,
|
|
36776
|
-
...(prefer ? { prefer } : {}),
|
|
36777
36747
|
});
|
|
36778
36748
|
// Cache the route data
|
|
36779
36749
|
// Useful when the getRoute mutation is called from another hook
|
|
36780
|
-
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice,
|
|
36750
|
+
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);
|
|
36781
36751
|
return route;
|
|
36782
36752
|
});
|
|
36783
36753
|
};
|
|
@@ -36791,7 +36761,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36791
36761
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36792
36762
|
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
36793
36763
|
const getRouteMutation = useGetRoute();
|
|
36794
|
-
const { fromChain, toChain,
|
|
36764
|
+
const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36795
36765
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
36796
36766
|
// When the payment method is deposit address, users can specify a refund address on the source chain
|
|
36797
36767
|
// Tokens will be sent to this address in case of swap failure
|
|
@@ -36800,13 +36770,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36800
36770
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36801
36771
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36802
36772
|
: sourceConnectedAddress;
|
|
36803
|
-
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address,
|
|
36773
|
+
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), [
|
|
36804
36774
|
fromChain?.chainId,
|
|
36805
36775
|
toChain?.chainId,
|
|
36806
36776
|
toToken?.address,
|
|
36807
36777
|
fromToken?.address,
|
|
36808
|
-
|
|
36809
|
-
toAmount,
|
|
36778
|
+
fromPrice,
|
|
36810
36779
|
config.slippage,
|
|
36811
36780
|
sourceUserAddress,
|
|
36812
36781
|
config.degenMode,
|
|
@@ -36817,12 +36786,12 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36817
36786
|
config.preHook,
|
|
36818
36787
|
config.postHook,
|
|
36819
36788
|
config.overrideGasRefundAddress,
|
|
36820
|
-
config.prefer,
|
|
36821
36789
|
]);
|
|
36822
36790
|
const queryEnabled = enabled != undefined
|
|
36823
36791
|
? enabled
|
|
36824
36792
|
: squid !== undefined &&
|
|
36825
|
-
|
|
36793
|
+
fromPrice !== undefined &&
|
|
36794
|
+
fromPrice !== "0" &&
|
|
36826
36795
|
toChain?.chainId !== undefined &&
|
|
36827
36796
|
toToken?.address !== undefined;
|
|
36828
36797
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -36840,15 +36809,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36840
36809
|
toToken,
|
|
36841
36810
|
sourceUserAddress,
|
|
36842
36811
|
destinationAddress,
|
|
36843
|
-
fromPrice
|
|
36844
|
-
toPrice: toAmount,
|
|
36812
|
+
fromPrice,
|
|
36845
36813
|
bypassGuardrails: config.degenMode,
|
|
36846
36814
|
quoteOnly,
|
|
36847
36815
|
fromChainType: fromChain?.chainType,
|
|
36848
36816
|
postHook: config.postHook,
|
|
36849
36817
|
preHook: config.preHook,
|
|
36850
36818
|
overrideGasRefundAddress: config.overrideGasRefundAddress,
|
|
36851
|
-
prefer: config.prefer,
|
|
36852
36819
|
});
|
|
36853
36820
|
return route;
|
|
36854
36821
|
}, {
|
|
@@ -37470,6 +37437,7 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37470
37437
|
// Even with an error, we want wagmi to be defined so that we can display the maintenance mode layout
|
|
37471
37438
|
// Create wagmi config with mainnet as fallback in maintenance mode
|
|
37472
37439
|
const newWagmiConfig = wagmi.createConfig({
|
|
37440
|
+
ssr: true,
|
|
37473
37441
|
chains: [chains$1.mainnet],
|
|
37474
37442
|
connectors: [connectors.injected()],
|
|
37475
37443
|
transports: {
|
|
@@ -37649,7 +37617,6 @@ exports.isWalletAddressValid = isWalletAddressValid;
|
|
|
37649
37617
|
exports.isXamanXAppContext = isXamanXAppContext;
|
|
37650
37618
|
exports.isXionSmartContractAddress = isXionSmartContractAddress;
|
|
37651
37619
|
exports.isXrplAddressValid = isXrplAddressValid;
|
|
37652
|
-
exports.isZeroAmount = isZeroAmount;
|
|
37653
37620
|
exports.mergeWallets = mergeWallets;
|
|
37654
37621
|
exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
|
|
37655
37622
|
exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
|
|
@@ -37772,4 +37739,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37772
37739
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37773
37740
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37774
37741
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37775
|
-
//# sourceMappingURL=index-
|
|
37742
|
+
//# sourceMappingURL=index-D3bbd13Z.js.map
|