@sodax/dapp-kit 0.0.1-rc.9 → 1.0.0-rc.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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -44
  3. package/dist/index.d.mts +1514 -0
  4. package/dist/index.d.ts +1514 -4
  5. package/dist/index.js +997 -82
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +957 -84
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +7 -8
  10. package/src/contexts/index.ts +3 -2
  11. package/src/hooks/backend/README.md +135 -0
  12. package/src/hooks/backend/index.ts +23 -0
  13. package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +49 -0
  14. package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +61 -0
  15. package/src/hooks/backend/useBackendIntentByHash.ts +53 -0
  16. package/src/hooks/backend/useBackendIntentByTxHash.ts +52 -0
  17. package/src/hooks/backend/useBackendMoneyMarketAsset.ts +57 -0
  18. package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +67 -0
  19. package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +67 -0
  20. package/src/hooks/backend/useBackendMoneyMarketPosition.ts +56 -0
  21. package/src/hooks/backend/useBackendOrderbook.ts +63 -0
  22. package/src/hooks/bridge/index.ts +5 -0
  23. package/src/hooks/bridge/useBridge.ts +57 -0
  24. package/src/hooks/bridge/useBridgeAllowance.ts +49 -0
  25. package/src/hooks/bridge/useBridgeApprove.ts +68 -0
  26. package/src/hooks/bridge/useGetBridgeableAmount.ts +50 -0
  27. package/src/hooks/bridge/useGetBridgeableTokens.ts +62 -0
  28. package/src/hooks/index.ts +4 -0
  29. package/src/hooks/migrate/index.ts +4 -0
  30. package/src/hooks/migrate/types.ts +15 -0
  31. package/src/hooks/migrate/useMigrate.tsx +110 -0
  32. package/src/hooks/migrate/useMigrationAllowance.tsx +79 -0
  33. package/src/hooks/migrate/useMigrationApprove.tsx +129 -0
  34. package/src/hooks/mm/useMMAllowance.ts +2 -1
  35. package/src/hooks/mm/useMMApprove.ts +2 -1
  36. package/src/hooks/mm/useReservesData.ts +1 -8
  37. package/src/hooks/mm/useReservesHumanized.ts +30 -0
  38. package/src/hooks/mm/useReservesList.ts +29 -0
  39. package/src/hooks/mm/useReservesUsdFormat.ts +38 -0
  40. package/src/hooks/mm/useUserFormattedSummary.ts +54 -0
  41. package/src/hooks/mm/useUserReservesData.ts +30 -31
  42. package/src/hooks/provider/useHubProvider.ts +3 -3
  43. package/src/hooks/provider/useSpokeProvider.ts +45 -21
  44. package/src/hooks/shared/index.ts +4 -0
  45. package/src/hooks/shared/useDeriveUserWalletAddress.ts +44 -0
  46. package/src/hooks/shared/useEstimateGas.ts +18 -0
  47. package/src/hooks/shared/useRequestTrustline.ts +103 -0
  48. package/src/hooks/shared/useStellarTrustlineCheck.ts +71 -0
  49. package/src/hooks/staking/index.ts +19 -0
  50. package/src/hooks/staking/useCancelUnstake.ts +52 -0
  51. package/src/hooks/staking/useClaim.ts +46 -0
  52. package/src/hooks/staking/useConvertedAssets.ts +47 -0
  53. package/src/hooks/staking/useInstantUnstake.ts +50 -0
  54. package/src/hooks/staking/useInstantUnstakeAllowance.ts +59 -0
  55. package/src/hooks/staking/useInstantUnstakeApprove.ts +52 -0
  56. package/src/hooks/staking/useInstantUnstakeRatio.ts +54 -0
  57. package/src/hooks/staking/useStake.ts +47 -0
  58. package/src/hooks/staking/useStakeAllowance.ts +57 -0
  59. package/src/hooks/staking/useStakeApprove.ts +50 -0
  60. package/src/hooks/staking/useStakeRatio.ts +53 -0
  61. package/src/hooks/staking/useStakingConfig.ts +40 -0
  62. package/src/hooks/staking/useStakingInfo.ts +50 -0
  63. package/src/hooks/staking/useUnstake.ts +54 -0
  64. package/src/hooks/staking/useUnstakeAllowance.ts +58 -0
  65. package/src/hooks/staking/useUnstakeApprove.ts +52 -0
  66. package/src/hooks/staking/useUnstakingInfo.ts +53 -0
  67. package/src/hooks/staking/useUnstakingInfoWithPenalty.ts +59 -0
  68. package/src/hooks/swap/index.ts +2 -1
  69. package/src/hooks/swap/useCancelSwap.ts +44 -0
  70. package/src/hooks/swap/useQuote.ts +16 -2
  71. package/src/hooks/swap/useStatus.ts +1 -1
  72. package/src/hooks/swap/{useCreateIntentOrder.ts → useSwap.ts} +16 -11
  73. package/src/hooks/swap/useSwapAllowance.ts +5 -1
  74. package/src/hooks/swap/useSwapApprove.ts +14 -14
  75. package/src/providers/SodaxProvider.tsx +8 -20
  76. package/dist/contexts/index.d.ts +0 -8
  77. package/dist/contexts/index.d.ts.map +0 -1
  78. package/dist/core/index.d.ts +0 -3
  79. package/dist/core/index.d.ts.map +0 -1
  80. package/dist/hooks/index.d.ts +0 -5
  81. package/dist/hooks/index.d.ts.map +0 -1
  82. package/dist/hooks/mm/index.d.ts +0 -9
  83. package/dist/hooks/mm/index.d.ts.map +0 -1
  84. package/dist/hooks/mm/useBorrow.d.ts +0 -35
  85. package/dist/hooks/mm/useBorrow.d.ts.map +0 -1
  86. package/dist/hooks/mm/useMMAllowance.d.ts +0 -26
  87. package/dist/hooks/mm/useMMAllowance.d.ts.map +0 -1
  88. package/dist/hooks/mm/useMMApprove.d.ts +0 -27
  89. package/dist/hooks/mm/useMMApprove.d.ts.map +0 -1
  90. package/dist/hooks/mm/useRepay.d.ts +0 -35
  91. package/dist/hooks/mm/useRepay.d.ts.map +0 -1
  92. package/dist/hooks/mm/useReservesData.d.ts +0 -19
  93. package/dist/hooks/mm/useReservesData.d.ts.map +0 -1
  94. package/dist/hooks/mm/useSupply.d.ts +0 -34
  95. package/dist/hooks/mm/useSupply.d.ts.map +0 -1
  96. package/dist/hooks/mm/useUserReservesData.d.ts +0 -3
  97. package/dist/hooks/mm/useUserReservesData.d.ts.map +0 -1
  98. package/dist/hooks/mm/useWithdraw.d.ts +0 -33
  99. package/dist/hooks/mm/useWithdraw.d.ts.map +0 -1
  100. package/dist/hooks/provider/index.d.ts +0 -3
  101. package/dist/hooks/provider/index.d.ts.map +0 -1
  102. package/dist/hooks/provider/useHubProvider.d.ts +0 -3
  103. package/dist/hooks/provider/useHubProvider.d.ts.map +0 -1
  104. package/dist/hooks/provider/useSpokeProvider.d.ts +0 -18
  105. package/dist/hooks/provider/useSpokeProvider.d.ts.map +0 -1
  106. package/dist/hooks/shared/index.d.ts +0 -2
  107. package/dist/hooks/shared/index.d.ts.map +0 -1
  108. package/dist/hooks/shared/useSodaxContext.d.ts +0 -8
  109. package/dist/hooks/shared/useSodaxContext.d.ts.map +0 -1
  110. package/dist/hooks/swap/index.d.ts +0 -6
  111. package/dist/hooks/swap/index.d.ts.map +0 -1
  112. package/dist/hooks/swap/useCreateIntentOrder.d.ts +0 -33
  113. package/dist/hooks/swap/useCreateIntentOrder.d.ts.map +0 -1
  114. package/dist/hooks/swap/useQuote.d.ts +0 -39
  115. package/dist/hooks/swap/useQuote.d.ts.map +0 -1
  116. package/dist/hooks/swap/useStatus.d.ts +0 -31
  117. package/dist/hooks/swap/useStatus.d.ts.map +0 -1
  118. package/dist/hooks/swap/useSwapAllowance.d.ts +0 -23
  119. package/dist/hooks/swap/useSwapAllowance.d.ts.map +0 -1
  120. package/dist/hooks/swap/useSwapApprove.d.ts +0 -26
  121. package/dist/hooks/swap/useSwapApprove.d.ts.map +0 -1
  122. package/dist/index.d.ts.map +0 -1
  123. package/dist/providers/SodaxProvider.d.ts +0 -10
  124. package/dist/providers/SodaxProvider.d.ts.map +0 -1
  125. package/dist/providers/index.d.ts +0 -2
  126. package/dist/providers/index.d.ts.map +0 -1
