@aave/react 4.0.0-next.5 → 4.0.0-next.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- 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 +1414 -626
- package/dist/index.d.ts +1414 -626
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{misc-gmAnSdm5.d.ts → misc-CLtLR-vZ.d.cts} +101 -24
- package/dist/{misc-BkG5G4yl.d.cts → misc-CfqYr0kO.d.ts} +101 -24
- 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 +12 -56
- package/dist/viem/index.d.ts +12 -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 +9 -8
- package/dist/chunk-GTUQRT5Q.js +0 -2
- package/dist/chunk-GTUQRT5Q.js.map +0 -1
- package/dist/chunk-YJ6HF5HO.js +0 -2
- package/dist/chunk-YJ6HF5HO.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AaveClient, CurrencyQueryOptions,
|
|
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, Hub, HubsRequest, HubAssetsRequest, HubAsset,
|
|
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, Hub, HubsRequest, HubAssetsRequest, HubAsset, HubSummaryHistoryRequest, HubSummarySample, AssetRequest, Asset, AssetPriceHistoryRequest, AssetPriceSample, AssetSupplyHistoryRequest, AssetSupplySample, AssetBorrowHistoryRequest, AssetBorrowSample, ProtocolHistoryRequest, ProtocolHistorySample, ReserveRequest, Reserve, ReservesRequest, BorrowApyHistoryRequest, ApySample, SupplyApyHistoryRequest, UserClaimableRewardsRequest, UserClaimableReward, SpokeRequest, Spoke, SpokesRequest, SpokePositionManagersRequest, PaginatedSpokePositionManagerResult, SpokeUserPositionManagersRequest, 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, UserSuppliesRequest, UserSupplyItem, UserBorrowsRequest, UserBorrowItem, UserSummaryRequest, UserSummary, UserPositionsRequest, UserPosition, UserPositionRequest, UserBalancesRequest, UserBalance, UserRiskPremiumBreakdownRequest, UserRiskPremiumBreakdownItem, UserSummaryHistoryRequest, UserSummaryHistoryItem } 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-CfqYr0kO.js';
|
|
9
|
+
export { d as UseChainArgs, f as UseChainsArgs, i as UseExchangeRateArgs, U as UseNetworkFee, l as UseNetworkFeeArgs, k as UseNetworkFeeRequestQuery, u as useChain, e as useChainAction, g as useChains, j as useExchangeRate, h as useExchangeRateAction } from './misc-CfqYr0kO.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
|
/**
|
|
@@ -49,7 +49,7 @@ declare function AaveProvider({ children, client }: AaveProviderProps): React.JS
|
|
|
49
49
|
*/
|
|
50
50
|
declare function useAaveClient(): AaveClient;
|
|
51
51
|
|
|
52
|
-
type UseHubArgs = Prettify<HubRequest & CurrencyQueryOptions>;
|
|
52
|
+
type UseHubArgs = Prettify<HubRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
53
53
|
/**
|
|
54
54
|
* Fetch a specific hub by ID or by address and chain ID.
|
|
55
55
|
*
|
|
@@ -102,7 +102,7 @@ declare function useHub(args: UseHubArgs): ReadResult<Hub | null>;
|
|
|
102
102
|
* ```
|
|
103
103
|
*/
|
|
104
104
|
declare function useHub(args: Pausable<UseHubArgs>): PausableReadResult<Hub | null>;
|
|
105
|
-
type UseHubsArgs = Prettify<HubsRequest & CurrencyQueryOptions>;
|
|
105
|
+
type UseHubsArgs = Prettify<HubsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
106
106
|
/**
|
|
107
107
|
* Fetch multiple hubs based on specified criteria.
|
|
108
108
|
*
|
|
@@ -153,7 +153,7 @@ declare function useHubs(args: UseHubsArgs): ReadResult<Hub[]>;
|
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
155
|
declare function useHubs(args: Pausable<UseHubsArgs>): PausableReadResult<Hub[]>;
|
|
156
|
-
type UseHubAssetsArgs = Prettify<HubAssetsRequest & CurrencyQueryOptions>;
|
|
156
|
+
type UseHubAssetsArgs = Prettify<HubAssetsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
157
157
|
/**
|
|
158
158
|
* Fetch hub assets for a specific hub by ID or by address and chain ID.
|
|
159
159
|
*
|
|
@@ -208,6 +208,61 @@ declare function useHubAssets(args: UseHubAssetsArgs): ReadResult<HubAsset[]>;
|
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
210
|
declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadResult<HubAsset[]>;
|
|
211
|
+
type UseHubSummaryHistoryArgs = HubSummaryHistoryRequest;
|
|
212
|
+
/**
|
|
213
|
+
* Fetch historical summary data for a specific hub.
|
|
214
|
+
*
|
|
215
|
+
* This signature supports React Suspense:
|
|
216
|
+
*
|
|
217
|
+
* ```tsx
|
|
218
|
+
* const { data } = useHubSummaryHistory({
|
|
219
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
220
|
+
* currency: Currency.Usd,
|
|
221
|
+
* window: TimeWindow.LastWeek,
|
|
222
|
+
* suspense: true,
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs & Suspendable): SuspenseResult<HubSummarySample[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Fetch historical summary data for a specific hub.
|
|
229
|
+
*
|
|
230
|
+
* Pausable suspense mode.
|
|
231
|
+
*
|
|
232
|
+
* ```tsx
|
|
233
|
+
* const { data } = useHubSummaryHistory({
|
|
234
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
235
|
+
* suspense: true,
|
|
236
|
+
* pause: true,
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs> & Suspendable): PausableSuspenseResult<HubSummarySample[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Fetch historical summary data for a specific hub.
|
|
243
|
+
*
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const { data, error, loading } = useHubSummaryHistory({
|
|
246
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
247
|
+
* currency: Currency.Usd,
|
|
248
|
+
* window: TimeWindow.LastWeek,
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs): ReadResult<HubSummarySample[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Fetch historical summary data for a specific hub.
|
|
255
|
+
*
|
|
256
|
+
* Pausable loading state mode.
|
|
257
|
+
*
|
|
258
|
+
* ```tsx
|
|
259
|
+
* const { data, error, loading, paused } = useHubSummaryHistory({
|
|
260
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
261
|
+
* pause: true,
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs>): PausableReadResult<HubSummarySample[]>;
|
|
211
266
|
/**
|
|
212
267
|
* Low-level hook to execute a {@link hubs} action directly.
|
|
213
268
|
*
|
|
@@ -237,11 +292,6 @@ declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadRes
|
|
|
237
292
|
*/
|
|
238
293
|
declare function useHubsAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubsRequest, Hub[], UnexpectedError>;
|
|
239
294
|
|
|
240
|
-
/**
|
|
241
|
-
* @internal
|
|
242
|
-
*/
|
|
243
|
-
declare function usePermitTypedDataAction(): UseAsyncTask<PermitRequest, PermitTypedDataResponse, UnexpectedError>;
|
|
244
|
-
|
|
245
295
|
type UseAssetArgs = Prettify<AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
246
296
|
/**
|
|
247
297
|
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
@@ -350,7 +400,7 @@ declare function useAssetPriceHistory(args: UseAssetPriceHistoryArgs): ReadResul
|
|
|
350
400
|
* ```
|
|
351
401
|
*/
|
|
352
402
|
declare function useAssetPriceHistory(args: Pausable<UseAssetPriceHistoryArgs>): PausableReadResult<AssetPriceSample[]>;
|
|
353
|
-
type UseAssetSupplyHistoryArgs = AssetSupplyHistoryRequest
|
|
403
|
+
type UseAssetSupplyHistoryArgs = Prettify<AssetSupplyHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
354
404
|
/**
|
|
355
405
|
* Fetch historical supply data for a specific asset.
|
|
356
406
|
*
|
|
@@ -403,7 +453,7 @@ declare function useAssetSupplyHistory(args: UseAssetSupplyHistoryArgs): ReadRes
|
|
|
403
453
|
* ```
|
|
404
454
|
*/
|
|
405
455
|
declare function useAssetSupplyHistory(args: Pausable<UseAssetSupplyHistoryArgs>): PausableReadResult<AssetSupplySample[]>;
|
|
406
|
-
type UseAssetBorrowHistoryArgs = AssetBorrowHistoryRequest
|
|
456
|
+
type UseAssetBorrowHistoryArgs = Prettify<AssetBorrowHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
407
457
|
/**
|
|
408
458
|
* Fetch historical borrow data for a specific asset.
|
|
409
459
|
*
|
|
@@ -456,8 +506,63 @@ declare function useAssetBorrowHistory(args: UseAssetBorrowHistoryArgs): ReadRes
|
|
|
456
506
|
* ```
|
|
457
507
|
*/
|
|
458
508
|
declare function useAssetBorrowHistory(args: Pausable<UseAssetBorrowHistoryArgs>): PausableReadResult<AssetBorrowSample[]>;
|
|
509
|
+
type UseProtocolHistoryArgs = ProtocolHistoryRequest;
|
|
510
|
+
/**
|
|
511
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
512
|
+
*
|
|
513
|
+
* This signature supports React Suspense:
|
|
514
|
+
*
|
|
515
|
+
* ```tsx
|
|
516
|
+
* const { data } = useProtocolHistory({
|
|
517
|
+
* currency: Currency.Usd,
|
|
518
|
+
* window: TimeWindow.LastWeek,
|
|
519
|
+
* suspense: true,
|
|
520
|
+
* });
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
declare function useProtocolHistory(args: UseProtocolHistoryArgs & Suspendable): SuspenseResult<ProtocolHistorySample[]>;
|
|
524
|
+
/**
|
|
525
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
526
|
+
*
|
|
527
|
+
* Pausable suspense mode.
|
|
528
|
+
*
|
|
529
|
+
* ```tsx
|
|
530
|
+
* const { data } = useProtocolHistory({
|
|
531
|
+
* currency: Currency.Usd,
|
|
532
|
+
* window: TimeWindow.LastWeek,
|
|
533
|
+
* suspense: true,
|
|
534
|
+
* pause: true,
|
|
535
|
+
* });
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
declare function useProtocolHistory(args: Pausable<UseProtocolHistoryArgs> & Suspendable): PausableSuspenseResult<ProtocolHistorySample[]>;
|
|
539
|
+
/**
|
|
540
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
541
|
+
*
|
|
542
|
+
* ```tsx
|
|
543
|
+
* const { data, error, loading } = useProtocolHistory({
|
|
544
|
+
* currency: Currency.Usd,
|
|
545
|
+
* window: TimeWindow.LastWeek,
|
|
546
|
+
* });
|
|
547
|
+
* ```
|
|
548
|
+
*/
|
|
549
|
+
declare function useProtocolHistory(args: UseProtocolHistoryArgs): ReadResult<ProtocolHistorySample[]>;
|
|
550
|
+
/**
|
|
551
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
552
|
+
*
|
|
553
|
+
* Pausable loading state mode.
|
|
554
|
+
*
|
|
555
|
+
* ```tsx
|
|
556
|
+
* const { data, error, loading, paused } = useProtocolHistory({
|
|
557
|
+
* currency: Currency.Usd,
|
|
558
|
+
* window: TimeWindow.LastWeek,
|
|
559
|
+
* pause: true,
|
|
560
|
+
* });
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
declare function useProtocolHistory(args: Pausable<UseProtocolHistoryArgs>): PausableReadResult<ProtocolHistorySample[]>;
|
|
459
564
|
|
|
460
|
-
type UseReserveArgs = Prettify<ReserveRequest & CurrencyQueryOptions>;
|
|
565
|
+
type UseReserveArgs = Prettify<ReserveRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
461
566
|
/**
|
|
462
567
|
* Fetch a specific reserve by reserve ID, spoke, and chain.
|
|
463
568
|
*
|
|
@@ -537,18 +642,8 @@ declare function useReserve(args: Pausable<UseReserveArgs>): PausableReadResult<
|
|
|
537
642
|
* }
|
|
538
643
|
* ```
|
|
539
644
|
*/
|
|
540
|
-
declare function useReserveAction(options?:
|
|
541
|
-
type UseReservesArgs
|
|
542
|
-
/**
|
|
543
|
-
* A function that maps the full list of reserves
|
|
544
|
-
* into a derived or narrowed value.
|
|
545
|
-
*
|
|
546
|
-
* Example: pick a single reserve based on a criteria.
|
|
547
|
-
*
|
|
548
|
-
* @experimental This is experimental and may be subject to breaking changes.
|
|
549
|
-
*/
|
|
550
|
-
selector?: Selector<Reserve[], T>;
|
|
551
|
-
}>;
|
|
645
|
+
declare function useReserveAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError>;
|
|
646
|
+
type UseReservesArgs = Prettify<ReservesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
552
647
|
/**
|
|
553
648
|
* Fetch reserves based on specified criteria.
|
|
554
649
|
*
|
|
@@ -567,36 +662,8 @@ type UseReservesArgs<T = Reserve[]> = Prettify<ReservesRequest & CurrencyQueryOp
|
|
|
567
662
|
* suspense: true,
|
|
568
663
|
* });
|
|
569
664
|
* ```
|
|
570
|
-
*
|
|
571
|
-
* **Reserves with Highest Supply APY**
|
|
572
|
-
* ```tsx
|
|
573
|
-
* const { data } = useReserves({
|
|
574
|
-
* query: {
|
|
575
|
-
* spoke: {
|
|
576
|
-
* address: evmAddress('0x123...'),
|
|
577
|
-
* chainId: chainId(1)
|
|
578
|
-
* }
|
|
579
|
-
* },
|
|
580
|
-
* suspense: true,
|
|
581
|
-
* selector: pickHighestSupplyApyReserve,
|
|
582
|
-
* });
|
|
583
|
-
* ```
|
|
584
|
-
*
|
|
585
|
-
* **Reserves with Lowest Borrow APY**
|
|
586
|
-
* ```tsx
|
|
587
|
-
* const { data } = useReserves({
|
|
588
|
-
* query: {
|
|
589
|
-
* spoke: {
|
|
590
|
-
* address: evmAddress('0x123...'),
|
|
591
|
-
* chainId: chainId(1)
|
|
592
|
-
* }
|
|
593
|
-
* },
|
|
594
|
-
* suspense: true,
|
|
595
|
-
* selector: pickLowestBorrowApyReserve,
|
|
596
|
-
* });
|
|
597
|
-
* ```
|
|
598
665
|
*/
|
|
599
|
-
declare function useReserves
|
|
666
|
+
declare function useReserves(args: UseReservesArgs & Suspendable): SuspenseResult<Reserve[]>;
|
|
600
667
|
/**
|
|
601
668
|
* Fetch reserves based on specified criteria.
|
|
602
669
|
*
|
|
@@ -615,7 +682,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T> & Suspendab
|
|
|
615
682
|
* });
|
|
616
683
|
* ```
|
|
617
684
|
*/
|
|
618
|
-
declare function useReserves
|
|
685
|
+
declare function useReserves(args: Pausable<UseReservesArgs> & Suspendable): PausableSuspenseResult<Reserve[]>;
|
|
619
686
|
/**
|
|
620
687
|
* Fetch reserves based on specified criteria.
|
|
621
688
|
*
|
|
@@ -631,34 +698,8 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>> &
|
|
|
631
698
|
* orderBy: { name: 'ASC' },
|
|
632
699
|
* });
|
|
633
700
|
* ```
|
|
634
|
-
*
|
|
635
|
-
* **Reserves with Highest Supply APY**
|
|
636
|
-
* ```tsx
|
|
637
|
-
* const { data } = useReserves({
|
|
638
|
-
* query: {
|
|
639
|
-
* spoke: {
|
|
640
|
-
* address: evmAddress('0x123...'),
|
|
641
|
-
* chainId: chainId(1)
|
|
642
|
-
* }
|
|
643
|
-
* },
|
|
644
|
-
* selector: pickHighestSupplyApyReserve,
|
|
645
|
-
* });
|
|
646
|
-
* ```
|
|
647
|
-
*
|
|
648
|
-
* **Reserves with Lowest Borrow APY**
|
|
649
|
-
* ```tsx
|
|
650
|
-
* const { data } = useReserves({
|
|
651
|
-
* query: {
|
|
652
|
-
* spoke: {
|
|
653
|
-
* address: evmAddress('0x123...'),
|
|
654
|
-
* chainId: chainId(1)
|
|
655
|
-
* }
|
|
656
|
-
* },
|
|
657
|
-
* selector: pickLowestBorrowApyReserve,
|
|
658
|
-
* });
|
|
659
|
-
* ```
|
|
660
701
|
*/
|
|
661
|
-
declare function useReserves
|
|
702
|
+
declare function useReserves(args: UseReservesArgs): ReadResult<Reserve[], UnexpectedError>;
|
|
662
703
|
/**
|
|
663
704
|
* Fetch reserves based on specified criteria.
|
|
664
705
|
*
|
|
@@ -676,7 +717,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T>): ReadResul
|
|
|
676
717
|
* });
|
|
677
718
|
* ```
|
|
678
719
|
*/
|
|
679
|
-
declare function useReserves
|
|
720
|
+
declare function useReserves(args: Pausable<UseReservesArgs>): PausableReadResult<Reserve[], UnexpectedError>;
|
|
680
721
|
/**
|
|
681
722
|
* Low-level hook to execute a {@link reserves} action directly.
|
|
682
723
|
*
|
|
@@ -706,39 +747,9 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>>):
|
|
|
706
747
|
* console.error(result.error);
|
|
707
748
|
* }
|
|
708
749
|
* ```
|
|
709
|
-
*
|
|
710
|
-
* **Reserves with Highest Supply APY**
|
|
711
|
-
* ```ts
|
|
712
|
-
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
713
|
-
*
|
|
714
|
-
* // …
|
|
715
|
-
*
|
|
716
|
-
* const result = await execute(…).map(pickHighestSupplyApyReserve);
|
|
717
|
-
*
|
|
718
|
-
* if (result.isOk()) {
|
|
719
|
-
* console.log(result.value); // Reserve | null
|
|
720
|
-
* } else {
|
|
721
|
-
* console.error(result.error);
|
|
722
|
-
* }
|
|
723
|
-
* ```
|
|
724
|
-
*
|
|
725
|
-
* **Reserves with Lowest Borrow APY**
|
|
726
|
-
* ```ts
|
|
727
|
-
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
728
|
-
*
|
|
729
|
-
* // …
|
|
730
|
-
*
|
|
731
|
-
* const result = await execute(…).map(pickLowestBorrowApyReserve);
|
|
732
|
-
*
|
|
733
|
-
* if (result.isOk()) {
|
|
734
|
-
* console.log(result.value); // Reserve | null
|
|
735
|
-
* } else {
|
|
736
|
-
* console.error(result.error);
|
|
737
|
-
* }
|
|
738
|
-
* ```
|
|
739
750
|
*/
|
|
740
|
-
declare function useReservesAction(options?:
|
|
741
|
-
type UseBorrowApyHistoryArgs =
|
|
751
|
+
declare function useReservesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError>;
|
|
752
|
+
type UseBorrowApyHistoryArgs = BorrowApyHistoryRequest;
|
|
742
753
|
/**
|
|
743
754
|
* Fetch borrow APY history for a specific reserve over time.
|
|
744
755
|
*
|
|
@@ -752,7 +763,7 @@ type UseBorrowApyHistoryArgs = BorrowAPYHistoryRequest;
|
|
|
752
763
|
* });
|
|
753
764
|
* ```
|
|
754
765
|
*/
|
|
755
|
-
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable): SuspenseResult<
|
|
766
|
+
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable): SuspenseResult<ApySample[]>;
|
|
756
767
|
/**
|
|
757
768
|
* Fetch borrow APY history for a specific reserve over time.
|
|
758
769
|
*
|
|
@@ -767,7 +778,7 @@ declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable
|
|
|
767
778
|
* });
|
|
768
779
|
* ```
|
|
769
780
|
*/
|
|
770
|
-
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & Suspendable): PausableSuspenseResult<
|
|
781
|
+
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & Suspendable): PausableSuspenseResult<ApySample[]>;
|
|
771
782
|
/**
|
|
772
783
|
* Fetch borrow APY history for a specific reserve over time.
|
|
773
784
|
*
|
|
@@ -778,7 +789,7 @@ declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & S
|
|
|
778
789
|
* });
|
|
779
790
|
* ```
|
|
780
791
|
*/
|
|
781
|
-
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<
|
|
792
|
+
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<ApySample[]>;
|
|
782
793
|
/**
|
|
783
794
|
* Fetch borrow APY history for a specific reserve over time.
|
|
784
795
|
*
|
|
@@ -792,8 +803,8 @@ declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<
|
|
|
792
803
|
* });
|
|
793
804
|
* ```
|
|
794
805
|
*/
|
|
795
|
-
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs>): PausableReadResult<
|
|
796
|
-
type UseSupplyApyHistoryArgs =
|
|
806
|
+
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs>): PausableReadResult<ApySample[]>;
|
|
807
|
+
type UseSupplyApyHistoryArgs = SupplyApyHistoryRequest;
|
|
797
808
|
/**
|
|
798
809
|
* Fetch supply APY history for a specific reserve over time.
|
|
799
810
|
*
|
|
@@ -807,7 +818,7 @@ type UseSupplyApyHistoryArgs = SupplyAPYHistoryRequest;
|
|
|
807
818
|
* });
|
|
808
819
|
* ```
|
|
809
820
|
*/
|
|
810
|
-
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable): SuspenseResult<
|
|
821
|
+
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable): SuspenseResult<ApySample[]>;
|
|
811
822
|
/**
|
|
812
823
|
* Fetch supply APY history for a specific reserve over time.
|
|
813
824
|
*
|
|
@@ -822,7 +833,7 @@ declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable
|
|
|
822
833
|
* });
|
|
823
834
|
* ```
|
|
824
835
|
*/
|
|
825
|
-
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & Suspendable): PausableSuspenseResult<
|
|
836
|
+
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & Suspendable): PausableSuspenseResult<ApySample[]>;
|
|
826
837
|
/**
|
|
827
838
|
* Fetch supply APY history for a specific reserve over time.
|
|
828
839
|
*
|
|
@@ -833,7 +844,7 @@ declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & S
|
|
|
833
844
|
* });
|
|
834
845
|
* ```
|
|
835
846
|
*/
|
|
836
|
-
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<
|
|
847
|
+
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<ApySample[]>;
|
|
837
848
|
/**
|
|
838
849
|
* Fetch supply APY history for a specific reserve over time.
|
|
839
850
|
*
|
|
@@ -847,7 +858,85 @@ declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<
|
|
|
847
858
|
* });
|
|
848
859
|
* ```
|
|
849
860
|
*/
|
|
850
|
-
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<
|
|
861
|
+
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<ApySample[]>;
|
|
862
|
+
|
|
863
|
+
type UseUserClaimableRewardsArgs = Prettify<UserClaimableRewardsRequest>;
|
|
864
|
+
/**
|
|
865
|
+
* Fetch all claimable rewards for a user.
|
|
866
|
+
*
|
|
867
|
+
* This signature supports React Suspense:
|
|
868
|
+
*
|
|
869
|
+
* ```tsx
|
|
870
|
+
* const { data } = useUserClaimableRewards({
|
|
871
|
+
* user: evmAddress('0x742d35cc…'),
|
|
872
|
+
* suspense: true,
|
|
873
|
+
* });
|
|
874
|
+
* ```
|
|
875
|
+
*/
|
|
876
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs & Suspendable): SuspenseResult<UserClaimableReward[]>;
|
|
877
|
+
/**
|
|
878
|
+
* Fetch all claimable rewards for a user.
|
|
879
|
+
*
|
|
880
|
+
* Pausable suspense mode.
|
|
881
|
+
*
|
|
882
|
+
* ```tsx
|
|
883
|
+
* const { data } = useUserClaimableRewards({
|
|
884
|
+
* user: evmAddress('0x742d35cc…'),
|
|
885
|
+
* suspense: true,
|
|
886
|
+
* pause: true,
|
|
887
|
+
* });
|
|
888
|
+
* ```
|
|
889
|
+
*/
|
|
890
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs> & Suspendable): PausableSuspenseResult<UserClaimableReward[]>;
|
|
891
|
+
/**
|
|
892
|
+
* Fetch all claimable rewards for a user.
|
|
893
|
+
*
|
|
894
|
+
* ```tsx
|
|
895
|
+
* const { data, error, loading } = useUserClaimableRewards({
|
|
896
|
+
* user: evmAddress('0x742d35cc…'),
|
|
897
|
+
* });
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs): ReadResult<UserClaimableReward[]>;
|
|
901
|
+
/**
|
|
902
|
+
* Fetch all claimable rewards for a user.
|
|
903
|
+
*
|
|
904
|
+
* Pausable loading state mode.
|
|
905
|
+
*
|
|
906
|
+
* ```tsx
|
|
907
|
+
* const { data, error, loading, paused } = useUserClaimableRewards({
|
|
908
|
+
* user: evmAddress('0x742d35cc…'),
|
|
909
|
+
* pause: true,
|
|
910
|
+
* });
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs>): PausableReadResult<UserClaimableReward[]>;
|
|
914
|
+
/**
|
|
915
|
+
* Low-level hook to execute a {@link userClaimableRewards} action directly.
|
|
916
|
+
*
|
|
917
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
918
|
+
* @remarks
|
|
919
|
+
* This hook **does not** actively watch for updated data on claimable rewards.
|
|
920
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
921
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
922
|
+
*
|
|
923
|
+
* ```ts
|
|
924
|
+
* const [execute, { called, data, error, loading }] = useUserClaimableRewardsAction();
|
|
925
|
+
*
|
|
926
|
+
* // …
|
|
927
|
+
*
|
|
928
|
+
* const result = await execute({
|
|
929
|
+
* user: evmAddress('0x742d35cc…'),
|
|
930
|
+
* });
|
|
931
|
+
*
|
|
932
|
+
* if (result.isOk()) {
|
|
933
|
+
* console.log(result.value); // UserClaimableReward[]
|
|
934
|
+
* } else {
|
|
935
|
+
* console.error(result.error);
|
|
936
|
+
* }
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
declare function useUserClaimableRewardsAction(): UseAsyncTask<UserClaimableRewardsRequest, UserClaimableReward[], UnexpectedError>;
|
|
851
940
|
|
|
852
941
|
type UseSpokeArgs = SpokeRequest;
|
|
853
942
|
/**
|
|
@@ -1060,113 +1149,466 @@ declare function useSpokeUserPositionManagers(args: UseSpokeUserPositionManagers
|
|
|
1060
1149
|
*/
|
|
1061
1150
|
declare function useSpokeUserPositionManagers(args: Pausable<UseSpokeUserPositionManagersArgs>): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1062
1151
|
|
|
1063
|
-
type
|
|
1152
|
+
type SwapHandlerOptions = {
|
|
1153
|
+
cancel: CancelOperation;
|
|
1154
|
+
};
|
|
1155
|
+
type SwapSignerError = CancelError | SigningError | UnexpectedError$1;
|
|
1156
|
+
type PositionSwapPlan = PositionSwapApproval | SwapTypedData;
|
|
1157
|
+
type PositionSwapHandler = (plan: PositionSwapPlan, options: SwapHandlerOptions) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1158
|
+
type PositionSwapValue = {
|
|
1159
|
+
quote?: SwapQuote;
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
type UseBorrowSwapRequest = Prettify<BorrowSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1064
1163
|
/**
|
|
1065
|
-
*
|
|
1066
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1067
|
-
*
|
|
1068
|
-
* This signature supports React Suspense:
|
|
1164
|
+
* Orchestrate the borrow swap execution plan.
|
|
1069
1165
|
*
|
|
1070
1166
|
* ```tsx
|
|
1071
|
-
* const
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1167
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1168
|
+
*
|
|
1169
|
+
* const [swapBorrow, { loading, error }] = useBorrowSwap((plan) => {
|
|
1170
|
+
* switch (plan.__typename) {
|
|
1171
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1172
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1173
|
+
* return signTypedData(plan.bySignature);
|
|
1174
|
+
*
|
|
1175
|
+
* case 'SwapTypedData':
|
|
1176
|
+
* return signTypedData(plan);
|
|
1177
|
+
* }
|
|
1178
|
+
* });
|
|
1179
|
+
*
|
|
1180
|
+
* const result = await swapBorrow({
|
|
1181
|
+
* market: {
|
|
1182
|
+
* debtPosition: userBorrowItem.id,
|
|
1183
|
+
* buyReserve: targetReserve.id,
|
|
1184
|
+
* amount: bigDecimal('1000'),
|
|
1185
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1186
|
+
* },
|
|
1078
1187
|
* });
|
|
1188
|
+
*
|
|
1189
|
+
* if (result.isErr()) {
|
|
1190
|
+
* console.error(result.error);
|
|
1191
|
+
* return;
|
|
1192
|
+
* }
|
|
1193
|
+
*
|
|
1194
|
+
* // result.value: SwapReceipt
|
|
1079
1195
|
* ```
|
|
1080
1196
|
*/
|
|
1081
|
-
declare function
|
|
1197
|
+
declare function useBorrowSwap(handler: PositionSwapHandler): UseAsyncTask<BorrowSwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1198
|
+
|
|
1199
|
+
type UseBorrowSwapQuoteArgs = Prettify<BorrowSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1082
1200
|
/**
|
|
1083
|
-
*
|
|
1084
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1201
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1085
1202
|
*
|
|
1086
|
-
*
|
|
1203
|
+
* This signature supports React Suspense:
|
|
1087
1204
|
*
|
|
1088
1205
|
* ```tsx
|
|
1089
|
-
* const { data } =
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1206
|
+
* const { data } = useBorrowSwapQuote({
|
|
1207
|
+
* market: {
|
|
1208
|
+
* sellPosition: userBorrowItem.id,
|
|
1209
|
+
* buyReserve: reserve.id,
|
|
1210
|
+
* amount: bigDecimal('1000'),
|
|
1211
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1212
|
+
* },
|
|
1213
|
+
* suspense: true,
|
|
1214
|
+
* });
|
|
1215
|
+
* ```
|
|
1216
|
+
*/
|
|
1217
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1220
|
+
*
|
|
1221
|
+
* Pausable suspense mode.
|
|
1222
|
+
*
|
|
1223
|
+
* ```tsx
|
|
1224
|
+
* const { data } = useBorrowSwapQuote({
|
|
1225
|
+
* market: {
|
|
1226
|
+
* sellPosition: userBorrowItem.id,
|
|
1227
|
+
* buyReserve: reserve.id,
|
|
1228
|
+
* amount: bigDecimal('1000'),
|
|
1229
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1230
|
+
* },
|
|
1096
1231
|
* suspense: true,
|
|
1097
1232
|
* pause: true,
|
|
1098
1233
|
* });
|
|
1099
1234
|
* ```
|
|
1100
1235
|
*/
|
|
1101
|
-
declare function
|
|
1236
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1102
1237
|
/**
|
|
1103
|
-
*
|
|
1104
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1238
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1105
1239
|
*
|
|
1106
1240
|
* ```tsx
|
|
1107
|
-
* const { data, error, loading } =
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1241
|
+
* const { data, error, loading } = useBorrowSwapQuote({
|
|
1242
|
+
* market: {
|
|
1243
|
+
* sellPosition: userBorrowItem.id,
|
|
1244
|
+
* buyReserve: reserve.id,
|
|
1245
|
+
* amount: bigDecimal('1000'),
|
|
1246
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1247
|
+
* },
|
|
1248
|
+
* });
|
|
1249
|
+
* ```
|
|
1250
|
+
*/
|
|
1251
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1254
|
+
*
|
|
1255
|
+
* Pausable loading state mode.
|
|
1256
|
+
*
|
|
1257
|
+
* ```tsx
|
|
1258
|
+
* const { data, error, loading, paused } = useBorrowSwapQuote({
|
|
1259
|
+
* market: {
|
|
1260
|
+
* sellPosition: userBorrowItem.id,
|
|
1261
|
+
* buyReserve: reserve.id,
|
|
1262
|
+
* amount: bigDecimal('1000'),
|
|
1263
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1264
|
+
* },
|
|
1265
|
+
* pause: true,
|
|
1266
|
+
* });
|
|
1267
|
+
* ```
|
|
1268
|
+
*/
|
|
1269
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Low-level hook to execute a borrow swap quote action directly.
|
|
1272
|
+
*
|
|
1273
|
+
* @remarks
|
|
1274
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1275
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1276
|
+
*
|
|
1277
|
+
* ```ts
|
|
1278
|
+
* const [getQuote, { called, data, error, loading }] = useBorrowSwapQuoteAction();
|
|
1279
|
+
*
|
|
1280
|
+
* // …
|
|
1281
|
+
*
|
|
1282
|
+
* const result = await getQuote({
|
|
1283
|
+
* debtPosition: userBorrowItem.id,
|
|
1284
|
+
* buyReserve: reserve.id,
|
|
1111
1285
|
* amount: bigDecimal('1000'),
|
|
1112
|
-
*
|
|
1286
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1287
|
+
* });
|
|
1288
|
+
*
|
|
1289
|
+
* if (result.isOk()) {
|
|
1290
|
+
* console.log('Borrow swap quote:', result.value);
|
|
1291
|
+
* } else {
|
|
1292
|
+
* console.error(result.error);
|
|
1293
|
+
* }
|
|
1294
|
+
* ```
|
|
1295
|
+
*/
|
|
1296
|
+
declare function useBorrowSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<BorrowSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1297
|
+
|
|
1298
|
+
type CancelSwapHandler = (data: SwapTypedData | TransactionRequest, options: {
|
|
1299
|
+
cancel: typeof cancel;
|
|
1300
|
+
}) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1301
|
+
declare class CannotCancelSwapError extends ResultAwareError {
|
|
1302
|
+
name: "CannotCancelSwapError";
|
|
1303
|
+
}
|
|
1304
|
+
type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | TimeoutError | TransactionError | UnexpectedError$1;
|
|
1305
|
+
/**
|
|
1306
|
+
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
1307
|
+
*
|
|
1308
|
+
* ```tsx
|
|
1309
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1310
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1311
|
+
*
|
|
1312
|
+
* const [cancelSwap, { loading, error }] = useCancelSwap((plan) => {
|
|
1313
|
+
* switch (plan.__typename) {
|
|
1314
|
+
* case 'TransactionRequest':
|
|
1315
|
+
* return sendTransaction(plan);
|
|
1316
|
+
*
|
|
1317
|
+
* case 'SwapTypedData':
|
|
1318
|
+
* return signTypedData(plan);
|
|
1319
|
+
* }
|
|
1113
1320
|
* });
|
|
1321
|
+
*
|
|
1322
|
+
* const result = await cancelSwap({
|
|
1323
|
+
* id: swapId('123…'),
|
|
1324
|
+
* });
|
|
1325
|
+
*
|
|
1326
|
+
* if (result.isErr()) {
|
|
1327
|
+
* console.error(result.error);
|
|
1328
|
+
* return;
|
|
1329
|
+
* }
|
|
1330
|
+
*
|
|
1331
|
+
* // result.value: SwapCancelledResult
|
|
1332
|
+
* console.log('Swap cancelled:', result.value);
|
|
1114
1333
|
* ```
|
|
1115
1334
|
*/
|
|
1116
|
-
declare function
|
|
1335
|
+
declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<PrepareSwapCancelRequest, SwapCancelledResult, CancelSwapError>;
|
|
1336
|
+
|
|
1337
|
+
type UseRepayWithSupplyRequest = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1117
1338
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1339
|
+
* Orchestrate the repay with supply execution plan.
|
|
1340
|
+
*
|
|
1341
|
+
* ```tsx
|
|
1342
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1343
|
+
*
|
|
1344
|
+
* const [repayWithSupply, { loading, error }] = useRepayWithSupply((plan) => {
|
|
1345
|
+
* switch (plan.__typename) {
|
|
1346
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1347
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1348
|
+
* return signTypedData(plan.bySignature);
|
|
1349
|
+
*
|
|
1350
|
+
* case 'SwapTypedData':
|
|
1351
|
+
* return signTypedData(plan);
|
|
1352
|
+
* }
|
|
1353
|
+
* });
|
|
1354
|
+
*
|
|
1355
|
+
* const result = await repayWithSupply({
|
|
1356
|
+
* market: {
|
|
1357
|
+
* sellPosition: userSupplyItem.id,
|
|
1358
|
+
* buyPosition: userBorrowItem.id,
|
|
1359
|
+
* amount: bigDecimal('1000'),
|
|
1360
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1361
|
+
* },
|
|
1362
|
+
* });
|
|
1363
|
+
*
|
|
1364
|
+
* if (result.isErr()) {
|
|
1365
|
+
* console.error(result.error);
|
|
1366
|
+
* return;
|
|
1367
|
+
* }
|
|
1368
|
+
*
|
|
1369
|
+
* // result.value: SwapReceipt
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
declare function useRepayWithSupply(handler: PositionSwapHandler): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1373
|
+
|
|
1374
|
+
type UseRepayWithSupplyQuoteArgs = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1377
|
+
*
|
|
1378
|
+
* This signature supports React Suspense:
|
|
1379
|
+
*
|
|
1380
|
+
* ```tsx
|
|
1381
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1382
|
+
* market: {
|
|
1383
|
+
* sellPosition: userSupplyItem.id,
|
|
1384
|
+
* buyPosition: userBorrowItem.id,
|
|
1385
|
+
* amount: bigDecimal('1000'),
|
|
1386
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1387
|
+
* },
|
|
1388
|
+
* suspense: true,
|
|
1389
|
+
* });
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1395
|
+
*
|
|
1396
|
+
* Pausable suspense mode.
|
|
1397
|
+
*
|
|
1398
|
+
* ```tsx
|
|
1399
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1400
|
+
* market: {
|
|
1401
|
+
* sellPosition: userSupplyItem.id,
|
|
1402
|
+
* buyPosition: userBorrowItem.id,
|
|
1403
|
+
* amount: bigDecimal('1000'),
|
|
1404
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1405
|
+
* },
|
|
1406
|
+
* suspense: true,
|
|
1407
|
+
* pause: true,
|
|
1408
|
+
* });
|
|
1409
|
+
* ```
|
|
1410
|
+
*/
|
|
1411
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1412
|
+
/**
|
|
1413
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1414
|
+
*
|
|
1415
|
+
* ```tsx
|
|
1416
|
+
* const { data, error, loading } = useRepayWithSupplyQuote({
|
|
1417
|
+
* market: {
|
|
1418
|
+
* sellPosition: userSupplyItem.id,
|
|
1419
|
+
* buyPosition: userBorrowItem.id,
|
|
1420
|
+
* amount: bigDecimal('1000'),
|
|
1421
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1422
|
+
* },
|
|
1423
|
+
* });
|
|
1424
|
+
* ```
|
|
1425
|
+
*/
|
|
1426
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs): ReadResult<SwapQuote>;
|
|
1427
|
+
/**
|
|
1428
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1120
1429
|
*
|
|
1121
1430
|
* Pausable loading state mode.
|
|
1122
1431
|
*
|
|
1123
1432
|
* ```tsx
|
|
1124
|
-
* const { data, error, loading, paused } =
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1433
|
+
* const { data, error, loading, paused } = useRepayWithSupplyQuote({
|
|
1434
|
+
* market: {
|
|
1435
|
+
* sellPosition: userSupplyItem.id,
|
|
1436
|
+
* buyPosition: userBorrowItem.id,
|
|
1437
|
+
* amount: bigDecimal('1000'),
|
|
1438
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1439
|
+
* },
|
|
1440
|
+
* pause: true,
|
|
1441
|
+
* });
|
|
1442
|
+
* ```
|
|
1443
|
+
*/
|
|
1444
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1445
|
+
/**
|
|
1446
|
+
* Low-level hook to execute a repay with supply quote action directly.
|
|
1447
|
+
*
|
|
1448
|
+
* @remarks
|
|
1449
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1450
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1451
|
+
*
|
|
1452
|
+
* ```ts
|
|
1453
|
+
* const [getQuote, { called, data, error, loading }] = useRepayWithSupplyQuoteAction();
|
|
1454
|
+
*
|
|
1455
|
+
* // …
|
|
1456
|
+
*
|
|
1457
|
+
* const result = await getQuote({
|
|
1458
|
+
* repayWithReserve: reserve.id,
|
|
1459
|
+
* debtPosition: userBorrowItem.id,
|
|
1128
1460
|
* amount: bigDecimal('1000'),
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1461
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1462
|
+
* });
|
|
1463
|
+
*
|
|
1464
|
+
* if (result.isOk()) {
|
|
1465
|
+
* console.log('Repay with supply quote:', result.value);
|
|
1466
|
+
* } else {
|
|
1467
|
+
* console.error(result.error);
|
|
1468
|
+
* }
|
|
1469
|
+
* ```
|
|
1470
|
+
*/
|
|
1471
|
+
declare function useRepayWithSupplyQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1472
|
+
|
|
1473
|
+
type UseSupplySwapRequest = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Orchestrate the supply swap execution plan.
|
|
1476
|
+
*
|
|
1477
|
+
* ```tsx
|
|
1478
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1479
|
+
*
|
|
1480
|
+
* const [swapSupply, { loading, error }] = useSupplySwap((plan) => {
|
|
1481
|
+
* switch (plan.__typename) {
|
|
1482
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1483
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1484
|
+
* return signTypedData(plan.bySignature);
|
|
1485
|
+
*
|
|
1486
|
+
* case 'SwapTypedData':
|
|
1487
|
+
* return signTypedData(plan);
|
|
1488
|
+
* }
|
|
1489
|
+
* });
|
|
1490
|
+
*
|
|
1491
|
+
* const result = await swapSupply({
|
|
1492
|
+
* market: {
|
|
1493
|
+
* sellPosition: supplyPosition.id,
|
|
1494
|
+
* buyReserve: targetReserve.id,
|
|
1495
|
+
* amount: bigDecimal('1000'),
|
|
1496
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1497
|
+
* enableCollateral: true,
|
|
1498
|
+
* },
|
|
1499
|
+
* });
|
|
1500
|
+
*
|
|
1501
|
+
* if (result.isErr()) {
|
|
1502
|
+
* console.error(result.error);
|
|
1503
|
+
* return;
|
|
1504
|
+
* }
|
|
1505
|
+
*
|
|
1506
|
+
* // result.value: SwapReceipt
|
|
1507
|
+
* ```
|
|
1508
|
+
*/
|
|
1509
|
+
declare function useSupplySwap(handler: PositionSwapHandler): UseAsyncTask<SupplySwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1510
|
+
|
|
1511
|
+
type UseSupplySwapQuoteArgs = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1514
|
+
*
|
|
1515
|
+
* This signature supports React Suspense:
|
|
1516
|
+
*
|
|
1517
|
+
* ```tsx
|
|
1518
|
+
* const { data } = useSupplySwapQuote({
|
|
1519
|
+
* market: {
|
|
1520
|
+
* sellPosition: userSupplyItem.id,
|
|
1521
|
+
* buyReserve: reserve.id,
|
|
1522
|
+
* amount: bigDecimal('1000'),
|
|
1523
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1524
|
+
* },
|
|
1525
|
+
* suspense: true,
|
|
1526
|
+
* });
|
|
1527
|
+
* ```
|
|
1528
|
+
*/
|
|
1529
|
+
declare function useSupplySwapQuote(args: UseSupplySwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1532
|
+
*
|
|
1533
|
+
* Pausable suspense mode.
|
|
1534
|
+
*
|
|
1535
|
+
* ```tsx
|
|
1536
|
+
* const { data } = useSupplySwapQuote({
|
|
1537
|
+
* market: {
|
|
1538
|
+
* sellPosition: userSupplyItem.id,
|
|
1539
|
+
* buyReserve: reserve.id,
|
|
1540
|
+
* amount: bigDecimal('1000'),
|
|
1541
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1542
|
+
* },
|
|
1543
|
+
* suspense: true,
|
|
1131
1544
|
* pause: true,
|
|
1132
1545
|
* });
|
|
1133
1546
|
* ```
|
|
1134
1547
|
*/
|
|
1135
|
-
declare function
|
|
1548
|
+
declare function useSupplySwapQuote(args: Pausable<UseSupplySwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1136
1549
|
/**
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1550
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1551
|
+
*
|
|
1552
|
+
* ```tsx
|
|
1553
|
+
* const { data, error, loading } = useSupplySwapQuote({
|
|
1554
|
+
* market: {
|
|
1555
|
+
* sellPosition: userSupplyItem.id,
|
|
1556
|
+
* buyReserve: reserve.id,
|
|
1557
|
+
* amount: bigDecimal('1000'),
|
|
1558
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1559
|
+
* },
|
|
1560
|
+
* });
|
|
1561
|
+
* ```
|
|
1562
|
+
*/
|
|
1563
|
+
declare function useSupplySwapQuote(args: UseSupplySwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1564
|
+
/**
|
|
1565
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1566
|
+
*
|
|
1567
|
+
* Pausable loading state mode.
|
|
1568
|
+
*
|
|
1569
|
+
* ```tsx
|
|
1570
|
+
* const { data, error, loading, paused } = useSupplySwapQuote({
|
|
1571
|
+
* market: {
|
|
1572
|
+
* sellPosition: userSupplyItem.id,
|
|
1573
|
+
* buyReserve: reserve.id,
|
|
1574
|
+
* amount: bigDecimal('1000'),
|
|
1575
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1576
|
+
* },
|
|
1577
|
+
* pause: true,
|
|
1578
|
+
* });
|
|
1579
|
+
* ```
|
|
1580
|
+
*/
|
|
1581
|
+
declare function useSupplySwapQuote(args: Pausable<UseSupplySwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1582
|
+
/**
|
|
1583
|
+
* Low-level hook to execute a supply swap quote action directly.
|
|
1139
1584
|
*
|
|
1140
|
-
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
1141
1585
|
* @remarks
|
|
1142
1586
|
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1143
|
-
* Use this hook to retrieve quotes on demand as part of a larger workflow
|
|
1144
|
-
* (e.g., in an event handler to get a fresh quote before executing a swap).
|
|
1587
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1145
1588
|
*
|
|
1146
1589
|
* ```ts
|
|
1147
|
-
* const [getQuote, { called, data, error, loading }] =
|
|
1590
|
+
* const [getQuote, { called, data, error, loading }] = useSupplySwapQuoteAction();
|
|
1148
1591
|
*
|
|
1149
1592
|
* // …
|
|
1150
1593
|
*
|
|
1151
1594
|
* const result = await getQuote({
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1595
|
+
* sellPosition: userSupplyItem.id,
|
|
1596
|
+
* buyReserve: reserve.id,
|
|
1155
1597
|
* amount: bigDecimal('1000'),
|
|
1156
|
-
*
|
|
1598
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1157
1599
|
* });
|
|
1158
1600
|
*
|
|
1159
1601
|
* if (result.isOk()) {
|
|
1160
|
-
* console.log('
|
|
1602
|
+
* console.log('Supply swap quote:', result.value);
|
|
1161
1603
|
* } else {
|
|
1162
1604
|
* console.error(result.error);
|
|
1163
1605
|
* }
|
|
1164
1606
|
* ```
|
|
1165
1607
|
*/
|
|
1166
|
-
declare function
|
|
1608
|
+
declare function useSupplySwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<SupplySwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1609
|
+
|
|
1167
1610
|
type UseSwappableTokensArgs = SwappableTokensRequest;
|
|
1168
1611
|
/**
|
|
1169
|
-
* @internal
|
|
1170
1612
|
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1171
1613
|
*
|
|
1172
1614
|
* This signature supports React Suspense:
|
|
@@ -1180,7 +1622,6 @@ type UseSwappableTokensArgs = SwappableTokensRequest;
|
|
|
1180
1622
|
*/
|
|
1181
1623
|
declare function useSwappableTokens(args: UseSwappableTokensArgs & Suspendable): SuspenseResult<Token[]>;
|
|
1182
1624
|
/**
|
|
1183
|
-
* @internal
|
|
1184
1625
|
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1185
1626
|
*
|
|
1186
1627
|
* Pausable suspense mode.
|
|
@@ -1195,7 +1636,6 @@ declare function useSwappableTokens(args: UseSwappableTokensArgs & Suspendable):
|
|
|
1195
1636
|
*/
|
|
1196
1637
|
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs> & Suspendable): PausableSuspenseResult<Token[]>;
|
|
1197
1638
|
/**
|
|
1198
|
-
* @internal
|
|
1199
1639
|
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1200
1640
|
*
|
|
1201
1641
|
* ```tsx
|
|
@@ -1206,7 +1646,6 @@ declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs> & Sus
|
|
|
1206
1646
|
*/
|
|
1207
1647
|
declare function useSwappableTokens(args: UseSwappableTokensArgs): ReadResult<Token[]>;
|
|
1208
1648
|
/**
|
|
1209
|
-
* @internal
|
|
1210
1649
|
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1211
1650
|
*
|
|
1212
1651
|
* Pausable loading state mode.
|
|
@@ -1219,9 +1658,218 @@ declare function useSwappableTokens(args: UseSwappableTokensArgs): ReadResult<To
|
|
|
1219
1658
|
* ```
|
|
1220
1659
|
*/
|
|
1221
1660
|
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs>): PausableReadResult<Token[]>;
|
|
1222
|
-
|
|
1661
|
+
|
|
1662
|
+
type UseSwapStatusArgs = Prettify<SwapStatusRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1663
|
+
/**
|
|
1664
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1665
|
+
*
|
|
1666
|
+
* Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).
|
|
1667
|
+
*
|
|
1668
|
+
* This signature supports React Suspense:
|
|
1669
|
+
*
|
|
1670
|
+
* ```tsx
|
|
1671
|
+
* const { data } = useSwapStatus({
|
|
1672
|
+
* id: swapReceipt.id,
|
|
1673
|
+
* suspense: true,
|
|
1674
|
+
* });
|
|
1675
|
+
* ```
|
|
1676
|
+
*/
|
|
1677
|
+
declare function useSwapStatus(args: UseSwapStatusArgs & Suspendable): SuspenseResult<SwapStatus>;
|
|
1678
|
+
/**
|
|
1679
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1680
|
+
*
|
|
1681
|
+
* Pausable suspense mode.
|
|
1682
|
+
*
|
|
1683
|
+
* ```tsx
|
|
1684
|
+
* const { data } = useSwapStatus({
|
|
1685
|
+
* id: swapReceipt.id,
|
|
1686
|
+
* suspense: true,
|
|
1687
|
+
* pause: shouldPause,
|
|
1688
|
+
* });
|
|
1689
|
+
* ```
|
|
1690
|
+
*/
|
|
1691
|
+
declare function useSwapStatus(args: Pausable<UseSwapStatusArgs> & Suspendable): PausableSuspenseResult<SwapStatus>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1694
|
+
*
|
|
1695
|
+
* Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).
|
|
1696
|
+
*
|
|
1697
|
+
* ```tsx
|
|
1698
|
+
* const { data, error, loading } = useSwapStatus({
|
|
1699
|
+
* id: swapReceipt.id,
|
|
1700
|
+
* });
|
|
1701
|
+
* ```
|
|
1702
|
+
*/
|
|
1703
|
+
declare function useSwapStatus(args: UseSwapStatusArgs): ReadResult<SwapStatus>;
|
|
1704
|
+
/**
|
|
1705
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1706
|
+
*
|
|
1707
|
+
* Pausable loading state mode.
|
|
1708
|
+
*
|
|
1709
|
+
* ```tsx
|
|
1710
|
+
* const { data, error, loading, paused } = useSwapStatus({
|
|
1711
|
+
* id: swapReceipt.id,
|
|
1712
|
+
* pause: shouldPause,
|
|
1713
|
+
* });
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
declare function useSwapStatus(args: Pausable<UseSwapStatusArgs>): PausableReadResult<SwapStatus>;
|
|
1717
|
+
|
|
1718
|
+
type UseTokenSwapRequest = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1719
|
+
type TokenSwapPlan = SwapTypedData | Erc20Approval | SwapTransactionRequest;
|
|
1720
|
+
type TokenSwapHandler = (plan: TokenSwapPlan, options: SwapHandlerOptions) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1721
|
+
/**
|
|
1722
|
+
* Orchestrate the token swap execution plan.
|
|
1723
|
+
*
|
|
1724
|
+
* ```tsx
|
|
1725
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1726
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1727
|
+
*
|
|
1728
|
+
* const [swap, { loading, error }] = useTokenSwap((plan) => {
|
|
1729
|
+
* switch (plan.__typename) {
|
|
1730
|
+
* case 'Erc20Approval':
|
|
1731
|
+
* if (plan.bySignature) {
|
|
1732
|
+
* return signTypedData(plan.bySignature);
|
|
1733
|
+
* }
|
|
1734
|
+
* return sendTransaction(plan.byTransaction);
|
|
1735
|
+
*
|
|
1736
|
+
* case 'SwapTransactionRequest':
|
|
1737
|
+
* return sendTransaction(plan.transaction);
|
|
1738
|
+
*
|
|
1739
|
+
* case 'SwapTypedData':
|
|
1740
|
+
* return signTypedData(plan);
|
|
1741
|
+
* }
|
|
1742
|
+
* });
|
|
1743
|
+
*
|
|
1744
|
+
* const result = await swap({
|
|
1745
|
+
* fromQuote: {
|
|
1746
|
+
* quoteId: quote.quoteId,
|
|
1747
|
+
* },
|
|
1748
|
+
* });
|
|
1749
|
+
*
|
|
1750
|
+
* if (result.isErr()) {
|
|
1751
|
+
* console.error(result.error);
|
|
1752
|
+
* return;
|
|
1753
|
+
* }
|
|
1754
|
+
*
|
|
1755
|
+
* // result.value: SwapReceipt
|
|
1756
|
+
* ```
|
|
1757
|
+
*/
|
|
1758
|
+
declare function useTokenSwap(handler: TokenSwapHandler): UseAsyncTask<UseTokenSwapRequest, SwapReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1759
|
+
|
|
1760
|
+
type UseTokenSwapQuoteArgs = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1761
|
+
/**
|
|
1762
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1763
|
+
*
|
|
1764
|
+
* This signature supports React Suspense:
|
|
1765
|
+
*
|
|
1766
|
+
* ```tsx
|
|
1767
|
+
* const { data } = useTokenSwapQuote({
|
|
1768
|
+
* market: {
|
|
1769
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1770
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1771
|
+
* amount: bigDecimal('1000'),
|
|
1772
|
+
* kind: SwapKind.Sell,
|
|
1773
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1774
|
+
* },
|
|
1775
|
+
* chainId: chainId(1),
|
|
1776
|
+
* suspense: true,
|
|
1777
|
+
* });
|
|
1778
|
+
* ```
|
|
1779
|
+
*/
|
|
1780
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1781
|
+
/**
|
|
1782
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1783
|
+
*
|
|
1784
|
+
* Pausable suspense mode.
|
|
1785
|
+
*
|
|
1786
|
+
* ```tsx
|
|
1787
|
+
* const { data } = useTokenSwapQuote({
|
|
1788
|
+
* market: {
|
|
1789
|
+
* chainId: chainId(1),
|
|
1790
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1791
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1792
|
+
* amount: bigDecimal('1000'),
|
|
1793
|
+
* kind: SwapKind.Sell,
|
|
1794
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1795
|
+
* },
|
|
1796
|
+
* suspense: true,
|
|
1797
|
+
* pause: true,
|
|
1798
|
+
* });
|
|
1799
|
+
* ```
|
|
1800
|
+
*/
|
|
1801
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1804
|
+
*
|
|
1805
|
+
* ```tsx
|
|
1806
|
+
* const { data, error, loading } = useTokenSwapQuote({
|
|
1807
|
+
* market: {
|
|
1808
|
+
* chainId: chainId(1),
|
|
1809
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1810
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1811
|
+
* amount: bigDecimal('1000'),
|
|
1812
|
+
* kind: SwapKind.Sell,
|
|
1813
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1814
|
+
* },
|
|
1815
|
+
* });
|
|
1816
|
+
* ```
|
|
1817
|
+
*/
|
|
1818
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1821
|
+
*
|
|
1822
|
+
* Pausable loading state mode.
|
|
1823
|
+
*
|
|
1824
|
+
* ```tsx
|
|
1825
|
+
* const { data, error, loading, paused } = useTokenSwapQuote({
|
|
1826
|
+
* market: {
|
|
1827
|
+
* chainId: chainId(1),
|
|
1828
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1829
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1830
|
+
* amount: bigDecimal('1000'),
|
|
1831
|
+
* kind: SwapKind.Sell,
|
|
1832
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1833
|
+
* },
|
|
1834
|
+
* pause: true,
|
|
1835
|
+
* });
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1839
|
+
/**
|
|
1840
|
+
* Low-level hook to execute a swap quote action directly.
|
|
1841
|
+
*
|
|
1842
|
+
* @remarks
|
|
1843
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1844
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow
|
|
1845
|
+
* (e.g., in an event handler to get a fresh quote before executing a swap).
|
|
1846
|
+
*
|
|
1847
|
+
* ```ts
|
|
1848
|
+
* const [getQuote, { called, data, error, loading }] = useTokenSwapQuoteAction();
|
|
1849
|
+
*
|
|
1850
|
+
* // …
|
|
1851
|
+
*
|
|
1852
|
+
* const result = await getQuote({
|
|
1853
|
+
* market: {
|
|
1854
|
+
* chainId: chainId(1),
|
|
1855
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1856
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1857
|
+
* amount: bigDecimal('1000'),
|
|
1858
|
+
* kind: SwapKind.Sell,
|
|
1859
|
+
* },
|
|
1860
|
+
* });
|
|
1861
|
+
*
|
|
1862
|
+
* if (result.isOk()) {
|
|
1863
|
+
* console.log('Swap quote:', result.value);
|
|
1864
|
+
* } else {
|
|
1865
|
+
* console.error(result.error);
|
|
1866
|
+
* }
|
|
1867
|
+
* ```
|
|
1868
|
+
*/
|
|
1869
|
+
declare function useTokenSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<TokenSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1870
|
+
|
|
1871
|
+
type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1223
1872
|
/**
|
|
1224
|
-
* @internal
|
|
1225
1873
|
* Fetch the user's swap history for a specific chain.
|
|
1226
1874
|
*
|
|
1227
1875
|
* This signature supports React Suspense:
|
|
@@ -1229,7 +1877,7 @@ type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions>;
|
|
|
1229
1877
|
* ```tsx
|
|
1230
1878
|
* const { data } = useUserSwaps({
|
|
1231
1879
|
* chainId: chainId(1),
|
|
1232
|
-
* user: evmAddress('0x742d35cc
|
|
1880
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1233
1881
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1234
1882
|
* suspense: true,
|
|
1235
1883
|
* });
|
|
@@ -1237,7 +1885,6 @@ type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions>;
|
|
|
1237
1885
|
*/
|
|
1238
1886
|
declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseResult<PaginatedUserSwapsResult>;
|
|
1239
1887
|
/**
|
|
1240
|
-
* @internal
|
|
1241
1888
|
* Fetch the user's swap history for a specific chain.
|
|
1242
1889
|
*
|
|
1243
1890
|
* Pausable suspense mode.
|
|
@@ -1245,7 +1892,7 @@ declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseRes
|
|
|
1245
1892
|
* ```tsx
|
|
1246
1893
|
* const { data } = useUserSwaps({
|
|
1247
1894
|
* chainId: chainId(1),
|
|
1248
|
-
* user: evmAddress('0x742d35cc
|
|
1895
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1249
1896
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1250
1897
|
* suspense: true,
|
|
1251
1898
|
* pause: true,
|
|
@@ -1254,20 +1901,18 @@ declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseRes
|
|
|
1254
1901
|
*/
|
|
1255
1902
|
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs> & Suspendable): PausableSuspenseResult<PaginatedUserSwapsResult>;
|
|
1256
1903
|
/**
|
|
1257
|
-
* @internal
|
|
1258
1904
|
* Fetch the user's swap history for a specific chain.
|
|
1259
1905
|
*
|
|
1260
1906
|
* ```tsx
|
|
1261
1907
|
* const { data, error, loading } = useUserSwaps({
|
|
1262
1908
|
* chainId: chainId(1),
|
|
1263
|
-
* user: evmAddress('0x742d35cc
|
|
1909
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1264
1910
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1265
1911
|
* });
|
|
1266
1912
|
* ```
|
|
1267
1913
|
*/
|
|
1268
1914
|
declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserSwapsResult>;
|
|
1269
1915
|
/**
|
|
1270
|
-
* @internal
|
|
1271
1916
|
* Fetch the user's swap history for a specific chain.
|
|
1272
1917
|
*
|
|
1273
1918
|
* Pausable loading state mode.
|
|
@@ -1275,49 +1920,38 @@ declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserS
|
|
|
1275
1920
|
* ```tsx
|
|
1276
1921
|
* const { data, error, loading, paused } = useUserSwaps({
|
|
1277
1922
|
* chainId: chainId(1),
|
|
1278
|
-
* user: evmAddress('0x742d35cc
|
|
1923
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1279
1924
|
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1280
1925
|
* pause: true,
|
|
1281
1926
|
* });
|
|
1282
1927
|
* ```
|
|
1283
1928
|
*/
|
|
1284
1929
|
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs>): PausableReadResult<PaginatedUserSwapsResult>;
|
|
1285
|
-
|
|
1286
|
-
type
|
|
1287
|
-
type SwapHandlerOptions = {
|
|
1288
|
-
cancel: CancelOperation;
|
|
1289
|
-
};
|
|
1290
|
-
type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAsync<ERC20PermitSignature | SwapReceipt, SendTransactionError | PendingTransactionError>;
|
|
1930
|
+
|
|
1931
|
+
type UseWithdrawSwapRequest = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1291
1932
|
/**
|
|
1292
|
-
*
|
|
1293
|
-
* Orchestrate the swap execution plan.
|
|
1933
|
+
* Orchestrate the withdraw swap execution plan.
|
|
1294
1934
|
*
|
|
1295
1935
|
* ```tsx
|
|
1296
|
-
* const [
|
|
1297
|
-
* const [signSwapByIntentWith, signing] = useSignSwapByIntentWith(wallet);
|
|
1936
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1298
1937
|
*
|
|
1299
|
-
* const [
|
|
1938
|
+
* const [withdrawSwap, { loading, error }] = useWithdrawSwap((plan) => {
|
|
1300
1939
|
* switch (plan.__typename) {
|
|
1301
|
-
* case '
|
|
1302
|
-
*
|
|
1940
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1941
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1942
|
+
* return signTypedData(plan.bySignature);
|
|
1303
1943
|
*
|
|
1304
|
-
* case '
|
|
1305
|
-
*
|
|
1306
|
-
* return sendTransaction(plan.transaction);
|
|
1307
|
-
*
|
|
1308
|
-
* case 'SwapTransactionRequest':
|
|
1309
|
-
* return sendTransaction(plan.transaction);
|
|
1944
|
+
* case 'SwapTypedData':
|
|
1945
|
+
* return signTypedData(plan);
|
|
1310
1946
|
* }
|
|
1311
1947
|
* });
|
|
1312
1948
|
*
|
|
1313
|
-
* const result = await
|
|
1949
|
+
* const result = await withdrawSwap({
|
|
1314
1950
|
* market: {
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1951
|
+
* position: userSupplyItem.id,
|
|
1952
|
+
* buyToken: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1318
1953
|
* amount: bigDecimal('1000'),
|
|
1319
|
-
*
|
|
1320
|
-
* user: evmAddress('0x742d35cc...'),
|
|
1954
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1321
1955
|
* },
|
|
1322
1956
|
* });
|
|
1323
1957
|
*
|
|
@@ -1329,99 +1963,191 @@ type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAs
|
|
|
1329
1963
|
* // result.value: SwapReceipt
|
|
1330
1964
|
* ```
|
|
1331
1965
|
*/
|
|
1332
|
-
declare function
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1966
|
+
declare function useWithdrawSwap(handler: PositionSwapHandler): UseAsyncTask<WithdrawSwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1967
|
+
|
|
1968
|
+
type UseWithdrawSwapQuoteArgs = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1969
|
+
/**
|
|
1970
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
1971
|
+
*
|
|
1972
|
+
* This signature supports React Suspense:
|
|
1973
|
+
*
|
|
1974
|
+
* ```tsx
|
|
1975
|
+
* const { data } = useWithdrawSwapQuote({
|
|
1976
|
+
* market: {
|
|
1977
|
+
* position: userSupplyItem.id,
|
|
1978
|
+
* buyReserve: reserve.id,
|
|
1979
|
+
* amount: bigDecimal('1000'),
|
|
1980
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1981
|
+
* },
|
|
1982
|
+
* suspense: true,
|
|
1983
|
+
* });
|
|
1984
|
+
* ```
|
|
1985
|
+
*/
|
|
1986
|
+
declare function useWithdrawSwapQuote(args: UseWithdrawSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1987
|
+
/**
|
|
1988
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
1989
|
+
*
|
|
1990
|
+
* Pausable suspense mode.
|
|
1991
|
+
*
|
|
1992
|
+
* ```tsx
|
|
1993
|
+
* const { data } = useWithdrawSwapQuote({
|
|
1994
|
+
* market: {
|
|
1995
|
+
* position: userSupplyItem.id,
|
|
1996
|
+
* buyReserve: reserve.id,
|
|
1997
|
+
* amount: bigDecimal('1000'),
|
|
1998
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1999
|
+
* },
|
|
2000
|
+
* suspense: true,
|
|
2001
|
+
* pause: true,
|
|
2002
|
+
* });
|
|
2003
|
+
* ```
|
|
2004
|
+
*/
|
|
2005
|
+
declare function useWithdrawSwapQuote(args: Pausable<UseWithdrawSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
2006
|
+
/**
|
|
2007
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2008
|
+
*
|
|
2009
|
+
* ```tsx
|
|
2010
|
+
* const { data, error, loading } = useWithdrawSwapQuote({
|
|
2011
|
+
* market: {
|
|
2012
|
+
* position: userSupplyItem.id,
|
|
2013
|
+
* buyReserve: reserve.id,
|
|
2014
|
+
* amount: bigDecimal('1000'),
|
|
2015
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2016
|
+
* },
|
|
2017
|
+
* });
|
|
2018
|
+
* ```
|
|
2019
|
+
*/
|
|
2020
|
+
declare function useWithdrawSwapQuote(args: UseWithdrawSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
2021
|
+
/**
|
|
2022
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2023
|
+
*
|
|
2024
|
+
* Pausable loading state mode.
|
|
2025
|
+
*
|
|
2026
|
+
* ```tsx
|
|
2027
|
+
* const { data, error, loading, paused } = useWithdrawSwapQuote({
|
|
2028
|
+
* market: {
|
|
2029
|
+
* position: userSupplyItem.id,
|
|
2030
|
+
* buyReserve: reserve.id,
|
|
2031
|
+
* amount: bigDecimal('1000'),
|
|
2032
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2033
|
+
* },
|
|
2034
|
+
* pause: true,
|
|
2035
|
+
* });
|
|
2036
|
+
* ```
|
|
2037
|
+
*/
|
|
2038
|
+
declare function useWithdrawSwapQuote(args: Pausable<UseWithdrawSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1338
2039
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
2040
|
+
* Low-level hook to execute a withdraw swap quote action directly.
|
|
1341
2041
|
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
2042
|
+
* @remarks
|
|
2043
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
2044
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1345
2045
|
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
* case 'TransactionRequest':
|
|
1349
|
-
* return sendTransaction(plan);
|
|
2046
|
+
* ```ts
|
|
2047
|
+
* const [getQuote, { called, data, error, loading }] = useWithdrawSwapQuoteAction();
|
|
1350
2048
|
*
|
|
1351
|
-
*
|
|
1352
|
-
* return signSwapCancelWith(plan);
|
|
1353
|
-
* }
|
|
1354
|
-
* });
|
|
2049
|
+
* // …
|
|
1355
2050
|
*
|
|
1356
|
-
* const result = await
|
|
1357
|
-
*
|
|
2051
|
+
* const result = await getQuote({
|
|
2052
|
+
* position: userSupplyItem.id,
|
|
2053
|
+
* buyReserve: reserve.id,
|
|
2054
|
+
* amount: bigDecimal('1000'),
|
|
2055
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1358
2056
|
* });
|
|
1359
2057
|
*
|
|
1360
|
-
* if (result.
|
|
2058
|
+
* if (result.isOk()) {
|
|
2059
|
+
* console.log('Withdraw swap quote:', result.value);
|
|
2060
|
+
* } else {
|
|
1361
2061
|
* console.error(result.error);
|
|
1362
|
-
* return;
|
|
1363
2062
|
* }
|
|
1364
|
-
*
|
|
1365
|
-
* // result.value: SwapCancelled
|
|
1366
|
-
* console.log('Swap cancelled:', result.value);
|
|
1367
2063
|
* ```
|
|
1368
2064
|
*/
|
|
1369
|
-
declare function
|
|
2065
|
+
declare function useWithdrawSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<WithdrawSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1370
2066
|
|
|
2067
|
+
type UseActivitiesArgs = Prettify<ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1371
2068
|
/**
|
|
1372
|
-
*
|
|
2069
|
+
* Fetch paginated list of activities.
|
|
1373
2070
|
*
|
|
1374
|
-
*
|
|
1375
|
-
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1376
|
-
* const [supply, { loading, error }] = useSupply((plan, { cancel }) => {
|
|
1377
|
-
* switch (plan.__typename) {
|
|
1378
|
-
* case 'TransactionRequest':
|
|
1379
|
-
* return sendTransaction(plan);
|
|
1380
|
-
* case 'Erc20ApprovalRequired':
|
|
1381
|
-
* case 'PreContractActionRequired':
|
|
1382
|
-
* return sendTransaction(plan.transaction);
|
|
1383
|
-
* }
|
|
1384
|
-
* });
|
|
2071
|
+
* This signature supports React Suspense:
|
|
1385
2072
|
*
|
|
1386
|
-
*
|
|
2073
|
+
* ```tsx
|
|
2074
|
+
* const { data } = useActivities({
|
|
2075
|
+
* query: {
|
|
2076
|
+
* chainId: chainId(1),
|
|
2077
|
+
* },
|
|
2078
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2079
|
+
* suspense: true,
|
|
2080
|
+
* });
|
|
1387
2081
|
*
|
|
1388
|
-
*
|
|
2082
|
+
* // data.items: ActivityItem[]
|
|
2083
|
+
* ```
|
|
2084
|
+
*/
|
|
2085
|
+
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2086
|
+
/**
|
|
2087
|
+
* Fetch paginated list of activities.
|
|
1389
2088
|
*
|
|
1390
|
-
*
|
|
1391
|
-
* switch (result.error.name) {
|
|
1392
|
-
* case 'CancelError':
|
|
1393
|
-
* // The user cancelled the operation
|
|
1394
|
-
* return;
|
|
2089
|
+
* Pausable suspense mode.
|
|
1395
2090
|
*
|
|
1396
|
-
*
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
2091
|
+
* ```tsx
|
|
2092
|
+
* const { data } = useActivities({
|
|
2093
|
+
* query: {
|
|
2094
|
+
* chainId: chainId(1),
|
|
2095
|
+
* },
|
|
2096
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2097
|
+
* suspense: true,
|
|
2098
|
+
* pause: true,
|
|
2099
|
+
* });
|
|
1399
2100
|
*
|
|
1400
|
-
*
|
|
1401
|
-
*
|
|
1402
|
-
|
|
2101
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2102
|
+
* ```
|
|
2103
|
+
*/
|
|
2104
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2105
|
+
/**
|
|
2106
|
+
* Fetch paginated list of activities.
|
|
1403
2107
|
*
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
2108
|
+
* ```tsx
|
|
2109
|
+
* const { data, error, loading } = useActivities({
|
|
2110
|
+
* query: {
|
|
2111
|
+
* chainId: chainId(1),
|
|
2112
|
+
* },
|
|
2113
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2114
|
+
* });
|
|
2115
|
+
* ```
|
|
2116
|
+
*/
|
|
2117
|
+
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Fetch paginated list of activities.
|
|
1407
2120
|
*
|
|
1408
|
-
*
|
|
1409
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1410
|
-
* break;
|
|
2121
|
+
* Pausable loading state mode.
|
|
1411
2122
|
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
2123
|
+
* ```tsx
|
|
2124
|
+
* const { data, error, loading } = useActivities({
|
|
2125
|
+
* query: {
|
|
2126
|
+
* chainId: chainId(1),
|
|
2127
|
+
* },
|
|
2128
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2129
|
+
* pause: true,
|
|
2130
|
+
* });
|
|
1418
2131
|
*
|
|
1419
|
-
*
|
|
2132
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2133
|
+
* // error: UnexpectedError | undefined
|
|
2134
|
+
* // loading: boolean | undefined
|
|
1420
2135
|
* ```
|
|
2136
|
+
*/
|
|
2137
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2138
|
+
/**
|
|
2139
|
+
* Low-level hook to execute a {@link activities} action directly.
|
|
1421
2140
|
*
|
|
1422
|
-
* @
|
|
2141
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2142
|
+
* @remarks
|
|
2143
|
+
* This hook does not actively watch for updates. Use it to fetch activities on demand
|
|
2144
|
+
* (e.g., in an event handler when paginating or refining filters).
|
|
2145
|
+
*
|
|
2146
|
+
* @param options - The query options.
|
|
2147
|
+
* @returns The user history.
|
|
1423
2148
|
*/
|
|
1424
|
-
declare function
|
|
2149
|
+
declare function useActivitiesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError>;
|
|
2150
|
+
|
|
1425
2151
|
/**
|
|
1426
2152
|
* A hook that provides a way to borrow assets from an Aave reserve.
|
|
1427
2153
|
*
|
|
@@ -1431,7 +2157,7 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1431
2157
|
* switch (plan.__typename) {
|
|
1432
2158
|
* case 'TransactionRequest':
|
|
1433
2159
|
* return sendTransaction(plan);
|
|
1434
|
-
*
|
|
2160
|
+
*
|
|
1435
2161
|
* case 'PreContractActionRequired':
|
|
1436
2162
|
* return sendTransaction(plan.transaction);
|
|
1437
2163
|
* }
|
|
@@ -1470,30 +2196,27 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1470
2196
|
* return;
|
|
1471
2197
|
* }
|
|
1472
2198
|
*
|
|
1473
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2199
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1474
2200
|
* ```
|
|
1475
2201
|
*
|
|
1476
2202
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1477
2203
|
*/
|
|
1478
|
-
declare function useBorrow(handler:
|
|
2204
|
+
declare function useBorrow(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<BorrowRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2205
|
+
|
|
1479
2206
|
/**
|
|
1480
|
-
* A hook that provides a way to
|
|
2207
|
+
* A hook that provides a way to claim rewards.
|
|
1481
2208
|
*
|
|
1482
2209
|
* ```ts
|
|
1483
2210
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1484
|
-
* const [
|
|
1485
|
-
*
|
|
1486
|
-
* case 'TransactionRequest':
|
|
1487
|
-
* return sendTransaction(plan);
|
|
1488
|
-
* case 'Erc20ApprovalRequired':
|
|
1489
|
-
* case 'PreContractActionRequired':
|
|
1490
|
-
* return sendTransaction(plan.transaction);
|
|
1491
|
-
* }
|
|
2211
|
+
* const [claim, { loading, error }] = useClaimRewards((transaction, { cancel }) => {
|
|
2212
|
+
* return sendTransaction(transaction);
|
|
1492
2213
|
* });
|
|
1493
2214
|
*
|
|
1494
2215
|
* // …
|
|
1495
2216
|
*
|
|
1496
|
-
* const result = await
|
|
2217
|
+
* const result = await claim({
|
|
2218
|
+
* ids: [rewardId('abc123')],
|
|
2219
|
+
* });
|
|
1497
2220
|
*
|
|
1498
2221
|
* if (result.isErr()) {
|
|
1499
2222
|
* switch (result.error.name) {
|
|
@@ -1513,10 +2236,6 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1513
2236
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1514
2237
|
* break;
|
|
1515
2238
|
*
|
|
1516
|
-
* case 'ValidationError':
|
|
1517
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1518
|
-
* break;
|
|
1519
|
-
*
|
|
1520
2239
|
* case 'UnexpectedError':
|
|
1521
2240
|
* console.error(result.error.message);
|
|
1522
2241
|
* break;
|
|
@@ -1524,22 +2243,26 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1524
2243
|
* return;
|
|
1525
2244
|
* }
|
|
1526
2245
|
*
|
|
1527
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2246
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1528
2247
|
* ```
|
|
1529
2248
|
*
|
|
1530
|
-
* @param handler - The handler that will be used to handle the
|
|
2249
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1531
2250
|
*/
|
|
1532
|
-
declare function
|
|
2251
|
+
declare function useClaimRewards(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<ClaimRewardsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2252
|
+
|
|
1533
2253
|
/**
|
|
1534
|
-
* A hook that provides a way to
|
|
2254
|
+
* A hook that provides a way to liquidate a user's position.
|
|
1535
2255
|
*
|
|
1536
2256
|
* ```ts
|
|
1537
2257
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1538
|
-
* const [
|
|
2258
|
+
* const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {
|
|
1539
2259
|
* switch (plan.__typename) {
|
|
1540
2260
|
* case 'TransactionRequest':
|
|
1541
2261
|
* return sendTransaction(plan);
|
|
1542
|
-
*
|
|
2262
|
+
*
|
|
2263
|
+
* case 'Erc20Approval':
|
|
2264
|
+
* return sendTransaction(plan.byTransaction);
|
|
2265
|
+
*
|
|
1543
2266
|
* case 'PreContractActionRequired':
|
|
1544
2267
|
* return sendTransaction(plan.transaction);
|
|
1545
2268
|
* }
|
|
@@ -1547,7 +2270,13 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1547
2270
|
*
|
|
1548
2271
|
* // …
|
|
1549
2272
|
*
|
|
1550
|
-
* const result = await
|
|
2273
|
+
* const result = await liquidatePosition({
|
|
2274
|
+
* collateral: reserveId('SGVsbG8h'),
|
|
2275
|
+
* debt: reserveId('Q2lhbyE= '),
|
|
2276
|
+
* amount: amount,
|
|
2277
|
+
* liquidator: liquidator,
|
|
2278
|
+
* borrower: borrower,
|
|
2279
|
+
* });
|
|
1551
2280
|
*
|
|
1552
2281
|
* if (result.isErr()) {
|
|
1553
2282
|
* switch (result.error.name) {
|
|
@@ -1578,156 +2307,153 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1578
2307
|
* return;
|
|
1579
2308
|
* }
|
|
1580
2309
|
*
|
|
1581
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2310
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1582
2311
|
* ```
|
|
1583
2312
|
*
|
|
1584
2313
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1585
2314
|
*/
|
|
1586
|
-
declare function
|
|
2315
|
+
declare function useLiquidatePosition(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, PendingTransaction | Signature>): UseAsyncTask<LiquidatePositionRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2316
|
+
|
|
1587
2317
|
/**
|
|
1588
|
-
*
|
|
2318
|
+
* Preview the impact of a potential action on a user's position.
|
|
1589
2319
|
*
|
|
1590
|
-
* ```
|
|
1591
|
-
* const [
|
|
1592
|
-
*
|
|
2320
|
+
* ```tsx
|
|
2321
|
+
* const [getPreview, previewing] = usePreviewAction();
|
|
2322
|
+
*
|
|
2323
|
+
* const loading = previewing.loading;
|
|
2324
|
+
* const error = previewing.error;
|
|
1593
2325
|
*
|
|
1594
2326
|
* // …
|
|
1595
2327
|
*
|
|
1596
|
-
* const result = await
|
|
2328
|
+
* const result = await getPreview({
|
|
2329
|
+
* action: {
|
|
2330
|
+
* supply: {
|
|
2331
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2332
|
+
* amount: {
|
|
2333
|
+
* erc20: {
|
|
2334
|
+
* value: '1000',
|
|
2335
|
+
* },
|
|
2336
|
+
* },
|
|
2337
|
+
* sender: evmAddress('0x9abc…'),
|
|
2338
|
+
* },
|
|
2339
|
+
* },
|
|
2340
|
+
* });
|
|
1597
2341
|
*
|
|
1598
2342
|
* if (result.isErr()) {
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1602
|
-
* return;
|
|
2343
|
+
* console.error(result.error);
|
|
2344
|
+
* return;
|
|
2345
|
+
* }
|
|
1603
2346
|
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
|
|
2347
|
+
* console.log('Preview result:', result.value);
|
|
2348
|
+
* ```
|
|
2349
|
+
*/
|
|
2350
|
+
declare function usePreviewAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError>;
|
|
2351
|
+
type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
|
|
2352
|
+
/**
|
|
2353
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1607
2354
|
*
|
|
1608
|
-
*
|
|
1609
|
-
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1610
|
-
* break;
|
|
2355
|
+
* This signature supports React Suspense:
|
|
1611
2356
|
*
|
|
1612
|
-
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
2357
|
+
* ```tsx
|
|
2358
|
+
* const { data } = usePreview({
|
|
2359
|
+
* action: {
|
|
2360
|
+
* supply: {
|
|
2361
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2362
|
+
* amount: {
|
|
2363
|
+
* erc20: {
|
|
2364
|
+
* currency: evmAddress('0x5678…'),
|
|
2365
|
+
* value: '1000',
|
|
2366
|
+
* },
|
|
2367
|
+
* },
|
|
2368
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2369
|
+
* },
|
|
2370
|
+
* },
|
|
2371
|
+
* suspense: true,
|
|
2372
|
+
* });
|
|
2373
|
+
* ```
|
|
2374
|
+
*/
|
|
2375
|
+
declare function usePreview(args: UsePreviewArgs & Suspendable): SuspenseResult<PreviewUserPosition>;
|
|
2376
|
+
/**
|
|
2377
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1615
2378
|
*
|
|
1616
|
-
*
|
|
1617
|
-
* console.error(result.error.message);
|
|
1618
|
-
* break;
|
|
1619
|
-
* }
|
|
1620
|
-
* return;
|
|
1621
|
-
* }
|
|
2379
|
+
* Pausable suspense mode.
|
|
1622
2380
|
*
|
|
1623
|
-
*
|
|
2381
|
+
* ```tsx
|
|
2382
|
+
* const { data } = usePreview({
|
|
2383
|
+
* action: {
|
|
2384
|
+
* supply: {
|
|
2385
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2386
|
+
* amount: {
|
|
2387
|
+
* erc20: {
|
|
2388
|
+
* currency: evmAddress('0x5678…'),
|
|
2389
|
+
* value: '1000',
|
|
2390
|
+
* },
|
|
2391
|
+
* },
|
|
2392
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2393
|
+
* },
|
|
2394
|
+
* },
|
|
2395
|
+
* suspense: true,
|
|
2396
|
+
* pause: true,
|
|
2397
|
+
* });
|
|
1624
2398
|
* ```
|
|
1625
|
-
*
|
|
1626
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1627
2399
|
*/
|
|
1628
|
-
declare function
|
|
2400
|
+
declare function usePreview(args: Pausable<UsePreviewArgs> & Suspendable): PausableSuspenseResult<PreviewUserPosition>;
|
|
1629
2401
|
/**
|
|
1630
|
-
*
|
|
2402
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1631
2403
|
*
|
|
1632
|
-
* ```
|
|
1633
|
-
* const
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
2404
|
+
* ```tsx
|
|
2405
|
+
* const { data, error, loading } = usePreview({
|
|
2406
|
+
* action: {
|
|
2407
|
+
* supply: {
|
|
2408
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2409
|
+
* amount: {
|
|
2410
|
+
* erc20: {
|
|
2411
|
+
* currency: evmAddress('0x5678…'),
|
|
2412
|
+
* value: '1000',
|
|
2413
|
+
* },
|
|
2414
|
+
* },
|
|
2415
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2416
|
+
* },
|
|
2417
|
+
* },
|
|
1636
2418
|
* });
|
|
1637
|
-
*
|
|
1638
|
-
* // …
|
|
1639
|
-
*
|
|
1640
|
-
* const result = await updateUserRiskPremium({ ... });
|
|
1641
|
-
*
|
|
1642
|
-
* if (result.isErr()) {
|
|
1643
|
-
* switch (result.error.name) {
|
|
1644
|
-
* case 'CancelError':
|
|
1645
|
-
* // The user cancelled the operation
|
|
1646
|
-
* return;
|
|
1647
|
-
*
|
|
1648
|
-
* case 'SigningError':
|
|
1649
|
-
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1650
|
-
* break;
|
|
1651
|
-
*
|
|
1652
|
-
* case 'TimeoutError':
|
|
1653
|
-
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1654
|
-
* break;
|
|
1655
|
-
*
|
|
1656
|
-
* case 'TransactionError':
|
|
1657
|
-
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1658
|
-
* break;
|
|
1659
|
-
*
|
|
1660
|
-
* case 'UnexpectedError':
|
|
1661
|
-
* console.error(result.error.message);
|
|
1662
|
-
* break;
|
|
1663
|
-
* }
|
|
1664
|
-
* return;
|
|
1665
|
-
* }
|
|
1666
|
-
*
|
|
1667
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
1668
2419
|
* ```
|
|
1669
|
-
*
|
|
1670
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1671
2420
|
*/
|
|
1672
|
-
declare function
|
|
2421
|
+
declare function usePreview(args: UsePreviewArgs): ReadResult<PreviewUserPosition>;
|
|
1673
2422
|
/**
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
* ```ts
|
|
1677
|
-
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1678
|
-
* const [updateUserDynamicConfig, { loading, error }] = useUpdateUserDynamicConfig((transaction, { cancel }) => {
|
|
1679
|
-
* return sendTransaction(transaction);
|
|
1680
|
-
* });
|
|
1681
|
-
*
|
|
1682
|
-
* // …
|
|
1683
|
-
*
|
|
1684
|
-
* const result = await updateUserDynamicConfig({ ... });
|
|
1685
|
-
*
|
|
1686
|
-
* if (result.isErr()) {
|
|
1687
|
-
* switch (result.error.name) {
|
|
1688
|
-
* case 'CancelError':
|
|
1689
|
-
* // The user cancelled the operation
|
|
1690
|
-
* return;
|
|
1691
|
-
*
|
|
1692
|
-
* case 'SigningError':
|
|
1693
|
-
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1694
|
-
* break;
|
|
1695
|
-
*
|
|
1696
|
-
* case 'TimeoutError':
|
|
1697
|
-
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1698
|
-
* break;
|
|
1699
|
-
*
|
|
1700
|
-
* case 'TransactionError':
|
|
1701
|
-
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1702
|
-
* break;
|
|
2423
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1703
2424
|
*
|
|
1704
|
-
*
|
|
1705
|
-
* console.error(result.error.message);
|
|
1706
|
-
* break;
|
|
1707
|
-
* }
|
|
1708
|
-
* return;
|
|
1709
|
-
* }
|
|
2425
|
+
* Pausable loading state mode.
|
|
1710
2426
|
*
|
|
1711
|
-
*
|
|
2427
|
+
* ```tsx
|
|
2428
|
+
* const { data, error, loading, paused } = usePreview({
|
|
2429
|
+
* action: {
|
|
2430
|
+
* supply: {
|
|
2431
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2432
|
+
* amount: {
|
|
2433
|
+
* erc20: {
|
|
2434
|
+
* currency: evmAddress('0x5678…'),
|
|
2435
|
+
* value: '1000',
|
|
2436
|
+
* },
|
|
2437
|
+
* },
|
|
2438
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2439
|
+
* },
|
|
2440
|
+
* },
|
|
2441
|
+
* pause: true,
|
|
2442
|
+
* });
|
|
1712
2443
|
* ```
|
|
1713
|
-
*
|
|
1714
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1715
2444
|
*/
|
|
1716
|
-
declare function
|
|
2445
|
+
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2446
|
+
|
|
1717
2447
|
/**
|
|
1718
|
-
*
|
|
2448
|
+
* A hook that provides a way to renounce a position manager of a user for a specific spoke.
|
|
1719
2449
|
*
|
|
1720
2450
|
* ```ts
|
|
1721
2451
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1722
|
-
* const [
|
|
1723
|
-
* return sendTransaction(transaction);
|
|
1724
|
-
* });
|
|
2452
|
+
* const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);
|
|
1725
2453
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
* enableCollateral: true,
|
|
1730
|
-
* });
|
|
2454
|
+
* // …
|
|
2455
|
+
*
|
|
2456
|
+
* const result = await renounceSpokeUserPositionManager({ ... });
|
|
1731
2457
|
*
|
|
1732
2458
|
* if (result.isErr()) {
|
|
1733
2459
|
* switch (result.error.name) {
|
|
@@ -1754,22 +2480,26 @@ declare function useUpdateUserDynamicConfig(handler: TransactionHandler): UseAsy
|
|
|
1754
2480
|
* return;
|
|
1755
2481
|
* }
|
|
1756
2482
|
*
|
|
1757
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2483
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1758
2484
|
* ```
|
|
1759
2485
|
*
|
|
1760
2486
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1761
2487
|
*/
|
|
1762
|
-
declare function
|
|
2488
|
+
declare function useRenounceSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<RenounceSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2489
|
+
|
|
1763
2490
|
/**
|
|
1764
|
-
* A hook that provides a way to
|
|
2491
|
+
* A hook that provides a way to repay borrowed assets to an Aave reserve.
|
|
1765
2492
|
*
|
|
1766
2493
|
* ```ts
|
|
1767
2494
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1768
|
-
* const [
|
|
2495
|
+
* const [repay, { loading, error }] = useRepay((plan, { cancel }) => {
|
|
1769
2496
|
* switch (plan.__typename) {
|
|
1770
2497
|
* case 'TransactionRequest':
|
|
1771
2498
|
* return sendTransaction(plan);
|
|
1772
|
-
*
|
|
2499
|
+
*
|
|
2500
|
+
* case 'Erc20Approval':
|
|
2501
|
+
* return sendTransaction(plan.byTransaction);
|
|
2502
|
+
*
|
|
1773
2503
|
* case 'PreContractActionRequired':
|
|
1774
2504
|
* return sendTransaction(plan.transaction);
|
|
1775
2505
|
* }
|
|
@@ -1777,13 +2507,7 @@ declare function useSetUserSupplyAsCollateral(handler: TransactionHandler): UseA
|
|
|
1777
2507
|
*
|
|
1778
2508
|
* // …
|
|
1779
2509
|
*
|
|
1780
|
-
* const result = await
|
|
1781
|
-
* collateral: reserveId('SGVsbG8h'),
|
|
1782
|
-
* debt: reserveId('Q2lhbyE= '),
|
|
1783
|
-
* amount: amount,
|
|
1784
|
-
* liquidator: liquidator,
|
|
1785
|
-
* borrower: borrower,
|
|
1786
|
-
* });
|
|
2510
|
+
* const result = await repay({ ... });
|
|
1787
2511
|
*
|
|
1788
2512
|
* if (result.isErr()) {
|
|
1789
2513
|
* switch (result.error.name) {
|
|
@@ -1814,12 +2538,13 @@ declare function useSetUserSupplyAsCollateral(handler: TransactionHandler): UseA
|
|
|
1814
2538
|
* return;
|
|
1815
2539
|
* }
|
|
1816
2540
|
*
|
|
1817
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2541
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1818
2542
|
* ```
|
|
1819
2543
|
*
|
|
1820
2544
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1821
2545
|
*/
|
|
1822
|
-
declare function
|
|
2546
|
+
declare function useRepay(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<RepayRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2547
|
+
|
|
1823
2548
|
/**
|
|
1824
2549
|
* A hook that provides a way to set or remove a position manager for a user on a specific spoke.
|
|
1825
2550
|
*
|
|
@@ -1876,226 +2601,226 @@ declare function useLiquidatePosition(handler: TransactionHandler): UseAsyncTask
|
|
|
1876
2601
|
* return;
|
|
1877
2602
|
* }
|
|
1878
2603
|
*
|
|
1879
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2604
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1880
2605
|
* ```
|
|
1881
2606
|
*
|
|
1882
2607
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1883
2608
|
*/
|
|
1884
|
-
declare function useSetSpokeUserPositionManager(handler:
|
|
2609
|
+
declare function useSetSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2610
|
+
|
|
1885
2611
|
/**
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1888
|
-
* ```tsx
|
|
1889
|
-
* const [getPreview, previewing] = usePreviewAction();
|
|
1890
|
-
*
|
|
1891
|
-
* const loading = previewing.loading;
|
|
1892
|
-
* const error = previewing.error;
|
|
2612
|
+
* Hook for updating the collateral status of user's supplies.
|
|
1893
2613
|
*
|
|
1894
|
-
*
|
|
2614
|
+
* ```ts
|
|
2615
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2616
|
+
* const [setUserSuppliesAsCollateral, { loading, error }] = useSetUserSuppliesAsCollateral((transaction, { cancel }) => {
|
|
2617
|
+
* return sendTransaction(transaction);
|
|
2618
|
+
* });
|
|
1895
2619
|
*
|
|
1896
|
-
* const result = await
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
* reserve:
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
* },
|
|
1905
|
-
* sender: evmAddress('0x9abc…'),
|
|
1906
|
-
* },
|
|
1907
|
-
* },
|
|
2620
|
+
* const result = await setUserSuppliesAsCollateral({
|
|
2621
|
+
* changes: [
|
|
2622
|
+
* {
|
|
2623
|
+
* reserve: reserve.id,
|
|
2624
|
+
* enableCollateral: true
|
|
2625
|
+
* }
|
|
2626
|
+
* ],
|
|
2627
|
+
* sender: evmAddress('0x456...')
|
|
1908
2628
|
* });
|
|
1909
2629
|
*
|
|
1910
2630
|
* if (result.isErr()) {
|
|
1911
|
-
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1915
|
-
* console.log('Preview result:', result.value);
|
|
1916
|
-
* ```
|
|
1917
|
-
*/
|
|
1918
|
-
declare function usePreviewAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError>;
|
|
1919
|
-
type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
|
|
1920
|
-
/**
|
|
1921
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1922
|
-
*
|
|
1923
|
-
* This signature supports React Suspense:
|
|
1924
|
-
*
|
|
1925
|
-
* ```tsx
|
|
1926
|
-
* const { data } = usePreview({
|
|
1927
|
-
* action: {
|
|
1928
|
-
* supply: {
|
|
1929
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1930
|
-
* amount: {
|
|
1931
|
-
* erc20: {
|
|
1932
|
-
* currency: evmAddress('0x5678…'),
|
|
1933
|
-
* value: '1000',
|
|
1934
|
-
* },
|
|
1935
|
-
* },
|
|
1936
|
-
* supplier: evmAddress('0x9abc…'),
|
|
1937
|
-
* },
|
|
1938
|
-
* },
|
|
1939
|
-
* suspense: true,
|
|
1940
|
-
* });
|
|
1941
|
-
* ```
|
|
1942
|
-
*/
|
|
1943
|
-
declare function usePreview(args: UsePreviewArgs & Suspendable): SuspenseResult<PreviewUserPosition>;
|
|
1944
|
-
/**
|
|
1945
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2631
|
+
* switch (result.error.name) {
|
|
2632
|
+
* case 'CancelError':
|
|
2633
|
+
* // The user cancelled the operation
|
|
2634
|
+
* return;
|
|
1946
2635
|
*
|
|
1947
|
-
*
|
|
2636
|
+
* case 'SigningError':
|
|
2637
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2638
|
+
* break;
|
|
1948
2639
|
*
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
*
|
|
1952
|
-
* supply: {
|
|
1953
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1954
|
-
* amount: {
|
|
1955
|
-
* erc20: {
|
|
1956
|
-
* currency: evmAddress('0x5678…'),
|
|
1957
|
-
* value: '1000',
|
|
1958
|
-
* },
|
|
1959
|
-
* },
|
|
1960
|
-
* supplier: evmAddress('0x9abc…'),
|
|
1961
|
-
* },
|
|
1962
|
-
* },
|
|
1963
|
-
* suspense: true,
|
|
1964
|
-
* pause: true,
|
|
1965
|
-
* });
|
|
1966
|
-
* ```
|
|
1967
|
-
*/
|
|
1968
|
-
declare function usePreview(args: Pausable<UsePreviewArgs> & Suspendable): PausableSuspenseResult<PreviewUserPosition>;
|
|
1969
|
-
/**
|
|
1970
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2640
|
+
* case 'TimeoutError':
|
|
2641
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2642
|
+
* break;
|
|
1971
2643
|
*
|
|
1972
|
-
*
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1975
|
-
* supply: {
|
|
1976
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
1977
|
-
* amount: {
|
|
1978
|
-
* erc20: {
|
|
1979
|
-
* currency: evmAddress('0x5678…'),
|
|
1980
|
-
* value: '1000',
|
|
1981
|
-
* },
|
|
1982
|
-
* },
|
|
1983
|
-
* supplier: evmAddress('0x9abc…'),
|
|
1984
|
-
* },
|
|
1985
|
-
* },
|
|
1986
|
-
* });
|
|
1987
|
-
* ```
|
|
1988
|
-
*/
|
|
1989
|
-
declare function usePreview(args: UsePreviewArgs): ReadResult<PreviewUserPosition>;
|
|
1990
|
-
/**
|
|
1991
|
-
* Fetch a preview of the impact of a potential action on a user's position.
|
|
2644
|
+
* case 'TransactionError':
|
|
2645
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2646
|
+
* break;
|
|
1992
2647
|
*
|
|
1993
|
-
*
|
|
2648
|
+
* case 'UnexpectedError':
|
|
2649
|
+
* console.error(result.error.message);
|
|
2650
|
+
* break;
|
|
2651
|
+
* }
|
|
2652
|
+
* return;
|
|
2653
|
+
* }
|
|
1994
2654
|
*
|
|
1995
|
-
*
|
|
1996
|
-
* const { data, error, loading, paused } = usePreview({
|
|
1997
|
-
* action: {
|
|
1998
|
-
* supply: {
|
|
1999
|
-
* reserve: reserveId('SGVsbG8h'),
|
|
2000
|
-
* amount: {
|
|
2001
|
-
* erc20: {
|
|
2002
|
-
* currency: evmAddress('0x5678…'),
|
|
2003
|
-
* value: '1000',
|
|
2004
|
-
* },
|
|
2005
|
-
* },
|
|
2006
|
-
* supplier: evmAddress('0x9abc…'),
|
|
2007
|
-
* },
|
|
2008
|
-
* },
|
|
2009
|
-
* pause: true,
|
|
2010
|
-
* });
|
|
2655
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2011
2656
|
* ```
|
|
2657
|
+
*
|
|
2658
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2012
2659
|
*/
|
|
2013
|
-
declare function
|
|
2014
|
-
|
|
2660
|
+
declare function useSetUserSuppliesAsCollateral(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetUserSuppliesAsCollateralRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2661
|
+
|
|
2015
2662
|
/**
|
|
2016
|
-
*
|
|
2663
|
+
* A hook that provides a way to supply assets to an Aave reserve.
|
|
2017
2664
|
*
|
|
2018
|
-
*
|
|
2665
|
+
* ```ts
|
|
2666
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2667
|
+
* const [supply, { loading, error }] = useSupply((plan, { cancel }) => {
|
|
2668
|
+
* switch (plan.__typename) {
|
|
2669
|
+
* case 'TransactionRequest':
|
|
2670
|
+
* return sendTransaction(plan);
|
|
2019
2671
|
*
|
|
2020
|
-
*
|
|
2021
|
-
*
|
|
2022
|
-
*
|
|
2023
|
-
*
|
|
2024
|
-
*
|
|
2025
|
-
*
|
|
2026
|
-
* suspense: true,
|
|
2672
|
+
* case 'Erc20Approval':
|
|
2673
|
+
* return sendTransaction(plan.byTransaction);
|
|
2674
|
+
*
|
|
2675
|
+
* case 'PreContractActionRequired':
|
|
2676
|
+
* return sendTransaction(plan.transaction);
|
|
2677
|
+
* }
|
|
2027
2678
|
* });
|
|
2028
2679
|
*
|
|
2029
|
-
* //
|
|
2030
|
-
* ```
|
|
2031
|
-
*/
|
|
2032
|
-
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2033
|
-
/**
|
|
2034
|
-
* Fetch paginated list of activities.
|
|
2680
|
+
* // …
|
|
2035
2681
|
*
|
|
2036
|
-
*
|
|
2682
|
+
* const result = await supply({ ... });
|
|
2037
2683
|
*
|
|
2038
|
-
*
|
|
2039
|
-
*
|
|
2040
|
-
*
|
|
2041
|
-
*
|
|
2042
|
-
*
|
|
2043
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2044
|
-
* suspense: true,
|
|
2045
|
-
* pause: true,
|
|
2046
|
-
* });
|
|
2684
|
+
* if (result.isErr()) {
|
|
2685
|
+
* switch (result.error.name) {
|
|
2686
|
+
* case 'CancelError':
|
|
2687
|
+
* // The user cancelled the operation
|
|
2688
|
+
* return;
|
|
2047
2689
|
*
|
|
2048
|
-
*
|
|
2690
|
+
* case 'SigningError':
|
|
2691
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2692
|
+
* break;
|
|
2693
|
+
*
|
|
2694
|
+
* case 'TimeoutError':
|
|
2695
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2696
|
+
* break;
|
|
2697
|
+
*
|
|
2698
|
+
* case 'TransactionError':
|
|
2699
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2700
|
+
* break;
|
|
2701
|
+
*
|
|
2702
|
+
* case 'ValidationError':
|
|
2703
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2704
|
+
* break;
|
|
2705
|
+
*
|
|
2706
|
+
* case 'UnexpectedError':
|
|
2707
|
+
* console.error(result.error.message);
|
|
2708
|
+
* break;
|
|
2709
|
+
* }
|
|
2710
|
+
* return;
|
|
2711
|
+
* }
|
|
2712
|
+
*
|
|
2713
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2049
2714
|
* ```
|
|
2715
|
+
*
|
|
2716
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
2050
2717
|
*/
|
|
2051
|
-
declare function
|
|
2718
|
+
declare function useSupply(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<SupplyRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2719
|
+
|
|
2052
2720
|
/**
|
|
2053
|
-
*
|
|
2721
|
+
* Hook for updating user position conditions (dynamic config and/or risk premium).
|
|
2054
2722
|
*
|
|
2055
|
-
* ```
|
|
2056
|
-
* const
|
|
2057
|
-
*
|
|
2058
|
-
*
|
|
2059
|
-
* },
|
|
2060
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2723
|
+
* ```ts
|
|
2724
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2725
|
+
* const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {
|
|
2726
|
+
* return sendTransaction(transaction);
|
|
2061
2727
|
* });
|
|
2062
|
-
* ```
|
|
2063
|
-
*/
|
|
2064
|
-
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
2065
|
-
/**
|
|
2066
|
-
* Fetch paginated list of activities.
|
|
2067
2728
|
*
|
|
2068
|
-
*
|
|
2729
|
+
* // …
|
|
2069
2730
|
*
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2072
|
-
*
|
|
2073
|
-
* chainId: chainId(1),
|
|
2074
|
-
* },
|
|
2075
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2076
|
-
* pause: true,
|
|
2731
|
+
* const result = await update({
|
|
2732
|
+
* userPositionId: userPosition.id,
|
|
2733
|
+
* update: UserPositionConditionsUpdate.AllDynamicConfig,
|
|
2077
2734
|
* });
|
|
2078
2735
|
*
|
|
2079
|
-
*
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2736
|
+
* if (result.isErr()) {
|
|
2737
|
+
* switch (result.error.name) {
|
|
2738
|
+
* case 'CancelError':
|
|
2739
|
+
* // The user cancelled the operation
|
|
2740
|
+
* return;
|
|
2741
|
+
*
|
|
2742
|
+
* case 'SigningError':
|
|
2743
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2744
|
+
* break;
|
|
2745
|
+
*
|
|
2746
|
+
* case 'TimeoutError':
|
|
2747
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2748
|
+
* break;
|
|
2749
|
+
*
|
|
2750
|
+
* case 'TransactionError':
|
|
2751
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2752
|
+
* break;
|
|
2753
|
+
*
|
|
2754
|
+
* case 'UnexpectedError':
|
|
2755
|
+
* console.error(result.error.message);
|
|
2756
|
+
* break;
|
|
2757
|
+
* }
|
|
2758
|
+
* return;
|
|
2759
|
+
* }
|
|
2760
|
+
*
|
|
2761
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2082
2762
|
* ```
|
|
2763
|
+
*
|
|
2764
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2083
2765
|
*/
|
|
2084
|
-
declare function
|
|
2766
|
+
declare function useUpdateUserPositionConditions(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<UpdateUserPositionConditionsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2767
|
+
|
|
2085
2768
|
/**
|
|
2086
|
-
*
|
|
2769
|
+
* A hook that provides a way to withdraw supplied assets from an Aave reserve.
|
|
2087
2770
|
*
|
|
2088
|
-
*
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
* (
|
|
2771
|
+
* ```ts
|
|
2772
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2773
|
+
* const [withdraw, { loading, error }] = useWithdraw((plan, { cancel }) => {
|
|
2774
|
+
* switch (plan.__typename) {
|
|
2775
|
+
* case 'TransactionRequest':
|
|
2776
|
+
* return sendTransaction(plan);
|
|
2092
2777
|
*
|
|
2093
|
-
*
|
|
2094
|
-
*
|
|
2778
|
+
* case 'PreContractActionRequired':
|
|
2779
|
+
* return sendTransaction(plan.transaction);
|
|
2780
|
+
* }
|
|
2781
|
+
* });
|
|
2782
|
+
*
|
|
2783
|
+
* // …
|
|
2784
|
+
*
|
|
2785
|
+
* const result = await withdraw({ ... });
|
|
2786
|
+
*
|
|
2787
|
+
* if (result.isErr()) {
|
|
2788
|
+
* switch (result.error.name) {
|
|
2789
|
+
* case 'CancelError':
|
|
2790
|
+
* // The user cancelled the operation
|
|
2791
|
+
* return;
|
|
2792
|
+
*
|
|
2793
|
+
* case 'SigningError':
|
|
2794
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2795
|
+
* break;
|
|
2796
|
+
*
|
|
2797
|
+
* case 'TimeoutError':
|
|
2798
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2799
|
+
* break;
|
|
2800
|
+
*
|
|
2801
|
+
* case 'TransactionError':
|
|
2802
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2803
|
+
* break;
|
|
2804
|
+
*
|
|
2805
|
+
* case 'ValidationError':
|
|
2806
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2807
|
+
* break;
|
|
2808
|
+
*
|
|
2809
|
+
* case 'UnexpectedError':
|
|
2810
|
+
* console.error(result.error.message);
|
|
2811
|
+
* break;
|
|
2812
|
+
* }
|
|
2813
|
+
* return;
|
|
2814
|
+
* }
|
|
2815
|
+
*
|
|
2816
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2817
|
+
* ```
|
|
2818
|
+
*
|
|
2819
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
2095
2820
|
*/
|
|
2096
|
-
declare function
|
|
2821
|
+
declare function useWithdraw(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<WithdrawRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2097
2822
|
|
|
2098
|
-
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions>;
|
|
2823
|
+
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2099
2824
|
/**
|
|
2100
2825
|
* Fetch all user supply positions.
|
|
2101
2826
|
*
|
|
@@ -2208,8 +2933,8 @@ declare function useUserSupplies(args: Pausable<UseUserSuppliesArgs>): PausableR
|
|
|
2208
2933
|
* }
|
|
2209
2934
|
* ```
|
|
2210
2935
|
*/
|
|
2211
|
-
declare function useUserSuppliesAction(options?:
|
|
2212
|
-
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions>;
|
|
2936
|
+
declare function useUserSuppliesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError>;
|
|
2937
|
+
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2213
2938
|
/**
|
|
2214
2939
|
* Fetch all user borrow positions.
|
|
2215
2940
|
*
|
|
@@ -2315,7 +3040,7 @@ declare function useUserBorrows(args: Pausable<UseUserBorrowsArgs>): PausableRea
|
|
|
2315
3040
|
* }
|
|
2316
3041
|
* ```
|
|
2317
3042
|
*/
|
|
2318
|
-
declare function useUserBorrowsAction(options?:
|
|
3043
|
+
declare function useUserBorrowsAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError>;
|
|
2319
3044
|
type UseUserSummaryArgs = Prettify<UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions>;
|
|
2320
3045
|
/**
|
|
2321
3046
|
* Fetch a user's financial summary.
|
|
@@ -2578,6 +3303,69 @@ declare function useUserBalances(args: UseUserBalancesArgs): ReadResult<UserBala
|
|
|
2578
3303
|
* ```
|
|
2579
3304
|
*/
|
|
2580
3305
|
declare function useUserBalances(args: Pausable<UseUserBalancesArgs>): PausableReadResult<UserBalance[]>;
|
|
3306
|
+
type UseUserRiskPremiumBreakdownArgs = UserRiskPremiumBreakdownRequest;
|
|
3307
|
+
/**
|
|
3308
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3309
|
+
*
|
|
3310
|
+
* This signature supports React Suspense:
|
|
3311
|
+
*
|
|
3312
|
+
* ```tsx
|
|
3313
|
+
* const { data } = useUserRiskPremiumBreakdown({
|
|
3314
|
+
* query: {
|
|
3315
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3316
|
+
* },
|
|
3317
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3318
|
+
* suspense: true,
|
|
3319
|
+
* });
|
|
3320
|
+
* ```
|
|
3321
|
+
*/
|
|
3322
|
+
declare function useUserRiskPremiumBreakdown(args: UseUserRiskPremiumBreakdownArgs & Suspendable): SuspenseResult<UserRiskPremiumBreakdownItem[]>;
|
|
3323
|
+
/**
|
|
3324
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3325
|
+
*
|
|
3326
|
+
* Pausable suspense mode.
|
|
3327
|
+
*
|
|
3328
|
+
* ```tsx
|
|
3329
|
+
* const { data } = useUserRiskPremiumBreakdown({
|
|
3330
|
+
* query: {
|
|
3331
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3332
|
+
* },
|
|
3333
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3334
|
+
* suspense: true,
|
|
3335
|
+
* pause: true,
|
|
3336
|
+
* });
|
|
3337
|
+
* ```
|
|
3338
|
+
*/
|
|
3339
|
+
declare function useUserRiskPremiumBreakdown(args: Pausable<UseUserRiskPremiumBreakdownArgs> & Suspendable): PausableSuspenseResult<UserRiskPremiumBreakdownItem[]>;
|
|
3340
|
+
/**
|
|
3341
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3342
|
+
*
|
|
3343
|
+
* ```tsx
|
|
3344
|
+
* const { data, error, loading } = useUserRiskPremiumBreakdown({
|
|
3345
|
+
* query: {
|
|
3346
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3347
|
+
* },
|
|
3348
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3349
|
+
* });
|
|
3350
|
+
* ```
|
|
3351
|
+
*/
|
|
3352
|
+
declare function useUserRiskPremiumBreakdown(args: UseUserRiskPremiumBreakdownArgs): ReadResult<UserRiskPremiumBreakdownItem[]>;
|
|
3353
|
+
/**
|
|
3354
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3355
|
+
*
|
|
3356
|
+
* Pausable loading state mode.
|
|
3357
|
+
*
|
|
3358
|
+
* ```tsx
|
|
3359
|
+
* const { data, error, loading, paused } = useUserRiskPremiumBreakdown({
|
|
3360
|
+
* query: {
|
|
3361
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3362
|
+
* },
|
|
3363
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3364
|
+
* pause: true,
|
|
3365
|
+
* });
|
|
3366
|
+
* ```
|
|
3367
|
+
*/
|
|
3368
|
+
declare function useUserRiskPremiumBreakdown(args: Pausable<UseUserRiskPremiumBreakdownArgs>): PausableReadResult<UserRiskPremiumBreakdownItem[]>;
|
|
2581
3369
|
/**
|
|
2582
3370
|
* Low-level hook to execute a {@link userBalances} action directly.
|
|
2583
3371
|
*
|
|
@@ -2667,4 +3455,4 @@ declare function useUserSummaryHistory(args: UseUserSummaryHistoryArgs): ReadRes
|
|
|
2667
3455
|
*/
|
|
2668
3456
|
declare function useUserSummaryHistory(args: Pausable<UseUserSummaryHistoryArgs>): PausableReadResult<UserSummaryHistoryItem[]>;
|
|
2669
3457
|
|
|
2670
|
-
export { AaveProvider, type AaveProviderProps, type CancelSwapError, type CancelSwapHandler, CannotCancelSwapError,
|
|
3458
|
+
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 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 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, useHubAssets, useHubSummaryHistory, useHubs, useHubsAction, useLiquidatePosition, usePreview, usePreviewAction, useProtocolHistory, useRenounceSpokeUserPositionManager, useRepay, useRepayWithSupply, useRepayWithSupplyQuote, useRepayWithSupplyQuoteAction, useReserve, useReserveAction, useReserves, useReservesAction, useSetSpokeUserPositionManager, useSetUserSuppliesAsCollateral, useSpoke, useSpokePositionManagers, useSpokeUserPositionManagers, useSpokes, 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 };
|