@sodax/dapp-kit 1.0.1-beta → 1.0.3-beta
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/README.md +130 -39
- package/dist/index.d.mts +576 -346
- package/dist/index.d.ts +576 -346
- package/dist/index.js +357 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +354 -178
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/backend/README.md +148 -49
- package/src/hooks/backend/index.ts +2 -0
- package/src/hooks/backend/types.ts +4 -0
- package/src/hooks/backend/useBackendAllMoneyMarketAssets.ts +31 -20
- package/src/hooks/backend/useBackendAllMoneyMarketBorrowers.ts +25 -7
- package/src/hooks/backend/useBackendIntentByHash.ts +36 -26
- package/src/hooks/backend/useBackendIntentByTxHash.ts +41 -29
- package/src/hooks/backend/useBackendMoneyMarketAsset.ts +40 -27
- package/src/hooks/backend/useBackendMoneyMarketAssetBorrowers.ts +45 -36
- package/src/hooks/backend/useBackendMoneyMarketAssetSuppliers.ts +45 -36
- package/src/hooks/backend/useBackendMoneyMarketPosition.ts +34 -37
- package/src/hooks/backend/useBackendOrderbook.ts +38 -38
- package/src/hooks/backend/useBackendUserIntents.ts +81 -0
- package/src/hooks/mm/index.ts +2 -0
- package/src/hooks/mm/useAToken.ts +37 -20
- package/src/hooks/mm/useATokensBalances.ts +87 -0
- package/src/hooks/mm/useBorrow.ts +36 -36
- package/src/hooks/mm/useMMAllowance.ts +33 -24
- package/src/hooks/mm/useMMApprove.ts +43 -48
- package/src/hooks/mm/useRepay.ts +32 -36
- package/src/hooks/mm/useReservesData.ts +35 -16
- package/src/hooks/mm/useReservesHumanized.ts +15 -3
- package/src/hooks/mm/useReservesList.ts +28 -15
- package/src/hooks/mm/useReservesUsdFormat.ts +30 -21
- package/src/hooks/mm/useSupply.ts +34 -36
- package/src/hooks/mm/useUserFormattedSummary.ts +42 -20
- package/src/hooks/mm/useUserReservesData.ts +34 -19
- package/src/hooks/mm/useWithdraw.ts +33 -35
- package/src/hooks/swap/index.ts +2 -0
- package/src/hooks/swap/useCancelLimitOrder.ts +53 -0
- package/src/hooks/swap/useCreateLimitOrder.ts +72 -0
- package/src/hooks/swap/useSwapAllowance.ts +7 -7
- package/src/hooks/swap/useSwapApprove.ts +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
5
|
-
import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
|
|
1
|
+
import { Sodax, SpokeProvider, GetEstimateGasReturnType, TxReturnType, SpokeChainId, StellarSpokeProvider, EvmHubProvider, IWalletProvider, MoneyMarketBorrowParams, MoneyMarketError, RelayErrorCode, MoneyMarketRepayParams, MoneyMarketSupplyParams, MoneyMarketWithdrawParams, UserReserveData, AggregatedReserveData, BaseCurrencyInfo, MoneyMarketParams, XToken, ReserveData, FormatReserveUSDResponse, FormatUserSummaryResponse, SolverIntentQuoteRequest, Result, SolverIntentQuoteResponse, SolverErrorResponse, SolverExecutionResponse, Intent, IntentDeliveryInfo, IntentError, IntentErrorCode, CreateIntentParams, Hex, SolverIntentStatusResponse, CreateLimitOrderParams, IntentResponse, Address as Address$1, UserIntentsResponse, OrderbookResponse, MoneyMarketPosition, MoneyMarketAsset, MoneyMarketAssetBorrowers, MoneyMarketAssetSuppliers, MoneyMarketBorrowers, CreateBridgeIntentParams, SpokeTxHash, HubTxHash, BridgeError, BridgeErrorCode, StakeParams, UnstakeParams, ClaimParams, CancelUnstakeParams, StakingInfo, UnstakingInfo, UnstakeRequestWithPenalty, StakingConfig, InstantUnstakeParams, SodaxConfig } from '@sodax/sdk';
|
|
2
|
+
import { RpcConfig, SpokeChainId as SpokeChainId$1, XToken as XToken$1 } from '@sodax/types';
|
|
3
|
+
import { UseMutationResult, UseQueryResult, UseQueryOptions } from '@tanstack/react-query';
|
|
6
4
|
import { Address } from 'viem';
|
|
7
5
|
import { ReactNode, ReactElement } from 'react';
|
|
8
6
|
|
|
@@ -156,160 +154,196 @@ interface BorrowResponse {
|
|
|
156
154
|
ok: true;
|
|
157
155
|
value: [string, string];
|
|
158
156
|
}
|
|
157
|
+
type UseBorrowParams = {
|
|
158
|
+
params: MoneyMarketBorrowParams;
|
|
159
|
+
spokeProvider: SpokeProvider;
|
|
160
|
+
};
|
|
159
161
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* This hook provides functionality to borrow tokens from the money market protocol,
|
|
163
|
-
* handling the entire borrow process including transaction creation, submission,
|
|
164
|
-
* and cross-chain communication.
|
|
162
|
+
* React hook for borrowing tokens in the Sodax money market protocol.
|
|
165
163
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
164
|
+
* Encapsulates the async process to initiate a borrow transaction via the money market,
|
|
165
|
+
* handling transaction creation, submission, and cross-chain logic.
|
|
168
166
|
*
|
|
169
|
-
* @returns {UseMutationResult<
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
167
|
+
* @returns {UseMutationResult<
|
|
168
|
+
* BorrowResponse,
|
|
169
|
+
* MoneyMarketError<'CREATE_BORROW_INTENT_FAILED' | 'BORROW_UNKNOWN_ERROR' | RelayErrorCode>,
|
|
170
|
+
* UseBorrowParams
|
|
171
|
+
* >} A React Query mutation result object containing:
|
|
172
|
+
* - mutateAsync: (params: UseBorrowParams) => Promise<BorrowResponse>
|
|
173
|
+
* Triggers the borrow action. Expects an object with valid borrow params and a `SpokeProvider`.
|
|
174
|
+
* - isPending: `boolean` if a borrow transaction is in progress.
|
|
175
|
+
* - error: `MoneyMarketError` if the transaction fails, or `null`.
|
|
173
176
|
*
|
|
174
177
|
* @example
|
|
175
178
|
* ```typescript
|
|
176
|
-
* const { mutateAsync: borrow, isPending, error } = useBorrow(
|
|
177
|
-
* await borrow(
|
|
179
|
+
* const { mutateAsync: borrow, isPending, error } = useBorrow();
|
|
180
|
+
* await borrow({ params: borrowParams, spokeProvider });
|
|
178
181
|
* ```
|
|
179
182
|
*
|
|
180
183
|
* @throws {Error} When:
|
|
181
|
-
* - spokeProvider is
|
|
182
|
-
* -
|
|
184
|
+
* - `spokeProvider` is missing or invalid.
|
|
185
|
+
* - The underlying borrow transaction fails.
|
|
183
186
|
*/
|
|
184
|
-
declare function useBorrow(
|
|
187
|
+
declare function useBorrow(): UseMutationResult<BorrowResponse, MoneyMarketError<'CREATE_BORROW_INTENT_FAILED' | 'BORROW_UNKNOWN_ERROR' | RelayErrorCode>, UseBorrowParams>;
|
|
185
188
|
|
|
186
189
|
interface RepayResponse {
|
|
187
190
|
ok: true;
|
|
188
191
|
value: [string, string];
|
|
189
192
|
}
|
|
193
|
+
type UseRepayParams = {
|
|
194
|
+
params: MoneyMarketRepayParams;
|
|
195
|
+
spokeProvider: SpokeProvider;
|
|
196
|
+
};
|
|
190
197
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* This hook provides functionality to repay borrowed tokens back to the money market protocol,
|
|
194
|
-
* handling the entire repayment process including transaction creation, submission,
|
|
195
|
-
* and cross-chain communication.
|
|
198
|
+
* React hook for repaying a borrow in the Sodax money market protocol.
|
|
196
199
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
200
|
+
* This hook encapsulates the process of sending a repay transaction to the money market.
|
|
201
|
+
* It manages the asynchronous operation for repayment, including sending the transaction
|
|
202
|
+
* and error handling.
|
|
199
203
|
*
|
|
200
|
-
* @returns {UseMutationResult<RepayResponse,
|
|
201
|
-
* - mutateAsync:
|
|
202
|
-
*
|
|
203
|
-
* -
|
|
204
|
+
* @returns {UseMutationResult<RepayResponse, MoneyMarketError<'CREATE_REPAY_INTENT_FAILED' | 'REPAY_UNKNOWN_ERROR' | RelayErrorCode>, UseRepayParams>} React Query mutation result object containing:
|
|
205
|
+
* - mutateAsync: (params: UseRepayParams) => Promise<RepayResponse>
|
|
206
|
+
* Initiates a repay transaction using the given MoneyMarketRepayParams and SpokeProvider.
|
|
207
|
+
* - isPending: boolean indicating if a transaction is in progress.
|
|
208
|
+
* - error: MoneyMarketError if an error occurred while repaying, otherwise undefined.
|
|
204
209
|
*
|
|
205
210
|
* @example
|
|
206
211
|
* ```typescript
|
|
207
|
-
* const { mutateAsync: repay, isPending, error } = useRepay(
|
|
208
|
-
* await repay(
|
|
212
|
+
* const { mutateAsync: repay, isPending, error } = useRepay();
|
|
213
|
+
* await repay({ params: repayParams, spokeProvider });
|
|
209
214
|
* ```
|
|
210
215
|
*
|
|
211
216
|
* @throws {Error} When:
|
|
212
|
-
* - spokeProvider is
|
|
213
|
-
* -
|
|
217
|
+
* - `spokeProvider` is missing or invalid.
|
|
218
|
+
* - The underlying repay transaction fails.
|
|
214
219
|
*/
|
|
215
|
-
declare function useRepay(
|
|
220
|
+
declare function useRepay(): UseMutationResult<RepayResponse, MoneyMarketError<'CREATE_REPAY_INTENT_FAILED' | 'REPAY_UNKNOWN_ERROR' | RelayErrorCode>, UseRepayParams>;
|
|
216
221
|
|
|
217
222
|
interface SupplyResponse {
|
|
218
223
|
ok: true;
|
|
219
224
|
value: [string, string];
|
|
220
225
|
}
|
|
226
|
+
type UseSupplyParams = {
|
|
227
|
+
params: MoneyMarketSupplyParams;
|
|
228
|
+
spokeProvider: SpokeProvider;
|
|
229
|
+
};
|
|
221
230
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* This hook provides functionality to supply tokens to the money market protocol,
|
|
225
|
-
* handling the entire supply process including transaction creation, submission,
|
|
226
|
-
* and cross-chain communication.
|
|
231
|
+
* React hook for supplying tokens to the Sodax money market protocol.
|
|
227
232
|
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
233
|
+
* Provides a mutation for performing the supply operation using React Query. Useful
|
|
234
|
+
* for UI components needing to manage the full state (pending, error, etc.) of a supply
|
|
235
|
+
* transaction. It handles transaction creation, cross-chain logic, and errors.
|
|
230
236
|
*
|
|
231
|
-
* @returns {UseMutationResult<SupplyResponse,
|
|
232
|
-
*
|
|
233
|
-
* -
|
|
234
|
-
*
|
|
237
|
+
* @returns {UseMutationResult<SupplyResponse, MoneyMarketError<'CREATE_SUPPLY_INTENT_FAILED' | 'SUPPLY_UNKNOWN_ERROR' | RelayErrorCode>, UseSupplyParams>}
|
|
238
|
+
* Mutation result object from React Query, where:
|
|
239
|
+
* - mutateAsync(params: UseSupplyParams): Promise<SupplyResponse>
|
|
240
|
+
* Initiates a supply transaction using the given MoneyMarketSupplyParams and SpokeProvider.
|
|
241
|
+
* - isPending: boolean indicating if a transaction is in progress.
|
|
242
|
+
* - error: MoneyMarketError if an error occurred while supplying, otherwise undefined.
|
|
235
243
|
*
|
|
236
244
|
* @example
|
|
237
245
|
* ```typescript
|
|
238
|
-
* const { mutateAsync: supply, isPending, error } = useSupply(
|
|
239
|
-
* await supply(
|
|
246
|
+
* const { mutateAsync: supply, isPending, error } = useSupply();
|
|
247
|
+
* await supply({ params: supplyParams, spokeProvider });
|
|
240
248
|
* ```
|
|
241
249
|
*
|
|
242
|
-
* @throws {Error} When:
|
|
243
|
-
* - spokeProvider is not
|
|
250
|
+
* @throws {Error|MoneyMarketError<...>} When:
|
|
251
|
+
* - `spokeProvider` is not provided or invalid.
|
|
252
|
+
* - The underlying supply transaction fails.
|
|
244
253
|
*/
|
|
245
|
-
declare function useSupply(
|
|
254
|
+
declare function useSupply(): UseMutationResult<SupplyResponse, MoneyMarketError<'CREATE_SUPPLY_INTENT_FAILED' | 'SUPPLY_UNKNOWN_ERROR' | RelayErrorCode>, UseSupplyParams>;
|
|
246
255
|
|
|
256
|
+
type UseWithdrawParams = {
|
|
257
|
+
params: MoneyMarketWithdrawParams;
|
|
258
|
+
spokeProvider: SpokeProvider;
|
|
259
|
+
};
|
|
247
260
|
interface WithdrawResponse {
|
|
248
261
|
ok: true;
|
|
249
262
|
value: [string, string];
|
|
250
263
|
}
|
|
251
264
|
/**
|
|
252
|
-
* Hook for
|
|
265
|
+
* Hook for performing withdrawals from the Sodax money market.
|
|
253
266
|
*
|
|
254
|
-
* This hook
|
|
255
|
-
* handling
|
|
256
|
-
* and
|
|
267
|
+
* This hook exposes a mutation that executes the complete withdrawal logic, including transaction
|
|
268
|
+
* creation and handling cross-chain communication. It leverages React Query's mutation API for
|
|
269
|
+
* easy asynchronous handling and status tracking within UI components.
|
|
257
270
|
*
|
|
258
|
-
* @
|
|
259
|
-
*
|
|
271
|
+
* @returns {UseMutationResult<WithdrawResponse, MoneyMarketError<'CREATE_WITHDRAW_INTENT_FAILED' | 'WITHDRAW_UNKNOWN_ERROR' | RelayErrorCode>, UseWithdrawParams>}
|
|
272
|
+
* Mutation result object, with:
|
|
273
|
+
* - mutateAsync: (params: UseWithdrawParams) => Promise<WithdrawResponse>
|
|
274
|
+
* Initiates the withdrawal using the provided params.
|
|
275
|
+
* - isPending: boolean indicating if a transaction is in progress.
|
|
276
|
+
* - error: MoneyMarketError if an error occurred while withdrawing, otherwise undefined.
|
|
260
277
|
*
|
|
261
|
-
* @returns {UseMutationResult<WithdrawResponse, Error, string>} A mutation result object with the following properties:
|
|
262
|
-
* - mutateAsync: Function to execute the withdraw transaction
|
|
263
|
-
* - isPending: Boolean indicating if a transaction is in progress
|
|
264
278
|
* @example
|
|
265
279
|
* ```typescript
|
|
266
|
-
* const { mutateAsync: withdraw, isPending, error } = useWithdraw(
|
|
267
|
-
* await withdraw(
|
|
280
|
+
* const { mutateAsync: withdraw, isPending, error } = useWithdraw();
|
|
281
|
+
* await withdraw({ params: withdrawParams, spokeProvider });
|
|
268
282
|
* ```
|
|
269
283
|
*
|
|
270
284
|
* @throws {Error} When:
|
|
271
|
-
* - spokeProvider is not
|
|
272
|
-
* -
|
|
285
|
+
* - spokeProvider is not provided or invalid.
|
|
286
|
+
* - Underlying withdrawal logic fails.
|
|
273
287
|
*/
|
|
274
|
-
declare function useWithdraw(
|
|
288
|
+
declare function useWithdraw(): UseMutationResult<WithdrawResponse, MoneyMarketError<'CREATE_WITHDRAW_INTENT_FAILED' | 'WITHDRAW_UNKNOWN_ERROR' | RelayErrorCode>, UseWithdrawParams>;
|
|
275
289
|
|
|
290
|
+
type UseUserReservesDataParams = {
|
|
291
|
+
spokeProvider: SpokeProvider | undefined;
|
|
292
|
+
address: string | undefined;
|
|
293
|
+
queryOptions?: UseQueryOptions<readonly [readonly UserReserveData[], number], Error>;
|
|
294
|
+
};
|
|
276
295
|
/**
|
|
277
296
|
* Hook for fetching user reserves data from the Sodax money market.
|
|
278
297
|
*
|
|
279
|
-
*
|
|
280
|
-
* The data
|
|
298
|
+
* @param params (optional) - Object including:
|
|
299
|
+
* - spokeProvider: The SpokeProvider instance required for data fetching. If not provided, data fetching is disabled.
|
|
300
|
+
* - address: The user's address (string) whose reserves data will be fetched. If not provided, data fetching is disabled.
|
|
301
|
+
* - queryOptions: (optional) Custom React Query options such as `queryKey`, `enabled`, or cache policy.
|
|
281
302
|
*
|
|
282
|
-
* @
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
303
|
+
* @returns {UseQueryResult<readonly [readonly UserReserveData[], number], Error>} React Query result object containing:
|
|
304
|
+
* - data: A tuple with array of UserReserveData and associated number, or undefined if loading
|
|
305
|
+
* - isLoading: Boolean loading state
|
|
306
|
+
* - isError: Boolean error state
|
|
307
|
+
* - error: Error object, if present
|
|
286
308
|
*
|
|
287
|
-
* @
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
309
|
+
* @example
|
|
310
|
+
* const { data: userReservesData, isLoading, error } = useUserReservesData({
|
|
311
|
+
* spokeProvider,
|
|
312
|
+
* address,
|
|
313
|
+
* });
|
|
291
314
|
*/
|
|
292
|
-
declare function useUserReservesData(
|
|
315
|
+
declare function useUserReservesData(params?: UseUserReservesDataParams): UseQueryResult<readonly [readonly UserReserveData[], number], Error>;
|
|
293
316
|
|
|
317
|
+
type UseReservesDataParams = {
|
|
318
|
+
queryOptions?: UseQueryOptions<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo], Error>;
|
|
319
|
+
};
|
|
294
320
|
/**
|
|
295
|
-
*
|
|
321
|
+
* React hook for fetching the latest reserves data from the Sodax money market.
|
|
296
322
|
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* fetched and cached using React Query.
|
|
323
|
+
* Provides the full set of aggregated reserves and base currency information.
|
|
324
|
+
* Optionally accepts React Query options for customizing the query key, cache time, and related behaviors.
|
|
300
325
|
*
|
|
301
|
-
* @
|
|
302
|
-
*
|
|
303
|
-
* const { data: reservesData, isLoading, error } = useReservesData();
|
|
304
|
-
* ```
|
|
326
|
+
* @param params (optional) - Object including:
|
|
327
|
+
* - queryOptions: Custom React Query options
|
|
305
328
|
*
|
|
306
|
-
* @returns
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
329
|
+
* @returns {UseQueryResult<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo], Error>}
|
|
330
|
+
* React Query result object containing:
|
|
331
|
+
* - data: [aggregated reserves[], base currency info], or undefined if not loaded
|
|
332
|
+
* - isLoading: True if the request is loading
|
|
333
|
+
* - isError: True if the request failed
|
|
334
|
+
* - error: Error object, if present
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* const { data, isLoading, error } = useReservesData();
|
|
338
|
+
* const { data } = useReservesData({ queryOptions: { queryKey: ['custom', 'reservesData'] } });
|
|
310
339
|
*/
|
|
311
|
-
declare function useReservesData():
|
|
340
|
+
declare function useReservesData(params?: UseReservesDataParams): UseQueryResult<readonly [readonly AggregatedReserveData[], BaseCurrencyInfo], Error>;
|
|
312
341
|
|
|
342
|
+
type UseMMAllowanceParams = {
|
|
343
|
+
params: MoneyMarketParams | undefined;
|
|
344
|
+
spokeProvider: SpokeProvider | undefined;
|
|
345
|
+
queryOptions?: UseQueryOptions<boolean, Error>;
|
|
346
|
+
};
|
|
313
347
|
/**
|
|
314
348
|
* Hook for checking token allowance for money market operations.
|
|
315
349
|
*
|
|
@@ -331,77 +365,161 @@ declare function useReservesData(): _tanstack_react_query.UseQueryResult<readonl
|
|
|
331
365
|
* const { data: hasAllowed, isLoading } = useMMAllowance(token, "100", "repay", provider);
|
|
332
366
|
* ```
|
|
333
367
|
*/
|
|
334
|
-
declare function useMMAllowance(
|
|
368
|
+
declare function useMMAllowance({ params, spokeProvider, queryOptions, }: UseMMAllowanceParams): UseQueryResult<boolean, Error>;
|
|
335
369
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}) => Promise<boolean>;
|
|
341
|
-
isLoading: boolean;
|
|
342
|
-
error: Error | null;
|
|
343
|
-
resetError: () => void;
|
|
344
|
-
}
|
|
370
|
+
type UseMMApproveParams = {
|
|
371
|
+
params: MoneyMarketParams;
|
|
372
|
+
spokeProvider: SpokeProvider | undefined;
|
|
373
|
+
};
|
|
345
374
|
/**
|
|
346
|
-
* Hook for approving token spending for money market actions
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
375
|
+
* Hook for approving ERC20 token spending for Sodax money market actions.
|
|
376
|
+
*
|
|
377
|
+
* This hook manages the approval transaction, allowing the user
|
|
378
|
+
* to grant the protocol permission to spend their tokens for specific money market actions
|
|
379
|
+
* (such as supply, borrow, or repay). Upon successful approval, it also invalidates and
|
|
380
|
+
* refetches the associated allowance status so the UI remains up-to-date.
|
|
381
|
+
*
|
|
382
|
+
* @returns {UseMutationResult<string, Error, UseMMApproveParams>} A React Query mutation result containing:
|
|
383
|
+
* - mutateAsync: Function to trigger the approval (see below)
|
|
384
|
+
* - isPending: Boolean indicating if approval transaction is in progress
|
|
385
|
+
* - error: Error object if the last approval failed, null otherwise
|
|
386
|
+
*
|
|
350
387
|
* @example
|
|
351
388
|
* ```tsx
|
|
352
|
-
* const { approve,
|
|
353
|
-
*
|
|
354
|
-
* // Approve tokens for supply action
|
|
355
|
-
* await approve({ amount: "100", action: "supply" });
|
|
389
|
+
* const { mutateAsync: approve, isPending, error } = useMMApprove();
|
|
390
|
+
* await approve({ params: { token, amount: "100", action: "supply", ... }, spokeProvider });
|
|
356
391
|
* ```
|
|
392
|
+
*
|
|
393
|
+
* @throws {Error} When:
|
|
394
|
+
* - spokeProvider is undefined or invalid
|
|
395
|
+
* - Approval transaction fails for any reason
|
|
357
396
|
*/
|
|
358
|
-
declare function useMMApprove(
|
|
397
|
+
declare function useMMApprove(): UseMutationResult<string, Error, UseMMApproveParams>;
|
|
359
398
|
|
|
399
|
+
type UseATokenParams = {
|
|
400
|
+
aToken: string;
|
|
401
|
+
queryOptions?: UseQueryOptions<XToken, Error>;
|
|
402
|
+
};
|
|
360
403
|
/**
|
|
361
|
-
* React hook
|
|
404
|
+
* React hook to fetch and cache metadata for a given aToken address.
|
|
405
|
+
*
|
|
406
|
+
* Accepts an aToken address and React Query options to control query behavior.
|
|
407
|
+
* Returns the aToken's ERC20-style metadata from the Sodax money market, with querying/caching
|
|
408
|
+
* powered by React Query.
|
|
362
409
|
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
410
|
+
* @param {UseATokenParams} params - Required params object:
|
|
411
|
+
* @property {Address} aToken - The aToken contract address to query.
|
|
412
|
+
* @property {UseQueryOptions<XToken, Error>} queryOptions - React Query options to control query (e.g., staleTime, refetch, etc.).
|
|
365
413
|
*
|
|
366
|
-
* @
|
|
367
|
-
*
|
|
414
|
+
* @returns {UseQueryResult<XToken, Error>} React Query result object:
|
|
415
|
+
* - data: XToken metadata, if available
|
|
416
|
+
* - isLoading: Boolean loading state
|
|
417
|
+
* - error: Error, if API call fails
|
|
368
418
|
*
|
|
369
419
|
* @example
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* console.log(aToken.symbol); // 'aETH'
|
|
420
|
+
* const { data: xToken, isLoading, error } = useAToken({ aToken: aTokenAddress, queryOptions: {} });
|
|
421
|
+
* if (xToken) {
|
|
422
|
+
* console.log(xToken.symbol);
|
|
374
423
|
* }
|
|
375
|
-
* ```
|
|
376
|
-
*
|
|
377
|
-
* @returns {UseQueryResult<Erc20Token, Error>} A React Query result object containing:
|
|
378
|
-
* - data: The aToken ERC20 metadata when available.
|
|
379
|
-
* - isLoading: Loading state indicator.
|
|
380
|
-
* - error: Any error that occurred during data fetching.
|
|
381
424
|
*/
|
|
382
|
-
declare function useAToken(aToken
|
|
425
|
+
declare function useAToken({ aToken, queryOptions }: UseATokenParams): UseQueryResult<XToken, Error>;
|
|
383
426
|
|
|
427
|
+
type UseATokensBalancesParams = {
|
|
428
|
+
aTokens: readonly Address[];
|
|
429
|
+
spokeProvider?: SpokeProvider;
|
|
430
|
+
userAddress?: string;
|
|
431
|
+
queryOptions?: UseQueryOptions<Map<Address, bigint>, Error>;
|
|
432
|
+
};
|
|
384
433
|
/**
|
|
385
|
-
*
|
|
386
|
-
* collateral, borrows, liquidation threshold, health factor, available borrowing power, etc..).
|
|
434
|
+
* React hook to fetch and cache aToken balances for multiple aToken addresses in a single multicall.
|
|
387
435
|
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
436
|
+
* Accepts an array of aToken addresses, a spoke provider, and user address. The hook derives the user's
|
|
437
|
+
* hub wallet address and then fetches balanceOf for each aToken in a single multicall. Returns a Map
|
|
438
|
+
* of aToken address to balance, with querying/caching powered by React Query. This hook uses viem's
|
|
439
|
+
* multicall to batch all requests into a single RPC call for better performance.
|
|
440
|
+
*
|
|
441
|
+
* @param {UseATokensBalancesParams} params - Required params object:
|
|
442
|
+
* @property {readonly Address[]} aTokens - Array of aToken contract addresses to query balances for.
|
|
443
|
+
* @property {SpokeProvider} spokeProvider - The spoke provider to derive hub wallet address from.
|
|
444
|
+
* @property {string} userAddress - User's wallet address on the spoke chain.
|
|
445
|
+
* @property {UseQueryOptions<Map<Address, bigint>, Error>} queryOptions - React Query options to control query (e.g., staleTime, refetch, etc.).
|
|
446
|
+
*
|
|
447
|
+
* @returns {UseQueryResult<Map<Address, bigint>, Error>} React Query result object:
|
|
448
|
+
* - data: Map of aToken address to balance, if available
|
|
449
|
+
* - isLoading: Boolean loading state
|
|
450
|
+
* - error: Error, if API call fails
|
|
390
451
|
*
|
|
391
452
|
* @example
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
453
|
+
* const { data: aTokenBalances, isLoading, error } = useATokensBalances({
|
|
454
|
+
* aTokens: [aToken1, aToken2, aToken3],
|
|
455
|
+
* spokeProvider,
|
|
456
|
+
* userAddress: '0x...',
|
|
457
|
+
* queryOptions: {}
|
|
458
|
+
* });
|
|
459
|
+
* const aToken1Balance = aTokenBalances?.get(aToken1);
|
|
460
|
+
*/
|
|
461
|
+
declare function useATokensBalances({ aTokens, spokeProvider, userAddress, queryOptions, }: UseATokensBalancesParams): UseQueryResult<Map<Address, bigint>, Error>;
|
|
462
|
+
|
|
463
|
+
type UseReservesUsdFormatParams = {
|
|
464
|
+
queryOptions?: UseQueryOptions<(ReserveData & {
|
|
465
|
+
priceInMarketReferenceCurrency: string;
|
|
466
|
+
} & FormatReserveUSDResponse)[], Error>;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Hook for fetching reserves data formatted with USD values in the Sodax money market.
|
|
395
470
|
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
471
|
+
* This hook returns an array of reserve objects, each extended with its price in the market reference
|
|
472
|
+
* currency and formatted USD values. Data is automatically fetched and cached using React Query.
|
|
473
|
+
*
|
|
474
|
+
* @param params (optional) - Object including:
|
|
475
|
+
* - queryOptions: Custom React Query options such as `queryKey`, cache behavior, or refetching policy.
|
|
476
|
+
*
|
|
477
|
+
* @returns {UseQueryResult<(ReserveData & { priceInMarketReferenceCurrency: string } & FormatReserveUSDResponse)[], Error>} React Query result object containing:
|
|
478
|
+
* - data: Array of reserves with USD-formatted values, or undefined if loading
|
|
479
|
+
* - isLoading: Boolean loading state
|
|
480
|
+
* - isError: Boolean error state
|
|
481
|
+
* - error: Error object, if present
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* const { data: reservesUSD, isLoading, error } = useReservesUsdFormat();
|
|
400
485
|
*/
|
|
401
|
-
declare function useReservesUsdFormat(): UseQueryResult<(ReserveData & {
|
|
486
|
+
declare function useReservesUsdFormat(params?: UseReservesUsdFormatParams): UseQueryResult<(ReserveData & {
|
|
402
487
|
priceInMarketReferenceCurrency: string;
|
|
403
488
|
} & FormatReserveUSDResponse)[], Error>;
|
|
404
489
|
|
|
490
|
+
type UseUserFormattedSummaryParams = {
|
|
491
|
+
spokeProvider?: SpokeProvider;
|
|
492
|
+
address?: string;
|
|
493
|
+
queryOptions?: UseQueryOptions<FormatUserSummaryResponse<FormatReserveUSDResponse>, Error>;
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* React hook to fetch a formatted summary of a user's Sodax money market portfolio.
|
|
497
|
+
*
|
|
498
|
+
* Accepts an optional params object:
|
|
499
|
+
* - `spokeProvider`: The SpokeProvider instance for the target chain
|
|
500
|
+
* - `address`: The user wallet address to get the summary for
|
|
501
|
+
* - `queryOptions`: Optional React Query options (key, caching, intervals, etc)
|
|
502
|
+
*
|
|
503
|
+
* The hook returns a React Query result object containing the formatted summary, loading and error state.
|
|
504
|
+
* The query is enabled only if both the spokeProvider and address are provided.
|
|
505
|
+
*
|
|
506
|
+
* @param params Optional parameters:
|
|
507
|
+
* - spokeProvider: SpokeProvider to query chain data (required for enabled query)
|
|
508
|
+
* - address: User account address (required for enabled query)
|
|
509
|
+
* - queryOptions: React Query options for customization (optional)
|
|
510
|
+
*
|
|
511
|
+
* @returns {UseQueryResult<FormatUserSummaryResponse<FormatReserveUSDResponse>, Error>}
|
|
512
|
+
* A result object from React Query including:
|
|
513
|
+
* - data: The user's formatted portfolio summary (or undefined if not loaded)
|
|
514
|
+
* - isLoading: Boolean loading state
|
|
515
|
+
* - isError: Boolean error state
|
|
516
|
+
* - error: Error if thrown in fetching
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* const { data, isLoading, error } = useUserFormattedSummary({ spokeProvider, address });
|
|
520
|
+
*/
|
|
521
|
+
declare function useUserFormattedSummary(params?: UseUserFormattedSummaryParams): UseQueryResult<FormatUserSummaryResponse<FormatReserveUSDResponse>, Error>;
|
|
522
|
+
|
|
405
523
|
/**
|
|
406
524
|
* Hook for fetching a quote for an intent-based swap.
|
|
407
525
|
*
|
|
@@ -495,12 +613,12 @@ declare function useSwap(spokeProvider: SpokeProvider | undefined): UseMutationR
|
|
|
495
613
|
declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIntentStatusResponse, SolverErrorResponse> | undefined>;
|
|
496
614
|
|
|
497
615
|
/**
|
|
498
|
-
* Hook for checking token allowance for
|
|
616
|
+
* Hook for checking token allowance for swap operations.
|
|
499
617
|
*
|
|
500
|
-
* This hook verifies if the user has approved enough tokens for a specific
|
|
501
|
-
*
|
|
618
|
+
* This hook verifies if the user has approved enough tokens for a specific swap action.
|
|
619
|
+
* It automatically queries and tracks the allowance status.
|
|
502
620
|
*
|
|
503
|
-
* @param {CreateIntentParams} params - The parameters for the intent to check allowance for.
|
|
621
|
+
* @param {CreateIntentParams | CreateLimitOrderParams} params - The parameters for the intent to check allowance for.
|
|
504
622
|
* @param {SpokeProvider} spokeProvider - The spoke provider to use for allowance checks
|
|
505
623
|
*
|
|
506
624
|
* @returns {UseQueryResult<boolean, Error>} A React Query result containing:
|
|
@@ -510,22 +628,22 @@ declare const useStatus: (intent_tx_hash: Hex) => UseQueryResult<Result<SolverIn
|
|
|
510
628
|
*
|
|
511
629
|
* @example
|
|
512
630
|
* ```typescript
|
|
513
|
-
* const { data: hasAllowed, isLoading } =
|
|
631
|
+
* const { data: hasAllowed, isLoading } = useSwapAllowance(params, spokeProvider);
|
|
514
632
|
* ```
|
|
515
633
|
*/
|
|
516
|
-
declare function useSwapAllowance(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
634
|
+
declare function useSwapAllowance(params: CreateIntentParams | CreateLimitOrderParams | undefined, spokeProvider: SpokeProvider | undefined): UseQueryResult<boolean, Error>;
|
|
517
635
|
|
|
518
636
|
interface UseApproveReturn$1 {
|
|
519
637
|
approve: ({ params }: {
|
|
520
|
-
params: CreateIntentParams;
|
|
638
|
+
params: CreateIntentParams | CreateLimitOrderParams;
|
|
521
639
|
}) => Promise<boolean>;
|
|
522
640
|
isLoading: boolean;
|
|
523
641
|
error: Error | null;
|
|
524
642
|
resetError: () => void;
|
|
525
643
|
}
|
|
526
644
|
/**
|
|
527
|
-
* Hook for approving token spending for
|
|
528
|
-
* @param
|
|
645
|
+
* Hook for approving token spending for swap actions
|
|
646
|
+
* @param params The parameters for the intent to approve spending for
|
|
529
647
|
* @param spokeProvider The spoke provider instance for the chain
|
|
530
648
|
* @returns Object containing approve function, loading state, error state and reset function
|
|
531
649
|
* @example
|
|
@@ -536,7 +654,7 @@ interface UseApproveReturn$1 {
|
|
|
536
654
|
* await approve({ amount: "100", action: "supply" });
|
|
537
655
|
* ```
|
|
538
656
|
*/
|
|
539
|
-
declare function useSwapApprove(params: CreateIntentParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn$1;
|
|
657
|
+
declare function useSwapApprove(params: CreateIntentParams | CreateLimitOrderParams | undefined, spokeProvider: SpokeProvider | undefined): UseApproveReturn$1;
|
|
540
658
|
|
|
541
659
|
type CancelIntentParams = {
|
|
542
660
|
intent: Intent;
|
|
@@ -564,169 +682,284 @@ type CancelIntentResult = Result<TxReturnType<SpokeProvider, boolean>>;
|
|
|
564
682
|
*/
|
|
565
683
|
declare function useCancelSwap(spokeProvider: SpokeProvider | undefined): UseMutationResult<CancelIntentResult, Error, CancelIntentParams>;
|
|
566
684
|
|
|
685
|
+
type CreateLimitOrderResult = Result<[
|
|
686
|
+
SolverExecutionResponse,
|
|
687
|
+
Intent,
|
|
688
|
+
IntentDeliveryInfo
|
|
689
|
+
], IntentError<IntentErrorCode>>;
|
|
567
690
|
/**
|
|
568
|
-
* Hook for
|
|
569
|
-
*
|
|
570
|
-
* This hook provides access to intent data associated with the transaction hash from when
|
|
571
|
-
* the intent was created on the hub chain, including intent details, events, and transaction
|
|
572
|
-
* information. The data is automatically fetched and cached using React Query.
|
|
691
|
+
* Hook for creating a limit order intent (no deadline, must be cancelled manually by user).
|
|
692
|
+
* Uses React Query's useMutation for better state management and caching.
|
|
573
693
|
*
|
|
574
|
-
*
|
|
694
|
+
* Limit orders remain active until manually cancelled by the user. Unlike swaps, limit orders
|
|
695
|
+
* do not have a deadline (deadline is automatically set to 0n).
|
|
575
696
|
*
|
|
576
|
-
* @
|
|
577
|
-
*
|
|
578
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
579
|
-
* - error: Error object if the request failed
|
|
580
|
-
* - refetch: Function to manually trigger a data refresh
|
|
697
|
+
* @param {SpokeProvider} spokeProvider - The spoke provider to use for creating the limit order
|
|
698
|
+
* @returns {UseMutationResult} Mutation result object containing mutation function and state
|
|
581
699
|
*
|
|
582
700
|
* @example
|
|
583
701
|
* ```typescript
|
|
584
|
-
* const {
|
|
702
|
+
* const { mutateAsync: createLimitOrder, isPending } = useCreateLimitOrder(spokeProvider);
|
|
703
|
+
*
|
|
704
|
+
* const handleCreateLimitOrder = async () => {
|
|
705
|
+
* const result = await createLimitOrder({
|
|
706
|
+
* inputToken: '0x...',
|
|
707
|
+
* outputToken: '0x...',
|
|
708
|
+
* inputAmount: 1000000000000000000n,
|
|
709
|
+
* minOutputAmount: 900000000000000000n,
|
|
710
|
+
* allowPartialFill: false,
|
|
711
|
+
* srcChain: '0xa4b1.arbitrum',
|
|
712
|
+
* dstChain: '0x89.polygon',
|
|
713
|
+
* srcAddress: '0x...',
|
|
714
|
+
* dstAddress: '0x...',
|
|
715
|
+
* solver: '0x0000000000000000000000000000000000000000',
|
|
716
|
+
* data: '0x'
|
|
717
|
+
* });
|
|
585
718
|
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
719
|
+
* if (result.ok) {
|
|
720
|
+
* const [solverExecutionResponse, intent, intentDeliveryInfo] = result.value;
|
|
721
|
+
* console.log('Limit order created:', intent);
|
|
722
|
+
* console.log('Intent hash:', solverExecutionResponse.intent_hash);
|
|
723
|
+
* }
|
|
724
|
+
* };
|
|
591
725
|
* ```
|
|
592
|
-
*
|
|
593
|
-
* @remarks
|
|
594
|
-
* - Intents are only created on the hub chain, so the transaction hash must be from the hub chain
|
|
595
|
-
* - The query is disabled when txHash is undefined or empty
|
|
596
|
-
* - Uses React Query for efficient caching and state management
|
|
597
|
-
* - Automatically handles error states and loading indicators
|
|
598
726
|
*/
|
|
599
|
-
declare
|
|
727
|
+
declare function useCreateLimitOrder(spokeProvider: SpokeProvider | undefined): UseMutationResult<CreateLimitOrderResult, Error, CreateLimitOrderParams>;
|
|
600
728
|
|
|
729
|
+
type CancelLimitOrderParams = {
|
|
730
|
+
intent: Intent;
|
|
731
|
+
spokeProvider: SpokeProvider;
|
|
732
|
+
timeout?: number;
|
|
733
|
+
};
|
|
734
|
+
type CancelLimitOrderResult = Result<[string, string], IntentError<IntentErrorCode>>;
|
|
601
735
|
/**
|
|
602
|
-
* Hook for
|
|
603
|
-
*
|
|
604
|
-
* This hook provides access to intent data using the intent hash directly,
|
|
605
|
-
* including intent details, events, and transaction information. The data is automatically
|
|
606
|
-
* fetched and cached using React Query.
|
|
736
|
+
* Hook for canceling a limit order intent and submitting it to the Relayer API.
|
|
737
|
+
* Uses React Query's useMutation for better state management and caching.
|
|
607
738
|
*
|
|
608
|
-
*
|
|
739
|
+
* This hook wraps cancelLimitOrder which cancels the intent on the spoke chain,
|
|
740
|
+
* submits it to the relayer API, and waits for execution on the destination/hub chain.
|
|
609
741
|
*
|
|
610
|
-
* @returns {
|
|
611
|
-
* - data: The intent response data when available
|
|
612
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
613
|
-
* - error: Error object if the request failed
|
|
614
|
-
* - refetch: Function to manually trigger a data refresh
|
|
742
|
+
* @returns {UseMutationResult} Mutation result object containing mutation function and state
|
|
615
743
|
*
|
|
616
744
|
* @example
|
|
617
745
|
* ```typescript
|
|
618
|
-
* const {
|
|
746
|
+
* const { mutateAsync: cancelLimitOrder, isPending } = useCancelLimitOrder();
|
|
747
|
+
*
|
|
748
|
+
* const handleCancelLimitOrder = async () => {
|
|
749
|
+
* const result = await cancelLimitOrder({
|
|
750
|
+
* intent: intentObject,
|
|
751
|
+
* spokeProvider,
|
|
752
|
+
* timeout: 60000 // optional, defaults to 60 seconds
|
|
753
|
+
* });
|
|
754
|
+
*
|
|
755
|
+
* if (result.ok) {
|
|
756
|
+
* const [cancelTxHash, dstTxHash] = result.value;
|
|
757
|
+
* console.log('Cancel transaction hash:', cancelTxHash);
|
|
758
|
+
* console.log('Destination transaction hash:', dstTxHash);
|
|
759
|
+
* }
|
|
760
|
+
* };
|
|
761
|
+
* ```
|
|
762
|
+
*/
|
|
763
|
+
declare function useCancelLimitOrder(): UseMutationResult<CancelLimitOrderResult, Error, CancelLimitOrderParams>;
|
|
764
|
+
|
|
765
|
+
type UseBackendIntentByTxHashParams = {
|
|
766
|
+
params: {
|
|
767
|
+
txHash: string | undefined;
|
|
768
|
+
};
|
|
769
|
+
queryOptions?: UseQueryOptions<IntentResponse | undefined, Error>;
|
|
770
|
+
};
|
|
771
|
+
/**
|
|
772
|
+
* React hook for fetching intent details from the backend API using a transaction hash.
|
|
773
|
+
*
|
|
774
|
+
* @param {UseBackendIntentByTxHashParams | undefined} params - Parameters for the query:
|
|
775
|
+
* - params: { txHash: string | undefined }
|
|
776
|
+
* - `txHash`: Transaction hash used to retrieve the associated intent; query is disabled if undefined or empty.
|
|
777
|
+
* - queryOptions (optional): React Query options to customize request behavior (e.g., caching, retry, refetchInterval, etc.).
|
|
778
|
+
*
|
|
779
|
+
* @returns {UseQueryResult<IntentResponse | undefined, Error>} React Query result object, including:
|
|
780
|
+
* - `data`: The intent response or undefined if unavailable,
|
|
781
|
+
* - `isLoading`: Loading state,
|
|
782
|
+
* - `error`: Error (if request failed),
|
|
783
|
+
* - `refetch`: Function to refetch the data.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* const { data: intent, isLoading, error } = useBackendIntentByTxHash({
|
|
787
|
+
* params: { txHash: '0x123...' },
|
|
788
|
+
* });
|
|
619
789
|
*
|
|
620
790
|
* if (isLoading) return <div>Loading intent...</div>;
|
|
621
791
|
* if (error) return <div>Error: {error.message}</div>;
|
|
622
792
|
* if (intent) {
|
|
623
793
|
* console.log('Intent found:', intent.intentHash);
|
|
624
|
-
* console.log('Open status:', intent.open);
|
|
625
794
|
* }
|
|
626
|
-
* ```
|
|
627
795
|
*
|
|
628
796
|
* @remarks
|
|
629
|
-
* -
|
|
630
|
-
* -
|
|
631
|
-
* -
|
|
797
|
+
* - Intents are only created on the hub chain, so `txHash` must originate from there.
|
|
798
|
+
* - Query is disabled if `params` is undefined, or if `params.params.txHash` is undefined or an empty string.
|
|
799
|
+
* - Default refetch interval is 1 second. Uses React Query for state management, caching, and retries.
|
|
632
800
|
*/
|
|
633
|
-
declare const
|
|
801
|
+
declare const useBackendIntentByTxHash: (params: UseBackendIntentByTxHashParams | undefined) => UseQueryResult<IntentResponse | undefined, Error>;
|
|
634
802
|
|
|
803
|
+
type UseBackendIntentByHashParams = {
|
|
804
|
+
params: {
|
|
805
|
+
intentHash: string | undefined;
|
|
806
|
+
};
|
|
807
|
+
queryOptions?: UseQueryOptions<IntentResponse | undefined, Error>;
|
|
808
|
+
};
|
|
635
809
|
/**
|
|
636
|
-
*
|
|
810
|
+
* React hook to fetch intent details from the backend API using an intent hash.
|
|
637
811
|
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
812
|
+
* @param {UseBackendIntentByHashParams | undefined} params - Parameters for the query:
|
|
813
|
+
* - params: { intentHash: string | undefined }
|
|
814
|
+
* - `intentHash`: The hash identifying the intent to fetch (disables query if undefined or empty).
|
|
815
|
+
* - queryOptions (optional): Options to customize React Query (e.g., staleTime, enabled).
|
|
641
816
|
*
|
|
642
|
-
* @
|
|
643
|
-
* @param {string} params.offset - The offset for pagination (number as string)
|
|
644
|
-
* @param {string} params.limit - The limit for pagination (number as string)
|
|
645
|
-
*
|
|
646
|
-
* @returns {UseQueryResult<OrderbookResponse | undefined>} A query result object containing:
|
|
647
|
-
* - data: The orderbook response data when available
|
|
648
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
649
|
-
* - error: Error object if the request failed
|
|
650
|
-
* - refetch: Function to manually trigger a data refresh
|
|
817
|
+
* @returns {UseQueryResult<IntentResponse | undefined, Error>} React Query result containing intent response data, loading, error, and refetch states.
|
|
651
818
|
*
|
|
652
819
|
* @example
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* offset: '0',
|
|
656
|
-
* limit: '10'
|
|
820
|
+
* const { data: intent, isLoading, error } = useBackendIntentByHash({
|
|
821
|
+
* params: { intentHash: '0xabc...' },
|
|
657
822
|
* });
|
|
658
823
|
*
|
|
659
|
-
* if (isLoading) return <div>Loading
|
|
824
|
+
* if (isLoading) return <div>Loading intent...</div>;
|
|
660
825
|
* if (error) return <div>Error: {error.message}</div>;
|
|
661
|
-
* if (
|
|
662
|
-
* console.log('
|
|
663
|
-
* console.log('Intents:', orderbook.data);
|
|
826
|
+
* if (intent) {
|
|
827
|
+
* console.log('Intent found:', intent.intentHash);
|
|
664
828
|
* }
|
|
665
|
-
* ```
|
|
666
829
|
*
|
|
667
830
|
* @remarks
|
|
668
|
-
* -
|
|
669
|
-
* -
|
|
670
|
-
* -
|
|
671
|
-
* - Stale time of 30 seconds for real-time orderbook data
|
|
672
|
-
* - Supports pagination through offset and limit parameters
|
|
831
|
+
* - Returns `undefined` data if no intentHash is provided or query is disabled.
|
|
832
|
+
* - Query is cached and managed using React Query.
|
|
833
|
+
* - Use `queryOptions` to customize caching, retry and fetch behavior.
|
|
673
834
|
*/
|
|
674
|
-
declare const
|
|
835
|
+
declare const useBackendIntentByHash: (params: UseBackendIntentByHashParams | undefined) => UseQueryResult<IntentResponse | undefined, Error>;
|
|
836
|
+
|
|
837
|
+
type BackendPaginationParams = {
|
|
675
838
|
offset: string;
|
|
676
839
|
limit: string;
|
|
677
|
-
}
|
|
840
|
+
};
|
|
678
841
|
|
|
842
|
+
type GetUserIntentsParams = {
|
|
843
|
+
userAddress: Address$1;
|
|
844
|
+
startDate?: number;
|
|
845
|
+
endDate?: number;
|
|
846
|
+
};
|
|
847
|
+
type UseBackendUserIntentsParams = {
|
|
848
|
+
params?: GetUserIntentsParams;
|
|
849
|
+
queryOptions?: UseQueryOptions<UserIntentsResponse | undefined, Error>;
|
|
850
|
+
pagination?: BackendPaginationParams;
|
|
851
|
+
};
|
|
679
852
|
/**
|
|
680
|
-
*
|
|
853
|
+
* React hook for fetching user-created intents from the backend API for a given user address,
|
|
854
|
+
* with optional support for a date filtering range.
|
|
855
|
+
*
|
|
856
|
+
* @param {UseBackendUserIntentsParams} args - Query configuration.
|
|
857
|
+
* @param {GetUserIntentsParams | undefined} args.params - User intent filter parameters.
|
|
858
|
+
* @param {Address} args.params.userAddress - The wallet address of the user (required).
|
|
859
|
+
* @param {number} [args.params.startDate] - Include intents created after this timestamp (ms).
|
|
860
|
+
* @param {number} [args.params.endDate] - Include intents created before this timestamp (ms).
|
|
861
|
+
* @param {UseQueryOptions<UserIntentsResponse | undefined, Error>} [args.queryOptions] - Optional React Query options.
|
|
862
|
+
* @param {BackendPaginationParams} [args.pagination] - (currently ignored) Pagination options.
|
|
863
|
+
*
|
|
864
|
+
* @returns {UseQueryResult<UserIntentsResponse | undefined, Error>} React Query result:
|
|
865
|
+
* - `data`: The user intent response, or undefined if unavailable.
|
|
866
|
+
* - `isLoading`: `true` if loading.
|
|
867
|
+
* - `error`: An Error instance if any occurred.
|
|
868
|
+
* - `refetch`: Function to refetch data.
|
|
681
869
|
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
870
|
+
* @example
|
|
871
|
+
* const { data: userIntents, isLoading, error } = useBackendUserIntents({
|
|
872
|
+
* params: { userAddress: "0x123..." }
|
|
873
|
+
* });
|
|
685
874
|
*
|
|
686
|
-
* @
|
|
875
|
+
* @example
|
|
876
|
+
* const { data } = useBackendUserIntents({
|
|
877
|
+
* params: {
|
|
878
|
+
* userAddress: "0xabc...",
|
|
879
|
+
* startDate: Date.now() - 1_000_000,
|
|
880
|
+
* endDate: Date.now(),
|
|
881
|
+
* },
|
|
882
|
+
* });
|
|
687
883
|
*
|
|
688
|
-
* @
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
|
|
692
|
-
|
|
884
|
+
* @remarks
|
|
885
|
+
* The query is disabled if `params` or `params.userAddress` is missing or empty. Uses React Query for
|
|
886
|
+
* cache/state management and auto-retries failed requests three times by default.
|
|
887
|
+
*/
|
|
888
|
+
declare const useBackendUserIntents: ({ params, queryOptions, }: UseBackendUserIntentsParams) => UseQueryResult<UserIntentsResponse | undefined, Error>;
|
|
889
|
+
|
|
890
|
+
type UseBackendOrderbookParams = {
|
|
891
|
+
queryOptions?: UseQueryOptions<OrderbookResponse | undefined, Error>;
|
|
892
|
+
pagination?: BackendPaginationParams;
|
|
893
|
+
};
|
|
894
|
+
/**
|
|
895
|
+
* Hook for fetching the solver orderbook from the backend API.
|
|
693
896
|
*
|
|
694
|
-
* @
|
|
695
|
-
*
|
|
696
|
-
*
|
|
897
|
+
* @param {UseBackendOrderbookParams | undefined} params - Optional parameters:
|
|
898
|
+
* - `pagination`: Pagination configuration (see `BackendPaginationParams`), including
|
|
899
|
+
* `offset` and `limit` (both required for fetch to be enabled).
|
|
900
|
+
* - `queryOptions`: Optional React Query options to override default behavior.
|
|
697
901
|
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
902
|
+
* @returns {UseQueryResult<OrderbookResponse | undefined, Error>} React Query result object:
|
|
903
|
+
* - `data`: The orderbook response, or undefined if unavailable.
|
|
904
|
+
* - `isLoading`: Loading state.
|
|
905
|
+
* - `error`: Error instance if the query failed.
|
|
906
|
+
* - `refetch`: Function to re-trigger the query.
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* const { data, isLoading, error } = useBackendOrderbook({
|
|
910
|
+
* pagination: { offset: '0', limit: '10' },
|
|
911
|
+
* queryOptions: { staleTime: 60000 },
|
|
912
|
+
* });
|
|
705
913
|
*
|
|
706
914
|
* @remarks
|
|
707
|
-
* -
|
|
708
|
-
* -
|
|
709
|
-
* -
|
|
710
|
-
* - Includes user's aToken and debt token balances across all reserves
|
|
915
|
+
* - Query is disabled if `params?.pagination`, `offset`, or `limit` are missing/empty.
|
|
916
|
+
* - Caches and manages server state using React Query.
|
|
917
|
+
* - Default `staleTime` is 30 seconds to support near-real-time updates.
|
|
711
918
|
*/
|
|
712
|
-
declare const
|
|
919
|
+
declare const useBackendOrderbook: (params: UseBackendOrderbookParams | undefined) => UseQueryResult<OrderbookResponse | undefined>;
|
|
713
920
|
|
|
921
|
+
type UseBackendMoneyMarketPositionParams = {
|
|
922
|
+
userAddress: string | undefined;
|
|
923
|
+
queryOptions?: UseQueryOptions<MoneyMarketPosition | undefined, Error>;
|
|
924
|
+
};
|
|
714
925
|
/**
|
|
715
|
-
*
|
|
926
|
+
* React hook for fetching a user's money market position from the backend API.
|
|
716
927
|
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
928
|
+
* @param {UseBackendMoneyMarketPositionParams | undefined} params - Parameters object:
|
|
929
|
+
* - userAddress: The user's wallet address to fetch positions for. If undefined or empty, the query is disabled.
|
|
930
|
+
* - queryOptions: (Optional) React Query options to customize behavior (e.g., staleTime, enabled).
|
|
720
931
|
*
|
|
721
|
-
* @returns {UseQueryResult<
|
|
722
|
-
* - data:
|
|
723
|
-
* - isLoading:
|
|
724
|
-
* - error: Error
|
|
725
|
-
* - refetch: Function to manually trigger a
|
|
932
|
+
* @returns {UseQueryResult<MoneyMarketPosition | undefined, Error>} - React Query result object with:
|
|
933
|
+
* - data: The user's money market position data, or undefined if not available.
|
|
934
|
+
* - isLoading: Loading state.
|
|
935
|
+
* - error: An Error instance if fetching failed.
|
|
936
|
+
* - refetch: Function to manually trigger a refetch.
|
|
726
937
|
*
|
|
727
938
|
* @example
|
|
728
|
-
*
|
|
729
|
-
*
|
|
939
|
+
* const { data, isLoading, error } = useBackendMoneyMarketPosition({
|
|
940
|
+
* userAddress: '0xabc...',
|
|
941
|
+
* queryOptions: { staleTime: 60000 },
|
|
942
|
+
* });
|
|
943
|
+
*/
|
|
944
|
+
declare const useBackendMoneyMarketPosition: (params: UseBackendMoneyMarketPositionParams | undefined) => UseQueryResult<MoneyMarketPosition | undefined, Error>;
|
|
945
|
+
|
|
946
|
+
type UseBackendAllMoneyMarketAssetsParams = {
|
|
947
|
+
queryOptions?: UseQueryOptions<MoneyMarketAsset[], Error>;
|
|
948
|
+
};
|
|
949
|
+
/**
|
|
950
|
+
* React hook to fetch all money market assets from the backend API.
|
|
951
|
+
*
|
|
952
|
+
* @param {UseBackendAllMoneyMarketAssetsParams | undefined} params - Optional parameters:
|
|
953
|
+
* - `queryOptions` (optional): React Query options to override default behavior (e.g., caching, retry, etc).
|
|
954
|
+
*
|
|
955
|
+
* @returns {UseQueryResult<MoneyMarketAsset[], Error>} React Query result object:
|
|
956
|
+
* - `data`: Array of all money market asset data when available.
|
|
957
|
+
* - `isLoading`: Boolean indicating if the request is in progress.
|
|
958
|
+
* - `error`: Error object if the request failed.
|
|
959
|
+
* - `refetch`: Function to manually trigger a data refresh.
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* const { data: assets, isLoading, error } = useBackendAllMoneyMarketAssets();
|
|
730
963
|
*
|
|
731
964
|
* if (isLoading) return <div>Loading assets...</div>;
|
|
732
965
|
* if (error) return <div>Error: {error.message}</div>;
|
|
@@ -736,35 +969,39 @@ declare const useBackendMoneyMarketPosition: (userAddress: string | undefined) =
|
|
|
736
969
|
* console.log(`${asset.symbol}: ${asset.liquidityRate} liquidity rate`);
|
|
737
970
|
* });
|
|
738
971
|
* }
|
|
739
|
-
* ```
|
|
740
972
|
*
|
|
741
973
|
* @remarks
|
|
742
|
-
* -
|
|
743
|
-
* -
|
|
744
|
-
* -
|
|
745
|
-
* - No parameters required - fetches all available assets
|
|
974
|
+
* - No required parameters — fetches all available money market assets from backend.
|
|
975
|
+
* - Uses React Query for caching, retries, and loading/error state management.
|
|
976
|
+
* - Supports overriding React Query config via `queryOptions`.
|
|
746
977
|
*/
|
|
747
|
-
declare const useBackendAllMoneyMarketAssets: () => UseQueryResult<MoneyMarketAsset[]>;
|
|
978
|
+
declare const useBackendAllMoneyMarketAssets: (params: UseBackendAllMoneyMarketAssetsParams | undefined) => UseQueryResult<MoneyMarketAsset[], Error>;
|
|
748
979
|
|
|
980
|
+
type UseBackendMoneyMarketAssetParams = {
|
|
981
|
+
params: {
|
|
982
|
+
reserveAddress: string | undefined;
|
|
983
|
+
};
|
|
984
|
+
queryOptions?: UseQueryOptions<MoneyMarketAsset | undefined, Error>;
|
|
985
|
+
};
|
|
749
986
|
/**
|
|
750
|
-
*
|
|
987
|
+
* React hook to fetch a specific money market asset from the backend API.
|
|
751
988
|
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
989
|
+
* @param params - The hook input parameter object (may be undefined):
|
|
990
|
+
* - `params`: An object containing:
|
|
991
|
+
* - `reserveAddress` (string | undefined): Reserve contract address to fetch asset details. Disables query if undefined or empty.
|
|
992
|
+
* - `queryOptions` (optional): React Query options for advanced configuration (e.g. caching, staleTime, retry, etc.).
|
|
755
993
|
*
|
|
756
|
-
* @
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
* -
|
|
760
|
-
* -
|
|
761
|
-
* -
|
|
762
|
-
* - refetch: Function to manually trigger a data refresh
|
|
994
|
+
* @returns A React Query result object: {@link UseQueryResult} for {@link MoneyMarketAsset} or `undefined` on error or if disabled,
|
|
995
|
+
* including:
|
|
996
|
+
* - `data`: The money market asset (when available) or `undefined`.
|
|
997
|
+
* - `isLoading`: Whether the query is running.
|
|
998
|
+
* - `error`: An error encountered by the query (if any).
|
|
999
|
+
* - `refetch`: Function to manually refetch the asset.
|
|
763
1000
|
*
|
|
764
1001
|
* @example
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
1002
|
+
* const { data: asset, isLoading, error } = useBackendMoneyMarketAsset({
|
|
1003
|
+
* params: { reserveAddress: '0xabc...' },
|
|
1004
|
+
* });
|
|
768
1005
|
* if (isLoading) return <div>Loading asset...</div>;
|
|
769
1006
|
* if (error) return <div>Error: {error.message}</div>;
|
|
770
1007
|
* if (asset) {
|
|
@@ -772,39 +1009,40 @@ declare const useBackendAllMoneyMarketAssets: () => UseQueryResult<MoneyMarketAs
|
|
|
772
1009
|
* console.log('Liquidity rate:', asset.liquidityRate);
|
|
773
1010
|
* console.log('Variable borrow rate:', asset.variableBorrowRate);
|
|
774
1011
|
* }
|
|
775
|
-
* ```
|
|
776
1012
|
*
|
|
777
1013
|
* @remarks
|
|
778
|
-
* -
|
|
779
|
-
* - Uses React Query for
|
|
780
|
-
* -
|
|
781
|
-
* - Returns comprehensive asset information for the specified reserve
|
|
1014
|
+
* - Query is disabled if `params`, `params.params`, or `params.params.reserveAddress` is missing or empty.
|
|
1015
|
+
* - Uses React Query for caching and background-state management.
|
|
1016
|
+
* - Loading and error handling are managed automatically.
|
|
782
1017
|
*/
|
|
783
|
-
declare const useBackendMoneyMarketAsset: (
|
|
1018
|
+
declare const useBackendMoneyMarketAsset: (params: UseBackendMoneyMarketAssetParams | undefined) => UseQueryResult<MoneyMarketAsset | undefined, Error>;
|
|
784
1019
|
|
|
1020
|
+
type UseBackendMoneyMarketAssetBorrowersParams = {
|
|
1021
|
+
params: {
|
|
1022
|
+
reserveAddress: string | undefined;
|
|
1023
|
+
};
|
|
1024
|
+
pagination: BackendPaginationParams;
|
|
1025
|
+
queryOptions?: UseQueryOptions<MoneyMarketAssetBorrowers | undefined, Error>;
|
|
1026
|
+
};
|
|
785
1027
|
/**
|
|
786
|
-
*
|
|
1028
|
+
* React hook for fetching borrowers for a specific money market asset from the backend API with pagination.
|
|
787
1029
|
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
1030
|
+
* @param {UseBackendMoneyMarketAssetBorrowersParams | undefined} params - Query parameters:
|
|
1031
|
+
* - `params`: Object containing:
|
|
1032
|
+
* - `reserveAddress`: Reserve contract address for which to fetch borrowers, or `undefined` to disable query.
|
|
1033
|
+
* - `pagination`: Pagination controls with `offset` and `limit` (both required as strings).
|
|
1034
|
+
* - `queryOptions` (optional): React Query options to override defaults (e.g. `staleTime`, `enabled`, etc.).
|
|
790
1035
|
*
|
|
791
|
-
* @
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
* @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined>} A query result object containing:
|
|
797
|
-
* - data: The asset borrowers data when available
|
|
798
|
-
* - isLoading: Boolean indicating if the request is in progress
|
|
799
|
-
* - error: Error object if the request failed
|
|
800
|
-
* - refetch: Function to manually trigger a data refresh
|
|
1036
|
+
* @returns {UseQueryResult<MoneyMarketAssetBorrowers | undefined, Error>} React Query result object including:
|
|
1037
|
+
* - `data`: The money market asset borrowers data, or `undefined` if not available.
|
|
1038
|
+
* - `isLoading`: Boolean indicating whether the query is loading.
|
|
1039
|
+
* - `error`: An Error instance if the request failed.
|
|
1040
|
+
* - `refetch`: Function to manually trigger a data refresh.
|
|
801
1041
|
*
|
|
802
1042
|
* @example
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
* offset: '0',
|
|
807
|
-
* limit: '20'
|
|
1043
|
+
* const { data: borrowers, isLoading, error } = useBackendMoneyMarketAssetBorrowers({
|
|
1044
|
+
* params: { reserveAddress: '0xabc...' },
|
|
1045
|
+
* pagination: { offset: '0', limit: '20' }
|
|
808
1046
|
* });
|
|
809
1047
|
*
|
|
810
1048
|
* if (isLoading) return <div>Loading borrowers...</div>;
|
|
@@ -813,43 +1051,40 @@ declare const useBackendMoneyMarketAsset: (reserveAddress: string | undefined) =
|
|
|
813
1051
|
* console.log('Total borrowers:', borrowers.total);
|
|
814
1052
|
* console.log('Borrowers:', borrowers.borrowers);
|
|
815
1053
|
* }
|
|
816
|
-
* ```
|
|
817
1054
|
*
|
|
818
1055
|
* @remarks
|
|
819
|
-
* - The query is disabled
|
|
820
|
-
* - Uses React Query for
|
|
821
|
-
* -
|
|
822
|
-
* - Supports pagination through offset and limit parameters
|
|
1056
|
+
* - The query is disabled if `reserveAddress`, `offset`, or `limit` are not provided.
|
|
1057
|
+
* - Uses React Query for caching, retries, and auto error/loading management.
|
|
1058
|
+
* - Pagination is handled via `pagination.offset` and `pagination.limit`.
|
|
823
1059
|
*/
|
|
824
|
-
declare const useBackendMoneyMarketAssetBorrowers: (params:
|
|
825
|
-
reserveAddress: string | undefined;
|
|
826
|
-
offset: string;
|
|
827
|
-
limit: string;
|
|
828
|
-
}) => UseQueryResult<MoneyMarketAssetBorrowers | undefined>;
|
|
1060
|
+
declare const useBackendMoneyMarketAssetBorrowers: (params: UseBackendMoneyMarketAssetBorrowersParams | undefined) => UseQueryResult<MoneyMarketAssetBorrowers | undefined, Error>;
|
|
829
1061
|
|
|
1062
|
+
type UseBackendMoneyMarketAssetSuppliersParams = {
|
|
1063
|
+
params: {
|
|
1064
|
+
reserveAddress: string | undefined;
|
|
1065
|
+
};
|
|
1066
|
+
pagination: BackendPaginationParams;
|
|
1067
|
+
queryOptions?: UseQueryOptions<MoneyMarketAssetSuppliers | undefined, Error>;
|
|
1068
|
+
};
|
|
830
1069
|
/**
|
|
831
|
-
*
|
|
1070
|
+
* React hook for fetching suppliers for a specific money market asset from the backend API, with pagination support.
|
|
832
1071
|
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
* @param {string} params.offset - The offset for pagination (number as string)
|
|
839
|
-
* @param {string} params.limit - The limit for pagination (number as string)
|
|
1072
|
+
* @param {UseBackendMoneyMarketAssetSuppliersParams | undefined} params - Hook parameters:
|
|
1073
|
+
* - `params`: Object containing:
|
|
1074
|
+
* - `reserveAddress`: The reserve contract address to query, or undefined to disable the query.
|
|
1075
|
+
* - `pagination`: Backend pagination controls (`offset` and `limit` as strings).
|
|
1076
|
+
* - `queryOptions` (optional): React Query options to override defaults.
|
|
840
1077
|
*
|
|
841
|
-
* @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined>}
|
|
842
|
-
* - data
|
|
843
|
-
* - isLoading
|
|
844
|
-
* - error
|
|
845
|
-
* - refetch
|
|
1078
|
+
* @returns {UseQueryResult<MoneyMarketAssetSuppliers | undefined, Error>} - Query result object with:
|
|
1079
|
+
* - `data`: The asset suppliers data when available.
|
|
1080
|
+
* - `isLoading`: Indicates if the request is in progress.
|
|
1081
|
+
* - `error`: Error object if the request failed.
|
|
1082
|
+
* - `refetch`: Function to trigger a manual data refresh.
|
|
846
1083
|
*
|
|
847
1084
|
* @example
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
* offset: '0',
|
|
852
|
-
* limit: '20'
|
|
1085
|
+
* const { data: suppliers, isLoading, error } = useBackendMoneyMarketAssetSuppliers({
|
|
1086
|
+
* params: { reserveAddress: '0xabc...' },
|
|
1087
|
+
* pagination: { offset: '0', limit: '20' }
|
|
853
1088
|
* });
|
|
854
1089
|
*
|
|
855
1090
|
* if (isLoading) return <div>Loading suppliers...</div>;
|
|
@@ -858,20 +1093,18 @@ declare const useBackendMoneyMarketAssetBorrowers: (params: {
|
|
|
858
1093
|
* console.log('Total suppliers:', suppliers.total);
|
|
859
1094
|
* console.log('Suppliers:', suppliers.suppliers);
|
|
860
1095
|
* }
|
|
861
|
-
* ```
|
|
862
1096
|
*
|
|
863
1097
|
* @remarks
|
|
864
|
-
* - The query is disabled
|
|
865
|
-
* - Uses React Query for efficient caching and
|
|
866
|
-
* -
|
|
867
|
-
* - Supports pagination through offset and limit parameters
|
|
1098
|
+
* - The query is disabled if `reserveAddress`, `offset`, or `limit` are not provided.
|
|
1099
|
+
* - Uses React Query for efficient caching, automatic retries, and error/loading handling.
|
|
1100
|
+
* - Pagination is handled via `pagination.offset` and `pagination.limit`.
|
|
868
1101
|
*/
|
|
869
|
-
declare const useBackendMoneyMarketAssetSuppliers: (params:
|
|
870
|
-
reserveAddress: string | undefined;
|
|
871
|
-
offset: string;
|
|
872
|
-
limit: string;
|
|
873
|
-
}) => UseQueryResult<MoneyMarketAssetSuppliers | undefined>;
|
|
1102
|
+
declare const useBackendMoneyMarketAssetSuppliers: (params: UseBackendMoneyMarketAssetSuppliersParams | undefined) => UseQueryResult<MoneyMarketAssetSuppliers | undefined, Error>;
|
|
874
1103
|
|
|
1104
|
+
type UseBackendAllMoneyMarketBorrowersParams = {
|
|
1105
|
+
pagination: BackendPaginationParams;
|
|
1106
|
+
queryOptions?: UseQueryOptions<MoneyMarketBorrowers | undefined, Error>;
|
|
1107
|
+
};
|
|
875
1108
|
/**
|
|
876
1109
|
* Hook for fetching all money market borrowers from the backend API.
|
|
877
1110
|
*
|
|
@@ -910,10 +1143,7 @@ declare const useBackendMoneyMarketAssetSuppliers: (params: {
|
|
|
910
1143
|
* - Supports pagination through offset and limit parameters
|
|
911
1144
|
* - Returns borrowers across all money market assets
|
|
912
1145
|
*/
|
|
913
|
-
declare const useBackendAllMoneyMarketBorrowers: (params:
|
|
914
|
-
offset: string;
|
|
915
|
-
limit: string;
|
|
916
|
-
} | undefined) => UseQueryResult<MoneyMarketBorrowers | undefined>;
|
|
1146
|
+
declare const useBackendAllMoneyMarketBorrowers: (params: UseBackendAllMoneyMarketBorrowersParams | undefined) => UseQueryResult<MoneyMarketBorrowers | undefined>;
|
|
917
1147
|
|
|
918
1148
|
/**
|
|
919
1149
|
* Hook for checking token allowance for bridge operations.
|
|
@@ -1015,7 +1245,7 @@ declare function useBridge(spokeProvider: SpokeProvider | undefined): UseMutatio
|
|
|
1015
1245
|
* }
|
|
1016
1246
|
* ```
|
|
1017
1247
|
*/
|
|
1018
|
-
declare function useGetBridgeableAmount(from: XToken
|
|
1248
|
+
declare function useGetBridgeableAmount(from: XToken | undefined, to: XToken | undefined): UseQueryResult<bigint, Error>;
|
|
1019
1249
|
|
|
1020
1250
|
/**
|
|
1021
1251
|
/**
|
|
@@ -1050,7 +1280,7 @@ declare function useGetBridgeableAmount(from: XToken$1 | undefined, to: XToken$1
|
|
|
1050
1280
|
* }
|
|
1051
1281
|
* ```
|
|
1052
1282
|
*/
|
|
1053
|
-
declare function useGetBridgeableTokens(from: SpokeChainId | undefined, to: SpokeChainId | undefined, token: string | undefined): UseQueryResult<XToken
|
|
1283
|
+
declare function useGetBridgeableTokens(from: SpokeChainId | undefined, to: SpokeChainId | undefined, token: string | undefined): UseQueryResult<XToken[], Error>;
|
|
1054
1284
|
|
|
1055
1285
|
/**
|
|
1056
1286
|
* Hook for executing stake transactions to stake SODA tokens and receive xSODA shares.
|
|
@@ -1474,11 +1704,11 @@ declare const MIGRATION_MODE_ICX_SODA = "icxsoda";
|
|
|
1474
1704
|
declare const MIGRATION_MODE_BNUSD = "bnusd";
|
|
1475
1705
|
type MigrationMode = typeof MIGRATION_MODE_ICX_SODA | typeof MIGRATION_MODE_BNUSD;
|
|
1476
1706
|
interface MigrationIntentParams {
|
|
1477
|
-
token: XToken | undefined;
|
|
1707
|
+
token: XToken$1 | undefined;
|
|
1478
1708
|
amount: string | undefined;
|
|
1479
1709
|
sourceAddress: string | undefined;
|
|
1480
1710
|
migrationMode?: MigrationMode;
|
|
1481
|
-
toToken?: XToken;
|
|
1711
|
+
toToken?: XToken$1;
|
|
1482
1712
|
destinationAddress?: string;
|
|
1483
1713
|
}
|
|
1484
1714
|
|
|
@@ -1562,4 +1792,4 @@ interface SodaxProviderProps {
|
|
|
1562
1792
|
}
|
|
1563
1793
|
declare const SodaxProvider: ({ children, testnet, config, rpcConfig }: SodaxProviderProps) => ReactElement;
|
|
1564
1794
|
|
|
1565
|
-
export { MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, useAToken, 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, useReservesUsdFormat, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserReservesData, useWithdraw };
|
|
1795
|
+
export { type BackendPaginationParams, MIGRATION_MODE_BNUSD, MIGRATION_MODE_ICX_SODA, type MigrationIntentParams, type MigrationMode, SodaxProvider, type UseATokenParams, type UseATokensBalancesParams, type UseBorrowParams, type UseMMAllowanceParams, type UseMMApproveParams, type UseRepayParams, type UseReservesDataParams, type UseReservesUsdFormatParams, type UseSupplyParams, type UseUserFormattedSummaryParams, type UseUserReservesDataParams, type UseWithdrawParams, useAToken, useATokensBalances, useBackendAllMoneyMarketAssets, useBackendAllMoneyMarketBorrowers, useBackendIntentByHash, useBackendIntentByTxHash, useBackendMoneyMarketAsset, useBackendMoneyMarketAssetBorrowers, useBackendMoneyMarketAssetSuppliers, useBackendMoneyMarketPosition, useBackendOrderbook, useBackendUserIntents, useBorrow, useBridge, useBridgeAllowance, useBridgeApprove, useCancelLimitOrder, useCancelSwap, useCancelUnstake, useClaim, useConvertedAssets, useCreateLimitOrder, useDeriveUserWalletAddress, useEstimateGas, useGetBridgeableAmount, useGetBridgeableTokens, useHubProvider, useInstantUnstake, useInstantUnstakeAllowance, useInstantUnstakeApprove, useInstantUnstakeRatio, useMMAllowance, useMMApprove, useMigrate, useMigrationAllowance, useMigrationApprove, useQuote, useRepay, useRequestTrustline, useReservesData, useReservesUsdFormat, useSodaxContext, useSpokeProvider, useStake, useStakeAllowance, useStakeApprove, useStakeRatio, useStakingConfig, useStakingInfo, useStatus, useStellarTrustlineCheck, useSupply, useSwap, useSwapAllowance, useSwapApprove, useUnstake, useUnstakeAllowance, useUnstakeApprove, useUnstakingInfo, useUnstakingInfoWithPenalty, useUserFormattedSummary, useUserReservesData, useWithdraw };
|