@aave/react 4.0.0-next.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4LHXPD6N.js +2 -0
- package/dist/chunk-4LHXPD6N.js.map +1 -0
- package/dist/chunk-4NA4FB6K.js +2 -0
- package/dist/chunk-4NA4FB6K.js.map +1 -0
- package/dist/chunk-V6Q6TCNV.js +2 -0
- package/dist/chunk-V6Q6TCNV.js.map +1 -0
- package/dist/ethers.cjs +1 -1
- package/dist/ethers.cjs.map +1 -1
- package/dist/ethers.d.cts +10 -66
- package/dist/ethers.d.ts +10 -66
- package/dist/ethers.js +1 -1
- package/dist/ethers.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1626 -593
- package/dist/index.d.ts +1626 -593
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{misc-CB94S1RB.d.cts → misc-BYT0opC5.d.cts} +91 -12
- package/dist/{misc-BUJSXsyz.d.ts → misc-mjFkGr9I.d.ts} +91 -12
- package/dist/privy.cjs +1 -1
- package/dist/privy.cjs.map +1 -1
- package/dist/privy.d.cts +9 -54
- package/dist/privy.d.ts +9 -54
- package/dist/privy.js +1 -1
- package/dist/privy.js.map +1 -1
- package/dist/thirdweb.cjs +1 -1
- package/dist/thirdweb.cjs.map +1 -1
- package/dist/thirdweb.d.cts +9 -54
- package/dist/thirdweb.d.ts +9 -54
- package/dist/thirdweb.js +1 -1
- package/dist/thirdweb.js.map +1 -1
- package/dist/viem/index.cjs +1 -1
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +11 -56
- package/dist/viem/index.d.ts +11 -56
- package/dist/viem/index.js +1 -1
- package/dist/viem/index.js.map +1 -1
- package/dist/{writes-BXnwYgAQ.d.cts → writes-sBt0thuG.d.cts} +17 -6
- package/dist/{writes-BXnwYgAQ.d.ts → writes-sBt0thuG.d.ts} +17 -6
- package/package.json +8 -7
- package/dist/chunk-FIYWA5XQ.js +0 -2
- package/dist/chunk-FIYWA5XQ.js.map +0 -1
- package/dist/chunk-GTUQRT5Q.js +0 -2
- package/dist/chunk-GTUQRT5Q.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AaveClient, CurrencyQueryOptions, TimeWindowQueryOptions, UnexpectedError,
|
|
1
|
+
import { AaveClient, CurrencyQueryOptions, TimeWindowQueryOptions, UnexpectedError, ActivitiesRequest, PaginatedActivitiesResult, TransactionReceipt } from '@aave/client';
|
|
2
2
|
export * from '@aave/client';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
import { a as UseAsyncTask, C as CancelOperation, S as SendTransactionError,
|
|
5
|
-
export { A as AsyncTaskError,
|
|
6
|
-
import { HubRequest,
|
|
7
|
-
import { Prettify, ResultAsync,
|
|
8
|
-
import { S as Suspendable, a as SuspenseResult, P as Pausable, b as PausableSuspenseResult, R as ReadResult, c as PausableReadResult
|
|
9
|
-
export {
|
|
10
|
-
import { UnexpectedError as UnexpectedError$1,
|
|
4
|
+
import { a as UseAsyncTask, C as CancelOperation, P as PendingTransaction, S as SendTransactionError, b as PendingTransactionError, c as cancel, E as ExecutionPlanHandler } from './writes-sBt0thuG.js';
|
|
5
|
+
export { A as AsyncTaskError, d as AsyncTaskIdle, e as AsyncTaskLoading, f as AsyncTaskState, g as AsyncTaskSuccess, T as TransactionHandlerOptions, U as UseSendTransactionResult } from './writes-sBt0thuG.js';
|
|
6
|
+
import { HubRequest, HubAssetInterestRateModelRequest, HubAssetsRequest, HubSummaryHistoryRequest, HubsRequest, Hub, HubAssetInterestRateModelPoint, HubAsset, HubSummarySample, AssetRequest, AssetBorrowHistoryRequest, AssetPriceHistoryRequest, AssetSupplyHistoryRequest, ProtocolHistoryRequest, Asset, AssetBorrowSample, AssetPriceSample, AssetSupplySample, ProtocolHistorySample, BorrowApyHistoryRequest, ReserveRequest, ReservesRequest, SupplyApyHistoryRequest, ApySample, Reserve, UserClaimableRewardsRequest, UserClaimableReward, SpokeRequest, SpokePositionManagersRequest, SpokeUserPositionManagersRequest, SpokesRequest, Spoke, PaginatedSpokePositionManagerResult, PaginatedSpokeUserPositionManagerResult, PositionSwapApproval, SwapTypedData, SwapQuote, BorrowSwapQuoteRequest, SwapReceipt, InsufficientBalanceError, InsufficientLiquidityError, TransactionRequest, PrepareSwapCancelRequest, SwapCancelledResult, RepayWithSupplyQuoteRequest, SupplySwapQuoteRequest, SwappableTokensRequest, Token, SwapStatusRequest, SwapStatus, Erc20Approval, SwapTransactionRequest, TokenSwapQuoteRequest, UserSwapsRequest, PaginatedUserSwapsResult, WithdrawSwapQuoteRequest, PreContractActionRequired, BorrowRequest, ClaimRewardsRequest, LiquidatePositionRequest, PreviewRequest, PreviewUserPosition, RenounceSpokeUserPositionManagerRequest, RepayRequest, SetSpokeUserPositionManagerRequest, SetUserSuppliesAsCollateralRequest, SupplyRequest, UpdateUserPositionConditionsRequest, WithdrawRequest, UserBalancesRequest, UserBorrowsRequest, UserPositionRequest, UserPositionsRequest, UserRiskPremiumBreakdownRequest, UserSummaryRequest, UserSummaryHistoryRequest, UserSuppliesRequest, UserBalance, UserBorrowItem, UserPosition, UserRiskPremiumBreakdownItem, UserSummary, UserSummaryHistoryItem, UserSupplyItem, StableVaultRequest, StableVaultClaimStatusRequest, StableVaultUserPositionsRequest, StableVaultsRequest, StableVault, StableVaultClaimStatus, StableVaultDepositRequest, StableVaultUserPosition, StableVaultWithdrawRequest, StableVaultWithdrawClaim, StableVaultWithdrawRedeemRequest } from '@aave/graphql';
|
|
7
|
+
import { Prettify, ResultAsync, Signature, ResultAwareError } from '@aave/types';
|
|
8
|
+
import { S as Suspendable, a as SuspenseResult, P as Pausable, b as PausableSuspenseResult, R as ReadResult, c as PausableReadResult } from './misc-mjFkGr9I.js';
|
|
9
|
+
export { d as UseChainArgs, e as UseChainsArgs, f as UseExchangeRateArgs, U as UseNetworkFee, g as UseNetworkFeeArgs, h as UseNetworkFeeRequestQuery, u as useChain, i as useChainAction, j as useChains, k as useExchangeRate, l as useExchangeRateAction } from './misc-mjFkGr9I.js';
|
|
10
|
+
import { CancelError, SigningError, UnexpectedError as UnexpectedError$1, ValidationError, TimeoutError, TransactionError } from '@aave/core';
|
|
11
11
|
import { UserPositionQueryOptions } from '@aave/client/actions';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -208,6 +208,137 @@ declare function useHubAssets(args: UseHubAssetsArgs): ReadResult<HubAsset[]>;
|
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
210
|
declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadResult<HubAsset[]>;
|
|
211
|
+
type UseHubSummaryHistoryArgs = HubSummaryHistoryRequest;
|
|
212
|
+
/**
|
|
213
|
+
* Fetch historical summary data for a specific hub.
|
|
214
|
+
*
|
|
215
|
+
* This signature supports React Suspense:
|
|
216
|
+
*
|
|
217
|
+
* ```tsx
|
|
218
|
+
* const { data } = useHubSummaryHistory({
|
|
219
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
220
|
+
* currency: Currency.Usd,
|
|
221
|
+
* window: TimeWindow.LastWeek,
|
|
222
|
+
* suspense: true,
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs & Suspendable): SuspenseResult<HubSummarySample[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Fetch historical summary data for a specific hub.
|
|
229
|
+
*
|
|
230
|
+
* Pausable suspense mode.
|
|
231
|
+
*
|
|
232
|
+
* ```tsx
|
|
233
|
+
* const { data } = useHubSummaryHistory({
|
|
234
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
235
|
+
* suspense: true,
|
|
236
|
+
* pause: true,
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs> & Suspendable): PausableSuspenseResult<HubSummarySample[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Fetch historical summary data for a specific hub.
|
|
243
|
+
*
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const { data, error, loading } = useHubSummaryHistory({
|
|
246
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
247
|
+
* currency: Currency.Usd,
|
|
248
|
+
* window: TimeWindow.LastWeek,
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs): ReadResult<HubSummarySample[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Fetch historical summary data for a specific hub.
|
|
255
|
+
*
|
|
256
|
+
* Pausable loading state mode.
|
|
257
|
+
*
|
|
258
|
+
* ```tsx
|
|
259
|
+
* const { data, error, loading, paused } = useHubSummaryHistory({
|
|
260
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
261
|
+
* pause: true,
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs>): PausableReadResult<HubSummarySample[]>;
|
|
266
|
+
type UseHubAssetInterestRateModelArgs = Prettify<HubAssetInterestRateModelRequest & CurrencyQueryOptions>;
|
|
267
|
+
/**
|
|
268
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
269
|
+
*
|
|
270
|
+
* This signature supports React Suspense:
|
|
271
|
+
*
|
|
272
|
+
* ```tsx
|
|
273
|
+
* const { data } = useHubAssetInterestRateModel({
|
|
274
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
275
|
+
* suspense: true,
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare function useHubAssetInterestRateModel(args: UseHubAssetInterestRateModelArgs & Suspendable): SuspenseResult<HubAssetInterestRateModelPoint[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
282
|
+
*
|
|
283
|
+
* Pausable suspense mode.
|
|
284
|
+
*
|
|
285
|
+
* ```tsx
|
|
286
|
+
* const { data } = useHubAssetInterestRateModel({
|
|
287
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
288
|
+
* suspense: true,
|
|
289
|
+
* pause: true,
|
|
290
|
+
* });
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
declare function useHubAssetInterestRateModel(args: Pausable<UseHubAssetInterestRateModelArgs> & Suspendable): PausableSuspenseResult<HubAssetInterestRateModelPoint[]>;
|
|
294
|
+
/**
|
|
295
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
296
|
+
*
|
|
297
|
+
* ```tsx
|
|
298
|
+
* const { data, error, loading } = useHubAssetInterestRateModel({
|
|
299
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
declare function useHubAssetInterestRateModel(args: UseHubAssetInterestRateModelArgs): ReadResult<HubAssetInterestRateModelPoint[]>;
|
|
304
|
+
/**
|
|
305
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
306
|
+
*
|
|
307
|
+
* Pausable loading state mode.
|
|
308
|
+
*
|
|
309
|
+
* ```tsx
|
|
310
|
+
* const { data, error, loading, paused } = useHubAssetInterestRateModel({
|
|
311
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
312
|
+
* pause: true,
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
declare function useHubAssetInterestRateModel(args: Pausable<UseHubAssetInterestRateModelArgs>): PausableReadResult<HubAssetInterestRateModelPoint[]>;
|
|
317
|
+
/**
|
|
318
|
+
* Low-level hook to execute a {@link hubAssetInterestRateModel} action directly.
|
|
319
|
+
*
|
|
320
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
321
|
+
* @remarks
|
|
322
|
+
* This hook **does not** actively watch for updated data.
|
|
323
|
+
* Use this hook to retrieve data on demand as part of a larger workflow.
|
|
324
|
+
*
|
|
325
|
+
* ```ts
|
|
326
|
+
* const [execute, { called, data, error, loading }] = useHubAssetInterestRateModelAction();
|
|
327
|
+
*
|
|
328
|
+
* // …
|
|
329
|
+
*
|
|
330
|
+
* const result = await execute({
|
|
331
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
332
|
+
* });
|
|
333
|
+
*
|
|
334
|
+
* if (result.isOk()) {
|
|
335
|
+
* console.log(result.value); // HubAssetInterestRateModelPoint[]
|
|
336
|
+
* } else {
|
|
337
|
+
* console.error(result.error);
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function useHubAssetInterestRateModelAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubAssetInterestRateModelRequest, HubAssetInterestRateModelPoint[], UnexpectedError>;
|
|
211
342
|
/**
|
|
212
343
|
* Low-level hook to execute a {@link hubs} action directly.
|
|
213
344
|
*
|
|
@@ -237,11 +368,6 @@ declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadRes
|
|
|
237
368
|
*/
|
|
238
369
|
declare function useHubsAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubsRequest, Hub[], UnexpectedError>;
|
|
239
370
|
|
|
240
|
-
/**
|
|
241
|
-
* @internal
|
|
242
|
-
*/
|
|
243
|
-
declare function usePermitTypedDataAction(): UseAsyncTask<PermitRequest, PermitTypedDataResponse, UnexpectedError>;
|
|
244
|
-
|
|
245
371
|
type UseAssetArgs = Prettify<AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
246
372
|
/**
|
|
247
373
|
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
@@ -350,7 +476,7 @@ declare function useAssetPriceHistory(args: UseAssetPriceHistoryArgs): ReadResul
|
|
|
350
476
|
* ```
|
|
351
477
|
*/
|
|
352
478
|
declare function useAssetPriceHistory(args: Pausable<UseAssetPriceHistoryArgs>): PausableReadResult<AssetPriceSample[]>;
|
|
353
|
-
type UseAssetSupplyHistoryArgs = AssetSupplyHistoryRequest
|
|
479
|
+
type UseAssetSupplyHistoryArgs = Prettify<AssetSupplyHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
354
480
|
/**
|
|
355
481
|
* Fetch historical supply data for a specific asset.
|
|
356
482
|
*
|
|
@@ -403,7 +529,7 @@ declare function useAssetSupplyHistory(args: UseAssetSupplyHistoryArgs): ReadRes
|
|
|
403
529
|
* ```
|
|
404
530
|
*/
|
|
405
531
|
declare function useAssetSupplyHistory(args: Pausable<UseAssetSupplyHistoryArgs>): PausableReadResult<AssetSupplySample[]>;
|
|
406
|
-
type UseAssetBorrowHistoryArgs = AssetBorrowHistoryRequest
|
|
532
|
+
type UseAssetBorrowHistoryArgs = Prettify<AssetBorrowHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
407
533
|
/**
|
|
408
534
|
* Fetch historical borrow data for a specific asset.
|
|
409
535
|
*
|
|
@@ -592,18 +718,8 @@ declare function useReserve(args: Pausable<UseReserveArgs>): PausableReadResult<
|
|
|
592
718
|
* }
|
|
593
719
|
* ```
|
|
594
720
|
*/
|
|
595
|
-
declare function useReserveAction(options?:
|
|
596
|
-
type UseReservesArgs
|
|
597
|
-
/**
|
|
598
|
-
* A function that maps the full list of reserves
|
|
599
|
-
* into a derived or narrowed value.
|
|
600
|
-
*
|
|
601
|
-
* Example: pick a single reserve based on a criteria.
|
|
602
|
-
*
|
|
603
|
-
* @experimental This is experimental and may be subject to breaking changes.
|
|
604
|
-
*/
|
|
605
|
-
selector?: Selector<Reserve[], T>;
|
|
606
|
-
}>;
|
|
721
|
+
declare function useReserveAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError>;
|
|
722
|
+
type UseReservesArgs = Prettify<ReservesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
607
723
|
/**
|
|
608
724
|
* Fetch reserves based on specified criteria.
|
|
609
725
|
*
|
|
@@ -622,36 +738,8 @@ type UseReservesArgs<T = Reserve[]> = Prettify<ReservesRequest & CurrencyQueryOp
|
|
|
622
738
|
* suspense: true,
|
|
623
739
|
* });
|
|
624
740
|
* ```
|
|
625
|
-
*
|
|
626
|
-
* **Reserves with Highest Supply APY**
|
|
627
|
-
* ```tsx
|
|
628
|
-
* const { data } = useReserves({
|
|
629
|
-
* query: {
|
|
630
|
-
* spoke: {
|
|
631
|
-
* address: evmAddress('0x123...'),
|
|
632
|
-
* chainId: chainId(1)
|
|
633
|
-
* }
|
|
634
|
-
* },
|
|
635
|
-
* suspense: true,
|
|
636
|
-
* selector: pickHighestSupplyApyReserve,
|
|
637
|
-
* });
|
|
638
|
-
* ```
|
|
639
|
-
*
|
|
640
|
-
* **Reserves with Lowest Borrow APY**
|
|
641
|
-
* ```tsx
|
|
642
|
-
* const { data } = useReserves({
|
|
643
|
-
* query: {
|
|
644
|
-
* spoke: {
|
|
645
|
-
* address: evmAddress('0x123...'),
|
|
646
|
-
* chainId: chainId(1)
|
|
647
|
-
* }
|
|
648
|
-
* },
|
|
649
|
-
* suspense: true,
|
|
650
|
-
* selector: pickLowestBorrowApyReserve,
|
|
651
|
-
* });
|
|
652
|
-
* ```
|
|
653
741
|
*/
|
|
654
|
-
declare function useReserves
|
|
742
|
+
declare function useReserves(args: UseReservesArgs & Suspendable): SuspenseResult<Reserve[]>;
|
|
655
743
|
/**
|
|
656
744
|
* Fetch reserves based on specified criteria.
|
|
657
745
|
*
|
|
@@ -670,7 +758,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T> & Suspendab
|
|
|
670
758
|
* });
|
|
671
759
|
* ```
|
|
672
760
|
*/
|
|
673
|
-
declare function useReserves
|
|
761
|
+
declare function useReserves(args: Pausable<UseReservesArgs> & Suspendable): PausableSuspenseResult<Reserve[]>;
|
|
674
762
|
/**
|
|
675
763
|
* Fetch reserves based on specified criteria.
|
|
676
764
|
*
|
|
@@ -686,34 +774,8 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>> &
|
|
|
686
774
|
* orderBy: { name: 'ASC' },
|
|
687
775
|
* });
|
|
688
776
|
* ```
|
|
689
|
-
*
|
|
690
|
-
* **Reserves with Highest Supply APY**
|
|
691
|
-
* ```tsx
|
|
692
|
-
* const { data } = useReserves({
|
|
693
|
-
* query: {
|
|
694
|
-
* spoke: {
|
|
695
|
-
* address: evmAddress('0x123...'),
|
|
696
|
-
* chainId: chainId(1)
|
|
697
|
-
* }
|
|
698
|
-
* },
|
|
699
|
-
* selector: pickHighestSupplyApyReserve,
|
|
700
|
-
* });
|
|
701
|
-
* ```
|
|
702
|
-
*
|
|
703
|
-
* **Reserves with Lowest Borrow APY**
|
|
704
|
-
* ```tsx
|
|
705
|
-
* const { data } = useReserves({
|
|
706
|
-
* query: {
|
|
707
|
-
* spoke: {
|
|
708
|
-
* address: evmAddress('0x123...'),
|
|
709
|
-
* chainId: chainId(1)
|
|
710
|
-
* }
|
|
711
|
-
* },
|
|
712
|
-
* selector: pickLowestBorrowApyReserve,
|
|
713
|
-
* });
|
|
714
|
-
* ```
|
|
715
777
|
*/
|
|
716
|
-
declare function useReserves
|
|
778
|
+
declare function useReserves(args: UseReservesArgs): ReadResult<Reserve[], UnexpectedError>;
|
|
717
779
|
/**
|
|
718
780
|
* Fetch reserves based on specified criteria.
|
|
719
781
|
*
|
|
@@ -731,7 +793,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T>): ReadResul
|
|
|
731
793
|
* });
|
|
732
794
|
* ```
|
|
733
795
|
*/
|
|
734
|
-
declare function useReserves
|
|
796
|
+
declare function useReserves(args: Pausable<UseReservesArgs>): PausableReadResult<Reserve[], UnexpectedError>;
|
|
735
797
|
/**
|
|
736
798
|
* Low-level hook to execute a {@link reserves} action directly.
|
|
737
799
|
*
|
|
@@ -761,38 +823,8 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>>):
|
|
|
761
823
|
* console.error(result.error);
|
|
762
824
|
* }
|
|
763
825
|
* ```
|
|
764
|
-
*
|
|
765
|
-
* **Reserves with Highest Supply APY**
|
|
766
|
-
* ```ts
|
|
767
|
-
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
768
|
-
*
|
|
769
|
-
* // …
|
|
770
|
-
*
|
|
771
|
-
* const result = await execute(…).map(pickHighestSupplyApyReserve);
|
|
772
|
-
*
|
|
773
|
-
* if (result.isOk()) {
|
|
774
|
-
* console.log(result.value); // Reserve | null
|
|
775
|
-
* } else {
|
|
776
|
-
* console.error(result.error);
|
|
777
|
-
* }
|
|
778
|
-
* ```
|
|
779
|
-
*
|
|
780
|
-
* **Reserves with Lowest Borrow APY**
|
|
781
|
-
* ```ts
|
|
782
|
-
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
783
|
-
*
|
|
784
|
-
* // …
|
|
785
|
-
*
|
|
786
|
-
* const result = await execute(…).map(pickLowestBorrowApyReserve);
|
|
787
|
-
*
|
|
788
|
-
* if (result.isOk()) {
|
|
789
|
-
* console.log(result.value); // Reserve | null
|
|
790
|
-
* } else {
|
|
791
|
-
* console.error(result.error);
|
|
792
|
-
* }
|
|
793
|
-
* ```
|
|
794
826
|
*/
|
|
795
|
-
declare function useReservesAction(options?:
|
|
827
|
+
declare function useReservesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError>;
|
|
796
828
|
type UseBorrowApyHistoryArgs = BorrowApyHistoryRequest;
|
|
797
829
|
/**
|
|
798
830
|
* Fetch borrow APY history for a specific reserve over time.
|
|
@@ -904,6 +936,84 @@ declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<
|
|
|
904
936
|
*/
|
|
905
937
|
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<ApySample[]>;
|
|
906
938
|
|
|
939
|
+
type UseUserClaimableRewardsArgs = Prettify<UserClaimableRewardsRequest>;
|
|
940
|
+
/**
|
|
941
|
+
* Fetch all claimable rewards for a user.
|
|
942
|
+
*
|
|
943
|
+
* This signature supports React Suspense:
|
|
944
|
+
*
|
|
945
|
+
* ```tsx
|
|
946
|
+
* const { data } = useUserClaimableRewards({
|
|
947
|
+
* user: evmAddress('0x742d35cc…'),
|
|
948
|
+
* suspense: true,
|
|
949
|
+
* });
|
|
950
|
+
* ```
|
|
951
|
+
*/
|
|
952
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs & Suspendable): SuspenseResult<UserClaimableReward[]>;
|
|
953
|
+
/**
|
|
954
|
+
* Fetch all claimable rewards for a user.
|
|
955
|
+
*
|
|
956
|
+
* Pausable suspense mode.
|
|
957
|
+
*
|
|
958
|
+
* ```tsx
|
|
959
|
+
* const { data } = useUserClaimableRewards({
|
|
960
|
+
* user: evmAddress('0x742d35cc…'),
|
|
961
|
+
* suspense: true,
|
|
962
|
+
* pause: true,
|
|
963
|
+
* });
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs> & Suspendable): PausableSuspenseResult<UserClaimableReward[]>;
|
|
967
|
+
/**
|
|
968
|
+
* Fetch all claimable rewards for a user.
|
|
969
|
+
*
|
|
970
|
+
* ```tsx
|
|
971
|
+
* const { data, error, loading } = useUserClaimableRewards({
|
|
972
|
+
* user: evmAddress('0x742d35cc…'),
|
|
973
|
+
* });
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
976
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs): ReadResult<UserClaimableReward[]>;
|
|
977
|
+
/**
|
|
978
|
+
* Fetch all claimable rewards for a user.
|
|
979
|
+
*
|
|
980
|
+
* Pausable loading state mode.
|
|
981
|
+
*
|
|
982
|
+
* ```tsx
|
|
983
|
+
* const { data, error, loading, paused } = useUserClaimableRewards({
|
|
984
|
+
* user: evmAddress('0x742d35cc…'),
|
|
985
|
+
* pause: true,
|
|
986
|
+
* });
|
|
987
|
+
* ```
|
|
988
|
+
*/
|
|
989
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs>): PausableReadResult<UserClaimableReward[]>;
|
|
990
|
+
/**
|
|
991
|
+
* Low-level hook to execute a {@link userClaimableRewards} action directly.
|
|
992
|
+
*
|
|
993
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
994
|
+
* @remarks
|
|
995
|
+
* This hook **does not** actively watch for updated data on claimable rewards.
|
|
996
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
997
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
998
|
+
*
|
|
999
|
+
* ```ts
|
|
1000
|
+
* const [execute, { called, data, error, loading }] = useUserClaimableRewardsAction();
|
|
1001
|
+
*
|
|
1002
|
+
* // …
|
|
1003
|
+
*
|
|
1004
|
+
* const result = await execute({
|
|
1005
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1006
|
+
* });
|
|
1007
|
+
*
|
|
1008
|
+
* if (result.isOk()) {
|
|
1009
|
+
* console.log(result.value); // UserClaimableReward[]
|
|
1010
|
+
* } else {
|
|
1011
|
+
* console.error(result.error);
|
|
1012
|
+
* }
|
|
1013
|
+
* ```
|
|
1014
|
+
*/
|
|
1015
|
+
declare function useUserClaimableRewardsAction(): UseAsyncTask<UserClaimableRewardsRequest, UserClaimableReward[], UnexpectedError>;
|
|
1016
|
+
|
|
907
1017
|
type UseSpokeArgs = SpokeRequest;
|
|
908
1018
|
/**
|
|
909
1019
|
* Fetch a specific spoke.
|
|
@@ -1115,168 +1225,727 @@ declare function useSpokeUserPositionManagers(args: UseSpokeUserPositionManagers
|
|
|
1115
1225
|
*/
|
|
1116
1226
|
declare function useSpokeUserPositionManagers(args: Pausable<UseSpokeUserPositionManagersArgs>): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1117
1227
|
|
|
1118
|
-
type
|
|
1228
|
+
type SwapHandlerOptions = {
|
|
1229
|
+
cancel: CancelOperation;
|
|
1230
|
+
};
|
|
1231
|
+
type SwapSignerError = CancelError | SigningError | UnexpectedError$1;
|
|
1232
|
+
type PositionSwapPlan = PositionSwapApproval | SwapTypedData;
|
|
1233
|
+
type PositionSwapHandler = (plan: PositionSwapPlan, options: SwapHandlerOptions) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1234
|
+
type PositionSwapValue = {
|
|
1235
|
+
quote?: SwapQuote;
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
type UseBorrowSwapRequest = Prettify<BorrowSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1119
1239
|
/**
|
|
1120
|
-
*
|
|
1121
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1122
|
-
*
|
|
1123
|
-
* This signature supports React Suspense:
|
|
1240
|
+
* Orchestrate the borrow swap execution plan.
|
|
1124
1241
|
*
|
|
1125
1242
|
* ```tsx
|
|
1126
|
-
* const
|
|
1127
|
-
* chainId: chainId(1),
|
|
1128
|
-
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1129
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1130
|
-
* amount: bigDecimal('1000'),
|
|
1131
|
-
* kind: SwapKind.SELL,
|
|
1132
|
-
* suspense: true,
|
|
1133
|
-
* });
|
|
1134
|
-
* ```
|
|
1135
|
-
*/
|
|
1136
|
-
declare function useSwapQuote(args: UseSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1137
|
-
/**
|
|
1138
|
-
* @internal
|
|
1139
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1243
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1140
1244
|
*
|
|
1141
|
-
*
|
|
1245
|
+
* const [swapBorrow, { loading, error }] = useBorrowSwap((plan) => {
|
|
1246
|
+
* switch (plan.__typename) {
|
|
1247
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1248
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1249
|
+
* return signTypedData(plan.bySignature);
|
|
1142
1250
|
*
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1251
|
+
* case 'SwapTypedData':
|
|
1252
|
+
* return signTypedData(plan);
|
|
1253
|
+
* }
|
|
1254
|
+
* });
|
|
1255
|
+
*
|
|
1256
|
+
* const result = await swapBorrow({
|
|
1257
|
+
* market: {
|
|
1258
|
+
* debtPosition: userBorrowItem.id,
|
|
1259
|
+
* buyReserve: targetReserve.id,
|
|
1260
|
+
* amount: bigDecimal('1000'),
|
|
1261
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1262
|
+
* },
|
|
1263
|
+
* });
|
|
1264
|
+
*
|
|
1265
|
+
* if (result.isErr()) {
|
|
1266
|
+
* console.error(result.error);
|
|
1267
|
+
* return;
|
|
1268
|
+
* }
|
|
1269
|
+
*
|
|
1270
|
+
* // result.value: SwapReceipt
|
|
1271
|
+
* ```
|
|
1272
|
+
*/
|
|
1273
|
+
declare function useBorrowSwap(handler: PositionSwapHandler): UseAsyncTask<BorrowSwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1274
|
+
|
|
1275
|
+
type UseBorrowSwapQuoteArgs = Prettify<BorrowSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1276
|
+
/**
|
|
1277
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1278
|
+
*
|
|
1279
|
+
* This signature supports React Suspense:
|
|
1280
|
+
*
|
|
1281
|
+
* ```tsx
|
|
1282
|
+
* const { data } = useBorrowSwapQuote({
|
|
1283
|
+
* market: {
|
|
1284
|
+
* sellPosition: userBorrowItem.id,
|
|
1285
|
+
* buyReserve: reserve.id,
|
|
1286
|
+
* amount: bigDecimal('1000'),
|
|
1287
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1288
|
+
* },
|
|
1289
|
+
* suspense: true,
|
|
1290
|
+
* });
|
|
1291
|
+
* ```
|
|
1292
|
+
*/
|
|
1293
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1296
|
+
*
|
|
1297
|
+
* Pausable suspense mode.
|
|
1298
|
+
*
|
|
1299
|
+
* ```tsx
|
|
1300
|
+
* const { data } = useBorrowSwapQuote({
|
|
1301
|
+
* market: {
|
|
1302
|
+
* sellPosition: userBorrowItem.id,
|
|
1303
|
+
* buyReserve: reserve.id,
|
|
1304
|
+
* amount: bigDecimal('1000'),
|
|
1305
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1306
|
+
* },
|
|
1307
|
+
* suspense: true,
|
|
1308
|
+
* pause: true,
|
|
1309
|
+
* });
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1313
|
+
/**
|
|
1314
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1315
|
+
*
|
|
1316
|
+
* ```tsx
|
|
1317
|
+
* const { data, error, loading } = useBorrowSwapQuote({
|
|
1318
|
+
* market: {
|
|
1319
|
+
* sellPosition: userBorrowItem.id,
|
|
1320
|
+
* buyReserve: reserve.id,
|
|
1321
|
+
* amount: bigDecimal('1000'),
|
|
1322
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1323
|
+
* },
|
|
1324
|
+
* });
|
|
1325
|
+
* ```
|
|
1326
|
+
*/
|
|
1327
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1330
|
+
*
|
|
1331
|
+
* Pausable loading state mode.
|
|
1332
|
+
*
|
|
1333
|
+
* ```tsx
|
|
1334
|
+
* const { data, error, loading, paused } = useBorrowSwapQuote({
|
|
1335
|
+
* market: {
|
|
1336
|
+
* sellPosition: userBorrowItem.id,
|
|
1337
|
+
* buyReserve: reserve.id,
|
|
1338
|
+
* amount: bigDecimal('1000'),
|
|
1339
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1340
|
+
* },
|
|
1152
1341
|
* pause: true,
|
|
1153
1342
|
* });
|
|
1154
1343
|
* ```
|
|
1155
1344
|
*/
|
|
1156
|
-
declare function
|
|
1345
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1346
|
+
/**
|
|
1347
|
+
* Low-level hook to execute a borrow swap quote action directly.
|
|
1348
|
+
*
|
|
1349
|
+
* @remarks
|
|
1350
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1351
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1352
|
+
*
|
|
1353
|
+
* ```ts
|
|
1354
|
+
* const [getQuote, { called, data, error, loading }] = useBorrowSwapQuoteAction();
|
|
1355
|
+
*
|
|
1356
|
+
* // …
|
|
1357
|
+
*
|
|
1358
|
+
* const result = await getQuote({
|
|
1359
|
+
* debtPosition: userBorrowItem.id,
|
|
1360
|
+
* buyReserve: reserve.id,
|
|
1361
|
+
* amount: bigDecimal('1000'),
|
|
1362
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1363
|
+
* });
|
|
1364
|
+
*
|
|
1365
|
+
* if (result.isOk()) {
|
|
1366
|
+
* console.log('Borrow swap quote:', result.value);
|
|
1367
|
+
* } else {
|
|
1368
|
+
* console.error(result.error);
|
|
1369
|
+
* }
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
declare function useBorrowSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<BorrowSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1373
|
+
|
|
1374
|
+
type CancelSwapHandler = (data: SwapTypedData | TransactionRequest, options: {
|
|
1375
|
+
cancel: typeof cancel;
|
|
1376
|
+
}) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1377
|
+
declare class CannotCancelSwapError extends ResultAwareError {
|
|
1378
|
+
name: "CannotCancelSwapError";
|
|
1379
|
+
}
|
|
1380
|
+
type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | TimeoutError | TransactionError | UnexpectedError$1;
|
|
1381
|
+
/**
|
|
1382
|
+
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
1383
|
+
*
|
|
1384
|
+
* ```tsx
|
|
1385
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1386
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1387
|
+
*
|
|
1388
|
+
* const [cancelSwap, { loading, error }] = useCancelSwap((plan) => {
|
|
1389
|
+
* switch (plan.__typename) {
|
|
1390
|
+
* case 'TransactionRequest':
|
|
1391
|
+
* return sendTransaction(plan);
|
|
1392
|
+
*
|
|
1393
|
+
* case 'SwapTypedData':
|
|
1394
|
+
* return signTypedData(plan);
|
|
1395
|
+
* }
|
|
1396
|
+
* });
|
|
1397
|
+
*
|
|
1398
|
+
* const result = await cancelSwap({
|
|
1399
|
+
* id: swapId('123…'),
|
|
1400
|
+
* });
|
|
1401
|
+
*
|
|
1402
|
+
* if (result.isErr()) {
|
|
1403
|
+
* console.error(result.error);
|
|
1404
|
+
* return;
|
|
1405
|
+
* }
|
|
1406
|
+
*
|
|
1407
|
+
* // result.value: SwapCancelledResult
|
|
1408
|
+
* console.log('Swap cancelled:', result.value);
|
|
1409
|
+
* ```
|
|
1410
|
+
*/
|
|
1411
|
+
declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<PrepareSwapCancelRequest, SwapCancelledResult, CancelSwapError>;
|
|
1412
|
+
|
|
1413
|
+
type UseRepayWithSupplyRequest = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1414
|
+
/**
|
|
1415
|
+
* Orchestrate the repay with supply execution plan.
|
|
1416
|
+
*
|
|
1417
|
+
* ```tsx
|
|
1418
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1419
|
+
*
|
|
1420
|
+
* const [repayWithSupply, { loading, error }] = useRepayWithSupply((plan) => {
|
|
1421
|
+
* switch (plan.__typename) {
|
|
1422
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1423
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1424
|
+
* return signTypedData(plan.bySignature);
|
|
1425
|
+
*
|
|
1426
|
+
* case 'SwapTypedData':
|
|
1427
|
+
* return signTypedData(plan);
|
|
1428
|
+
* }
|
|
1429
|
+
* });
|
|
1430
|
+
*
|
|
1431
|
+
* const result = await repayWithSupply({
|
|
1432
|
+
* market: {
|
|
1433
|
+
* sellPosition: userSupplyItem.id,
|
|
1434
|
+
* buyPosition: userBorrowItem.id,
|
|
1435
|
+
* amount: bigDecimal('1000'),
|
|
1436
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1437
|
+
* },
|
|
1438
|
+
* });
|
|
1439
|
+
*
|
|
1440
|
+
* if (result.isErr()) {
|
|
1441
|
+
* console.error(result.error);
|
|
1442
|
+
* return;
|
|
1443
|
+
* }
|
|
1444
|
+
*
|
|
1445
|
+
* // result.value: SwapReceipt
|
|
1446
|
+
* ```
|
|
1447
|
+
*/
|
|
1448
|
+
declare function useRepayWithSupply(handler: PositionSwapHandler): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1449
|
+
|
|
1450
|
+
type UseRepayWithSupplyQuoteArgs = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1451
|
+
/**
|
|
1452
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1453
|
+
*
|
|
1454
|
+
* This signature supports React Suspense:
|
|
1455
|
+
*
|
|
1456
|
+
* ```tsx
|
|
1457
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1458
|
+
* market: {
|
|
1459
|
+
* sellPosition: userSupplyItem.id,
|
|
1460
|
+
* buyPosition: userBorrowItem.id,
|
|
1461
|
+
* amount: bigDecimal('1000'),
|
|
1462
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1463
|
+
* },
|
|
1464
|
+
* suspense: true,
|
|
1465
|
+
* });
|
|
1466
|
+
* ```
|
|
1467
|
+
*/
|
|
1468
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1471
|
+
*
|
|
1472
|
+
* Pausable suspense mode.
|
|
1473
|
+
*
|
|
1474
|
+
* ```tsx
|
|
1475
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1476
|
+
* market: {
|
|
1477
|
+
* sellPosition: userSupplyItem.id,
|
|
1478
|
+
* buyPosition: userBorrowItem.id,
|
|
1479
|
+
* amount: bigDecimal('1000'),
|
|
1480
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1481
|
+
* },
|
|
1482
|
+
* suspense: true,
|
|
1483
|
+
* pause: true,
|
|
1484
|
+
* });
|
|
1485
|
+
* ```
|
|
1486
|
+
*/
|
|
1487
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1490
|
+
*
|
|
1491
|
+
* ```tsx
|
|
1492
|
+
* const { data, error, loading } = useRepayWithSupplyQuote({
|
|
1493
|
+
* market: {
|
|
1494
|
+
* sellPosition: userSupplyItem.id,
|
|
1495
|
+
* buyPosition: userBorrowItem.id,
|
|
1496
|
+
* amount: bigDecimal('1000'),
|
|
1497
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1498
|
+
* },
|
|
1499
|
+
* });
|
|
1500
|
+
* ```
|
|
1501
|
+
*/
|
|
1502
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs): ReadResult<SwapQuote>;
|
|
1503
|
+
/**
|
|
1504
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1505
|
+
*
|
|
1506
|
+
* Pausable loading state mode.
|
|
1507
|
+
*
|
|
1508
|
+
* ```tsx
|
|
1509
|
+
* const { data, error, loading, paused } = useRepayWithSupplyQuote({
|
|
1510
|
+
* market: {
|
|
1511
|
+
* sellPosition: userSupplyItem.id,
|
|
1512
|
+
* buyPosition: userBorrowItem.id,
|
|
1513
|
+
* amount: bigDecimal('1000'),
|
|
1514
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1515
|
+
* },
|
|
1516
|
+
* pause: true,
|
|
1517
|
+
* });
|
|
1518
|
+
* ```
|
|
1519
|
+
*/
|
|
1520
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1521
|
+
/**
|
|
1522
|
+
* Low-level hook to execute a repay with supply quote action directly.
|
|
1523
|
+
*
|
|
1524
|
+
* @remarks
|
|
1525
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1526
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1527
|
+
*
|
|
1528
|
+
* ```ts
|
|
1529
|
+
* const [getQuote, { called, data, error, loading }] = useRepayWithSupplyQuoteAction();
|
|
1530
|
+
*
|
|
1531
|
+
* // …
|
|
1532
|
+
*
|
|
1533
|
+
* const result = await getQuote({
|
|
1534
|
+
* repayWithReserve: reserve.id,
|
|
1535
|
+
* debtPosition: userBorrowItem.id,
|
|
1536
|
+
* amount: bigDecimal('1000'),
|
|
1537
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1538
|
+
* });
|
|
1539
|
+
*
|
|
1540
|
+
* if (result.isOk()) {
|
|
1541
|
+
* console.log('Repay with supply quote:', result.value);
|
|
1542
|
+
* } else {
|
|
1543
|
+
* console.error(result.error);
|
|
1544
|
+
* }
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
declare function useRepayWithSupplyQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1548
|
+
|
|
1549
|
+
type UseSupplySwapRequest = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1550
|
+
/**
|
|
1551
|
+
* Orchestrate the supply swap execution plan.
|
|
1552
|
+
*
|
|
1553
|
+
* ```tsx
|
|
1554
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1555
|
+
*
|
|
1556
|
+
* const [swapSupply, { loading, error }] = useSupplySwap((plan) => {
|
|
1557
|
+
* switch (plan.__typename) {
|
|
1558
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1559
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1560
|
+
* return signTypedData(plan.bySignature);
|
|
1561
|
+
*
|
|
1562
|
+
* case 'SwapTypedData':
|
|
1563
|
+
* return signTypedData(plan);
|
|
1564
|
+
* }
|
|
1565
|
+
* });
|
|
1566
|
+
*
|
|
1567
|
+
* const result = await swapSupply({
|
|
1568
|
+
* market: {
|
|
1569
|
+
* sellPosition: supplyPosition.id,
|
|
1570
|
+
* buyReserve: targetReserve.id,
|
|
1571
|
+
* amount: bigDecimal('1000'),
|
|
1572
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1573
|
+
* enableCollateral: true,
|
|
1574
|
+
* },
|
|
1575
|
+
* });
|
|
1576
|
+
*
|
|
1577
|
+
* if (result.isErr()) {
|
|
1578
|
+
* console.error(result.error);
|
|
1579
|
+
* return;
|
|
1580
|
+
* }
|
|
1581
|
+
*
|
|
1582
|
+
* // result.value: SwapReceipt
|
|
1583
|
+
* ```
|
|
1584
|
+
*/
|
|
1585
|
+
declare function useSupplySwap(handler: PositionSwapHandler): UseAsyncTask<SupplySwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1586
|
+
|
|
1587
|
+
type UseSupplySwapQuoteArgs = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1588
|
+
/**
|
|
1589
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1590
|
+
*
|
|
1591
|
+
* This signature supports React Suspense:
|
|
1592
|
+
*
|
|
1593
|
+
* ```tsx
|
|
1594
|
+
* const { data } = useSupplySwapQuote({
|
|
1595
|
+
* market: {
|
|
1596
|
+
* sellPosition: userSupplyItem.id,
|
|
1597
|
+
* buyReserve: reserve.id,
|
|
1598
|
+
* amount: bigDecimal('1000'),
|
|
1599
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1600
|
+
* },
|
|
1601
|
+
* suspense: true,
|
|
1602
|
+
* });
|
|
1603
|
+
* ```
|
|
1604
|
+
*/
|
|
1605
|
+
declare function useSupplySwapQuote(args: UseSupplySwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1608
|
+
*
|
|
1609
|
+
* Pausable suspense mode.
|
|
1610
|
+
*
|
|
1611
|
+
* ```tsx
|
|
1612
|
+
* const { data } = useSupplySwapQuote({
|
|
1613
|
+
* market: {
|
|
1614
|
+
* sellPosition: userSupplyItem.id,
|
|
1615
|
+
* buyReserve: reserve.id,
|
|
1616
|
+
* amount: bigDecimal('1000'),
|
|
1617
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1618
|
+
* },
|
|
1619
|
+
* suspense: true,
|
|
1620
|
+
* pause: true,
|
|
1621
|
+
* });
|
|
1622
|
+
* ```
|
|
1623
|
+
*/
|
|
1624
|
+
declare function useSupplySwapQuote(args: Pausable<UseSupplySwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1627
|
+
*
|
|
1628
|
+
* ```tsx
|
|
1629
|
+
* const { data, error, loading } = useSupplySwapQuote({
|
|
1630
|
+
* market: {
|
|
1631
|
+
* sellPosition: userSupplyItem.id,
|
|
1632
|
+
* buyReserve: reserve.id,
|
|
1633
|
+
* amount: bigDecimal('1000'),
|
|
1634
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1635
|
+
* },
|
|
1636
|
+
* });
|
|
1637
|
+
* ```
|
|
1638
|
+
*/
|
|
1639
|
+
declare function useSupplySwapQuote(args: UseSupplySwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1640
|
+
/**
|
|
1641
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1642
|
+
*
|
|
1643
|
+
* Pausable loading state mode.
|
|
1644
|
+
*
|
|
1645
|
+
* ```tsx
|
|
1646
|
+
* const { data, error, loading, paused } = useSupplySwapQuote({
|
|
1647
|
+
* market: {
|
|
1648
|
+
* sellPosition: userSupplyItem.id,
|
|
1649
|
+
* buyReserve: reserve.id,
|
|
1650
|
+
* amount: bigDecimal('1000'),
|
|
1651
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1652
|
+
* },
|
|
1653
|
+
* pause: true,
|
|
1654
|
+
* });
|
|
1655
|
+
* ```
|
|
1656
|
+
*/
|
|
1657
|
+
declare function useSupplySwapQuote(args: Pausable<UseSupplySwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1658
|
+
/**
|
|
1659
|
+
* Low-level hook to execute a supply swap quote action directly.
|
|
1660
|
+
*
|
|
1661
|
+
* @remarks
|
|
1662
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1663
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1664
|
+
*
|
|
1665
|
+
* ```ts
|
|
1666
|
+
* const [getQuote, { called, data, error, loading }] = useSupplySwapQuoteAction();
|
|
1667
|
+
*
|
|
1668
|
+
* // …
|
|
1669
|
+
*
|
|
1670
|
+
* const result = await getQuote({
|
|
1671
|
+
* sellPosition: userSupplyItem.id,
|
|
1672
|
+
* buyReserve: reserve.id,
|
|
1673
|
+
* amount: bigDecimal('1000'),
|
|
1674
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1675
|
+
* });
|
|
1676
|
+
*
|
|
1677
|
+
* if (result.isOk()) {
|
|
1678
|
+
* console.log('Supply swap quote:', result.value);
|
|
1679
|
+
* } else {
|
|
1680
|
+
* console.error(result.error);
|
|
1681
|
+
* }
|
|
1682
|
+
* ```
|
|
1683
|
+
*/
|
|
1684
|
+
declare function useSupplySwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<SupplySwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1685
|
+
|
|
1686
|
+
type UseSwappableTokensArgs = SwappableTokensRequest;
|
|
1687
|
+
/**
|
|
1688
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1689
|
+
*
|
|
1690
|
+
* This signature supports React Suspense:
|
|
1691
|
+
*
|
|
1692
|
+
* ```tsx
|
|
1693
|
+
* const { data } = useSwappableTokens({
|
|
1694
|
+
* query: { chainIds: [chainId(1)] },
|
|
1695
|
+
* suspense: true,
|
|
1696
|
+
* });
|
|
1697
|
+
* ```
|
|
1698
|
+
*/
|
|
1699
|
+
declare function useSwappableTokens(args: UseSwappableTokensArgs & Suspendable): SuspenseResult<Token[]>;
|
|
1700
|
+
/**
|
|
1701
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1702
|
+
*
|
|
1703
|
+
* Pausable suspense mode.
|
|
1704
|
+
*
|
|
1705
|
+
* ```tsx
|
|
1706
|
+
* const { data } = useSwappableTokens({
|
|
1707
|
+
* query: { chainIds: [chainId(1)] },
|
|
1708
|
+
* suspense: true,
|
|
1709
|
+
* pause: true,
|
|
1710
|
+
* });
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs> & Suspendable): PausableSuspenseResult<Token[]>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1716
|
+
*
|
|
1717
|
+
* ```tsx
|
|
1718
|
+
* const { data, error, loading } = useSwappableTokens({
|
|
1719
|
+
* query: { chainIds: [chainId(1)] },
|
|
1720
|
+
* });
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
declare function useSwappableTokens(args: UseSwappableTokensArgs): ReadResult<Token[]>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1726
|
+
*
|
|
1727
|
+
* Pausable loading state mode.
|
|
1728
|
+
*
|
|
1729
|
+
* ```tsx
|
|
1730
|
+
* const { data, error, loading, paused } = useSwappableTokens({
|
|
1731
|
+
* query: { chainIds: [chainId(1)] },
|
|
1732
|
+
* pause: true,
|
|
1733
|
+
* });
|
|
1734
|
+
* ```
|
|
1735
|
+
*/
|
|
1736
|
+
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs>): PausableReadResult<Token[]>;
|
|
1737
|
+
|
|
1738
|
+
type UseSwapStatusArgs = Prettify<SwapStatusRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1741
|
+
*
|
|
1742
|
+
* Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).
|
|
1743
|
+
*
|
|
1744
|
+
* This signature supports React Suspense:
|
|
1745
|
+
*
|
|
1746
|
+
* ```tsx
|
|
1747
|
+
* const { data } = useSwapStatus({
|
|
1748
|
+
* id: swapReceipt.id,
|
|
1749
|
+
* suspense: true,
|
|
1750
|
+
* });
|
|
1751
|
+
* ```
|
|
1752
|
+
*/
|
|
1753
|
+
declare function useSwapStatus(args: UseSwapStatusArgs & Suspendable): SuspenseResult<SwapStatus>;
|
|
1754
|
+
/**
|
|
1755
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1756
|
+
*
|
|
1757
|
+
* Pausable suspense mode.
|
|
1758
|
+
*
|
|
1759
|
+
* ```tsx
|
|
1760
|
+
* const { data } = useSwapStatus({
|
|
1761
|
+
* id: swapReceipt.id,
|
|
1762
|
+
* suspense: true,
|
|
1763
|
+
* pause: shouldPause,
|
|
1764
|
+
* });
|
|
1765
|
+
* ```
|
|
1766
|
+
*/
|
|
1767
|
+
declare function useSwapStatus(args: Pausable<UseSwapStatusArgs> & Suspendable): PausableSuspenseResult<SwapStatus>;
|
|
1157
1768
|
/**
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1769
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1770
|
+
*
|
|
1771
|
+
* Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).
|
|
1160
1772
|
*
|
|
1161
1773
|
* ```tsx
|
|
1162
|
-
* const { data, error, loading } =
|
|
1163
|
-
*
|
|
1164
|
-
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1165
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1166
|
-
* amount: bigDecimal('1000'),
|
|
1167
|
-
* kind: SwapKind.SELL,
|
|
1774
|
+
* const { data, error, loading } = useSwapStatus({
|
|
1775
|
+
* id: swapReceipt.id,
|
|
1168
1776
|
* });
|
|
1169
1777
|
* ```
|
|
1170
1778
|
*/
|
|
1171
|
-
declare function
|
|
1779
|
+
declare function useSwapStatus(args: UseSwapStatusArgs): ReadResult<SwapStatus>;
|
|
1172
1780
|
/**
|
|
1173
|
-
*
|
|
1174
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1781
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1175
1782
|
*
|
|
1176
1783
|
* Pausable loading state mode.
|
|
1177
1784
|
*
|
|
1178
1785
|
* ```tsx
|
|
1179
|
-
* const { data, error, loading, paused } =
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1183
|
-
* amount: bigDecimal('1000'),
|
|
1184
|
-
* kind: SwapKind.SELL,
|
|
1185
|
-
* from: evmAddress('0x742d35cc...'),
|
|
1186
|
-
* pause: true,
|
|
1786
|
+
* const { data, error, loading, paused } = useSwapStatus({
|
|
1787
|
+
* id: swapReceipt.id,
|
|
1788
|
+
* pause: shouldPause,
|
|
1187
1789
|
* });
|
|
1188
1790
|
* ```
|
|
1189
1791
|
*/
|
|
1190
|
-
declare function
|
|
1792
|
+
declare function useSwapStatus(args: Pausable<UseSwapStatusArgs>): PausableReadResult<SwapStatus>;
|
|
1793
|
+
|
|
1794
|
+
type UseTokenSwapRequest = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1795
|
+
type TokenSwapPlan = SwapTypedData | Erc20Approval | SwapTransactionRequest;
|
|
1796
|
+
type TokenSwapHandler = (plan: TokenSwapPlan, options: SwapHandlerOptions) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1191
1797
|
/**
|
|
1192
|
-
*
|
|
1193
|
-
* Low-level hook to execute a swap quote action directly.
|
|
1798
|
+
* Orchestrate the token swap execution plan.
|
|
1194
1799
|
*
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
*
|
|
1198
|
-
* Use this hook to retrieve quotes on demand as part of a larger workflow
|
|
1199
|
-
* (e.g., in an event handler to get a fresh quote before executing a swap).
|
|
1800
|
+
* ```tsx
|
|
1801
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1802
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1200
1803
|
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1804
|
+
* const [swap, { loading, error }] = useTokenSwap((plan) => {
|
|
1805
|
+
* switch (plan.__typename) {
|
|
1806
|
+
* case 'Erc20Approval':
|
|
1807
|
+
* if (plan.bySignature) {
|
|
1808
|
+
* return signTypedData(plan.bySignature);
|
|
1809
|
+
* }
|
|
1810
|
+
* return sendTransaction(plan.byTransaction);
|
|
1203
1811
|
*
|
|
1204
|
-
*
|
|
1812
|
+
* case 'SwapTransactionRequest':
|
|
1813
|
+
* return sendTransaction(plan.transaction);
|
|
1205
1814
|
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1210
|
-
* amount: bigDecimal('1000'),
|
|
1211
|
-
* kind: SwapKind.SELL,
|
|
1815
|
+
* case 'SwapTypedData':
|
|
1816
|
+
* return signTypedData(plan);
|
|
1817
|
+
* }
|
|
1212
1818
|
* });
|
|
1213
1819
|
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1820
|
+
* const result = await swap({
|
|
1821
|
+
* fromQuote: {
|
|
1822
|
+
* quoteId: quote.quoteId,
|
|
1823
|
+
* },
|
|
1824
|
+
* });
|
|
1825
|
+
*
|
|
1826
|
+
* if (result.isErr()) {
|
|
1217
1827
|
* console.error(result.error);
|
|
1828
|
+
* return;
|
|
1218
1829
|
* }
|
|
1830
|
+
*
|
|
1831
|
+
* // result.value: SwapReceipt
|
|
1219
1832
|
* ```
|
|
1220
1833
|
*/
|
|
1221
|
-
declare function
|
|
1222
|
-
|
|
1834
|
+
declare function useTokenSwap(handler: TokenSwapHandler): UseAsyncTask<UseTokenSwapRequest, SwapReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1835
|
+
|
|
1836
|
+
type UseTokenSwapQuoteArgs = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1223
1837
|
/**
|
|
1224
|
-
*
|
|
1225
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1838
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1226
1839
|
*
|
|
1227
1840
|
* This signature supports React Suspense:
|
|
1228
1841
|
*
|
|
1229
1842
|
* ```tsx
|
|
1230
|
-
* const { data } =
|
|
1231
|
-
*
|
|
1843
|
+
* const { data } = useTokenSwapQuote({
|
|
1844
|
+
* market: {
|
|
1845
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1846
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1847
|
+
* amount: bigDecimal('1000'),
|
|
1848
|
+
* kind: SwapKind.Sell,
|
|
1849
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1850
|
+
* },
|
|
1851
|
+
* chainId: chainId(1),
|
|
1232
1852
|
* suspense: true,
|
|
1233
1853
|
* });
|
|
1234
1854
|
* ```
|
|
1235
1855
|
*/
|
|
1236
|
-
declare function
|
|
1856
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1237
1857
|
/**
|
|
1238
|
-
*
|
|
1239
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1858
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1240
1859
|
*
|
|
1241
1860
|
* Pausable suspense mode.
|
|
1242
1861
|
*
|
|
1243
1862
|
* ```tsx
|
|
1244
|
-
* const { data } =
|
|
1245
|
-
*
|
|
1863
|
+
* const { data } = useTokenSwapQuote({
|
|
1864
|
+
* market: {
|
|
1865
|
+
* chainId: chainId(1),
|
|
1866
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1867
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1868
|
+
* amount: bigDecimal('1000'),
|
|
1869
|
+
* kind: SwapKind.Sell,
|
|
1870
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1871
|
+
* },
|
|
1246
1872
|
* suspense: true,
|
|
1247
1873
|
* pause: true,
|
|
1248
1874
|
* });
|
|
1249
1875
|
* ```
|
|
1250
1876
|
*/
|
|
1251
|
-
declare function
|
|
1877
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1252
1878
|
/**
|
|
1253
|
-
*
|
|
1254
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1879
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1255
1880
|
*
|
|
1256
1881
|
* ```tsx
|
|
1257
|
-
* const { data, error, loading } =
|
|
1258
|
-
*
|
|
1882
|
+
* const { data, error, loading } = useTokenSwapQuote({
|
|
1883
|
+
* market: {
|
|
1884
|
+
* chainId: chainId(1),
|
|
1885
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1886
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1887
|
+
* amount: bigDecimal('1000'),
|
|
1888
|
+
* kind: SwapKind.Sell,
|
|
1889
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1890
|
+
* },
|
|
1259
1891
|
* });
|
|
1260
1892
|
* ```
|
|
1261
1893
|
*/
|
|
1262
|
-
declare function
|
|
1894
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1263
1895
|
/**
|
|
1264
|
-
*
|
|
1265
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1896
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1266
1897
|
*
|
|
1267
1898
|
* Pausable loading state mode.
|
|
1268
1899
|
*
|
|
1269
1900
|
* ```tsx
|
|
1270
|
-
* const { data, error, loading, paused } =
|
|
1271
|
-
*
|
|
1901
|
+
* const { data, error, loading, paused } = useTokenSwapQuote({
|
|
1902
|
+
* market: {
|
|
1903
|
+
* chainId: chainId(1),
|
|
1904
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1905
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1906
|
+
* amount: bigDecimal('1000'),
|
|
1907
|
+
* kind: SwapKind.Sell,
|
|
1908
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1909
|
+
* },
|
|
1272
1910
|
* pause: true,
|
|
1273
1911
|
* });
|
|
1274
1912
|
* ```
|
|
1275
1913
|
*/
|
|
1276
|
-
declare function
|
|
1277
|
-
|
|
1914
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1915
|
+
/**
|
|
1916
|
+
* Low-level hook to execute a swap quote action directly.
|
|
1917
|
+
*
|
|
1918
|
+
* @remarks
|
|
1919
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1920
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow
|
|
1921
|
+
* (e.g., in an event handler to get a fresh quote before executing a swap).
|
|
1922
|
+
*
|
|
1923
|
+
* ```ts
|
|
1924
|
+
* const [getQuote, { called, data, error, loading }] = useTokenSwapQuoteAction();
|
|
1925
|
+
*
|
|
1926
|
+
* // …
|
|
1927
|
+
*
|
|
1928
|
+
* const result = await getQuote({
|
|
1929
|
+
* market: {
|
|
1930
|
+
* chainId: chainId(1),
|
|
1931
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1932
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1933
|
+
* amount: bigDecimal('1000'),
|
|
1934
|
+
* kind: SwapKind.Sell,
|
|
1935
|
+
* },
|
|
1936
|
+
* });
|
|
1937
|
+
*
|
|
1938
|
+
* if (result.isOk()) {
|
|
1939
|
+
* console.log('Swap quote:', result.value);
|
|
1940
|
+
* } else {
|
|
1941
|
+
* console.error(result.error);
|
|
1942
|
+
* }
|
|
1943
|
+
* ```
|
|
1944
|
+
*/
|
|
1945
|
+
declare function useTokenSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<TokenSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1946
|
+
|
|
1947
|
+
type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1278
1948
|
/**
|
|
1279
|
-
* @internal
|
|
1280
1949
|
* Fetch the user's swap history for a specific chain.
|
|
1281
1950
|
*
|
|
1282
1951
|
* This signature supports React Suspense:
|
|
@@ -1284,7 +1953,7 @@ type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions>;
|
|
|
1284
1953
|
* ```tsx
|
|
1285
1954
|
* const { data } = useUserSwaps({
|
|
1286
1955
|
* chainId: chainId(1),
|
|
1287
|
-
* user: evmAddress('0x742d35cc
|
|
1956
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1288
1957
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1289
1958
|
* suspense: true,
|
|
1290
1959
|
* });
|
|
@@ -1292,7 +1961,6 @@ type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions>;
|
|
|
1292
1961
|
*/
|
|
1293
1962
|
declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseResult<PaginatedUserSwapsResult>;
|
|
1294
1963
|
/**
|
|
1295
|
-
* @internal
|
|
1296
1964
|
* Fetch the user's swap history for a specific chain.
|
|
1297
1965
|
*
|
|
1298
1966
|
* Pausable suspense mode.
|
|
@@ -1300,7 +1968,7 @@ declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseRes
|
|
|
1300
1968
|
* ```tsx
|
|
1301
1969
|
* const { data } = useUserSwaps({
|
|
1302
1970
|
* chainId: chainId(1),
|
|
1303
|
-
* user: evmAddress('0x742d35cc
|
|
1971
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1304
1972
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1305
1973
|
* suspense: true,
|
|
1306
1974
|
* pause: true,
|
|
@@ -1309,20 +1977,18 @@ declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseRes
|
|
|
1309
1977
|
*/
|
|
1310
1978
|
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs> & Suspendable): PausableSuspenseResult<PaginatedUserSwapsResult>;
|
|
1311
1979
|
/**
|
|
1312
|
-
* @internal
|
|
1313
1980
|
* Fetch the user's swap history for a specific chain.
|
|
1314
1981
|
*
|
|
1315
1982
|
* ```tsx
|
|
1316
1983
|
* const { data, error, loading } = useUserSwaps({
|
|
1317
1984
|
* chainId: chainId(1),
|
|
1318
|
-
* user: evmAddress('0x742d35cc
|
|
1985
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1319
1986
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1320
1987
|
* });
|
|
1321
1988
|
* ```
|
|
1322
1989
|
*/
|
|
1323
1990
|
declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserSwapsResult>;
|
|
1324
1991
|
/**
|
|
1325
|
-
* @internal
|
|
1326
1992
|
* Fetch the user's swap history for a specific chain.
|
|
1327
1993
|
*
|
|
1328
1994
|
* Pausable loading state mode.
|
|
@@ -1330,109 +1996,244 @@ declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserS
|
|
|
1330
1996
|
* ```tsx
|
|
1331
1997
|
* const { data, error, loading, paused } = useUserSwaps({
|
|
1332
1998
|
* chainId: chainId(1),
|
|
1333
|
-
* user: evmAddress('0x742d35cc
|
|
1999
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1334
2000
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1335
2001
|
* pause: true,
|
|
1336
2002
|
* });
|
|
1337
2003
|
* ```
|
|
1338
2004
|
*/
|
|
1339
2005
|
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs>): PausableReadResult<PaginatedUserSwapsResult>;
|
|
1340
|
-
|
|
1341
|
-
type
|
|
1342
|
-
type SwapHandlerOptions = {
|
|
1343
|
-
cancel: CancelOperation;
|
|
1344
|
-
};
|
|
1345
|
-
type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAsync<ERC20PermitSignature | SwapReceipt, SendTransactionError | PendingTransactionError>;
|
|
2006
|
+
|
|
2007
|
+
type UseWithdrawSwapRequest = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1346
2008
|
/**
|
|
1347
|
-
*
|
|
1348
|
-
* Orchestrate the swap execution plan.
|
|
2009
|
+
* Orchestrate the withdraw swap execution plan.
|
|
1349
2010
|
*
|
|
1350
2011
|
* ```tsx
|
|
1351
|
-
* const [
|
|
1352
|
-
* const [signSwapByIntentWith, signing] = useSignSwapByIntentWith(wallet);
|
|
2012
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1353
2013
|
*
|
|
1354
|
-
* const [
|
|
2014
|
+
* const [withdrawSwap, { loading, error }] = useWithdrawSwap((plan) => {
|
|
1355
2015
|
* switch (plan.__typename) {
|
|
1356
|
-
* case '
|
|
1357
|
-
*
|
|
1358
|
-
*
|
|
1359
|
-
* case 'SwapApprovalRequired':
|
|
1360
|
-
* case 'SwapByIntentWithApprovalRequired':
|
|
1361
|
-
* return sendTransaction(plan.transaction);
|
|
2016
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
2017
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
2018
|
+
* return signTypedData(plan.bySignature);
|
|
1362
2019
|
*
|
|
1363
|
-
* case '
|
|
1364
|
-
* return
|
|
2020
|
+
* case 'SwapTypedData':
|
|
2021
|
+
* return signTypedData(plan);
|
|
1365
2022
|
* }
|
|
1366
2023
|
* });
|
|
1367
2024
|
*
|
|
1368
|
-
* const result = await
|
|
2025
|
+
* const result = await withdrawSwap({
|
|
1369
2026
|
* market: {
|
|
1370
|
-
*
|
|
1371
|
-
*
|
|
1372
|
-
*
|
|
2027
|
+
* position: userSupplyItem.id,
|
|
2028
|
+
* buyToken: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
2029
|
+
* amount: bigDecimal('1000'),
|
|
2030
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2031
|
+
* },
|
|
2032
|
+
* });
|
|
2033
|
+
*
|
|
2034
|
+
* if (result.isErr()) {
|
|
2035
|
+
* console.error(result.error);
|
|
2036
|
+
* return;
|
|
2037
|
+
* }
|
|
2038
|
+
*
|
|
2039
|
+
* // result.value: SwapReceipt
|
|
2040
|
+
* ```
|
|
2041
|
+
*/
|
|
2042
|
+
declare function useWithdrawSwap(handler: PositionSwapHandler): UseAsyncTask<WithdrawSwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
2043
|
+
|
|
2044
|
+
type UseWithdrawSwapQuoteArgs = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
2045
|
+
/**
|
|
2046
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2047
|
+
*
|
|
2048
|
+
* This signature supports React Suspense:
|
|
2049
|
+
*
|
|
2050
|
+
* ```tsx
|
|
2051
|
+
* const { data } = useWithdrawSwapQuote({
|
|
2052
|
+
* market: {
|
|
2053
|
+
* position: userSupplyItem.id,
|
|
2054
|
+
* buyReserve: reserve.id,
|
|
2055
|
+
* amount: bigDecimal('1000'),
|
|
2056
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2057
|
+
* },
|
|
2058
|
+
* suspense: true,
|
|
2059
|
+
* });
|
|
2060
|
+
* ```
|
|
2061
|
+
*/
|
|
2062
|
+
declare function useWithdrawSwapQuote(args: UseWithdrawSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
2063
|
+
/**
|
|
2064
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2065
|
+
*
|
|
2066
|
+
* Pausable suspense mode.
|
|
2067
|
+
*
|
|
2068
|
+
* ```tsx
|
|
2069
|
+
* const { data } = useWithdrawSwapQuote({
|
|
2070
|
+
* market: {
|
|
2071
|
+
* position: userSupplyItem.id,
|
|
2072
|
+
* buyReserve: reserve.id,
|
|
2073
|
+
* amount: bigDecimal('1000'),
|
|
2074
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2075
|
+
* },
|
|
2076
|
+
* suspense: true,
|
|
2077
|
+
* pause: true,
|
|
2078
|
+
* });
|
|
2079
|
+
* ```
|
|
2080
|
+
*/
|
|
2081
|
+
declare function useWithdrawSwapQuote(args: Pausable<UseWithdrawSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2084
|
+
*
|
|
2085
|
+
* ```tsx
|
|
2086
|
+
* const { data, error, loading } = useWithdrawSwapQuote({
|
|
2087
|
+
* market: {
|
|
2088
|
+
* position: userSupplyItem.id,
|
|
2089
|
+
* buyReserve: reserve.id,
|
|
2090
|
+
* amount: bigDecimal('1000'),
|
|
2091
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2092
|
+
* },
|
|
2093
|
+
* });
|
|
2094
|
+
* ```
|
|
2095
|
+
*/
|
|
2096
|
+
declare function useWithdrawSwapQuote(args: UseWithdrawSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2099
|
+
*
|
|
2100
|
+
* Pausable loading state mode.
|
|
2101
|
+
*
|
|
2102
|
+
* ```tsx
|
|
2103
|
+
* const { data, error, loading, paused } = useWithdrawSwapQuote({
|
|
2104
|
+
* market: {
|
|
2105
|
+
* position: userSupplyItem.id,
|
|
2106
|
+
* buyReserve: reserve.id,
|
|
1373
2107
|
* amount: bigDecimal('1000'),
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
2108
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2109
|
+
* },
|
|
2110
|
+
* pause: true,
|
|
2111
|
+
* });
|
|
2112
|
+
* ```
|
|
2113
|
+
*/
|
|
2114
|
+
declare function useWithdrawSwapQuote(args: Pausable<UseWithdrawSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
2115
|
+
/**
|
|
2116
|
+
* Low-level hook to execute a withdraw swap quote action directly.
|
|
2117
|
+
*
|
|
2118
|
+
* @remarks
|
|
2119
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
2120
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
2121
|
+
*
|
|
2122
|
+
* ```ts
|
|
2123
|
+
* const [getQuote, { called, data, error, loading }] = useWithdrawSwapQuoteAction();
|
|
2124
|
+
*
|
|
2125
|
+
* // …
|
|
2126
|
+
*
|
|
2127
|
+
* const result = await getQuote({
|
|
2128
|
+
* position: userSupplyItem.id,
|
|
2129
|
+
* buyReserve: reserve.id,
|
|
2130
|
+
* amount: bigDecimal('1000'),
|
|
2131
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2132
|
+
* });
|
|
2133
|
+
*
|
|
2134
|
+
* if (result.isOk()) {
|
|
2135
|
+
* console.log('Withdraw swap quote:', result.value);
|
|
2136
|
+
* } else {
|
|
2137
|
+
* console.error(result.error);
|
|
2138
|
+
* }
|
|
2139
|
+
* ```
|
|
2140
|
+
*/
|
|
2141
|
+
declare function useWithdrawSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<WithdrawSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
2142
|
+
|
|
2143
|
+
type UseActivitiesArgs = Prettify<ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2144
|
+
/**
|
|
2145
|
+
* Fetch paginated list of activities.
|
|
2146
|
+
*
|
|
2147
|
+
* This signature supports React Suspense:
|
|
2148
|
+
*
|
|
2149
|
+
* ```tsx
|
|
2150
|
+
* const { data } = useActivities({
|
|
2151
|
+
* query: {
|
|
2152
|
+
* chainId: chainId(1),
|
|
2153
|
+
* },
|
|
2154
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2155
|
+
* suspense: true,
|
|
2156
|
+
* });
|
|
2157
|
+
*
|
|
2158
|
+
* // data.items: ActivityItem[]
|
|
2159
|
+
* ```
|
|
2160
|
+
*/
|
|
2161
|
+
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2162
|
+
/**
|
|
2163
|
+
* Fetch paginated list of activities.
|
|
2164
|
+
*
|
|
2165
|
+
* Pausable suspense mode.
|
|
2166
|
+
*
|
|
2167
|
+
* ```tsx
|
|
2168
|
+
* const { data } = useActivities({
|
|
2169
|
+
* query: {
|
|
2170
|
+
* chainId: chainId(1),
|
|
2171
|
+
* },
|
|
2172
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2173
|
+
* suspense: true,
|
|
2174
|
+
* pause: true,
|
|
2175
|
+
* });
|
|
2176
|
+
*
|
|
2177
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2178
|
+
* ```
|
|
2179
|
+
*/
|
|
2180
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Fetch paginated list of activities.
|
|
2183
|
+
*
|
|
2184
|
+
* ```tsx
|
|
2185
|
+
* const { data, error, loading } = useActivities({
|
|
2186
|
+
* query: {
|
|
2187
|
+
* chainId: chainId(1),
|
|
1376
2188
|
* },
|
|
2189
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1377
2190
|
* });
|
|
1378
|
-
*
|
|
1379
|
-
* if (result.isErr()) {
|
|
1380
|
-
* console.error(result.error);
|
|
1381
|
-
* return;
|
|
1382
|
-
* }
|
|
1383
|
-
*
|
|
1384
|
-
* // result.value: SwapReceipt
|
|
1385
2191
|
* ```
|
|
1386
2192
|
*/
|
|
1387
|
-
declare function
|
|
1388
|
-
type CancelSwapHandler = (data: CancelSwapTypedData | TransactionRequest) => ResultAsync<ERC20PermitSignature | PendingTransaction, SigningError | UnexpectedError$1>;
|
|
1389
|
-
declare class CannotCancelSwapError extends ResultAwareError {
|
|
1390
|
-
name: "CannotCancelSwapError";
|
|
1391
|
-
}
|
|
1392
|
-
type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | TimeoutError | TransactionError | UnexpectedError$1;
|
|
2193
|
+
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
1393
2194
|
/**
|
|
1394
|
-
*
|
|
1395
|
-
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
1396
|
-
*
|
|
1397
|
-
* ```tsx
|
|
1398
|
-
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1399
|
-
* const [signSwapCancelWith] = useSignSwapCancelWith(wallet);
|
|
2195
|
+
* Fetch paginated list of activities.
|
|
1400
2196
|
*
|
|
1401
|
-
*
|
|
1402
|
-
* switch (plan.__typename) {
|
|
1403
|
-
* case 'TransactionRequest':
|
|
1404
|
-
* return sendTransaction(plan);
|
|
2197
|
+
* Pausable loading state mode.
|
|
1405
2198
|
*
|
|
1406
|
-
*
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
2199
|
+
* ```tsx
|
|
2200
|
+
* const { data, error, loading } = useActivities({
|
|
2201
|
+
* query: {
|
|
2202
|
+
* chainId: chainId(1),
|
|
2203
|
+
* },
|
|
2204
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2205
|
+
* pause: true,
|
|
1409
2206
|
* });
|
|
1410
2207
|
*
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
2208
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2209
|
+
* // error: UnexpectedError | undefined
|
|
2210
|
+
* // loading: boolean | undefined
|
|
2211
|
+
* ```
|
|
2212
|
+
*/
|
|
2213
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2214
|
+
/**
|
|
2215
|
+
* Low-level hook to execute a {@link activities} action directly.
|
|
1414
2216
|
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
*
|
|
2217
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2218
|
+
* @remarks
|
|
2219
|
+
* This hook does not actively watch for updates. Use it to fetch activities on demand
|
|
2220
|
+
* (e.g., in an event handler when paginating or refining filters).
|
|
1419
2221
|
*
|
|
1420
|
-
*
|
|
1421
|
-
*
|
|
1422
|
-
* ```
|
|
2222
|
+
* @param options - The query options.
|
|
2223
|
+
* @returns The user history.
|
|
1423
2224
|
*/
|
|
1424
|
-
declare function
|
|
2225
|
+
declare function useActivitiesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError>;
|
|
1425
2226
|
|
|
1426
2227
|
/**
|
|
1427
|
-
* A hook that provides a way to
|
|
2228
|
+
* A hook that provides a way to borrow assets from an Aave reserve.
|
|
1428
2229
|
*
|
|
1429
2230
|
* ```ts
|
|
1430
2231
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1431
|
-
* const [
|
|
2232
|
+
* const [borrow, { loading, error }] = useBorrow((plan, { cancel }) => {
|
|
1432
2233
|
* switch (plan.__typename) {
|
|
1433
2234
|
* case 'TransactionRequest':
|
|
1434
2235
|
* return sendTransaction(plan);
|
|
1435
|
-
*
|
|
2236
|
+
*
|
|
1436
2237
|
* case 'PreContractActionRequired':
|
|
1437
2238
|
* return sendTransaction(plan.transaction);
|
|
1438
2239
|
* }
|
|
@@ -1440,7 +2241,7 @@ declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<Prepare
|
|
|
1440
2241
|
*
|
|
1441
2242
|
* // …
|
|
1442
2243
|
*
|
|
1443
|
-
* const result = await
|
|
2244
|
+
* const result = await borrow({ ... });
|
|
1444
2245
|
*
|
|
1445
2246
|
* if (result.isErr()) {
|
|
1446
2247
|
* switch (result.error.name) {
|
|
@@ -1471,30 +2272,29 @@ declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<Prepare
|
|
|
1471
2272
|
* return;
|
|
1472
2273
|
* }
|
|
1473
2274
|
*
|
|
1474
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2275
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1475
2276
|
* ```
|
|
1476
2277
|
*
|
|
1477
2278
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1478
2279
|
*/
|
|
1479
|
-
declare function
|
|
2280
|
+
declare function useBorrow(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<BorrowRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2281
|
+
|
|
1480
2282
|
/**
|
|
1481
|
-
* A hook that provides a way to
|
|
2283
|
+
* A hook that provides a way to claim rewards.
|
|
1482
2284
|
*
|
|
1483
2285
|
* ```ts
|
|
1484
2286
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1485
|
-
* const [
|
|
1486
|
-
*
|
|
1487
|
-
* case 'TransactionRequest':
|
|
1488
|
-
* return sendTransaction(plan);
|
|
1489
|
-
* case 'Erc20ApprovalRequired':
|
|
1490
|
-
* case 'PreContractActionRequired':
|
|
1491
|
-
* return sendTransaction(plan.transaction);
|
|
1492
|
-
* }
|
|
2287
|
+
* const [claim, { loading, error }] = useClaimRewards((transaction, { cancel }) => {
|
|
2288
|
+
* return sendTransaction(transaction);
|
|
1493
2289
|
* });
|
|
1494
2290
|
*
|
|
1495
2291
|
* // …
|
|
1496
2292
|
*
|
|
1497
|
-
* const result = await
|
|
2293
|
+
* const result = await claim({
|
|
2294
|
+
* ids: [rewardId('abc123')],
|
|
2295
|
+
* chainId: chainId(1),
|
|
2296
|
+
* user: evmAddress('0x9abc…'),
|
|
2297
|
+
* });
|
|
1498
2298
|
*
|
|
1499
2299
|
* if (result.isErr()) {
|
|
1500
2300
|
* switch (result.error.name) {
|
|
@@ -1514,10 +2314,6 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1514
2314
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1515
2315
|
* break;
|
|
1516
2316
|
*
|
|
1517
|
-
* case 'ValidationError':
|
|
1518
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1519
|
-
* break;
|
|
1520
|
-
*
|
|
1521
2317
|
* case 'UnexpectedError':
|
|
1522
2318
|
* console.error(result.error.message);
|
|
1523
2319
|
* break;
|
|
@@ -1525,22 +2321,26 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1525
2321
|
* return;
|
|
1526
2322
|
* }
|
|
1527
2323
|
*
|
|
1528
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2324
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1529
2325
|
* ```
|
|
1530
2326
|
*
|
|
1531
|
-
* @param handler - The handler that will be used to handle the
|
|
2327
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1532
2328
|
*/
|
|
1533
|
-
declare function
|
|
2329
|
+
declare function useClaimRewards(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<ClaimRewardsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2330
|
+
|
|
1534
2331
|
/**
|
|
1535
|
-
* A hook that provides a way to
|
|
2332
|
+
* A hook that provides a way to liquidate a user's position.
|
|
1536
2333
|
*
|
|
1537
2334
|
* ```ts
|
|
1538
2335
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1539
|
-
* const [
|
|
2336
|
+
* const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {
|
|
1540
2337
|
* switch (plan.__typename) {
|
|
1541
2338
|
* case 'TransactionRequest':
|
|
1542
2339
|
* return sendTransaction(plan);
|
|
1543
|
-
*
|
|
2340
|
+
*
|
|
2341
|
+
* case 'Erc20Approval':
|
|
2342
|
+
* return sendTransaction(plan.byTransaction);
|
|
2343
|
+
*
|
|
1544
2344
|
* case 'PreContractActionRequired':
|
|
1545
2345
|
* return sendTransaction(plan.transaction);
|
|
1546
2346
|
* }
|
|
@@ -1548,7 +2348,13 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1548
2348
|
*
|
|
1549
2349
|
* // …
|
|
1550
2350
|
*
|
|
1551
|
-
* const result = await
|
|
2351
|
+
* const result = await liquidatePosition({
|
|
2352
|
+
* collateral: reserveId('SGVsbG8h'),
|
|
2353
|
+
* debt: reserveId('Q2lhbyE= '),
|
|
2354
|
+
* amount: amount,
|
|
2355
|
+
* liquidator: liquidator,
|
|
2356
|
+
* borrower: borrower,
|
|
2357
|
+
* });
|
|
1552
2358
|
*
|
|
1553
2359
|
* if (result.isErr()) {
|
|
1554
2360
|
* switch (result.error.name) {
|
|
@@ -1579,30 +2385,153 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1579
2385
|
* return;
|
|
1580
2386
|
* }
|
|
1581
2387
|
*
|
|
1582
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2388
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1583
2389
|
* ```
|
|
1584
2390
|
*
|
|
1585
2391
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1586
2392
|
*/
|
|
1587
|
-
declare function
|
|
2393
|
+
declare function useLiquidatePosition(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, PendingTransaction | Signature>): UseAsyncTask<LiquidatePositionRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2394
|
+
|
|
1588
2395
|
/**
|
|
1589
|
-
*
|
|
2396
|
+
* Preview the impact of a potential action on a user's position.
|
|
2397
|
+
*
|
|
2398
|
+
* ```tsx
|
|
2399
|
+
* const [getPreview, previewing] = usePreviewAction();
|
|
2400
|
+
*
|
|
2401
|
+
* const loading = previewing.loading;
|
|
2402
|
+
* const error = previewing.error;
|
|
2403
|
+
*
|
|
2404
|
+
* // …
|
|
2405
|
+
*
|
|
2406
|
+
* const result = await getPreview({
|
|
2407
|
+
* action: {
|
|
2408
|
+
* supply: {
|
|
2409
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2410
|
+
* amount: {
|
|
2411
|
+
* erc20: {
|
|
2412
|
+
* value: '1000',
|
|
2413
|
+
* },
|
|
2414
|
+
* },
|
|
2415
|
+
* sender: evmAddress('0x9abc…'),
|
|
2416
|
+
* },
|
|
2417
|
+
* },
|
|
2418
|
+
* });
|
|
2419
|
+
*
|
|
2420
|
+
* if (result.isErr()) {
|
|
2421
|
+
* console.error(result.error);
|
|
2422
|
+
* return;
|
|
2423
|
+
* }
|
|
2424
|
+
*
|
|
2425
|
+
* console.log('Preview result:', result.value);
|
|
2426
|
+
* ```
|
|
2427
|
+
*/
|
|
2428
|
+
declare function usePreviewAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError>;
|
|
2429
|
+
type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
|
|
2430
|
+
/**
|
|
2431
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2432
|
+
*
|
|
2433
|
+
* This signature supports React Suspense:
|
|
2434
|
+
*
|
|
2435
|
+
* ```tsx
|
|
2436
|
+
* const { data } = usePreview({
|
|
2437
|
+
* action: {
|
|
2438
|
+
* supply: {
|
|
2439
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2440
|
+
* amount: {
|
|
2441
|
+
* erc20: {
|
|
2442
|
+
* currency: evmAddress('0x5678…'),
|
|
2443
|
+
* value: '1000',
|
|
2444
|
+
* },
|
|
2445
|
+
* },
|
|
2446
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2447
|
+
* },
|
|
2448
|
+
* },
|
|
2449
|
+
* suspense: true,
|
|
2450
|
+
* });
|
|
2451
|
+
* ```
|
|
2452
|
+
*/
|
|
2453
|
+
declare function usePreview(args: UsePreviewArgs & Suspendable): SuspenseResult<PreviewUserPosition>;
|
|
2454
|
+
/**
|
|
2455
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2456
|
+
*
|
|
2457
|
+
* Pausable suspense mode.
|
|
2458
|
+
*
|
|
2459
|
+
* ```tsx
|
|
2460
|
+
* const { data } = usePreview({
|
|
2461
|
+
* action: {
|
|
2462
|
+
* supply: {
|
|
2463
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2464
|
+
* amount: {
|
|
2465
|
+
* erc20: {
|
|
2466
|
+
* currency: evmAddress('0x5678…'),
|
|
2467
|
+
* value: '1000',
|
|
2468
|
+
* },
|
|
2469
|
+
* },
|
|
2470
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2471
|
+
* },
|
|
2472
|
+
* },
|
|
2473
|
+
* suspense: true,
|
|
2474
|
+
* pause: true,
|
|
2475
|
+
* });
|
|
2476
|
+
* ```
|
|
2477
|
+
*/
|
|
2478
|
+
declare function usePreview(args: Pausable<UsePreviewArgs> & Suspendable): PausableSuspenseResult<PreviewUserPosition>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2481
|
+
*
|
|
2482
|
+
* ```tsx
|
|
2483
|
+
* const { data, error, loading } = usePreview({
|
|
2484
|
+
* action: {
|
|
2485
|
+
* supply: {
|
|
2486
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2487
|
+
* amount: {
|
|
2488
|
+
* erc20: {
|
|
2489
|
+
* currency: evmAddress('0x5678…'),
|
|
2490
|
+
* value: '1000',
|
|
2491
|
+
* },
|
|
2492
|
+
* },
|
|
2493
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2494
|
+
* },
|
|
2495
|
+
* },
|
|
2496
|
+
* });
|
|
2497
|
+
* ```
|
|
2498
|
+
*/
|
|
2499
|
+
declare function usePreview(args: UsePreviewArgs): ReadResult<PreviewUserPosition>;
|
|
2500
|
+
/**
|
|
2501
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2502
|
+
*
|
|
2503
|
+
* Pausable loading state mode.
|
|
2504
|
+
*
|
|
2505
|
+
* ```tsx
|
|
2506
|
+
* const { data, error, loading, paused } = usePreview({
|
|
2507
|
+
* action: {
|
|
2508
|
+
* supply: {
|
|
2509
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2510
|
+
* amount: {
|
|
2511
|
+
* erc20: {
|
|
2512
|
+
* currency: evmAddress('0x5678…'),
|
|
2513
|
+
* value: '1000',
|
|
2514
|
+
* },
|
|
2515
|
+
* },
|
|
2516
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2517
|
+
* },
|
|
2518
|
+
* },
|
|
2519
|
+
* pause: true,
|
|
2520
|
+
* });
|
|
2521
|
+
* ```
|
|
2522
|
+
*/
|
|
2523
|
+
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2524
|
+
|
|
2525
|
+
/**
|
|
2526
|
+
* A hook that provides a way to renounce a position manager of a user for a specific spoke.
|
|
1590
2527
|
*
|
|
1591
2528
|
* ```ts
|
|
1592
2529
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1593
|
-
* const [
|
|
1594
|
-
* switch (plan.__typename) {
|
|
1595
|
-
* case 'TransactionRequest':
|
|
1596
|
-
* return sendTransaction(plan);
|
|
1597
|
-
* case 'Erc20ApprovalRequired':
|
|
1598
|
-
* case 'PreContractActionRequired':
|
|
1599
|
-
* return sendTransaction(plan.transaction);
|
|
1600
|
-
* }
|
|
1601
|
-
* });
|
|
2530
|
+
* const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);
|
|
1602
2531
|
*
|
|
1603
2532
|
* // …
|
|
1604
2533
|
*
|
|
1605
|
-
* const result = await
|
|
2534
|
+
* const result = await renounceSpokeUserPositionManager({ ... });
|
|
1606
2535
|
*
|
|
1607
2536
|
* if (result.isErr()) {
|
|
1608
2537
|
* switch (result.error.name) {
|
|
@@ -1622,10 +2551,6 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1622
2551
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1623
2552
|
* break;
|
|
1624
2553
|
*
|
|
1625
|
-
* case 'ValidationError':
|
|
1626
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1627
|
-
* break;
|
|
1628
|
-
*
|
|
1629
2554
|
* case 'UnexpectedError':
|
|
1630
2555
|
* console.error(result.error.message);
|
|
1631
2556
|
* break;
|
|
@@ -1633,22 +2558,34 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1633
2558
|
* return;
|
|
1634
2559
|
* }
|
|
1635
2560
|
*
|
|
1636
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2561
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1637
2562
|
* ```
|
|
1638
2563
|
*
|
|
1639
|
-
* @param handler - The handler that will be used to handle the
|
|
2564
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1640
2565
|
*/
|
|
1641
|
-
declare function
|
|
2566
|
+
declare function useRenounceSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<RenounceSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2567
|
+
|
|
1642
2568
|
/**
|
|
1643
|
-
* A hook that provides a way to
|
|
2569
|
+
* A hook that provides a way to repay borrowed assets to an Aave reserve.
|
|
1644
2570
|
*
|
|
1645
2571
|
* ```ts
|
|
1646
2572
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1647
|
-
* const [
|
|
2573
|
+
* const [repay, { loading, error }] = useRepay((plan, { cancel }) => {
|
|
2574
|
+
* switch (plan.__typename) {
|
|
2575
|
+
* case 'TransactionRequest':
|
|
2576
|
+
* return sendTransaction(plan);
|
|
2577
|
+
*
|
|
2578
|
+
* case 'Erc20Approval':
|
|
2579
|
+
* return sendTransaction(plan.byTransaction);
|
|
2580
|
+
*
|
|
2581
|
+
* case 'PreContractActionRequired':
|
|
2582
|
+
* return sendTransaction(plan.transaction);
|
|
2583
|
+
* }
|
|
2584
|
+
* });
|
|
1648
2585
|
*
|
|
1649
2586
|
* // …
|
|
1650
2587
|
*
|
|
1651
|
-
* const result = await
|
|
2588
|
+
* const result = await repay({ ... });
|
|
1652
2589
|
*
|
|
1653
2590
|
* if (result.isErr()) {
|
|
1654
2591
|
* switch (result.error.name) {
|
|
@@ -1668,6 +2605,10 @@ declare function useWithdraw(handler: TransactionHandler): UseAsyncTask<Withdraw
|
|
|
1668
2605
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1669
2606
|
* break;
|
|
1670
2607
|
*
|
|
2608
|
+
* case 'ValidationError':
|
|
2609
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2610
|
+
* break;
|
|
2611
|
+
*
|
|
1671
2612
|
* case 'UnexpectedError':
|
|
1672
2613
|
* console.error(result.error.message);
|
|
1673
2614
|
* break;
|
|
@@ -1675,27 +2616,42 @@ declare function useWithdraw(handler: TransactionHandler): UseAsyncTask<Withdraw
|
|
|
1675
2616
|
* return;
|
|
1676
2617
|
* }
|
|
1677
2618
|
*
|
|
1678
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2619
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1679
2620
|
* ```
|
|
1680
2621
|
*
|
|
1681
|
-
* @param handler - The handler that will be used to handle the
|
|
2622
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
1682
2623
|
*/
|
|
1683
|
-
declare function
|
|
2624
|
+
declare function useRepay(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<RepayRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2625
|
+
|
|
1684
2626
|
/**
|
|
1685
|
-
*
|
|
2627
|
+
* A hook that provides a way to set or remove a position manager for a user on a specific spoke.
|
|
2628
|
+
*
|
|
2629
|
+
* **Position managers** can perform transactions on behalf of other users, including:
|
|
2630
|
+
* - Supply assets
|
|
2631
|
+
* - Borrow assets
|
|
2632
|
+
* - Withdraw assets
|
|
2633
|
+
* - Enable/disable collateral
|
|
2634
|
+
*
|
|
2635
|
+
* The `signature` parameter is an **ERC712 signature** that must be signed by the **user**
|
|
2636
|
+
* (the account granting permissions) to authorize the position manager. The signature contains:
|
|
2637
|
+
* - `value`: The actual cryptographic signature
|
|
2638
|
+
* - `deadline`: Unix timestamp when the authorization expires
|
|
1686
2639
|
*
|
|
1687
2640
|
* ```ts
|
|
1688
2641
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1689
|
-
* const [
|
|
2642
|
+
* const [setSpokeUserPositionManager, { loading, error }] = useSetSpokeUserPositionManager((transaction, { cancel }) => {
|
|
1690
2643
|
* return sendTransaction(transaction);
|
|
1691
2644
|
* });
|
|
1692
2645
|
*
|
|
1693
|
-
*
|
|
1694
|
-
*
|
|
1695
|
-
*
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
1698
|
-
*
|
|
2646
|
+
* const result = await setSpokeUserPositionManager({
|
|
2647
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
2648
|
+
* manager: evmAddress('0x9abc…'), // Address that will become the position manager
|
|
2649
|
+
* approve: true, // true to approve, false to remove the manager
|
|
2650
|
+
* user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)
|
|
2651
|
+
* signature: {
|
|
2652
|
+
* value: '0x1234...', // ERC712 signature signed by the user
|
|
2653
|
+
* deadline: 1735689600, // Unix timestamp when signature expires
|
|
2654
|
+
* },
|
|
1699
2655
|
* });
|
|
1700
2656
|
*
|
|
1701
2657
|
* if (result.isErr()) {
|
|
@@ -1723,12 +2679,13 @@ declare function useRenounceSpokeUserPositionManager(handler: TransactionHandler
|
|
|
1723
2679
|
* return;
|
|
1724
2680
|
* }
|
|
1725
2681
|
*
|
|
1726
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2682
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1727
2683
|
* ```
|
|
1728
2684
|
*
|
|
1729
2685
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1730
2686
|
*/
|
|
1731
|
-
declare function
|
|
2687
|
+
declare function useSetSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2688
|
+
|
|
1732
2689
|
/**
|
|
1733
2690
|
* Hook for updating the collateral status of user's supplies.
|
|
1734
2691
|
*
|
|
@@ -1773,22 +2730,26 @@ declare function useUpdateUserPositionConditions(handler: TransactionHandler): U
|
|
|
1773
2730
|
* return;
|
|
1774
2731
|
* }
|
|
1775
2732
|
*
|
|
1776
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2733
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1777
2734
|
* ```
|
|
1778
2735
|
*
|
|
1779
2736
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1780
2737
|
*/
|
|
1781
|
-
declare function useSetUserSuppliesAsCollateral(handler:
|
|
2738
|
+
declare function useSetUserSuppliesAsCollateral(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetUserSuppliesAsCollateralRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2739
|
+
|
|
1782
2740
|
/**
|
|
1783
|
-
* A hook that provides a way to
|
|
2741
|
+
* A hook that provides a way to supply assets to an Aave reserve.
|
|
1784
2742
|
*
|
|
1785
2743
|
* ```ts
|
|
1786
2744
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1787
|
-
* const [
|
|
2745
|
+
* const [supply, { loading, error }] = useSupply((plan, { cancel }) => {
|
|
1788
2746
|
* switch (plan.__typename) {
|
|
1789
2747
|
* case 'TransactionRequest':
|
|
1790
2748
|
* return sendTransaction(plan);
|
|
1791
|
-
*
|
|
2749
|
+
*
|
|
2750
|
+
* case 'Erc20Approval':
|
|
2751
|
+
* return sendTransaction(plan.byTransaction);
|
|
2752
|
+
*
|
|
1792
2753
|
* case 'PreContractActionRequired':
|
|
1793
2754
|
* return sendTransaction(plan.transaction);
|
|
1794
2755
|
* }
|
|
@@ -1796,13 +2757,7 @@ declare function useSetUserSuppliesAsCollateral(handler: TransactionHandler): Us
|
|
|
1796
2757
|
*
|
|
1797
2758
|
* // …
|
|
1798
2759
|
*
|
|
1799
|
-
* const result = await
|
|
1800
|
-
* collateral: reserveId('SGVsbG8h'),
|
|
1801
|
-
* debt: reserveId('Q2lhbyE= '),
|
|
1802
|
-
* amount: amount,
|
|
1803
|
-
* liquidator: liquidator,
|
|
1804
|
-
* borrower: borrower,
|
|
1805
|
-
* });
|
|
2760
|
+
* const result = await supply({ ... });
|
|
1806
2761
|
*
|
|
1807
2762
|
* if (result.isErr()) {
|
|
1808
2763
|
* switch (result.error.name) {
|
|
@@ -1833,41 +2788,27 @@ declare function useSetUserSuppliesAsCollateral(handler: TransactionHandler): Us
|
|
|
1833
2788
|
* return;
|
|
1834
2789
|
* }
|
|
1835
2790
|
*
|
|
1836
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2791
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1837
2792
|
* ```
|
|
1838
2793
|
*
|
|
1839
2794
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1840
2795
|
*/
|
|
1841
|
-
declare function
|
|
2796
|
+
declare function useSupply(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<SupplyRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2797
|
+
|
|
1842
2798
|
/**
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1845
|
-
* **Position managers** can perform transactions on behalf of other users, including:
|
|
1846
|
-
* - Supply assets
|
|
1847
|
-
* - Borrow assets
|
|
1848
|
-
* - Withdraw assets
|
|
1849
|
-
* - Enable/disable collateral
|
|
1850
|
-
*
|
|
1851
|
-
* The `signature` parameter is an **ERC712 signature** that must be signed by the **user**
|
|
1852
|
-
* (the account granting permissions) to authorize the position manager. The signature contains:
|
|
1853
|
-
* - `value`: The actual cryptographic signature
|
|
1854
|
-
* - `deadline`: Unix timestamp when the authorization expires
|
|
2799
|
+
* Hook for updating user position conditions (dynamic config and/or risk premium).
|
|
1855
2800
|
*
|
|
1856
2801
|
* ```ts
|
|
1857
2802
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1858
|
-
* const [
|
|
2803
|
+
* const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {
|
|
1859
2804
|
* return sendTransaction(transaction);
|
|
1860
2805
|
* });
|
|
1861
2806
|
*
|
|
1862
|
-
*
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1867
|
-
* signature: {
|
|
1868
|
-
* value: '0x1234...', // ERC712 signature signed by the user
|
|
1869
|
-
* deadline: 1735689600, // Unix timestamp when signature expires
|
|
1870
|
-
* },
|
|
2807
|
+
* // …
|
|
2808
|
+
*
|
|
2809
|
+
* const result = await update({
|
|
2810
|
+
* userPositionId: userPosition.id,
|
|
2811
|
+
* update: UserPositionConditionsUpdate.AllDynamicConfig,
|
|
1871
2812
|
* });
|
|
1872
2813
|
*
|
|
1873
2814
|
* if (result.isErr()) {
|
|
@@ -1888,231 +2829,74 @@ declare function useLiquidatePosition(handler: TransactionHandler): UseAsyncTask
|
|
|
1888
2829
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1889
2830
|
* break;
|
|
1890
2831
|
*
|
|
1891
|
-
* case 'UnexpectedError':
|
|
1892
|
-
* console.error(result.error.message);
|
|
1893
|
-
* break;
|
|
1894
|
-
* }
|
|
1895
|
-
* return;
|
|
1896
|
-
* }
|
|
1897
|
-
*
|
|
1898
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
1899
|
-
* ```
|
|
1900
|
-
*
|
|
1901
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1902
|
-
*/
|
|
1903
|
-
declare function useSetSpokeUserPositionManager(handler: TransactionHandler): UseAsyncTask<SetSpokeUserPositionManagerRequest, TxHash, SendTransactionError | PendingTransactionError>;
|
|
1904
|
-
/**
|
|
1905
|
-
* Preview the impact of a potential action on a user's position.
|
|
1906
|
-
*
|
|
1907
|
-
* ```tsx
|
|
1908
|
-
* const [getPreview, previewing] = usePreviewAction();
|
|
1909
|
-
*
|
|
1910
|
-
* const loading = previewing.loading;
|
|
1911
|
-
* const error = previewing.error;
|
|
1912
|
-
*
|
|
1913
|
-
* // …
|
|
1914
|
-
*
|
|
1915
|
-
* const result = await getPreview({
|
|
1916
|
-
* action: {
|
|
1917
|
-
* supply: {
|
|
1918
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1919
|
-
* amount: {
|
|
1920
|
-
* erc20: {
|
|
1921
|
-
* value: '1000',
|
|
1922
|
-
* },
|
|
1923
|
-
* },
|
|
1924
|
-
* sender: evmAddress('0x9abc…'),
|
|
1925
|
-
* },
|
|
1926
|
-
* },
|
|
1927
|
-
* });
|
|
1928
|
-
*
|
|
1929
|
-
* if (result.isErr()) {
|
|
1930
|
-
* console.error(result.error);
|
|
1931
|
-
* return;
|
|
1932
|
-
* }
|
|
1933
|
-
*
|
|
1934
|
-
* console.log('Preview result:', result.value);
|
|
1935
|
-
* ```
|
|
1936
|
-
*/
|
|
1937
|
-
declare function usePreviewAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError>;
|
|
1938
|
-
type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
|
|
1939
|
-
/**
|
|
1940
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1941
|
-
*
|
|
1942
|
-
* This signature supports React Suspense:
|
|
1943
|
-
*
|
|
1944
|
-
* ```tsx
|
|
1945
|
-
* const { data } = usePreview({
|
|
1946
|
-
* action: {
|
|
1947
|
-
* supply: {
|
|
1948
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1949
|
-
* amount: {
|
|
1950
|
-
* erc20: {
|
|
1951
|
-
* currency: evmAddress('0x5678…'),
|
|
1952
|
-
* value: '1000',
|
|
1953
|
-
* },
|
|
1954
|
-
* },
|
|
1955
|
-
* supplier: evmAddress('0x9abc…'),
|
|
1956
|
-
* },
|
|
1957
|
-
* },
|
|
1958
|
-
* suspense: true,
|
|
1959
|
-
* });
|
|
1960
|
-
* ```
|
|
1961
|
-
*/
|
|
1962
|
-
declare function usePreview(args: UsePreviewArgs & Suspendable): SuspenseResult<PreviewUserPosition>;
|
|
1963
|
-
/**
|
|
1964
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1965
|
-
*
|
|
1966
|
-
* Pausable suspense mode.
|
|
1967
|
-
*
|
|
1968
|
-
* ```tsx
|
|
1969
|
-
* const { data } = usePreview({
|
|
1970
|
-
* action: {
|
|
1971
|
-
* supply: {
|
|
1972
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1973
|
-
* amount: {
|
|
1974
|
-
* erc20: {
|
|
1975
|
-
* currency: evmAddress('0x5678…'),
|
|
1976
|
-
* value: '1000',
|
|
1977
|
-
* },
|
|
1978
|
-
* },
|
|
1979
|
-
* supplier: evmAddress('0x9abc…'),
|
|
1980
|
-
* },
|
|
1981
|
-
* },
|
|
1982
|
-
* suspense: true,
|
|
1983
|
-
* pause: true,
|
|
1984
|
-
* });
|
|
1985
|
-
* ```
|
|
1986
|
-
*/
|
|
1987
|
-
declare function usePreview(args: Pausable<UsePreviewArgs> & Suspendable): PausableSuspenseResult<PreviewUserPosition>;
|
|
1988
|
-
/**
|
|
1989
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1990
|
-
*
|
|
1991
|
-
* ```tsx
|
|
1992
|
-
* const { data, error, loading } = usePreview({
|
|
1993
|
-
* action: {
|
|
1994
|
-
* supply: {
|
|
1995
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1996
|
-
* amount: {
|
|
1997
|
-
* erc20: {
|
|
1998
|
-
* currency: evmAddress('0x5678…'),
|
|
1999
|
-
* value: '1000',
|
|
2000
|
-
* },
|
|
2001
|
-
* },
|
|
2002
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2003
|
-
* },
|
|
2004
|
-
* },
|
|
2005
|
-
* });
|
|
2006
|
-
* ```
|
|
2007
|
-
*/
|
|
2008
|
-
declare function usePreview(args: UsePreviewArgs): ReadResult<PreviewUserPosition>;
|
|
2009
|
-
/**
|
|
2010
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2011
|
-
*
|
|
2012
|
-
* Pausable loading state mode.
|
|
2013
|
-
*
|
|
2014
|
-
* ```tsx
|
|
2015
|
-
* const { data, error, loading, paused } = usePreview({
|
|
2016
|
-
* action: {
|
|
2017
|
-
* supply: {
|
|
2018
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
2019
|
-
* amount: {
|
|
2020
|
-
* erc20: {
|
|
2021
|
-
* currency: evmAddress('0x5678…'),
|
|
2022
|
-
* value: '1000',
|
|
2023
|
-
* },
|
|
2024
|
-
* },
|
|
2025
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2026
|
-
* },
|
|
2027
|
-
* },
|
|
2028
|
-
* pause: true,
|
|
2029
|
-
* });
|
|
2030
|
-
* ```
|
|
2031
|
-
*/
|
|
2032
|
-
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2033
|
-
type UseActivitiesArgs = Prettify<ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2034
|
-
/**
|
|
2035
|
-
* Fetch paginated list of activities.
|
|
2036
|
-
*
|
|
2037
|
-
* This signature supports React Suspense:
|
|
2038
|
-
*
|
|
2039
|
-
* ```tsx
|
|
2040
|
-
* const { data } = useActivities({
|
|
2041
|
-
* query: {
|
|
2042
|
-
* chainId: chainId(1),
|
|
2043
|
-
* },
|
|
2044
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2045
|
-
* suspense: true,
|
|
2046
|
-
* });
|
|
2047
|
-
*
|
|
2048
|
-
* // data.items: ActivityItem[]
|
|
2049
|
-
* ```
|
|
2050
|
-
*/
|
|
2051
|
-
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2052
|
-
/**
|
|
2053
|
-
* Fetch paginated list of activities.
|
|
2054
|
-
*
|
|
2055
|
-
* Pausable suspense mode.
|
|
2056
|
-
*
|
|
2057
|
-
* ```tsx
|
|
2058
|
-
* const { data } = useActivities({
|
|
2059
|
-
* query: {
|
|
2060
|
-
* chainId: chainId(1),
|
|
2061
|
-
* },
|
|
2062
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2063
|
-
* suspense: true,
|
|
2064
|
-
* pause: true,
|
|
2065
|
-
* });
|
|
2832
|
+
* case 'UnexpectedError':
|
|
2833
|
+
* console.error(result.error.message);
|
|
2834
|
+
* break;
|
|
2835
|
+
* }
|
|
2836
|
+
* return;
|
|
2837
|
+
* }
|
|
2066
2838
|
*
|
|
2067
|
-
*
|
|
2839
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2068
2840
|
* ```
|
|
2069
|
-
*/
|
|
2070
|
-
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2071
|
-
/**
|
|
2072
|
-
* Fetch paginated list of activities.
|
|
2073
2841
|
*
|
|
2074
|
-
*
|
|
2075
|
-
* const { data, error, loading } = useActivities({
|
|
2076
|
-
* query: {
|
|
2077
|
-
* chainId: chainId(1),
|
|
2078
|
-
* },
|
|
2079
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2080
|
-
* });
|
|
2081
|
-
* ```
|
|
2842
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2082
2843
|
*/
|
|
2083
|
-
declare function
|
|
2844
|
+
declare function useUpdateUserPositionConditions(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<UpdateUserPositionConditionsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2845
|
+
|
|
2084
2846
|
/**
|
|
2085
|
-
*
|
|
2847
|
+
* A hook that provides a way to withdraw supplied assets from an Aave reserve.
|
|
2086
2848
|
*
|
|
2087
|
-
*
|
|
2849
|
+
* ```ts
|
|
2850
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2851
|
+
* const [withdraw, { loading, error }] = useWithdraw((plan, { cancel }) => {
|
|
2852
|
+
* switch (plan.__typename) {
|
|
2853
|
+
* case 'TransactionRequest':
|
|
2854
|
+
* return sendTransaction(plan);
|
|
2088
2855
|
*
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
*
|
|
2092
|
-
* chainId: chainId(1),
|
|
2093
|
-
* },
|
|
2094
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2095
|
-
* pause: true,
|
|
2856
|
+
* case 'PreContractActionRequired':
|
|
2857
|
+
* return sendTransaction(plan.transaction);
|
|
2858
|
+
* }
|
|
2096
2859
|
* });
|
|
2097
2860
|
*
|
|
2098
|
-
* //
|
|
2099
|
-
* // error: UnexpectedError | undefined
|
|
2100
|
-
* // loading: boolean | undefined
|
|
2101
|
-
* ```
|
|
2102
|
-
*/
|
|
2103
|
-
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2104
|
-
/**
|
|
2105
|
-
* Low-level hook to execute a {@link activities} action directly.
|
|
2861
|
+
* // …
|
|
2106
2862
|
*
|
|
2107
|
-
*
|
|
2108
|
-
* @remarks
|
|
2109
|
-
* This hook does not actively watch for updates. Use it to fetch activities on demand
|
|
2110
|
-
* (e.g., in an event handler when paginating or refining filters).
|
|
2863
|
+
* const result = await withdraw({ ... });
|
|
2111
2864
|
*
|
|
2112
|
-
*
|
|
2113
|
-
*
|
|
2865
|
+
* if (result.isErr()) {
|
|
2866
|
+
* switch (result.error.name) {
|
|
2867
|
+
* case 'CancelError':
|
|
2868
|
+
* // The user cancelled the operation
|
|
2869
|
+
* return;
|
|
2870
|
+
*
|
|
2871
|
+
* case 'SigningError':
|
|
2872
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2873
|
+
* break;
|
|
2874
|
+
*
|
|
2875
|
+
* case 'TimeoutError':
|
|
2876
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2877
|
+
* break;
|
|
2878
|
+
*
|
|
2879
|
+
* case 'TransactionError':
|
|
2880
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2881
|
+
* break;
|
|
2882
|
+
*
|
|
2883
|
+
* case 'ValidationError':
|
|
2884
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2885
|
+
* break;
|
|
2886
|
+
*
|
|
2887
|
+
* case 'UnexpectedError':
|
|
2888
|
+
* console.error(result.error.message);
|
|
2889
|
+
* break;
|
|
2890
|
+
* }
|
|
2891
|
+
* return;
|
|
2892
|
+
* }
|
|
2893
|
+
*
|
|
2894
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2895
|
+
* ```
|
|
2896
|
+
*
|
|
2897
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
2114
2898
|
*/
|
|
2115
|
-
declare function
|
|
2899
|
+
declare function useWithdraw(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<WithdrawRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2116
2900
|
|
|
2117
2901
|
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2118
2902
|
/**
|
|
@@ -2227,7 +3011,7 @@ declare function useUserSupplies(args: Pausable<UseUserSuppliesArgs>): PausableR
|
|
|
2227
3011
|
* }
|
|
2228
3012
|
* ```
|
|
2229
3013
|
*/
|
|
2230
|
-
declare function useUserSuppliesAction(options?:
|
|
3014
|
+
declare function useUserSuppliesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError>;
|
|
2231
3015
|
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2232
3016
|
/**
|
|
2233
3017
|
* Fetch all user borrow positions.
|
|
@@ -2334,7 +3118,7 @@ declare function useUserBorrows(args: Pausable<UseUserBorrowsArgs>): PausableRea
|
|
|
2334
3118
|
* }
|
|
2335
3119
|
* ```
|
|
2336
3120
|
*/
|
|
2337
|
-
declare function useUserBorrowsAction(options?:
|
|
3121
|
+
declare function useUserBorrowsAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError>;
|
|
2338
3122
|
type UseUserSummaryArgs = Prettify<UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions>;
|
|
2339
3123
|
/**
|
|
2340
3124
|
* Fetch a user's financial summary.
|
|
@@ -2597,6 +3381,69 @@ declare function useUserBalances(args: UseUserBalancesArgs): ReadResult<UserBala
|
|
|
2597
3381
|
* ```
|
|
2598
3382
|
*/
|
|
2599
3383
|
declare function useUserBalances(args: Pausable<UseUserBalancesArgs>): PausableReadResult<UserBalance[]>;
|
|
3384
|
+
type UseUserRiskPremiumBreakdownArgs = UserRiskPremiumBreakdownRequest;
|
|
3385
|
+
/**
|
|
3386
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3387
|
+
*
|
|
3388
|
+
* This signature supports React Suspense:
|
|
3389
|
+
*
|
|
3390
|
+
* ```tsx
|
|
3391
|
+
* const { data } = useUserRiskPremiumBreakdown({
|
|
3392
|
+
* query: {
|
|
3393
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3394
|
+
* },
|
|
3395
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3396
|
+
* suspense: true,
|
|
3397
|
+
* });
|
|
3398
|
+
* ```
|
|
3399
|
+
*/
|
|
3400
|
+
declare function useUserRiskPremiumBreakdown(args: UseUserRiskPremiumBreakdownArgs & Suspendable): SuspenseResult<UserRiskPremiumBreakdownItem[]>;
|
|
3401
|
+
/**
|
|
3402
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3403
|
+
*
|
|
3404
|
+
* Pausable suspense mode.
|
|
3405
|
+
*
|
|
3406
|
+
* ```tsx
|
|
3407
|
+
* const { data } = useUserRiskPremiumBreakdown({
|
|
3408
|
+
* query: {
|
|
3409
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3410
|
+
* },
|
|
3411
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3412
|
+
* suspense: true,
|
|
3413
|
+
* pause: true,
|
|
3414
|
+
* });
|
|
3415
|
+
* ```
|
|
3416
|
+
*/
|
|
3417
|
+
declare function useUserRiskPremiumBreakdown(args: Pausable<UseUserRiskPremiumBreakdownArgs> & Suspendable): PausableSuspenseResult<UserRiskPremiumBreakdownItem[]>;
|
|
3418
|
+
/**
|
|
3419
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3420
|
+
*
|
|
3421
|
+
* ```tsx
|
|
3422
|
+
* const { data, error, loading } = useUserRiskPremiumBreakdown({
|
|
3423
|
+
* query: {
|
|
3424
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3425
|
+
* },
|
|
3426
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3427
|
+
* });
|
|
3428
|
+
* ```
|
|
3429
|
+
*/
|
|
3430
|
+
declare function useUserRiskPremiumBreakdown(args: UseUserRiskPremiumBreakdownArgs): ReadResult<UserRiskPremiumBreakdownItem[]>;
|
|
3431
|
+
/**
|
|
3432
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3433
|
+
*
|
|
3434
|
+
* Pausable loading state mode.
|
|
3435
|
+
*
|
|
3436
|
+
* ```tsx
|
|
3437
|
+
* const { data, error, loading, paused } = useUserRiskPremiumBreakdown({
|
|
3438
|
+
* query: {
|
|
3439
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3440
|
+
* },
|
|
3441
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3442
|
+
* pause: true,
|
|
3443
|
+
* });
|
|
3444
|
+
* ```
|
|
3445
|
+
*/
|
|
3446
|
+
declare function useUserRiskPremiumBreakdown(args: Pausable<UseUserRiskPremiumBreakdownArgs>): PausableReadResult<UserRiskPremiumBreakdownItem[]>;
|
|
2600
3447
|
/**
|
|
2601
3448
|
* Low-level hook to execute a {@link userBalances} action directly.
|
|
2602
3449
|
*
|
|
@@ -2686,4 +3533,190 @@ declare function useUserSummaryHistory(args: UseUserSummaryHistoryArgs): ReadRes
|
|
|
2686
3533
|
*/
|
|
2687
3534
|
declare function useUserSummaryHistory(args: Pausable<UseUserSummaryHistoryArgs>): PausableReadResult<UserSummaryHistoryItem[]>;
|
|
2688
3535
|
|
|
2689
|
-
|
|
3536
|
+
/**
|
|
3537
|
+
* A hook that provides a way to deposit assets into a stable vault.
|
|
3538
|
+
*
|
|
3539
|
+
* ```ts
|
|
3540
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
3541
|
+
*
|
|
3542
|
+
* const [deposit, { loading, error }] = useStableVaultDeposit((plan) => {
|
|
3543
|
+
* switch (plan.__typename) {
|
|
3544
|
+
* case 'TransactionRequest':
|
|
3545
|
+
* return sendTransaction(plan);
|
|
3546
|
+
*
|
|
3547
|
+
* case 'Erc20Approval':
|
|
3548
|
+
* return sendTransaction(plan.byTransaction);
|
|
3549
|
+
* }
|
|
3550
|
+
* });
|
|
3551
|
+
* ```
|
|
3552
|
+
*
|
|
3553
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
3554
|
+
*/
|
|
3555
|
+
declare function useStableVaultDeposit(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval, Signature | PendingTransaction>): UseAsyncTask<StableVaultDepositRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
3556
|
+
type StableVaultWithdrawResult = TransactionReceipt | StableVaultWithdrawClaim;
|
|
3557
|
+
/**
|
|
3558
|
+
* A hook that provides a way to withdraw from a stable vault.
|
|
3559
|
+
*
|
|
3560
|
+
* The result discriminates between instant and deferred withdrawals:
|
|
3561
|
+
* - `TransactionReceipt` — Instant withdraw completed.
|
|
3562
|
+
* - `StableVaultWithdrawClaim` — Deferred withdraw; IOU minted, funds need to be redeemed.
|
|
3563
|
+
*
|
|
3564
|
+
* ```ts
|
|
3565
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
3566
|
+
*
|
|
3567
|
+
* const [withdraw, { loading, error }] = useStableVaultWithdraw((transaction) =>
|
|
3568
|
+
* sendTransaction(transaction),
|
|
3569
|
+
* );
|
|
3570
|
+
* ```
|
|
3571
|
+
*
|
|
3572
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
3573
|
+
*/
|
|
3574
|
+
declare function useStableVaultWithdraw(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<StableVaultWithdrawRequest, StableVaultWithdrawResult, SendTransactionError | PendingTransactionError>;
|
|
3575
|
+
/**
|
|
3576
|
+
* A hook that provides a way to redeem a deferred withdrawal claim.
|
|
3577
|
+
*
|
|
3578
|
+
* Use this after the claim status is `READY` (see {@link useStableVaultClaimStatus}).
|
|
3579
|
+
*
|
|
3580
|
+
* ```ts
|
|
3581
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
3582
|
+
*
|
|
3583
|
+
* const [redeem, { loading, error }] = useStableVaultWithdrawRedeem((plan) =>
|
|
3584
|
+
* sendTransaction(plan),
|
|
3585
|
+
* );
|
|
3586
|
+
* ```
|
|
3587
|
+
*
|
|
3588
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
3589
|
+
*/
|
|
3590
|
+
declare function useStableVaultWithdrawRedeem(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<StableVaultWithdrawRedeemRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
3591
|
+
type UseStableVaultClaimStatusArgs = StableVaultClaimStatusRequest;
|
|
3592
|
+
/**
|
|
3593
|
+
* Poll a deferred withdrawal claim until it is ready.
|
|
3594
|
+
*
|
|
3595
|
+
* The hook automatically polls until the claim reaches a final status.
|
|
3596
|
+
*
|
|
3597
|
+
* This signature supports React Suspense:
|
|
3598
|
+
*
|
|
3599
|
+
* ```tsx
|
|
3600
|
+
* const { data } = useStableVaultClaimStatus({
|
|
3601
|
+
* claimId,
|
|
3602
|
+
* suspense: true,
|
|
3603
|
+
* });
|
|
3604
|
+
* ```
|
|
3605
|
+
*/
|
|
3606
|
+
declare function useStableVaultClaimStatus(args: UseStableVaultClaimStatusArgs & Suspendable): SuspenseResult<StableVaultClaimStatus>;
|
|
3607
|
+
/**
|
|
3608
|
+
* Pausable suspense mode.
|
|
3609
|
+
*/
|
|
3610
|
+
declare function useStableVaultClaimStatus(args: Pausable<UseStableVaultClaimStatusArgs> & Suspendable): PausableSuspenseResult<StableVaultClaimStatus>;
|
|
3611
|
+
/**
|
|
3612
|
+
* Poll a deferred withdrawal claim until it is ready.
|
|
3613
|
+
*
|
|
3614
|
+
* ```tsx
|
|
3615
|
+
* const { data, loading, error } = useStableVaultClaimStatus({
|
|
3616
|
+
* claimId,
|
|
3617
|
+
* });
|
|
3618
|
+
* ```
|
|
3619
|
+
*/
|
|
3620
|
+
declare function useStableVaultClaimStatus(args: UseStableVaultClaimStatusArgs): ReadResult<StableVaultClaimStatus>;
|
|
3621
|
+
/**
|
|
3622
|
+
* Pausable loading state mode.
|
|
3623
|
+
*/
|
|
3624
|
+
declare function useStableVaultClaimStatus(args: Pausable<UseStableVaultClaimStatusArgs>): PausableReadResult<StableVaultClaimStatus>;
|
|
3625
|
+
type UseStableVaultUserPositionsArgs = StableVaultUserPositionsRequest;
|
|
3626
|
+
/**
|
|
3627
|
+
* Fetch all stable vault positions for a given user.
|
|
3628
|
+
*
|
|
3629
|
+
* This signature supports React Suspense:
|
|
3630
|
+
*
|
|
3631
|
+
* ```tsx
|
|
3632
|
+
* const { data } = useStableVaultUserPositions({
|
|
3633
|
+
* user: evmAddress('0x…'),
|
|
3634
|
+
* suspense: true,
|
|
3635
|
+
* });
|
|
3636
|
+
* ```
|
|
3637
|
+
*/
|
|
3638
|
+
declare function useStableVaultUserPositions(args: UseStableVaultUserPositionsArgs & Suspendable): SuspenseResult<StableVaultUserPosition[]>;
|
|
3639
|
+
/**
|
|
3640
|
+
* Pausable suspense mode.
|
|
3641
|
+
*/
|
|
3642
|
+
declare function useStableVaultUserPositions(args: Pausable<UseStableVaultUserPositionsArgs> & Suspendable): PausableSuspenseResult<StableVaultUserPosition[]>;
|
|
3643
|
+
/**
|
|
3644
|
+
* Fetch all stable vault positions for a given user.
|
|
3645
|
+
*
|
|
3646
|
+
* ```tsx
|
|
3647
|
+
* const { data, loading, error } = useStableVaultUserPositions({
|
|
3648
|
+
* user: evmAddress('0x…'),
|
|
3649
|
+
* });
|
|
3650
|
+
* ```
|
|
3651
|
+
*/
|
|
3652
|
+
declare function useStableVaultUserPositions(args: UseStableVaultUserPositionsArgs): ReadResult<StableVaultUserPosition[]>;
|
|
3653
|
+
/**
|
|
3654
|
+
* Pausable loading state mode.
|
|
3655
|
+
*/
|
|
3656
|
+
declare function useStableVaultUserPositions(args: Pausable<UseStableVaultUserPositionsArgs>): PausableReadResult<StableVaultUserPosition[]>;
|
|
3657
|
+
type UseStableVaultArgs = StableVaultRequest;
|
|
3658
|
+
/**
|
|
3659
|
+
* Fetch a stable vault by ID.
|
|
3660
|
+
*
|
|
3661
|
+
* This signature supports React Suspense:
|
|
3662
|
+
*
|
|
3663
|
+
* ```tsx
|
|
3664
|
+
* const { data } = useStableVault({
|
|
3665
|
+
* id: stableVaultId('vault-123'),
|
|
3666
|
+
* suspense: true,
|
|
3667
|
+
* });
|
|
3668
|
+
* ```
|
|
3669
|
+
*/
|
|
3670
|
+
declare function useStableVault(args: UseStableVaultArgs & Suspendable): SuspenseResult<StableVault | null>;
|
|
3671
|
+
/**
|
|
3672
|
+
* Pausable suspense mode.
|
|
3673
|
+
*/
|
|
3674
|
+
declare function useStableVault(args: Pausable<UseStableVaultArgs> & Suspendable): PausableSuspenseResult<StableVault | null>;
|
|
3675
|
+
/**
|
|
3676
|
+
* Fetch a stable vault by ID.
|
|
3677
|
+
*
|
|
3678
|
+
* ```tsx
|
|
3679
|
+
* const { data, loading, error } = useStableVault({
|
|
3680
|
+
* id: stableVaultId('vault-123'),
|
|
3681
|
+
* });
|
|
3682
|
+
* ```
|
|
3683
|
+
*/
|
|
3684
|
+
declare function useStableVault(args: UseStableVaultArgs): ReadResult<StableVault | null>;
|
|
3685
|
+
/**
|
|
3686
|
+
* Pausable loading state mode.
|
|
3687
|
+
*/
|
|
3688
|
+
declare function useStableVault(args: Pausable<UseStableVaultArgs>): PausableReadResult<StableVault | null>;
|
|
3689
|
+
type UseStableVaultsArgs = StableVaultsRequest;
|
|
3690
|
+
/**
|
|
3691
|
+
* Fetch all stable vaults managed by a given admin address.
|
|
3692
|
+
*
|
|
3693
|
+
* This signature supports React Suspense:
|
|
3694
|
+
*
|
|
3695
|
+
* ```tsx
|
|
3696
|
+
* const { data } = useStableVaults({
|
|
3697
|
+
* adminAddress: evmAddress('0x…'),
|
|
3698
|
+
* suspense: true,
|
|
3699
|
+
* });
|
|
3700
|
+
* ```
|
|
3701
|
+
*/
|
|
3702
|
+
declare function useStableVaults(args: UseStableVaultsArgs & Suspendable): SuspenseResult<StableVault[]>;
|
|
3703
|
+
/**
|
|
3704
|
+
* Pausable suspense mode.
|
|
3705
|
+
*/
|
|
3706
|
+
declare function useStableVaults(args: Pausable<UseStableVaultsArgs> & Suspendable): PausableSuspenseResult<StableVault[]>;
|
|
3707
|
+
/**
|
|
3708
|
+
* Fetch all stable vaults managed by a given admin address.
|
|
3709
|
+
*
|
|
3710
|
+
* ```tsx
|
|
3711
|
+
* const { data, loading, error } = useStableVaults({
|
|
3712
|
+
* adminAddress: evmAddress('0x…'),
|
|
3713
|
+
* });
|
|
3714
|
+
* ```
|
|
3715
|
+
*/
|
|
3716
|
+
declare function useStableVaults(args: UseStableVaultsArgs): ReadResult<StableVault[]>;
|
|
3717
|
+
/**
|
|
3718
|
+
* Pausable loading state mode.
|
|
3719
|
+
*/
|
|
3720
|
+
declare function useStableVaults(args: Pausable<UseStableVaultsArgs>): PausableReadResult<StableVault[]>;
|
|
3721
|
+
|
|
3722
|
+
export { AaveProvider, type AaveProviderProps, type CancelSwapError, type CancelSwapHandler, CannotCancelSwapError, PendingTransactionError, type PositionSwapHandler, type PositionSwapPlan, type PositionSwapValue, SendTransactionError, type SwapHandlerOptions, type SwapSignerError, type TokenSwapHandler, type TokenSwapPlan, type UseActivitiesArgs, type UseAssetArgs, type UseAssetBorrowHistoryArgs, type UseAssetPriceHistoryArgs, type UseAssetSupplyHistoryArgs, UseAsyncTask, type UseBorrowApyHistoryArgs, type UseBorrowSwapQuoteArgs, type UseBorrowSwapRequest, type UseHubArgs, type UseHubAssetInterestRateModelArgs, type UseHubAssetsArgs, type UseHubSummaryHistoryArgs, type UseHubsArgs, type UsePreviewArgs, type UseProtocolHistoryArgs, type UseRepayWithSupplyQuoteArgs, type UseRepayWithSupplyRequest, type UseReserveArgs, type UseReservesArgs, type UseSpokeArgs, type UseSpokePositionManagersArgs, type UseSpokeUserPositionManagersArgs, type UseSpokesArgs, type UseStableVaultArgs, type UseStableVaultClaimStatusArgs, type UseStableVaultUserPositionsArgs, type UseStableVaultsArgs, type UseSupplyApyHistoryArgs, type UseSupplySwapQuoteArgs, type UseSupplySwapRequest, type UseSwapStatusArgs, type UseSwappableTokensArgs, type UseTokenSwapQuoteArgs, type UseTokenSwapRequest, type UseUserBalancesArgs, type UseUserBorrowsArgs, type UseUserClaimableRewardsArgs, type UseUserPositionArgs, type UseUserPositionsArgs, type UseUserRiskPremiumBreakdownArgs, type UseUserSummaryArgs, type UseUserSummaryHistoryArgs, type UseUserSuppliesArgs, type UseUserSwapsArgs, type UseWithdrawSwapQuoteArgs, type UseWithdrawSwapRequest, useAaveClient, useActivities, useActivitiesAction, useAsset, useAssetBorrowHistory, useAssetPriceHistory, useAssetSupplyHistory, useBorrow, useBorrowApyHistory, useBorrowSwap, useBorrowSwapQuote, useBorrowSwapQuoteAction, useCancelSwap, useClaimRewards, useHub, useHubAssetInterestRateModel, useHubAssetInterestRateModelAction, useHubAssets, useHubSummaryHistory, useHubs, useHubsAction, useLiquidatePosition, usePreview, usePreviewAction, useProtocolHistory, useRenounceSpokeUserPositionManager, useRepay, useRepayWithSupply, useRepayWithSupplyQuote, useRepayWithSupplyQuoteAction, useReserve, useReserveAction, useReserves, useReservesAction, useSetSpokeUserPositionManager, useSetUserSuppliesAsCollateral, useSpoke, useSpokePositionManagers, useSpokeUserPositionManagers, useSpokes, useStableVault, useStableVaultClaimStatus, useStableVaultDeposit, useStableVaultUserPositions, useStableVaultWithdraw, useStableVaultWithdrawRedeem, useStableVaults, useSupply, useSupplyApyHistory, useSupplySwap, useSupplySwapQuote, useSupplySwapQuoteAction, useSwapStatus, useSwappableTokens, useTokenSwap, useTokenSwapQuote, useTokenSwapQuoteAction, useUpdateUserPositionConditions, useUserBalances, useUserBalancesAction, useUserBorrows, useUserBorrowsAction, useUserClaimableRewards, useUserClaimableRewardsAction, useUserPosition, useUserPositions, useUserPositionsAction, useUserRiskPremiumBreakdown, useUserSummary, useUserSummaryHistory, useUserSupplies, useUserSuppliesAction, useUserSwaps, useWithdraw, useWithdrawSwap, useWithdrawSwapQuote, useWithdrawSwapQuoteAction };
|