@aave/react 4.0.0-next.5 → 4.0.0-next.51
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 +1571 -707
- package/dist/index.d.ts +1571 -707
- 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.cts
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.cjs';
|
|
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.cjs';
|
|
6
|
+
import { HubRequest, Hub, HubsRequest, HubAssetsRequest, HubAsset, HubSummaryHistoryRequest, HubSummarySample, HubAssetInterestRateModelRequest, HubAssetInterestRateModelPoint, 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-CLtLR-vZ.cjs';
|
|
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-CLtLR-vZ.cjs';
|
|
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,137 @@ declare function useHubAssets(args: UseHubAssetsArgs): ReadResult<HubAsset[]>;
|
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
210
|
declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadResult<HubAsset[]>;
|
|
211
|
+
type UseHubSummaryHistoryArgs = HubSummaryHistoryRequest;
|
|
212
|
+
/**
|
|
213
|
+
* Fetch historical summary data for a specific hub.
|
|
214
|
+
*
|
|
215
|
+
* This signature supports React Suspense:
|
|
216
|
+
*
|
|
217
|
+
* ```tsx
|
|
218
|
+
* const { data } = useHubSummaryHistory({
|
|
219
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
220
|
+
* currency: Currency.Usd,
|
|
221
|
+
* window: TimeWindow.LastWeek,
|
|
222
|
+
* suspense: true,
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs & Suspendable): SuspenseResult<HubSummarySample[]>;
|
|
227
|
+
/**
|
|
228
|
+
* Fetch historical summary data for a specific hub.
|
|
229
|
+
*
|
|
230
|
+
* Pausable suspense mode.
|
|
231
|
+
*
|
|
232
|
+
* ```tsx
|
|
233
|
+
* const { data } = useHubSummaryHistory({
|
|
234
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
235
|
+
* suspense: true,
|
|
236
|
+
* pause: true,
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs> & Suspendable): PausableSuspenseResult<HubSummarySample[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Fetch historical summary data for a specific hub.
|
|
243
|
+
*
|
|
244
|
+
* ```tsx
|
|
245
|
+
* const { data, error, loading } = useHubSummaryHistory({
|
|
246
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
247
|
+
* currency: Currency.Usd,
|
|
248
|
+
* window: TimeWindow.LastWeek,
|
|
249
|
+
* });
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function useHubSummaryHistory(args: UseHubSummaryHistoryArgs): ReadResult<HubSummarySample[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Fetch historical summary data for a specific hub.
|
|
255
|
+
*
|
|
256
|
+
* Pausable loading state mode.
|
|
257
|
+
*
|
|
258
|
+
* ```tsx
|
|
259
|
+
* const { data, error, loading, paused } = useHubSummaryHistory({
|
|
260
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
261
|
+
* pause: true,
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function useHubSummaryHistory(args: Pausable<UseHubSummaryHistoryArgs>): PausableReadResult<HubSummarySample[]>;
|
|
266
|
+
type UseHubAssetInterestRateModelArgs = Prettify<HubAssetInterestRateModelRequest & CurrencyQueryOptions>;
|
|
267
|
+
/**
|
|
268
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
269
|
+
*
|
|
270
|
+
* This signature supports React Suspense:
|
|
271
|
+
*
|
|
272
|
+
* ```tsx
|
|
273
|
+
* const { data } = useHubAssetInterestRateModel({
|
|
274
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
275
|
+
* suspense: true,
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare function useHubAssetInterestRateModel(args: UseHubAssetInterestRateModelArgs & Suspendable): SuspenseResult<HubAssetInterestRateModelPoint[]>;
|
|
280
|
+
/**
|
|
281
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
282
|
+
*
|
|
283
|
+
* Pausable suspense mode.
|
|
284
|
+
*
|
|
285
|
+
* ```tsx
|
|
286
|
+
* const { data } = useHubAssetInterestRateModel({
|
|
287
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
288
|
+
* suspense: true,
|
|
289
|
+
* pause: true,
|
|
290
|
+
* });
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
declare function useHubAssetInterestRateModel(args: Pausable<UseHubAssetInterestRateModelArgs> & Suspendable): PausableSuspenseResult<HubAssetInterestRateModelPoint[]>;
|
|
294
|
+
/**
|
|
295
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
296
|
+
*
|
|
297
|
+
* ```tsx
|
|
298
|
+
* const { data, error, loading } = useHubAssetInterestRateModel({
|
|
299
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
declare function useHubAssetInterestRateModel(args: UseHubAssetInterestRateModelArgs): ReadResult<HubAssetInterestRateModelPoint[]>;
|
|
304
|
+
/**
|
|
305
|
+
* Fetch the interest rate model for a specific hub asset.
|
|
306
|
+
*
|
|
307
|
+
* Pausable loading state mode.
|
|
308
|
+
*
|
|
309
|
+
* ```tsx
|
|
310
|
+
* const { data, error, loading, paused } = useHubAssetInterestRateModel({
|
|
311
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
312
|
+
* pause: true,
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
declare function useHubAssetInterestRateModel(args: Pausable<UseHubAssetInterestRateModelArgs>): PausableReadResult<HubAssetInterestRateModelPoint[]>;
|
|
317
|
+
/**
|
|
318
|
+
* Low-level hook to execute a {@link hubAssetInterestRateModel} action directly.
|
|
319
|
+
*
|
|
320
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
321
|
+
* @remarks
|
|
322
|
+
* This hook **does not** actively watch for updated data.
|
|
323
|
+
* Use this hook to retrieve data on demand as part of a larger workflow.
|
|
324
|
+
*
|
|
325
|
+
* ```ts
|
|
326
|
+
* const [execute, { called, data, error, loading }] = useHubAssetInterestRateModelAction();
|
|
327
|
+
*
|
|
328
|
+
* // …
|
|
329
|
+
*
|
|
330
|
+
* const result = await execute({
|
|
331
|
+
* query: { hubAssetId: hubAssetId('...') },
|
|
332
|
+
* });
|
|
333
|
+
*
|
|
334
|
+
* if (result.isOk()) {
|
|
335
|
+
* console.log(result.value); // HubAssetInterestRateModelPoint[]
|
|
336
|
+
* } else {
|
|
337
|
+
* console.error(result.error);
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
declare function useHubAssetInterestRateModelAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubAssetInterestRateModelRequest, HubAssetInterestRateModelPoint[], UnexpectedError>;
|
|
211
342
|
/**
|
|
212
343
|
* Low-level hook to execute a {@link hubs} action directly.
|
|
213
344
|
*
|
|
@@ -237,11 +368,6 @@ declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadRes
|
|
|
237
368
|
*/
|
|
238
369
|
declare function useHubsAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubsRequest, Hub[], UnexpectedError>;
|
|
239
370
|
|
|
240
|
-
/**
|
|
241
|
-
* @internal
|
|
242
|
-
*/
|
|
243
|
-
declare function usePermitTypedDataAction(): UseAsyncTask<PermitRequest, PermitTypedDataResponse, UnexpectedError>;
|
|
244
|
-
|
|
245
371
|
type UseAssetArgs = Prettify<AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
246
372
|
/**
|
|
247
373
|
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
@@ -350,7 +476,7 @@ declare function useAssetPriceHistory(args: UseAssetPriceHistoryArgs): ReadResul
|
|
|
350
476
|
* ```
|
|
351
477
|
*/
|
|
352
478
|
declare function useAssetPriceHistory(args: Pausable<UseAssetPriceHistoryArgs>): PausableReadResult<AssetPriceSample[]>;
|
|
353
|
-
type UseAssetSupplyHistoryArgs = AssetSupplyHistoryRequest
|
|
479
|
+
type UseAssetSupplyHistoryArgs = Prettify<AssetSupplyHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
354
480
|
/**
|
|
355
481
|
* Fetch historical supply data for a specific asset.
|
|
356
482
|
*
|
|
@@ -403,7 +529,7 @@ declare function useAssetSupplyHistory(args: UseAssetSupplyHistoryArgs): ReadRes
|
|
|
403
529
|
* ```
|
|
404
530
|
*/
|
|
405
531
|
declare function useAssetSupplyHistory(args: Pausable<UseAssetSupplyHistoryArgs>): PausableReadResult<AssetSupplySample[]>;
|
|
406
|
-
type UseAssetBorrowHistoryArgs = AssetBorrowHistoryRequest
|
|
532
|
+
type UseAssetBorrowHistoryArgs = Prettify<AssetBorrowHistoryRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
407
533
|
/**
|
|
408
534
|
* Fetch historical borrow data for a specific asset.
|
|
409
535
|
*
|
|
@@ -456,8 +582,63 @@ declare function useAssetBorrowHistory(args: UseAssetBorrowHistoryArgs): ReadRes
|
|
|
456
582
|
* ```
|
|
457
583
|
*/
|
|
458
584
|
declare function useAssetBorrowHistory(args: Pausable<UseAssetBorrowHistoryArgs>): PausableReadResult<AssetBorrowSample[]>;
|
|
585
|
+
type UseProtocolHistoryArgs = ProtocolHistoryRequest;
|
|
586
|
+
/**
|
|
587
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
588
|
+
*
|
|
589
|
+
* This signature supports React Suspense:
|
|
590
|
+
*
|
|
591
|
+
* ```tsx
|
|
592
|
+
* const { data } = useProtocolHistory({
|
|
593
|
+
* currency: Currency.Usd,
|
|
594
|
+
* window: TimeWindow.LastWeek,
|
|
595
|
+
* suspense: true,
|
|
596
|
+
* });
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
declare function useProtocolHistory(args: UseProtocolHistoryArgs & Suspendable): SuspenseResult<ProtocolHistorySample[]>;
|
|
600
|
+
/**
|
|
601
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
602
|
+
*
|
|
603
|
+
* Pausable suspense mode.
|
|
604
|
+
*
|
|
605
|
+
* ```tsx
|
|
606
|
+
* const { data } = useProtocolHistory({
|
|
607
|
+
* currency: Currency.Usd,
|
|
608
|
+
* window: TimeWindow.LastWeek,
|
|
609
|
+
* suspense: true,
|
|
610
|
+
* pause: true,
|
|
611
|
+
* });
|
|
612
|
+
* ```
|
|
613
|
+
*/
|
|
614
|
+
declare function useProtocolHistory(args: Pausable<UseProtocolHistoryArgs> & Suspendable): PausableSuspenseResult<ProtocolHistorySample[]>;
|
|
615
|
+
/**
|
|
616
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
617
|
+
*
|
|
618
|
+
* ```tsx
|
|
619
|
+
* const { data, error, loading } = useProtocolHistory({
|
|
620
|
+
* currency: Currency.Usd,
|
|
621
|
+
* window: TimeWindow.LastWeek,
|
|
622
|
+
* });
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
declare function useProtocolHistory(args: UseProtocolHistoryArgs): ReadResult<ProtocolHistorySample[]>;
|
|
626
|
+
/**
|
|
627
|
+
* Fetch historical protocol-wide data (deposits, borrows, earnings).
|
|
628
|
+
*
|
|
629
|
+
* Pausable loading state mode.
|
|
630
|
+
*
|
|
631
|
+
* ```tsx
|
|
632
|
+
* const { data, error, loading, paused } = useProtocolHistory({
|
|
633
|
+
* currency: Currency.Usd,
|
|
634
|
+
* window: TimeWindow.LastWeek,
|
|
635
|
+
* pause: true,
|
|
636
|
+
* });
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
declare function useProtocolHistory(args: Pausable<UseProtocolHistoryArgs>): PausableReadResult<ProtocolHistorySample[]>;
|
|
459
640
|
|
|
460
|
-
type UseReserveArgs = Prettify<ReserveRequest & CurrencyQueryOptions>;
|
|
641
|
+
type UseReserveArgs = Prettify<ReserveRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
461
642
|
/**
|
|
462
643
|
* Fetch a specific reserve by reserve ID, spoke, and chain.
|
|
463
644
|
*
|
|
@@ -537,18 +718,8 @@ declare function useReserve(args: Pausable<UseReserveArgs>): PausableReadResult<
|
|
|
537
718
|
* }
|
|
538
719
|
* ```
|
|
539
720
|
*/
|
|
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
|
-
}>;
|
|
721
|
+
declare function useReserveAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError>;
|
|
722
|
+
type UseReservesArgs = Prettify<ReservesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
552
723
|
/**
|
|
553
724
|
* Fetch reserves based on specified criteria.
|
|
554
725
|
*
|
|
@@ -567,36 +738,8 @@ type UseReservesArgs<T = Reserve[]> = Prettify<ReservesRequest & CurrencyQueryOp
|
|
|
567
738
|
* suspense: true,
|
|
568
739
|
* });
|
|
569
740
|
* ```
|
|
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
741
|
*/
|
|
599
|
-
declare function useReserves
|
|
742
|
+
declare function useReserves(args: UseReservesArgs & Suspendable): SuspenseResult<Reserve[]>;
|
|
600
743
|
/**
|
|
601
744
|
* Fetch reserves based on specified criteria.
|
|
602
745
|
*
|
|
@@ -615,7 +758,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T> & Suspendab
|
|
|
615
758
|
* });
|
|
616
759
|
* ```
|
|
617
760
|
*/
|
|
618
|
-
declare function useReserves
|
|
761
|
+
declare function useReserves(args: Pausable<UseReservesArgs> & Suspendable): PausableSuspenseResult<Reserve[]>;
|
|
619
762
|
/**
|
|
620
763
|
* Fetch reserves based on specified criteria.
|
|
621
764
|
*
|
|
@@ -631,34 +774,8 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>> &
|
|
|
631
774
|
* orderBy: { name: 'ASC' },
|
|
632
775
|
* });
|
|
633
776
|
* ```
|
|
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
777
|
*/
|
|
661
|
-
declare function useReserves
|
|
778
|
+
declare function useReserves(args: UseReservesArgs): ReadResult<Reserve[], UnexpectedError>;
|
|
662
779
|
/**
|
|
663
780
|
* Fetch reserves based on specified criteria.
|
|
664
781
|
*
|
|
@@ -676,7 +793,7 @@ declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T>): ReadResul
|
|
|
676
793
|
* });
|
|
677
794
|
* ```
|
|
678
795
|
*/
|
|
679
|
-
declare function useReserves
|
|
796
|
+
declare function useReserves(args: Pausable<UseReservesArgs>): PausableReadResult<Reserve[], UnexpectedError>;
|
|
680
797
|
/**
|
|
681
798
|
* Low-level hook to execute a {@link reserves} action directly.
|
|
682
799
|
*
|
|
@@ -706,39 +823,9 @@ declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>>):
|
|
|
706
823
|
* console.error(result.error);
|
|
707
824
|
* }
|
|
708
825
|
* ```
|
|
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
826
|
*/
|
|
740
|
-
declare function useReservesAction(options?:
|
|
741
|
-
type UseBorrowApyHistoryArgs =
|
|
827
|
+
declare function useReservesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError>;
|
|
828
|
+
type UseBorrowApyHistoryArgs = BorrowApyHistoryRequest;
|
|
742
829
|
/**
|
|
743
830
|
* Fetch borrow APY history for a specific reserve over time.
|
|
744
831
|
*
|
|
@@ -752,7 +839,7 @@ type UseBorrowApyHistoryArgs = BorrowAPYHistoryRequest;
|
|
|
752
839
|
* });
|
|
753
840
|
* ```
|
|
754
841
|
*/
|
|
755
|
-
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable): SuspenseResult<
|
|
842
|
+
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable): SuspenseResult<ApySample[]>;
|
|
756
843
|
/**
|
|
757
844
|
* Fetch borrow APY history for a specific reserve over time.
|
|
758
845
|
*
|
|
@@ -767,7 +854,7 @@ declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable
|
|
|
767
854
|
* });
|
|
768
855
|
* ```
|
|
769
856
|
*/
|
|
770
|
-
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & Suspendable): PausableSuspenseResult<
|
|
857
|
+
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & Suspendable): PausableSuspenseResult<ApySample[]>;
|
|
771
858
|
/**
|
|
772
859
|
* Fetch borrow APY history for a specific reserve over time.
|
|
773
860
|
*
|
|
@@ -778,7 +865,7 @@ declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & S
|
|
|
778
865
|
* });
|
|
779
866
|
* ```
|
|
780
867
|
*/
|
|
781
|
-
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<
|
|
868
|
+
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<ApySample[]>;
|
|
782
869
|
/**
|
|
783
870
|
* Fetch borrow APY history for a specific reserve over time.
|
|
784
871
|
*
|
|
@@ -792,8 +879,8 @@ declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<
|
|
|
792
879
|
* });
|
|
793
880
|
* ```
|
|
794
881
|
*/
|
|
795
|
-
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs>): PausableReadResult<
|
|
796
|
-
type UseSupplyApyHistoryArgs =
|
|
882
|
+
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs>): PausableReadResult<ApySample[]>;
|
|
883
|
+
type UseSupplyApyHistoryArgs = SupplyApyHistoryRequest;
|
|
797
884
|
/**
|
|
798
885
|
* Fetch supply APY history for a specific reserve over time.
|
|
799
886
|
*
|
|
@@ -807,7 +894,7 @@ type UseSupplyApyHistoryArgs = SupplyAPYHistoryRequest;
|
|
|
807
894
|
* });
|
|
808
895
|
* ```
|
|
809
896
|
*/
|
|
810
|
-
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable): SuspenseResult<
|
|
897
|
+
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable): SuspenseResult<ApySample[]>;
|
|
811
898
|
/**
|
|
812
899
|
* Fetch supply APY history for a specific reserve over time.
|
|
813
900
|
*
|
|
@@ -822,7 +909,7 @@ declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable
|
|
|
822
909
|
* });
|
|
823
910
|
* ```
|
|
824
911
|
*/
|
|
825
|
-
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & Suspendable): PausableSuspenseResult<
|
|
912
|
+
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & Suspendable): PausableSuspenseResult<ApySample[]>;
|
|
826
913
|
/**
|
|
827
914
|
* Fetch supply APY history for a specific reserve over time.
|
|
828
915
|
*
|
|
@@ -833,7 +920,7 @@ declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & S
|
|
|
833
920
|
* });
|
|
834
921
|
* ```
|
|
835
922
|
*/
|
|
836
|
-
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<
|
|
923
|
+
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<ApySample[]>;
|
|
837
924
|
/**
|
|
838
925
|
* Fetch supply APY history for a specific reserve over time.
|
|
839
926
|
*
|
|
@@ -847,79 +934,157 @@ declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<
|
|
|
847
934
|
* });
|
|
848
935
|
* ```
|
|
849
936
|
*/
|
|
850
|
-
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<
|
|
937
|
+
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<ApySample[]>;
|
|
851
938
|
|
|
852
|
-
type
|
|
939
|
+
type UseUserClaimableRewardsArgs = Prettify<UserClaimableRewardsRequest>;
|
|
853
940
|
/**
|
|
854
|
-
* Fetch a
|
|
941
|
+
* Fetch all claimable rewards for a user.
|
|
855
942
|
*
|
|
856
943
|
* This signature supports React Suspense:
|
|
857
944
|
*
|
|
858
945
|
* ```tsx
|
|
859
|
-
* const { data } =
|
|
860
|
-
*
|
|
946
|
+
* const { data } = useUserClaimableRewards({
|
|
947
|
+
* user: evmAddress('0x742d35cc…'),
|
|
861
948
|
* suspense: true,
|
|
862
949
|
* });
|
|
863
|
-
* // data will be Spoke | null
|
|
864
950
|
* ```
|
|
865
951
|
*/
|
|
866
|
-
declare function
|
|
952
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs & Suspendable): SuspenseResult<UserClaimableReward[]>;
|
|
867
953
|
/**
|
|
868
|
-
* Fetch a
|
|
954
|
+
* Fetch all claimable rewards for a user.
|
|
869
955
|
*
|
|
870
956
|
* Pausable suspense mode.
|
|
871
957
|
*
|
|
872
958
|
* ```tsx
|
|
873
|
-
* const { data } =
|
|
874
|
-
*
|
|
959
|
+
* const { data } = useUserClaimableRewards({
|
|
960
|
+
* user: evmAddress('0x742d35cc…'),
|
|
875
961
|
* suspense: true,
|
|
876
962
|
* pause: true,
|
|
877
963
|
* });
|
|
878
964
|
* ```
|
|
879
965
|
*/
|
|
880
|
-
declare function
|
|
966
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs> & Suspendable): PausableSuspenseResult<UserClaimableReward[]>;
|
|
881
967
|
/**
|
|
882
|
-
* Fetch a
|
|
968
|
+
* Fetch all claimable rewards for a user.
|
|
883
969
|
*
|
|
884
970
|
* ```tsx
|
|
885
|
-
* const { data, error, loading } =
|
|
886
|
-
*
|
|
971
|
+
* const { data, error, loading } = useUserClaimableRewards({
|
|
972
|
+
* user: evmAddress('0x742d35cc…'),
|
|
887
973
|
* });
|
|
888
|
-
* // data will be Spoke | null
|
|
889
974
|
* ```
|
|
890
975
|
*/
|
|
891
|
-
declare function
|
|
976
|
+
declare function useUserClaimableRewards(args: UseUserClaimableRewardsArgs): ReadResult<UserClaimableReward[]>;
|
|
892
977
|
/**
|
|
893
|
-
* Fetch a
|
|
978
|
+
* Fetch all claimable rewards for a user.
|
|
894
979
|
*
|
|
895
980
|
* Pausable loading state mode.
|
|
896
981
|
*
|
|
897
982
|
* ```tsx
|
|
898
|
-
* const { data, error, loading, paused } =
|
|
899
|
-
*
|
|
983
|
+
* const { data, error, loading, paused } = useUserClaimableRewards({
|
|
984
|
+
* user: evmAddress('0x742d35cc…'),
|
|
900
985
|
* pause: true,
|
|
901
986
|
* });
|
|
902
987
|
* ```
|
|
903
988
|
*/
|
|
904
|
-
declare function
|
|
905
|
-
type UseSpokesArgs = SpokesRequest;
|
|
989
|
+
declare function useUserClaimableRewards(args: Pausable<UseUserClaimableRewardsArgs>): PausableReadResult<UserClaimableReward[]>;
|
|
906
990
|
/**
|
|
907
|
-
*
|
|
991
|
+
* Low-level hook to execute a {@link userClaimableRewards} action directly.
|
|
908
992
|
*
|
|
909
|
-
* This
|
|
993
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
994
|
+
* @remarks
|
|
995
|
+
* This hook **does not** actively watch for updated data on claimable rewards.
|
|
996
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
997
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
910
998
|
*
|
|
911
|
-
* ```
|
|
912
|
-
* const { data } =
|
|
913
|
-
* query: { chainIds: [chainId(1)] },
|
|
914
|
-
* suspense: true,
|
|
915
|
-
* });
|
|
916
|
-
* ```
|
|
917
|
-
*/
|
|
918
|
-
declare function useSpokes(args: UseSpokesArgs & Suspendable): SuspenseResult<Spoke[]>;
|
|
919
|
-
/**
|
|
920
|
-
* Fetch spokes based on specified criteria.
|
|
999
|
+
* ```ts
|
|
1000
|
+
* const [execute, { called, data, error, loading }] = useUserClaimableRewardsAction();
|
|
921
1001
|
*
|
|
922
|
-
*
|
|
1002
|
+
* // …
|
|
1003
|
+
*
|
|
1004
|
+
* const result = await execute({
|
|
1005
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1006
|
+
* });
|
|
1007
|
+
*
|
|
1008
|
+
* if (result.isOk()) {
|
|
1009
|
+
* console.log(result.value); // UserClaimableReward[]
|
|
1010
|
+
* } else {
|
|
1011
|
+
* console.error(result.error);
|
|
1012
|
+
* }
|
|
1013
|
+
* ```
|
|
1014
|
+
*/
|
|
1015
|
+
declare function useUserClaimableRewardsAction(): UseAsyncTask<UserClaimableRewardsRequest, UserClaimableReward[], UnexpectedError>;
|
|
1016
|
+
|
|
1017
|
+
type UseSpokeArgs = SpokeRequest;
|
|
1018
|
+
/**
|
|
1019
|
+
* Fetch a specific spoke.
|
|
1020
|
+
*
|
|
1021
|
+
* This signature supports React Suspense:
|
|
1022
|
+
*
|
|
1023
|
+
* ```tsx
|
|
1024
|
+
* const { data } = useSpoke({
|
|
1025
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1026
|
+
* suspense: true,
|
|
1027
|
+
* });
|
|
1028
|
+
* // data will be Spoke | null
|
|
1029
|
+
* ```
|
|
1030
|
+
*/
|
|
1031
|
+
declare function useSpoke(args: UseSpokeArgs & Suspendable): SuspenseResult<Spoke | null>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Fetch a specific spoke.
|
|
1034
|
+
*
|
|
1035
|
+
* Pausable suspense mode.
|
|
1036
|
+
*
|
|
1037
|
+
* ```tsx
|
|
1038
|
+
* const { data } = useSpoke({
|
|
1039
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1040
|
+
* suspense: true,
|
|
1041
|
+
* pause: true,
|
|
1042
|
+
* });
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
declare function useSpoke(args: Pausable<UseSpokeArgs> & Suspendable): PausableSuspenseResult<Spoke | null>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Fetch a specific spoke.
|
|
1048
|
+
*
|
|
1049
|
+
* ```tsx
|
|
1050
|
+
* const { data, error, loading } = useSpoke({
|
|
1051
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1052
|
+
* });
|
|
1053
|
+
* // data will be Spoke | null
|
|
1054
|
+
* ```
|
|
1055
|
+
*/
|
|
1056
|
+
declare function useSpoke(args: UseSpokeArgs): ReadResult<Spoke | null>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Fetch a specific spoke.
|
|
1059
|
+
*
|
|
1060
|
+
* Pausable loading state mode.
|
|
1061
|
+
*
|
|
1062
|
+
* ```tsx
|
|
1063
|
+
* const { data, error, loading, paused } = useSpoke({
|
|
1064
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
1065
|
+
* pause: true,
|
|
1066
|
+
* });
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
declare function useSpoke(args: Pausable<UseSpokeArgs>): PausableReadResult<Spoke | null>;
|
|
1070
|
+
type UseSpokesArgs = SpokesRequest;
|
|
1071
|
+
/**
|
|
1072
|
+
* Fetch spokes based on specified criteria.
|
|
1073
|
+
*
|
|
1074
|
+
* This signature supports React Suspense:
|
|
1075
|
+
*
|
|
1076
|
+
* ```tsx
|
|
1077
|
+
* const { data } = useSpokes({
|
|
1078
|
+
* query: { chainIds: [chainId(1)] },
|
|
1079
|
+
* suspense: true,
|
|
1080
|
+
* });
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
declare function useSpokes(args: UseSpokesArgs & Suspendable): SuspenseResult<Spoke[]>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Fetch spokes based on specified criteria.
|
|
1086
|
+
*
|
|
1087
|
+
* Pausable suspense mode.
|
|
923
1088
|
*
|
|
924
1089
|
* ```tsx
|
|
925
1090
|
* const { data } = useSpokes({
|
|
@@ -1060,264 +1225,809 @@ declare function useSpokeUserPositionManagers(args: UseSpokeUserPositionManagers
|
|
|
1060
1225
|
*/
|
|
1061
1226
|
declare function useSpokeUserPositionManagers(args: Pausable<UseSpokeUserPositionManagersArgs>): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1062
1227
|
|
|
1063
|
-
type
|
|
1228
|
+
type SwapHandlerOptions = {
|
|
1229
|
+
cancel: CancelOperation;
|
|
1230
|
+
};
|
|
1231
|
+
type SwapSignerError = CancelError | SigningError | UnexpectedError$1;
|
|
1232
|
+
type PositionSwapPlan = PositionSwapApproval | SwapTypedData;
|
|
1233
|
+
type PositionSwapHandler = (plan: PositionSwapPlan, options: SwapHandlerOptions) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1234
|
+
type PositionSwapValue = {
|
|
1235
|
+
quote?: SwapQuote;
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
type UseBorrowSwapRequest = Prettify<BorrowSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1064
1239
|
/**
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1240
|
+
* Orchestrate the borrow swap execution plan.
|
|
1241
|
+
*
|
|
1242
|
+
* ```tsx
|
|
1243
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1244
|
+
*
|
|
1245
|
+
* const [swapBorrow, { loading, error }] = useBorrowSwap((plan) => {
|
|
1246
|
+
* switch (plan.__typename) {
|
|
1247
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1248
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1249
|
+
* return signTypedData(plan.bySignature);
|
|
1250
|
+
*
|
|
1251
|
+
* case 'SwapTypedData':
|
|
1252
|
+
* return signTypedData(plan);
|
|
1253
|
+
* }
|
|
1254
|
+
* });
|
|
1255
|
+
*
|
|
1256
|
+
* const result = await swapBorrow({
|
|
1257
|
+
* market: {
|
|
1258
|
+
* debtPosition: userBorrowItem.id,
|
|
1259
|
+
* buyReserve: targetReserve.id,
|
|
1260
|
+
* amount: bigDecimal('1000'),
|
|
1261
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1262
|
+
* },
|
|
1263
|
+
* });
|
|
1264
|
+
*
|
|
1265
|
+
* if (result.isErr()) {
|
|
1266
|
+
* console.error(result.error);
|
|
1267
|
+
* return;
|
|
1268
|
+
* }
|
|
1269
|
+
*
|
|
1270
|
+
* // result.value: SwapReceipt
|
|
1271
|
+
* ```
|
|
1272
|
+
*/
|
|
1273
|
+
declare function useBorrowSwap(handler: PositionSwapHandler): UseAsyncTask<BorrowSwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1274
|
+
|
|
1275
|
+
type UseBorrowSwapQuoteArgs = Prettify<BorrowSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1276
|
+
/**
|
|
1277
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1067
1278
|
*
|
|
1068
1279
|
* This signature supports React Suspense:
|
|
1069
1280
|
*
|
|
1070
1281
|
* ```tsx
|
|
1071
|
-
* const { data } =
|
|
1072
|
-
*
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1282
|
+
* const { data } = useBorrowSwapQuote({
|
|
1283
|
+
* market: {
|
|
1284
|
+
* sellPosition: userBorrowItem.id,
|
|
1285
|
+
* buyReserve: reserve.id,
|
|
1286
|
+
* amount: bigDecimal('1000'),
|
|
1287
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1288
|
+
* },
|
|
1077
1289
|
* suspense: true,
|
|
1078
1290
|
* });
|
|
1079
1291
|
* ```
|
|
1080
1292
|
*/
|
|
1081
|
-
declare function
|
|
1293
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1082
1294
|
/**
|
|
1083
|
-
*
|
|
1084
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1295
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1085
1296
|
*
|
|
1086
1297
|
* Pausable suspense mode.
|
|
1087
1298
|
*
|
|
1088
1299
|
* ```tsx
|
|
1089
|
-
* const { data } =
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1300
|
+
* const { data } = useBorrowSwapQuote({
|
|
1301
|
+
* market: {
|
|
1302
|
+
* sellPosition: userBorrowItem.id,
|
|
1303
|
+
* buyReserve: reserve.id,
|
|
1304
|
+
* amount: bigDecimal('1000'),
|
|
1305
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1306
|
+
* },
|
|
1096
1307
|
* suspense: true,
|
|
1097
1308
|
* pause: true,
|
|
1098
1309
|
* });
|
|
1099
1310
|
* ```
|
|
1100
1311
|
*/
|
|
1101
|
-
declare function
|
|
1312
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1102
1313
|
/**
|
|
1103
|
-
*
|
|
1104
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1314
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1105
1315
|
*
|
|
1106
1316
|
* ```tsx
|
|
1107
|
-
* const { data, error, loading } =
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1317
|
+
* const { data, error, loading } = useBorrowSwapQuote({
|
|
1318
|
+
* market: {
|
|
1319
|
+
* sellPosition: userBorrowItem.id,
|
|
1320
|
+
* buyReserve: reserve.id,
|
|
1321
|
+
* amount: bigDecimal('1000'),
|
|
1322
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1323
|
+
* },
|
|
1113
1324
|
* });
|
|
1114
1325
|
* ```
|
|
1115
1326
|
*/
|
|
1116
|
-
declare function
|
|
1327
|
+
declare function useBorrowSwapQuote(args: UseBorrowSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1117
1328
|
/**
|
|
1118
|
-
*
|
|
1119
|
-
* Fetch a swap quote for the specified trade parameters.
|
|
1329
|
+
* Fetch a quote for a borrow swap operation with the specified parameters.
|
|
1120
1330
|
*
|
|
1121
1331
|
* Pausable loading state mode.
|
|
1122
1332
|
*
|
|
1123
1333
|
* ```tsx
|
|
1124
|
-
* const { data, error, loading, paused } =
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
*
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1334
|
+
* const { data, error, loading, paused } = useBorrowSwapQuote({
|
|
1335
|
+
* market: {
|
|
1336
|
+
* sellPosition: userBorrowItem.id,
|
|
1337
|
+
* buyReserve: reserve.id,
|
|
1338
|
+
* amount: bigDecimal('1000'),
|
|
1339
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1340
|
+
* },
|
|
1131
1341
|
* pause: true,
|
|
1132
1342
|
* });
|
|
1133
1343
|
* ```
|
|
1134
1344
|
*/
|
|
1135
|
-
declare function
|
|
1345
|
+
declare function useBorrowSwapQuote(args: Pausable<UseBorrowSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1136
1346
|
/**
|
|
1137
|
-
*
|
|
1138
|
-
* Low-level hook to execute a swap quote action directly.
|
|
1347
|
+
* Low-level hook to execute a borrow swap quote action directly.
|
|
1139
1348
|
*
|
|
1140
|
-
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
1141
1349
|
* @remarks
|
|
1142
1350
|
* 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).
|
|
1351
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1145
1352
|
*
|
|
1146
1353
|
* ```ts
|
|
1147
|
-
* const [getQuote, { called, data, error, loading }] =
|
|
1354
|
+
* const [getQuote, { called, data, error, loading }] = useBorrowSwapQuoteAction();
|
|
1148
1355
|
*
|
|
1149
1356
|
* // …
|
|
1150
1357
|
*
|
|
1151
1358
|
* const result = await getQuote({
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1359
|
+
* debtPosition: userBorrowItem.id,
|
|
1360
|
+
* buyReserve: reserve.id,
|
|
1155
1361
|
* amount: bigDecimal('1000'),
|
|
1156
|
-
*
|
|
1362
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1157
1363
|
* });
|
|
1158
1364
|
*
|
|
1159
1365
|
* if (result.isOk()) {
|
|
1160
|
-
* console.log('
|
|
1366
|
+
* console.log('Borrow swap quote:', result.value);
|
|
1161
1367
|
* } else {
|
|
1162
1368
|
* console.error(result.error);
|
|
1163
1369
|
* }
|
|
1164
1370
|
* ```
|
|
1165
1371
|
*/
|
|
1166
|
-
declare function
|
|
1167
|
-
|
|
1372
|
+
declare function useBorrowSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<BorrowSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1373
|
+
|
|
1374
|
+
type CancelSwapHandler = (data: SwapTypedData | TransactionRequest, options: {
|
|
1375
|
+
cancel: typeof cancel;
|
|
1376
|
+
}) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1377
|
+
declare class CannotCancelSwapError extends ResultAwareError {
|
|
1378
|
+
name: "CannotCancelSwapError";
|
|
1379
|
+
}
|
|
1380
|
+
type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | TimeoutError | TransactionError | UnexpectedError$1;
|
|
1168
1381
|
/**
|
|
1169
|
-
*
|
|
1170
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1171
|
-
*
|
|
1172
|
-
* This signature supports React Suspense:
|
|
1382
|
+
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
1173
1383
|
*
|
|
1174
1384
|
* ```tsx
|
|
1175
|
-
* const
|
|
1176
|
-
*
|
|
1177
|
-
* suspense: true,
|
|
1178
|
-
* });
|
|
1179
|
-
* ```
|
|
1180
|
-
*/
|
|
1181
|
-
declare function useSwappableTokens(args: UseSwappableTokensArgs & Suspendable): SuspenseResult<Token[]>;
|
|
1182
|
-
/**
|
|
1183
|
-
* @internal
|
|
1184
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1385
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1386
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1185
1387
|
*
|
|
1186
|
-
*
|
|
1388
|
+
* const [cancelSwap, { loading, error }] = useCancelSwap((plan) => {
|
|
1389
|
+
* switch (plan.__typename) {
|
|
1390
|
+
* case 'TransactionRequest':
|
|
1391
|
+
* return sendTransaction(plan);
|
|
1187
1392
|
*
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1190
|
-
*
|
|
1191
|
-
* suspense: true,
|
|
1192
|
-
* pause: true,
|
|
1393
|
+
* case 'SwapTypedData':
|
|
1394
|
+
* return signTypedData(plan);
|
|
1395
|
+
* }
|
|
1193
1396
|
* });
|
|
1194
|
-
* ```
|
|
1195
|
-
*/
|
|
1196
|
-
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs> & Suspendable): PausableSuspenseResult<Token[]>;
|
|
1197
|
-
/**
|
|
1198
|
-
* @internal
|
|
1199
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1200
1397
|
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
* query: { chainIds: [chainId(1)] },
|
|
1398
|
+
* const result = await cancelSwap({
|
|
1399
|
+
* id: swapId('123…'),
|
|
1204
1400
|
* });
|
|
1401
|
+
*
|
|
1402
|
+
* if (result.isErr()) {
|
|
1403
|
+
* console.error(result.error);
|
|
1404
|
+
* return;
|
|
1405
|
+
* }
|
|
1406
|
+
*
|
|
1407
|
+
* // result.value: SwapCancelledResult
|
|
1408
|
+
* console.log('Swap cancelled:', result.value);
|
|
1205
1409
|
* ```
|
|
1206
1410
|
*/
|
|
1207
|
-
declare function
|
|
1411
|
+
declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<PrepareSwapCancelRequest, SwapCancelledResult, CancelSwapError>;
|
|
1412
|
+
|
|
1413
|
+
type UseRepayWithSupplyRequest = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1208
1414
|
/**
|
|
1209
|
-
*
|
|
1210
|
-
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1211
|
-
*
|
|
1212
|
-
* Pausable loading state mode.
|
|
1415
|
+
* Orchestrate the repay with supply execution plan.
|
|
1213
1416
|
*
|
|
1214
1417
|
* ```tsx
|
|
1215
|
-
* const
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1418
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1419
|
+
*
|
|
1420
|
+
* const [repayWithSupply, { loading, error }] = useRepayWithSupply((plan) => {
|
|
1421
|
+
* switch (plan.__typename) {
|
|
1422
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1423
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1424
|
+
* return signTypedData(plan.bySignature);
|
|
1425
|
+
*
|
|
1426
|
+
* case 'SwapTypedData':
|
|
1427
|
+
* return signTypedData(plan);
|
|
1428
|
+
* }
|
|
1429
|
+
* });
|
|
1430
|
+
*
|
|
1431
|
+
* const result = await repayWithSupply({
|
|
1432
|
+
* market: {
|
|
1433
|
+
* sellPosition: userSupplyItem.id,
|
|
1434
|
+
* buyPosition: userBorrowItem.id,
|
|
1435
|
+
* amount: bigDecimal('1000'),
|
|
1436
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1437
|
+
* },
|
|
1218
1438
|
* });
|
|
1439
|
+
*
|
|
1440
|
+
* if (result.isErr()) {
|
|
1441
|
+
* console.error(result.error);
|
|
1442
|
+
* return;
|
|
1443
|
+
* }
|
|
1444
|
+
*
|
|
1445
|
+
* // result.value: SwapReceipt
|
|
1219
1446
|
* ```
|
|
1220
1447
|
*/
|
|
1221
|
-
declare function
|
|
1222
|
-
|
|
1448
|
+
declare function useRepayWithSupply(handler: PositionSwapHandler): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1449
|
+
|
|
1450
|
+
type UseRepayWithSupplyQuoteArgs = Prettify<RepayWithSupplyQuoteRequest & CurrencyQueryOptions>;
|
|
1223
1451
|
/**
|
|
1224
|
-
*
|
|
1225
|
-
* Fetch the user's swap history for a specific chain.
|
|
1452
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1226
1453
|
*
|
|
1227
1454
|
* This signature supports React Suspense:
|
|
1228
1455
|
*
|
|
1229
1456
|
* ```tsx
|
|
1230
|
-
* const { data } =
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1457
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1458
|
+
* market: {
|
|
1459
|
+
* sellPosition: userSupplyItem.id,
|
|
1460
|
+
* buyPosition: userBorrowItem.id,
|
|
1461
|
+
* amount: bigDecimal('1000'),
|
|
1462
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1463
|
+
* },
|
|
1234
1464
|
* suspense: true,
|
|
1235
1465
|
* });
|
|
1236
1466
|
* ```
|
|
1237
1467
|
*/
|
|
1238
|
-
declare function
|
|
1468
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1239
1469
|
/**
|
|
1240
|
-
*
|
|
1241
|
-
* Fetch the user's swap history for a specific chain.
|
|
1470
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1242
1471
|
*
|
|
1243
1472
|
* Pausable suspense mode.
|
|
1244
1473
|
*
|
|
1245
1474
|
* ```tsx
|
|
1246
|
-
* const { data } =
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1475
|
+
* const { data } = useRepayWithSupplyQuote({
|
|
1476
|
+
* market: {
|
|
1477
|
+
* sellPosition: userSupplyItem.id,
|
|
1478
|
+
* buyPosition: userBorrowItem.id,
|
|
1479
|
+
* amount: bigDecimal('1000'),
|
|
1480
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1481
|
+
* },
|
|
1250
1482
|
* suspense: true,
|
|
1251
1483
|
* pause: true,
|
|
1252
1484
|
* });
|
|
1253
1485
|
* ```
|
|
1254
1486
|
*/
|
|
1255
|
-
declare function
|
|
1487
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1256
1488
|
/**
|
|
1257
|
-
*
|
|
1258
|
-
* Fetch the user's swap history for a specific chain.
|
|
1489
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1259
1490
|
*
|
|
1260
1491
|
* ```tsx
|
|
1261
|
-
* const { data, error, loading } =
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1492
|
+
* const { data, error, loading } = useRepayWithSupplyQuote({
|
|
1493
|
+
* market: {
|
|
1494
|
+
* sellPosition: userSupplyItem.id,
|
|
1495
|
+
* buyPosition: userBorrowItem.id,
|
|
1496
|
+
* amount: bigDecimal('1000'),
|
|
1497
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1498
|
+
* },
|
|
1265
1499
|
* });
|
|
1266
1500
|
* ```
|
|
1267
1501
|
*/
|
|
1268
|
-
declare function
|
|
1502
|
+
declare function useRepayWithSupplyQuote(args: UseRepayWithSupplyQuoteArgs): ReadResult<SwapQuote>;
|
|
1269
1503
|
/**
|
|
1270
|
-
*
|
|
1271
|
-
* Fetch the user's swap history for a specific chain.
|
|
1504
|
+
* Fetch a quote for a repay with supply operation with the specified parameters.
|
|
1272
1505
|
*
|
|
1273
1506
|
* Pausable loading state mode.
|
|
1274
1507
|
*
|
|
1275
1508
|
* ```tsx
|
|
1276
|
-
* const { data, error, loading, paused } =
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1509
|
+
* const { data, error, loading, paused } = useRepayWithSupplyQuote({
|
|
1510
|
+
* market: {
|
|
1511
|
+
* sellPosition: userSupplyItem.id,
|
|
1512
|
+
* buyPosition: userBorrowItem.id,
|
|
1513
|
+
* amount: bigDecimal('1000'),
|
|
1514
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1515
|
+
* },
|
|
1280
1516
|
* pause: true,
|
|
1281
1517
|
* });
|
|
1282
1518
|
* ```
|
|
1283
1519
|
*/
|
|
1284
|
-
declare function
|
|
1285
|
-
type UseSwapTokensRequest = Prettify<PrepareSwapRequest & CurrencyQueryOptions>;
|
|
1286
|
-
type SwapIntent = SwapByIntentTypedData | SwapByIntentWithApprovalRequired | SwapTransactionRequest | SwapApprovalRequired;
|
|
1287
|
-
type SwapHandlerOptions = {
|
|
1288
|
-
cancel: CancelOperation;
|
|
1289
|
-
};
|
|
1290
|
-
type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAsync<ERC20PermitSignature | SwapReceipt, SendTransactionError | PendingTransactionError>;
|
|
1520
|
+
declare function useRepayWithSupplyQuote(args: Pausable<UseRepayWithSupplyQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1291
1521
|
/**
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1522
|
+
* Low-level hook to execute a repay with supply quote action directly.
|
|
1523
|
+
*
|
|
1524
|
+
* @remarks
|
|
1525
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1526
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1527
|
+
*
|
|
1528
|
+
* ```ts
|
|
1529
|
+
* const [getQuote, { called, data, error, loading }] = useRepayWithSupplyQuoteAction();
|
|
1530
|
+
*
|
|
1531
|
+
* // …
|
|
1532
|
+
*
|
|
1533
|
+
* const result = await getQuote({
|
|
1534
|
+
* repayWithReserve: reserve.id,
|
|
1535
|
+
* debtPosition: userBorrowItem.id,
|
|
1536
|
+
* amount: bigDecimal('1000'),
|
|
1537
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1538
|
+
* });
|
|
1539
|
+
*
|
|
1540
|
+
* if (result.isOk()) {
|
|
1541
|
+
* console.log('Repay with supply quote:', result.value);
|
|
1542
|
+
* } else {
|
|
1543
|
+
* console.error(result.error);
|
|
1544
|
+
* }
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
declare function useRepayWithSupplyQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<RepayWithSupplyQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1548
|
+
|
|
1549
|
+
type UseSupplySwapRequest = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1550
|
+
/**
|
|
1551
|
+
* Orchestrate the supply swap execution plan.
|
|
1294
1552
|
*
|
|
1295
1553
|
* ```tsx
|
|
1296
|
-
* const [
|
|
1297
|
-
* const [signSwapByIntentWith, signing] = useSignSwapByIntentWith(wallet);
|
|
1554
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1298
1555
|
*
|
|
1299
|
-
* const [
|
|
1556
|
+
* const [swapSupply, { loading, error }] = useSupplySwap((plan) => {
|
|
1300
1557
|
* switch (plan.__typename) {
|
|
1301
|
-
* case '
|
|
1302
|
-
*
|
|
1558
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
1559
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
1560
|
+
* return signTypedData(plan.bySignature);
|
|
1303
1561
|
*
|
|
1304
|
-
* case '
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1562
|
+
* case 'SwapTypedData':
|
|
1563
|
+
* return signTypedData(plan);
|
|
1564
|
+
* }
|
|
1565
|
+
* });
|
|
1566
|
+
*
|
|
1567
|
+
* const result = await swapSupply({
|
|
1568
|
+
* market: {
|
|
1569
|
+
* sellPosition: supplyPosition.id,
|
|
1570
|
+
* buyReserve: targetReserve.id,
|
|
1571
|
+
* amount: bigDecimal('1000'),
|
|
1572
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1573
|
+
* enableCollateral: true,
|
|
1574
|
+
* },
|
|
1575
|
+
* });
|
|
1576
|
+
*
|
|
1577
|
+
* if (result.isErr()) {
|
|
1578
|
+
* console.error(result.error);
|
|
1579
|
+
* return;
|
|
1580
|
+
* }
|
|
1581
|
+
*
|
|
1582
|
+
* // result.value: SwapReceipt
|
|
1583
|
+
* ```
|
|
1584
|
+
*/
|
|
1585
|
+
declare function useSupplySwap(handler: PositionSwapHandler): UseAsyncTask<SupplySwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1586
|
+
|
|
1587
|
+
type UseSupplySwapQuoteArgs = Prettify<SupplySwapQuoteRequest & CurrencyQueryOptions>;
|
|
1588
|
+
/**
|
|
1589
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1590
|
+
*
|
|
1591
|
+
* This signature supports React Suspense:
|
|
1592
|
+
*
|
|
1593
|
+
* ```tsx
|
|
1594
|
+
* const { data } = useSupplySwapQuote({
|
|
1595
|
+
* market: {
|
|
1596
|
+
* sellPosition: userSupplyItem.id,
|
|
1597
|
+
* buyReserve: reserve.id,
|
|
1598
|
+
* amount: bigDecimal('1000'),
|
|
1599
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1600
|
+
* },
|
|
1601
|
+
* suspense: true,
|
|
1602
|
+
* });
|
|
1603
|
+
* ```
|
|
1604
|
+
*/
|
|
1605
|
+
declare function useSupplySwapQuote(args: UseSupplySwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1608
|
+
*
|
|
1609
|
+
* Pausable suspense mode.
|
|
1610
|
+
*
|
|
1611
|
+
* ```tsx
|
|
1612
|
+
* const { data } = useSupplySwapQuote({
|
|
1613
|
+
* market: {
|
|
1614
|
+
* sellPosition: userSupplyItem.id,
|
|
1615
|
+
* buyReserve: reserve.id,
|
|
1616
|
+
* amount: bigDecimal('1000'),
|
|
1617
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1618
|
+
* },
|
|
1619
|
+
* suspense: true,
|
|
1620
|
+
* pause: true,
|
|
1621
|
+
* });
|
|
1622
|
+
* ```
|
|
1623
|
+
*/
|
|
1624
|
+
declare function useSupplySwapQuote(args: Pausable<UseSupplySwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1627
|
+
*
|
|
1628
|
+
* ```tsx
|
|
1629
|
+
* const { data, error, loading } = useSupplySwapQuote({
|
|
1630
|
+
* market: {
|
|
1631
|
+
* sellPosition: userSupplyItem.id,
|
|
1632
|
+
* buyReserve: reserve.id,
|
|
1633
|
+
* amount: bigDecimal('1000'),
|
|
1634
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1635
|
+
* },
|
|
1636
|
+
* });
|
|
1637
|
+
* ```
|
|
1638
|
+
*/
|
|
1639
|
+
declare function useSupplySwapQuote(args: UseSupplySwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1640
|
+
/**
|
|
1641
|
+
* Fetch a quote for a supply swap operation with the specified parameters.
|
|
1642
|
+
*
|
|
1643
|
+
* Pausable loading state mode.
|
|
1644
|
+
*
|
|
1645
|
+
* ```tsx
|
|
1646
|
+
* const { data, error, loading, paused } = useSupplySwapQuote({
|
|
1647
|
+
* market: {
|
|
1648
|
+
* sellPosition: userSupplyItem.id,
|
|
1649
|
+
* buyReserve: reserve.id,
|
|
1650
|
+
* amount: bigDecimal('1000'),
|
|
1651
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1652
|
+
* },
|
|
1653
|
+
* pause: true,
|
|
1654
|
+
* });
|
|
1655
|
+
* ```
|
|
1656
|
+
*/
|
|
1657
|
+
declare function useSupplySwapQuote(args: Pausable<UseSupplySwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1658
|
+
/**
|
|
1659
|
+
* Low-level hook to execute a supply swap quote action directly.
|
|
1660
|
+
*
|
|
1661
|
+
* @remarks
|
|
1662
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1663
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1664
|
+
*
|
|
1665
|
+
* ```ts
|
|
1666
|
+
* const [getQuote, { called, data, error, loading }] = useSupplySwapQuoteAction();
|
|
1667
|
+
*
|
|
1668
|
+
* // …
|
|
1669
|
+
*
|
|
1670
|
+
* const result = await getQuote({
|
|
1671
|
+
* sellPosition: userSupplyItem.id,
|
|
1672
|
+
* buyReserve: reserve.id,
|
|
1673
|
+
* amount: bigDecimal('1000'),
|
|
1674
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1675
|
+
* });
|
|
1676
|
+
*
|
|
1677
|
+
* if (result.isOk()) {
|
|
1678
|
+
* console.log('Supply swap quote:', result.value);
|
|
1679
|
+
* } else {
|
|
1680
|
+
* console.error(result.error);
|
|
1681
|
+
* }
|
|
1682
|
+
* ```
|
|
1683
|
+
*/
|
|
1684
|
+
declare function useSupplySwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<SupplySwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1685
|
+
|
|
1686
|
+
type UseSwappableTokensArgs = SwappableTokensRequest;
|
|
1687
|
+
/**
|
|
1688
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1689
|
+
*
|
|
1690
|
+
* This signature supports React Suspense:
|
|
1691
|
+
*
|
|
1692
|
+
* ```tsx
|
|
1693
|
+
* const { data } = useSwappableTokens({
|
|
1694
|
+
* query: { chainIds: [chainId(1)] },
|
|
1695
|
+
* suspense: true,
|
|
1696
|
+
* });
|
|
1697
|
+
* ```
|
|
1698
|
+
*/
|
|
1699
|
+
declare function useSwappableTokens(args: UseSwappableTokensArgs & Suspendable): SuspenseResult<Token[]>;
|
|
1700
|
+
/**
|
|
1701
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1702
|
+
*
|
|
1703
|
+
* Pausable suspense mode.
|
|
1704
|
+
*
|
|
1705
|
+
* ```tsx
|
|
1706
|
+
* const { data } = useSwappableTokens({
|
|
1707
|
+
* query: { chainIds: [chainId(1)] },
|
|
1708
|
+
* suspense: true,
|
|
1709
|
+
* pause: true,
|
|
1710
|
+
* });
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs> & Suspendable): PausableSuspenseResult<Token[]>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1716
|
+
*
|
|
1717
|
+
* ```tsx
|
|
1718
|
+
* const { data, error, loading } = useSwappableTokens({
|
|
1719
|
+
* query: { chainIds: [chainId(1)] },
|
|
1720
|
+
* });
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
declare function useSwappableTokens(args: UseSwappableTokensArgs): ReadResult<Token[]>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1726
|
+
*
|
|
1727
|
+
* Pausable loading state mode.
|
|
1728
|
+
*
|
|
1729
|
+
* ```tsx
|
|
1730
|
+
* const { data, error, loading, paused } = useSwappableTokens({
|
|
1731
|
+
* query: { chainIds: [chainId(1)] },
|
|
1732
|
+
* pause: true,
|
|
1733
|
+
* });
|
|
1734
|
+
* ```
|
|
1735
|
+
*/
|
|
1736
|
+
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs>): PausableReadResult<Token[]>;
|
|
1737
|
+
|
|
1738
|
+
type UseSwapStatusArgs = Prettify<SwapStatusRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1741
|
+
*
|
|
1742
|
+
* Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).
|
|
1743
|
+
*
|
|
1744
|
+
* This signature supports React Suspense:
|
|
1745
|
+
*
|
|
1746
|
+
* ```tsx
|
|
1747
|
+
* const { data } = useSwapStatus({
|
|
1748
|
+
* id: swapReceipt.id,
|
|
1749
|
+
* suspense: true,
|
|
1750
|
+
* });
|
|
1751
|
+
* ```
|
|
1752
|
+
*/
|
|
1753
|
+
declare function useSwapStatus(args: UseSwapStatusArgs & Suspendable): SuspenseResult<SwapStatus>;
|
|
1754
|
+
/**
|
|
1755
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1756
|
+
*
|
|
1757
|
+
* Pausable suspense mode.
|
|
1758
|
+
*
|
|
1759
|
+
* ```tsx
|
|
1760
|
+
* const { data } = useSwapStatus({
|
|
1761
|
+
* id: swapReceipt.id,
|
|
1762
|
+
* suspense: true,
|
|
1763
|
+
* pause: shouldPause,
|
|
1764
|
+
* });
|
|
1765
|
+
* ```
|
|
1766
|
+
*/
|
|
1767
|
+
declare function useSwapStatus(args: Pausable<UseSwapStatusArgs> & Suspendable): PausableSuspenseResult<SwapStatus>;
|
|
1768
|
+
/**
|
|
1769
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1770
|
+
*
|
|
1771
|
+
* Polls automatically until the swap reaches a terminal state (fulfilled, cancelled, or expired).
|
|
1772
|
+
*
|
|
1773
|
+
* ```tsx
|
|
1774
|
+
* const { data, error, loading } = useSwapStatus({
|
|
1775
|
+
* id: swapReceipt.id,
|
|
1776
|
+
* });
|
|
1777
|
+
* ```
|
|
1778
|
+
*/
|
|
1779
|
+
declare function useSwapStatus(args: UseSwapStatusArgs): ReadResult<SwapStatus>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Monitor the status of a single swap operation in real-time.
|
|
1782
|
+
*
|
|
1783
|
+
* Pausable loading state mode.
|
|
1784
|
+
*
|
|
1785
|
+
* ```tsx
|
|
1786
|
+
* const { data, error, loading, paused } = useSwapStatus({
|
|
1787
|
+
* id: swapReceipt.id,
|
|
1788
|
+
* pause: shouldPause,
|
|
1789
|
+
* });
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
1792
|
+
declare function useSwapStatus(args: Pausable<UseSwapStatusArgs>): PausableReadResult<SwapStatus>;
|
|
1793
|
+
|
|
1794
|
+
type UseTokenSwapRequest = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1795
|
+
type TokenSwapPlan = SwapTypedData | Erc20Approval | SwapTransactionRequest;
|
|
1796
|
+
type TokenSwapHandler = (plan: TokenSwapPlan, options: SwapHandlerOptions) => ResultAsync<PendingTransaction | Signature, SwapSignerError>;
|
|
1797
|
+
/**
|
|
1798
|
+
* Orchestrate the token swap execution plan.
|
|
1799
|
+
*
|
|
1800
|
+
* ```tsx
|
|
1801
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1802
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
1803
|
+
*
|
|
1804
|
+
* const [swap, { loading, error }] = useTokenSwap((plan) => {
|
|
1805
|
+
* switch (plan.__typename) {
|
|
1806
|
+
* case 'Erc20Approval':
|
|
1807
|
+
* if (plan.bySignature) {
|
|
1808
|
+
* return signTypedData(plan.bySignature);
|
|
1809
|
+
* }
|
|
1810
|
+
* return sendTransaction(plan.byTransaction);
|
|
1307
1811
|
*
|
|
1308
1812
|
* case 'SwapTransactionRequest':
|
|
1309
1813
|
* return sendTransaction(plan.transaction);
|
|
1814
|
+
*
|
|
1815
|
+
* case 'SwapTypedData':
|
|
1816
|
+
* return signTypedData(plan);
|
|
1310
1817
|
* }
|
|
1311
1818
|
* });
|
|
1312
1819
|
*
|
|
1313
1820
|
* const result = await swap({
|
|
1821
|
+
* fromQuote: {
|
|
1822
|
+
* quoteId: quote.quoteId,
|
|
1823
|
+
* },
|
|
1824
|
+
* });
|
|
1825
|
+
*
|
|
1826
|
+
* if (result.isErr()) {
|
|
1827
|
+
* console.error(result.error);
|
|
1828
|
+
* return;
|
|
1829
|
+
* }
|
|
1830
|
+
*
|
|
1831
|
+
* // result.value: SwapReceipt
|
|
1832
|
+
* ```
|
|
1833
|
+
*/
|
|
1834
|
+
declare function useTokenSwap(handler: TokenSwapHandler): UseAsyncTask<UseTokenSwapRequest, SwapReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
1835
|
+
|
|
1836
|
+
type UseTokenSwapQuoteArgs = Prettify<TokenSwapQuoteRequest & CurrencyQueryOptions>;
|
|
1837
|
+
/**
|
|
1838
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1839
|
+
*
|
|
1840
|
+
* This signature supports React Suspense:
|
|
1841
|
+
*
|
|
1842
|
+
* ```tsx
|
|
1843
|
+
* const { data } = useTokenSwapQuote({
|
|
1844
|
+
* market: {
|
|
1845
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1846
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1847
|
+
* amount: bigDecimal('1000'),
|
|
1848
|
+
* kind: SwapKind.Sell,
|
|
1849
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1850
|
+
* },
|
|
1851
|
+
* chainId: chainId(1),
|
|
1852
|
+
* suspense: true,
|
|
1853
|
+
* });
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1857
|
+
/**
|
|
1858
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1859
|
+
*
|
|
1860
|
+
* Pausable suspense mode.
|
|
1861
|
+
*
|
|
1862
|
+
* ```tsx
|
|
1863
|
+
* const { data } = useTokenSwapQuote({
|
|
1864
|
+
* market: {
|
|
1865
|
+
* chainId: chainId(1),
|
|
1866
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1867
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1868
|
+
* amount: bigDecimal('1000'),
|
|
1869
|
+
* kind: SwapKind.Sell,
|
|
1870
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1871
|
+
* },
|
|
1872
|
+
* suspense: true,
|
|
1873
|
+
* pause: true,
|
|
1874
|
+
* });
|
|
1875
|
+
* ```
|
|
1876
|
+
*/
|
|
1877
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1878
|
+
/**
|
|
1879
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1880
|
+
*
|
|
1881
|
+
* ```tsx
|
|
1882
|
+
* const { data, error, loading } = useTokenSwapQuote({
|
|
1314
1883
|
* market: {
|
|
1315
1884
|
* chainId: chainId(1),
|
|
1316
|
-
* buy: { erc20: evmAddress('0xA0b86a33E6
|
|
1317
|
-
* sell: { erc20: evmAddress('0x6B175474E
|
|
1885
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1886
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1318
1887
|
* amount: bigDecimal('1000'),
|
|
1319
|
-
* kind: SwapKind.
|
|
1320
|
-
* user: evmAddress('0x742d35cc
|
|
1888
|
+
* kind: SwapKind.Sell,
|
|
1889
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1890
|
+
* },
|
|
1891
|
+
* });
|
|
1892
|
+
* ```
|
|
1893
|
+
*/
|
|
1894
|
+
declare function useTokenSwapQuote(args: UseTokenSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1895
|
+
/**
|
|
1896
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1897
|
+
*
|
|
1898
|
+
* Pausable loading state mode.
|
|
1899
|
+
*
|
|
1900
|
+
* ```tsx
|
|
1901
|
+
* const { data, error, loading, paused } = useTokenSwapQuote({
|
|
1902
|
+
* market: {
|
|
1903
|
+
* chainId: chainId(1),
|
|
1904
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1905
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1906
|
+
* amount: bigDecimal('1000'),
|
|
1907
|
+
* kind: SwapKind.Sell,
|
|
1908
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1909
|
+
* },
|
|
1910
|
+
* pause: true,
|
|
1911
|
+
* });
|
|
1912
|
+
* ```
|
|
1913
|
+
*/
|
|
1914
|
+
declare function useTokenSwapQuote(args: Pausable<UseTokenSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1915
|
+
/**
|
|
1916
|
+
* Low-level hook to execute a swap quote action directly.
|
|
1917
|
+
*
|
|
1918
|
+
* @remarks
|
|
1919
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
1920
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow
|
|
1921
|
+
* (e.g., in an event handler to get a fresh quote before executing a swap).
|
|
1922
|
+
*
|
|
1923
|
+
* ```ts
|
|
1924
|
+
* const [getQuote, { called, data, error, loading }] = useTokenSwapQuoteAction();
|
|
1925
|
+
*
|
|
1926
|
+
* // …
|
|
1927
|
+
*
|
|
1928
|
+
* const result = await getQuote({
|
|
1929
|
+
* market: {
|
|
1930
|
+
* chainId: chainId(1),
|
|
1931
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
1932
|
+
* sell: { erc20: evmAddress('0x6B175474E…') },
|
|
1933
|
+
* amount: bigDecimal('1000'),
|
|
1934
|
+
* kind: SwapKind.Sell,
|
|
1935
|
+
* },
|
|
1936
|
+
* });
|
|
1937
|
+
*
|
|
1938
|
+
* if (result.isOk()) {
|
|
1939
|
+
* console.log('Swap quote:', result.value);
|
|
1940
|
+
* } else {
|
|
1941
|
+
* console.error(result.error);
|
|
1942
|
+
* }
|
|
1943
|
+
* ```
|
|
1944
|
+
*/
|
|
1945
|
+
declare function useTokenSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<TokenSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1946
|
+
|
|
1947
|
+
type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Fetch the user's swap history for a specific chain.
|
|
1950
|
+
*
|
|
1951
|
+
* This signature supports React Suspense:
|
|
1952
|
+
*
|
|
1953
|
+
* ```tsx
|
|
1954
|
+
* const { data } = useUserSwaps({
|
|
1955
|
+
* chainId: chainId(1),
|
|
1956
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1957
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1958
|
+
* suspense: true,
|
|
1959
|
+
* });
|
|
1960
|
+
* ```
|
|
1961
|
+
*/
|
|
1962
|
+
declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseResult<PaginatedUserSwapsResult>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Fetch the user's swap history for a specific chain.
|
|
1965
|
+
*
|
|
1966
|
+
* Pausable suspense mode.
|
|
1967
|
+
*
|
|
1968
|
+
* ```tsx
|
|
1969
|
+
* const { data } = useUserSwaps({
|
|
1970
|
+
* chainId: chainId(1),
|
|
1971
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1972
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1973
|
+
* suspense: true,
|
|
1974
|
+
* pause: true,
|
|
1975
|
+
* });
|
|
1976
|
+
* ```
|
|
1977
|
+
*/
|
|
1978
|
+
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs> & Suspendable): PausableSuspenseResult<PaginatedUserSwapsResult>;
|
|
1979
|
+
/**
|
|
1980
|
+
* Fetch the user's swap history for a specific chain.
|
|
1981
|
+
*
|
|
1982
|
+
* ```tsx
|
|
1983
|
+
* const { data, error, loading } = useUserSwaps({
|
|
1984
|
+
* chainId: chainId(1),
|
|
1985
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1986
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1987
|
+
* });
|
|
1988
|
+
* ```
|
|
1989
|
+
*/
|
|
1990
|
+
declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserSwapsResult>;
|
|
1991
|
+
/**
|
|
1992
|
+
* Fetch the user's swap history for a specific chain.
|
|
1993
|
+
*
|
|
1994
|
+
* Pausable loading state mode.
|
|
1995
|
+
*
|
|
1996
|
+
* ```tsx
|
|
1997
|
+
* const { data, error, loading, paused } = useUserSwaps({
|
|
1998
|
+
* chainId: chainId(1),
|
|
1999
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2000
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
2001
|
+
* pause: true,
|
|
2002
|
+
* });
|
|
2003
|
+
* ```
|
|
2004
|
+
*/
|
|
2005
|
+
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs>): PausableReadResult<PaginatedUserSwapsResult>;
|
|
2006
|
+
|
|
2007
|
+
type UseWithdrawSwapRequest = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
2008
|
+
/**
|
|
2009
|
+
* Orchestrate the withdraw swap execution plan.
|
|
2010
|
+
*
|
|
2011
|
+
* ```tsx
|
|
2012
|
+
* const [signTypedData] = useSignTypedData(wallet);
|
|
2013
|
+
*
|
|
2014
|
+
* const [withdrawSwap, { loading, error }] = useWithdrawSwap((plan) => {
|
|
2015
|
+
* switch (plan.__typename) {
|
|
2016
|
+
* case 'PositionSwapAdapterContractApproval':
|
|
2017
|
+
* case 'PositionSwapPositionManagerApproval':
|
|
2018
|
+
* return signTypedData(plan.bySignature);
|
|
2019
|
+
*
|
|
2020
|
+
* case 'SwapTypedData':
|
|
2021
|
+
* return signTypedData(plan);
|
|
2022
|
+
* }
|
|
2023
|
+
* });
|
|
2024
|
+
*
|
|
2025
|
+
* const result = await withdrawSwap({
|
|
2026
|
+
* market: {
|
|
2027
|
+
* position: userSupplyItem.id,
|
|
2028
|
+
* buyToken: { erc20: evmAddress('0xA0b86a33E6…') },
|
|
2029
|
+
* amount: bigDecimal('1000'),
|
|
2030
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1321
2031
|
* },
|
|
1322
2032
|
* });
|
|
1323
2033
|
*
|
|
@@ -1329,99 +2039,191 @@ type SwapHandler = (intent: SwapIntent, options: SwapHandlerOptions) => ResultAs
|
|
|
1329
2039
|
* // result.value: SwapReceipt
|
|
1330
2040
|
* ```
|
|
1331
2041
|
*/
|
|
1332
|
-
declare function
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
2042
|
+
declare function useWithdrawSwap(handler: PositionSwapHandler): UseAsyncTask<WithdrawSwapQuoteRequest, SwapReceipt, SwapSignerError | SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError | InsufficientLiquidityError>>;
|
|
2043
|
+
|
|
2044
|
+
type UseWithdrawSwapQuoteArgs = Prettify<WithdrawSwapQuoteRequest & CurrencyQueryOptions>;
|
|
2045
|
+
/**
|
|
2046
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2047
|
+
*
|
|
2048
|
+
* This signature supports React Suspense:
|
|
2049
|
+
*
|
|
2050
|
+
* ```tsx
|
|
2051
|
+
* const { data } = useWithdrawSwapQuote({
|
|
2052
|
+
* market: {
|
|
2053
|
+
* position: userSupplyItem.id,
|
|
2054
|
+
* buyReserve: reserve.id,
|
|
2055
|
+
* amount: bigDecimal('1000'),
|
|
2056
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2057
|
+
* },
|
|
2058
|
+
* suspense: true,
|
|
2059
|
+
* });
|
|
2060
|
+
* ```
|
|
2061
|
+
*/
|
|
2062
|
+
declare function useWithdrawSwapQuote(args: UseWithdrawSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
2063
|
+
/**
|
|
2064
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2065
|
+
*
|
|
2066
|
+
* Pausable suspense mode.
|
|
2067
|
+
*
|
|
2068
|
+
* ```tsx
|
|
2069
|
+
* const { data } = useWithdrawSwapQuote({
|
|
2070
|
+
* market: {
|
|
2071
|
+
* position: userSupplyItem.id,
|
|
2072
|
+
* buyReserve: reserve.id,
|
|
2073
|
+
* amount: bigDecimal('1000'),
|
|
2074
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2075
|
+
* },
|
|
2076
|
+
* suspense: true,
|
|
2077
|
+
* pause: true,
|
|
2078
|
+
* });
|
|
2079
|
+
* ```
|
|
2080
|
+
*/
|
|
2081
|
+
declare function useWithdrawSwapQuote(args: Pausable<UseWithdrawSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2084
|
+
*
|
|
2085
|
+
* ```tsx
|
|
2086
|
+
* const { data, error, loading } = useWithdrawSwapQuote({
|
|
2087
|
+
* market: {
|
|
2088
|
+
* position: userSupplyItem.id,
|
|
2089
|
+
* buyReserve: reserve.id,
|
|
2090
|
+
* amount: bigDecimal('1000'),
|
|
2091
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2092
|
+
* },
|
|
2093
|
+
* });
|
|
2094
|
+
* ```
|
|
2095
|
+
*/
|
|
2096
|
+
declare function useWithdrawSwapQuote(args: UseWithdrawSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Fetch a quote for a withdraw swap operation with the specified parameters.
|
|
2099
|
+
*
|
|
2100
|
+
* Pausable loading state mode.
|
|
2101
|
+
*
|
|
2102
|
+
* ```tsx
|
|
2103
|
+
* const { data, error, loading, paused } = useWithdrawSwapQuote({
|
|
2104
|
+
* market: {
|
|
2105
|
+
* position: userSupplyItem.id,
|
|
2106
|
+
* buyReserve: reserve.id,
|
|
2107
|
+
* amount: bigDecimal('1000'),
|
|
2108
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2109
|
+
* },
|
|
2110
|
+
* pause: true,
|
|
2111
|
+
* });
|
|
2112
|
+
* ```
|
|
2113
|
+
*/
|
|
2114
|
+
declare function useWithdrawSwapQuote(args: Pausable<UseWithdrawSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1338
2115
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
2116
|
+
* Low-level hook to execute a withdraw swap quote action directly.
|
|
1341
2117
|
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
2118
|
+
* @remarks
|
|
2119
|
+
* This hook **does not** actively watch for updated data on the swap quote.
|
|
2120
|
+
* Use this hook to retrieve quotes on demand as part of a larger workflow.
|
|
1345
2121
|
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
* case 'TransactionRequest':
|
|
1349
|
-
* return sendTransaction(plan);
|
|
2122
|
+
* ```ts
|
|
2123
|
+
* const [getQuote, { called, data, error, loading }] = useWithdrawSwapQuoteAction();
|
|
1350
2124
|
*
|
|
1351
|
-
*
|
|
1352
|
-
* return signSwapCancelWith(plan);
|
|
1353
|
-
* }
|
|
1354
|
-
* });
|
|
2125
|
+
* // …
|
|
1355
2126
|
*
|
|
1356
|
-
* const result = await
|
|
1357
|
-
*
|
|
2127
|
+
* const result = await getQuote({
|
|
2128
|
+
* position: userSupplyItem.id,
|
|
2129
|
+
* buyReserve: reserve.id,
|
|
2130
|
+
* amount: bigDecimal('1000'),
|
|
2131
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1358
2132
|
* });
|
|
1359
2133
|
*
|
|
1360
|
-
* if (result.
|
|
2134
|
+
* if (result.isOk()) {
|
|
2135
|
+
* console.log('Withdraw swap quote:', result.value);
|
|
2136
|
+
* } else {
|
|
1361
2137
|
* console.error(result.error);
|
|
1362
|
-
* return;
|
|
1363
2138
|
* }
|
|
1364
|
-
*
|
|
1365
|
-
* // result.value: SwapCancelled
|
|
1366
|
-
* console.log('Swap cancelled:', result.value);
|
|
1367
2139
|
* ```
|
|
1368
2140
|
*/
|
|
1369
|
-
declare function
|
|
2141
|
+
declare function useWithdrawSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<WithdrawSwapQuoteRequest, SwapQuote, UnexpectedError$1 | ValidationError<InsufficientLiquidityError>>;
|
|
1370
2142
|
|
|
2143
|
+
type UseActivitiesArgs = Prettify<ActivitiesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
1371
2144
|
/**
|
|
1372
|
-
*
|
|
2145
|
+
* Fetch paginated list of activities.
|
|
1373
2146
|
*
|
|
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
|
-
* });
|
|
2147
|
+
* This signature supports React Suspense:
|
|
1385
2148
|
*
|
|
1386
|
-
*
|
|
2149
|
+
* ```tsx
|
|
2150
|
+
* const { data } = useActivities({
|
|
2151
|
+
* query: {
|
|
2152
|
+
* chainId: chainId(1),
|
|
2153
|
+
* },
|
|
2154
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2155
|
+
* suspense: true,
|
|
2156
|
+
* });
|
|
1387
2157
|
*
|
|
1388
|
-
*
|
|
2158
|
+
* // data.items: ActivityItem[]
|
|
2159
|
+
* ```
|
|
2160
|
+
*/
|
|
2161
|
+
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2162
|
+
/**
|
|
2163
|
+
* Fetch paginated list of activities.
|
|
1389
2164
|
*
|
|
1390
|
-
*
|
|
1391
|
-
* switch (result.error.name) {
|
|
1392
|
-
* case 'CancelError':
|
|
1393
|
-
* // The user cancelled the operation
|
|
1394
|
-
* return;
|
|
2165
|
+
* Pausable suspense mode.
|
|
1395
2166
|
*
|
|
1396
|
-
*
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
2167
|
+
* ```tsx
|
|
2168
|
+
* const { data } = useActivities({
|
|
2169
|
+
* query: {
|
|
2170
|
+
* chainId: chainId(1),
|
|
2171
|
+
* },
|
|
2172
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2173
|
+
* suspense: true,
|
|
2174
|
+
* pause: true,
|
|
2175
|
+
* });
|
|
1399
2176
|
*
|
|
1400
|
-
*
|
|
1401
|
-
*
|
|
1402
|
-
|
|
2177
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2178
|
+
* ```
|
|
2179
|
+
*/
|
|
2180
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Fetch paginated list of activities.
|
|
1403
2183
|
*
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
2184
|
+
* ```tsx
|
|
2185
|
+
* const { data, error, loading } = useActivities({
|
|
2186
|
+
* query: {
|
|
2187
|
+
* chainId: chainId(1),
|
|
2188
|
+
* },
|
|
2189
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2190
|
+
* });
|
|
2191
|
+
* ```
|
|
2192
|
+
*/
|
|
2193
|
+
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
2194
|
+
/**
|
|
2195
|
+
* Fetch paginated list of activities.
|
|
1407
2196
|
*
|
|
1408
|
-
*
|
|
1409
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1410
|
-
* break;
|
|
2197
|
+
* Pausable loading state mode.
|
|
1411
2198
|
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
2199
|
+
* ```tsx
|
|
2200
|
+
* const { data, error, loading } = useActivities({
|
|
2201
|
+
* query: {
|
|
2202
|
+
* chainId: chainId(1),
|
|
2203
|
+
* },
|
|
2204
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2205
|
+
* pause: true,
|
|
2206
|
+
* });
|
|
1418
2207
|
*
|
|
1419
|
-
*
|
|
2208
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2209
|
+
* // error: UnexpectedError | undefined
|
|
2210
|
+
* // loading: boolean | undefined
|
|
1420
2211
|
* ```
|
|
2212
|
+
*/
|
|
2213
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2214
|
+
/**
|
|
2215
|
+
* Low-level hook to execute a {@link activities} action directly.
|
|
1421
2216
|
*
|
|
1422
|
-
* @
|
|
2217
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2218
|
+
* @remarks
|
|
2219
|
+
* This hook does not actively watch for updates. Use it to fetch activities on demand
|
|
2220
|
+
* (e.g., in an event handler when paginating or refining filters).
|
|
2221
|
+
*
|
|
2222
|
+
* @param options - The query options.
|
|
2223
|
+
* @returns The user history.
|
|
1423
2224
|
*/
|
|
1424
|
-
declare function
|
|
2225
|
+
declare function useActivitiesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError>;
|
|
2226
|
+
|
|
1425
2227
|
/**
|
|
1426
2228
|
* A hook that provides a way to borrow assets from an Aave reserve.
|
|
1427
2229
|
*
|
|
@@ -1431,7 +2233,7 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1431
2233
|
* switch (plan.__typename) {
|
|
1432
2234
|
* case 'TransactionRequest':
|
|
1433
2235
|
* return sendTransaction(plan);
|
|
1434
|
-
*
|
|
2236
|
+
*
|
|
1435
2237
|
* case 'PreContractActionRequired':
|
|
1436
2238
|
* return sendTransaction(plan.transaction);
|
|
1437
2239
|
* }
|
|
@@ -1470,30 +2272,27 @@ declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequ
|
|
|
1470
2272
|
* return;
|
|
1471
2273
|
* }
|
|
1472
2274
|
*
|
|
1473
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2275
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1474
2276
|
* ```
|
|
1475
2277
|
*
|
|
1476
2278
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1477
2279
|
*/
|
|
1478
|
-
declare function useBorrow(handler:
|
|
2280
|
+
declare function useBorrow(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<BorrowRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2281
|
+
|
|
1479
2282
|
/**
|
|
1480
|
-
* A hook that provides a way to
|
|
2283
|
+
* A hook that provides a way to claim rewards.
|
|
1481
2284
|
*
|
|
1482
2285
|
* ```ts
|
|
1483
2286
|
* 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
|
-
* }
|
|
2287
|
+
* const [claim, { loading, error }] = useClaimRewards((transaction, { cancel }) => {
|
|
2288
|
+
* return sendTransaction(transaction);
|
|
1492
2289
|
* });
|
|
1493
2290
|
*
|
|
1494
2291
|
* // …
|
|
1495
2292
|
*
|
|
1496
|
-
* const result = await
|
|
2293
|
+
* const result = await claim({
|
|
2294
|
+
* ids: [rewardId('abc123')],
|
|
2295
|
+
* });
|
|
1497
2296
|
*
|
|
1498
2297
|
* if (result.isErr()) {
|
|
1499
2298
|
* switch (result.error.name) {
|
|
@@ -1513,10 +2312,6 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1513
2312
|
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1514
2313
|
* break;
|
|
1515
2314
|
*
|
|
1516
|
-
* case 'ValidationError':
|
|
1517
|
-
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1518
|
-
* break;
|
|
1519
|
-
*
|
|
1520
2315
|
* case 'UnexpectedError':
|
|
1521
2316
|
* console.error(result.error.message);
|
|
1522
2317
|
* break;
|
|
@@ -1524,22 +2319,26 @@ declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequ
|
|
|
1524
2319
|
* return;
|
|
1525
2320
|
* }
|
|
1526
2321
|
*
|
|
1527
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2322
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1528
2323
|
* ```
|
|
1529
2324
|
*
|
|
1530
|
-
* @param handler - The handler that will be used to handle the
|
|
2325
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1531
2326
|
*/
|
|
1532
|
-
declare function
|
|
2327
|
+
declare function useClaimRewards(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<ClaimRewardsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2328
|
+
|
|
1533
2329
|
/**
|
|
1534
|
-
* A hook that provides a way to
|
|
2330
|
+
* A hook that provides a way to liquidate a user's position.
|
|
1535
2331
|
*
|
|
1536
2332
|
* ```ts
|
|
1537
2333
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1538
|
-
* const [
|
|
2334
|
+
* const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {
|
|
1539
2335
|
* switch (plan.__typename) {
|
|
1540
2336
|
* case 'TransactionRequest':
|
|
1541
2337
|
* return sendTransaction(plan);
|
|
1542
|
-
*
|
|
2338
|
+
*
|
|
2339
|
+
* case 'Erc20Approval':
|
|
2340
|
+
* return sendTransaction(plan.byTransaction);
|
|
2341
|
+
*
|
|
1543
2342
|
* case 'PreContractActionRequired':
|
|
1544
2343
|
* return sendTransaction(plan.transaction);
|
|
1545
2344
|
* }
|
|
@@ -1547,7 +2346,13 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1547
2346
|
*
|
|
1548
2347
|
* // …
|
|
1549
2348
|
*
|
|
1550
|
-
* const result = await
|
|
2349
|
+
* const result = await liquidatePosition({
|
|
2350
|
+
* collateral: reserveId('SGVsbG8h'),
|
|
2351
|
+
* debt: reserveId('Q2lhbyE= '),
|
|
2352
|
+
* amount: amount,
|
|
2353
|
+
* liquidator: liquidator,
|
|
2354
|
+
* borrower: borrower,
|
|
2355
|
+
* });
|
|
1551
2356
|
*
|
|
1552
2357
|
* if (result.isErr()) {
|
|
1553
2358
|
* switch (result.error.name) {
|
|
@@ -1578,156 +2383,153 @@ declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayReques
|
|
|
1578
2383
|
* return;
|
|
1579
2384
|
* }
|
|
1580
2385
|
*
|
|
1581
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2386
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1582
2387
|
* ```
|
|
1583
2388
|
*
|
|
1584
2389
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1585
2390
|
*/
|
|
1586
|
-
declare function
|
|
2391
|
+
declare function useLiquidatePosition(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, PendingTransaction | Signature>): UseAsyncTask<LiquidatePositionRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2392
|
+
|
|
1587
2393
|
/**
|
|
1588
|
-
*
|
|
2394
|
+
* Preview the impact of a potential action on a user's position.
|
|
1589
2395
|
*
|
|
1590
|
-
* ```
|
|
1591
|
-
* const [
|
|
1592
|
-
*
|
|
2396
|
+
* ```tsx
|
|
2397
|
+
* const [getPreview, previewing] = usePreviewAction();
|
|
2398
|
+
*
|
|
2399
|
+
* const loading = previewing.loading;
|
|
2400
|
+
* const error = previewing.error;
|
|
1593
2401
|
*
|
|
1594
2402
|
* // …
|
|
1595
2403
|
*
|
|
1596
|
-
* const result = await
|
|
2404
|
+
* const result = await getPreview({
|
|
2405
|
+
* action: {
|
|
2406
|
+
* supply: {
|
|
2407
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2408
|
+
* amount: {
|
|
2409
|
+
* erc20: {
|
|
2410
|
+
* value: '1000',
|
|
2411
|
+
* },
|
|
2412
|
+
* },
|
|
2413
|
+
* sender: evmAddress('0x9abc…'),
|
|
2414
|
+
* },
|
|
2415
|
+
* },
|
|
2416
|
+
* });
|
|
1597
2417
|
*
|
|
1598
2418
|
* if (result.isErr()) {
|
|
1599
|
-
*
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1602
|
-
* return;
|
|
2419
|
+
* console.error(result.error);
|
|
2420
|
+
* return;
|
|
2421
|
+
* }
|
|
1603
2422
|
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
|
|
2423
|
+
* console.log('Preview result:', result.value);
|
|
2424
|
+
* ```
|
|
2425
|
+
*/
|
|
2426
|
+
declare function usePreviewAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<PreviewRequest, PreviewUserPosition, UnexpectedError>;
|
|
2427
|
+
type UsePreviewArgs = Prettify<PreviewRequest & CurrencyQueryOptions>;
|
|
2428
|
+
/**
|
|
2429
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1607
2430
|
*
|
|
1608
|
-
*
|
|
1609
|
-
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1610
|
-
* break;
|
|
2431
|
+
* This signature supports React Suspense:
|
|
1611
2432
|
*
|
|
1612
|
-
*
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
2433
|
+
* ```tsx
|
|
2434
|
+
* const { data } = usePreview({
|
|
2435
|
+
* action: {
|
|
2436
|
+
* supply: {
|
|
2437
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2438
|
+
* amount: {
|
|
2439
|
+
* erc20: {
|
|
2440
|
+
* currency: evmAddress('0x5678…'),
|
|
2441
|
+
* value: '1000',
|
|
2442
|
+
* },
|
|
2443
|
+
* },
|
|
2444
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2445
|
+
* },
|
|
2446
|
+
* },
|
|
2447
|
+
* suspense: true,
|
|
2448
|
+
* });
|
|
2449
|
+
* ```
|
|
2450
|
+
*/
|
|
2451
|
+
declare function usePreview(args: UsePreviewArgs & Suspendable): SuspenseResult<PreviewUserPosition>;
|
|
2452
|
+
/**
|
|
2453
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1615
2454
|
*
|
|
1616
|
-
*
|
|
1617
|
-
* console.error(result.error.message);
|
|
1618
|
-
* break;
|
|
1619
|
-
* }
|
|
1620
|
-
* return;
|
|
1621
|
-
* }
|
|
2455
|
+
* Pausable suspense mode.
|
|
1622
2456
|
*
|
|
1623
|
-
*
|
|
2457
|
+
* ```tsx
|
|
2458
|
+
* const { data } = usePreview({
|
|
2459
|
+
* action: {
|
|
2460
|
+
* supply: {
|
|
2461
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2462
|
+
* amount: {
|
|
2463
|
+
* erc20: {
|
|
2464
|
+
* currency: evmAddress('0x5678…'),
|
|
2465
|
+
* value: '1000',
|
|
2466
|
+
* },
|
|
2467
|
+
* },
|
|
2468
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2469
|
+
* },
|
|
2470
|
+
* },
|
|
2471
|
+
* suspense: true,
|
|
2472
|
+
* pause: true,
|
|
2473
|
+
* });
|
|
1624
2474
|
* ```
|
|
1625
|
-
*
|
|
1626
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1627
2475
|
*/
|
|
1628
|
-
declare function
|
|
2476
|
+
declare function usePreview(args: Pausable<UsePreviewArgs> & Suspendable): PausableSuspenseResult<PreviewUserPosition>;
|
|
1629
2477
|
/**
|
|
1630
|
-
*
|
|
2478
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1631
2479
|
*
|
|
1632
|
-
* ```
|
|
1633
|
-
* const
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
2480
|
+
* ```tsx
|
|
2481
|
+
* const { data, error, loading } = usePreview({
|
|
2482
|
+
* action: {
|
|
2483
|
+
* supply: {
|
|
2484
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2485
|
+
* amount: {
|
|
2486
|
+
* erc20: {
|
|
2487
|
+
* currency: evmAddress('0x5678…'),
|
|
2488
|
+
* value: '1000',
|
|
2489
|
+
* },
|
|
2490
|
+
* },
|
|
2491
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2492
|
+
* },
|
|
2493
|
+
* },
|
|
1636
2494
|
* });
|
|
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
2495
|
* ```
|
|
1669
|
-
*
|
|
1670
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1671
2496
|
*/
|
|
1672
|
-
declare function
|
|
2497
|
+
declare function usePreview(args: UsePreviewArgs): ReadResult<PreviewUserPosition>;
|
|
1673
2498
|
/**
|
|
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;
|
|
2499
|
+
* Fetch a preview of the impact of a potential action on a user's position.
|
|
1703
2500
|
*
|
|
1704
|
-
*
|
|
1705
|
-
* console.error(result.error.message);
|
|
1706
|
-
* break;
|
|
1707
|
-
* }
|
|
1708
|
-
* return;
|
|
1709
|
-
* }
|
|
2501
|
+
* Pausable loading state mode.
|
|
1710
2502
|
*
|
|
1711
|
-
*
|
|
2503
|
+
* ```tsx
|
|
2504
|
+
* const { data, error, loading, paused } = usePreview({
|
|
2505
|
+
* action: {
|
|
2506
|
+
* supply: {
|
|
2507
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
2508
|
+
* amount: {
|
|
2509
|
+
* erc20: {
|
|
2510
|
+
* currency: evmAddress('0x5678…'),
|
|
2511
|
+
* value: '1000',
|
|
2512
|
+
* },
|
|
2513
|
+
* },
|
|
2514
|
+
* supplier: evmAddress('0x9abc…'),
|
|
2515
|
+
* },
|
|
2516
|
+
* },
|
|
2517
|
+
* pause: true,
|
|
2518
|
+
* });
|
|
1712
2519
|
* ```
|
|
1713
|
-
*
|
|
1714
|
-
* @param handler - The handler that will be used to handle the transaction.
|
|
1715
2520
|
*/
|
|
1716
|
-
declare function
|
|
2521
|
+
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2522
|
+
|
|
1717
2523
|
/**
|
|
1718
|
-
*
|
|
2524
|
+
* A hook that provides a way to renounce a position manager of a user for a specific spoke.
|
|
1719
2525
|
*
|
|
1720
2526
|
* ```ts
|
|
1721
2527
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1722
|
-
* const [
|
|
1723
|
-
* return sendTransaction(transaction);
|
|
1724
|
-
* });
|
|
2528
|
+
* const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);
|
|
1725
2529
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
* enableCollateral: true,
|
|
1730
|
-
* });
|
|
2530
|
+
* // …
|
|
2531
|
+
*
|
|
2532
|
+
* const result = await renounceSpokeUserPositionManager({ ... });
|
|
1731
2533
|
*
|
|
1732
2534
|
* if (result.isErr()) {
|
|
1733
2535
|
* switch (result.error.name) {
|
|
@@ -1754,22 +2556,26 @@ declare function useUpdateUserDynamicConfig(handler: TransactionHandler): UseAsy
|
|
|
1754
2556
|
* return;
|
|
1755
2557
|
* }
|
|
1756
2558
|
*
|
|
1757
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2559
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1758
2560
|
* ```
|
|
1759
2561
|
*
|
|
1760
2562
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1761
2563
|
*/
|
|
1762
|
-
declare function
|
|
2564
|
+
declare function useRenounceSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<RenounceSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2565
|
+
|
|
1763
2566
|
/**
|
|
1764
|
-
* A hook that provides a way to
|
|
2567
|
+
* A hook that provides a way to repay borrowed assets to an Aave reserve.
|
|
1765
2568
|
*
|
|
1766
2569
|
* ```ts
|
|
1767
2570
|
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1768
|
-
* const [
|
|
2571
|
+
* const [repay, { loading, error }] = useRepay((plan, { cancel }) => {
|
|
1769
2572
|
* switch (plan.__typename) {
|
|
1770
2573
|
* case 'TransactionRequest':
|
|
1771
2574
|
* return sendTransaction(plan);
|
|
1772
|
-
*
|
|
2575
|
+
*
|
|
2576
|
+
* case 'Erc20Approval':
|
|
2577
|
+
* return sendTransaction(plan.byTransaction);
|
|
2578
|
+
*
|
|
1773
2579
|
* case 'PreContractActionRequired':
|
|
1774
2580
|
* return sendTransaction(plan.transaction);
|
|
1775
2581
|
* }
|
|
@@ -1777,13 +2583,7 @@ declare function useSetUserSupplyAsCollateral(handler: TransactionHandler): UseA
|
|
|
1777
2583
|
*
|
|
1778
2584
|
* // …
|
|
1779
2585
|
*
|
|
1780
|
-
* const result = await
|
|
1781
|
-
* collateral: reserveId('SGVsbG8h'),
|
|
1782
|
-
* debt: reserveId('Q2lhbyE= '),
|
|
1783
|
-
* amount: amount,
|
|
1784
|
-
* liquidator: liquidator,
|
|
1785
|
-
* borrower: borrower,
|
|
1786
|
-
* });
|
|
2586
|
+
* const result = await repay({ ... });
|
|
1787
2587
|
*
|
|
1788
2588
|
* if (result.isErr()) {
|
|
1789
2589
|
* switch (result.error.name) {
|
|
@@ -1814,12 +2614,13 @@ declare function useSetUserSupplyAsCollateral(handler: TransactionHandler): UseA
|
|
|
1814
2614
|
* return;
|
|
1815
2615
|
* }
|
|
1816
2616
|
*
|
|
1817
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2617
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1818
2618
|
* ```
|
|
1819
2619
|
*
|
|
1820
2620
|
* @param handler - The handler that will be used to handle the transactions.
|
|
1821
2621
|
*/
|
|
1822
|
-
declare function
|
|
2622
|
+
declare function useRepay(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<RepayRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2623
|
+
|
|
1823
2624
|
/**
|
|
1824
2625
|
* A hook that provides a way to set or remove a position manager for a user on a specific spoke.
|
|
1825
2626
|
*
|
|
@@ -1876,226 +2677,226 @@ declare function useLiquidatePosition(handler: TransactionHandler): UseAsyncTask
|
|
|
1876
2677
|
* return;
|
|
1877
2678
|
* }
|
|
1878
2679
|
*
|
|
1879
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
2680
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
1880
2681
|
* ```
|
|
1881
2682
|
*
|
|
1882
2683
|
* @param handler - The handler that will be used to handle the transaction.
|
|
1883
2684
|
*/
|
|
1884
|
-
declare function useSetSpokeUserPositionManager(handler:
|
|
2685
|
+
declare function useSetSpokeUserPositionManager(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetSpokeUserPositionManagerRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2686
|
+
|
|
1885
2687
|
/**
|
|
1886
|
-
*
|
|
1887
|
-
*
|
|
1888
|
-
* ```tsx
|
|
1889
|
-
* const [getPreview, previewing] = usePreviewAction();
|
|
1890
|
-
*
|
|
1891
|
-
* const loading = previewing.loading;
|
|
1892
|
-
* const error = previewing.error;
|
|
2688
|
+
* Hook for updating the collateral status of user's supplies.
|
|
1893
2689
|
*
|
|
1894
|
-
*
|
|
2690
|
+
* ```ts
|
|
2691
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2692
|
+
* const [setUserSuppliesAsCollateral, { loading, error }] = useSetUserSuppliesAsCollateral((transaction, { cancel }) => {
|
|
2693
|
+
* return sendTransaction(transaction);
|
|
2694
|
+
* });
|
|
1895
2695
|
*
|
|
1896
|
-
* const result = await
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
* reserve:
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
* },
|
|
1905
|
-
* sender: evmAddress('0x9abc…'),
|
|
1906
|
-
* },
|
|
1907
|
-
* },
|
|
2696
|
+
* const result = await setUserSuppliesAsCollateral({
|
|
2697
|
+
* changes: [
|
|
2698
|
+
* {
|
|
2699
|
+
* reserve: reserve.id,
|
|
2700
|
+
* enableCollateral: true
|
|
2701
|
+
* }
|
|
2702
|
+
* ],
|
|
2703
|
+
* sender: evmAddress('0x456...')
|
|
1908
2704
|
* });
|
|
1909
2705
|
*
|
|
1910
2706
|
* 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.
|
|
2707
|
+
* switch (result.error.name) {
|
|
2708
|
+
* case 'CancelError':
|
|
2709
|
+
* // The user cancelled the operation
|
|
2710
|
+
* return;
|
|
1946
2711
|
*
|
|
1947
|
-
*
|
|
2712
|
+
* case 'SigningError':
|
|
2713
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2714
|
+
* break;
|
|
1948
2715
|
*
|
|
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.
|
|
2716
|
+
* case 'TimeoutError':
|
|
2717
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2718
|
+
* break;
|
|
1971
2719
|
*
|
|
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.
|
|
2720
|
+
* case 'TransactionError':
|
|
2721
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2722
|
+
* break;
|
|
1992
2723
|
*
|
|
1993
|
-
*
|
|
2724
|
+
* case 'UnexpectedError':
|
|
2725
|
+
* console.error(result.error.message);
|
|
2726
|
+
* break;
|
|
2727
|
+
* }
|
|
2728
|
+
* return;
|
|
2729
|
+
* }
|
|
1994
2730
|
*
|
|
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
|
-
* });
|
|
2731
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2011
2732
|
* ```
|
|
2733
|
+
*
|
|
2734
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2012
2735
|
*/
|
|
2013
|
-
declare function
|
|
2014
|
-
|
|
2736
|
+
declare function useSetUserSuppliesAsCollateral(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<SetUserSuppliesAsCollateralRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2737
|
+
|
|
2015
2738
|
/**
|
|
2016
|
-
*
|
|
2739
|
+
* A hook that provides a way to supply assets to an Aave reserve.
|
|
2017
2740
|
*
|
|
2018
|
-
*
|
|
2741
|
+
* ```ts
|
|
2742
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2743
|
+
* const [supply, { loading, error }] = useSupply((plan, { cancel }) => {
|
|
2744
|
+
* switch (plan.__typename) {
|
|
2745
|
+
* case 'TransactionRequest':
|
|
2746
|
+
* return sendTransaction(plan);
|
|
2019
2747
|
*
|
|
2020
|
-
*
|
|
2021
|
-
*
|
|
2022
|
-
*
|
|
2023
|
-
*
|
|
2024
|
-
*
|
|
2025
|
-
*
|
|
2026
|
-
* suspense: true,
|
|
2748
|
+
* case 'Erc20Approval':
|
|
2749
|
+
* return sendTransaction(plan.byTransaction);
|
|
2750
|
+
*
|
|
2751
|
+
* case 'PreContractActionRequired':
|
|
2752
|
+
* return sendTransaction(plan.transaction);
|
|
2753
|
+
* }
|
|
2027
2754
|
* });
|
|
2028
2755
|
*
|
|
2029
|
-
* //
|
|
2030
|
-
* ```
|
|
2031
|
-
*/
|
|
2032
|
-
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2033
|
-
/**
|
|
2034
|
-
* Fetch paginated list of activities.
|
|
2756
|
+
* // …
|
|
2035
2757
|
*
|
|
2036
|
-
*
|
|
2758
|
+
* const result = await supply({ ... });
|
|
2037
2759
|
*
|
|
2038
|
-
*
|
|
2039
|
-
*
|
|
2040
|
-
*
|
|
2041
|
-
*
|
|
2042
|
-
*
|
|
2043
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2044
|
-
* suspense: true,
|
|
2045
|
-
* pause: true,
|
|
2046
|
-
* });
|
|
2760
|
+
* if (result.isErr()) {
|
|
2761
|
+
* switch (result.error.name) {
|
|
2762
|
+
* case 'CancelError':
|
|
2763
|
+
* // The user cancelled the operation
|
|
2764
|
+
* return;
|
|
2047
2765
|
*
|
|
2048
|
-
*
|
|
2766
|
+
* case 'SigningError':
|
|
2767
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2768
|
+
* break;
|
|
2769
|
+
*
|
|
2770
|
+
* case 'TimeoutError':
|
|
2771
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2772
|
+
* break;
|
|
2773
|
+
*
|
|
2774
|
+
* case 'TransactionError':
|
|
2775
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2776
|
+
* break;
|
|
2777
|
+
*
|
|
2778
|
+
* case 'ValidationError':
|
|
2779
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2780
|
+
* break;
|
|
2781
|
+
*
|
|
2782
|
+
* case 'UnexpectedError':
|
|
2783
|
+
* console.error(result.error.message);
|
|
2784
|
+
* break;
|
|
2785
|
+
* }
|
|
2786
|
+
* return;
|
|
2787
|
+
* }
|
|
2788
|
+
*
|
|
2789
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2049
2790
|
* ```
|
|
2791
|
+
*
|
|
2792
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
2050
2793
|
*/
|
|
2051
|
-
declare function
|
|
2794
|
+
declare function useSupply(handler: ExecutionPlanHandler<TransactionRequest | Erc20Approval | PreContractActionRequired, Signature | PendingTransaction>): UseAsyncTask<SupplyRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2795
|
+
|
|
2052
2796
|
/**
|
|
2053
|
-
*
|
|
2797
|
+
* Hook for updating user position conditions (dynamic config and/or risk premium).
|
|
2054
2798
|
*
|
|
2055
|
-
* ```
|
|
2056
|
-
* const
|
|
2057
|
-
*
|
|
2058
|
-
*
|
|
2059
|
-
* },
|
|
2060
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2799
|
+
* ```ts
|
|
2800
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2801
|
+
* const [update, { loading, error }] = useUpdateUserPositionConditions((transaction, { cancel }) => {
|
|
2802
|
+
* return sendTransaction(transaction);
|
|
2061
2803
|
* });
|
|
2062
|
-
* ```
|
|
2063
|
-
*/
|
|
2064
|
-
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
2065
|
-
/**
|
|
2066
|
-
* Fetch paginated list of activities.
|
|
2067
2804
|
*
|
|
2068
|
-
*
|
|
2805
|
+
* // …
|
|
2069
2806
|
*
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2072
|
-
*
|
|
2073
|
-
* chainId: chainId(1),
|
|
2074
|
-
* },
|
|
2075
|
-
* user: evmAddress('0x742d35cc…'),
|
|
2076
|
-
* pause: true,
|
|
2807
|
+
* const result = await update({
|
|
2808
|
+
* userPositionId: userPosition.id,
|
|
2809
|
+
* update: UserPositionConditionsUpdate.AllDynamicConfig,
|
|
2077
2810
|
* });
|
|
2078
2811
|
*
|
|
2079
|
-
*
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2812
|
+
* if (result.isErr()) {
|
|
2813
|
+
* switch (result.error.name) {
|
|
2814
|
+
* case 'CancelError':
|
|
2815
|
+
* // The user cancelled the operation
|
|
2816
|
+
* return;
|
|
2817
|
+
*
|
|
2818
|
+
* case 'SigningError':
|
|
2819
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2820
|
+
* break;
|
|
2821
|
+
*
|
|
2822
|
+
* case 'TimeoutError':
|
|
2823
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2824
|
+
* break;
|
|
2825
|
+
*
|
|
2826
|
+
* case 'TransactionError':
|
|
2827
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2828
|
+
* break;
|
|
2829
|
+
*
|
|
2830
|
+
* case 'UnexpectedError':
|
|
2831
|
+
* console.error(result.error.message);
|
|
2832
|
+
* break;
|
|
2833
|
+
* }
|
|
2834
|
+
* return;
|
|
2835
|
+
* }
|
|
2836
|
+
*
|
|
2837
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2082
2838
|
* ```
|
|
2839
|
+
*
|
|
2840
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
2083
2841
|
*/
|
|
2084
|
-
declare function
|
|
2842
|
+
declare function useUpdateUserPositionConditions(handler: ExecutionPlanHandler<TransactionRequest, PendingTransaction>): UseAsyncTask<UpdateUserPositionConditionsRequest, TransactionReceipt, SendTransactionError | PendingTransactionError>;
|
|
2843
|
+
|
|
2085
2844
|
/**
|
|
2086
|
-
*
|
|
2845
|
+
* A hook that provides a way to withdraw supplied assets from an Aave reserve.
|
|
2087
2846
|
*
|
|
2088
|
-
*
|
|
2089
|
-
*
|
|
2090
|
-
*
|
|
2091
|
-
* (
|
|
2847
|
+
* ```ts
|
|
2848
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
2849
|
+
* const [withdraw, { loading, error }] = useWithdraw((plan, { cancel }) => {
|
|
2850
|
+
* switch (plan.__typename) {
|
|
2851
|
+
* case 'TransactionRequest':
|
|
2852
|
+
* return sendTransaction(plan);
|
|
2092
2853
|
*
|
|
2093
|
-
*
|
|
2094
|
-
*
|
|
2854
|
+
* case 'PreContractActionRequired':
|
|
2855
|
+
* return sendTransaction(plan.transaction);
|
|
2856
|
+
* }
|
|
2857
|
+
* });
|
|
2858
|
+
*
|
|
2859
|
+
* // …
|
|
2860
|
+
*
|
|
2861
|
+
* const result = await withdraw({ ... });
|
|
2862
|
+
*
|
|
2863
|
+
* if (result.isErr()) {
|
|
2864
|
+
* switch (result.error.name) {
|
|
2865
|
+
* case 'CancelError':
|
|
2866
|
+
* // The user cancelled the operation
|
|
2867
|
+
* return;
|
|
2868
|
+
*
|
|
2869
|
+
* case 'SigningError':
|
|
2870
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
2871
|
+
* break;
|
|
2872
|
+
*
|
|
2873
|
+
* case 'TimeoutError':
|
|
2874
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
2875
|
+
* break;
|
|
2876
|
+
*
|
|
2877
|
+
* case 'TransactionError':
|
|
2878
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
2879
|
+
* break;
|
|
2880
|
+
*
|
|
2881
|
+
* case 'ValidationError':
|
|
2882
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
2883
|
+
* break;
|
|
2884
|
+
*
|
|
2885
|
+
* case 'UnexpectedError':
|
|
2886
|
+
* console.error(result.error.message);
|
|
2887
|
+
* break;
|
|
2888
|
+
* }
|
|
2889
|
+
* return;
|
|
2890
|
+
* }
|
|
2891
|
+
*
|
|
2892
|
+
* console.log('Transaction sent with hash:', result.value.txHash);
|
|
2893
|
+
* ```
|
|
2894
|
+
*
|
|
2895
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
2095
2896
|
*/
|
|
2096
|
-
declare function
|
|
2897
|
+
declare function useWithdraw(handler: ExecutionPlanHandler<TransactionRequest | PreContractActionRequired, PendingTransaction>): UseAsyncTask<WithdrawRequest, TransactionReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
2097
2898
|
|
|
2098
|
-
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions>;
|
|
2899
|
+
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2099
2900
|
/**
|
|
2100
2901
|
* Fetch all user supply positions.
|
|
2101
2902
|
*
|
|
@@ -2208,8 +3009,8 @@ declare function useUserSupplies(args: Pausable<UseUserSuppliesArgs>): PausableR
|
|
|
2208
3009
|
* }
|
|
2209
3010
|
* ```
|
|
2210
3011
|
*/
|
|
2211
|
-
declare function useUserSuppliesAction(options?:
|
|
2212
|
-
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions>;
|
|
3012
|
+
declare function useUserSuppliesAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError>;
|
|
3013
|
+
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
2213
3014
|
/**
|
|
2214
3015
|
* Fetch all user borrow positions.
|
|
2215
3016
|
*
|
|
@@ -2315,7 +3116,7 @@ declare function useUserBorrows(args: Pausable<UseUserBorrowsArgs>): PausableRea
|
|
|
2315
3116
|
* }
|
|
2316
3117
|
* ```
|
|
2317
3118
|
*/
|
|
2318
|
-
declare function useUserBorrowsAction(options?:
|
|
3119
|
+
declare function useUserBorrowsAction(options?: CurrencyQueryOptions & TimeWindowQueryOptions): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError>;
|
|
2319
3120
|
type UseUserSummaryArgs = Prettify<UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions>;
|
|
2320
3121
|
/**
|
|
2321
3122
|
* Fetch a user's financial summary.
|
|
@@ -2578,6 +3379,69 @@ declare function useUserBalances(args: UseUserBalancesArgs): ReadResult<UserBala
|
|
|
2578
3379
|
* ```
|
|
2579
3380
|
*/
|
|
2580
3381
|
declare function useUserBalances(args: Pausable<UseUserBalancesArgs>): PausableReadResult<UserBalance[]>;
|
|
3382
|
+
type UseUserRiskPremiumBreakdownArgs = UserRiskPremiumBreakdownRequest;
|
|
3383
|
+
/**
|
|
3384
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3385
|
+
*
|
|
3386
|
+
* This signature supports React Suspense:
|
|
3387
|
+
*
|
|
3388
|
+
* ```tsx
|
|
3389
|
+
* const { data } = useUserRiskPremiumBreakdown({
|
|
3390
|
+
* query: {
|
|
3391
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3392
|
+
* },
|
|
3393
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3394
|
+
* suspense: true,
|
|
3395
|
+
* });
|
|
3396
|
+
* ```
|
|
3397
|
+
*/
|
|
3398
|
+
declare function useUserRiskPremiumBreakdown(args: UseUserRiskPremiumBreakdownArgs & Suspendable): SuspenseResult<UserRiskPremiumBreakdownItem[]>;
|
|
3399
|
+
/**
|
|
3400
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3401
|
+
*
|
|
3402
|
+
* Pausable suspense mode.
|
|
3403
|
+
*
|
|
3404
|
+
* ```tsx
|
|
3405
|
+
* const { data } = useUserRiskPremiumBreakdown({
|
|
3406
|
+
* query: {
|
|
3407
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3408
|
+
* },
|
|
3409
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3410
|
+
* suspense: true,
|
|
3411
|
+
* pause: true,
|
|
3412
|
+
* });
|
|
3413
|
+
* ```
|
|
3414
|
+
*/
|
|
3415
|
+
declare function useUserRiskPremiumBreakdown(args: Pausable<UseUserRiskPremiumBreakdownArgs> & Suspendable): PausableSuspenseResult<UserRiskPremiumBreakdownItem[]>;
|
|
3416
|
+
/**
|
|
3417
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3418
|
+
*
|
|
3419
|
+
* ```tsx
|
|
3420
|
+
* const { data, error, loading } = useUserRiskPremiumBreakdown({
|
|
3421
|
+
* query: {
|
|
3422
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3423
|
+
* },
|
|
3424
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3425
|
+
* });
|
|
3426
|
+
* ```
|
|
3427
|
+
*/
|
|
3428
|
+
declare function useUserRiskPremiumBreakdown(args: UseUserRiskPremiumBreakdownArgs): ReadResult<UserRiskPremiumBreakdownItem[]>;
|
|
3429
|
+
/**
|
|
3430
|
+
* Fetch the risk premium breakdown for a user position or spoke.
|
|
3431
|
+
*
|
|
3432
|
+
* Pausable loading state mode.
|
|
3433
|
+
*
|
|
3434
|
+
* ```tsx
|
|
3435
|
+
* const { data, error, loading, paused } = useUserRiskPremiumBreakdown({
|
|
3436
|
+
* query: {
|
|
3437
|
+
* userPositionId: userPositionId('SGVsbG8h'),
|
|
3438
|
+
* },
|
|
3439
|
+
* user: evmAddress('0x742d35cc…'),
|
|
3440
|
+
* pause: true,
|
|
3441
|
+
* });
|
|
3442
|
+
* ```
|
|
3443
|
+
*/
|
|
3444
|
+
declare function useUserRiskPremiumBreakdown(args: Pausable<UseUserRiskPremiumBreakdownArgs>): PausableReadResult<UserRiskPremiumBreakdownItem[]>;
|
|
2581
3445
|
/**
|
|
2582
3446
|
* Low-level hook to execute a {@link userBalances} action directly.
|
|
2583
3447
|
*
|
|
@@ -2667,4 +3531,4 @@ declare function useUserSummaryHistory(args: UseUserSummaryHistoryArgs): ReadRes
|
|
|
2667
3531
|
*/
|
|
2668
3532
|
declare function useUserSummaryHistory(args: Pausable<UseUserSummaryHistoryArgs>): PausableReadResult<UserSummaryHistoryItem[]>;
|
|
2669
3533
|
|
|
2670
|
-
export { AaveProvider, type AaveProviderProps, type CancelSwapError, type CancelSwapHandler, CannotCancelSwapError,
|
|
3534
|
+
export { AaveProvider, type AaveProviderProps, type CancelSwapError, type CancelSwapHandler, CannotCancelSwapError, PendingTransactionError, type PositionSwapHandler, type PositionSwapPlan, type PositionSwapValue, SendTransactionError, type SwapHandlerOptions, type SwapSignerError, type TokenSwapHandler, type TokenSwapPlan, type UseActivitiesArgs, type UseAssetArgs, type UseAssetBorrowHistoryArgs, type UseAssetPriceHistoryArgs, type UseAssetSupplyHistoryArgs, UseAsyncTask, type UseBorrowApyHistoryArgs, type UseBorrowSwapQuoteArgs, type UseBorrowSwapRequest, type UseHubArgs, type UseHubAssetInterestRateModelArgs, type UseHubAssetsArgs, type UseHubSummaryHistoryArgs, type UseHubsArgs, type UsePreviewArgs, type UseProtocolHistoryArgs, type UseRepayWithSupplyQuoteArgs, type UseRepayWithSupplyRequest, type UseReserveArgs, type UseReservesArgs, type UseSpokeArgs, type UseSpokePositionManagersArgs, type UseSpokeUserPositionManagersArgs, type UseSpokesArgs, type UseSupplyApyHistoryArgs, type UseSupplySwapQuoteArgs, type UseSupplySwapRequest, type UseSwapStatusArgs, type UseSwappableTokensArgs, type UseTokenSwapQuoteArgs, type UseTokenSwapRequest, type UseUserBalancesArgs, type UseUserBorrowsArgs, type UseUserClaimableRewardsArgs, type UseUserPositionArgs, type UseUserPositionsArgs, type UseUserRiskPremiumBreakdownArgs, type UseUserSummaryArgs, type UseUserSummaryHistoryArgs, type UseUserSuppliesArgs, type UseUserSwapsArgs, type UseWithdrawSwapQuoteArgs, type UseWithdrawSwapRequest, useAaveClient, useActivities, useActivitiesAction, useAsset, useAssetBorrowHistory, useAssetPriceHistory, useAssetSupplyHistory, useBorrow, useBorrowApyHistory, useBorrowSwap, useBorrowSwapQuote, useBorrowSwapQuoteAction, useCancelSwap, useClaimRewards, useHub, useHubAssetInterestRateModel, useHubAssetInterestRateModelAction, useHubAssets, useHubSummaryHistory, useHubs, useHubsAction, useLiquidatePosition, usePreview, usePreviewAction, useProtocolHistory, useRenounceSpokeUserPositionManager, useRepay, useRepayWithSupply, useRepayWithSupplyQuote, useRepayWithSupplyQuoteAction, useReserve, useReserveAction, useReserves, useReservesAction, useSetSpokeUserPositionManager, useSetUserSuppliesAsCollateral, useSpoke, useSpokePositionManagers, useSpokeUserPositionManagers, useSpokes, 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 };
|