@aave/client 4.0.0-next.0 → 4.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/package.json +3 -3
  2. package/dist/AaveClient-CgHY2iS9.d.ts +0 -82
  3. package/dist/AaveClient-L3v8kWvn.d.cts +0 -82
  4. package/dist/actions/index.cjs +0 -2
  5. package/dist/actions/index.cjs.map +0 -1
  6. package/dist/actions/index.d.cts +0 -1033
  7. package/dist/actions/index.d.ts +0 -1033
  8. package/dist/actions/index.js +0 -2
  9. package/dist/actions/index.js.map +0 -1
  10. package/dist/chunk-2TNQ52OQ.js +0 -3
  11. package/dist/chunk-2TNQ52OQ.js.map +0 -1
  12. package/dist/chunk-BQFM5RT3.js +0 -2
  13. package/dist/chunk-BQFM5RT3.js.map +0 -1
  14. package/dist/chunk-BQNVAUS6.js +0 -3
  15. package/dist/chunk-BQNVAUS6.js.map +0 -1
  16. package/dist/ethers.cjs +0 -2
  17. package/dist/ethers.cjs.map +0 -1
  18. package/dist/ethers.d.cts +0 -38
  19. package/dist/ethers.d.ts +0 -38
  20. package/dist/ethers.js +0 -2
  21. package/dist/ethers.js.map +0 -1
  22. package/dist/index.cjs +0 -3
  23. package/dist/index.cjs.map +0 -1
  24. package/dist/index.d.cts +0 -23
  25. package/dist/index.d.ts +0 -23
  26. package/dist/index.js +0 -2
  27. package/dist/index.js.map +0 -1
  28. package/dist/options-vB2peXdE.d.cts +0 -35
  29. package/dist/options-vB2peXdE.d.ts +0 -35
  30. package/dist/privy.cjs +0 -3
  31. package/dist/privy.cjs.map +0 -1
  32. package/dist/privy.d.cts +0 -30
  33. package/dist/privy.d.ts +0 -30
  34. package/dist/privy.js +0 -2
  35. package/dist/privy.js.map +0 -1
  36. package/dist/test-utils.cjs +0 -3
  37. package/dist/test-utils.cjs.map +0 -1
  38. package/dist/test-utils.d.cts +0 -49
  39. package/dist/test-utils.d.ts +0 -49
  40. package/dist/test-utils.js +0 -3
  41. package/dist/test-utils.js.map +0 -1
  42. package/dist/thirdweb.cjs +0 -3
  43. package/dist/thirdweb.cjs.map +0 -1
  44. package/dist/thirdweb.d.cts +0 -30
  45. package/dist/thirdweb.d.ts +0 -30
  46. package/dist/thirdweb.js +0 -3
  47. package/dist/thirdweb.js.map +0 -1
  48. package/dist/types-Bu63z0x6.d.cts +0 -21
  49. package/dist/types-Bu63z0x6.d.ts +0 -21
  50. package/dist/utils/index.cjs +0 -2
  51. package/dist/utils/index.cjs.map +0 -1
  52. package/dist/utils/index.d.cts +0 -18
  53. package/dist/utils/index.d.ts +0 -18
  54. package/dist/utils/index.js +0 -2
  55. package/dist/utils/index.js.map +0 -1
  56. package/dist/viem.cjs +0 -3
  57. package/dist/viem.cjs.map +0 -1
  58. package/dist/viem.d.cts +0 -50
  59. package/dist/viem.d.ts +0 -50
  60. package/dist/viem.js +0 -2
  61. package/dist/viem.js.map +0 -1