@@ -0,0 +1,1514 @@
1
+ import * as _sodax_sdk from '@sodax/sdk';
2
+ import { Sodax, SpokeProvider, GetEstimateGasReturnType, TxReturnType, SpokeChainId, StellarSpokeProvider, EvmHubProvider, IWalletProvider, UserReserveData, MoneyMarketAction, SolverIntentQuoteRequest, Result, SolverIntentQuoteResponse, SolverErrorResponse, SolverExecutionResponse, Intent, IntentDeliveryInfo, IntentError, IntentErrorCode, CreateIntentParams, Hex, SolverIntentStatusResponse, IntentResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, CreateBridgeIntentParams, SpokeTxHash, HubTxHash, BridgeError, BridgeErrorCode, XToken as XToken$1, StakeParams, UnstakeParams, ClaimParams, CancelUnstakeParams, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeParams, SodaxConfig } from '@sodax/sdk';
3
+ import { RpcConfig, SpokeChainId as SpokeChainId$1, XToken, ChainId } from '@sodax/types';
4
+ import * as _tanstack_react_query from '@tanstack/react-query';
5
+ import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
6
+ import { Address } from 'viem';
7
+ import { ReactNode, ReactElement } from 'react';
8
+
9
+ interface SodaxContextType {
10
+ sodax: Sodax;
11
+ testnet: boolean;
12
+ rpcConfig: RpcConfig;
13
+ }
14
+
15
+ /**
16
+ * Hook to access the Sodax context which provides access to the Sodax SDK instance and chain configuration
17
+ * @throws {Error} If used outside of a SodaxProvider
18
+ * @returns {SodaxContextType} The Sodax context containing SDK instance and configuration
19
+ */
20
+ declare const useSodaxContext: () => SodaxContextType;
21
+
22
+ declare function useEstimateGas<T extends SpokeProvider = SpokeProvider>(spokeProvider: T | undefined): UseMutationResult<GetEstimateGasReturnType<T>, Error, TxReturnType<T, true>>;
23
+
24
+ /**
25
+ * Hook for deriving user wallet address for hub abstraction.
26
+ *
27
+ * This hook derives the user's abstracted wallet address for the hub chain.
28
+ * If the spoke chain is the same as the hub chain, it returns the original wallet address.
29
+ * Otherwise, it returns the abstracted wallet address for cross-chain operations.
30
+ *
31
+ * @param spokeProvider - The spoke provider instance for the origin chain
32
+ * @param walletAddress - Optional user wallet address on spoke chain. If not provided, will fetch from spokeProvider
33
+ * @returns A React Query result object containing:
34
+ * - data: The derived user wallet address when available
35
+ * - isLoading: Loading state indicator
36
+ * - error: Any error that occurred during derivation
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const { data: derivedAddress, isLoading, error } = useDeriveUserWalletAddress(spokeProvider, userAddress);
41
+ * ```
42
+ */
43
+ declare function useDeriveUserWalletAddress(spokeProvider: SpokeProvider | undefined, walletAddress?: string | undefined): UseQueryResult<Address, Error>;
44
+
45
+ /**
46
+ * React hook to check if a Stellar account has a sufficient trustline for a given token and amount.
47
+ *
48
+ * This hook queries the Stellar network (via the provided SpokeProvider) to determine
49
+ * whether the account has established a trustline for the specified token and if the trustline
50
+ * is sufficient for the intended amount. It is useful for gating UI actions that require
51
+ * a trustline to be present and funded.
52
+ *
53
+ * @template T - The type of SpokeProvider, defaults to SpokeProvider.
54
+ * @param {string | undefined} token - The Stellar asset code or token address to check the trustline for.
55
+ * @param {bigint | undefined} amount - The minimum amount required for the trustline.
56
+ * @param {T | undefined} spokeProvider - The provider instance for interacting with the Stellar network.
57
+ * @param {SpokeChainId | undefined} chainId - The chain ID to determine if the check should be performed (only on Stellar mainnet).
58
+ * @returns {UseQueryResult<boolean, Error>} A React Query result object containing:
59
+ * - `data`: `true` if the trustline exists and is sufficient, `false` otherwise.
60
+ * - `error`: Any error encountered during the check.
61
+ * - `isLoading`: Whether the query is in progress.
62
+ * - Other React Query state.
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * import { useStellarTrustlineCheck } from '@sodax/dapp-kit';
67
+ *
68
+ * const { data: hasTrustline, isLoading, error } = useStellarTrustlineCheck(
69
+ * 'USDC-G...TOKEN',
70
+ * 10000000n,
71
+ * stellarProvider,
72
+ * 'stellar'
73
+ * );
74
+ *
75
+ * if (isLoading) return <span>Checking trustline...</span>;
76
+ * if (error) return <span>Error: {error.message}</span>;
77
+ * if (!hasTrustline) return <span>Trustline not established or insufficient.</span>;
78
+ * return <span>Trustline is sufficient!</span>;
79
+ * ```
80
+ */
81
+ declare function useStellarTrustlineCheck<T extends SpokeProvider = SpokeProvider>(token: string | undefined, amount: bigint | undefined, spokeProvider: T | undefined, chainId: SpokeChainId | undefined): UseQueryResult<boolean, Error>;
82
+
83
+ /**
84
+ * React hook to request a Stellar trustline for a given token and amount.
85
+ *
86
+ * This hook provides a callback function for requesting a trustline on the Stellar network
87
+ * using the provided SpokeProvider. It is intended for use with StellarSpokeProvider
88
+ * and will throw if used with a non-Stellar provider. Upon success, it invalidates
89
+ * the trustline check query to ensure UI reflects the updated trustline state.
90
+ *
91
+ * @template T - The type of SpokeProvider, defaults to SpokeProvider.
92
+ * @param {string | undefined} token - The Stellar asset code or token address for which to request a trustline.
93
+ * @returns {Object} An object containing:
94
+ * - `requestTrustline`: Function to trigger the trustline request.
95
+ * - `isLoading`: Whether the request is in progress.
96
+ * - `isRequested`: Whether a trustline has been successfully requested.
97
+ * - `error`: Any error encountered during the request.
98
+ * - `data`: The transaction result if successful.
99
+ *
100
+ * @example
101
+ * ```tsx
102
+ * import { useRequestTrustline } from '@sodax/dapp-kit';
103
+ *
104
+ * const { requestTrustline, isLoading, isRequested, error, data } = useRequestTrustline('USDC-G...TOKEN');
105
+ *
106
+ * // To request a trustline:
107
+ * await requestTrustline({
108
+ * token: 'USDC-G...TOKEN',
109
+ * amount: 10000000n,
110
+ * spokeProvider: stellarProvider,
111
+ * });
112
+ *
113
+ * if (isLoading) return <span>Requesting trustline...</span>;
114
+ * if (error) return <span>Error: {error.message}</span>;
115
+ * if (isRequested) return <span>Trustline requested! Tx: {data?.txHash}</span>;
116
+ * ```
117
+ */
118
+ declare function useRequestTrustline<T extends SpokeProvider = SpokeProvider>(token: string | undefined): {
119
+ requestTrustline: (params: {
120
+ token: string;
121
+ amount: bigint;
122
+ spokeProvider: T;
123
+ }) => Promise<TxReturnType<StellarSpokeProvider, false>>;
124
+ isLoading: boolean;
125
+ isRequested: boolean;
126
+ error: Error | null;
127
+ data: TxReturnType<StellarSpokeProvider, false> | null;
128
+ };
129
+
130
+ declare function useHubProvider(): EvmHubProvider;
131
+
132
+ /**
133
+ * Hook to get the appropriate spoke provider based on the chain type.
134
+ * Supports EVM, SUI, ICON and INJECTIVE chains.
135
+ *
136
+ * @param {SpokeChainId | undefined} spokeChainId - The spoke chain ID to get the provider for
137
+ * @param {IWalletProvider | undefined} walletProvider - The wallet provider to use
138
+ * @returns {SpokeProvider | undefined} The appropriate spoke provider instance for the given chain ID, or undefined if invalid/unsupported
139
+ *
140
+ * @example
141
+ * ```tsx
142
+ * // Using a specific SpokeChainId and wallet provider
143
+ * const spokeProvider = useSpokeProvider(spokeChainId, walletProvider);
144
+ * ```
145
+ */
146
+ declare function useSpokeProvider(spokeChainId: SpokeChainId$1 | undefined, walletProvider?: IWalletProvider | undefined): SpokeProvider | undefined;
147
+
148
+ interface BorrowResponse {
149
+ ok: true;
150
+ value: [string, string];
151
+ }
152
+ /**
153
+ * Hook for borrowing tokens from the Sodax money market.
154
+ *
155
+ * This hook provides functionality to borrow tokens from the money market protocol,
156
+ * handling the entire borrow process including transaction creation, submission,
157
+ * and cross-chain communication.
158
+ *
159
+ * @param {XToken} spokeToken - The token to borrow from the spoke chain. Must be an XToken with valid address and chain information.
160
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the borrow transaction. Must be a valid SpokeProvider instance.
161
+ *
162
+ * @returns {UseMutationResult<BorrowResponse, Error, string>} A mutation result object with the following properties:
163
+ * - mutateAsync: Function to execute the borrow transaction
164
+ * - isPending: Boolean indicating if a transaction is in progress
165
+ * - error: Error object if the last transaction failed, null otherwise
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const { mutateAsync: borrow, isPending, error } = useBorrow(spokeToken);
170
+ * await borrow('100');
171
+ * ```
172
+ *
173
+ * @throws {Error} When:
174
+ * - spokeProvider is not available
175
+ * - Transaction execution fails
176
+ */
177
+ declare function useBorrow(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<BorrowResponse, Error, string>;
178
+
179
+ interface RepayResponse {
180
+ ok: true;
181
+ value: [string, string];
182
+ }
183
+ /**
184
+ * Hook for repaying borrowed tokens to the Sodax money market.
185
+ *
186
+ * This hook provides functionality to repay borrowed tokens back to the money market protocol,
187
+ * handling the entire repayment process including transaction creation, submission,
188
+ * and cross-chain communication.
189
+ *
190
+ * @param {XToken} spokeToken - The token to repay on the spoke chain. Must be an XToken with valid address and chain information.
191
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the repay transaction. Must be a valid SpokeProvider instance.
192
+ *
193
+ * @returns {UseMutationResult<RepayResponse, Error, string>} A mutation result object with the following properties:
194
+ * - mutateAsync: Function to execute the repay transaction
195
+ * - isPending: Boolean indicating if a transaction is in progress
196
+ * - error: Error object if the last transaction failed, null otherwise
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * const { mutateAsync: repay, isPending, error } = useRepay(spokeToken);
201
+ * await repay('100');
202
+ * ```
203
+ *
204
+ * @throws {Error} When:
205
+ * - spokeProvider is not available
206
+ * - Transaction execution fails
207
+ */
208
+ declare function useRepay(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<RepayResponse, Error, string>;
209
+
210
+ interface SupplyResponse {
211
+ ok: true;
212
+ value: [string, string];
213
+ }
214
+ /**
215
+ * Hook for supplying tokens to the Sodax money market.
216
+ *
217
+ * This hook provides functionality to supply tokens to the money market protocol,
218
+ * handling the entire supply process including transaction creation, submission,
219
+ * and cross-chain communication.
220
+ *
221
+ * @param {XToken} spokeToken - The token to supply on the spoke chain. Must be an XToken with valid address and chain information.
222
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the supply transaction. Must be a valid SpokeProvider instance.
223
+ *
224
+ * @returns {UseMutationResult<SupplyResponse, Error, string>} A mutation result object with the following properties:
225
+ * - mutateAsync: Function to execute the supply transaction
226
+ * - isPending: Boolean indicating if a transaction is in progress
227
+ * - error: Error object if the last transaction failed, null otherwise
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * const { mutateAsync: supply, isPending, error } = useSupply(spokeToken);
232
+ * await supply('100');
233
+ * ```
234
+ *
235
+ * @throws {Error} When:
236
+ * - spokeProvider is not available
237
+ */
238
+ declare function useSupply(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<SupplyResponse, Error, string>;
239
+
240
+ interface WithdrawResponse {
241
+ ok: true;
242
+ value: [string, string];
243
+ }
244
+ /**
245
+ * Hook for withdrawing supplied tokens from the Sodax money market.
246
+ *
247
+ * This hook provides functionality to withdraw previously supplied tokens from the money market protocol,
248
+ * handling the entire withdrawal process including transaction creation, submission,
249
+ * and cross-chain communication.
250
+ *
251
+ * @param {XToken} spokeToken - The token to withdraw from the spoke chain. Must be an XToken with valid address and chain information.
252
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the withdraw transaction. Must be a valid SpokeProvider instance.
253
+ *
254
+ * @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:
255
+ * - mutateAsync: Function to execute the withdraw transaction
256
+ * - isPending: Boolean indicating if a transaction is in progress
257
+ * @example
258
+ * ```typescript
259
+ * const { mutateAsync: withdraw, isPending, error } = useWithdraw(spokeToken);
260
+ * await withdraw('100');
261
+ * ```
262
+ *
263
+ * @throws {Error} When:
264
+ * - spokeProvider is not available
265
+ * - Transaction execution fails
266
+ */
267
+ declare function useWithdraw(spokeToken: XToken, spokeProvider: SpokeProvider | undefined): UseMutationResult<WithdrawResponse, Error, string>;
268
+
269
+ /**
270
+ * Hook for fetching user reserves data from the Sodax money market.
271
+ *
272
+ * This hook provides access to the current state of user reserves in the money market protocol.
273
+ * The data is automatically fetched and cached using React Query.
274
+ *
275
+ * @example
276
+ * ```typescript
277
+ * const { data: userReservesData, isLoading, error } = useUserReservesData(spokeProvider, address);
278
+ * ```
279
+ *
280
+ * @returns A React Query result object containing:
281
+ * - data: The user reserves data when available
282
+ * - isLoading: Loading state indicator
283
+ * - error: Any error that occurred during data fetching
284
+ */
285
+ declare function useUserReservesData(spokeProvider: SpokeProvider | undefined, address: string | undefined, refetchInterval?: number): UseQueryResult<readonly [readonly UserReserveData[], number], Error>;
286
+
287
+ /**
288
+ * Hook for fetching reserves data from the Sodax money market.
289
+ *
290
+ * This hook provides access to the current state of all reserves in the money market protocol,
291
+ * including liquidity, interest rates, and other key metrics. The data is automatically
292
+ * fetched and cached using React Query.
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * const { data: reservesData, isLoading, error } = useReservesData();
297
+ * ```
298
+ *
299
+ * @returns A React Query result object containing:
300
+ * - data: The reserves data when available
301
+ * - isLoading: Loading state indicator
302
+ * - error: Any error that occurred during data fetching
303
+ */
304
+ declare function useReservesData(): _tanstack_react_query.UseQueryResult<readonly [readonly _sodax_sdk.AggregatedReserveData[], _sodax_sdk.BaseCurrencyInfo], Error>;
305
+
306
+ /**
307
+ * Hook for checking token allowance for money market operations.
308
+ *
309
+ * This hook verifies if the user has approved enough tokens for a specific money market action
310
+ * (borrow/repay). It automatically queries and tracks the allowance status.
311
+ *
312
+ * @param {XToken} token - The token to check allowance for. Must be an XToken with valid address and chain information.
313
+ * @param {string} amount - The amount to check allowance for, as a decimal string
314
+ * @param {MoneyMarketAction} action - The money market action to check allowance for ('borrow' or 'repay')
315
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
316
+ *
317
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
318
+ * - data: Boolean indicating if allowance is sufficient
319
+ * - isLoading: Loading state indicator
320
+ * - error: Any error that occurred during the check
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * const { data: hasAllowed, isLoading } = useMMAllowance(token, "100", "repay", provider);
325
+ * ```
326
+ */
327
+ declare function useMMAllowance(token: XToken, amount: string, action: MoneyMarketAction, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
328
+
329
+ interface UseApproveReturn$2 {
330
+ approve: ({ amount, action }: {
331
+ amount: string;
332
+ action: MoneyMarketAction;
333
+ }) => Promise<boolean>;
334
+ isLoading: boolean;
335
+ error: Error | null;
336
+ resetError: () => void;
337
+ }
338
+ /**
339
+ * Hook for approving token spending for money market actions
340
+ * @param token The token to approve spending for
341
+ * @param spokeProvider The spoke provider instance for the chain
342
+ * @returns Object containing approve function, loading state, error state and reset function
343
+ * @example
344
+ * ```tsx
345
+ * const { approve, isLoading, error } = useMMApprove(token, spokeProvider);
346
+ *
347
+ * // Approve tokens for supply action
348
+ * await approve({ amount: "100", action: "supply" });
349
+ * ```
350
+ */
351
+ declare function useMMApprove(token: XToken, spokeProvider: SpokeProvider | undefined): UseApproveReturn$2;
352
+
353
+ /**
354
+ * Hook for fetching a quote for an intent-based swap.
355
+ *
356
+ * This hook provides real-time quote data for an intent-based swap.
357
+ *
358
+ * @param {SolverIntentQuoteRequest | undefined} payload - The intent quote request parameters. If undefined, the query will be disabled.
359
+ *
360
+ * @returns {UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>} A query result object containing:
361
+ * - data: The quote result from the solver
362
+ * - isLoading: Boolean indicating if the quote is being fetched
363
+ * - error: Error object if the quote request failed
364
+ * - refetch: Function to manually trigger a quote refresh
365
+ *
366
+ * @example
367
+ * ```typescript
368
+ * const { data: quote, isLoading } = useQuote({
369
+ * token_src: '0x...',
370
+ * token_src_blockchain_id: '1',
371
+ * token_dst: '0x...',
372
+ * token_dst_blockchain_id: '2',
373
+ * amount: '1000000000000000000',
374
+ * quote_type: 'exact_input',
375
+ * });
376
+ *
377
+ * if (isLoading) return <div>Loading quote...</div>;
378
+ * if (quote) {
379
+ * console.log('Quote received:', quote);
380
+ * }
381
+ * ```
382
+ *
383
+ * @remarks
384
+ * - The quote is automatically refreshed every 3 seconds
385
+ * - The query is disabled when payload is undefined
386
+ * - Uses React Query for efficient caching and state management
387
+ */
388
+ declare const useQuote: (payload: SolverIntentQuoteRequest | undefined) => UseQueryResult<Result<SolverIntentQuoteResponse, SolverErrorResponse> | undefined>;
389
+
390
+ type CreateIntentResult = Result<[SolverExecutionResponse, Intent, IntentDeliveryInfo], IntentError<IntentErrorCode>>;
391
+ /**
392
+ * Hook for creating and submitting an swap intent order for cross-chain swaps.
393
+ * Uses React Query's useMutation for better state management and caching.
394
+ *
395
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the swap
396
+ * @returns {UseMutationResult} Mutation result object containing mutation function and state
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * const { mutateAsync: swap, isPending } = useSwap(spokeProvider);
401
+ *
402
+ * const handleSwap = async () => {
403
+ * const result = await swap({
404
+ * token_src: '0x...',
405
+ * token_src_blockchain_id: 'arbitrum',
406
+ * token_dst: '0x...',
407
+ * token_dst_blockchain_id: 'polygon',
408
+ * amount: '1000000000000000000',
409
+ * min_output_amount: '900000000000000000'
410
+ * });
411
+ * };
412
+ * ```
413
+ */
414
+ declare function useSwap(spokeProvider: SpokeProvider | undefined): UseMutationResult<CreateIntentResult, Error, CreateIntentParams>;
415
+
416
+ /**
417
+ * Hook for monitoring the status of an intent-based swap.
418
+ *
419
+ * This hook provides real-time status updates for an intent-based swap transaction.
420
+ *
421
+ * @param {Hex} intent_tx_hash - The transaction hash of the intent order on the hub chain
422
+ *
423
+ * @returns {UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>} A query result object containing:
424
+ * - data: The status result from the solver
425
+ * - isLoading: Boolean indicating if the status is being fetched
426
+ * - error: Error object if the status request failed
427
+ * - refetch: Function to manually trigger a status refresh
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * const { data: status, isLoading } = useStatus('0x...');
432
+ *
433
+ * if (isLoading) return <div>Loading status...</div>;
434
+ * if (status?.ok) {
435
+ * console.log('Status:', status.value);
436
+ * }
437
+ * ```
438
+ *
439
+ * @remarks
440
+ * - The status is automatically refreshed every 3 seconds
441
+ * - Uses React Query for efficient caching and state management
442
+ */
443
+ declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>;
444
+
445
+ /**
446
+ * Hook for checking token allowance for money market operations.
447
+ *
448
+ * This hook verifies if the user has approved enough tokens for a specific money market action
449
+ * (borrow/repay). It automatically queries and tracks the allowance status.
450
+ *
451
+ * @param {CreateIntentParams} params - The parameters for the intent to check allowance for.
452
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
453
+ *
454
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
455
+ * - data: Boolean indicating if allowance is sufficient
456
+ * - isLoading: Loading state indicator
457
+ * - error: Any error that occurred during the check
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const { data: hasAllowed, isLoading } = useMMAllowance(params, spokeProvider);
462
+ * ```
463
+ */
464
+ declare function useSwapAllowance(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
465
+
466
+ interface UseApproveReturn$1 {
467
+ approve: ({ params }: {
468
+ params: CreateIntentParams;
469
+ }) => Promise<boolean>;
470
+ isLoading: boolean;
471
+ error: Error | null;
472
+ resetError: () => void;
473
+ }
474
+ /**
475
+ * Hook for approving token spending for money market actions
476
+ * @param token The token to approve spending for
477
+ * @param spokeProvider The spoke provider instance for the chain
478
+ * @returns Object containing approve function, loading state, error state and reset function
479
+ * @example
480
+ * ```tsx
481
+ * const { approve, isLoading, error } = useApprove(token, spokeProvider);
482
+ *
483
+ * // Approve tokens for supply action
484
+ * await approve({ amount: "100", action: "supply" });
485
+ * ```
486
+ */
487
+ declare function useSwapApprove(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn$1;
488
+
489
+ type CancelIntentParams = {
490
+ intent: Intent;
491
+ raw?: boolean;
492
+ };
493
+ type CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;
494
+ /**
495
+ * Hook for canceling a swap intent order.
496
+ * Uses React Query's useMutation for better state management and caching.
497
+ *
498
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for canceling the intent
499
+ * @returns {UseMutationResult} Mutation result object containing mutation function and state
500
+ *
501
+ * @example
502
+ * ```typescript
503
+ * const { mutateAsync: cancelSwap, isPending } = useCancelSwap(spokeProvider);
504
+ *
505
+ * const handleCancelSwap = async () => {
506
+ * const result = await cancelSwap({
507
+ * intent: intentObject,
508
+ * raw: false // optional, defaults to false
509
+ * });
510
+ * };
511
+ * ```
512
+ */
513
+ declare function useCancelSwap(spokeProvider: SpokeProvider | undefined): UseMutationResult<CancelIntentResult, Error, CancelIntentParams>;
514
+
515
+ /**
516
+ * Hook for fetching intent details by transaction hash from the backend API.
517
+ *
518
+ * This hook provides access to intent data associated with a specific transaction hash,
519
+ * including intent details, events, and transaction information. The data is automatically
520
+ * fetched and cached using React Query.
521
+ *
522
+ * @param {string | undefined} txHash - The transaction hash to fetch intent for. If undefined, the query will be disabled.
523
+ *
524
+ * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:
525
+ * - data: The intent response data when available
526
+ * - isLoading: Boolean indicating if the request is in progress
527
+ * - error: Error object if the request failed
528
+ * - refetch: Function to manually trigger a data refresh
529
+ *
530
+ * @example
531
+ * ```typescript
532
+ * const { data: intent, isLoading, error } = useIntentByTxHash('0x123...');
533
+ *
534
+ * if (isLoading) return <div>Loading intent...</div>;
535
+ * if (error) return <div>Error: {error.message}</div>;
536
+ * if (intent) {
537
+ * console.log('Intent found:', intent.intentHash);
538
+ * }
539
+ * ```
540
+ *
541
+ * @remarks
542
+ * - The query is disabled when txHash is undefined or empty
543
+ * - Uses React Query for efficient caching and state management
544
+ * - Automatically handles error states and loading indicators
545
+ */
546
+ declare const useBackendIntentByTxHash: (txHash: string | undefined) => UseQueryResult<IntentResponse | undefined>;
547
+
548
+ /**
549
+ * Hook for fetching intent details by intent hash from the backend API.
550
+ *
551
+ * This hook provides access to intent data using the intent hash directly,
552
+ * including intent details, events, and transaction information. The data is automatically
553
+ * fetched and cached using React Query.
554
+ *
555
+ * @param {string | undefined} intentHash - The intent hash to fetch intent for. If undefined, the query will be disabled.
556
+ *
557
+ * @returns {UseQueryResult<IntentResponse | undefined>} A query result object containing:
558
+ * - data: The intent response data when available
559
+ * - isLoading: Boolean indicating if the request is in progress
560
+ * - error: Error object if the request failed
561
+ * - refetch: Function to manually trigger a data refresh
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * const { data: intent, isLoading, error } = useIntentByHash('0xabc...');
566
+ *
567
+ * if (isLoading) return <div>Loading intent...</div>;
568
+ * if (error) return <div>Error: {error.message}</div>;
569
+ * if (intent) {
570
+ * console.log('Intent found:', intent.intentHash);
571
+ * console.log('Open status:', intent.open);
572
+ * }
573
+ * ```
574
+ *
575
+ * @remarks
576
+ * - The query is disabled when intentHash is undefined or empty
577
+ * - Uses React Query for efficient caching and state management
578
+ * - Automatically handles error states and loading indicators
579
+ */
580
+ declare const useBackendIntentByHash: (intentHash: string | undefined) => UseQueryResult<IntentResponse | undefined>;
581
+
582
+ /**
583
+ * Hook for fetching the solver orderbook from the backend API.
584
+ *
585
+ * This hook provides access to the solver orderbook data, including intent states
586
+ * and intent data for all available intents. The data is automatically fetched
587
+ * and cached using React Query with pagination support.
588
+ *
589
+ * @param {Object} params - Pagination parameters for the orderbook
590
+ * @param {string} params.offset - The offset for pagination (number as string)
591
+ * @param {string} params.limit - The limit for pagination (number as string)
592
+ *
593
+ * @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:
594
+ * - data: The orderbook response data when available
595
+ * - isLoading: Boolean indicating if the request is in progress
596
+ * - error: Error object if the request failed
597
+ * - refetch: Function to manually trigger a data refresh
598
+ *
599
+ * @example
600
+ * ```typescript
601
+ * const { data: orderbook, isLoading, error } = useOrderbook({
602
+ * offset: '0',
603
+ * limit: '10'
604
+ * });
605
+ *
606
+ * if (isLoading) return <div>Loading orderbook...</div>;
607
+ * if (error) return <div>Error: {error.message}</div>;
608
+ * if (orderbook) {
609
+ * console.log('Total intents:', orderbook.total);
610
+ * console.log('Intents:', orderbook.data);
611
+ * }
612
+ * ```
613
+ *
614
+ * @remarks
615
+ * - The query is disabled when params are undefined or invalid
616
+ * - Uses React Query for efficient caching and state management
617
+ * - Automatically handles error states and loading indicators
618
+ * - Stale time of 30 seconds for real-time orderbook data
619
+ * - Supports pagination through offset and limit parameters
620
+ */
621
+ declare const useBackendOrderbook: (params: {
622
+ offset: string;
623
+ limit: string;
624
+ } | undefined) => UseQueryResult<OrderbookResponse | undefined>;
625
+
626
+ /**
627
+ * Hook for fetching money market position for a specific user from the backend API.
628
+ *
629
+ * This hook provides access to a user's money market positions, including their
630
+ * aToken balances, variable debt token balances, and associated reserve information.
631
+ * The data is automatically fetched and cached using React Query.
632
+ *
633
+ * @param {string | undefined} userAddress - The user's wallet address. If undefined, the query will be disabled.
634
+ *
635
+ * @returns {UseQueryResult<MoneyMarketPosition | undefined>} A query result object containing:
636
+ * - data: The money market position data when available
637
+ * - isLoading: Boolean indicating if the request is in progress
638
+ * - error: Error object if the request failed
639
+ * - refetch: Function to manually trigger a data refresh
640
+ *
641
+ * @example
642
+ * ```typescript
643
+ * const { data: position, isLoading, error } = useMoneyMarketPosition('0x123...');
644
+ *
645
+ * if (isLoading) return <div>Loading position...</div>;
646
+ * if (error) return <div>Error: {error.message}</div>;
647
+ * if (position) {
648
+ * console.log('User address:', position.userAddress);
649
+ * console.log('Positions:', position.positions);
650
+ * }
651
+ * ```
652
+ *
653
+ * @remarks
654
+ * - The query is disabled when userAddress is undefined or empty
655
+ * - Uses React Query for efficient caching and state management
656
+ * - Automatically handles error states and loading indicators
657
+ * - Includes user's aToken and debt token balances across all reserves
658
+ */
659
+ declare const useBackendMoneyMarketPosition: (userAddress: string | undefined) => UseQueryResult<MoneyMarketPosition | undefined>;
660
+
661
+ /**
662
+ * Hook for fetching all money market assets from the backend API.
663
+ *
664
+ * This hook provides access to all available money market assets, including
665
+ * their reserve information, liquidity rates, borrow rates, and market statistics.
666
+ * The data is automatically fetched and cached using React Query.
667
+ *
668
+ * @returns {UseQueryResult<MoneyMarketAsset[]>} A query result object containing:
669
+ * - data: Array of money market asset data when available
670
+ * - isLoading: Boolean indicating if the request is in progress
671
+ * - error: Error object if the request failed
672
+ * - refetch: Function to manually trigger a data refresh
673
+ *
674
+ * @example
675
+ * ```typescript
676
+ * const { data: assets, isLoading, error } = useAllMoneyMarketAssets();
677
+ *
678
+ * if (isLoading) return <div>Loading assets...</div>;
679
+ * if (error) return <div>Error: {error.message}</div>;
680
+ * if (assets) {
681
+ * console.log('Total assets:', assets.length);
682
+ * assets.forEach(asset => {
683
+ * console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);
684
+ * });
685
+ * }
686
+ * ```
687
+ *
688
+ * @remarks
689
+ * - Uses React Query for efficient caching and state management
690
+ * - Automatically handles error states and loading indicators
691
+ * - Returns comprehensive asset information including rates and statistics
692
+ * - No parameters required - fetches all available assets
693
+ */
694
+ declare const useBackendAllMoneyMarketAssets: () => UseQueryResult<MoneyMarketAsset[]>;
695
+
696
+ /**
697
+ * Hook for fetching specific money market asset details from the backend API.
698
+ *
699
+ * This hook provides access to detailed information for a specific money market asset,
700
+ * including reserve information, liquidity rates, borrow rates, and market statistics.
701
+ * The data is automatically fetched and cached using React Query.
702
+ *
703
+ * @param {string | undefined} reserveAddress - The reserve contract address. If undefined, the query will be disabled.
704
+ *
705
+ * @returns {UseQueryResult<MoneyMarketAsset | undefined>} A query result object containing:
706
+ * - data: The money market asset data when available
707
+ * - isLoading: Boolean indicating if the request is in progress
708
+ * - error: Error object if the request failed
709
+ * - refetch: Function to manually trigger a data refresh
710
+ *
711
+ * @example
712
+ * ```typescript
713
+ * const { data: asset, isLoading, error } = useMoneyMarketAsset('0xabc...');
714
+ *
715
+ * if (isLoading) return <div>Loading asset...</div>;
716
+ * if (error) return <div>Error: {error.message}</div>;
717
+ * if (asset) {
718
+ * console.log('Asset symbol:', asset.symbol);
719
+ * console.log('Liquidity rate:', asset.liquidityRate);
720
+ * console.log('Variable borrow rate:', asset.variableBorrowRate);
721
+ * }
722
+ * ```
723
+ *
724
+ * @remarks
725
+ * - The query is disabled when reserveAddress is undefined or empty
726
+ * - Uses React Query for efficient caching and state management
727
+ * - Automatically handles error states and loading indicators
728
+ * - Returns comprehensive asset information for the specified reserve
729
+ */
730
+ declare const useBackendMoneyMarketAsset: (reserveAddress: string | undefined) => UseQueryResult<MoneyMarketAsset | undefined>;
731
+
732
+ /**
733
+ * Hook for fetching borrowers for a specific money market asset from the backend API.
734
+ *
735
+ * This hook provides access to the list of borrowers for a specific money market asset,
736
+ * with pagination support. The data is automatically fetched and cached using React Query.
737
+ *
738
+ * @param {Object} params - Parameters for fetching asset borrowers
739
+ * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.
740
+ * @param {string} params.offset - The offset for pagination (number as string)
741
+ * @param {string} params.limit - The limit for pagination (number as string)
742
+ *
743
+ * @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:
744
+ * - data: The asset borrowers data when available
745
+ * - isLoading: Boolean indicating if the request is in progress
746
+ * - error: Error object if the request failed
747
+ * - refetch: Function to manually trigger a data refresh
748
+ *
749
+ * @example
750
+ * ```typescript
751
+ * const { data: borrowers, isLoading, error } = useMoneyMarketAssetBorrowers({
752
+ * reserveAddress: '0xabc...',
753
+ * offset: '0',
754
+ * limit: '20'
755
+ * });
756
+ *
757
+ * if (isLoading) return <div>Loading borrowers...</div>;
758
+ * if (error) return <div>Error: {error.message}</div>;
759
+ * if (borrowers) {
760
+ * console.log('Total borrowers:', borrowers.total);
761
+ * console.log('Borrowers:', borrowers.borrowers);
762
+ * }
763
+ * ```
764
+ *
765
+ * @remarks
766
+ * - The query is disabled when reserveAddress is undefined or empty
767
+ * - Uses React Query for efficient caching and state management
768
+ * - Automatically handles error states and loading indicators
769
+ * - Supports pagination through offset and limit parameters
770
+ */
771
+ declare const useBackendMoneyMarketAssetBorrowers: (params: {
772
+ reserveAddress: string | undefined;
773
+ offset: string;
774
+ limit: string;
775
+ }) => UseQueryResult<MoneyMarketAssetBorrowers | undefined>;
776
+
777
+ /**
778
+ * Hook for fetching suppliers for a specific money market asset from the backend API.
779
+ *
780
+ * This hook provides access to the list of suppliers for a specific money market asset,
781
+ * with pagination support. The data is automatically fetched and cached using React Query.
782
+ *
783
+ * @param {Object} params - Parameters for fetching asset suppliers
784
+ * @param {string | undefined} params.reserveAddress - The reserve contract address. If undefined, the query will be disabled.
785
+ * @param {string} params.offset - The offset for pagination (number as string)
786
+ * @param {string} params.limit - The limit for pagination (number as string)
787
+ *
788
+ * @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>} A query result object containing:
789
+ * - data: The asset suppliers data when available
790
+ * - isLoading: Boolean indicating if the request is in progress
791
+ * - error: Error object if the request failed
792
+ * - refetch: Function to manually trigger a data refresh
793
+ *
794
+ * @example
795
+ * ```typescript
796
+ * const { data: suppliers, isLoading, error } = useMoneyMarketAssetSuppliers({
797
+ * reserveAddress: '0xabc...',
798
+ * offset: '0',
799
+ * limit: '20'
800
+ * });
801
+ *
802
+ * if (isLoading) return <div>Loading suppliers...</div>;
803
+ * if (error) return <div>Error: {error.message}</div>;
804
+ * if (suppliers) {
805
+ * console.log('Total suppliers:', suppliers.total);
806
+ * console.log('Suppliers:', suppliers.suppliers);
807
+ * }
808
+ * ```
809
+ *
810
+ * @remarks
811
+ * - The query is disabled when reserveAddress is undefined or empty
812
+ * - Uses React Query for efficient caching and state management
813
+ * - Automatically handles error states and loading indicators
814
+ * - Supports pagination through offset and limit parameters
815
+ */
816
+ declare const useBackendMoneyMarketAssetSuppliers: (params: {
817
+ reserveAddress: string | undefined;
818
+ offset: string;
819
+ limit: string;
820
+ }) => UseQueryResult<MoneyMarketAssetSuppliers | undefined>;
821
+
822
+ /**
823
+ * Hook for fetching all money market borrowers from the backend API.
824
+ *
825
+ * This hook provides access to the list of all borrowers across all money market assets,
826
+ * with pagination support. The data is automatically fetched and cached using React Query.
827
+ *
828
+ * @param {Object} params - Pagination parameters for fetching all borrowers
829
+ * @param {string} params.offset - The offset for pagination (number as string)
830
+ * @param {string} params.limit - The limit for pagination (number as string)
831
+ *
832
+ * @returns {UseQueryResult<MoneyMarketBorrowers | undefined>} A query result object containing:
833
+ * - data: The all borrowers data when available
834
+ * - isLoading: Boolean indicating if the request is in progress
835
+ * - error: Error object if the request failed
836
+ * - refetch: Function to manually trigger a data refresh
837
+ *
838
+ * @example
839
+ * ```typescript
840
+ * const { data: borrowers, isLoading, error } = useAllMoneyMarketBorrowers({
841
+ * offset: '0',
842
+ * limit: '50'
843
+ * });
844
+ *
845
+ * if (isLoading) return <div>Loading borrowers...</div>;
846
+ * if (error) return <div>Error: {error.message}</div>;
847
+ * if (borrowers) {
848
+ * console.log('Total borrowers:', borrowers.total);
849
+ * console.log('Borrowers:', borrowers.borrowers);
850
+ * }
851
+ * ```
852
+ *
853
+ * @remarks
854
+ * - The query is disabled when params are undefined or invalid
855
+ * - Uses React Query for efficient caching and state management
856
+ * - Automatically handles error states and loading indicators
857
+ * - Supports pagination through offset and limit parameters
858
+ * - Returns borrowers across all money market assets
859
+ */
860
+ declare const useBackendAllMoneyMarketBorrowers: (params: {
861
+ offset: string;
862
+ limit: string;
863
+ } | undefined) => UseQueryResult<MoneyMarketBorrowers | undefined>;
864
+
865
+ /**
866
+ * Hook for checking token allowance for bridge operations.
867
+ *
868
+ * This hook verifies if the user has approved enough tokens for a specific bridge action.
869
+ * It automatically queries and tracks the allowance status.
870
+ *
871
+ * @param {BridgeParams} params - The parameters for the bridge to check allowance for.
872
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
873
+ *
874
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
875
+ * - data: Boolean indicating if allowance is sufficient
876
+ * - isLoading: Loading state indicator
877
+ * - error: Any error that occurred during the check
878
+ *
879
+ * @example
880
+ * ```typescript
881
+ * const { data: hasAllowed, isLoading } = useBridgeAllowance(params, spokeProvider);
882
+ * ```
883
+ */
884
+ declare function useBridgeAllowance(params: CreateBridgeIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
885
+
886
+ interface UseBridgeApproveReturn {
887
+ approve: (params: CreateBridgeIntentParams) => Promise<boolean>;
888
+ isLoading: boolean;
889
+ error: Error | null;
890
+ resetError: () => void;
891
+ }
892
+ /**
893
+ * Hook for approving token spending for bridge actions
894
+ * @param spokeProvider The spoke provider instance for the chain
895
+ * @returns Object containing approve function, loading state, error state and reset function
896
+ * @example
897
+ * ```tsx
898
+ * const { approve, isLoading, error } = useBridgeApprove(spokeProvider);
899
+ *
900
+ * // Approve tokens for bridge action
901
+ * await approve({
902
+ * srcChainId: '0x2105.base',
903
+ * srcAsset: '0x...',
904
+ * amount: 1000n,
905
+ * dstChainId: '0x89.polygon',
906
+ * dstAsset: '0x...',
907
+ * recipient: '0x...'
908
+ * });
909
+ * ```
910
+ */
911
+ declare function useBridgeApprove(spokeProvider: SpokeProvider | undefined): UseBridgeApproveReturn;
912
+
913
+ /**
914
+ * Hook for executing bridge transactions to transfer tokens between chains.
915
+ * Uses React Query's useMutation for better state management and caching.
916
+ *
917
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the bridge
918
+ * @returns {UseMutationResult} Mutation result object containing mutation function and state
919
+ *
920
+ * @example
921
+ * ```typescript
922
+ * const { mutateAsync: bridge, isPending } = useBridge(spokeProvider);
923
+ *
924
+ * const handleBridge = async () => {
925
+ * const result = await bridge({
926
+ * srcChainId: '0x2105.base',
927
+ * srcAsset: '0x...',
928
+ * amount: 1000n,
929
+ * dstChainId: '0x89.polygon',
930
+ * dstAsset: '0x...',
931
+ * recipient: '0x...'
932
+ * });
933
+ *
934
+ * console.log('Bridge transaction hashes:', {
935
+ * spokeTxHash: result.spokeTxHash,
936
+ * hubTxHash: result.hubTxHash
937
+ * });
938
+ * };
939
+ * ```
940
+ */
941
+ declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutationResult<Result<[SpokeTxHash, HubTxHash], BridgeError<BridgeErrorCode>>, Error, CreateBridgeIntentParams>;
942
+
943
+ /**
944
+ * Hook for getting the amount available to be bridged.
945
+ *
946
+ * This hook is used to check if a target chain has enough balance to bridge when bridging.
947
+ * It automatically queries and tracks the available amount to be bridged.
948
+ *
949
+ * @param {SpokeChainId | undefined} chainId - The chain ID to get the balance for
950
+ * @param {string | undefined} token - The token address to get the balance for
951
+ *
952
+ * @returns {UseQueryResult<bigint, Error>} A React Query result containing:
953
+ * - data: The available amount to be bridged (bigint)
954
+ * - error: Any error that occurred during the check
955
+ *
956
+ * @example
957
+ * ```typescript
958
+ * const { data: balance, isLoading } = useSpokeAssetManagerTokenBalance(chainId, tokenAddress);
959
+ *
960
+ * if (balance) {
961
+ * console.log('Asset manager token balance:', balance.toString());
962
+ * }
963
+ * ```
964
+ */
965
+ declare function useGetBridgeableAmount(from: XToken$1 | undefined, to: XToken$1 | undefined): UseQueryResult<bigint, Error>;
966
+
967
+ /**
968
+ /**
969
+ * Hook for retrieving all bridgeable tokens from a source token on one chain to a destination chain.
970
+ *
971
+ * This hook queries and tracks the set of tokens on the destination chain that can be bridged to,
972
+ * given a source chain, destination chain, and source token address.
973
+ *
974
+ * @param {SpokeChainId | undefined} from - The source chain ID
975
+ * @param {SpokeChainId | undefined} to - The destination chain ID
976
+ * @param {string | undefined} token - The source token address
977
+ *
978
+ * @returns {UseQueryResult<XToken[], Error>} A React Query result containing:
979
+ * - data: Array of bridgeable tokens (XToken[]) on the destination chain
980
+ * - error: Any error that occurred during the query
981
+ *
982
+ *
983
+ * @example
984
+ * ```typescript
985
+ * const { data: bridgeableTokens, isLoading } = useGetBridgeableTokens(
986
+ * fromChainId,
987
+ * toChainId,
988
+ * fromTokenAddress
989
+ * );
990
+ *
991
+ * if (bridgeableTokens && bridgeableTokens.length > 0) {
992
+ * bridgeableTokens.forEach(token => {
993
+ * console.log(`Bridgeable token: ${token.symbol} (${token.address}) on chain ${token.xChainId}`);
994
+ * });
995
+ * } else {
996
+ * console.log('No bridgeable tokens found for the selected route.');
997
+ * }
998
+ * ```
999
+ */
1000
+ declare function useGetBridgeableTokens(from: SpokeChainId | undefined, to: SpokeChainId | undefined, token: string | undefined): UseQueryResult<XToken$1[], Error>;
1001
+
1002
+ /**
1003
+ * Hook for executing stake transactions to stake SODA tokens and receive xSODA shares.
1004
+ * Uses React Query's useMutation for better state management and caching.
1005
+ *
1006
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the stake
1007
+ * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, StakeParams>} Mutation result object containing mutation function and state
1008
+ *
1009
+ * @example
1010
+ * ```typescript
1011
+ * const { mutateAsync: stake, isPending } = useStake(spokeProvider);
1012
+ *
1013
+ * const handleStake = async () => {
1014
+ * const result = await stake({
1015
+ * amount: 1000000000000000000n, // 1 SODA
1016
+ * account: '0x...'
1017
+ * });
1018
+ *
1019
+ * console.log('Stake successful:', result);
1020
+ * };
1021
+ * ```
1022
+ */
1023
+ declare function useStake(spokeProvider: SpokeProvider | undefined): UseMutationResult<[SpokeTxHash, HubTxHash], Error, StakeParams>;
1024
+
1025
+ /**
1026
+ * Hook for approving SODA token spending for staking operations.
1027
+ * Uses React Query's useMutation for better state management and caching.
1028
+ *
1029
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval
1030
+ * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>>} Mutation result object containing mutation function and state
1031
+ *
1032
+ * @example
1033
+ * ```typescript
1034
+ * const { mutateAsync: approve, isPending } = useStakeApprove(spokeProvider);
1035
+ *
1036
+ * const handleApprove = async () => {
1037
+ * const result = await approve({
1038
+ * amount: 1000000000000000000n, // 1 SODA
1039
+ * account: '0x...'
1040
+ * });
1041
+ *
1042
+ * console.log('Approval successful:', result);
1043
+ * };
1044
+ * ```
1045
+ */
1046
+ declare function useStakeApprove(spokeProvider: SpokeProvider | undefined): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<StakeParams, 'action'>>;
1047
+
1048
+ /**
1049
+ * Hook for checking SODA token allowance for staking operations.
1050
+ * Uses React Query for efficient caching and state management.
1051
+ *
1052
+ * @param {Omit<StakeParams, 'action'> | undefined} params - The staking parameters. If undefined, the query will be disabled.
1053
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check
1054
+ * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state
1055
+ *
1056
+ * @example
1057
+ * ```typescript
1058
+ * const { data: hasAllowed, isLoading } = useStakeAllowance(
1059
+ * {
1060
+ * amount: 1000000000000000000n, // 1 SODA
1061
+ * account: '0x...'
1062
+ * },
1063
+ * spokeProvider
1064
+ * );
1065
+ *
1066
+ * if (isLoading) return <div>Checking allowance...</div>;
1067
+ * if (hasAllowed) {
1068
+ * console.log('Sufficient allowance for staking');
1069
+ * }
1070
+ * ```
1071
+ */
1072
+ declare function useStakeAllowance(params: Omit<StakeParams, 'action'> | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
1073
+
1074
+ /**
1075
+ * Hook for executing unstake transactions to unstake xSODA shares.
1076
+ * Uses React Query's useMutation for better state management and caching.
1077
+ *
1078
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the unstake
1079
+ * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state
1080
+ *
1081
+ * @example
1082
+ * ```typescript
1083
+ * const { mutateAsync: unstake, isPending } = useUnstake(spokeProvider);
1084
+ *
1085
+ * const handleUnstake = async () => {
1086
+ * const result = await unstake({
1087
+ * amount: 1000000000000000000n, // 1 xSODA
1088
+ * account: '0x...'
1089
+ * });
1090
+ *
1091
+ * console.log('Unstake successful:', result);
1092
+ * };
1093
+ * ```
1094
+ */
1095
+ declare function useUnstake(spokeProvider: SpokeProvider | undefined): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<UnstakeParams, 'action'>>;
1096
+
1097
+ /**
1098
+ * Hook for executing claim transactions to claim unstaked SODA tokens after the unstaking period.
1099
+ * Uses React Query's useMutation for better state management and caching.
1100
+ *
1101
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the claim
1102
+ * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>>} Mutation result object containing mutation function and state
1103
+ *
1104
+ * @example
1105
+ * ```typescript
1106
+ * const { mutateAsync: claim, isPending } = useClaim(spokeProvider);
1107
+ *
1108
+ * const handleClaim = async () => {
1109
+ * const result = await claim({
1110
+ * requestId: 1n
1111
+ * });
1112
+ *
1113
+ * console.log('Claim successful:', result);
1114
+ * };
1115
+ * ```
1116
+ */
1117
+ declare function useClaim(spokeProvider: SpokeProvider | undefined): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<ClaimParams, 'action'>>;
1118
+
1119
+ /**
1120
+ * Hook for executing cancel unstake transactions to cancel pending unstake requests.
1121
+ * Uses React Query's useMutation for better state management and caching.
1122
+ *
1123
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the cancel unstake
1124
+ * @returns {UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<CancelUnstakeParams, 'action'>>} Mutation result object containing mutation function and state
1125
+ *
1126
+ * @example
1127
+ * ```typescript
1128
+ * const { mutateAsync: cancelUnstake, isPending } = useCancelUnstake(spokeProvider);
1129
+ *
1130
+ * const handleCancelUnstake = async () => {
1131
+ * const result = await cancelUnstake({
1132
+ * requestId: 1n
1133
+ * });
1134
+ *
1135
+ * console.log('Cancel unstake successful:', result);
1136
+ * };
1137
+ * ```
1138
+ */
1139
+ declare function useCancelUnstake(spokeProvider: SpokeProvider | undefined): UseMutationResult<[SpokeTxHash, HubTxHash], Error, Omit<CancelUnstakeParams, 'action'>>;
1140
+
1141
+ /**
1142
+ * Hook for fetching comprehensive staking information for a user.
1143
+ * Uses React Query for efficient caching and state management.
1144
+ *
1145
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the query
1146
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)
1147
+ * @returns {UseQueryResult<StakingInfo, Error>} Query result object containing staking info and state
1148
+ *
1149
+ * @example
1150
+ * ```typescript
1151
+ * const { data: stakingInfo, isLoading, error } = useStakingInfo(spokeProvider);
1152
+ *
1153
+ * if (isLoading) return <div>Loading staking info...</div>;
1154
+ * if (stakingInfo) {
1155
+ * console.log('Total staked:', stakingInfo.totalStaked);
1156
+ * console.log('User staked:', stakingInfo.userStaked);
1157
+ * console.log('xSODA balance:', stakingInfo.userXSodaBalance);
1158
+ * }
1159
+ * ```
1160
+ */
1161
+ declare function useStakingInfo(spokeProvider: SpokeProvider | undefined, refetchInterval?: number): UseQueryResult<StakingInfo, Error>;
1162
+
1163
+ type UnstakingInfoWithPenalty = UnstakingInfo & {
1164
+ requestsWithPenalty: UnstakeRequestWithPenalty[];
1165
+ };
1166
+ /**
1167
+ * Hook for fetching unstaking information with penalty calculations from the stakedSoda contract.
1168
+ * Uses React Query for efficient caching and state management.
1169
+ *
1170
+ * @param {string | undefined} userAddress - The user address to fetch unstaking info for
1171
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance
1172
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)
1173
+ * @returns {UseQueryResult<UnstakingInfoWithPenalty, Error>} Query result object containing unstaking info with penalties and state
1174
+ *
1175
+ * @example
1176
+ * ```typescript
1177
+ * const { data: unstakingInfo, isLoading, error } = useUnstakingInfoWithPenalty(userAddress, spokeProvider);
1178
+ *
1179
+ * if (isLoading) return <div>Loading unstaking info...</div>;
1180
+ * if (unstakingInfo) {
1181
+ * console.log('Total unstaking:', unstakingInfo.totalUnstaking);
1182
+ * unstakingInfo.requestsWithPenalty.forEach(request => {
1183
+ * console.log('Penalty:', request.penaltyPercentage + '%');
1184
+ * console.log('Claimable amount:', request.claimableAmount);
1185
+ * });
1186
+ * }
1187
+ * ```
1188
+ */
1189
+ declare function useUnstakingInfoWithPenalty(userAddress: string | undefined, spokeProvider: SpokeProvider | undefined, refetchInterval?: number): UseQueryResult<UnstakingInfoWithPenalty, Error>;
1190
+
1191
+ /**
1192
+ * Hook for fetching staking configuration from the stakedSoda contract.
1193
+ * Uses React Query for efficient caching and state management.
1194
+ *
1195
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 30000)
1196
+ * @returns {UseQueryResult<StakingConfig, Error>} Query result object containing staking config and state
1197
+ *
1198
+ * @example
1199
+ * ```typescript
1200
+ * const { data: stakingConfig, isLoading, error } = useStakingConfig();
1201
+ *
1202
+ * if (isLoading) return <div>Loading staking config...</div>;
1203
+ * if (stakingConfig) {
1204
+ * console.log('Unstaking period (days):', stakingConfig.unstakingPeriod / 86400n);
1205
+ * console.log('Max penalty (%):', stakingConfig.maxPenalty);
1206
+ * }
1207
+ * ```
1208
+ */
1209
+ declare function useStakingConfig(refetchInterval?: number): UseQueryResult<StakingConfig, Error>;
1210
+
1211
+ /**
1212
+ * Hook for fetching stake ratio estimates (xSoda amount and preview deposit).
1213
+ * Uses React Query for efficient caching and state management.
1214
+ *
1215
+ * @param {bigint | undefined} amount - The amount of SODA to estimate stake for
1216
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)
1217
+ * @returns {UseQueryResult<[bigint, bigint], Error>} Query result object containing stake ratio estimates and state
1218
+ *
1219
+ * @example
1220
+ * ```typescript
1221
+ * const { data: stakeRatio, isLoading, error } = useStakeRatio(1000000000000000000n); // 1 SODA
1222
+ *
1223
+ * if (isLoading) return <div>Loading stake ratio...</div>;
1224
+ * if (stakeRatio) {
1225
+ * const [xSodaAmount, previewDepositAmount] = stakeRatio;
1226
+ * console.log('xSoda amount:', xSodaAmount);
1227
+ * console.log('Preview deposit:', previewDepositAmount);
1228
+ * }
1229
+ * ```
1230
+ */
1231
+ declare function useStakeRatio(amount: bigint | undefined, refetchInterval?: number): UseQueryResult<[bigint, bigint], Error>;
1232
+
1233
+ /**
1234
+ * Hook for fetching instant unstake ratio estimates.
1235
+ * Uses React Query for efficient caching and state management.
1236
+ *
1237
+ * @param {bigint | undefined} amount - The amount of xSoda to estimate instant unstake for
1238
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)
1239
+ * @returns {UseQueryResult<bigint, Error>} Query result object containing instant unstake ratio and state
1240
+ *
1241
+ * @example
1242
+ * ```typescript
1243
+ * const { data: instantUnstakeRatio, isLoading, error } = useInstantUnstakeRatio(1000000000000000000n); // 1 xSoda
1244
+ *
1245
+ * if (isLoading) return <div>Loading instant unstake ratio...</div>;
1246
+ * if (instantUnstakeRatio) {
1247
+ * console.log('Instant unstake ratio:', instantUnstakeRatio);
1248
+ * }
1249
+ * ```
1250
+ */
1251
+ declare function useInstantUnstakeRatio(amount: bigint | undefined, refetchInterval?: number): UseQueryResult<bigint, Error>;
1252
+
1253
+ /**
1254
+ * Hook for fetching converted assets amount for xSODA shares.
1255
+ * Uses React Query for efficient caching and state management.
1256
+ *
1257
+ * @param {bigint | undefined} amount - The amount of xSODA shares to convert
1258
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 10000)
1259
+ * @returns {UseQueryResult<bigint, Error>} Query result object containing converted assets amount and state
1260
+ *
1261
+ * @example
1262
+ * ```typescript
1263
+ * const { data: convertedAssets, isLoading, error } = useConvertedAssets(1000000000000000000n); // 1 xSODA
1264
+ *
1265
+ * if (isLoading) return <div>Loading converted assets...</div>;
1266
+ * if (convertedAssets) {
1267
+ * console.log('Converted assets:', convertedAssets);
1268
+ * }
1269
+ * ```
1270
+ */
1271
+ declare function useConvertedAssets(amount: bigint | undefined, refetchInterval?: number): UseQueryResult<bigint, Error>;
1272
+
1273
+ /**
1274
+ * Hook for executing instant unstake operations.
1275
+ * Uses React Query for efficient state management and error handling.
1276
+ *
1277
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider for the transaction
1278
+ * @returns {UseMutationResult<[string, string], Error, Omit<InstantUnstakeParams, 'action'>>} Mutation result object containing instant unstake state and methods
1279
+ *
1280
+ * @example
1281
+ * ```typescript
1282
+ * const { mutateAsync: instantUnstake, isPending } = useInstantUnstake(spokeProvider);
1283
+ *
1284
+ * const handleInstantUnstake = async () => {
1285
+ * const result = await instantUnstake({
1286
+ * amount: 1000000000000000000n,
1287
+ * minAmount: 950000000000000000n,
1288
+ * account: '0x...'
1289
+ * });
1290
+ * console.log('Instant unstake successful:', result);
1291
+ * };
1292
+ * ```
1293
+ */
1294
+ declare function useInstantUnstake(spokeProvider: SpokeProvider | undefined): UseMutationResult<[string, string], Error, Omit<InstantUnstakeParams, 'action'>>;
1295
+
1296
+ /**
1297
+ * Hook for checking xSODA token allowance for unstaking operations.
1298
+ * Uses React Query for efficient caching and state management.
1299
+ *
1300
+ * @param {Omit<UnstakeParams, 'action'> | undefined} params - The unstaking parameters. If undefined, the query will be disabled.
1301
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check
1302
+ * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state
1303
+ *
1304
+ * @example
1305
+ * ```typescript
1306
+ * const { data: hasAllowed, isLoading } = useUnstakeAllowance(
1307
+ * {
1308
+ * amount: 1000000000000000000n, // 1 xSODA
1309
+ * account: '0x...'
1310
+ * },
1311
+ * spokeProvider
1312
+ * );
1313
+ *
1314
+ * if (isLoading) return <div>Checking allowance...</div>;
1315
+ * if (hasAllowed) {
1316
+ * console.log('Sufficient allowance for unstaking');
1317
+ * }
1318
+ * ```
1319
+ */
1320
+ declare function useUnstakeAllowance(params: Omit<UnstakeParams, 'action'> | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
1321
+
1322
+ /**
1323
+ * Hook for approving xSODA token spending for unstaking operations.
1324
+ * Uses React Query's useMutation for better state management and caching.
1325
+ *
1326
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval
1327
+ * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>} Mutation result object containing mutation function and state
1328
+ *
1329
+ * @example
1330
+ * ```typescript
1331
+ * const { mutateAsync: approve, isPending } = useUnstakeApprove(spokeProvider);
1332
+ *
1333
+ * const handleApprove = async () => {
1334
+ * const result = await approve({
1335
+ * amount: 1000000000000000000n, // 1 xSODA
1336
+ * account: '0x...'
1337
+ * });
1338
+ *
1339
+ * console.log('Approval successful:', result);
1340
+ * };
1341
+ * ```
1342
+ */
1343
+ declare function useUnstakeApprove(spokeProvider: SpokeProvider | undefined): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<UnstakeParams, 'action'>>;
1344
+
1345
+ /**
1346
+ * Hook for fetching unstaking information from the stakedSoda contract.
1347
+ * Uses React Query for efficient caching and state management.
1348
+ *
1349
+ * @param {string | undefined} userAddress - The user address to fetch unstaking info for
1350
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider instance
1351
+ * @param {number} refetchInterval - The interval in milliseconds to refetch data (default: 5000)
1352
+ * @returns {UseQueryResult<UnstakingInfo, Error>} Query result object containing unstaking info and state
1353
+ *
1354
+ * @example
1355
+ * ```typescript
1356
+ * const { data: unstakingInfo, isLoading, error } = useUnstakingInfo(userAddress, spokeProvider);
1357
+ *
1358
+ * if (isLoading) return <div>Loading unstaking info...</div>;
1359
+ * if (unstakingInfo) {
1360
+ * console.log('Total unstaking:', unstakingInfo.totalUnstaking);
1361
+ * unstakingInfo.userUnstakeSodaRequests.forEach(request => {
1362
+ * console.log('Request amount:', request.request.amount);
1363
+ * });
1364
+ * }
1365
+ * ```
1366
+ */
1367
+ declare function useUnstakingInfo(userAddress: string | undefined, spokeProvider: SpokeProvider | undefined, refetchInterval?: number): UseQueryResult<UnstakingInfo, Error>;
1368
+
1369
+ /**
1370
+ * Hook for approving xSODA token spending for instant unstaking operations.
1371
+ * Uses React Query's useMutation for better state management and caching.
1372
+ *
1373
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the approval
1374
+ * @returns {UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>>} Mutation result object containing mutation function and state
1375
+ *
1376
+ * @example
1377
+ * ```typescript
1378
+ * const { mutateAsync: approve, isPending } = useInstantUnstakeApprove(spokeProvider);
1379
+ *
1380
+ * const handleApprove = async () => {
1381
+ * const result = await approve({
1382
+ * amount: 1000000000000000000n, // 1 xSODA
1383
+ * minAmount: 950000000000000000n, // 0.95 SODA
1384
+ * account: '0x...'
1385
+ * });
1386
+ *
1387
+ * console.log('Approval successful:', result);
1388
+ * };
1389
+ * ```
1390
+ */
1391
+ declare function useInstantUnstakeApprove(spokeProvider: SpokeProvider | undefined): UseMutationResult<TxReturnType<SpokeProvider, false>, Error, Omit<InstantUnstakeParams, 'action'>>;
1392
+
1393
+ /**
1394
+ * Hook for checking xSODA token allowance for instant unstaking operations.
1395
+ * Uses React Query for efficient caching and state management.
1396
+ *
1397
+ * @param {Omit<InstantUnstakeParams, 'action'> | undefined} params - The instant unstaking parameters. If undefined, the query will be disabled.
1398
+ * @param {SpokeProvider | undefined} spokeProvider - The spoke provider to use for the allowance check
1399
+ * @returns {UseQueryResult<boolean, Error>} Query result object containing allowance data and state
1400
+ *
1401
+ * @example
1402
+ * ```typescript
1403
+ * const { data: hasAllowed, isLoading } = useInstantUnstakeAllowance(
1404
+ * {
1405
+ * amount: 1000000000000000000n, // 1 xSODA
1406
+ * minAmount: 950000000000000000n, // 0.95 SODA
1407
+ * account: '0x...'
1408
+ * },
1409
+ * spokeProvider
1410
+ * );
1411
+ *
1412
+ * if (isLoading) return <div>Checking allowance...</div>;
1413
+ * if (hasAllowed) {
1414
+ * console.log('Sufficient allowance for instant unstaking');
1415
+ * }
1416
+ * ```
1417
+ */
1418
+ declare function useInstantUnstakeAllowance(params: Omit<InstantUnstakeParams, 'action'> | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
1419
+
1420
+ declare const MIGRATION_MODE_ICX_SODA = "icxsoda";
1421
+ declare const MIGRATION_MODE_BNUSD = "bnusd";
1422
+ type MigrationMode = typeof MIGRATION_MODE_ICX_SODA | typeof MIGRATION_MODE_BNUSD;
1423
+ interface MigrationIntentParams {
1424
+ token: XToken | undefined;
1425
+ amount: string | undefined;
1426
+ sourceAddress: string | undefined;
1427
+ migrationMode?: MigrationMode;
1428
+ toToken?: XToken;
1429
+ destinationAddress?: string;
1430
+ }
1431
+
1432
+ /**
1433
+ * Hook for executing migration operations between chains.
1434
+ *
1435
+ * This hook handles ICX/SODA and bnUSD migrations by accepting a spoke provider
1436
+ * and returning a mutation function that accepts migration parameters.
1437
+ *
1438
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for the migration
1439
+ * @returns {UseMutationResult} Mutation result object containing migration function and state
1440
+ *
1441
+ * @example
1442
+ * ```typescript
1443
+ * const { mutateAsync: migrate, isPending } = useMigrate(spokeProvider);
1444
+ *
1445
+ * const result = await migrate({
1446
+ * token: { address: "0x...", decimals: 18 },
1447
+ * amount: "100",
1448
+ * migrationMode: MIGRATION_MODE_ICX_SODA,
1449
+ * toToken: { address: "0x...", decimals: 18 },
1450
+ * destinationAddress: "0x..."
1451
+ * });
1452
+ * ```
1453
+ */
1454
+ declare function useMigrate(spokeProvider: SpokeProvider | undefined): UseMutationResult<{
1455
+ spokeTxHash: string;
1456
+ hubTxHash: `0x${string}`;
1457
+ }, Error, MigrationIntentParams>;
1458
+
1459
+ /**
1460
+ * Hook for checking token allowance for migration operations.
1461
+ *
1462
+ * This hook verifies if the user has approved enough tokens for migration operations.
1463
+ * It handles both ICX/SODA and bnUSD migration allowance checks.
1464
+ *
1465
+ * @param {MigrationIntentParams} params - The parameters for the migration allowance check
1466
+ * @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
1467
+ *
1468
+ * @returns {UseQueryResult<boolean, Error>} A React Query result containing:
1469
+ * - data: Boolean indicating if allowance is sufficient
1470
+ * - isLoading: Loading state indicator
1471
+ * - error: Any error that occurred during the check
1472
+ *
1473
+ * @example
1474
+ * ```typescript
1475
+ * const { data: hasAllowed, isLoading } = useMigrationAllowance(params, spokeProvider);
1476
+ * ```
1477
+ */
1478
+ declare function useMigrationAllowance(params: MigrationIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
1479
+
1480
+ interface UseApproveReturn {
1481
+ approve: ({ params }: {
1482
+ params: MigrationIntentParams;
1483
+ }) => Promise<boolean>;
1484
+ isLoading: boolean;
1485
+ error: Error | null;
1486
+ resetError: () => void;
1487
+ isApproved: boolean;
1488
+ }
1489
+ /**
1490
+ * Hook for approving token spending for migration actions
1491
+ * @param params The parameters for the migration approval
1492
+ * @param spokeProvider The spoke provider instance for the chain
1493
+ * @returns Object containing approve function, loading state, error state and reset function
1494
+ * @example
1495
+ * ```tsx
1496
+ * const { approve, isLoading, error } = useMigrationApprove(params, spokeProvider);
1497
+ *
1498
+ * // Approve tokens for migration
1499
+ * await approve({ params });
1500
+ * ```
1501
+ */
1502
+ declare function useMigrationApprove(params: MigrationIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn;
1503
+
1504
+ interface SodaxProviderProps {
1505
+ children: ReactNode;
1506
+ testnet?: boolean;
1507
+ config?: SodaxConfig;
1508
+ rpcConfig: RpcConfig;
1509
+ }
1510
+ declare const SodaxProvider: ({ children, testnet, config, rpcConfig }: SodaxProviderProps) => ReactElement;
1511
+
1512
+ declare const getSpokeTokenAddressByVault: (spokeChainId: ChainId, vault: string) => string | undefined;
1513
+
1514
+ export { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, getSpokeTokenAddressByVault, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserReservesData, useWithdraw };