@aave/react 4.0.0-next.9 → 4.0.1
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 +1557 -748
- package/dist/index.d.ts +1557 -748
- 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
|
/**
|
|
@@ -263,6 +263,82 @@ declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs): ReadResul
|
|
|
263
263
|
* ```
|
|
264
264
|
*/
|
|
265
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>;
|
|
266
342
|
/**
|
|
267
343
|
* Low-level hook to execute a {@link hubs} action directly.
|
|
268
344
|
*
|
|
@@ -292,11 +368,6 @@ declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs>):
|
|
|
292
368
|
*/
|
|
293
369
|
declare function useHubsAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubsRequest, Hub[], UnexpectedError>;
|
|
294
370
|
|
|
295
|
-
/**
|
|
296
|
-
* @internal
|
|
297
|
-
*/
|
|
298
|
-
declare function usePermitTypedDataAction(): UseAsyncTask<PermitRequest, PermitTypedDataResponse, UnexpectedError>;
|
|
299
|
-
|
|
300
371
|
type UseAssetArgs = Prettify<AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
301
372
|
/**
|
|
302
373
|
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
@@ -405,7 +476,7 @@ declare function useAssetPriceHistory(args: UseAssetPriceHistoryArgs): ReadResul
|
|
|
405
476
|
* ```
|
|
406
477
|
*/
|
|
407
478
|
declare function useAssetPriceHistory(args: Pausable<UseAssetPriceHistoryArgs>): PausableReadResult<AssetPriceSample[]>;
|
|
408
|
-
type UseAssetSupplyHistoryArgs = AssetSupplyHistoryRequest
|
|
479
|
+
type UseAssetSupplyHistoryArgs = Prettify<AssetSupplyHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
409
480
|
/**
|
|
410
481
|
* Fetch historical supply data for a specific asset.
|
|
411
482
|
*
|
|
@@ -458,7 +529,7 @@ declare function useAssetSupplyHistory(args: UseAssetSupplyHistoryArgs): ReadRes
|
|
|
458
529
|
* ```
|
|
459
530
|
*/
|
|
460
531
|
declare function useAssetSupplyHistory(args: Pausable<UseAssetSupplyHistoryArgs>): PausableReadResult<AssetSupplySample[]>;
|
|
461
|
-
type UseAssetBorrowHistoryArgs = AssetBorrowHistoryRequest
|
|
532
|
+
type UseAssetBorrowHistoryArgs = Prettify<AssetBorrowHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
462
533
|
/**
|
|
463
534
|
* Fetch historical borrow data for a specific asset.
|
|
464
535
|
*
|
|
@@ -511,112 +582,6 @@ declare function useAssetBorrowHistory(args: UseAssetBorrowHistoryArgs): ReadRes
|
|
|
511
582
|
* ```
|
|
512
583
|
*/
|
|
513
584
|
declare function useAssetBorrowHistory(args: Pausable<UseAssetBorrowHistoryArgs>): PausableReadResult<AssetBorrowSample[]>;
|
|
514
|
-
type UseAssetCategoryBorrowHistoryArgs = Prettify<AssetCategoryBorrowHistoryRequest & CurrencyQueryOptions>;
|
|
515
|
-
/**
|
|
516
|
-
* Fetch historical borrow data for a specific token category.
|
|
517
|
-
*
|
|
518
|
-
* This signature supports React Suspense:
|
|
519
|
-
*
|
|
520
|
-
* ```tsx
|
|
521
|
-
* const { data } = useAssetCategoryBorrowHistory({
|
|
522
|
-
* category: TokenCategory.Stablecoin,
|
|
523
|
-
* window: TimeWindow.LastWeek,
|
|
524
|
-
* suspense: true,
|
|
525
|
-
* });
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
declare function useAssetCategoryBorrowHistory(args: UseAssetCategoryBorrowHistoryArgs & Suspendable): SuspenseResult<AssetCategoryBorrowSample[]>;
|
|
529
|
-
/**
|
|
530
|
-
* Fetch historical borrow data for a specific token category.
|
|
531
|
-
*
|
|
532
|
-
* Pausable suspense mode.
|
|
533
|
-
*
|
|
534
|
-
* ```tsx
|
|
535
|
-
* const { data } = useAssetCategoryBorrowHistory({
|
|
536
|
-
* category: TokenCategory.Stablecoin,
|
|
537
|
-
* suspense: true,
|
|
538
|
-
* pause: true,
|
|
539
|
-
* });
|
|
540
|
-
* ```
|
|
541
|
-
*/
|
|
542
|
-
declare function useAssetCategoryBorrowHistory(args: Pausable<UseAssetCategoryBorrowHistoryArgs> & Suspendable): PausableSuspenseResult<AssetCategoryBorrowSample[]>;
|
|
543
|
-
/**
|
|
544
|
-
* Fetch historical borrow data for a specific token category.
|
|
545
|
-
*
|
|
546
|
-
* ```tsx
|
|
547
|
-
* const { data, error, loading } = useAssetCategoryBorrowHistory({
|
|
548
|
-
* category: TokenCategory.Stablecoin,
|
|
549
|
-
* window: TimeWindow.LastWeek,
|
|
550
|
-
* });
|
|
551
|
-
* ```
|
|
552
|
-
*/
|
|
553
|
-
declare function useAssetCategoryBorrowHistory(args: UseAssetCategoryBorrowHistoryArgs): ReadResult<AssetCategoryBorrowSample[]>;
|
|
554
|
-
/**
|
|
555
|
-
* Fetch historical borrow data for a specific token category.
|
|
556
|
-
*
|
|
557
|
-
* Pausable loading state mode.
|
|
558
|
-
*
|
|
559
|
-
* ```tsx
|
|
560
|
-
* const { data, error, loading, paused } = useAssetCategoryBorrowHistory({
|
|
561
|
-
* category: TokenCategory.Stablecoin,
|
|
562
|
-
* pause: true,
|
|
563
|
-
* });
|
|
564
|
-
* ```
|
|
565
|
-
*/
|
|
566
|
-
declare function useAssetCategoryBorrowHistory(args: Pausable<UseAssetCategoryBorrowHistoryArgs>): PausableReadResult<AssetCategoryBorrowSample[]>;
|
|
567
|
-
type UseAssetCategorySupplyHistoryArgs = Prettify<AssetCategorySupplyHistoryRequest & CurrencyQueryOptions>;
|
|
568
|
-
/**
|
|
569
|
-
* Fetch historical supply data for a specific token category.
|
|
570
|
-
*
|
|
571
|
-
* This signature supports React Suspense:
|
|
572
|
-
*
|
|
573
|
-
* ```tsx
|
|
574
|
-
* const { data } = useAssetCategorySupplyHistory({
|
|
575
|
-
* category: TokenCategory.Stablecoin,
|
|
576
|
-
* window: TimeWindow.LastWeek,
|
|
577
|
-
* suspense: true,
|
|
578
|
-
* });
|
|
579
|
-
* ```
|
|
580
|
-
*/
|
|
581
|
-
declare function useAssetCategorySupplyHistory(args: UseAssetCategorySupplyHistoryArgs & Suspendable): SuspenseResult<AssetCategorySupplySample[]>;
|
|
582
|
-
/**
|
|
583
|
-
* Fetch historical supply data for a specific token category.
|
|
584
|
-
*
|
|
585
|
-
* Pausable suspense mode.
|
|
586
|
-
*
|
|
587
|
-
* ```tsx
|
|
588
|
-
* const { data } = useAssetCategorySupplyHistory({
|
|
589
|
-
* category: TokenCategory.Stablecoin,
|
|
590
|
-
* suspense: true,
|
|
591
|
-
* pause: true,
|
|
592
|
-
* });
|
|
593
|
-
* ```
|
|
594
|
-
*/
|
|
595
|
-
declare function useAssetCategorySupplyHistory(args: Pausable<UseAssetCategorySupplyHistoryArgs> & Suspendable): PausableSuspenseResult<AssetCategorySupplySample[]>;
|
|
596
|
-
/**
|
|
597
|
-
* Fetch historical supply data for a specific token category.
|
|
598
|
-
*
|
|
599
|
-
* ```tsx
|
|
600
|
-
* const { data, error, loading } = useAssetCategorySupplyHistory({
|
|
601
|
-
* category: TokenCategory.Stablecoin,
|
|
602
|
-
* window: TimeWindow.LastWeek,
|
|
603
|
-
* });
|
|
604
|
-
* ```
|
|
605
|
-
*/
|
|
606
|
-
declare function useAssetCategorySupplyHistory(args: UseAssetCategorySupplyHistoryArgs): ReadResult<AssetCategorySupplySample[]>;
|
|
607
|
-
/**
|
|
608
|
-
* Fetch historical supply data for a specific token category.
|
|
609
|
-
*
|
|
610
|
-
* Pausable loading state mode.
|
|
611
|
-
*
|
|
612
|
-
* ```tsx
|
|
613
|
-
* const { data, error, loading, paused } = useAssetCategorySupplyHistory({
|
|
614
|
-
* category: TokenCategory.Stablecoin,
|
|
615
|
-
* pause: true,
|
|
616
|
-
* });
|
|
617
|
-
* ```
|
|
618
|
-
*/
|
|
619
|
-
declare function useAssetCategorySupplyHistory(args: Pausable<UseAssetCategorySupplyHistoryArgs>): PausableReadResult<AssetCategorySupplySample[]>;
|
|
620
585
|
type UseProtocolHistoryArgs = ProtocolHistoryRequest;
|
|
621
586
|
/**
|
|
622
587
|
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
@@ -753,18 +718,8 @@ declare function useReserve(args: Pausable<UseReserveArgs>): PausableReadResult<
|
|
|
753
718
|
* }
|
|
754
719
|
* ```
|
|
755
720
|
*/
|
|
756
|
-
declare function useReserveAction(options?:
|
|
757
|
-
type UseReservesArgs
|
|
758
|
-
/**
|
|
759
|
-
* A function that maps the full list of reserves
|
|
760
|
-
* into a derived or narrowed value.
|
|
761
|
-
*
|
|
762
|
-
* Example: pick a single reserve based on a criteria.
|
|
763
|
-
*
|
|
764
|
-
* @experimental This is experimental and may be subject to breaking changes.
|
|
765
|
-
*/
|
|
766
|
-
selector?: Selector<Reserve[], T>;
|
|
767
|
-
}>;
|
|
721
|
+
declare function useReserveAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError>;
|
|
722
|
+
type UseReservesArgs = Prettify<ReservesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
768
723
|
/**
|
|
769
724
|
* Fetch reserves based on specified criteria.
|
|
770
725
|
*
|
|
@@ -783,36 +738,8 @@ type UseReservesArgs<T = Reserve[]> = Prettify<ReservesRequest & CurrencyQueryOp
|
|
|
783
738
|
* suspense: true,
|
|
784
739
|
* });
|
|
785
740
|
* ```
|
|
786
|
-
*
|
|
787
|
-
* **Reserves with Highest Supply APY**
|
|
788
|
-
* ```tsx
|
|
789
|
-
* const { data } = useReserves({
|
|
790
|
-
* query: {
|
|
791
|
-
* spoke: {
|
|
792
|
-
* address: evmAddress('0x123...'),
|
|
793
|
-
* chainId: chainId(1)
|
|
794
|
-
* }
|
|
795
|
-
* },
|
|
796
|
-
* suspense: true,
|
|
797
|
-
* selector: pickHighestSupplyApyReserve,
|
|
798
|
-
* });
|
|
799
|
-
* ```
|
|
800
|
-
*
|
|
801
|
-
* **Reserves with Lowest Borrow APY**
|
|
802
|
-
* ```tsx
|
|
803
|
-
* const { data } = useReserves({
|
|
804
|
-
* query: {
|
|
805
|
-
* spoke: {
|
|
806
|
-
* address: evmAddress('0x123...'),
|
|
807
|
-
* chainId: chainId(1)
|
|
808
|
-
* }
|
|
809
|
-
* },
|
|
810
|
-
* suspense: true,
|
|
811
|
-
* selector: pickLowestBorrowApyReserve,
|
|
812
|
-
* });
|
|
813
|
-
* ```
|
|
814
741
|
*/
|
|
815
|
-
declare function useReserves
|
|
742
|
+
declare function useReserves(args: UseReservesArgs & Suspendable): SuspenseResult<Reserve[]>;
|
|
816
743
|
/**
|
|
817
744
|
* Fetch reserves based on specified criteria.
|
|
818
745
|
*
|
|
@@ -831,7 +758,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T> & Suspendab
|
|
|
831
758
|
* });
|
|
832
759
|
* ```
|
|
833
760
|
*/
|
|
834
|
-
declare function useReserves
|
|
761
|
+
declare function useReserves(args: Pausable<UseReservesArgs> & Suspendable): PausableSuspenseResult<Reserve[]>;
|
|
835
762
|
/**
|
|
836
763
|
* Fetch reserves based on specified criteria.
|
|
837
764
|
*
|
|
@@ -847,34 +774,8 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>> &
|
|
|
847
774
|
* orderBy: { name: 'ASC' },
|
|
848
775
|
* });
|
|
849
776
|
* ```
|
|
850
|
-
*
|
|
851
|
-
* **Reserves with Highest Supply APY**
|
|
852
|
-
* ```tsx
|
|
853
|
-
* const { data } = useReserves({
|
|
854
|
-
* query: {
|
|
855
|
-
* spoke: {
|
|
856
|
-
* address: evmAddress('0x123...'),
|
|
857
|
-
* chainId: chainId(1)
|
|
858
|
-
* }
|
|
859
|
-
* },
|
|
860
|
-
* selector: pickHighestSupplyApyReserve,
|
|
861
|
-
* });
|
|
862
|
-
* ```
|
|
863
|
-
*
|
|
864
|
-
* **Reserves with Lowest Borrow APY**
|
|
865
|
-
* ```tsx
|
|
866
|
-
* const { data } = useReserves({
|
|
867
|
-
* query: {
|
|
868
|
-
* spoke: {
|
|
869
|
-
* address: evmAddress('0x123...'),
|
|
870
|
-
* chainId: chainId(1)
|
|
871
|
-
* }
|
|
872
|
-
* },
|
|
873
|
-
* selector: pickLowestBorrowApyReserve,
|
|
874
|
-
* });
|
|
875
|
-
* ```
|
|
876
777
|
*/
|
|
877
|
-
declare function useReserves
|
|
778
|
+
declare function useReserves(args: UseReservesArgs): ReadResult<Reserve[], UnexpectedError>;
|
|
878
779
|
/**
|
|
879
780
|
* Fetch reserves based on specified criteria.
|
|
880
781
|
*
|
|
@@ -892,7 +793,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T>): ReadResul
|
|
|
892
793
|
* });
|
|
893
794
|
* ```
|
|
894
795
|
*/
|
|
895
|
-
declare function useReserves
|
|
796
|
+
declare function useReserves(args: Pausable<UseReservesArgs>): PausableReadResult<Reserve[], UnexpectedError>;
|
|
896
797
|
/**
|
|
897
798
|
* Low-level hook to execute a {@link reserves} action directly.
|
|
898
799
|
*
|
|
@@ -922,38 +823,8 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>>):
|
|
|
922
823
|
* console.error(result.error);
|
|
923
824
|
* }
|
|
924
825
|
* ```
|
|
925
|
-
*
|
|
926
|
-
* **Reserves with Highest Supply APY**
|
|
927
|
-
* ```ts
|
|
928
|
-
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
929
|
-
*
|
|
930
|
-
* // …
|
|
931
|
-
*
|
|
932
|
-
* const result = await execute(…).map(pickHighestSupplyApyReserve);
|
|
933
|
-
*
|
|
934
|
-
* if (result.isOk()) {
|
|
935
|
-
* console.log(result.value); // Reserve | null
|
|
936
|
-
* } else {
|
|
937
|
-
* console.error(result.error);
|
|
938
|
-
* }
|
|
939
|
-
* ```
|
|
940
|
-
*
|
|
941
|
-
* **Reserves with Lowest Borrow APY**
|
|
942
|
-
* ```ts
|
|
943
|
-
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
944
|
-
*
|
|
945
|
-
* // …
|
|
946
|
-
*
|
|
947
|
-
* const result = await execute(…).map(pickLowestBorrowApyReserve);
|
|
948
|
-
*
|
|
949
|
-
* if (result.isOk()) {
|
|
950
|
-
* console.log(result.value); // Reserve | null
|
|
951
|
-
* } else {
|
|
952
|
-
* console.error(result.error);
|
|
953
|
-
* }
|
|
954
|
-
* ```
|
|
955
826
|
*/
|
|
956
|
-
declare function useReservesAction(options?:
|
|
827
|
+
declare function useReservesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError>;
|
|
957
828
|
type UseBorrowApyHistoryArgs = BorrowApyHistoryRequest;
|
|
958
829
|
/**
|
|
959
830
|
* Fetch borrow APY history for a specific reserve over time.
|
|
@@ -1065,81 +936,159 @@ declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<
|
|
|
1065
936
|
*/
|
|
1066
937
|
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<ApySample[]>;
|
|
1067
938
|
|
|
1068
|
-
type
|
|
939
|
+
type UseUserClaimableRewardsArgs = Prettify<UserClaimableRewardsRequest>;
|
|
1069
940
|
/**
|
|
1070
|
-
* Fetch a
|
|
941
|
+
* Fetch all claimable rewards for a user.
|
|
1071
942
|
*
|
|
1072
943
|
* This signature supports React Suspense:
|
|
1073
944
|
*
|
|
1074
945
|
* ```tsx
|
|
1075
|
-
* const { data } =
|
|
1076
|
-
*
|
|
946
|
+
* const { data } = useUserClaimableRewards({
|
|
947
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1077
948
|
* suspense: true,
|
|
1078
949
|
* });
|
|
1079
|
-
* // data will be Spoke | null
|
|
1080
950
|
* ```
|
|
1081
951
|
*/
|
|
1082
|
-
declare function
|
|
952
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs & Suspendable): SuspenseResult<UserClaimableReward[]>;
|
|
1083
953
|
/**
|
|
1084
|
-
* Fetch a
|
|
954
|
+
* Fetch all claimable rewards for a user.
|
|
1085
955
|
*
|
|
1086
956
|
* Pausable suspense mode.
|
|
1087
957
|
*
|
|
1088
958
|
* ```tsx
|
|
1089
|
-
* const { data } =
|
|
1090
|
-
*
|
|
959
|
+
* const { data } = useUserClaimableRewards({
|
|
960
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1091
961
|
* suspense: true,
|
|
1092
962
|
* pause: true,
|
|
1093
963
|
* });
|
|
1094
964
|
* ```
|
|
1095
965
|
*/
|
|
1096
|
-
declare function
|
|
966
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs> & Suspendable): PausableSuspenseResult<UserClaimableReward[]>;
|
|
1097
967
|
/**
|
|
1098
|
-
* Fetch a
|
|
968
|
+
* Fetch all claimable rewards for a user.
|
|
1099
969
|
*
|
|
1100
970
|
* ```tsx
|
|
1101
|
-
* const { data, error, loading } =
|
|
1102
|
-
*
|
|
971
|
+
* const { data, error, loading } = useUserClaimableRewards({
|
|
972
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1103
973
|
* });
|
|
1104
|
-
* // data will be Spoke | null
|
|
1105
974
|
* ```
|
|
1106
975
|
*/
|
|
1107
|
-
declare function
|
|
976
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs): ReadResult<UserClaimableReward[]>;
|
|
1108
977
|
/**
|
|
1109
|
-
* Fetch a
|
|
978
|
+
* Fetch all claimable rewards for a user.
|
|
1110
979
|
*
|
|
1111
980
|
* Pausable loading state mode.
|
|
1112
981
|
*
|
|
1113
982
|
* ```tsx
|
|
1114
|
-
* const { data, error, loading, paused } =
|
|
1115
|
-
*
|
|
983
|
+
* const { data, error, loading, paused } = useUserClaimableRewards({
|
|
984
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1116
985
|
* pause: true,
|
|
1117
986
|
* });
|
|
1118
987
|
* ```
|
|
1119
988
|
*/
|
|
1120
|
-
declare function
|
|
1121
|
-
type UseSpokesArgs = SpokesRequest;
|
|
989
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs>): PausableReadResult<UserClaimableReward[]>;
|
|
1122
990
|
/**
|
|
1123
|
-
*
|
|
991
|
+
* Low-level hook to execute a {@link userClaimableRewards} action directly.
|
|
1124
992
|
*
|
|
1125
|
-
* This
|
|
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).
|
|
1126
998
|
*
|
|
1127
|
-
* ```
|
|
1128
|
-
* const { data } =
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
999
|
+
* ```ts
|
|
1000
|
+
* const [execute, { called, data, error, loading }] = useUserClaimableRewardsAction();
|
|
1001
|
+
*
|
|
1002
|
+
* // …
|
|
1003
|
+
*
|
|
1004
|
+
* const result = await execute({
|
|
1005
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1131
1006
|
* });
|
|
1007
|
+
*
|
|
1008
|
+
* if (result.isOk()) {
|
|
1009
|
+
* console.log(result.value); // UserClaimableReward[]
|
|
1010
|
+
* } else {
|
|
1011
|
+
* console.error(result.error);
|
|
1012
|
+
* }
|
|
1132
1013
|
* ```
|
|
1133
1014
|
*/
|
|
1134
|
-
declare function
|
|
1015
|
+
declare function useUserClaimableRewardsAction(): UseAsyncTask<UserClaimableRewardsRequest, UserClaimableReward[], UnexpectedError>;
|
|
1016
|
+
|
|
1017
|
+
type UseSpokeArgs = SpokeRequest;
|
|
1135
1018
|
/**
|
|
1136
|
-
* Fetch
|
|
1019
|
+
* Fetch a specific spoke.
|
|
1137
1020
|
*
|
|
1138
|
-
*
|
|
1021
|
+
* This signature supports React Suspense:
|
|
1139
1022
|
*
|
|
1140
1023
|
* ```tsx
|
|
1141
|
-
* const { data } =
|
|
1142
|
-
* query: {
|
|
1024
|
+
* const { data } = useSpoke({
|
|
1025
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1026
|
+
* suspense: true,
|
|
1027
|
+
* });
|
|
1028
|
+
* // data will be Spoke | null
|
|
1029
|
+
* ```
|
|
1030
|
+
*/
|
|
1031
|
+
declare function useSpoke(args: UseSpokeArgs & Suspendable): SuspenseResult<Spoke | null>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Fetch a specific spoke.
|
|
1034
|
+
*
|
|
1035
|
+
* Pausable suspense mode.
|
|
1036
|
+
*
|
|
1037
|
+
* ```tsx
|
|
1038
|
+
* const { data } = useSpoke({
|
|
1039
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1040
|
+
* suspense: true,
|
|
1041
|
+
* pause: true,
|
|
1042
|
+
* });
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
declare function useSpoke(args: Pausable<UseSpokeArgs> & Suspendable): PausableSuspenseResult<Spoke | null>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Fetch a specific spoke.
|
|
1048
|
+
*
|
|
1049
|
+
* ```tsx
|
|
1050
|
+
* const { data, error, loading } = useSpoke({
|
|
1051
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1052
|
+
* });
|
|
1053
|
+
* // data will be Spoke | null
|
|
1054
|
+
* ```
|
|
1055
|
+
*/
|
|
1056
|
+
declare function useSpoke(args: UseSpokeArgs): ReadResult<Spoke | null>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Fetch a specific spoke.
|
|
1059
|
+
*
|
|
1060
|
+
* Pausable loading state mode.
|
|
1061
|
+
*
|
|
1062
|
+
* ```tsx
|
|
1063
|
+
* const { data, error, loading, paused } = useSpoke({
|
|
1064
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1065
|
+
* pause: true,
|
|
1066
|
+
* });
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
declare function useSpoke(args: Pausable<UseSpokeArgs>): PausableReadResult<Spoke | null>;
|
|
1070
|
+
type UseSpokesArgs = SpokesRequest;
|
|
1071
|
+
/**
|
|
1072
|
+
* Fetch spokes based on specified criteria.
|
|
1073
|
+
*
|
|
1074
|
+
* This signature supports React Suspense:
|
|
1075
|
+
*
|
|
1076
|
+
* ```tsx
|
|
1077
|
+
* const { data } = useSpokes({
|
|
1078
|
+
* query: { chainIds: [chainId(1)] },
|
|
1079
|
+
* suspense: true,
|
|
1080
|
+
* });
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
declare function useSpokes(args: UseSpokesArgs & Suspendable): SuspenseResult<Spoke[]>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Fetch spokes based on specified criteria.
|
|
1086
|
+
*
|
|
1087
|
+
* Pausable suspense mode.
|
|
1088
|
+
*
|
|
1089
|
+
* ```tsx
|
|
1090
|
+
* const { data } = useSpokes({
|
|
1091
|
+
* query: { chainIds: [chainId(1)] },
|
|
1143
1092
|
* suspense: true,
|
|
1144
1093
|
* pause: true,
|
|
1145
1094
|
* });
|
|
@@ -1276,264 +1225,352 @@ declare function useSpokeUserPositionManagers(args: UseSpokeUserPositionManagers
|
|
|
1276
1225
|
*/
|
|
1277
1226
|
declare function useSpokeUserPositionManagers(args: Pausable<UseSpokeUserPositionManagersArgs>): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1278
1227
|
|
|
1279
|
-
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>;
|
|
1280
1239
|
/**
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
1240
|
+
* Orchestrate the borrow swap execution plan.
|
|
1241
|
+
*
|
|
1242
|
+
* ```tsx
|
|
1243
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1244
|
+
*
|
|
1245
|
+
* const [swapBorrow, { loading, error }] = useBorrowSwap((plan) => {
|
|
1246
|
+
* switch (plan.__typename) {
|
|
1247
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1248
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1249
|
+
* return signTypedData(plan.bySignature);
|
|
1250
|
+
*
|
|
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.
|
|
1283
1278
|
*
|
|
1284
1279
|
* This signature supports React Suspense:
|
|
1285
1280
|
*
|
|
1286
1281
|
* ```tsx
|
|
1287
|
-
* const { data } =
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1282
|
+
* const { data } = useBorrowSwapQuote({
|
|
1283
|
+
* market: {
|
|
1284
|
+
* sellPosition: userBorrowItem.id,
|
|
1285
|
+
* buyReserve: reserve.id,
|
|
1286
|
+
* amount: bigDecimal('1000'),
|
|
1287
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1288
|
+
* },
|
|
1293
1289
|
* suspense: true,
|
|
1294
1290
|
* });
|
|
1295
1291
|
* ```
|
|
1296
1292
|
*/
|
|
1297
|
-
declare function
|
|
1293
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1298
1294
|
/**
|
|
1299
|
-
*
|
|
1300
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1295
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1301
1296
|
*
|
|
1302
1297
|
* Pausable suspense mode.
|
|
1303
1298
|
*
|
|
1304
1299
|
* ```tsx
|
|
1305
|
-
* const { data } =
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1300
|
+
* const { data } = useBorrowSwapQuote({
|
|
1301
|
+
* market: {
|
|
1302
|
+
* sellPosition: userBorrowItem.id,
|
|
1303
|
+
* buyReserve: reserve.id,
|
|
1304
|
+
* amount: bigDecimal('1000'),
|
|
1305
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1306
|
+
* },
|
|
1312
1307
|
* suspense: true,
|
|
1313
1308
|
* pause: true,
|
|
1314
1309
|
* });
|
|
1315
1310
|
* ```
|
|
1316
1311
|
*/
|
|
1317
|
-
declare function
|
|
1312
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1318
1313
|
/**
|
|
1319
|
-
*
|
|
1320
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1314
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1321
1315
|
*
|
|
1322
1316
|
* ```tsx
|
|
1323
|
-
* const { data, error, loading } =
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1327
|
-
*
|
|
1328
|
-
*
|
|
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
|
+
* },
|
|
1329
1324
|
* });
|
|
1330
1325
|
* ```
|
|
1331
1326
|
*/
|
|
1332
|
-
declare function
|
|
1327
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1333
1328
|
/**
|
|
1334
|
-
*
|
|
1335
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1329
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1336
1330
|
*
|
|
1337
1331
|
* Pausable loading state mode.
|
|
1338
1332
|
*
|
|
1339
1333
|
* ```tsx
|
|
1340
|
-
* const { data, error, loading, paused } =
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
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
|
+
* },
|
|
1347
1341
|
* pause: true,
|
|
1348
1342
|
* });
|
|
1349
1343
|
* ```
|
|
1350
1344
|
*/
|
|
1351
|
-
declare function
|
|
1345
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1352
1346
|
/**
|
|
1353
|
-
*
|
|
1354
|
-
* Low-level hook to execute a swap quote action directly.
|
|
1347
|
+
* Low-level hook to execute a borrow swap quote action directly.
|
|
1355
1348
|
*
|
|
1356
|
-
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
1357
1349
|
* @remarks
|
|
1358
1350
|
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1359
|
-
* Use this hook to retrieve quotes on demand as part of a larger workflow
|
|
1360
|
-
* (e.g., in an event handler to get a fresh quote before executing a swap).
|
|
1351
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1361
1352
|
*
|
|
1362
1353
|
* ```ts
|
|
1363
|
-
* const [getQuote, { called, data, error, loading }] =
|
|
1354
|
+
* const [getQuote, { called, data, error, loading }] = useBorrowSwapQuoteAction();
|
|
1364
1355
|
*
|
|
1365
1356
|
* // …
|
|
1366
1357
|
*
|
|
1367
1358
|
* const result = await getQuote({
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1359
|
+
* debtPosition: userBorrowItem.id,
|
|
1360
|
+
* buyReserve: reserve.id,
|
|
1371
1361
|
* amount: bigDecimal('1000'),
|
|
1372
|
-
*
|
|
1362
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1373
1363
|
* });
|
|
1374
1364
|
*
|
|
1375
1365
|
* if (result.isOk()) {
|
|
1376
|
-
* console.log('
|
|
1366
|
+
* console.log('Borrow swap quote:', result.value);
|
|
1377
1367
|
* } else {
|
|
1378
1368
|
* console.error(result.error);
|
|
1379
1369
|
* }
|
|
1380
1370
|
* ```
|
|
1381
1371
|
*/
|
|
1382
|
-
declare function
|
|
1383
|
-
|
|
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;
|
|
1384
1381
|
/**
|
|
1385
|
-
*
|
|
1386
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1387
|
-
*
|
|
1388
|
-
* This signature supports React Suspense:
|
|
1382
|
+
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
1389
1383
|
*
|
|
1390
1384
|
* ```tsx
|
|
1391
|
-
* const
|
|
1392
|
-
*
|
|
1393
|
-
* suspense: true,
|
|
1394
|
-
* });
|
|
1395
|
-
* ```
|
|
1396
|
-
*/
|
|
1397
|
-
declare function useSwappableTokens(args: UseSwappableTokensArgs & Suspendable): SuspenseResult<Token[]>;
|
|
1398
|
-
/**
|
|
1399
|
-
* @internal
|
|
1400
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1385
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1386
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1401
1387
|
*
|
|
1402
|
-
*
|
|
1388
|
+
* const [cancelSwap, { loading, error }] = useCancelSwap((plan) => {
|
|
1389
|
+
* switch (plan.__typename) {
|
|
1390
|
+
* case 'TransactionRequest':
|
|
1391
|
+
* return sendTransaction(plan);
|
|
1403
1392
|
*
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1407
|
-
* suspense: true,
|
|
1408
|
-
* pause: true,
|
|
1393
|
+
* case 'SwapTypedData':
|
|
1394
|
+
* return signTypedData(plan);
|
|
1395
|
+
* }
|
|
1409
1396
|
* });
|
|
1410
|
-
* ```
|
|
1411
|
-
*/
|
|
1412
|
-
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs> & Suspendable): PausableSuspenseResult<Token[]>;
|
|
1413
|
-
/**
|
|
1414
|
-
* @internal
|
|
1415
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1416
1397
|
*
|
|
1417
|
-
*
|
|
1418
|
-
*
|
|
1419
|
-
* query: { chainIds: [chainId(1)] },
|
|
1398
|
+
* const result = await cancelSwap({
|
|
1399
|
+
* id: swapId('123…'),
|
|
1420
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);
|
|
1421
1409
|
* ```
|
|
1422
1410
|
*/
|
|
1423
|
-
declare function
|
|
1411
|
+
declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<PrepareSwapCancelRequest, SwapCancelledResult, CancelSwapError>;
|
|
1412
|
+
|
|
1413
|
+
type UseRepayWithSupplyRequest = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1424
1414
|
/**
|
|
1425
|
-
*
|
|
1426
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1427
|
-
*
|
|
1428
|
-
* Pausable loading state mode.
|
|
1415
|
+
* Orchestrate the repay with supply execution plan.
|
|
1429
1416
|
*
|
|
1430
1417
|
* ```tsx
|
|
1431
|
-
* const
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
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
|
+
* },
|
|
1434
1438
|
* });
|
|
1439
|
+
*
|
|
1440
|
+
* if (result.isErr()) {
|
|
1441
|
+
* console.error(result.error);
|
|
1442
|
+
* return;
|
|
1443
|
+
* }
|
|
1444
|
+
*
|
|
1445
|
+
* // result.value: SwapReceipt
|
|
1435
1446
|
* ```
|
|
1436
1447
|
*/
|
|
1437
|
-
declare function
|
|
1438
|
-
|
|
1448
|
+
declare function useRepayWithSupply(handler: PositionSwapHandler): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1449
|
+
|
|
1450
|
+
type UseRepayWithSupplyQuoteArgs = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1439
1451
|
/**
|
|
1440
|
-
*
|
|
1441
|
-
* Fetch the user's swap history for a specific chain.
|
|
1452
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1442
1453
|
*
|
|
1443
1454
|
* This signature supports React Suspense:
|
|
1444
1455
|
*
|
|
1445
1456
|
* ```tsx
|
|
1446
|
-
* const { data } =
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1457
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1458
|
+
* market: {
|
|
1459
|
+
* sellPosition: userSupplyItem.id,
|
|
1460
|
+
* buyPosition: userBorrowItem.id,
|
|
1461
|
+
* amount: bigDecimal('1000'),
|
|
1462
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1463
|
+
* },
|
|
1450
1464
|
* suspense: true,
|
|
1451
1465
|
* });
|
|
1452
1466
|
* ```
|
|
1453
1467
|
*/
|
|
1454
|
-
declare function
|
|
1468
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1455
1469
|
/**
|
|
1456
|
-
*
|
|
1457
|
-
* Fetch the user's swap history for a specific chain.
|
|
1470
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1458
1471
|
*
|
|
1459
1472
|
* Pausable suspense mode.
|
|
1460
1473
|
*
|
|
1461
1474
|
* ```tsx
|
|
1462
|
-
* const { data } =
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1465
|
-
*
|
|
1475
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1476
|
+
* market: {
|
|
1477
|
+
* sellPosition: userSupplyItem.id,
|
|
1478
|
+
* buyPosition: userBorrowItem.id,
|
|
1479
|
+
* amount: bigDecimal('1000'),
|
|
1480
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1481
|
+
* },
|
|
1466
1482
|
* suspense: true,
|
|
1467
1483
|
* pause: true,
|
|
1468
1484
|
* });
|
|
1469
1485
|
* ```
|
|
1470
1486
|
*/
|
|
1471
|
-
declare function
|
|
1487
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1472
1488
|
/**
|
|
1473
|
-
*
|
|
1474
|
-
* Fetch the user's swap history for a specific chain.
|
|
1489
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1475
1490
|
*
|
|
1476
1491
|
* ```tsx
|
|
1477
|
-
* const { data, error, loading } =
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
*
|
|
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
|
+
* },
|
|
1481
1499
|
* });
|
|
1482
1500
|
* ```
|
|
1483
1501
|
*/
|
|
1484
|
-
declare function
|
|
1502
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs): ReadResult<SwapQuote>;
|
|
1485
1503
|
/**
|
|
1486
|
-
*
|
|
1487
|
-
* Fetch the user's swap history for a specific chain.
|
|
1504
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1488
1505
|
*
|
|
1489
1506
|
* Pausable loading state mode.
|
|
1490
1507
|
*
|
|
1491
1508
|
* ```tsx
|
|
1492
|
-
* const { data, error, loading, paused } =
|
|
1493
|
-
*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
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
|
+
* },
|
|
1496
1516
|
* pause: true,
|
|
1497
1517
|
* });
|
|
1498
1518
|
* ```
|
|
1499
1519
|
*/
|
|
1500
|
-
declare function
|
|
1501
|
-
type UseSwapTokensRequest = Prettify<PrepareSwapRequest & CurrencyQueryOptions>;
|
|
1502
|
-
type SwapIntent = SwapByIntentTypedData | SwapByIntentWithApprovalRequired | SwapTransactionRequest | SwapApprovalRequired;
|
|
1503
|
-
type SwapHandlerOptions = {
|
|
1504
|
-
cancel: CancelOperation;
|
|
1505
|
-
};
|
|
1506
|
-
type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAsync<ERC20PermitSignature | SwapReceipt, SendTransactionError | PendingTransactionError>;
|
|
1520
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1507
1521
|
/**
|
|
1508
|
-
*
|
|
1509
|
-
* Orchestrate the swap execution plan.
|
|
1522
|
+
* Low-level hook to execute a repay with supply quote action directly.
|
|
1510
1523
|
*
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
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.
|
|
1514
1527
|
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
* case 'SwapByIntentTypedData':
|
|
1518
|
-
* return signSwapByIntentWith(plan);
|
|
1528
|
+
* ```ts
|
|
1529
|
+
* const [getQuote, { called, data, error, loading }] = useRepayWithSupplyQuoteAction();
|
|
1519
1530
|
*
|
|
1520
|
-
*
|
|
1521
|
-
* case 'SwapByIntentWithApprovalRequired':
|
|
1522
|
-
* return sendTransaction(plan.transaction);
|
|
1531
|
+
* // …
|
|
1523
1532
|
*
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
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);
|
|
1526
1564
|
* }
|
|
1527
1565
|
* });
|
|
1528
1566
|
*
|
|
1529
|
-
* const result = await
|
|
1567
|
+
* const result = await swapSupply({
|
|
1530
1568
|
* market: {
|
|
1531
|
-
*
|
|
1532
|
-
*
|
|
1533
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1569
|
+
* sellPosition: supplyPosition.id,
|
|
1570
|
+
* buyReserve: targetReserve.id,
|
|
1534
1571
|
* amount: bigDecimal('1000'),
|
|
1535
|
-
*
|
|
1536
|
-
*
|
|
1572
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1573
|
+
* enableCollateral: true,
|
|
1537
1574
|
* },
|
|
1538
1575
|
* });
|
|
1539
1576
|
*
|
|
@@ -1545,32 +1582,245 @@ type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAs
|
|
|
1545
1582
|
* // result.value: SwapReceipt
|
|
1546
1583
|
* ```
|
|
1547
1584
|
*/
|
|
1548
|
-
declare function
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
name: "CannotCancelSwapError";
|
|
1552
|
-
}
|
|
1553
|
-
type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | TimeoutError | TransactionError | UnexpectedError$1;
|
|
1585
|
+
declare function useSupplySwap(handler: PositionSwapHandler): UseAsyncTask<SupplySwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1586
|
+
|
|
1587
|
+
type UseSupplySwapQuoteArgs = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1554
1588
|
/**
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
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>;
|
|
1768
|
+
/**
|
|
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).
|
|
1772
|
+
*
|
|
1773
|
+
* ```tsx
|
|
1774
|
+
* const { data, error, loading } = useSwapStatus({
|
|
1775
|
+
* id: swapReceipt.id,
|
|
1776
|
+
* });
|
|
1777
|
+
* ```
|
|
1778
|
+
*/
|
|
1779
|
+
declare function useSwapStatus(args: UseSwapStatusArgs): ReadResult<SwapStatus>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1782
|
+
*
|
|
1783
|
+
* Pausable loading state mode.
|
|
1784
|
+
*
|
|
1785
|
+
* ```tsx
|
|
1786
|
+
* const { data, error, loading, paused } = useSwapStatus({
|
|
1787
|
+
* id: swapReceipt.id,
|
|
1788
|
+
* pause: shouldPause,
|
|
1789
|
+
* });
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
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>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Orchestrate the token swap execution plan.
|
|
1557
1799
|
*
|
|
1558
1800
|
* ```tsx
|
|
1559
1801
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1560
|
-
* const [
|
|
1802
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1561
1803
|
*
|
|
1562
|
-
* const [
|
|
1804
|
+
* const [swap, { loading, error }] = useTokenSwap((plan) => {
|
|
1563
1805
|
* switch (plan.__typename) {
|
|
1564
|
-
* case '
|
|
1565
|
-
*
|
|
1806
|
+
* case 'Erc20Approval':
|
|
1807
|
+
* if (plan.bySignature) {
|
|
1808
|
+
* return signTypedData(plan.bySignature);
|
|
1809
|
+
* }
|
|
1810
|
+
* return sendTransaction(plan.byTransaction);
|
|
1811
|
+
*
|
|
1812
|
+
* case 'SwapTransactionRequest':
|
|
1813
|
+
* return sendTransaction(plan.transaction);
|
|
1566
1814
|
*
|
|
1567
|
-
* case '
|
|
1568
|
-
* return
|
|
1815
|
+
* case 'SwapTypedData':
|
|
1816
|
+
* return signTypedData(plan);
|
|
1569
1817
|
* }
|
|
1570
1818
|
* });
|
|
1571
1819
|
*
|
|
1572
|
-
* const result = await
|
|
1573
|
-
*
|
|
1820
|
+
* const result = await swap({
|
|
1821
|
+
* fromQuote: {
|
|
1822
|
+
* quoteId: quote.quoteId,
|
|
1823
|
+
* },
|
|
1574
1824
|
* });
|
|
1575
1825
|
*
|
|
1576
1826
|
* if (result.isErr()) {
|
|
@@ -1578,66 +1828,402 @@ type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | Time
|
|
|
1578
1828
|
* return;
|
|
1579
1829
|
* }
|
|
1580
1830
|
*
|
|
1581
|
-
* // result.value:
|
|
1582
|
-
* console.log('Swap cancelled:', result.value);
|
|
1831
|
+
* // result.value: SwapReceipt
|
|
1583
1832
|
* ```
|
|
1584
1833
|
*/
|
|
1585
|
-
declare function
|
|
1834
|
+
declare function useTokenSwap(handler: TokenSwapHandler): UseAsyncTask<UseTokenSwapRequest, SwapReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1586
1835
|
|
|
1836
|
+
type UseTokenSwapQuoteArgs = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1587
1837
|
/**
|
|
1588
|
-
*
|
|
1838
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1839
|
+
*
|
|
1840
|
+
* This signature supports React Suspense:
|
|
1841
|
+
*
|
|
1842
|
+
* ```tsx
|
|
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),
|
|
1852
|
+
* suspense: true,
|
|
1853
|
+
* });
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1857
|
+
/**
|
|
1858
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1859
|
+
*
|
|
1860
|
+
* Pausable suspense mode.
|
|
1861
|
+
*
|
|
1862
|
+
* ```tsx
|
|
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
|
+
* },
|
|
1872
|
+
* suspense: true,
|
|
1873
|
+
* pause: true,
|
|
1874
|
+
* });
|
|
1875
|
+
* ```
|
|
1876
|
+
*/
|
|
1877
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1878
|
+
/**
|
|
1879
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1880
|
+
*
|
|
1881
|
+
* ```tsx
|
|
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
|
+
* },
|
|
1891
|
+
* });
|
|
1892
|
+
* ```
|
|
1893
|
+
*/
|
|
1894
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1895
|
+
/**
|
|
1896
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1897
|
+
*
|
|
1898
|
+
* Pausable loading state mode.
|
|
1899
|
+
*
|
|
1900
|
+
* ```tsx
|
|
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
|
+
* },
|
|
1910
|
+
* pause: true,
|
|
1911
|
+
* });
|
|
1912
|
+
* ```
|
|
1913
|
+
*/
|
|
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).
|
|
1589
1922
|
*
|
|
1590
1923
|
* ```ts
|
|
1591
|
-
* const [
|
|
1592
|
-
*
|
|
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>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Fetch the user's swap history for a specific chain.
|
|
1950
|
+
*
|
|
1951
|
+
* This signature supports React Suspense:
|
|
1952
|
+
*
|
|
1953
|
+
* ```tsx
|
|
1954
|
+
* const { data } = useUserSwaps({
|
|
1955
|
+
* chainId: chainId(1),
|
|
1956
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1957
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1958
|
+
* suspense: true,
|
|
1959
|
+
* });
|
|
1960
|
+
* ```
|
|
1961
|
+
*/
|
|
1962
|
+
declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseResult<PaginatedUserSwapsResult>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Fetch the user's swap history for a specific chain.
|
|
1965
|
+
*
|
|
1966
|
+
* Pausable suspense mode.
|
|
1967
|
+
*
|
|
1968
|
+
* ```tsx
|
|
1969
|
+
* const { data } = useUserSwaps({
|
|
1970
|
+
* chainId: chainId(1),
|
|
1971
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1972
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1973
|
+
* suspense: true,
|
|
1974
|
+
* pause: true,
|
|
1975
|
+
* });
|
|
1976
|
+
* ```
|
|
1977
|
+
*/
|
|
1978
|
+
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs> & Suspendable): PausableSuspenseResult<PaginatedUserSwapsResult>;
|
|
1979
|
+
/**
|
|
1980
|
+
* Fetch the user's swap history for a specific chain.
|
|
1981
|
+
*
|
|
1982
|
+
* ```tsx
|
|
1983
|
+
* const { data, error, loading } = useUserSwaps({
|
|
1984
|
+
* chainId: chainId(1),
|
|
1985
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1986
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1987
|
+
* });
|
|
1988
|
+
* ```
|
|
1989
|
+
*/
|
|
1990
|
+
declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserSwapsResult>;
|
|
1991
|
+
/**
|
|
1992
|
+
* Fetch the user's swap history for a specific chain.
|
|
1993
|
+
*
|
|
1994
|
+
* Pausable loading state mode.
|
|
1995
|
+
*
|
|
1996
|
+
* ```tsx
|
|
1997
|
+
* const { data, error, loading, paused } = useUserSwaps({
|
|
1998
|
+
* chainId: chainId(1),
|
|
1999
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2000
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
2001
|
+
* pause: true,
|
|
2002
|
+
* });
|
|
2003
|
+
* ```
|
|
2004
|
+
*/
|
|
2005
|
+
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs>): PausableReadResult<PaginatedUserSwapsResult>;
|
|
2006
|
+
|
|
2007
|
+
type UseWithdrawSwapRequest = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
2008
|
+
/**
|
|
2009
|
+
* Orchestrate the withdraw swap execution plan.
|
|
2010
|
+
*
|
|
2011
|
+
* ```tsx
|
|
2012
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
2013
|
+
*
|
|
2014
|
+
* const [withdrawSwap, { loading, error }] = useWithdrawSwap((plan) => {
|
|
1593
2015
|
* switch (plan.__typename) {
|
|
1594
|
-
* case '
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
2016
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
2017
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
2018
|
+
* return signTypedData(plan.bySignature);
|
|
2019
|
+
*
|
|
2020
|
+
* case 'SwapTypedData':
|
|
2021
|
+
* return signTypedData(plan);
|
|
1599
2022
|
* }
|
|
1600
2023
|
* });
|
|
1601
2024
|
*
|
|
2025
|
+
* const result = await withdrawSwap({
|
|
2026
|
+
* market: {
|
|
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,
|
|
2107
|
+
* amount: bigDecimal('1000'),
|
|
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
|
+
*
|
|
1602
2125
|
* // …
|
|
1603
2126
|
*
|
|
1604
|
-
* const result = await
|
|
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.
|
|
1605
2164
|
*
|
|
1606
|
-
*
|
|
1607
|
-
* switch (result.error.name) {
|
|
1608
|
-
* case 'CancelError':
|
|
1609
|
-
* // The user cancelled the operation
|
|
1610
|
-
* return;
|
|
2165
|
+
* Pausable suspense mode.
|
|
1611
2166
|
*
|
|
1612
|
-
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
2167
|
+
* ```tsx
|
|
2168
|
+
* const { data } = useActivities({
|
|
2169
|
+
* query: {
|
|
2170
|
+
* chainId: chainId(1),
|
|
2171
|
+
* },
|
|
2172
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2173
|
+
* suspense: true,
|
|
2174
|
+
* pause: true,
|
|
2175
|
+
* });
|
|
1615
2176
|
*
|
|
1616
|
-
*
|
|
1617
|
-
*
|
|
1618
|
-
|
|
2177
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2178
|
+
* ```
|
|
2179
|
+
*/
|
|
2180
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Fetch paginated list of activities.
|
|
1619
2183
|
*
|
|
1620
|
-
*
|
|
1621
|
-
*
|
|
1622
|
-
*
|
|
2184
|
+
* ```tsx
|
|
2185
|
+
* const { data, error, loading } = useActivities({
|
|
2186
|
+
* query: {
|
|
2187
|
+
* chainId: chainId(1),
|
|
2188
|
+
* },
|
|
2189
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2190
|
+
* });
|
|
2191
|
+
* ```
|
|
2192
|
+
*/
|
|
2193
|
+
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
2194
|
+
/**
|
|
2195
|
+
* Fetch paginated list of activities.
|
|
1623
2196
|
*
|
|
1624
|
-
*
|
|
1625
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1626
|
-
* break;
|
|
2197
|
+
* Pausable loading state mode.
|
|
1627
2198
|
*
|
|
1628
|
-
*
|
|
1629
|
-
*
|
|
1630
|
-
*
|
|
1631
|
-
*
|
|
1632
|
-
*
|
|
1633
|
-
*
|
|
2199
|
+
* ```tsx
|
|
2200
|
+
* const { data, error, loading } = useActivities({
|
|
2201
|
+
* query: {
|
|
2202
|
+
* chainId: chainId(1),
|
|
2203
|
+
* },
|
|
2204
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2205
|
+
* pause: true,
|
|
2206
|
+
* });
|
|
1634
2207
|
*
|
|
1635
|
-
*
|
|
2208
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2209
|
+
* // error: UnexpectedError | undefined
|
|
2210
|
+
* // loading: boolean | undefined
|
|
1636
2211
|
* ```
|
|
2212
|
+
*/
|
|
2213
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2214
|
+
/**
|
|
2215
|
+
* Low-level hook to execute a {@link activities} action directly.
|
|
1637
2216
|
*
|
|
1638
|
-
* @
|
|
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).
|
|
2221
|
+
*
|
|
2222
|
+
* @param options - The query options.
|
|
2223
|
+
* @returns The user history.
|
|
1639
2224
|
*/
|
|
1640
|
-
declare function
|
|
2225
|
+
declare function useActivitiesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError>;
|
|
2226
|
+
|
|
1641
2227
|
/**
|
|
1642
2228
|
* A hook that provides a way to borrow assets from an Aave reserve.
|
|
1643
2229
|
*
|
|
@@ -1647,7 +2233,7 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1647
2233
|
* switch (plan.__typename) {
|
|
1648
2234
|
* case 'TransactionRequest':
|
|
1649
2235
|
* return sendTransaction(plan);
|
|
1650
|
-
*
|
|
2236
|
+
*
|
|
1651
2237
|
* case 'PreContractActionRequired':
|
|
1652
2238
|
* return sendTransaction(plan.transaction);
|
|
1653
2239
|
* }
|
|
@@ -1686,30 +2272,29 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1686
2272
|
* return;
|
|
1687
2273
|
* }
|
|
1688
2274
|
*
|
|
1689
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2275
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1690
2276
|
* ```
|
|
1691
2277
|
*
|
|
1692
2278
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1693
2279
|
*/
|
|
1694
|
-
declare function useBorrow(handler:
|
|
2280
|
+
declare function useBorrow(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<BorrowRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2281
|
+
|
|
1695
2282
|
/**
|
|
1696
|
-
* A hook that provides a way to
|
|
2283
|
+
* A hook that provides a way to claim rewards.
|
|
1697
2284
|
*
|
|
1698
2285
|
* ```ts
|
|
1699
2286
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1700
|
-
* const [
|
|
1701
|
-
*
|
|
1702
|
-
* case 'TransactionRequest':
|
|
1703
|
-
* return sendTransaction(plan);
|
|
1704
|
-
* case 'Erc20ApprovalRequired':
|
|
1705
|
-
* case 'PreContractActionRequired':
|
|
1706
|
-
* return sendTransaction(plan.transaction);
|
|
1707
|
-
* }
|
|
2287
|
+
* const [claim, { loading, error }] = useClaimRewards((transaction, { cancel }) => {
|
|
2288
|
+
* return sendTransaction(transaction);
|
|
1708
2289
|
* });
|
|
1709
2290
|
*
|
|
1710
2291
|
* // …
|
|
1711
2292
|
*
|
|
1712
|
-
* const result = await
|
|
2293
|
+
* const result = await claim({
|
|
2294
|
+
* ids: [rewardId('abc123')],
|
|
2295
|
+
* chainId: chainId(1),
|
|
2296
|
+
* user: evmAddress('0x9abc…'),
|
|
2297
|
+
* });
|
|
1713
2298
|
*
|
|
1714
2299
|
* if (result.isErr()) {
|
|
1715
2300
|
* switch (result.error.name) {
|
|
@@ -1729,10 +2314,6 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1729
2314
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1730
2315
|
* break;
|
|
1731
2316
|
*
|
|
1732
|
-
* case 'ValidationError':
|
|
1733
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1734
|
-
* break;
|
|
1735
|
-
*
|
|
1736
2317
|
* case 'UnexpectedError':
|
|
1737
2318
|
* console.error(result.error.message);
|
|
1738
2319
|
* break;
|
|
@@ -1740,22 +2321,26 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1740
2321
|
* return;
|
|
1741
2322
|
* }
|
|
1742
2323
|
*
|
|
1743
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2324
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1744
2325
|
* ```
|
|
1745
2326
|
*
|
|
1746
|
-
* @param handler - The handler that will be used to handle the
|
|
2327
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1747
2328
|
*/
|
|
1748
|
-
declare function
|
|
2329
|
+
declare function useClaimRewards(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<ClaimRewardsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2330
|
+
|
|
1749
2331
|
/**
|
|
1750
|
-
* A hook that provides a way to
|
|
2332
|
+
* A hook that provides a way to liquidate a user's position.
|
|
1751
2333
|
*
|
|
1752
2334
|
* ```ts
|
|
1753
2335
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1754
|
-
* const [
|
|
2336
|
+
* const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {
|
|
1755
2337
|
* switch (plan.__typename) {
|
|
1756
2338
|
* case 'TransactionRequest':
|
|
1757
2339
|
* return sendTransaction(plan);
|
|
1758
|
-
*
|
|
2340
|
+
*
|
|
2341
|
+
* case 'Erc20Approval':
|
|
2342
|
+
* return sendTransaction(plan.byTransaction);
|
|
2343
|
+
*
|
|
1759
2344
|
* case 'PreContractActionRequired':
|
|
1760
2345
|
* return sendTransaction(plan.transaction);
|
|
1761
2346
|
* }
|
|
@@ -1763,7 +2348,13 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1763
2348
|
*
|
|
1764
2349
|
* // …
|
|
1765
2350
|
*
|
|
1766
|
-
* 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
|
+
* });
|
|
1767
2358
|
*
|
|
1768
2359
|
* if (result.isErr()) {
|
|
1769
2360
|
* switch (result.error.name) {
|
|
@@ -1794,120 +2385,153 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1794
2385
|
* return;
|
|
1795
2386
|
* }
|
|
1796
2387
|
*
|
|
1797
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2388
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1798
2389
|
* ```
|
|
1799
2390
|
*
|
|
1800
2391
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1801
2392
|
*/
|
|
1802
|
-
declare function
|
|
2393
|
+
declare function useLiquidatePosition(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, PendingTransaction | Signature>): UseAsyncTask<LiquidatePositionRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2394
|
+
|
|
1803
2395
|
/**
|
|
1804
|
-
*
|
|
2396
|
+
* Preview the impact of a potential action on a user's position.
|
|
1805
2397
|
*
|
|
1806
|
-
* ```
|
|
1807
|
-
* const [
|
|
1808
|
-
*
|
|
2398
|
+
* ```tsx
|
|
2399
|
+
* const [getPreview, previewing] = usePreviewAction();
|
|
2400
|
+
*
|
|
2401
|
+
* const loading = previewing.loading;
|
|
2402
|
+
* const error = previewing.error;
|
|
1809
2403
|
*
|
|
1810
2404
|
* // …
|
|
1811
2405
|
*
|
|
1812
|
-
* const result = await
|
|
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
|
+
* });
|
|
1813
2419
|
*
|
|
1814
2420
|
* if (result.isErr()) {
|
|
1815
|
-
*
|
|
1816
|
-
* case 'CancelError':
|
|
1817
|
-
* // The user cancelled the operation
|
|
1818
|
-
* return;
|
|
1819
|
-
*
|
|
1820
|
-
* case 'SigningError':
|
|
1821
|
-
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1822
|
-
* break;
|
|
1823
|
-
*
|
|
1824
|
-
* case 'TimeoutError':
|
|
1825
|
-
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1826
|
-
* break;
|
|
1827
|
-
*
|
|
1828
|
-
* case 'TransactionError':
|
|
1829
|
-
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1830
|
-
* break;
|
|
1831
|
-
*
|
|
1832
|
-
* case 'UnexpectedError':
|
|
1833
|
-
* console.error(result.error.message);
|
|
1834
|
-
* break;
|
|
1835
|
-
* }
|
|
2421
|
+
* console.error(result.error);
|
|
1836
2422
|
* return;
|
|
1837
2423
|
* }
|
|
1838
2424
|
*
|
|
1839
|
-
* console.log('
|
|
2425
|
+
* console.log('Preview result:', result.value);
|
|
1840
2426
|
* ```
|
|
1841
|
-
*
|
|
1842
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1843
2427
|
*/
|
|
1844
|
-
declare function
|
|
2428
|
+
declare function usePreviewAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError>;
|
|
2429
|
+
type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
|
|
1845
2430
|
/**
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
* ```ts
|
|
1849
|
-
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1850
|
-
* const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {
|
|
1851
|
-
* return sendTransaction(transaction);
|
|
1852
|
-
* });
|
|
2431
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1853
2432
|
*
|
|
1854
|
-
*
|
|
2433
|
+
* This signature supports React Suspense:
|
|
1855
2434
|
*
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1858
|
-
*
|
|
1859
|
-
*
|
|
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,
|
|
1860
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.
|
|
1861
2456
|
*
|
|
1862
|
-
*
|
|
1863
|
-
* switch (result.error.name) {
|
|
1864
|
-
* case 'CancelError':
|
|
1865
|
-
* // The user cancelled the operation
|
|
1866
|
-
* return;
|
|
1867
|
-
*
|
|
1868
|
-
* case 'SigningError':
|
|
1869
|
-
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1870
|
-
* break;
|
|
2457
|
+
* Pausable suspense mode.
|
|
1871
2458
|
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1874
|
-
*
|
|
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.
|
|
1875
2481
|
*
|
|
1876
|
-
*
|
|
1877
|
-
*
|
|
1878
|
-
*
|
|
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.
|
|
1879
2502
|
*
|
|
1880
|
-
*
|
|
1881
|
-
* console.error(result.error.message);
|
|
1882
|
-
* break;
|
|
1883
|
-
* }
|
|
1884
|
-
* return;
|
|
1885
|
-
* }
|
|
2503
|
+
* Pausable loading state mode.
|
|
1886
2504
|
*
|
|
1887
|
-
*
|
|
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
|
+
* });
|
|
1888
2521
|
* ```
|
|
1889
|
-
*
|
|
1890
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1891
2522
|
*/
|
|
1892
|
-
declare function
|
|
2523
|
+
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2524
|
+
|
|
1893
2525
|
/**
|
|
1894
|
-
*
|
|
2526
|
+
* A hook that provides a way to renounce a position manager of a user for a specific spoke.
|
|
1895
2527
|
*
|
|
1896
2528
|
* ```ts
|
|
1897
2529
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1898
|
-
* const [
|
|
1899
|
-
* return sendTransaction(transaction);
|
|
1900
|
-
* });
|
|
2530
|
+
* const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);
|
|
1901
2531
|
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
* reserve: reserve.id,
|
|
1906
|
-
* enableCollateral: true
|
|
1907
|
-
* }
|
|
1908
|
-
* ],
|
|
1909
|
-
* sender: evmAddress('0x456...')
|
|
1910
|
-
* });
|
|
2532
|
+
* // …
|
|
2533
|
+
*
|
|
2534
|
+
* const result = await renounceSpokeUserPositionManager({ ... });
|
|
1911
2535
|
*
|
|
1912
2536
|
* if (result.isErr()) {
|
|
1913
2537
|
* switch (result.error.name) {
|
|
@@ -1934,22 +2558,26 @@ declare function useUpdateUserPositionConditions(handler: TransactionHandler): U
|
|
|
1934
2558
|
* return;
|
|
1935
2559
|
* }
|
|
1936
2560
|
*
|
|
1937
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2561
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1938
2562
|
* ```
|
|
1939
2563
|
*
|
|
1940
2564
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1941
2565
|
*/
|
|
1942
|
-
declare function
|
|
2566
|
+
declare function useRenounceSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<RenounceSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2567
|
+
|
|
1943
2568
|
/**
|
|
1944
|
-
* A hook that provides a way to
|
|
2569
|
+
* A hook that provides a way to repay borrowed assets to an Aave reserve.
|
|
1945
2570
|
*
|
|
1946
2571
|
* ```ts
|
|
1947
2572
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1948
|
-
* const [
|
|
2573
|
+
* const [repay, { loading, error }] = useRepay((plan, { cancel }) => {
|
|
1949
2574
|
* switch (plan.__typename) {
|
|
1950
2575
|
* case 'TransactionRequest':
|
|
1951
2576
|
* return sendTransaction(plan);
|
|
1952
|
-
*
|
|
2577
|
+
*
|
|
2578
|
+
* case 'Erc20Approval':
|
|
2579
|
+
* return sendTransaction(plan.byTransaction);
|
|
2580
|
+
*
|
|
1953
2581
|
* case 'PreContractActionRequired':
|
|
1954
2582
|
* return sendTransaction(plan.transaction);
|
|
1955
2583
|
* }
|
|
@@ -1957,13 +2585,7 @@ declare function useSetUserSuppliesAsCollateral(handler: TransactionHandler): Us
|
|
|
1957
2585
|
*
|
|
1958
2586
|
* // …
|
|
1959
2587
|
*
|
|
1960
|
-
* const result = await
|
|
1961
|
-
* collateral: reserveId('SGVsbG8h'),
|
|
1962
|
-
* debt: reserveId('Q2lhbyE= '),
|
|
1963
|
-
* amount: amount,
|
|
1964
|
-
* liquidator: liquidator,
|
|
1965
|
-
* borrower: borrower,
|
|
1966
|
-
* });
|
|
2588
|
+
* const result = await repay({ ... });
|
|
1967
2589
|
*
|
|
1968
2590
|
* if (result.isErr()) {
|
|
1969
2591
|
* switch (result.error.name) {
|
|
@@ -1994,12 +2616,13 @@ declare function useSetUserSuppliesAsCollateral(handler: TransactionHandler): Us
|
|
|
1994
2616
|
* return;
|
|
1995
2617
|
* }
|
|
1996
2618
|
*
|
|
1997
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2619
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1998
2620
|
* ```
|
|
1999
2621
|
*
|
|
2000
2622
|
* @param handler - The handler that will be used to handle the transactions.
|
|
2001
2623
|
*/
|
|
2002
|
-
declare function
|
|
2624
|
+
declare function useRepay(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<RepayRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2625
|
+
|
|
2003
2626
|
/**
|
|
2004
2627
|
* A hook that provides a way to set or remove a position manager for a user on a specific spoke.
|
|
2005
2628
|
*
|
|
@@ -2056,224 +2679,224 @@ declare function useLiquidatePosition(handler: TransactionHandler): UseAsyncTask
|
|
|
2056
2679
|
* return;
|
|
2057
2680
|
* }
|
|
2058
2681
|
*
|
|
2059
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2682
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2060
2683
|
* ```
|
|
2061
2684
|
*
|
|
2062
2685
|
* @param handler - The handler that will be used to handle the transaction.
|
|
2063
2686
|
*/
|
|
2064
|
-
declare function useSetSpokeUserPositionManager(handler:
|
|
2687
|
+
declare function useSetSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2688
|
+
|
|
2065
2689
|
/**
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2068
|
-
* ```tsx
|
|
2069
|
-
* const [getPreview, previewing] = usePreviewAction();
|
|
2070
|
-
*
|
|
2071
|
-
* const loading = previewing.loading;
|
|
2072
|
-
* const error = previewing.error;
|
|
2690
|
+
* Hook for updating the collateral status of user's supplies.
|
|
2073
2691
|
*
|
|
2074
|
-
*
|
|
2692
|
+
* ```ts
|
|
2693
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2694
|
+
* const [setUserSuppliesAsCollateral, { loading, error }] = useSetUserSuppliesAsCollateral((transaction, { cancel }) => {
|
|
2695
|
+
* return sendTransaction(transaction);
|
|
2696
|
+
* });
|
|
2075
2697
|
*
|
|
2076
|
-
* const result = await
|
|
2077
|
-
*
|
|
2078
|
-
*
|
|
2079
|
-
* reserve:
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2082
|
-
*
|
|
2083
|
-
*
|
|
2084
|
-
* },
|
|
2085
|
-
* sender: evmAddress('0x9abc…'),
|
|
2086
|
-
* },
|
|
2087
|
-
* },
|
|
2698
|
+
* const result = await setUserSuppliesAsCollateral({
|
|
2699
|
+
* changes: [
|
|
2700
|
+
* {
|
|
2701
|
+
* reserve: reserve.id,
|
|
2702
|
+
* enableCollateral: true
|
|
2703
|
+
* }
|
|
2704
|
+
* ],
|
|
2705
|
+
* sender: evmAddress('0x456...')
|
|
2088
2706
|
* });
|
|
2089
2707
|
*
|
|
2090
2708
|
* if (result.isErr()) {
|
|
2091
|
-
*
|
|
2709
|
+
* switch (result.error.name) {
|
|
2710
|
+
* case 'CancelError':
|
|
2711
|
+
* // The user cancelled the operation
|
|
2712
|
+
* return;
|
|
2713
|
+
*
|
|
2714
|
+
* case 'SigningError':
|
|
2715
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2716
|
+
* break;
|
|
2717
|
+
*
|
|
2718
|
+
* case 'TimeoutError':
|
|
2719
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2720
|
+
* break;
|
|
2721
|
+
*
|
|
2722
|
+
* case 'TransactionError':
|
|
2723
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2724
|
+
* break;
|
|
2725
|
+
*
|
|
2726
|
+
* case 'UnexpectedError':
|
|
2727
|
+
* console.error(result.error.message);
|
|
2728
|
+
* break;
|
|
2729
|
+
* }
|
|
2092
2730
|
* return;
|
|
2093
2731
|
* }
|
|
2094
2732
|
*
|
|
2095
|
-
* console.log('
|
|
2733
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2096
2734
|
* ```
|
|
2735
|
+
*
|
|
2736
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2097
2737
|
*/
|
|
2098
|
-
declare function
|
|
2099
|
-
|
|
2738
|
+
declare function useSetUserSuppliesAsCollateral(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetUserSuppliesAsCollateralRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2739
|
+
|
|
2100
2740
|
/**
|
|
2101
|
-
*
|
|
2741
|
+
* A hook that provides a way to supply assets to an Aave reserve.
|
|
2102
2742
|
*
|
|
2103
|
-
*
|
|
2743
|
+
* ```ts
|
|
2744
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2745
|
+
* const [supply, { loading, error }] = useSupply((plan, { cancel }) => {
|
|
2746
|
+
* switch (plan.__typename) {
|
|
2747
|
+
* case 'TransactionRequest':
|
|
2748
|
+
* return sendTransaction(plan);
|
|
2104
2749
|
*
|
|
2105
|
-
*
|
|
2106
|
-
*
|
|
2107
|
-
*
|
|
2108
|
-
*
|
|
2109
|
-
*
|
|
2110
|
-
*
|
|
2111
|
-
* erc20: {
|
|
2112
|
-
* currency: evmAddress('0x5678…'),
|
|
2113
|
-
* value: '1000',
|
|
2114
|
-
* },
|
|
2115
|
-
* },
|
|
2116
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2117
|
-
* },
|
|
2118
|
-
* },
|
|
2119
|
-
* suspense: true,
|
|
2750
|
+
* case 'Erc20Approval':
|
|
2751
|
+
* return sendTransaction(plan.byTransaction);
|
|
2752
|
+
*
|
|
2753
|
+
* case 'PreContractActionRequired':
|
|
2754
|
+
* return sendTransaction(plan.transaction);
|
|
2755
|
+
* }
|
|
2120
2756
|
* });
|
|
2121
|
-
* ```
|
|
2122
|
-
*/
|
|
2123
|
-
declare function usePreview(args: UsePreviewArgs & Suspendable): SuspenseResult<PreviewUserPosition>;
|
|
2124
|
-
/**
|
|
2125
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2126
2757
|
*
|
|
2127
|
-
*
|
|
2758
|
+
* // …
|
|
2128
2759
|
*
|
|
2129
|
-
*
|
|
2130
|
-
* const { data } = usePreview({
|
|
2131
|
-
* action: {
|
|
2132
|
-
* supply: {
|
|
2133
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
2134
|
-
* amount: {
|
|
2135
|
-
* erc20: {
|
|
2136
|
-
* currency: evmAddress('0x5678…'),
|
|
2137
|
-
* value: '1000',
|
|
2138
|
-
* },
|
|
2139
|
-
* },
|
|
2140
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2141
|
-
* },
|
|
2142
|
-
* },
|
|
2143
|
-
* suspense: true,
|
|
2144
|
-
* pause: true,
|
|
2145
|
-
* });
|
|
2146
|
-
* ```
|
|
2147
|
-
*/
|
|
2148
|
-
declare function usePreview(args: Pausable<UsePreviewArgs> & Suspendable): PausableSuspenseResult<PreviewUserPosition>;
|
|
2149
|
-
/**
|
|
2150
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2760
|
+
* const result = await supply({ ... });
|
|
2151
2761
|
*
|
|
2152
|
-
*
|
|
2153
|
-
*
|
|
2154
|
-
*
|
|
2155
|
-
*
|
|
2156
|
-
*
|
|
2157
|
-
* amount: {
|
|
2158
|
-
* erc20: {
|
|
2159
|
-
* currency: evmAddress('0x5678…'),
|
|
2160
|
-
* value: '1000',
|
|
2161
|
-
* },
|
|
2162
|
-
* },
|
|
2163
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2164
|
-
* },
|
|
2165
|
-
* },
|
|
2166
|
-
* });
|
|
2167
|
-
* ```
|
|
2168
|
-
*/
|
|
2169
|
-
declare function usePreview(args: UsePreviewArgs): ReadResult<PreviewUserPosition>;
|
|
2170
|
-
/**
|
|
2171
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2762
|
+
* if (result.isErr()) {
|
|
2763
|
+
* switch (result.error.name) {
|
|
2764
|
+
* case 'CancelError':
|
|
2765
|
+
* // The user cancelled the operation
|
|
2766
|
+
* return;
|
|
2172
2767
|
*
|
|
2173
|
-
*
|
|
2768
|
+
* case 'SigningError':
|
|
2769
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2770
|
+
* break;
|
|
2174
2771
|
*
|
|
2175
|
-
*
|
|
2176
|
-
*
|
|
2177
|
-
*
|
|
2178
|
-
* supply: {
|
|
2179
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
2180
|
-
* amount: {
|
|
2181
|
-
* erc20: {
|
|
2182
|
-
* currency: evmAddress('0x5678…'),
|
|
2183
|
-
* value: '1000',
|
|
2184
|
-
* },
|
|
2185
|
-
* },
|
|
2186
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2187
|
-
* },
|
|
2188
|
-
* },
|
|
2189
|
-
* pause: true,
|
|
2190
|
-
* });
|
|
2191
|
-
* ```
|
|
2192
|
-
*/
|
|
2193
|
-
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2194
|
-
type UseActivitiesArgs = Prettify<ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2195
|
-
/**
|
|
2196
|
-
* Fetch paginated list of activities.
|
|
2772
|
+
* case 'TimeoutError':
|
|
2773
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2774
|
+
* break;
|
|
2197
2775
|
*
|
|
2198
|
-
*
|
|
2776
|
+
* case 'TransactionError':
|
|
2777
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2778
|
+
* break;
|
|
2199
2779
|
*
|
|
2200
|
-
*
|
|
2201
|
-
*
|
|
2202
|
-
*
|
|
2203
|
-
*
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2206
|
-
*
|
|
2207
|
-
*
|
|
2780
|
+
* case 'ValidationError':
|
|
2781
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2782
|
+
* break;
|
|
2783
|
+
*
|
|
2784
|
+
* case 'UnexpectedError':
|
|
2785
|
+
* console.error(result.error.message);
|
|
2786
|
+
* break;
|
|
2787
|
+
* }
|
|
2788
|
+
* return;
|
|
2789
|
+
* }
|
|
2208
2790
|
*
|
|
2209
|
-
*
|
|
2791
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2210
2792
|
* ```
|
|
2793
|
+
*
|
|
2794
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
2211
2795
|
*/
|
|
2212
|
-
declare function
|
|
2796
|
+
declare function useSupply(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<SupplyRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2797
|
+
|
|
2213
2798
|
/**
|
|
2214
|
-
*
|
|
2215
|
-
*
|
|
2216
|
-
* Pausable suspense mode.
|
|
2799
|
+
* Hook for updating user position conditions (dynamic config and/or risk premium).
|
|
2217
2800
|
*
|
|
2218
|
-
* ```
|
|
2219
|
-
* const
|
|
2220
|
-
*
|
|
2221
|
-
*
|
|
2222
|
-
* },
|
|
2223
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2224
|
-
* suspense: true,
|
|
2225
|
-
* pause: true,
|
|
2801
|
+
* ```ts
|
|
2802
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2803
|
+
* const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {
|
|
2804
|
+
* return sendTransaction(transaction);
|
|
2226
2805
|
* });
|
|
2227
2806
|
*
|
|
2228
|
-
* //
|
|
2229
|
-
* ```
|
|
2230
|
-
*/
|
|
2231
|
-
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2232
|
-
/**
|
|
2233
|
-
* Fetch paginated list of activities.
|
|
2807
|
+
* // …
|
|
2234
2808
|
*
|
|
2235
|
-
*
|
|
2236
|
-
*
|
|
2237
|
-
*
|
|
2238
|
-
* chainId: chainId(1),
|
|
2239
|
-
* },
|
|
2240
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2809
|
+
* const result = await update({
|
|
2810
|
+
* userPositionId: userPosition.id,
|
|
2811
|
+
* update: UserPositionConditionsUpdate.AllDynamicConfig,
|
|
2241
2812
|
* });
|
|
2813
|
+
*
|
|
2814
|
+
* if (result.isErr()) {
|
|
2815
|
+
* switch (result.error.name) {
|
|
2816
|
+
* case 'CancelError':
|
|
2817
|
+
* // The user cancelled the operation
|
|
2818
|
+
* return;
|
|
2819
|
+
*
|
|
2820
|
+
* case 'SigningError':
|
|
2821
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2822
|
+
* break;
|
|
2823
|
+
*
|
|
2824
|
+
* case 'TimeoutError':
|
|
2825
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2826
|
+
* break;
|
|
2827
|
+
*
|
|
2828
|
+
* case 'TransactionError':
|
|
2829
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2830
|
+
* break;
|
|
2831
|
+
*
|
|
2832
|
+
* case 'UnexpectedError':
|
|
2833
|
+
* console.error(result.error.message);
|
|
2834
|
+
* break;
|
|
2835
|
+
* }
|
|
2836
|
+
* return;
|
|
2837
|
+
* }
|
|
2838
|
+
*
|
|
2839
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2242
2840
|
* ```
|
|
2841
|
+
*
|
|
2842
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2243
2843
|
*/
|
|
2244
|
-
declare function
|
|
2844
|
+
declare function useUpdateUserPositionConditions(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<UpdateUserPositionConditionsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2845
|
+
|
|
2245
2846
|
/**
|
|
2246
|
-
*
|
|
2847
|
+
* A hook that provides a way to withdraw supplied assets from an Aave reserve.
|
|
2247
2848
|
*
|
|
2248
|
-
*
|
|
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);
|
|
2249
2855
|
*
|
|
2250
|
-
*
|
|
2251
|
-
*
|
|
2252
|
-
*
|
|
2253
|
-
* chainId: chainId(1),
|
|
2254
|
-
* },
|
|
2255
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2256
|
-
* pause: true,
|
|
2856
|
+
* case 'PreContractActionRequired':
|
|
2857
|
+
* return sendTransaction(plan.transaction);
|
|
2858
|
+
* }
|
|
2257
2859
|
* });
|
|
2258
2860
|
*
|
|
2259
|
-
* //
|
|
2260
|
-
* // error: UnexpectedError | undefined
|
|
2261
|
-
* // loading: boolean | undefined
|
|
2262
|
-
* ```
|
|
2263
|
-
*/
|
|
2264
|
-
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2265
|
-
/**
|
|
2266
|
-
* Low-level hook to execute a {@link activities} action directly.
|
|
2861
|
+
* // …
|
|
2267
2862
|
*
|
|
2268
|
-
*
|
|
2269
|
-
* @remarks
|
|
2270
|
-
* This hook does not actively watch for updates. Use it to fetch activities on demand
|
|
2271
|
-
* (e.g., in an event handler when paginating or refining filters).
|
|
2863
|
+
* const result = await withdraw({ ... });
|
|
2272
2864
|
*
|
|
2273
|
-
*
|
|
2274
|
-
*
|
|
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.
|
|
2275
2898
|
*/
|
|
2276
|
-
declare function
|
|
2899
|
+
declare function useWithdraw(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<WithdrawRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2277
2900
|
|
|
2278
2901
|
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2279
2902
|
/**
|
|
@@ -2388,7 +3011,7 @@ declare function useUserSupplies(args: Pausable<UseUserSuppliesArgs>): PausableR
|
|
|
2388
3011
|
* }
|
|
2389
3012
|
* ```
|
|
2390
3013
|
*/
|
|
2391
|
-
declare function useUserSuppliesAction(options?:
|
|
3014
|
+
declare function useUserSuppliesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError>;
|
|
2392
3015
|
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2393
3016
|
/**
|
|
2394
3017
|
* Fetch all user borrow positions.
|
|
@@ -2495,7 +3118,7 @@ declare function useUserBorrows(args: Pausable<UseUserBorrowsArgs>): PausableRea
|
|
|
2495
3118
|
* }
|
|
2496
3119
|
* ```
|
|
2497
3120
|
*/
|
|
2498
|
-
declare function useUserBorrowsAction(options?:
|
|
3121
|
+
declare function useUserBorrowsAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError>;
|
|
2499
3122
|
type UseUserSummaryArgs = Prettify<UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions>;
|
|
2500
3123
|
/**
|
|
2501
3124
|
* Fetch a user's financial summary.
|
|
@@ -2910,4 +3533,190 @@ declare function useUserSummaryHistory(args: UseUserSummaryHistoryArgs): ReadRes
|
|
|
2910
3533
|
*/
|
|
2911
3534
|
declare function useUserSummaryHistory(args: Pausable<UseUserSummaryHistoryArgs>): PausableReadResult<UserSummaryHistoryItem[]>;
|
|
2912
3535
|
|
|
2913
|
-
|
|
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 };
|