@0xsquid/react-hooks 8.7.1 → 8.7.2-beta-interactive-to-amount.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/queries/queries-keys.d.ts +1 -1
- package/dist/core/types/config.d.ts +1 -1
- package/dist/core/types/event.d.ts +1 -2
- package/dist/hooks/store/useSquidStore.d.ts +2 -1
- package/dist/hooks/swap/useSwap.d.ts +4 -2
- package/dist/hooks/transaction/useGetRoute.d.ts +8 -8
- package/dist/{index-Dgqm3ZeG.js → index-6eFn7nS3.js} +62 -33
- package/dist/index-6eFn7nS3.js.map +1 -0
- package/dist/{index-DQERpZr8.js → index-uUESkMSI.js} +62 -32
- package/dist/index-uUESkMSI.js.map +1 -0
- package/dist/{index.es-BKxEl9R1.js → index.es-C0R5BhSh.js} +2 -2
- package/dist/{index.es-BKxEl9R1.js.map → index.es-C0R5BhSh.js.map} +1 -1
- package/dist/{index.es-DOFFrTzb.js → index.es-CRHo3jIu.js} +2 -2
- package/dist/{index.es-DOFFrTzb.js.map → index.es-CRHo3jIu.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{secretService-CqdaN_la.js → secretService-B87PUWJl.js} +2 -2
- package/dist/{secretService-CqdaN_la.js.map → secretService-B87PUWJl.js.map} +1 -1
- package/dist/{secretService-DXExZJnA.js → secretService-C8LsM_VG.js} +2 -2
- package/dist/{secretService-DXExZJnA.js.map → secretService-C8LsM_VG.js.map} +1 -1
- package/dist/services/internal/eventService.d.ts +1 -2
- package/dist/services/internal/numberService.d.ts +1 -0
- package/dist/{stellarService.client-eK7yYyOR.js → stellarService.client-BFgOtfFI.js} +2 -2
- package/dist/{stellarService.client-eK7yYyOR.js.map → stellarService.client-BFgOtfFI.js.map} +1 -1
- package/dist/{stellarService.client-BmkrPHkP.js → stellarService.client-DidQHS07.js} +2 -2
- package/dist/{stellarService.client-BmkrPHkP.js.map → stellarService.client-DidQHS07.js.map} +1 -1
- package/package.json +3 -3
- package/dist/core/types/route.d.ts +0 -4
- package/dist/index-DQERpZr8.js.map +0 -1
- package/dist/index-Dgqm3ZeG.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, fromAmount: string | undefined, toAmount: 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,7 +1,6 @@
|
|
|
1
|
-
import type { RouteResponse } from "@0xsquid/squid-types";
|
|
1
|
+
import type { RouteRequest, RouteResponse } from "@0xsquid/squid-types";
|
|
2
2
|
import { TransactionErrorWithMessage } from "./error";
|
|
3
3
|
import { ExecuteQuoteServer } from "./onramps";
|
|
4
|
-
import { RouteRequest } from "./route";
|
|
5
4
|
type BaseSwapEventParams = Pick<RouteRequest, "fromAddress" | "toAddress" | "fromChain" | "toChain" | "fromToken" | "toToken" | "fromAmount">;
|
|
6
5
|
type BaseSendTransactionEventParams = {
|
|
7
6
|
fromAddress: string;
|
|
@@ -21,7 +21,8 @@ export interface ConfigState {
|
|
|
21
21
|
}
|
|
22
22
|
export declare const useConfigStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ConfigState>>;
|
|
23
23
|
interface TransactionState {
|
|
24
|
-
|
|
24
|
+
fromAmount?: string;
|
|
25
|
+
toAmount?: string;
|
|
25
26
|
txLocalId?: string;
|
|
26
27
|
transactions: Record<string, TransactionParams>;
|
|
27
28
|
currentTransaction?: TransactionParams;
|
|
@@ -7,8 +7,10 @@ export declare const useSwap: () => {
|
|
|
7
7
|
};
|
|
8
8
|
onSwapChange: (inputSwapParams: SwapParams) => SwapParams;
|
|
9
9
|
invertSwaps: (() => SwapParams) | undefined;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
fromAmount: string | undefined;
|
|
11
|
+
toAmount: string | undefined;
|
|
12
|
+
fromAmountChanged: (amount: string) => void;
|
|
13
|
+
toAmountChanged: (amount: string) => void;
|
|
12
14
|
toToken: import("../../core").Token | undefined;
|
|
13
15
|
fromToken: import("../../core").Token | undefined;
|
|
14
16
|
fromChain: import("@0xsquid/squid-types").ChainData | undefined;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { RouteResponse } from "@0xsquid/sdk/dist/types";
|
|
2
|
-
import { ChainType, Token } from "@0xsquid/squid-types";
|
|
2
|
+
import { ChainType, RouteRequest, 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";
|
|
6
5
|
export declare const useGetRoute: () => import("@tanstack/react-query").UseMutationResult<{
|
|
7
6
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
8
7
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
9
|
-
params:
|
|
8
|
+
params: RouteRequest;
|
|
10
9
|
quoteId: string;
|
|
11
10
|
} | undefined, unknown, {
|
|
12
11
|
fromChain: RouteRequest["fromChain"] | undefined;
|
|
@@ -16,6 +15,7 @@ export declare const useGetRoute: () => import("@tanstack/react-query").UseMutat
|
|
|
16
15
|
sourceUserAddress: string | undefined;
|
|
17
16
|
destinationAddress: string | undefined;
|
|
18
17
|
fromPrice: string | undefined;
|
|
18
|
+
toPrice: string | undefined;
|
|
19
19
|
bypassGuardrails: RouteRequest["bypassGuardrails"] | undefined;
|
|
20
20
|
quoteOnly: boolean | undefined;
|
|
21
21
|
fromChainType: ChainType | undefined;
|
|
@@ -26,17 +26,17 @@ export declare const useGetRoute: () => import("@tanstack/react-query").UseMutat
|
|
|
26
26
|
export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refetchOnWindowFocus, refetchIntervalInBackground, refetchInterval, quoteOnly, }: Pick<QueryObserverOptions<{
|
|
27
27
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
28
28
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
29
|
-
params:
|
|
29
|
+
params: RouteRequest;
|
|
30
30
|
quoteId: string;
|
|
31
31
|
} | undefined, unknown, {
|
|
32
32
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
33
33
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
34
|
-
params:
|
|
34
|
+
params: RouteRequest;
|
|
35
35
|
quoteId: string;
|
|
36
36
|
} | undefined, {
|
|
37
37
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
38
38
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
39
|
-
params:
|
|
39
|
+
params: RouteRequest;
|
|
40
40
|
quoteId: string;
|
|
41
41
|
} | undefined, import("@tanstack/react-query").QueryKey>, "cacheTime" | "enabled" | "staleTime" | "refetchInterval" | "refetchIntervalInBackground" | "refetchOnWindowFocus"> & {
|
|
42
42
|
quoteOnly?: boolean | undefined;
|
|
@@ -44,7 +44,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
44
44
|
squidRoute: import("@tanstack/react-query").UseQueryResult<{
|
|
45
45
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
46
46
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
47
|
-
params:
|
|
47
|
+
params: RouteRequest;
|
|
48
48
|
quoteId: string;
|
|
49
49
|
} | undefined, unknown>;
|
|
50
50
|
showLoading: boolean;
|
|
@@ -52,7 +52,7 @@ export declare const useGetRouteWrapper: ({ enabled, cacheTime, staleTime, refet
|
|
|
52
52
|
routeData: {
|
|
53
53
|
estimate: import("@0xsquid/squid-types").Estimate;
|
|
54
54
|
transactionRequest?: import("@0xsquid/squid-types").SquidData | undefined;
|
|
55
|
-
params:
|
|
55
|
+
params: RouteRequest;
|
|
56
56
|
quoteId: string;
|
|
57
57
|
} | undefined;
|
|
58
58
|
};
|
|
@@ -3950,6 +3950,9 @@ const getNumericValue = ({ value, precision, useComaEvery3Digits = true, hideIfZ
|
|
|
3950
3950
|
const finalValue = `${isNegative ? "-" : ""}${prefix}${formattedIfVerySmall}${suffix ? ` ${suffix}` : ""}`;
|
|
3951
3951
|
return wrapInParens ? `(${finalValue})` : finalValue;
|
|
3952
3952
|
};
|
|
3953
|
+
function isZeroAmount(amount) {
|
|
3954
|
+
return !amount || amount === "0";
|
|
3955
|
+
}
|
|
3953
3956
|
|
|
3954
3957
|
/**
|
|
3955
3958
|
* Creates a hash string from quote request parameters to track changes
|
|
@@ -22392,14 +22395,15 @@ const keys = () => ({
|
|
|
22392
22395
|
// ============
|
|
22393
22396
|
// Transactions
|
|
22394
22397
|
// ============
|
|
22395
|
-
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress,
|
|
22398
|
+
transaction: (fromChainId, toChainId, toTokenAddress, fromTokenAddress, fromAmount, toAmount, slippage, sourceUserAddress, degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChainType, preHook, postHook, overrideGasRefundAddress) => [
|
|
22396
22399
|
...keys().transactions(),
|
|
22397
22400
|
QueryKeys.Transaction,
|
|
22398
22401
|
fromChainId,
|
|
22399
22402
|
toChainId,
|
|
22400
22403
|
toTokenAddress,
|
|
22401
22404
|
fromTokenAddress,
|
|
22402
|
-
|
|
22405
|
+
fromAmount,
|
|
22406
|
+
toAmount,
|
|
22403
22407
|
slippage,
|
|
22404
22408
|
sourceUserAddress,
|
|
22405
22409
|
degenMode,
|
|
@@ -23294,7 +23298,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23294
23298
|
};
|
|
23295
23299
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23296
23300
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23297
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23301
|
+
const { fetchAllSecretBalances } = await import('./secretService-B87PUWJl.js');
|
|
23298
23302
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23299
23303
|
};
|
|
23300
23304
|
function getTokenAssetsKey(token) {
|
|
@@ -25151,10 +25155,7 @@ const useConfigStore = create(() => ({
|
|
|
25151
25155
|
isInitialized: false,
|
|
25152
25156
|
}));
|
|
25153
25157
|
const useTransactionStore = create((set, get) => ({
|
|
25154
|
-
fromPrice: undefined,
|
|
25155
|
-
txLocalId: undefined,
|
|
25156
25158
|
transactions: {},
|
|
25157
|
-
currentTransaction: undefined,
|
|
25158
25159
|
setTransactionState(txId, tx) {
|
|
25159
25160
|
if (!txId)
|
|
25160
25161
|
return;
|
|
@@ -26692,7 +26693,7 @@ function useStellarWallets() {
|
|
|
26692
26693
|
try {
|
|
26693
26694
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26694
26695
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module');
|
|
26695
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
26696
|
+
const { formatStellarWallet } = await import('./stellarService.client-DidQHS07.js');
|
|
26696
26697
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26697
26698
|
const promises = modules.map(async (module) => {
|
|
26698
26699
|
const isAvailable = await module.isAvailable();
|
|
@@ -27591,7 +27592,8 @@ const useMultiChainWallet = (chain) => {
|
|
|
27591
27592
|
|
|
27592
27593
|
const useSwap = () => {
|
|
27593
27594
|
const { initialAssets, defaultTokensPerChain, disabledChains, availableChains, } = useConfigStore((state) => state.config);
|
|
27594
|
-
const
|
|
27595
|
+
const fromAmount = useTransactionStore((state) => state.fromAmount);
|
|
27596
|
+
const toAmount = useTransactionStore((state) => state.toAmount);
|
|
27595
27597
|
const { swapRoute } = useSwapRoutePersistStore();
|
|
27596
27598
|
const { tokens } = useSquidTokens();
|
|
27597
27599
|
const queryClient = useQueryClient();
|
|
@@ -27643,8 +27645,17 @@ const useSwap = () => {
|
|
|
27643
27645
|
}),
|
|
27644
27646
|
};
|
|
27645
27647
|
}, [destAddressData, destAddressEnsData.data, toChain?.chainType]);
|
|
27646
|
-
const
|
|
27647
|
-
useTransactionStore.setState({
|
|
27648
|
+
const fromAmountChanged = useCallback((amount) => {
|
|
27649
|
+
useTransactionStore.setState({
|
|
27650
|
+
fromAmount: amount || undefined,
|
|
27651
|
+
toAmount: undefined,
|
|
27652
|
+
});
|
|
27653
|
+
}, []);
|
|
27654
|
+
const toAmountChanged = useCallback((amount) => {
|
|
27655
|
+
useTransactionStore.setState({
|
|
27656
|
+
toAmount: amount || undefined,
|
|
27657
|
+
fromAmount: undefined,
|
|
27658
|
+
});
|
|
27648
27659
|
}, []);
|
|
27649
27660
|
/**
|
|
27650
27661
|
* When user changes something from the SwapView
|
|
@@ -27804,8 +27815,10 @@ const useSwap = () => {
|
|
|
27804
27815
|
tokenItems,
|
|
27805
27816
|
onSwapChange,
|
|
27806
27817
|
invertSwaps,
|
|
27807
|
-
|
|
27808
|
-
|
|
27818
|
+
fromAmount,
|
|
27819
|
+
toAmount,
|
|
27820
|
+
fromAmountChanged,
|
|
27821
|
+
toAmountChanged,
|
|
27809
27822
|
toToken,
|
|
27810
27823
|
fromToken,
|
|
27811
27824
|
fromChain,
|
|
@@ -30012,7 +30025,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30012
30025
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30013
30026
|
if (!optionalChains.length)
|
|
30014
30027
|
return;
|
|
30015
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30028
|
+
const { EthereumProvider } = await import('./index.es-CRHo3jIu.js');
|
|
30016
30029
|
const rawProvider = await EthereumProvider.init({
|
|
30017
30030
|
...restParameters,
|
|
30018
30031
|
disableProviderPing: true,
|
|
@@ -32417,7 +32430,7 @@ const useHistory = (txType) => {
|
|
|
32417
32430
|
fromChain: tx.params.fromChain,
|
|
32418
32431
|
fromToken: tx.params.fromToken,
|
|
32419
32432
|
fromAddress: tx.params.fromAddress,
|
|
32420
|
-
fromAmount: tx.params.fromAmount,
|
|
32433
|
+
fromAmount: tx.params.fromAmount || tx.estimate.fromAmount,
|
|
32421
32434
|
toChain: tx.params.toChain,
|
|
32422
32435
|
toToken: tx.params.toToken,
|
|
32423
32436
|
toAddress: tx.params.toAddress,
|
|
@@ -32658,7 +32671,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32658
32671
|
const publicClient = usePublicClient();
|
|
32659
32672
|
const queryClient = useQueryClient();
|
|
32660
32673
|
const squid = useSquidStore((state) => state.squid);
|
|
32661
|
-
const { fromChain, fromToken,
|
|
32674
|
+
const { fromChain, fromToken, fromAmount, toAmount, isSameChain } = useSwap();
|
|
32662
32675
|
const { evmSigner } = useSigner({ chain: fromChain });
|
|
32663
32676
|
const { connector: activeConnector } = useAccount();
|
|
32664
32677
|
const { getChainType } = useSquidChains();
|
|
@@ -32831,7 +32844,7 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
32831
32844
|
// This is to ensure we're using the latest expiry timestamp
|
|
32832
32845
|
if (squidRoute) {
|
|
32833
32846
|
queryClient.refetchQueries({
|
|
32834
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken,
|
|
32847
|
+
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromAmount, toAmount, 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,
|
|
32835
32848
|
// TODO: update types
|
|
32836
32849
|
squidRoute.params?.overrideGasRefundAddress),
|
|
32837
32850
|
});
|
|
@@ -32850,7 +32863,7 @@ const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/ass
|
|
|
32850
32863
|
const useEstimate = (squidRoute) => {
|
|
32851
32864
|
const collectFees = useConfigStore((state) => state.config.collectFees);
|
|
32852
32865
|
const { tokens } = useSquidTokens();
|
|
32853
|
-
const { fromChain, toChain,
|
|
32866
|
+
const { fromChain, toChain, fromAmount } = useSwap();
|
|
32854
32867
|
const fromToken = useMemo(() => findToken(tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken), [tokens, squidRoute?.params.fromChain, squidRoute?.params.fromToken]);
|
|
32855
32868
|
const { chainFeeParams, gasToken } = useSourceChainGasToken({
|
|
32856
32869
|
fromChain,
|
|
@@ -32946,9 +32959,9 @@ const useEstimate = (squidRoute) => {
|
|
|
32946
32959
|
const slippageFormatted = Number(squidRoute?.estimate?.aggregateSlippage ?? 0).toFixed(2) + "%";
|
|
32947
32960
|
const fromBalanceEnoughToSwap = useMemo(() => {
|
|
32948
32961
|
const fromBalanceNum = Number(fromBalanceFormatted ?? 0);
|
|
32949
|
-
const
|
|
32950
|
-
return fromBalanceNum >=
|
|
32951
|
-
}, [fromBalanceFormatted,
|
|
32962
|
+
const fromAmountNum = Number(fromAmount ?? 0);
|
|
32963
|
+
return fromBalanceNum >= fromAmountNum;
|
|
32964
|
+
}, [fromBalanceFormatted, fromAmount]);
|
|
32952
32965
|
return {
|
|
32953
32966
|
...estimateResults,
|
|
32954
32967
|
fromBalanceFormatted,
|
|
@@ -36167,8 +36180,12 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36167
36180
|
if (!depositData?.depositAddress) {
|
|
36168
36181
|
throw new Error("Deposit address is required");
|
|
36169
36182
|
}
|
|
36183
|
+
const fromAmount = route.params.fromAmount || route.estimate.fromAmount;
|
|
36184
|
+
if (isZeroAmount(fromAmount)) {
|
|
36185
|
+
throw new Error("fromAmount is required for Solana transfer");
|
|
36186
|
+
}
|
|
36170
36187
|
const signature = await executeSolanaTransfer({
|
|
36171
|
-
amount: BigInt(
|
|
36188
|
+
amount: BigInt(fromAmount),
|
|
36172
36189
|
target: depositData.depositAddress,
|
|
36173
36190
|
signer: solanaSigner,
|
|
36174
36191
|
connection: solanaConnection,
|
|
@@ -36678,8 +36695,12 @@ const useGetRoute = () => {
|
|
|
36678
36695
|
* These data will be used to trigger the transaction
|
|
36679
36696
|
* @returns {Route} Route data
|
|
36680
36697
|
*/
|
|
36681
|
-
return useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice, bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
|
|
36682
|
-
if (!fromChain ||
|
|
36698
|
+
return useMutation(async ({ fromChain, toChain, fromToken, toToken, sourceUserAddress, destinationAddress, fromPrice = "", toPrice = "", bypassGuardrails, quoteOnly, fromChainType, postHook, preHook, overrideGasRefundAddress, }) => {
|
|
36699
|
+
if (!fromChain ||
|
|
36700
|
+
!toChain ||
|
|
36701
|
+
!fromToken ||
|
|
36702
|
+
!toToken ||
|
|
36703
|
+
(!fromPrice && !toPrice)) {
|
|
36683
36704
|
return undefined;
|
|
36684
36705
|
}
|
|
36685
36706
|
// Dispatch requestQuote event
|
|
@@ -36689,6 +36710,7 @@ const useGetRoute = () => {
|
|
|
36689
36710
|
fromToken: fromToken.address,
|
|
36690
36711
|
toToken: toToken.address,
|
|
36691
36712
|
fromAmount: fromPrice,
|
|
36713
|
+
toAmount: toPrice,
|
|
36692
36714
|
fromAddress: sourceUserAddress,
|
|
36693
36715
|
toAddress: destinationAddress,
|
|
36694
36716
|
});
|
|
@@ -36697,13 +36719,13 @@ const useGetRoute = () => {
|
|
|
36697
36719
|
const fromTokenAddress = fromToken.address;
|
|
36698
36720
|
const toTokenAddress = toToken.address;
|
|
36699
36721
|
const fromAmount = parseToBigInt(fromPrice?.toString() ?? "0", fromToken?.decimals).toString();
|
|
36722
|
+
const toAmount = parseToBigInt(toPrice?.toString() ?? "0", toToken?.decimals).toString();
|
|
36700
36723
|
const fromAddress = sourceUserAddress ??
|
|
36701
36724
|
chainTypeToZeroAddressMap[fromChainType ?? ChainType.EVM];
|
|
36702
36725
|
const params = {
|
|
36703
36726
|
fromChain,
|
|
36704
36727
|
fromToken: fromTokenAddress,
|
|
36705
36728
|
fromAddress,
|
|
36706
|
-
fromAmount,
|
|
36707
36729
|
toChain,
|
|
36708
36730
|
toToken: toTokenAddress,
|
|
36709
36731
|
toAddress: destinationAddress ?? "",
|
|
@@ -36720,12 +36742,18 @@ const useGetRoute = () => {
|
|
|
36720
36742
|
cosmosFallbackAddresses[0].address) {
|
|
36721
36743
|
params.fallbackAddresses = cosmosFallbackAddresses;
|
|
36722
36744
|
}
|
|
36745
|
+
if (!isZeroAmount(fromAmount)) {
|
|
36746
|
+
params.fromAmount = fromAmount;
|
|
36747
|
+
}
|
|
36748
|
+
else if (!isZeroAmount(toAmount)) {
|
|
36749
|
+
params.toAmount = toAmount;
|
|
36750
|
+
}
|
|
36723
36751
|
const { route } = await squid.getRoute({
|
|
36724
36752
|
...params,
|
|
36725
36753
|
});
|
|
36726
36754
|
// Cache the route data
|
|
36727
36755
|
// Useful when the getRoute mutation is called from another hook
|
|
36728
|
-
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
|
|
36756
|
+
queryClient.setQueryData(keys().transaction(fromChain, toChain, toToken.address, fromToken.address, fromPrice, toPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, swapRoute?.fallbackAddress, quoteOnly, fromChainType, config.preHook, config.postHook, overrideGasRefundAddress), route);
|
|
36729
36757
|
return route;
|
|
36730
36758
|
});
|
|
36731
36759
|
};
|
|
@@ -36739,7 +36767,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36739
36767
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
36740
36768
|
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
36741
36769
|
const getRouteMutation = useGetRoute();
|
|
36742
|
-
const { fromChain, toChain,
|
|
36770
|
+
const { fromChain, toChain, fromAmount, toAmount, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
36743
36771
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
36744
36772
|
// When the payment method is deposit address, users can specify a refund address on the source chain
|
|
36745
36773
|
// Tokens will be sent to this address in case of swap failure
|
|
@@ -36748,12 +36776,13 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36748
36776
|
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
36749
36777
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
36750
36778
|
: sourceConnectedAddress;
|
|
36751
|
-
const squidRouteQueryKeys = useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address,
|
|
36779
|
+
const squidRouteQueryKeys = useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromAmount, toAmount, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
|
|
36752
36780
|
fromChain?.chainId,
|
|
36753
36781
|
toChain?.chainId,
|
|
36754
36782
|
toToken?.address,
|
|
36755
36783
|
fromToken?.address,
|
|
36756
|
-
|
|
36784
|
+
fromAmount,
|
|
36785
|
+
toAmount,
|
|
36757
36786
|
config.slippage,
|
|
36758
36787
|
sourceUserAddress,
|
|
36759
36788
|
config.degenMode,
|
|
@@ -36768,8 +36797,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36768
36797
|
const queryEnabled = enabled != undefined
|
|
36769
36798
|
? enabled
|
|
36770
36799
|
: squid !== undefined &&
|
|
36771
|
-
|
|
36772
|
-
fromPrice !== "0" &&
|
|
36800
|
+
(!isZeroAmount(fromAmount) || !isZeroAmount(toAmount)) &&
|
|
36773
36801
|
toChain?.chainId !== undefined &&
|
|
36774
36802
|
toToken?.address !== undefined;
|
|
36775
36803
|
const queryClient = useQueryClient();
|
|
@@ -36787,7 +36815,8 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36787
36815
|
toToken,
|
|
36788
36816
|
sourceUserAddress,
|
|
36789
36817
|
destinationAddress,
|
|
36790
|
-
fromPrice,
|
|
36818
|
+
fromPrice: fromAmount,
|
|
36819
|
+
toPrice: toAmount,
|
|
36791
36820
|
bypassGuardrails: config.degenMode,
|
|
36792
36821
|
quoteOnly,
|
|
36793
36822
|
fromChainType: fromChain?.chainType,
|
|
@@ -37453,5 +37482,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37453
37482
|
React.createElement(CosmosProvider, null, children)))))))))) : (placeholder);
|
|
37454
37483
|
};
|
|
37455
37484
|
|
|
37456
|
-
export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a, useGetOnrampPaymentTypes as a$, useSwap as a0, buildUrlSearchParamsFromSwapEvent as a1, parseInitialAssetsFromUrl as a2, useUrlSwapParams as a3, useAllConnectedWalletBalances as a4, useAllTokensWithBalanceForChainType as a5, useCosmosBalance as a6, useEvmBalance as a7, useMultiChainBalance as a8, useMultipleTokenPrices as a9, useSwapTransactionStatus as aA, useAvatar as aB, useHistory as aC, useDebouncedValue as aD, useAddToken as aE, useAutoConnect as aF, useEnsDataForAddress as aG, useEnsSearch as aH, useGnosisContext as aI, useIsSameAddressAndGnosisContext as aJ, useIntegratorContext as aK, useMultiChainWallet as aL, useSigner as aM, useWallet as aN, useWallets as aO, useXrplTrustLine as aP, TX_STATUS_CONSTANTS as aQ, FINAL_TRANSACTION_STATUSES as aR, useGetFiatQuote as aS, useGetOnRampConfig as aT, useExecuteFiatQuote as aU, useFiatOnRampTxStatus as aV, useFiatTransactions as aW, useCurrencyDetails as aX, useCountryDetails as aY, useAvailableQuotes as aZ, useRecommendedQuote as a_, useBitcoinNativeBalance as aa, useCosmosNativeBalance as ab, useEvmNativeBalance as ac, useNativeBalance as ad, useSolanaNativeBalance as ae, useStellarNativeBalance as af, useSuiNativeBalance as ag, useXrplNativeBalance as ah, useNativeTokenForChain as ai, useSingleTokenPrice as aj, useSourceChainGasToken as ak, useSquidTokens as al, useHistoricalData as am, useTokensData as an, useEstimateSendTransaction as ao, useSendTransaction as ap, useSendTransactionGas as aq, useAllTransactionsStatus as ar, useApproval as as, useEstimate as at, useEstimatePriceImpact as au, useExecuteTransaction as av, useGetRoute as aw, useGetRouteWrapper as ax, useRouteWarnings as ay, useSendTransactionStatus as az, chainTypeToZeroAddressMap as b, filterWagmiConnector as b$, useSuggestedFiatAmounts as b0, SquidProvider as b1, EnsService as b2, getXummClient as b3, isXamanXAppContext as b4, getQueryHeaders as b5, getStatusCode as b6, is404Error as b7, assetsBaseUrl as b8, shareSubgraphId as b9, fetchHighestBalanceToken as bA, getInitialOrDefaultTokenAddressForChain as bB, getInitialTokenAddressForChain as bC, filterTokensForDestination as bD, getInitialChainIdFromConfig as bE, getCosmosKey as bF, getKeysSettled as bG, getAllKeysForSupportedCosmosChains as bH, isCosmosAddressValid as bI, getCosmosSigningClient as bJ, getCosmosChainInfosObject as bK, connectCosmosWallet as bL, isFallbackAddressNeeded as bM, suggestChainOrThrow as bN, normalizeError as bO, transactionErrorCode as bP, isUserRejectionError as bQ, getTransactionError as bR, handleTransactionErrorEvents as bS, isSwapRouteError as bT, isStatusError as bU, createQuoteRequestParamsHash as bV, WidgetEvents as bW, EvmNetworkNotSupportedErrorCode as bX, addEthereumChain as bY, parseEvmAddress as bZ, formatEvmWallet as b_, sortTokensBySharedSubgraphIds as ba, getSupportedChainIdsForDirection as bb, filterChains as bc, filterTokens as bd, getTokenImage as be, getNewSwapParamsFromInput as bf, sortAllTokens as bg, findToken as bh, findNativeToken as bi, normalizeIbcAddress as bj, groupTokensBySymbol as bk, groupTokensByChainId as bl, filterViewableTokens as bm, getSecretNetworkBalances as bn, getTokenAssetsKey as bo, fetchAssetsColors as bp, initializeSquidWithAssetsColors as bq, isEmptyObject as br, normalizeTokenSymbol as bs, areTokenSymbolsCompatible as bt, isEvmosChain as bu, resolveChainIdFromAsset as bv, getConfigWithDefaults as bw, randomIntFromInterval as bx, getTokensForChain as by, getFirstAvailableChainId as bz, chainTypeToNativeTokenAddressMap as c,
|
|
37457
|
-
//# sourceMappingURL=index-
|
|
37485
|
+
export { useDepositAddress as $, AxelarStatusResponseType as A, useHederaTokenAssociations as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useKeyboardNavigation as E, useSquidQueryClient as F, useSquid as G, HistoryTxType as H, useStellarAccountActivation as I, useStellarTrustLine as J, useAddressBookStore as K, useAssetsColorsStore as L, useFavoriteTokensStore as M, Nr as N, useHistoryStore as O, useSendTransactionStore as P, QueryKeys as Q, useConfigStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useSquidStore as U, useSwapRoutePersistStore as V, Wo as W, XamanXrplNetwork as X, useTransactionStore as Y, ConnectingWalletStatus as Z, useWalletStore as _, WindowWalletFlag as a, useGetOnrampPaymentTypes as a$, useSwap as a0, buildUrlSearchParamsFromSwapEvent as a1, parseInitialAssetsFromUrl as a2, useUrlSwapParams as a3, useAllConnectedWalletBalances as a4, useAllTokensWithBalanceForChainType as a5, useCosmosBalance as a6, useEvmBalance as a7, useMultiChainBalance as a8, useMultipleTokenPrices as a9, useSwapTransactionStatus as aA, useAvatar as aB, useHistory as aC, useDebouncedValue as aD, useAddToken as aE, useAutoConnect as aF, useEnsDataForAddress as aG, useEnsSearch as aH, useGnosisContext as aI, useIsSameAddressAndGnosisContext as aJ, useIntegratorContext as aK, useMultiChainWallet as aL, useSigner as aM, useWallet as aN, useWallets as aO, useXrplTrustLine as aP, TX_STATUS_CONSTANTS as aQ, FINAL_TRANSACTION_STATUSES as aR, useGetFiatQuote as aS, useGetOnRampConfig as aT, useExecuteFiatQuote as aU, useFiatOnRampTxStatus as aV, useFiatTransactions as aW, useCurrencyDetails as aX, useCountryDetails as aY, useAvailableQuotes as aZ, useRecommendedQuote as a_, useBitcoinNativeBalance as aa, useCosmosNativeBalance as ab, useEvmNativeBalance as ac, useNativeBalance as ad, useSolanaNativeBalance as ae, useStellarNativeBalance as af, useSuiNativeBalance as ag, useXrplNativeBalance as ah, useNativeTokenForChain as ai, useSingleTokenPrice as aj, useSourceChainGasToken as ak, useSquidTokens as al, useHistoricalData as am, useTokensData as an, useEstimateSendTransaction as ao, useSendTransaction as ap, useSendTransactionGas as aq, useAllTransactionsStatus as ar, useApproval as as, useEstimate as at, useEstimatePriceImpact as au, useExecuteTransaction as av, useGetRoute as aw, useGetRouteWrapper as ax, useRouteWarnings as ay, useSendTransactionStatus as az, chainTypeToZeroAddressMap as b, filterWagmiConnector as b$, useSuggestedFiatAmounts as b0, SquidProvider as b1, EnsService as b2, getXummClient as b3, isXamanXAppContext as b4, getQueryHeaders as b5, getStatusCode as b6, is404Error as b7, assetsBaseUrl as b8, shareSubgraphId as b9, fetchHighestBalanceToken as bA, getInitialOrDefaultTokenAddressForChain as bB, getInitialTokenAddressForChain as bC, filterTokensForDestination as bD, getInitialChainIdFromConfig as bE, getCosmosKey as bF, getKeysSettled as bG, getAllKeysForSupportedCosmosChains as bH, isCosmosAddressValid as bI, getCosmosSigningClient as bJ, getCosmosChainInfosObject as bK, connectCosmosWallet as bL, isFallbackAddressNeeded as bM, suggestChainOrThrow as bN, normalizeError as bO, transactionErrorCode as bP, isUserRejectionError as bQ, getTransactionError as bR, handleTransactionErrorEvents as bS, isSwapRouteError as bT, isStatusError as bU, createQuoteRequestParamsHash as bV, WidgetEvents as bW, EvmNetworkNotSupportedErrorCode as bX, addEthereumChain as bY, parseEvmAddress as bZ, formatEvmWallet as b_, sortTokensBySharedSubgraphIds as ba, getSupportedChainIdsForDirection as bb, filterChains as bc, filterTokens as bd, getTokenImage as be, getNewSwapParamsFromInput as bf, sortAllTokens as bg, findToken as bh, findNativeToken as bi, normalizeIbcAddress as bj, groupTokensBySymbol as bk, groupTokensByChainId as bl, filterViewableTokens as bm, getSecretNetworkBalances as bn, getTokenAssetsKey as bo, fetchAssetsColors as bp, initializeSquidWithAssetsColors as bq, isEmptyObject as br, normalizeTokenSymbol as bs, areTokenSymbolsCompatible as bt, isEvmosChain as bu, resolveChainIdFromAsset as bv, getConfigWithDefaults as bw, randomIntFromInterval as bx, getTokensForChain as by, getFirstAvailableChainId as bz, chainTypeToNativeTokenAddressMap as c, isHistoryTransactionPending as c$, waitForReceiptWithRetry as c0, getUserCountry as c1, getCountryData as c2, getCurrencyData as c3, adaptiveRound as c4, getSuggestedAmountsForCurrency as c5, HederaExtensionHelper as c6, convertHederaAccountIdToEvmAddress as c7, convertEvmAddressToHederaAccountId as c8, scaleHbarToWei as c9, isValidIssuedAsset as cA, isValidHorizonAsset as cB, formatTransactionHistoryDate as cC, getAxelarExplorerTxUrl as cD, getSourceExplorerTxUrl as cE, getMainExplorerUrl as cF, formatDistance as cG, formatSeconds as cH, formatSwapTxStatusResponseForStorage as cI, simplifyRouteAction as cJ, fetchSwapTransactionStatus as cK, compareTransactionIds as cL, isCoralBridgeAction as cM, sleep as cN, isDepositRoute as cO, isChainflipBridgeTransaction as cP, isOnChainTxData as cQ, getHistoryTransactionId as cR, getStepStatuses as cS, getHalfSuccessState as cT, getStepsInfos as cU, getSwapTxStatusRefetchInterval as cV, getSendTxStatusRefetchInterval as cW, chainflipMultihopBridgeType as cX, getBridgeType as cY, getTransactionStatus as cZ, getTransactionEndStatus as c_, scaleWeiToHbar as ca, parseToBigInt as cb, roundNumericValue as cc, formatUnitsRounded as cd, formatTokenAmount as ce, formatUsdAmount as cf, trimExtraDecimals as cg, getNumericValue as ch, isZeroAmount as ci, cleanAmount as cj, convertTokenAmountToUSD as ck, convertUSDToTokenAmount as cl, calculateTotal24hChange as cm, getRouteExpiry as cn, searchTokens as co, filterSolanaWallets as cp, isSolanaAddressValid as cq, executeSolanaSwap as cr, executeSolanaTransfer as cs, isStellarAddressValid as ct, getStellarNetwork as cu, stellarAddressToScVal as cv, getStellarTrustLineAsset as cw, isStellarToken as cx, isStellarIssuedToken as cy, getStellarHorizonApiUrl as cz, definedInWindow as d, isHistoryTransactionFailed as d0, isHistoryTransactionWarning as d1, isHistoryTransactionEnded as d2, formatHash as d3, isWalletAddressValid as d4, redirectToExtensionsStore as d5, accessProperty as d6, populateWallets as d7, getDefaultChain as d8, sortWallets as d9, areSameAddress as da, sortAddressBook as db, calculateTotalUsdBalanceUSD as dc, addTokenToWallet as dd, isEvmChainNotSupportedError as de, getWalletSupportedChainTypes as df, getConnectorForChainType as dg, walletSupportsChainType as dh, connectWallet as di, cancelConnectWallet as dj, isProblematicConnector as dk, mergeWallets as dl, isXionSmartContractAddress as dm, isXrplAddressValid as dn, buildXrplTrustSetTx as dp, getXrplNetwork as dq, parseXrplPaymentTx as dr, parseXrplTokenAddress as ds, er as e, formatBNToReadable as f, DEFAULT_ROUTE_REFETCH_INTERVAL as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCosmosTokenAddress as j, nativeEvmTokenAddress as k, nativeSolanaTokenAddress as l, nativeStellarTokenAddress as m, nativeBitcoinTokenAddress as n, nativeSuiTokenAddress as o, nativeXrplTokenAddress as p, CosmosProvider as q, SendTransactionStatus as r, TransactionStatus as s, useTrackSearchEmpty as t, useCosmosContext as u, useSquidChains as v, walletIconBaseUrl as w, useClient as x, useCosmosForChain as y, useHederaAccountActivation as z };
|
|
37486
|
+
//# sourceMappingURL=index-6eFn7nS3.js.map
|