@aave/react 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts DELETED
@@ -1,1171 +0,0 @@
1
- import { AaveClient, UnexpectedError } from '@aave/client';
2
- export * from '@aave/client';
3
- import React, { ReactNode } from 'react';
4
- import { MarketRequest, MarketsRequest } from '@aave/client/actions';
5
- import { Market, ChainsFilter, Chain, UsdExchangeRatesRequest, UsdExchangeRate, HealthFactorPreviewRequest, HealthFactorPreviewResponse, ReserveRequest, Reserve, BorrowAPYHistoryRequest, APYSample, SupplyAPYHistoryRequest, CreditDelegateeAmountRequest, TokenAmount, SupplyRequest, ExecutionPlan, BorrowRequest, RepayRequest, WithdrawRequest, UserSetEmodeRequest, TransactionRequest, CollateralToggleRequest, LiquidateRequest, VaultDepositRequest, VaultMintSharesRequest, VaultRedeemSharesRequest, VaultWithdrawRequest, VaultDeployRequest, VaultSetFeeRequest, VaultWithdrawFeesRequest, ApproveBorrowCreditDelegatorRequest, UserSuppliesRequest, MarketUserReserveSupplyPosition, UserBorrowsRequest, MarketUserReserveBorrowPosition, UserMarketStateRequest, MarketUserState, UserTransactionHistoryRequest, PaginatedUserTransactionHistoryResult, VaultRequest, Vault, VaultsRequest, PaginatedVaultsResult, UserVaultsRequest, VaultPreviewDepositRequest, VaultPreviewMintRequest, VaultPreviewWithdrawRequest, VaultPreviewRedeemRequest, VaultUserTransactionHistoryRequest, PaginatedVaultUserTransactionHistoryResult } from '@aave/graphql';
6
- import { U as UseAsyncTask } from './tasks-DUn7x8pK.js';
7
- import '@aave/types';
8
-
9
- /**
10
- * A read hook result.
11
- *
12
- * It's a discriminated union of the possible results of a read operation:
13
- * - Rely on the `loading` value to determine if the `data` or `error` can be evaluated.
14
- * - If `error` is `undefined`, then `data` value will be available.
15
- */
16
- type ReadResult<T, E = never> = {
17
- data: undefined;
18
- error: undefined;
19
- loading: true;
20
- } | {
21
- data: T;
22
- error: undefined;
23
- loading: false;
24
- } | {
25
- data: undefined;
26
- error: E;
27
- loading: false;
28
- };
29
- /**
30
- * @internal
31
- */
32
- declare const ReadResult: {
33
- Initial: <T, E = never>() => ReadResult<T, E>;
34
- Success: <T, E = never>(data: T) => ReadResult<T, E>;
35
- Failure: <T, E = never>(error: E) => ReadResult<T, E>;
36
- };
37
- /**
38
- * A read hook result that supports React Suspense
39
- */
40
- type SuspenseResult<T> = {
41
- data: T;
42
- };
43
-
44
- /**
45
- * @internal
46
- */
47
- type Suspendable = {
48
- suspense: true;
49
- };
50
-
51
- /**
52
- * <AaveProvider> props
53
- */
54
- type AaveProviderProps = {
55
- /**
56
- * The children to render
57
- */
58
- children: ReactNode;
59
- /**
60
- * The Aave client instance to use
61
- */
62
- client: AaveClient;
63
- };
64
- /**
65
- * Manages the internal state of the Aave SDK.
66
- *
67
- * ```tsx
68
- * import { AaveProvider, AaveClient, production } from '@aave/react';
69
- *
70
- * const client = AaveClient.create({
71
- * environment: production,
72
- * });
73
- *
74
- * function App() {
75
- * return (
76
- * <AaveProvider client={client}>
77
- * // ...
78
- * </AaveProvider>
79
- * );
80
- * }
81
- * ```
82
- */
83
- declare function AaveProvider({ children, client }: AaveProviderProps): React.JSX.Element;
84
-
85
- /**
86
- * Retrieve the injected {@link AaveClient} from the context.
87
- */
88
- declare function useAaveClient(): AaveClient;
89
-
90
- type UseAaveMarketArgs = MarketRequest;
91
- /**
92
- * Fetch a single Aave Market.
93
- *
94
- * This signature supports React Suspense:
95
- *
96
- * ```tsx
97
- * const { data } = useAaveMarket({
98
- * address: evmAddress('0x8787…'),
99
- * chainId: chainId(1),
100
- * suspense: true,
101
- * });
102
- * ```
103
- */
104
- declare function useAaveMarket(args: UseAaveMarketArgs & Suspendable): SuspenseResult<Market | null>;
105
- /**
106
- * Fetch a single Aave Market.
107
- *
108
- * ```tsx
109
- * const { data, loading } = useAaveMarket({
110
- * address: evmAddress('0x8787…'),
111
- * chainId: chainId(1),
112
- * });
113
- * ```
114
- */
115
- declare function useAaveMarket(args: UseAaveMarketArgs): ReadResult<Market | null>;
116
- type UseAaveMarketsArgs = MarketsRequest;
117
- /**
118
- * Fetch all Aave Markets for the specified chains.
119
- *
120
- * This signature supports React Suspense:
121
- *
122
- * ```tsx
123
- * const { data } = useAaveMarkets({
124
- * chainIds: [chainId(1), chainId(8453)],
125
- * user: evmAddress('0x742d35cc...'),
126
- * suspense: true
127
- * });
128
- * ```
129
- */
130
- declare function useAaveMarkets(args: UseAaveMarketsArgs & Suspendable): SuspenseResult<Market[]>;
131
- /**
132
- * Fetch all Aave Markets for the specified chains.
133
- *
134
- * ```tsx
135
- * const { data, loading } = useAaveMarkets({
136
- * chainIds: [chainId(1), chainId(8453)],
137
- * user: evmAddress('0x742d35cc...'),
138
- * });
139
- * ```
140
- */
141
- declare function useAaveMarkets(args: UseAaveMarketsArgs): ReadResult<Market[]>;
142
-
143
- type UseAaveChainsArgs = {
144
- filter?: ChainsFilter;
145
- };
146
- /**
147
- * Fetch all supported Aave chains.
148
- *
149
- * This signature supports React Suspense:
150
- *
151
- * ```tsx
152
- * const { data } = useAaveChains({
153
- * filter: ChainsFilter.MAINNET_ONLY,
154
- * suspense: true,
155
- * });
156
- * ```
157
- */
158
- declare function useAaveChains(args: UseAaveChainsArgs & Suspendable): SuspenseResult<Chain[]>;
159
- /**
160
- * Fetch all supported Aave chains.
161
- *
162
- * ```tsx
163
- * const { data, loading } = useAaveChains({
164
- * filter: ChainsFilter.MAINNET_ONLY,
165
- * });
166
- * ```
167
- */
168
- declare function useAaveChains(args: UseAaveChainsArgs): ReadResult<Chain[]>;
169
- /**
170
- * Health check query.
171
- *
172
- * This signature supports React Suspense:
173
- *
174
- * ```tsx
175
- * const { data } = useAaveHealth({
176
- * suspense: true,
177
- * });
178
- * ```
179
- */
180
- declare function useAaveHealth(args: Suspendable): SuspenseResult<boolean>;
181
- /**
182
- * Health check query.
183
- *
184
- * ```tsx
185
- * const { data, loading } = useAaveHealth();
186
- * ```
187
- */
188
- declare function useAaveHealth(): ReadResult<boolean>;
189
- type UseUsdExchangeRatesArgs = UsdExchangeRatesRequest;
190
- /**
191
- * Fetch USD exchange rates for different tokens on a given market.
192
- *
193
- * This signature supports React Suspense:
194
- *
195
- * ```tsx
196
- * const { data } = useUsdExchangeRates({
197
- * market: evmAddress('0x1234…'),
198
- * underlyingTokens: [evmAddress('0x5678…'), evmAddress('0x90ab…')],
199
- * chainId: chainId(1),
200
- * suspense: true,
201
- * });
202
- * ```
203
- */
204
- declare function useUsdExchangeRates(args: UseUsdExchangeRatesArgs & Suspendable): SuspenseResult<UsdExchangeRate[]>;
205
- /**
206
- * Fetch USD exchange rates for different tokens on a given market.
207
- *
208
- * ```tsx
209
- * const { data, loading } = useUsdExchangeRates({
210
- * market: evmAddress('0x1234…'),
211
- * underlyingTokens: [evmAddress('0x5678…'), evmAddress('0x90ab…')],
212
- * chainId: chainId(1),
213
- * });
214
- * ```
215
- */
216
- declare function useUsdExchangeRates(args: UseUsdExchangeRatesArgs): ReadResult<UsdExchangeRate[]>;
217
- /**
218
- * Determines the health factor after a given action.
219
- *
220
- * ```ts
221
- * const [preview, { loading, error }] = useAaveHealthFactorPreview();
222
- *
223
- * // …
224
- *
225
- * const result = await preview({
226
- * action: {
227
- * borrow: {
228
- * market: market.address,
229
- * amount: {
230
- * erc20: {
231
- * currency: evmAddress('0x5678…'),
232
- * value: '1000',
233
- * },
234
- * },
235
- * borrower: evmAddress('0x9abc…'),
236
- * chainId: market.chain.chainId,
237
- * },
238
- * },
239
- * });
240
- *
241
- * if (result.isErr()) {
242
- * console.error(result.error);
243
- * } else {
244
- * console.log(result.value);
245
- * }
246
- * ```
247
- */
248
- declare function useAaveHealthFactorPreview(): UseAsyncTask<HealthFactorPreviewRequest, HealthFactorPreviewResponse, UnexpectedError>;
249
-
250
- type UseAaveReserveArgs = ReserveRequest;
251
- /**
252
- * Fetch a single Aave Reserve.
253
- *
254
- * This signature supports React Suspense:
255
- *
256
- * ```tsx
257
- * const { data } = useAaveReserve({
258
- * market: evmAddress('0x87870bca...'),
259
- * underlyingToken: evmAddress('0xa0b86a33...'),
260
- * chainId: chainId(1),
261
- * suspense: true,
262
- * });
263
- * ```
264
- */
265
- declare function useAaveReserve(args: UseAaveReserveArgs & Suspendable): SuspenseResult<Reserve | null>;
266
- /**
267
- * Fetch a single Aave Reserve.
268
- *
269
- * ```tsx
270
- * const { data, loading } = useAaveReserve({
271
- * market: evmAddress('0x87870bca...'),
272
- * underlyingToken: evmAddress('0xa0b86a33...'),
273
- * chainId: chainId(1),
274
- * });
275
- * ```
276
- */
277
- declare function useAaveReserve(args: UseAaveReserveArgs): ReadResult<Reserve | null>;
278
- type UseBorrowAPYHistoryArgs = BorrowAPYHistoryRequest;
279
- /**
280
- * Fetches historical borrow APY data for a given underlying asset on a specific market
281
- * within a defined time window.
282
- *
283
- * This signature supports React Suspense:
284
- *
285
- * ```tsx
286
- * const { data } = useBorrowAPYHistory({
287
- * chainId: chainId(1),
288
- * underlyingToken: evmAddress('0x742d35cc…'),
289
- * market: evmAddress('0x24dc35d3c…'),
290
- * window: TimeWindow.LastWeek
291
- * suspense: true
292
- * });
293
- * ```
294
- */
295
- declare function useBorrowAPYHistory(args: UseBorrowAPYHistoryArgs & Suspendable): SuspenseResult<APYSample[]>;
296
- /**
297
- * Fetches historical borrow APY data for a given underlying asset on a specific market
298
- * within a defined time window.
299
- *
300
- * ```tsx
301
- * const { data } = useBorrowAPYHistory({
302
- * chainId: chainId(1),
303
- * underlyingToken: evmAddress('0x742d35cc…'),
304
- * market: evmAddress('0x24dc35d3c…'),
305
- * window: TimeWindow.LastWeek
306
- * });
307
- * ```
308
- */
309
- declare function useBorrowAPYHistory(args: UseBorrowAPYHistoryArgs): ReadResult<APYSample[]>;
310
- type UseSupplyAPYHistoryArgs = SupplyAPYHistoryRequest;
311
- /**
312
- * Fetches historical supply APY data for a given underlying asset on a specific market
313
- * within a defined time window.
314
- *
315
- * This signature supports React Suspense:
316
- *
317
- * ```tsx
318
- * const { data } = useSupplyAPYHistory({
319
- * chainId: chainId(1),
320
- * underlyingToken: evmAddress('0x742d35cc…'),
321
- * market: evmAddress('0x24dc35d3c…'),
322
- * window: TimeWindow.LastWeek,
323
- * suspense: true
324
- * });
325
- * ```
326
- */
327
- declare function useSupplyAPYHistory(args: UseSupplyAPYHistoryArgs & Suspendable): SuspenseResult<APYSample[]>;
328
- /**
329
- * Fetches historical supply APY data for a given underlying asset on a specific market
330
- * within a defined time window.
331
- *
332
- * ```tsx
333
- * const { data } = useSupplyAPYHistory({
334
- * chainId: chainId(1),
335
- * underlyingToken: evmAddress('0x742d35cc…'),
336
- * market: evmAddress('0x24dc35d3c…'),
337
- * window: TimeWindow.LastWeek
338
- * });
339
- * ```
340
- */
341
- declare function useSupplyAPYHistory(args: UseSupplyAPYHistoryArgs): ReadResult<APYSample[]>;
342
- type UseCreditDelegateeAllowanceArgs = CreditDelegateeAmountRequest;
343
- /**
344
- * Get the amount delegated to the credit delegatee that can borrow on your behalf.
345
- *
346
- * This signature supports React Suspense:
347
- *
348
- * ```tsx
349
- * const { data } = useCreditDelegateeAllowance({
350
- * market: evmAddress('0x87870bca...'),
351
- * underlyingToken: evmAddress('0xa0b86a33...'),
352
- * user: evmAddress('0x742d35cc...'),
353
- * delegatee: evmAddress('0x5678...'),
354
- * chainId: chainId(1),
355
- * suspense: true,
356
- * });
357
- * ```
358
- */
359
- declare function useCreditDelegateeAllowance(args: UseCreditDelegateeAllowanceArgs & Suspendable): SuspenseResult<TokenAmount>;
360
- /**
361
- * Get the amount delegated to the credit delegatee that can borrow on your behalf.
362
- *
363
- * ```tsx
364
- * const { data, loading } = useCreditDelegateeAllowance({
365
- * market: evmAddress('0x87870bca...'),
366
- * underlyingToken: evmAddress('0xa0b86a33...'),
367
- * user: evmAddress('0x742d35cc...'),
368
- * delegatee: evmAddress('0x5678...'),
369
- * chainId: chainId(1),
370
- * });
371
- * ```
372
- */
373
- declare function useCreditDelegateeAllowance(args: UseCreditDelegateeAllowanceArgs): ReadResult<TokenAmount>;
374
-
375
- /**
376
- * A hook that provides a way to supply assets to an Aave market.
377
- *
378
- * ```ts
379
- * const [supply, supplying] = useSupply();
380
- * const [sendTransaction, sending] = useSendTransaction(wallet);
381
- *
382
- * const loading = supplying.loading && sending.loading;
383
- * const error = supplying.error || sending.error;
384
- *
385
- * // …
386
- *
387
- * const result = await supply({ ... })
388
- * .andThen((plan) => {
389
- * switch (plan.__typename) {
390
- * case 'TransactionRequest':
391
- * return sendTransaction(plan);
392
- *
393
- * case 'ApprovalRequired':
394
- * return sendTransaction(plan.approval)
395
- * .andThen(() => sendTransaction(plan.originalTransaction));
396
- * }
397
- * });
398
- *
399
- * if (result.isErr()) {
400
- * console.error(result.error);
401
- * return;
402
- * }
403
- *
404
- * console.log('Transaction sent with hash:', result.value);
405
- * ```
406
- */
407
- declare function useSupply(): UseAsyncTask<SupplyRequest, ExecutionPlan, UnexpectedError>;
408
- /**
409
- * A hook that provides a way to borrow assets from an Aave market.
410
- *
411
- * ```ts
412
- * const [borrow, borrowing] = useBorrow();
413
- * const [sendTransaction, sending] = useSendTransaction(wallet);
414
- *
415
- * const loading = borrowing.loading && sending.loading;
416
- * const error = borrowing.error || sending.error;
417
- *
418
- * // …
419
- *
420
- * const result = await borrow({ ... })
421
- * .andThen((plan) => {
422
- * switch (plan.__typename) {
423
- * case 'TransactionRequest':
424
- * return sendTransaction(plan);
425
- *
426
- * case 'ApprovalRequired':
427
- * return sendTransaction(plan.approval)
428
- * .andThen(() => sendTransaction(plan.originalTransaction));
429
- * }
430
- * });
431
- *
432
- * if (result.isErr()) {
433
- * console.error(result.error);
434
- * return;
435
- * }
436
- *
437
- * console.log('Transaction sent with hash:', result.value);
438
- * ```
439
- */
440
- declare function useBorrow(): UseAsyncTask<BorrowRequest, ExecutionPlan, UnexpectedError>;
441
- /**
442
- * A hook that provides a way to repay borrowed assets to an Aave market.
443
- *
444
- * ```ts
445
- * const [repay, repaying] = useRepay();
446
- * const [sendTransaction, sending] = useSendTransaction(wallet);
447
- *
448
- * const loading = repaying.loading && sending.loading;
449
- * const error = repaying.error || sending.error;
450
- *
451
- * // …
452
- *
453
- * const result = await repay({ ... })
454
- * .andThen((plan) => {
455
- * switch (plan.__typename) {
456
- * case 'TransactionRequest':
457
- * return sendTransaction(plan);
458
- *
459
- * case 'ApprovalRequired':
460
- * return sendTransaction(plan.approval)
461
- * .andThen(() => sendTransaction(plan.originalTransaction));
462
- * }
463
- * });
464
- *
465
- * if (result.isErr()) {
466
- * console.error(result.error);
467
- * return;
468
- * }
469
- *
470
- * console.log('Transaction sent with hash:', result.value);
471
- * ```
472
- */
473
- declare function useRepay(): UseAsyncTask<RepayRequest, ExecutionPlan, UnexpectedError>;
474
- /**
475
- * A hook that provides a way to withdraw supplied assets from an Aave market.
476
- *
477
- * ```ts
478
- * const [withdraw, withdrawing] = useWithdraw();
479
- * const [sendTransaction, sending] = useSendTransaction(wallet);
480
- *
481
- * const loading = withdrawing.loading && sending.loading;
482
- * const error = withdrawing.error || sending.error;
483
- *
484
- * // …
485
- *
486
- * const result = await withdraw({ ... })
487
- * .andThen((plan) => {
488
- * switch (plan.__typename) {
489
- * case 'TransactionRequest':
490
- * return sendTransaction(plan);
491
- *
492
- * case 'ApprovalRequired':
493
- * return sendTransaction(plan.approval)
494
- * .andThen(() => sendTransaction(plan.originalTransaction));
495
- * }
496
- * });
497
- *
498
- * if (result.isErr()) {
499
- * console.error(result.error);
500
- * return;
501
- * }
502
- *
503
- * console.log('Transaction sent with hash:', result.value);
504
- * ```
505
- */
506
- declare function useWithdraw(): UseAsyncTask<WithdrawRequest, ExecutionPlan, UnexpectedError>;
507
- /**
508
- * A hook that provides a way to set eMode for a user.
509
- *
510
- * ```ts
511
- * const [setUserEMode, setting] = useUserEMode();
512
- * const [sendTransaction, sending] = useSendTransaction(wallet);
513
- *
514
- * const loading = setting.loading && sending.loading;
515
- * const error = setting.error || sending.error;
516
- *
517
- * // …
518
- *
519
- * const result = await setUserEMode({ ... })
520
- * .andThen((plan) => {
521
- * switch (plan.__typename) {
522
- * case 'TransactionRequest':
523
- * return sendTransaction(plan);
524
- *
525
- * case 'ApprovalRequired':
526
- * return sendTransaction(plan.approval)
527
- * .andThen(() => sendTransaction(plan.originalTransaction));
528
- * }
529
- * });
530
- *
531
- * if (result.isErr()) {
532
- * console.error(result.error);
533
- * return;
534
- * }
535
- *
536
- * console.log('Transaction sent with hash:', result.value);
537
- * ```
538
- */
539
- declare function useUserEMode(): UseAsyncTask<UserSetEmodeRequest, TransactionRequest, UnexpectedError>;
540
- /**
541
- * A hook that provides a way to enable/disable a specific supplied asset as collateral.
542
- *
543
- * ```ts
544
- * const [toggle, toggling] = useCollateralToggle();
545
- * const [sendTransaction, sending] = useSendTransaction(wallet);
546
- *
547
- * const loading = toggling.loading && sending.loading;
548
- * const error = toggling.error || sending.error;
549
- *
550
- * // …
551
- *
552
- * const result = await toggle({ ... })
553
- * .andThen(sendTransaction);
554
- *
555
- * if (result.isErr()) {
556
- * console.error(result.error);
557
- * return;
558
- * }
559
- *
560
- * console.log('Transaction sent with hash:', result.value);
561
- * ```
562
- */
563
- declare function useCollateralToggle(): UseAsyncTask<CollateralToggleRequest, TransactionRequest, UnexpectedError>;
564
- /**
565
- * A hook that provides a way to liquidate a non-healthy position with Health Factor below 1.
566
- *
567
- * ```ts
568
- * const [liquidate, liquidating] = useLiquidate();
569
- * const [sendTransaction, sending] = useSendTransaction(wallet);
570
- *
571
- * const loading = liquidating.loading && sending.loading;
572
- * const error = liquidating.error || sending.error;
573
- *
574
- * // …
575
- *
576
- * const result = await liquidate({ ... })
577
- * .andThen(sendTransaction);
578
- *
579
- * if (result.isErr()) {
580
- * console.error(result.error);
581
- * return;
582
- * }
583
- *
584
- * console.log('Transaction sent with hash:', result.value);
585
- * ```
586
- */
587
- declare function useLiquidate(): UseAsyncTask<LiquidateRequest, TransactionRequest, UnexpectedError>;
588
- /**
589
- * A hook that provides a way to deposit assets into a vault.
590
- *
591
- * ```ts
592
- * const [deposit, depositing] = useVaultDeposit();
593
- * const [sendTransaction, sending] = useSendTransaction(wallet);
594
- *
595
- * const loading = depositing.loading && sending.loading;
596
- * const error = depositing.error || sending.error;
597
- *
598
- * // …
599
- *
600
- * const result = await deposit({ ... })
601
- * .andThen((plan) => {
602
- * switch (plan.__typename) {
603
- * case 'TransactionRequest':
604
- * return sendTransaction(plan);
605
- *
606
- * case 'ApprovalRequired':
607
- * return sendTransaction(plan.approval)
608
- * .andThen(() => sendTransaction(plan.originalTransaction));
609
- * }
610
- * });
611
- *
612
- * if (result.isErr()) {
613
- * console.error(result.error);
614
- * return;
615
- * }
616
- *
617
- * console.log('Transaction sent with hash:', result.value);
618
- * ```
619
- */
620
- declare function useVaultDeposit(): UseAsyncTask<VaultDepositRequest, ExecutionPlan, UnexpectedError>;
621
- /**
622
- * A hook that provides a way to mint vault shares.
623
- *
624
- * ```ts
625
- * const [mint, minting] = useVaultMintShares();
626
- * const [sendTransaction, sending] = useSendTransaction(wallet);
627
- *
628
- * const loading = minting.loading && sending.loading;
629
- * const error = minting.error || sending.error;
630
- *
631
- * // …
632
- *
633
- * const result = await mint({ ... })
634
- * .andThen((plan) => {
635
- * switch (plan.__typename) {
636
- * case 'TransactionRequest':
637
- * return sendTransaction(plan);
638
- *
639
- * case 'ApprovalRequired':
640
- * return sendTransaction(plan.approval)
641
- * .andThen(() => sendTransaction(plan.originalTransaction));
642
- * }
643
- * });
644
- *
645
- * if (result.isErr()) {
646
- * console.error(result.error);
647
- * return;
648
- * }
649
- *
650
- * console.log('Transaction sent with hash:', result.value);
651
- * ```
652
- */
653
- declare function useVaultMintShares(): UseAsyncTask<VaultMintSharesRequest, ExecutionPlan, UnexpectedError>;
654
- /**
655
- * A hook that provides a way to redeem vault shares.
656
- *
657
- * ```ts
658
- * const [redeem, redeeming] = useVaultRedeemShares();
659
- * const [sendTransaction, sending] = useSendTransaction(wallet);
660
- *
661
- * const loading = redeeming.loading && sending.loading;
662
- * const error = redeeming.error || sending.error;
663
- *
664
- * // …
665
- *
666
- * const result = await redeem({ ... })
667
- * .andThen((plan) => {
668
- * switch (plan.__typename) {
669
- * case 'TransactionRequest':
670
- * return sendTransaction(plan);
671
- *
672
- * case 'ApprovalRequired':
673
- * return sendTransaction(plan.approval)
674
- * .andThen(() => sendTransaction(plan.originalTransaction));
675
- * }
676
- * });
677
- *
678
- * if (result.isErr()) {
679
- * console.error(result.error);
680
- * return;
681
- * }
682
- *
683
- * console.log('Transaction sent with hash:', result.value);
684
- * ```
685
- */
686
- declare function useVaultRedeemShares(): UseAsyncTask<VaultRedeemSharesRequest, TransactionRequest, UnexpectedError>;
687
- /**
688
- * A hook that provides a way to withdraw assets from a vault.
689
- *
690
- * ```ts
691
- * const [withdraw, withdrawing] = useVaultWithdraw();
692
- * const [sendTransaction, sending] = useSendTransaction(wallet);
693
- *
694
- * const loading = withdrawing.loading && sending.loading;
695
- * const error = withdrawing.error || sending.error;
696
- *
697
- * // …
698
- *
699
- * const result = await withdraw({ ... })
700
- * .andThen((plan) => {
701
- * switch (plan.__typename) {
702
- * case 'TransactionRequest':
703
- * return sendTransaction(plan);
704
- *
705
- * case 'ApprovalRequired':
706
- * return sendTransaction(plan.approval)
707
- * .andThen(() => sendTransaction(plan.originalTransaction));
708
- * }
709
- * });
710
- *
711
- * if (result.isErr()) {
712
- * console.error(result.error);
713
- * return;
714
- * }
715
- *
716
- * console.log('Transaction sent with hash:', result.value);
717
- * ```
718
- */
719
- declare function useVaultWithdraw(): UseAsyncTask<VaultWithdrawRequest, TransactionRequest, UnexpectedError>;
720
- /**
721
- * A hook that provides a way to deploy a vault.
722
- *
723
- * ```ts
724
- * const [deploy, deploying] = useVaultDeploy();
725
- * const [sendTransaction, sending] = useSendTransaction(wallet);
726
- *
727
- * const loading = deploying.loading && sending.loading;
728
- * const error = deploying.error || sending.error;
729
- *
730
- * // …
731
- *
732
- * const result = await deploy({ ... })
733
- * .andThen((plan) => {
734
- * switch (plan.__typename) {
735
- * case 'TransactionRequest':
736
- * return sendTransaction(plan);
737
- *
738
- * case 'ApprovalRequired':
739
- * return sendTransaction(plan.approval)
740
- * .andThen(() => sendTransaction(plan.originalTransaction));
741
- * }
742
- * });
743
- *
744
- * if (result.isErr()) {
745
- * console.error(result.error);
746
- * return;
747
- * }
748
- *
749
- * console.log('Transaction sent with hash:', result.value);
750
- * ```
751
- */
752
- declare function useVaultDeploy(): UseAsyncTask<VaultDeployRequest, ExecutionPlan, UnexpectedError>;
753
- /**
754
- * A hook that provides a way to set vault fee.
755
- *
756
- * ```ts
757
- * const [setFee, setting] = useVaultSetFee();
758
- * const [sendTransaction, sending] = useSendTransaction(wallet);
759
- *
760
- * const loading = setting.loading && sending.loading;
761
- * const error = setting.error || sending.error;
762
- *
763
- * // …
764
- *
765
- * const result = await setFee({ ... })
766
- * .andThen((plan) => {
767
- * switch (plan.__typename) {
768
- * case 'TransactionRequest':
769
- * return sendTransaction(plan);
770
- *
771
- * case 'ApprovalRequired':
772
- * return sendTransaction(plan.approval)
773
- * .andThen(() => sendTransaction(plan.originalTransaction));
774
- * }
775
- * });
776
- *
777
- * if (result.isErr()) {
778
- * console.error(result.error);
779
- * return;
780
- * }
781
- *
782
- * console.log('Transaction sent with hash:', result.value);
783
- * ```
784
- */
785
- declare function useVaultSetFee(): UseAsyncTask<VaultSetFeeRequest, TransactionRequest, UnexpectedError>;
786
- /**
787
- * A hook that provides a way to withdraw vault fees.
788
- *
789
- * ```ts
790
- * const [withdraw, withdrawing] = useVaultWithdrawFees();
791
- * const [sendTransaction, sending] = useSendTransaction(wallet);
792
- *
793
- * const loading = withdrawing.loading && sending.loading;
794
- * const error = withdrawing.error || sending.error;
795
- *
796
- * // …
797
- *
798
- * const result = await withdraw({ ... })
799
- * .andThen((plan) => {
800
- * switch (plan.__typename) {
801
- * case 'TransactionRequest':
802
- * return sendTransaction(plan);
803
- *
804
- * case 'ApprovalRequired':
805
- * return sendTransaction(plan.approval)
806
- * .andThen(() => sendTransaction(plan.originalTransaction));
807
- * }
808
- * });
809
- *
810
- * if (result.isErr()) {
811
- * console.error(result.error);
812
- * return;
813
- * }
814
- *
815
- * console.log('Transaction sent with hash:', result.value);
816
- * ```
817
- */
818
- declare function useVaultWithdrawFees(): UseAsyncTask<VaultWithdrawFeesRequest, TransactionRequest, UnexpectedError>;
819
- /**
820
- * A hook that provides a way to approve a credit borrow delegator to be able to borrow on your behalf.
821
- *
822
- * ```ts
823
- * const [approve, approving] = useApproveBorrowCreditDelegation();
824
- * const [sendTransaction, sending] = useSendTransaction(wallet);
825
- *
826
- * const loading = approving.loading && sending.loading;
827
- * const error = approving.error || sending.error;
828
- *
829
- * // …
830
- *
831
- * const result = await approve({
832
- * market: evmAddress('0x87870bca3f3fd6335c3f4ce8392d69350b4fa4e2'),
833
- * underlyingToken: evmAddress('0xa0b86a33e6441c8c5f0bb9b7e5e1f8bbf5b78b5c'),
834
- * amount: '1000',
835
- * user: evmAddress('0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234'),
836
- * delegatee: evmAddress('0x5678…'),
837
- * chainId: chainId(1),
838
- * }).andThen(sendTransaction);
839
- *
840
- * if (result.isErr()) {
841
- * console.error(result.error);
842
- * return;
843
- * }
844
- *
845
- * console.log('Transaction sent with hash:', result.value);
846
- * ```
847
- */
848
- declare function useApproveBorrowCreditDelegation(): UseAsyncTask<ApproveBorrowCreditDelegatorRequest, TransactionRequest, UnexpectedError>;
849
-
850
- type UseUserSuppliesArgs = UserSuppliesRequest;
851
- /**
852
- * Fetch all user supply positions.
853
- *
854
- * This signature supports React Suspense:
855
- *
856
- * ```tsx
857
- * const { data } = useUserSupplies({
858
- * markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
859
- * user: evmAddress('0x742d35cc…'),
860
- * orderBy: { name: OrderDirection.ASC },
861
- * suspense: true,
862
- * });
863
- * ```
864
- */
865
- declare function useUserSupplies(args: UseUserSuppliesArgs & Suspendable): SuspenseResult<MarketUserReserveSupplyPosition[]>;
866
- /**
867
- * Fetch all user supply positions.
868
- *
869
- * ```tsx
870
- * const { data, loading } = useUserSupplies({
871
- * markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
872
- * user: evmAddress('0x742d35cc…'),
873
- * orderBy: { name: OrderDirection.ASC },
874
- * });
875
- * ```
876
- */
877
- declare function useUserSupplies(args: UseUserSuppliesArgs): ReadResult<MarketUserReserveSupplyPosition[]>;
878
- type UseUserBorrowsArgs = UserBorrowsRequest;
879
- /**
880
- * Fetch all user borrow positions.
881
- *
882
- * This signature supports React Suspense:
883
- *
884
- * ```tsx
885
- * const { data } = useUserBorrows({
886
- * markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
887
- * user: evmAddress('0x742d35cc…'),
888
- * orderBy: { name: OrderDirection.ASC },
889
- * suspense: true
890
- * });
891
- * ```
892
- */
893
- declare function useUserBorrows(args: UseUserBorrowsArgs & Suspendable): SuspenseResult<MarketUserReserveBorrowPosition[]>;
894
- /**
895
- * Fetch all user borrow positions.
896
- *
897
- * ```tsx
898
- * const { data, loading } = useUserBorrows({
899
- * markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
900
- * user: evmAddress('0x742d35cc…'),
901
- * orderBy: { name: OrderDirection.ASC },
902
- * });
903
- * ```
904
- */
905
- declare function useUserBorrows(args: UseUserBorrowsArgs): ReadResult<MarketUserReserveBorrowPosition[]>;
906
- type UseUserStateArgs = UserMarketStateRequest;
907
- /**
908
- * Fetch user account market data across all reserves.
909
- *
910
- * This signature supports React Suspense:
911
- *
912
- * ```tsx
913
- * const { data } = useUserMarketState({
914
- * market: evmAddress('0x1234…'),
915
- * user: evmAddress('0x5678…'),
916
- * chainId: chainId(1),
917
- * suspense: true,
918
- * });
919
- * ```
920
- */
921
- declare function useUserMarketState(args: UseUserStateArgs & Suspendable): SuspenseResult<MarketUserState>;
922
- /**
923
- * Fetch user account market data across all reserves.
924
- *
925
- * ```tsx
926
- * const { data, loading } = useUserMarketState({
927
- * market: evmAddress('0x1234…'),
928
- * user: evmAddress('0x5678…'),
929
- * chainId: chainId(1),
930
- * });
931
- * ```
932
- */
933
- declare function useUserMarketState(args: UseUserStateArgs): ReadResult<MarketUserState>;
934
- type UseUserTransactionHistoryArgs = UserTransactionHistoryRequest;
935
- /**
936
- * Fetch user transaction history.
937
- *
938
- * This signature supports React Suspense:
939
- *
940
- * ```tsx
941
- * const { data } = useUserTransactionHistory({
942
- * suspense: true,
943
- * });
944
- * ```
945
- */
946
- declare function useUserTransactionHistory(args: UseUserTransactionHistoryArgs & Suspendable): SuspenseResult<PaginatedUserTransactionHistoryResult>;
947
- /**
948
- * Fetch user transaction history.
949
- *
950
- * ```tsx
951
- * const { data, loading } = useUserTransactionHistory();
952
- * ```
953
- */
954
- declare function useUserTransactionHistory(args: UseUserTransactionHistoryArgs): ReadResult<PaginatedUserTransactionHistoryResult>;
955
-
956
- type UseVaultArgs = VaultRequest;
957
- /**
958
- * Fetch a single vault by address and chain ID.
959
- *
960
- * This signature supports React Suspense:
961
- *
962
- * ```tsx
963
- * const { data } = useVault({
964
- * by: {
965
- * address: evmAddress('0x1234…'),
966
- * },
967
- * chainId: chainId(1),
968
- * user: evmAddress('0x5678…'),
969
- * suspense: true,
970
- * });
971
- * ```
972
- */
973
- declare function useVault(args: UseVaultArgs & Suspendable): SuspenseResult<Vault | null>;
974
- /**
975
- * Fetch a single vault by address and chain ID.
976
- *
977
- * ```tsx
978
- * const { data, loading } = useVault({
979
- * address: evmAddress('0x1234…'),
980
- * chainId: chainId(1),
981
- * user: evmAddress('0x5678…'),
982
- * });
983
- * ```
984
- */
985
- declare function useVault(args: UseVaultArgs): ReadResult<Vault | null>;
986
- type UseVaultsArgs = VaultsRequest;
987
- /**
988
- * Fetch vaults based on filter criteria.
989
- *
990
- * This signature supports React Suspense:
991
- *
992
- * ```tsx
993
- * const { data } = useVaults({
994
- * criteria: {
995
- * ownedBy: [evmAddress('0x1234…')]
996
- * },
997
- * pageSize: PageSize.Ten,
998
- * user: evmAddress('0x5678…'),
999
- * suspense: true,
1000
- * });
1001
- * ```
1002
- */
1003
- declare function useVaults(args: UseVaultsArgs & Suspendable): SuspenseResult<PaginatedVaultsResult>;
1004
- /**
1005
- * Fetch vaults based on filter criteria.
1006
- *
1007
- * ```tsx
1008
- * const { data, loading } = useVaults({
1009
- * criteria: {
1010
- * ownedBy: [evmAddress('0x1234…')]
1011
- * },
1012
- * pageSize: PageSize.Ten,
1013
- * user: evmAddress('0x5678…'),
1014
- * });
1015
- * ```
1016
- */
1017
- declare function useVaults(args: UseVaultsArgs): ReadResult<PaginatedVaultsResult>;
1018
- type UseUserVaultsArgs = UserVaultsRequest;
1019
- /**
1020
- * Fetch vaults that a user has shares in.
1021
- *
1022
- * This signature supports React Suspense:
1023
- *
1024
- * ```tsx
1025
- * const { data } = useUserVaults({
1026
- * user: evmAddress('0x1234…'),
1027
- * filters: {
1028
- * markets: [evmAddress('0x5678…')]
1029
- * },
1030
- * orderBy: { shares: OrderDirection.Desc },
1031
- * pageSize: PageSize.Fifty,
1032
- * suspense: true,
1033
- * });
1034
- * ```
1035
- */
1036
- declare function useUserVaults(args: UseUserVaultsArgs & Suspendable): SuspenseResult<PaginatedVaultsResult>;
1037
- /**
1038
- * Fetch vaults that a user has shares in.
1039
- *
1040
- * ```tsx
1041
- * const { data, loading } = useUserVaults({
1042
- * user: evmAddress('0x1234…'),
1043
- * filters: {
1044
- * markets: [evmAddress('0x5678…')]
1045
- * },
1046
- * orderBy: { shares: OrderDirection.Desc },
1047
- * pageSize: PageSize.Fifty,
1048
- * });
1049
- * ```
1050
- */
1051
- declare function useUserVaults(args: UseUserVaultsArgs): ReadResult<PaginatedVaultsResult>;
1052
- /**
1053
- * Determines the amount of shares that would be received for a deposit.
1054
- *
1055
- * ```ts
1056
- * const [preview, { loading, error }] = useVaultDepositPreview();
1057
- *
1058
- * // …
1059
- *
1060
- * const result = await preview({
1061
- * vault: evmAddress('0x1234567890abcdef1234567890abcdef12345678'),
1062
- * chainId: chainId(1),
1063
- * amount: bigDecimal('1000'),
1064
- * });
1065
- *
1066
- * if (result.isErr()) {
1067
- * console.error(result.error);
1068
- * } else {
1069
- * console.log(result.value);
1070
- * }
1071
- * ```
1072
- */
1073
- declare function useVaultDepositPreview(): UseAsyncTask<VaultPreviewDepositRequest, TokenAmount, UnexpectedError>;
1074
- /**
1075
- * Determines the amount of assets that would be required to mint a specific amount of vault shares.
1076
- *
1077
- * ```ts
1078
- * const [preview, { loading, error }] = useVaultMintPreview();
1079
- *
1080
- * // …
1081
- *
1082
- * const result = await preview({
1083
- * vault: evmAddress('0x1234567890abcdef1234567890abcdef12345678'),
1084
- * chainId: chainId(1),
1085
- * amount: bigDecimal('500'),
1086
- * });
1087
- *
1088
- * if (result.isErr()) {
1089
- * console.error(result.error);
1090
- * } else {
1091
- * console.log(result.value);
1092
- * }
1093
- * ```
1094
- */
1095
- declare function useVaultMintPreview(): UseAsyncTask<VaultPreviewMintRequest, TokenAmount, UnexpectedError>;
1096
- /**
1097
- * Determines the amount of shares that would be burned for a withdrawal.
1098
- *
1099
- * ```ts
1100
- * const [preview, { loading, error }] = useVaultWithdrawPreview();
1101
- *
1102
- * // …
1103
- *
1104
- * const result = await preview({
1105
- * vault: evmAddress('0x1234567890abcdef1234567890abcdef12345678'),
1106
- * chainId: chainId(1),
1107
- * amount: bigDecimal('750'),
1108
- * });
1109
- *
1110
- * if (result.isErr()) {
1111
- * console.error(result.error);
1112
- * } else {
1113
- * console.log(result.value);
1114
- * }
1115
- * ```
1116
- */
1117
- declare function useVaultWithdrawPreview(): UseAsyncTask<VaultPreviewWithdrawRequest, TokenAmount, UnexpectedError>;
1118
- /**
1119
- * Determines the amount of assets that would be received for redeeming a specific amount of vault shares.
1120
- *
1121
- * This signature supports React Suspense:
1122
- *
1123
- * ```ts
1124
- * const [preview, { loading, error }] = useVaultRedeemPreview();
1125
- *
1126
- * // …
1127
- *
1128
- * const result = await preview({
1129
- * vault: evmAddress('0x1234567890abcdef1234567890abcdef12345678'),
1130
- * chainId: chainId(1),
1131
- * amount: bigDecimal('200'),
1132
- * });
1133
- *
1134
- * if (result.isErr()) {
1135
- * console.error(result.error);
1136
- * } else {
1137
- * console.log(result.value);
1138
- * }
1139
- * ```
1140
- */
1141
- declare function useVaultRedeemPreview(): UseAsyncTask<VaultPreviewRedeemRequest, TokenAmount, UnexpectedError>;
1142
- type UseVaultUserTransactionHistoryArgs = VaultUserTransactionHistoryRequest;
1143
- /**
1144
- * Fetch user transaction history for a vault.
1145
- *
1146
- * This signature supports React Suspense:
1147
- *
1148
- * ```tsx
1149
- * const { data } = useVaultUserTransactionHistory({
1150
- * vault: evmAddress('0x1234567890abcdef1234567890abcdef12345678'),
1151
- * chainId: chainId(1),
1152
- * user: evmAddress('0x5678901234567890abcdef1234567890abcdef12'),
1153
- * suspense: true,
1154
- * });
1155
- * ```
1156
- */
1157
- declare function useVaultUserTransactionHistory(args: UseVaultUserTransactionHistoryArgs & Suspendable): SuspenseResult<PaginatedVaultUserTransactionHistoryResult>;
1158
- /**
1159
- * Fetch user transaction history for a vault.
1160
- *
1161
- * ```tsx
1162
- * const { data, loading } = useVaultUserTransactionHistory({
1163
- * vault: evmAddress('0x1234567890abcdef1234567890abcdef12345678'),
1164
- * chainId: chainId(1),
1165
- * user: evmAddress('0x5678901234567890abcdef1234567890abcdef12'),
1166
- * });
1167
- * ```
1168
- */
1169
- declare function useVaultUserTransactionHistory(args: UseVaultUserTransactionHistoryArgs): ReadResult<PaginatedVaultUserTransactionHistoryResult>;
1170
-
1171
- export { AaveProvider, type AaveProviderProps, type UseAaveChainsArgs, type UseAaveMarketArgs, type UseAaveMarketsArgs, type UseAaveReserveArgs, type UseBorrowAPYHistoryArgs, type UseCreditDelegateeAllowanceArgs, type UseSupplyAPYHistoryArgs, type UseUsdExchangeRatesArgs, type UseUserBorrowsArgs, type UseUserStateArgs, type UseUserSuppliesArgs, type UseUserTransactionHistoryArgs, type UseUserVaultsArgs, type UseVaultArgs, type UseVaultUserTransactionHistoryArgs, type UseVaultsArgs, useAaveChains, useAaveClient, useAaveHealth, useAaveHealthFactorPreview, useAaveMarket, useAaveMarkets, useAaveReserve, useApproveBorrowCreditDelegation, useBorrow, useBorrowAPYHistory, useCollateralToggle, useCreditDelegateeAllowance, useLiquidate, useRepay, useSupply, useSupplyAPYHistory, useUsdExchangeRates, useUserBorrows, useUserEMode, useUserMarketState, useUserSupplies, useUserTransactionHistory, useUserVaults, useVault, useVaultDeploy, useVaultDeposit, useVaultDepositPreview, useVaultMintPreview, useVaultMintShares, useVaultRedeemPreview, useVaultRedeemShares, useVaultSetFee, useVaultUserTransactionHistory, useVaultWithdraw, useVaultWithdrawFees, useVaultWithdrawPreview, useVaults, useWithdraw };