@@ -1,1033 +0,0 @@
1
- import { UnexpectedError, TimeoutError } from '@aave/core';
2
- import { HubRequest, Hub, HubsRequest, HubAssetsRequest, HubAsset, ChainRequest, Chain, ChainsFilter, HasProcessedKnownTransactionRequest, ExchangeRateRequest, FiatAmount, PermitRequest, PermitTypedDataResponse, AssetRequest, Asset, AssetPriceHistoryRequest, AssetPriceSample, AssetSupplyHistoryRequest, AssetSupplySample, AssetBorrowHistoryRequest, AssetBorrowSample, ReserveRequest, Reserve, ReservesRequest, BorrowAPYHistoryRequest, APYSample, SupplyAPYHistoryRequest, SpokeRequest, Spoke, SpokesRequest, SpokePositionManagersRequest, PaginatedSpokePositionManagerResult, SpokeUserPositionManagersRequest, PaginatedSpokeUserPositionManagerResult, SwapQuoteRequest, SwapQuote, SwappableTokensRequest, Token, PrepareSwapRequest, PrepareSwapResult, SwapStatusRequest, SwapStatus, SwapCancelled, SwapExpired, SwapFulfilled, SwapReceipt, SwapRequest, SwapExecutionPlan, PrepareSwapCancelRequest, PrepareSwapCancelResult, CancelSwapRequest, CancelSwapExecutionPlan, UserSwapsRequest, PaginatedUserSwapsResult, BorrowRequest, ExecutionPlan, SupplyRequest, RepayRequest, WithdrawRequest, RenounceSpokeUserPositionManagerRequest, TransactionRequest, UpdateUserDynamicConfigRequest, UpdateUserRiskPremiumRequest, LiquidatePositionRequest, SetSpokeUserPositionManagerRequest, PreviewRequest, PreviewUserPosition, SetUserSupplyAsCollateralRequest, ActivitiesRequest, PaginatedActivitiesResult, UserSuppliesRequest, UserSupplyItem, UserBorrowsRequest, UserBorrowItem, UserSummaryRequest, UserSummary, UserPositionsRequest, UserPosition, UserPositionRequest, UserBalancesRequest, UserBalance, UserSummaryHistoryRequest, UserSummaryHistoryItem } from '@aave/graphql';
3
- import { ResultAsync, Prettify } from '@aave/types';
4
- import { A as AaveClient } from '../AaveClient-L3v8kWvn.cjs';
5
- import { C as CurrencyQueryOptions, R as RequestPolicyOptions, T as TimeWindowQueryOptions } from '../options-vB2peXdE.cjs';
6
- import '@urql/core';
7
- import '../types-Bu63z0x6.cjs';
8
-
9
- /**
10
- * Fetches a specific hub by ID or by address and chain ID.
11
- *
12
- * ```ts
13
- * const result = await hub(client, {
14
- * query: { hubId: hubId('SGVsbG8h') }
15
- * });
16
- * ```
17
- *
18
- * @param client - Aave client.
19
- * @param request - The hub request parameters.
20
- * @param options - The query options.
21
- * @returns The hub data, or null if not found.
22
- */
23
- declare function hub(client: AaveClient, request: HubRequest, options?: CurrencyQueryOptions & RequestPolicyOptions): ResultAsync<Hub | null, UnexpectedError>;
24
- /**
25
- * Fetches multiple hubs based on specified criteria.
26
- *
27
- * ```ts
28
- * const result = await hubs(client, {
29
- * query: {
30
- * chainIds: [chainId(1)]
31
- * }
32
- * });
33
- * ```
34
- *
35
- * @param client - Aave client.
36
- * @param request - The hubs request parameters (either tokens or chainIds).
37
- * @param options - The query options.
38
- * @returns Array of hub data.
39
- */
40
- declare function hubs(client: AaveClient, request: HubsRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<Hub[], UnexpectedError>;
41
- /**
42
- * Fetches hub assets for a specific hub by ID or by address and chain ID.
43
- *
44
- * ```ts
45
- * const result = await hubAssets(client, {
46
- * query: { hubId: hubId('SGVsbG8h') },
47
- * });
48
- * ```
49
- *
50
- * @param client - Aave client.
51
- * @param request - The hub assets request parameters.
52
- * @param options - The query options.
53
- * @returns The hub assets array.
54
- */
55
- declare function hubAssets(client: AaveClient, request: HubAssetsRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<HubAsset[], UnexpectedError>;
56
-
57
- /**
58
- * Fetches a specific chain by chain ID.
59
- *
60
- * ```ts
61
- * const result = await chain(client, {
62
- * chainId: chainId(1),
63
- * });
64
- * ```
65
- *
66
- * @param client - Aave client.
67
- * @param request - The chain request parameters.
68
- * @returns The chain data, or null if not found.
69
- */
70
- declare function chain(client: AaveClient, request: ChainRequest): ResultAsync<Chain | null, UnexpectedError>;
71
- /**
72
- * Fetches the list of supported chains.
73
- *
74
- * ```ts
75
- * const chains = await chains(client, { filter: ChainsFilter.ALL });
76
- * ```
77
- *
78
- * @param client - Aave client.
79
- * @param filter - The filter for chains.
80
- * @returns Array of supported chains.
81
- */
82
- declare function chains(client: AaveClient, filter?: ChainsFilter): ResultAsync<Chain[], UnexpectedError>;
83
- /**
84
- * Check if a transaction has been processed by the Aave API.
85
- *
86
- * @param client - Aave client.
87
- * @param request - The request containing transaction hash and operations to check.
88
- * @returns True if the transaction has been processed, false otherwise.
89
- */
90
- declare function hasProcessedKnownTransaction(client: AaveClient, request: HasProcessedKnownTransactionRequest): ResultAsync<boolean, UnexpectedError>;
91
- /**
92
- * Fetches the exchange rate between tokens and fiat currencies.
93
- *
94
- * ```ts
95
- * const result = await exchangeRate(client, {
96
- * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },
97
- * to: Currency.Usd,
98
- * });
99
- * ```
100
- *
101
- * @param client - Aave client.
102
- * @param request - The exchange rate request parameters.
103
- * @returns The exchange rate information as a fiat amount.
104
- */
105
- declare function exchangeRate(client: AaveClient, request: ExchangeRateRequest): ResultAsync<FiatAmount, UnexpectedError>;
106
-
107
- /**
108
- * Generates EIP-712 typed data for permit signatures.
109
- *
110
- * ```ts
111
- * const result = await permitTypedData(client, {
112
- * spender: evmAddress('0x87870bca…'),
113
- * currency: evmAddress('0xa0b86991c431c924b2047c7094daf21b77e…'),
114
- * amount: '1000.5',
115
- * });
116
- *
117
- * if (result.isOk()) {
118
- * // Use the typed data to create a signature
119
- * const signature = await wallet.signTypedData(result.value);
120
- * }
121
- * ```
122
- *
123
- * @param client - Aave client.
124
- * @param request - The permit request parameters.
125
- * @returns The EIP-712 typed data for permit signature.
126
- */
127
- declare function permitTypedData(client: AaveClient, request: PermitRequest): ResultAsync<PermitTypedDataResponse, UnexpectedError>;
128
-
129
- /**
130
- * Fetches information about a specific asset (ERC20 token) in the protocol by ID or by token.
131
- *
132
- * ```ts
133
- * const result = await asset(client, {
134
- * query: { assetId: assetId('SGVsbG8h') }
135
- * });
136
- * ```
137
- *
138
- * @param client - Aave client.
139
- * @param request - The asset request parameters.
140
- * @param options - The query options including currency and time window.
141
- * @returns The asset data, or null if not found.
142
- */
143
- declare function asset(client: AaveClient, request: AssetRequest, options?: CurrencyQueryOptions & TimeWindowQueryOptions & RequestPolicyOptions): ResultAsync<Asset | null, UnexpectedError>;
144
- /**
145
- * Fetches historical price data for a specific asset.
146
- *
147
- * ```ts
148
- * const result = await assetPriceHistory(client, {
149
- * token: { chainId: chainId(1), address: evmAddress('0x123…') },
150
- * currency: Currency.Usd,
151
- * window: TimeWindow.LastWeek,
152
- * });
153
- * ```
154
- *
155
- * @param client - Aave client.
156
- * @param request - The asset price history request parameters.
157
- * @param options - The query options.
158
- * @returns Array of asset price samples over time.
159
- */
160
- declare function assetPriceHistory(client: AaveClient, request: AssetPriceHistoryRequest, options?: Required<RequestPolicyOptions>): ResultAsync<AssetPriceSample[], UnexpectedError>;
161
- /**
162
- * Fetches historical supply data for a specific asset.
163
- *
164
- * ```ts
165
- * const result = await assetSupplyHistory(client, {
166
- * token: { chainId: chainId(1), address: evmAddress('0x123…') },
167
- * window: TimeWindow.LastWeek,
168
- * });
169
- * ```
170
- *
171
- * @param client - Aave client.
172
- * @param request - The asset supply history request parameters.
173
- * @param options - The query options.
174
- * @returns Array of asset supply samples over time.
175
- */
176
- declare function assetSupplyHistory(client: AaveClient, request: AssetSupplyHistoryRequest, options?: Required<RequestPolicyOptions>): ResultAsync<AssetSupplySample[], UnexpectedError>;
177
- /**
178
- * Fetches historical borrow data for a specific asset.
179
- *
180
- * ```ts
181
- * const result = await assetBorrowHistory(client, {
182
- * token: { chainId: chainId(1), address: evmAddress('0x123…') },
183
- * window: TimeWindow.LastWeek,
184
- * });
185
- * ```
186
- *
187
- * @param client - Aave client.
188
- * @param request - The asset borrow history request parameters.
189
- * @param options - The query options.
190
- * @returns Array of asset borrow samples over time.
191
- */
192
- declare function assetBorrowHistory(client: AaveClient, request: AssetBorrowHistoryRequest, options?: Required<RequestPolicyOptions>): ResultAsync<AssetBorrowSample[], UnexpectedError>;
193
-
194
- /**
195
- * Fetches a specific reserve by reserve ID, spoke, and chain.
196
- *
197
- * ```ts
198
- * const result = await reserve(client, {
199
- * reserve: reserveId('SGVsbG8h'),
200
- * user: evmAddress('0x742d35cc…'),
201
- * });
202
- * ```
203
- *
204
- * @param client - Aave client.
205
- * @param request - The reserve request parameters.
206
- * @param options - The query options.
207
- * @returns The reserve data, or null if not found.
208
- */
209
- declare function reserve(client: AaveClient, request: ReserveRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<Reserve | null, UnexpectedError>;
210
- /**
211
- * Fetches reserves based on specified criteria.
212
- *
213
- * ```ts
214
- * const result = await reserves(client, {
215
- * query: {
216
- * spoke: {
217
- * address: evmAddress('0x123...'),
218
- * chainId: chainId(1)
219
- * }
220
- * },
221
- * filter: ReservesRequestFilter.All,
222
- * orderBy: { name: 'ASC' }
223
- * });
224
- * ```
225
- *
226
- * @param client - Aave client.
227
- * @param request - The reserves request parameters.
228
- * @param options - The query options.
229
- * @returns Array of reserves matching the criteria.
230
- */
231
- declare function reserves(client: AaveClient, request: ReservesRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<Reserve[], UnexpectedError>;
232
- /**
233
- * Fetches borrow APY history for a specific reserve over time.
234
- *
235
- * ```ts
236
- * const result = await borrowApyHistory(client, {
237
- * reserve: reserveId('SGVsbG8h'),
238
- * window: TimeWindow.LastWeek
239
- * });
240
- * ```
241
- *
242
- * @param client - Aave client.
243
- * @param request - The borrow APY history request parameters.
244
- * @returns The borrow APY history samples.
245
- */
246
- declare function borrowApyHistory(client: AaveClient, request: BorrowAPYHistoryRequest): ResultAsync<APYSample[], UnexpectedError>;
247
- /**
248
- * Fetches supply APY history for a specific reserve over time.
249
- *
250
- * ```ts
251
- * const result = await supplyApyHistory(client, {
252
- * reserve: reserveId('SGVsbG8h'),
253
- * window: TimeWindow.LastWeek
254
- * });
255
- * ```
256
- *
257
- * @param client - Aave client.
258
- * @param request - The supply APY history request parameters.
259
- * @returns The supply APY history samples.
260
- */
261
- declare function supplyApyHistory(client: AaveClient, request: SupplyAPYHistoryRequest): ResultAsync<APYSample[], UnexpectedError>;
262
-
263
- /**
264
- * Fetches a specific spoke.
265
- *
266
- * ```ts
267
- * const result = await spoke(client, {
268
- * query: { spokeId: spokeId('SGVsbG8h') }
269
- * });
270
- * ```
271
- *
272
- * @param client - Aave client.
273
- * @param request - The spoke request parameters.
274
- * @returns The spoke data, or null if not found.
275
- */
276
- declare function spoke(client: AaveClient, request: SpokeRequest): ResultAsync<Spoke | null, UnexpectedError>;
277
- /**
278
- * Fetches spokes based on specified criteria.
279
- *
280
- * ```ts
281
- * const result = await spokes(client, {
282
- * query: { chainIds: [chainId(1)] }
283
- * });
284
- * ```
285
- *
286
- * @param client - Aave client.
287
- * @param request - The spokes request parameters.
288
- * @returns Array of spokes matching the criteria.
289
- */
290
- declare function spokes(client: AaveClient, request: SpokesRequest): ResultAsync<Spoke[], UnexpectedError>;
291
- /**
292
- * Fetches all positions manager for a specific spoke.
293
- *
294
- * ```ts
295
- * const result = await spokePositionManagers(client, {
296
- * spoke: spokeId('SGVsbG8h'),
297
- * });
298
- * ```
299
- *
300
- * @param client - Aave client.
301
- * @param request - The spokes request parameters.
302
- * @returns Array of spokes matching the criteria.
303
- */
304
- declare function spokePositionManagers(client: AaveClient, request: SpokePositionManagersRequest): ResultAsync<PaginatedSpokePositionManagerResult, UnexpectedError>;
305
- /**
306
- * Fetches all the positions managers of a user for a specific spoke.
307
- *
308
- * ```ts
309
- * const result = await spokeUserPositionManagers(client, {
310
- * spoke: spokeId('SGVsbG8h'),
311
- * user: evmAddress('0x123...'),
312
- * });
313
- * ```
314
- *
315
- * @param client - Aave client.
316
- * @param request - The spokes and pagination request parameters.
317
- * @returns Array of position managers of a user for a specific spoke.
318
- */
319
- declare function spokeUserPositionManagers(client: AaveClient, request: SpokeUserPositionManagersRequest): ResultAsync<PaginatedSpokeUserPositionManagerResult, UnexpectedError>;
320
-
321
- /**
322
- * @internal
323
- * Fetches a swap quote for the specified trade parameters.
324
- *
325
- * ```ts
326
- * const result = await swapQuote(client, {
327
- * chainId: chainId(1),
328
- * buy: { erc20: evmAddress('0xA0b86a33E6...') },
329
- * sell: { erc20: evmAddress('0x6B175474E...') },
330
- * amount: bigDecimal('1000'),
331
- * kind: SwapKind.SELL,
332
- * from: evmAddress('0x742d35cc...'),
333
- * });
334
- * ```
335
- *
336
- * @param client - Aave client.
337
- * @param request - The swap quote request parameters.
338
- * @param options - The query options.
339
- * @returns The swap quote including pricing and cost information.
340
- */
341
- declare function swapQuote(client: AaveClient, request: SwapQuoteRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<SwapQuote, UnexpectedError>;
342
- /**
343
- * @internal
344
- * Fetches the list of tokens available for swapping on a specific chain.
345
- *
346
- * ```ts
347
- * const result = await swappableTokens(client, {
348
- * query: { chainIds: [chainId(1)] },
349
- * });
350
- * ```
351
- *
352
- * @param client - Aave client.
353
- * @param request - The swappable tokens request parameters.
354
- * @returns The list of tokens available for swapping.
355
- */
356
- declare function swappableTokens(client: AaveClient, request: SwappableTokensRequest): ResultAsync<Token[], UnexpectedError>;
357
- /**
358
- * @internal
359
- * Prepares a swap for the specified trade parameters.
360
- *
361
- * ```ts
362
- * const result = await prepareSwap(client, {
363
- * market: {
364
- * chainId: chainId(1),
365
- * buy: { erc20: evmAddress('0xA0b86a33E6...') },
366
- * sell: { erc20: evmAddress('0x6B175474E...') },
367
- * amount: bigDecimal('1000'),
368
- * kind: SwapKind.SELL,
369
- * user: evmAddress('0x742d35cc...'),
370
- * },
371
- * }).andThen(plan => {
372
- * switch (plan.__typename) {
373
- * case 'SwapByIntent':
374
- * return signSwapByIntentWith(plan.data)
375
- * .andThen((signature) => swap({ intent: { quoteId: quote.quoteId, signature } }))
376
- * .andThen((plan) => {
377
- * // …
378
- * });
379
- * );
380
- *
381
- * case 'SwapByIntentWithApprovalRequired':
382
- * return sendTransaction(plan.transaction)
383
- * .andThen(signSwapByIntentWith(plan.data))
384
- * .andThen((signature) => swap({ intent: { quoteId: quote.quoteId, signature } }))
385
- * .andThen((plan) => {
386
- * // …
387
- * });
388
- * );
389
- *
390
- * case 'SwapByTransaction':
391
- * return swap({ transaction: { quoteId: quote.quoteId } })
392
- * .andThen((plan) => {
393
- * // …
394
- * });
395
- * );
396
- *
397
- * case 'InsufficientBalanceError':
398
- * return errAsync(new Error(`Insufficient balance: ${plan.required.value} required.`));
399
- * }
400
- * });
401
- * ```
402
- *
403
- * @param client - Aave client.
404
- * @param request - The prepare swap request parameters.
405
- * @param options - The query options.
406
- * @returns The prepared swap result containing details of the swap.
407
- */
408
- declare function prepareSwap(client: AaveClient, request: PrepareSwapRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<PrepareSwapResult, UnexpectedError>;
409
- /**
410
- * @internal
411
- * Fetches the status of a specific swap.
412
- *
413
- * ```ts
414
- * const result = await swapStatus(client, {
415
- * id: swapId('swap_123'),
416
- * });
417
- * ```
418
- *
419
- * @param client - Aave client.
420
- * @param request - The swap status request parameters.
421
- * @param options - The query options.
422
- * @returns The current status of the swap.
423
- */
424
- declare function swapStatus(client: AaveClient, request: SwapStatusRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<SwapStatus, UnexpectedError>;
425
- type SwapOutcome = SwapCancelled | SwapExpired | SwapFulfilled;
426
- /**
427
- * @internal
428
- * Waits for a swap to reach a final outcome (cancelled, expired, or fulfilled).
429
- *
430
- * ```ts
431
- * const result = waitForSwapOutcome(client)(swapReceipt);
432
- *
433
- * if (result.isOk()) {
434
- * const outcome = result.value;
435
- * switch (outcome.__typename) {
436
- * case 'SwapFulfilled':
437
- * console.log('Swap completed successfully:', outcome.txHash);
438
- * break;
439
- * case 'SwapCancelled':
440
- * console.log('Swap was cancelled:', outcome.cancelledAt);
441
- * break;
442
- * case 'SwapExpired':
443
- * console.log('Swap expired:', outcome.expiredAt);
444
- * break;
445
- * }
446
- * }
447
- * ```
448
- *
449
- * @param client - Aave client configured with polling settings.
450
- * @returns A function that takes a SwapReceipt and returns a ResultAsync with the final outcome.
451
- */
452
- declare function waitForSwapOutcome(client: AaveClient): (receipt: SwapReceipt) => ResultAsync<SwapOutcome, TimeoutError | UnexpectedError>;
453
- /**
454
- * @internal
455
- * Executes a swap for the specified request parameters.
456
- *
457
- * ```ts
458
- * const result = await swap(client, {
459
- * intent: {
460
- * quoteId: swapQuoteId('123...'),
461
- * signature: {
462
- * value: signature('0x456...'),
463
- * deadline: 1234567890,
464
- * },
465
- * },
466
- * }).andThen((plan) => {
467
- * switch (plan.__typename) {
468
- * case 'SwapTransactionRequest':
469
- * return sendTransaction(plan.transaction)
470
- * .map(() => plan.orderReceipt);
471
- *
472
- * case 'SwapApprovalRequired':
473
- * return sendTransaction(plan.transaction)
474
- * .andThen(() => sendTransaction(plan.originalTransaction))
475
- * .map(() => plan.originalTransaction.orderReceipt);
476
- *
477
- * case 'SwapReceipt':
478
- * return okAsync(plan.orderReceipt);
479
- *
480
- * case 'InsufficientBalanceError':
481
- * return errAsync(new Error(`Insufficient balance: ${plan.required.value} required.`));
482
- * }
483
- * });
484
- *
485
- * if (result.isErr()) {
486
- * console.error(result.error);
487
- * return;
488
- * }
489
- *
490
- * console.log('Order receipt:', result.value);
491
- * ```
492
- *
493
- * @param client - Aave client.
494
- * @param request - The swap request parameters.
495
- * @returns The swap execution plan containing transaction details or receipt.
496
- */
497
- declare function swap(client: AaveClient, request: SwapRequest): ResultAsync<SwapExecutionPlan, UnexpectedError>;
498
- /**
499
- * @internal
500
- * Prepares a swap cancellation for the specified swap ID.
501
- *
502
- * ```ts
503
- * const result = await prepareSwapCancel(client, {
504
- * id: swapId('123...'),
505
- * });
506
- * ```
507
- *
508
- * @param client - Aave client.
509
- * @param request - The prepare swap cancel request parameters.
510
- * @returns The prepared swap cancel result containing typed data for signing.
511
- */
512
- declare function prepareSwapCancel(client: AaveClient, request: PrepareSwapCancelRequest): ResultAsync<PrepareSwapCancelResult, UnexpectedError>;
513
- /**
514
- * @internal
515
- * Executes a swap cancellation for the specified request parameters.
516
- *
517
- * ```ts
518
- * const result = await cancelSwap(client, {
519
- * intent: {
520
- * id: swapId('123...'),
521
- * signature: {
522
- * value: signature('0x456...'),
523
- * deadline: 1234567890,
524
- * },
525
- * },
526
- * }).andThen((plan) => {
527
- * switch (plan.__typename) {
528
- * case 'TransactionRequest':
529
- * return sendTransaction(plan)
530
- * .map(() => ({ success: true }));
531
- *
532
- * case 'SwapCancelled':
533
- * return okAsync(plan);
534
- * }
535
- * });
536
- * ```
537
- *
538
- * @param client - Aave client.
539
- * @param request - The cancel swap request parameters.
540
- * @returns The cancel swap execution plan containing transaction details or cancellation receipt.
541
- */
542
- declare function cancelSwap(client: AaveClient, request: CancelSwapRequest): ResultAsync<CancelSwapExecutionPlan, UnexpectedError>;
543
- /**
544
- * @internal
545
- * Fetches the user's swap history for a specific chain.
546
- *
547
- * ```ts
548
- * const result = await userSwaps(client, {
549
- * chainId: chainId(1),
550
- * user: evmAddress('0x742d35cc...'),
551
- * filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
552
- * });
553
- * ```
554
- *
555
- * @param client - Aave client.
556
- * @param request - The user swaps request parameters.
557
- * @param options - The query options.
558
- * @returns The paginated list of user swaps with their status information.
559
- */
560
- declare function userSwaps(client: AaveClient, request: UserSwapsRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<PaginatedUserSwapsResult, UnexpectedError>;
561
-
562
- /**
563
- * Creates a transaction to borrow from a market.
564
- *
565
- * ```ts
566
- * const result = await borrow(client, {
567
- * amount: {
568
- * erc20: {
569
- * value: bigDecimal('1000'),
570
- * },
571
- * },
572
- * reserve: reserveId('SGVsbG8h'),
573
- * sender: evmAddress('0x9abc…'),
574
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
575
- *
576
- * if (result.isErr()) {
577
- * // Handle error, e.g. signing error, etc.
578
- * return;
579
- * }
580
- *
581
- * // result.value: TxHash
582
- * ```
583
- *
584
- * @param client - Aave client.
585
- * @param request - The borrow request parameters.
586
- * @returns The transaction data, approval requirements, or insufficient balance error.
587
- */
588
- declare function borrow(client: AaveClient, request: BorrowRequest): ResultAsync<ExecutionPlan, UnexpectedError>;
589
- /**
590
- * Creates a transaction to supply to a market.
591
- *
592
- * ```ts
593
- * const result = await supply(client, {
594
- * reserve: {
595
- * reserveId: "1234567890",
596
- * spoke: evmAddress('0x8787…'),
597
- * chainId: chainId(1),
598
- * },
599
- * amount: {
600
- * erc20: {
601
- * value: bigDecimal('1000'),
602
- * },
603
- * },
604
- * enableCollateral: true, // Optional, defaults to true
605
- * sender: evmAddress('0x9abc…'),
606
- * });
607
- *
608
- * if (result.isErr()) {
609
- * // Handle error, e.g. insufficient balance, signing error, etc.
610
- * return;
611
- * }
612
- *
613
- * // result.value: TxHash
614
- * ```
615
- *
616
- * @param client - Aave client.
617
- * @param request - The supply request parameters.
618
- * @returns The transaction data, approval requirements, or insufficient balance error.
619
- */
620
- declare function supply(client: AaveClient, request: SupplyRequest): ResultAsync<ExecutionPlan, UnexpectedError>;
621
- /**
622
- * Creates a transaction to repay to a market.
623
- *
624
- * ```ts
625
- * const result = await repay(client, {
626
- * amount: {
627
- * erc20: {
628
- * value: {
629
- * exact: bigDecimal('500'),
630
- * },
631
- * },
632
- * },
633
- * sender: evmAddress('0x9abc…'),
634
- * reserve: reserveId('SGVsbG8h'),
635
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
636
- *
637
- * if (result.isErr()) {
638
- * // Handle error, e.g. insufficient balance, signing error, etc.
639
- * return;
640
- * }
641
- *
642
- * // result.value: TxHash
643
- * ```
644
- *
645
- * @param client - Aave client.
646
- * @param request - The repay request parameters.
647
- * @returns The transaction data, approval requirements, or insufficient balance error.
648
- */
649
- declare function repay(client: AaveClient, request: RepayRequest): ResultAsync<ExecutionPlan, UnexpectedError>;
650
- /**
651
- * Creates a transaction to withdraw from a reserve.
652
- *
653
- * ```ts
654
- * const result = await withdraw(client, {
655
- * reserve: reserveId('SGVsbG8h'),
656
- * amount: {
657
- * erc20: {
658
- * exact: bigDecimal('750.5'),
659
- * },
660
- * },
661
- * sender: evmAddress('0x9abc…'),
662
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
663
- *
664
- * if (result.isErr()) {
665
- * // Handle error, e.g. insufficient balance, signing error, etc.
666
- * return;
667
- * }
668
- *
669
- * // result.value: TxHash
670
- * ```
671
- *
672
- * **Withdraw specific amount:**
673
- * ```ts
674
- * amount: {
675
- * erc20: {
676
- * exact: bigDecimal('100.5'), // Exact amount to withdraw
677
- * }
678
- * }
679
- * ```
680
- *
681
- * **Withdraw all available:**
682
- * ```ts
683
- * amount: {
684
- * erc20: {
685
- * max: true, // Withdraw the full position
686
- * }
687
- * }
688
- * ```
689
- *
690
- * **Withdraw native token:**
691
- * ```ts
692
- * amount: {
693
- * native: bigDecimal('0.5'), // For ETH on Ethereum
694
- * }
695
- * ```
696
- *
697
- * @param client - Aave client.
698
- * @param request - The withdraw request parameters.
699
- * @returns The transaction data, approval requirements, or insufficient balance error.
700
- */
701
- declare function withdraw(client: AaveClient, request: WithdrawRequest): ResultAsync<ExecutionPlan, UnexpectedError>;
702
- /**
703
- * Creates a transaction to renounce a position manager of a user in a specific spoke.
704
- *
705
- * ```ts
706
- * const result = await renounceSpokeUserPositionManager(client, {
707
- * manager: evmAddress('0x9abc…'),
708
- * managing: evmAddress('0xdef0…'),
709
- * spoke: spokeId('SGVsbG8h'),
710
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
711
- *
712
- * if (result.isErr()) {
713
- * // Handle error
714
- * return;
715
- * }
716
- *
717
- * // result.value: TxHash
718
- * ```
719
- *
720
- *
721
- * @param client - Aave client.
722
- * @param request - The renounce spoke user position manager request parameters.
723
- * @returns The transaction data.
724
- */
725
- declare function renounceSpokeUserPositionManager(client: AaveClient, request: RenounceSpokeUserPositionManagerRequest): ResultAsync<TransactionRequest, UnexpectedError>;
726
- /**
727
- * Creates a transaction to update user dynamic config for a specific spoke.
728
- *
729
- * ```ts
730
- * const result = await updateUserDynamicConfig(client, {
731
- * sender: evmAddress('0x9abc…'),
732
- * spoke: spokeId('SGVsbG8h'),
733
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
734
- *
735
- * if (result.isErr()) {
736
- * // Handle error
737
- * return;
738
- * }
739
- *
740
- * // result.value: TxHash
741
- * ```
742
- *
743
- *
744
- * @param client - Aave client.
745
- * @param request - The update user dynamic config request parameters.
746
- * @returns The transaction data.
747
- */
748
- declare function updateUserDynamicConfig(client: AaveClient, request: UpdateUserDynamicConfigRequest): ResultAsync<TransactionRequest, UnexpectedError>;
749
- /**
750
- * Creates a transaction to update user risk premium for a specific spoke.
751
- *
752
- * ```ts
753
- * const result = await updateUserRiskPremium(client, {
754
- * sender: evmAddress('0x9abc…'),
755
- * spoke: spokeId('SGVsbG8h'),
756
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
757
- *
758
- * if (result.isErr()) {
759
- * // Handle error
760
- * return;
761
- * }
762
- *
763
- * // result.value: TxHash
764
- * ```
765
- *
766
- *
767
- * @param client - Aave client.
768
- * @param request - The update user risk premium request parameters.
769
- * @returns The transaction data.
770
- */
771
- declare function updateUserRiskPremium(client: AaveClient, request: UpdateUserRiskPremiumRequest): ResultAsync<TransactionRequest, UnexpectedError>;
772
- /**
773
- * Creates a transaction to liquidate a user's position.
774
- *
775
- * ```ts
776
- * const result = await liquidatePosition(client, {
777
- * collateral: reserveId('SGVsbG8h'),
778
- * debt: reserveId('Q2lhbyE= '),
779
- * amount: {
780
- * exact: bigDecimal('1000'),
781
- * },
782
- * liquidator: evmAddress('0x9abc…'),
783
- * user: evmAddress('0xdef0…'),
784
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
785
- *
786
- * if (result.isErr()) {
787
- * // Handle error, e.g. signing error, etc.
788
- * return;
789
- * }
790
- *
791
- * // result.value: TxHash
792
- * ```
793
- *
794
- * @param client - Aave client.
795
- * @param request - The liquidate position request parameters.
796
- * @returns The transaction data, approval requirements, or insufficient balance error.
797
- */
798
- declare function liquidatePosition(client: AaveClient, request: LiquidatePositionRequest): ResultAsync<ExecutionPlan, UnexpectedError>;
799
- /**
800
- * Sets or removes a position manager for a user on a specific spoke.
801
- *
802
- * **Position managers** can perform transactions on behalf of other users, including:
803
- * - Supply assets
804
- * - Borrow assets
805
- * - Withdraw assets
806
- * - Enable/disable collateral
807
- *
808
- * The `signature` parameter is an **ERC712 signature** that must be signed by the **user**
809
- * (the account granting permissions) to authorize the position manager. The signature contains:
810
- * - `value`: The actual cryptographic signature
811
- * - `deadline`: Unix timestamp when the authorization expires
812
- *
813
- * ```ts
814
- * const result = await setSpokeUserPositionManager(client, {
815
- * spoke: spokeId('SGVsbG8h'),
816
- * manager: evmAddress('0x9abc…'), // Address that will become the position manager
817
- * approve: true, // true to approve, false to remove the manager
818
- * user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)
819
- * signature: {
820
- * value: '0x1234...', // ERC712 signature signed by the user
821
- * deadline: 1735689600, // Unix timestamp when signature expires
822
- * },
823
- * }).andThen(sendWith(wallet)).andThen(client.waitForTransaction);
824
- *
825
- * if (result.isErr()) {
826
- * // Handle error, e.g. signing error, etc.
827
- * return;
828
- * }
829
- *
830
- * // result.value: TxHash
831
- * ```
832
- *
833
- * @param client - Aave client.
834
- * @param request - The spoke set for the position manager request parameters.
835
- * @returns The transaction request data to set position manager.
836
- */
837
- declare function setSpokeUserPositionManager(client: AaveClient, request: SetSpokeUserPositionManagerRequest): ResultAsync<TransactionRequest, UnexpectedError>;
838
- /**
839
- * Previews the impact of a potential action on a user's position.
840
- *
841
- * ```ts
842
- * const result = await preview(client, {
843
- * action: {
844
- * supply: {
845
- * reserve: reserveId('SGVsbG8h'),
846
- * amount: {
847
- * erc20: {
848
- * value: '1000',
849
- * },
850
- * },
851
- * sender: evmAddress('0x9abc…'),
852
- * },
853
- * },
854
- * });
855
- * ```
856
- *
857
- * @param client - Aave client.
858
- * @param request - The preview request parameters containing the action to preview.
859
- * @param options - The query options.
860
- * @returns The preview result showing position changes.
861
- */
862
- declare function preview(client: AaveClient, request: PreviewRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<PreviewUserPosition, UnexpectedError>;
863
- /**
864
- * Sets whether a user's supply should be used as collateral.
865
- *
866
- * ```ts
867
- * const result = await setUserSupplyAsCollateral(client, {
868
- * reserve: reserveId('SGVsbG8h'),
869
- * sender: evmAddress('0x456...'),
870
- * enableCollateral: true
871
- * });
872
- * ```
873
- *
874
- * @param client - Aave client.
875
- * @param request - The set user supply as collateral request parameters.
876
- * @returns The transaction request to set collateral status.
877
- */
878
- declare function setUserSupplyAsCollateral(client: AaveClient, request: SetUserSupplyAsCollateralRequest): ResultAsync<TransactionRequest, UnexpectedError>;
879
- /**
880
- * Fetches paginated list of activities.
881
- *
882
- * ```ts
883
- * const result = await activities(client, {
884
- * query: {
885
- * chainIds: [chainId(1)],
886
- * },
887
- * user: evmAddress('0x742d35cc…'), // Optional
888
- * types: [ActivityType.Supply, ActivityType.Borrow, ActivityType.Withdraw, ActivityType.Repay],
889
- * });
890
- * ```
891
- *
892
- * @param client - Aave client.
893
- * @param request - The activities request parameters.
894
- * @param options - The query options.
895
- * @returns The paginated list of activities.
896
- */
897
- declare function activities(client: AaveClient, request: ActivitiesRequest, options?: CurrencyQueryOptions & RequestPolicyOptions): ResultAsync<PaginatedActivitiesResult, UnexpectedError>;
898
-
899
- /**
900
- * Fetches all user supply positions across the specified spoke.
901
- *
902
- * ```ts
903
- * const result = await userSupplies(client, {
904
- * query: {
905
- * userSpoke: {
906
- * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
907
- * user: evmAddress('0x742d35cc…'),
908
- * },
909
- * },
910
- * orderBy: { name: 'ASC' },
911
- * });
912
- * ```
913
- *
914
- * @param client - Aave client.
915
- * @param request - The user supplies request parameters.
916
- * @param options - The query options.
917
- * @returns The user's supply positions.
918
- */
919
- declare function userSupplies(client: AaveClient, request: UserSuppliesRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<UserSupplyItem[], UnexpectedError>;
920
- /**
921
- * Fetches all user borrow positions across the specified spoke.
922
- *
923
- * ```ts
924
- * const result = await userBorrows(client, {
925
- * query: {
926
- * userSpoke: {
927
- * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
928
- * user: evmAddress('0x742d35cc…'),
929
- * },
930
- * },
931
- * orderBy: { name: 'ASC' },
932
- * });
933
- * ```
934
- *
935
- * @param client - Aave client.
936
- * @param request - The user borrows request parameters.
937
- * @param options - The query options.
938
- * @returns The user's borrow positions.
939
- */
940
- declare function userBorrows(client: AaveClient, request: UserBorrowsRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<UserBorrowItem[], UnexpectedError>;
941
- type UserSummaryQueryOptions = Prettify<CurrencyQueryOptions & TimeWindowQueryOptions>;
942
- /**
943
- * Fetches a user's summary across all positions.
944
- *
945
- * ```ts
946
- * const result = await userSummary(client, {
947
- * user: evmAddress('0x742d35cc…'),
948
- * filter: {
949
- * spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
950
- * },
951
- * });
952
- * ```
953
- *
954
- * @param client - Aave client.
955
- * @param request - The user summary request parameters.
956
- * @param options - The query options.
957
- * @returns The user's financial summary.
958
- */
959
- declare function userSummary(client: AaveClient, request: UserSummaryRequest, { currency, timeWindow, }?: UserSummaryQueryOptions): ResultAsync<UserSummary, UnexpectedError>;
960
- type UserPositionQueryOptions = CurrencyQueryOptions & TimeWindowQueryOptions;
961
- /**
962
- * Fetches all user positions across specified chains.
963
- *
964
- * ```ts
965
- * const result = await userPositions(client, {
966
- * user: evmAddress('0x742d35cc…'),
967
- * filter: {
968
- * chainIds: [chainId(1), chainId(137)],
969
- * },
970
- * orderBy: { balance: 'DESC' },
971
- * });
972
- * ```
973
- *
974
- * @param client - Aave client.
975
- * @param request - The user positions request parameters.
976
- * @param options - The query options.
977
- * @returns The user's positions across all specified chains.
978
- */
979
- declare function userPositions(client: AaveClient, request: UserPositionsRequest, { currency, timeWindow, }?: UserPositionQueryOptions): ResultAsync<UserPosition[], UnexpectedError>;
980
- /**
981
- * Fetches a specific user position by ID.
982
- *
983
- * ```ts
984
- * const result = await userPosition(client, {
985
- * id: userPositionId('SGVsbG8h'),
986
- * });
987
- * ```
988
- *
989
- * @param client - Aave client.
990
- * @param request - The user position request parameters.
991
- * @param options - The query options.
992
- * @returns The specific user position or null if not found.
993
- */
994
- declare function userPosition(client: AaveClient, request: UserPositionRequest, { currency, timeWindow, }?: UserPositionQueryOptions): ResultAsync<UserPosition | null, UnexpectedError>;
995
- /**
996
- * Fetches all user balances across specified chains.
997
- *
998
- * ```ts
999
- * const result = await userBalances(client, {
1000
- * user: evmAddress('0x742d35cc…'),
1001
- * filter: {
1002
- * chainIds: [chainId(1), chainId(137)],
1003
- * },
1004
- * });
1005
- * ```
1006
- *
1007
- * @param client - Aave client.
1008
- * @param request - The user balances request parameters.
1009
- * @param options - The query options.
1010
- * @returns The user's balances across all specified chains.
1011
- **/
1012
- declare function userBalances(client: AaveClient, request: UserBalancesRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<UserBalance[], UnexpectedError>;
1013
- /**
1014
- * Fetches user summary history over time.
1015
- *
1016
- * ```ts
1017
- * const result = await userSummaryHistory(client, {
1018
- * user: evmAddress('0x742d35cc…'),
1019
- * window: TimeWindow.LastWeek,
1020
- * filter: {
1021
- * chainIds: [chainId(1)]
1022
- * }
1023
- * });
1024
- * ```
1025
- *
1026
- * @param client - Aave client.
1027
- * @param request - The user summary history request parameters.
1028
- * @param options - The query options.
1029
- * @returns The user summary history items.
1030
- */
1031
- declare function userSummaryHistory(client: AaveClient, request: UserSummaryHistoryRequest, options?: Required<CurrencyQueryOptions>): ResultAsync<UserSummaryHistoryItem[], UnexpectedError>;
1032
-
1033
- export { type SwapOutcome, type UserPositionQueryOptions, type UserSummaryQueryOptions, activities, asset, assetBorrowHistory, assetPriceHistory, assetSupplyHistory, borrow, borrowApyHistory, cancelSwap, chain, chains, exchangeRate, hasProcessedKnownTransaction, hub, hubAssets, hubs, liquidatePosition, permitTypedData, prepareSwap, prepareSwapCancel, preview, renounceSpokeUserPositionManager, repay, reserve, reserves, setSpokeUserPositionManager, setUserSupplyAsCollateral, spoke, spokePositionManagers, spokeUserPositionManagers, spokes, supply, supplyApyHistory, swap, swapQuote, swapStatus, swappableTokens, updateUserDynamicConfig, updateUserRiskPremium, userBalances, userBorrows, userPosition, userPositions, userSummary, userSummaryHistory, userSupplies, userSwaps, waitForSwapOutcome, withdraw };