@aave/react 0.7.0 → 4.0.0-next.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/README.md +42 -28
- package/dist/chunk-GTUQRT5Q.js +2 -0
- package/dist/chunk-GTUQRT5Q.js.map +1 -0
- package/dist/chunk-XIDOSID3.js +2 -0
- package/dist/chunk-XIDOSID3.js.map +1 -0
- package/dist/ethers.cjs +1 -1
- package/dist/ethers.cjs.map +1 -1
- package/dist/ethers.d.cts +41 -71
- package/dist/ethers.d.ts +41 -71
- 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 +2114 -793
- package/dist/index.d.ts +2114 -793
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/misc-BkG5G4yl.d.cts +377 -0
- package/dist/misc-gmAnSdm5.d.ts +377 -0
- package/dist/privy.cjs +1 -1
- package/dist/privy.cjs.map +1 -1
- package/dist/privy.d.cts +36 -76
- package/dist/privy.d.ts +36 -76
- package/dist/privy.js +1 -1
- package/dist/privy.js.map +1 -1
- package/dist/thirdweb.cjs +2 -2
- package/dist/thirdweb.cjs.map +1 -1
- package/dist/thirdweb.d.cts +35 -85
- package/dist/thirdweb.d.ts +35 -85
- package/dist/thirdweb.js +2 -2
- package/dist/thirdweb.js.map +1 -1
- package/dist/utils.cjs +2 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/dist/viem/index.cjs +2 -0
- package/dist/viem/index.cjs.map +1 -0
- package/dist/viem/index.d.cts +97 -0
- package/dist/viem/index.d.ts +97 -0
- package/dist/viem/index.js +2 -0
- package/dist/viem/index.js.map +1 -0
- package/dist/{tasks-DUn7x8pK.d.cts → writes-BXnwYgAQ.d.cts} +37 -1
- package/dist/{tasks-DUn7x8pK.d.ts → writes-BXnwYgAQ.d.ts} +37 -1
- package/package.json +37 -12
- package/dist/chunk-SECI6TSB.js +0 -2
- package/dist/chunk-SECI6TSB.js.map +0 -1
- package/dist/viem.cjs +0 -2
- package/dist/viem.cjs.map +0 -1
- package/dist/viem.d.cts +0 -115
- package/dist/viem.d.ts +0 -115
- package/dist/viem.js +0 -2
- package/dist/viem.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,14 @@
|
|
|
1
|
-
import { AaveClient, UnexpectedError } from '@aave/client';
|
|
1
|
+
import { AaveClient, CurrencyQueryOptions, UnexpectedError, TimeWindowQueryOptions, ValidationError, ActivitiesRequest, PaginatedActivitiesResult } from '@aave/client';
|
|
2
2
|
export * from '@aave/client';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import '@aave/types';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
};
|
|
4
|
+
import { a as UseAsyncTask, C as CancelOperation, S as SendTransactionError, P as PendingTransactionError, b as PendingTransaction, T as TransactionHandler } from './writes-BXnwYgAQ.js';
|
|
5
|
+
export { A as AsyncTaskError, c as AsyncTaskIdle, d as AsyncTaskLoading, e as AsyncTaskState, f as AsyncTaskSuccess, g as TransactionHandlerOptions, U as UseSendTransactionResult } from './writes-BXnwYgAQ.js';
|
|
6
|
+
import { HubRequest, Hub, HubsRequest, HubAssetsRequest, HubAsset, 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, UserSwapsRequest, PaginatedUserSwapsResult, PrepareSwapRequest, SwapByIntentTypedData, SwapByIntentWithApprovalRequired, SwapTransactionRequest, SwapApprovalRequired, ERC20PermitSignature, SwapReceipt, InsufficientBalanceError, CancelSwapTypedData, TransactionRequest, PrepareSwapCancelRequest, SwapCancelled, SupplyRequest, BorrowRequest, RepayRequest, WithdrawRequest, RenounceSpokeUserPositionManagerRequest, UpdateUserRiskPremiumRequest, UpdateUserDynamicConfigRequest, SetUserSupplyAsCollateralRequest, LiquidatePositionRequest, SetSpokeUserPositionManagerRequest, PreviewRequest, PreviewUserPosition, UserSuppliesRequest, UserSupplyItem, UserBorrowsRequest, UserBorrowItem, UserSummaryRequest, UserSummary, UserPositionsRequest, UserPosition, UserPositionRequest, UserBalancesRequest, UserBalance, UserSummaryHistoryRequest, UserSummaryHistoryItem } from '@aave/graphql';
|
|
7
|
+
import { Prettify, ResultAsync, ResultAwareError, TxHash } from '@aave/types';
|
|
8
|
+
import { S as Suspendable, a as SuspenseResult, P as Pausable, b as PausableSuspenseResult, R as ReadResult, c as PausableReadResult, d as Selector } from './misc-gmAnSdm5.js';
|
|
9
|
+
export { e as UseChainArgs, f as UseChainsArgs, i as UseExchangeRateArgs, U as UseNetworkFee, l as UseNetworkFeeArgs, k as UseNetworkFeeRequestQuery, u as useChain, g as useChains, j as useExchangeRate, h as useExchangeRateAction } from './misc-gmAnSdm5.js';
|
|
10
|
+
import { UnexpectedError as UnexpectedError$1, SigningError, CancelError, TimeoutError, TransactionError, ValidationError as ValidationError$1 } from '@aave/core';
|
|
11
|
+
import { UserPositionQueryOptions } from '@aave/client/actions';
|
|
50
12
|
|
|
51
13
|
/**
|
|
52
14
|
* <AaveProvider> props
|
|
@@ -83,1267 +45,2626 @@ type AaveProviderProps = {
|
|
|
83
45
|
declare function AaveProvider({ children, client }: AaveProviderProps): React.JSX.Element;
|
|
84
46
|
|
|
85
47
|
/**
|
|
86
|
-
*
|
|
48
|
+
* @internal
|
|
87
49
|
*/
|
|
88
50
|
declare function useAaveClient(): AaveClient;
|
|
89
51
|
|
|
90
|
-
type
|
|
52
|
+
type UseHubArgs = Prettify<HubRequest & CurrencyQueryOptions>;
|
|
91
53
|
/**
|
|
92
|
-
*
|
|
54
|
+
* Fetch a specific hub by ID or by address and chain ID.
|
|
93
55
|
*
|
|
94
56
|
* This signature supports React Suspense:
|
|
95
57
|
*
|
|
96
58
|
* ```tsx
|
|
97
|
-
* const { data } =
|
|
98
|
-
*
|
|
59
|
+
* const { data } = useHub({
|
|
60
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
99
61
|
* suspense: true,
|
|
100
62
|
* });
|
|
63
|
+
* // data will be Hub | null
|
|
101
64
|
* ```
|
|
102
65
|
*/
|
|
103
|
-
declare function
|
|
66
|
+
declare function useHub(args: UseHubArgs & Suspendable): SuspenseResult<Hub | null>;
|
|
104
67
|
/**
|
|
105
|
-
*
|
|
68
|
+
* Fetch a specific hub by ID or by address and chain ID.
|
|
69
|
+
*
|
|
70
|
+
* Pausable suspense mode.
|
|
106
71
|
*
|
|
107
72
|
* ```tsx
|
|
108
|
-
* const { data
|
|
109
|
-
*
|
|
73
|
+
* const { data } = useHub({
|
|
74
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
75
|
+
* suspense: true,
|
|
76
|
+
* pause: true,
|
|
110
77
|
* });
|
|
111
78
|
* ```
|
|
112
79
|
*/
|
|
113
|
-
declare function
|
|
80
|
+
declare function useHub(args: Pausable<UseHubArgs> & Suspendable): PausableSuspenseResult<Hub | null>;
|
|
114
81
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* ```ts
|
|
118
|
-
* const [withdraw, withdrawing] = useSavingsGhoWithdraw();
|
|
119
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
120
|
-
*
|
|
121
|
-
* const loading = withdrawing.loading && sending.loading;
|
|
122
|
-
* const error = withdrawing.error || sending.error;
|
|
123
|
-
*
|
|
124
|
-
* // …
|
|
125
|
-
*
|
|
126
|
-
* const result = await withdraw({ ... })
|
|
127
|
-
* .andThen((plan) => {
|
|
128
|
-
* switch (plan.__typename) {
|
|
129
|
-
* case 'TransactionRequest':
|
|
130
|
-
* return sendTransaction(plan);
|
|
131
|
-
*
|
|
132
|
-
* case 'ApprovalRequired':
|
|
133
|
-
* return sendTransaction(plan.approval)
|
|
134
|
-
* .andThen(() => sendTransaction(plan.originalTransaction));
|
|
135
|
-
*
|
|
136
|
-
* case 'InsufficientBalanceError':
|
|
137
|
-
* return errAsync(
|
|
138
|
-
* new Error(`Insufficient balance to withdraw: ${plan.required.value} is the maximum withdrawal allowed.`)
|
|
139
|
-
* );
|
|
140
|
-
* }
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* if (result.isErr()) {
|
|
144
|
-
* console.error(result.error);
|
|
145
|
-
* return;
|
|
146
|
-
* }
|
|
82
|
+
* Fetch a specific hub by ID or by address and chain ID.
|
|
147
83
|
*
|
|
148
|
-
*
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const { data, error, loading } = useHub({
|
|
86
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
87
|
+
* });
|
|
88
|
+
* // data will be Hub | null
|
|
149
89
|
* ```
|
|
150
90
|
*/
|
|
151
|
-
declare function
|
|
91
|
+
declare function useHub(args: UseHubArgs): ReadResult<Hub | null>;
|
|
152
92
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* ```ts
|
|
156
|
-
* const [deposit, depositing] = useSavingsGhoDeposit();
|
|
157
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
93
|
+
* Fetch a specific hub by ID or by address and chain ID.
|
|
158
94
|
*
|
|
159
|
-
*
|
|
160
|
-
* const error = depositing.error || sending.error;
|
|
95
|
+
* Pausable loading state mode.
|
|
161
96
|
*
|
|
162
|
-
*
|
|
97
|
+
* ```tsx
|
|
98
|
+
* const { data, error, loading, paused } = useHub({
|
|
99
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
100
|
+
* pause: true,
|
|
101
|
+
* });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
declare function useHub(args: Pausable<UseHubArgs>): PausableReadResult<Hub | null>;
|
|
105
|
+
type UseHubsArgs = Prettify<HubsRequest & CurrencyQueryOptions>;
|
|
106
|
+
/**
|
|
107
|
+
* Fetch multiple hubs based on specified criteria.
|
|
163
108
|
*
|
|
164
|
-
*
|
|
165
|
-
* .andThen((plan) => {
|
|
166
|
-
* switch (plan.__typename) {
|
|
167
|
-
* case 'TransactionRequest':
|
|
168
|
-
* return sendTransaction(plan);
|
|
109
|
+
* This signature supports React Suspense:
|
|
169
110
|
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
111
|
+
* ```tsx
|
|
112
|
+
* const { data } = useHubs({
|
|
113
|
+
* query: { chainIds: [chainId(1)] },
|
|
114
|
+
* suspense: true,
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function useHubs(args: UseHubsArgs & Suspendable): SuspenseResult<Hub[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Fetch multiple hubs based on specified criteria.
|
|
173
121
|
*
|
|
174
|
-
*
|
|
175
|
-
* return errAsync(
|
|
176
|
-
* new Error(`Insufficient balance: ${plan.required.value} required.`)
|
|
177
|
-
* );
|
|
178
|
-
* }
|
|
179
|
-
* });
|
|
122
|
+
* Pausable suspense mode.
|
|
180
123
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
124
|
+
* ```tsx
|
|
125
|
+
* const { data } = useHubs({
|
|
126
|
+
* query: { chainIds: [chainId(1)] },
|
|
127
|
+
* suspense: true,
|
|
128
|
+
* pause: true,
|
|
129
|
+
* });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
declare function useHubs(args: Pausable<UseHubsArgs> & Suspendable): PausableSuspenseResult<Hub[]>;
|
|
133
|
+
/**
|
|
134
|
+
* Fetch multiple hubs based on specified criteria.
|
|
185
135
|
*
|
|
186
|
-
*
|
|
136
|
+
* ```tsx
|
|
137
|
+
* const { data, error, loading } = useHubs({
|
|
138
|
+
* query: { chainIds: [chainId(1)] },
|
|
139
|
+
* });
|
|
187
140
|
* ```
|
|
188
141
|
*/
|
|
189
|
-
declare function
|
|
190
|
-
|
|
191
|
-
type UserMeritRewardsArgs = UserMeritRewardsRequest;
|
|
142
|
+
declare function useHubs(args: UseHubsArgs): ReadResult<Hub[]>;
|
|
192
143
|
/**
|
|
193
|
-
*
|
|
144
|
+
* Fetch multiple hubs based on specified criteria.
|
|
194
145
|
*
|
|
195
|
-
*
|
|
146
|
+
* Pausable loading state mode.
|
|
196
147
|
*
|
|
197
148
|
* ```tsx
|
|
198
|
-
* const { data } =
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* suspense: true,
|
|
149
|
+
* const { data, error, loading, paused } = useHubs({
|
|
150
|
+
* query: { chainIds: [chainId(1)] },
|
|
151
|
+
* pause: true,
|
|
202
152
|
* });
|
|
203
153
|
* ```
|
|
204
154
|
*/
|
|
205
|
-
declare function
|
|
155
|
+
declare function useHubs(args: Pausable<UseHubsArgs>): PausableReadResult<Hub[]>;
|
|
156
|
+
type UseHubAssetsArgs = Prettify<HubAssetsRequest & CurrencyQueryOptions>;
|
|
206
157
|
/**
|
|
207
|
-
*
|
|
158
|
+
* Fetch hub assets for a specific hub by ID or by address and chain ID.
|
|
159
|
+
*
|
|
160
|
+
* This signature supports React Suspense:
|
|
208
161
|
*
|
|
209
162
|
* ```tsx
|
|
210
|
-
* const { data
|
|
211
|
-
*
|
|
212
|
-
*
|
|
163
|
+
* const { data } = useHubAssets({
|
|
164
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
165
|
+
* user: evmAddress('0x456...'), // optional
|
|
166
|
+
* suspense: true,
|
|
213
167
|
* });
|
|
214
168
|
* ```
|
|
215
169
|
*/
|
|
216
|
-
declare function
|
|
217
|
-
|
|
218
|
-
type UseAaveMarketArgs = MarketRequest;
|
|
170
|
+
declare function useHubAssets(args: UseHubAssetsArgs & Suspendable): SuspenseResult<HubAsset[]>;
|
|
219
171
|
/**
|
|
220
|
-
* Fetch a
|
|
172
|
+
* Fetch hub assets for a specific hub by ID or by address and chain ID.
|
|
221
173
|
*
|
|
222
|
-
*
|
|
174
|
+
* Pausable suspense mode.
|
|
223
175
|
*
|
|
224
176
|
* ```tsx
|
|
225
|
-
* const { data } =
|
|
226
|
-
*
|
|
227
|
-
*
|
|
177
|
+
* const { data } = useHubAssets({
|
|
178
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
179
|
+
* user: evmAddress('0x456...'), // optional
|
|
228
180
|
* suspense: true,
|
|
181
|
+
* pause: true,
|
|
229
182
|
* });
|
|
230
183
|
* ```
|
|
231
184
|
*/
|
|
232
|
-
declare function
|
|
185
|
+
declare function useHubAssets(args: Pausable<UseHubAssetsArgs> & Suspendable): PausableSuspenseResult<HubAsset[]>;
|
|
233
186
|
/**
|
|
234
|
-
* Fetch a
|
|
187
|
+
* Fetch hub assets for a specific hub by ID or by address and chain ID.
|
|
235
188
|
*
|
|
236
189
|
* ```tsx
|
|
237
|
-
* const { data, error, loading } =
|
|
238
|
-
*
|
|
239
|
-
*
|
|
190
|
+
* const { data, error, loading } = useHubAssets({
|
|
191
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
192
|
+
* user: evmAddress('0x456...'), // optional
|
|
240
193
|
* });
|
|
241
194
|
* ```
|
|
242
195
|
*/
|
|
243
|
-
declare function
|
|
244
|
-
type UseAaveMarketsArgs = MarketsRequest;
|
|
196
|
+
declare function useHubAssets(args: UseHubAssetsArgs): ReadResult<HubAsset[]>;
|
|
245
197
|
/**
|
|
246
|
-
* Fetch
|
|
198
|
+
* Fetch hub assets for a specific hub by ID or by address and chain ID.
|
|
247
199
|
*
|
|
248
|
-
*
|
|
200
|
+
* Pausable loading state mode.
|
|
249
201
|
*
|
|
250
202
|
* ```tsx
|
|
251
|
-
* const { data } =
|
|
252
|
-
*
|
|
253
|
-
* user: evmAddress('
|
|
254
|
-
*
|
|
203
|
+
* const { data, error, loading, paused } = useHubAssets({
|
|
204
|
+
* query: { hubId: hubId('SGVsbG8h') },
|
|
205
|
+
* user: evmAddress('0x456...'), // optional
|
|
206
|
+
* pause: true,
|
|
255
207
|
* });
|
|
256
208
|
* ```
|
|
257
209
|
*/
|
|
258
|
-
declare function
|
|
210
|
+
declare function useHubAssets(args: Pausable<UseHubAssetsArgs>): PausableReadResult<HubAsset[]>;
|
|
259
211
|
/**
|
|
260
|
-
*
|
|
212
|
+
* Low-level hook to execute a {@link hubs} action directly.
|
|
261
213
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
214
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
215
|
+
* @remarks
|
|
216
|
+
* This hook **does not** actively watch for updated data on the hubs.
|
|
217
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
218
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
219
|
+
*
|
|
220
|
+
* ```ts
|
|
221
|
+
* const [execute, { called, data, error, loading }] = useHubsAction();
|
|
222
|
+
*
|
|
223
|
+
* // …
|
|
224
|
+
*
|
|
225
|
+
* const result = await execute({
|
|
226
|
+
* query: {
|
|
227
|
+
* chainIds: [chainId(1)]
|
|
228
|
+
* }
|
|
266
229
|
* });
|
|
230
|
+
*
|
|
231
|
+
* if (result.isOk()) {
|
|
232
|
+
* console.log(result.value); // Hub[]
|
|
233
|
+
* } else {
|
|
234
|
+
* console.error(result.error);
|
|
235
|
+
* }
|
|
267
236
|
* ```
|
|
268
237
|
*/
|
|
269
|
-
declare function
|
|
238
|
+
declare function useHubsAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<HubsRequest, Hub[], UnexpectedError>;
|
|
270
239
|
|
|
271
|
-
type UseAaveChainsArgs = {
|
|
272
|
-
filter?: ChainsFilter;
|
|
273
|
-
};
|
|
274
240
|
/**
|
|
275
|
-
*
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
declare function usePermitTypedDataAction(): UseAsyncTask<PermitRequest, PermitTypedDataResponse, UnexpectedError>;
|
|
244
|
+
|
|
245
|
+
type UseAssetArgs = Prettify<AssetRequest & CurrencyQueryOptions & TimeWindowQueryOptions>;
|
|
246
|
+
/**
|
|
247
|
+
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
276
248
|
*
|
|
277
249
|
* This signature supports React Suspense:
|
|
278
250
|
*
|
|
279
251
|
* ```tsx
|
|
280
|
-
* const { data } =
|
|
281
|
-
*
|
|
252
|
+
* const { data } = useAsset({
|
|
253
|
+
* query: { assetId: assetId('SGVsbG8h') },
|
|
282
254
|
* suspense: true,
|
|
283
255
|
* });
|
|
256
|
+
* // data will be Asset | null
|
|
284
257
|
* ```
|
|
285
258
|
*/
|
|
286
|
-
declare function
|
|
259
|
+
declare function useAsset(args: UseAssetArgs & Suspendable): SuspenseResult<Asset | null>;
|
|
287
260
|
/**
|
|
288
|
-
* Fetch
|
|
261
|
+
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
262
|
+
*
|
|
263
|
+
* Pausable suspense mode.
|
|
289
264
|
*
|
|
290
265
|
* ```tsx
|
|
291
|
-
* const { data
|
|
292
|
-
*
|
|
266
|
+
* const { data } = useAsset({
|
|
267
|
+
* query: { assetId: assetId('SGVsbG8h') },
|
|
268
|
+
* suspense: true,
|
|
269
|
+
* pause: true,
|
|
293
270
|
* });
|
|
294
271
|
* ```
|
|
295
272
|
*/
|
|
296
|
-
declare function
|
|
273
|
+
declare function useAsset(args: Pausable<UseAssetArgs> & Suspendable): PausableSuspenseResult<Asset | null>;
|
|
297
274
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* This signature supports React Suspense:
|
|
275
|
+
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
301
276
|
*
|
|
302
277
|
* ```tsx
|
|
303
|
-
* const { data } =
|
|
304
|
-
*
|
|
278
|
+
* const { data, error, loading } = useAsset({
|
|
279
|
+
* query: { assetId: assetId('SGVsbG8h') },
|
|
305
280
|
* });
|
|
281
|
+
* // data will be Asset | null
|
|
306
282
|
* ```
|
|
307
283
|
*/
|
|
308
|
-
declare function
|
|
284
|
+
declare function useAsset(args: UseAssetArgs): ReadResult<Asset | null>;
|
|
309
285
|
/**
|
|
310
|
-
*
|
|
286
|
+
* Fetch information about a specific asset (ERC20 token) in the protocol by ID or by token.
|
|
287
|
+
*
|
|
288
|
+
* Pausable loading state mode.
|
|
311
289
|
*
|
|
312
290
|
* ```tsx
|
|
313
|
-
* const { data, error, loading } =
|
|
291
|
+
* const { data, error, loading, paused } = useAsset({
|
|
292
|
+
* query: { assetId: assetId('SGVsbG8h') },
|
|
293
|
+
* pause: true,
|
|
294
|
+
* });
|
|
314
295
|
* ```
|
|
315
296
|
*/
|
|
316
|
-
declare function
|
|
317
|
-
type
|
|
297
|
+
declare function useAsset(args: Pausable<UseAssetArgs>): PausableReadResult<Asset | null>;
|
|
298
|
+
type UseAssetPriceHistoryArgs = AssetPriceHistoryRequest;
|
|
318
299
|
/**
|
|
319
|
-
* Fetch
|
|
300
|
+
* Fetch historical price data for a specific asset.
|
|
320
301
|
*
|
|
321
302
|
* This signature supports React Suspense:
|
|
322
303
|
*
|
|
323
304
|
* ```tsx
|
|
324
|
-
* const { data } =
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
305
|
+
* const { data } = useAssetPriceHistory({
|
|
306
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
307
|
+
* currency: Currency.Usd,
|
|
308
|
+
* window: TimeWindow.LastWeek,
|
|
328
309
|
* suspense: true,
|
|
329
310
|
* });
|
|
330
311
|
* ```
|
|
331
312
|
*/
|
|
332
|
-
declare function
|
|
313
|
+
declare function useAssetPriceHistory(args: UseAssetPriceHistoryArgs & Suspendable): SuspenseResult<AssetPriceSample[]>;
|
|
333
314
|
/**
|
|
334
|
-
* Fetch
|
|
315
|
+
* Fetch historical price data for a specific asset.
|
|
316
|
+
*
|
|
317
|
+
* Pausable suspense mode.
|
|
335
318
|
*
|
|
336
319
|
* ```tsx
|
|
337
|
-
* const { data
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
320
|
+
* const { data } = useAssetPriceHistory({
|
|
321
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
322
|
+
* suspense: true,
|
|
323
|
+
* pause: true,
|
|
341
324
|
* });
|
|
342
325
|
* ```
|
|
343
326
|
*/
|
|
344
|
-
declare function
|
|
327
|
+
declare function useAssetPriceHistory(args: Pausable<UseAssetPriceHistoryArgs> & Suspendable): PausableSuspenseResult<AssetPriceSample[]>;
|
|
345
328
|
/**
|
|
346
|
-
*
|
|
329
|
+
* Fetch historical price data for a specific asset.
|
|
347
330
|
*
|
|
348
|
-
* ```
|
|
349
|
-
* const
|
|
331
|
+
* ```tsx
|
|
332
|
+
* const { data, error, loading } = useAssetPriceHistory({
|
|
333
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
334
|
+
* currency: Currency.Usd,
|
|
335
|
+
* window: TimeWindow.LastWeek,
|
|
336
|
+
* });
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
declare function useAssetPriceHistory(args: UseAssetPriceHistoryArgs): ReadResult<AssetPriceSample[]>;
|
|
340
|
+
/**
|
|
341
|
+
* Fetch historical price data for a specific asset.
|
|
350
342
|
*
|
|
351
|
-
*
|
|
343
|
+
* Pausable loading state mode.
|
|
352
344
|
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
* amount: {
|
|
358
|
-
* erc20: {
|
|
359
|
-
* currency: evmAddress('0x5678…'),
|
|
360
|
-
* value: '1000',
|
|
361
|
-
* },
|
|
362
|
-
* },
|
|
363
|
-
* borrower: evmAddress('0x9abc…'),
|
|
364
|
-
* chainId: market.chain.chainId,
|
|
365
|
-
* },
|
|
366
|
-
* },
|
|
345
|
+
* ```tsx
|
|
346
|
+
* const { data, error, loading, paused } = useAssetPriceHistory({
|
|
347
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
348
|
+
* pause: true,
|
|
367
349
|
* });
|
|
368
|
-
*
|
|
369
|
-
* if (result.isErr()) {
|
|
370
|
-
* console.error(result.error);
|
|
371
|
-
* } else {
|
|
372
|
-
* console.log(result.value);
|
|
373
|
-
* }
|
|
374
350
|
* ```
|
|
375
351
|
*/
|
|
376
|
-
declare function
|
|
377
|
-
|
|
378
|
-
type UseAaveReserveArgs = ReserveRequest;
|
|
352
|
+
declare function useAssetPriceHistory(args: Pausable<UseAssetPriceHistoryArgs>): PausableReadResult<AssetPriceSample[]>;
|
|
353
|
+
type UseAssetSupplyHistoryArgs = AssetSupplyHistoryRequest;
|
|
379
354
|
/**
|
|
380
|
-
* Fetch a
|
|
355
|
+
* Fetch historical supply data for a specific asset.
|
|
381
356
|
*
|
|
382
357
|
* This signature supports React Suspense:
|
|
383
358
|
*
|
|
384
359
|
* ```tsx
|
|
385
|
-
* const { data } =
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* chainId: chainId(1),
|
|
360
|
+
* const { data } = useAssetSupplyHistory({
|
|
361
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
362
|
+
* window: TimeWindow.LastWeek,
|
|
389
363
|
* suspense: true,
|
|
390
364
|
* });
|
|
391
365
|
* ```
|
|
392
366
|
*/
|
|
393
|
-
declare function
|
|
367
|
+
declare function useAssetSupplyHistory(args: UseAssetSupplyHistoryArgs & Suspendable): SuspenseResult<AssetSupplySample[]>;
|
|
394
368
|
/**
|
|
395
|
-
* Fetch a
|
|
369
|
+
* Fetch historical supply data for a specific asset.
|
|
370
|
+
*
|
|
371
|
+
* Pausable suspense mode.
|
|
396
372
|
*
|
|
397
373
|
* ```tsx
|
|
398
|
-
* const { data
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
374
|
+
* const { data } = useAssetSupplyHistory({
|
|
375
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
376
|
+
* suspense: true,
|
|
377
|
+
* pause: true,
|
|
402
378
|
* });
|
|
403
379
|
* ```
|
|
404
380
|
*/
|
|
405
|
-
declare function
|
|
406
|
-
type UseBorrowAPYHistoryArgs = BorrowAPYHistoryRequest;
|
|
381
|
+
declare function useAssetSupplyHistory(args: Pausable<UseAssetSupplyHistoryArgs> & Suspendable): PausableSuspenseResult<AssetSupplySample[]>;
|
|
407
382
|
/**
|
|
408
|
-
*
|
|
409
|
-
* within a defined time window.
|
|
410
|
-
*
|
|
411
|
-
* This signature supports React Suspense:
|
|
383
|
+
* Fetch historical supply data for a specific asset.
|
|
412
384
|
*
|
|
413
385
|
* ```tsx
|
|
414
|
-
* const { data } =
|
|
415
|
-
* chainId: chainId(1),
|
|
416
|
-
*
|
|
417
|
-
* market: evmAddress('0x24dc35d3c…'),
|
|
418
|
-
* window: TimeWindow.LastWeek
|
|
419
|
-
* suspense: true
|
|
386
|
+
* const { data, error, loading } = useAssetSupplyHistory({
|
|
387
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
388
|
+
* window: TimeWindow.LastWeek,
|
|
420
389
|
* });
|
|
421
390
|
* ```
|
|
422
391
|
*/
|
|
423
|
-
declare function
|
|
392
|
+
declare function useAssetSupplyHistory(args: UseAssetSupplyHistoryArgs): ReadResult<AssetSupplySample[]>;
|
|
424
393
|
/**
|
|
425
|
-
*
|
|
426
|
-
*
|
|
394
|
+
* Fetch historical supply data for a specific asset.
|
|
395
|
+
*
|
|
396
|
+
* Pausable loading state mode.
|
|
427
397
|
*
|
|
428
398
|
* ```tsx
|
|
429
|
-
* const { data } =
|
|
430
|
-
* chainId: chainId(1),
|
|
431
|
-
*
|
|
432
|
-
* market: evmAddress('0x24dc35d3c…'),
|
|
433
|
-
* window: TimeWindow.LastWeek
|
|
399
|
+
* const { data, error, loading, paused } = useAssetSupplyHistory({
|
|
400
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
401
|
+
* pause: true,
|
|
434
402
|
* });
|
|
435
403
|
* ```
|
|
436
404
|
*/
|
|
437
|
-
declare function
|
|
438
|
-
type
|
|
405
|
+
declare function useAssetSupplyHistory(args: Pausable<UseAssetSupplyHistoryArgs>): PausableReadResult<AssetSupplySample[]>;
|
|
406
|
+
type UseAssetBorrowHistoryArgs = AssetBorrowHistoryRequest;
|
|
439
407
|
/**
|
|
440
|
-
*
|
|
441
|
-
* within a defined time window.
|
|
408
|
+
* Fetch historical borrow data for a specific asset.
|
|
442
409
|
*
|
|
443
410
|
* This signature supports React Suspense:
|
|
444
411
|
*
|
|
445
412
|
* ```tsx
|
|
446
|
-
* const { data } =
|
|
447
|
-
* chainId: chainId(1),
|
|
448
|
-
* underlyingToken: evmAddress('0x742d35cc…'),
|
|
449
|
-
* market: evmAddress('0x24dc35d3c…'),
|
|
413
|
+
* const { data } = useAssetBorrowHistory({
|
|
414
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
450
415
|
* window: TimeWindow.LastWeek,
|
|
451
|
-
* suspense: true
|
|
416
|
+
* suspense: true,
|
|
452
417
|
* });
|
|
453
418
|
* ```
|
|
454
419
|
*/
|
|
455
|
-
declare function
|
|
420
|
+
declare function useAssetBorrowHistory(args: UseAssetBorrowHistoryArgs & Suspendable): SuspenseResult<AssetBorrowSample[]>;
|
|
456
421
|
/**
|
|
457
|
-
*
|
|
458
|
-
*
|
|
422
|
+
* Fetch historical borrow data for a specific asset.
|
|
423
|
+
*
|
|
424
|
+
* Pausable suspense mode.
|
|
459
425
|
*
|
|
460
426
|
* ```tsx
|
|
461
|
-
* const { data } =
|
|
462
|
-
* chainId: chainId(1),
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
* window: TimeWindow.LastWeek
|
|
427
|
+
* const { data } = useAssetBorrowHistory({
|
|
428
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
429
|
+
* suspense: true,
|
|
430
|
+
* pause: true,
|
|
466
431
|
* });
|
|
467
432
|
* ```
|
|
468
433
|
*/
|
|
469
|
-
declare function
|
|
470
|
-
type UseCreditDelegateeAllowanceArgs = CreditDelegateeAmountRequest;
|
|
434
|
+
declare function useAssetBorrowHistory(args: Pausable<UseAssetBorrowHistoryArgs> & Suspendable): PausableSuspenseResult<AssetBorrowSample[]>;
|
|
471
435
|
/**
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
* This signature supports React Suspense:
|
|
436
|
+
* Fetch historical borrow data for a specific asset.
|
|
475
437
|
*
|
|
476
438
|
* ```tsx
|
|
477
|
-
* const { data } =
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
* user: evmAddress('0x742d35cc...'),
|
|
481
|
-
* delegatee: evmAddress('0x5678...'),
|
|
482
|
-
* chainId: chainId(1),
|
|
483
|
-
* suspense: true,
|
|
439
|
+
* const { data, error, loading } = useAssetBorrowHistory({
|
|
440
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
441
|
+
* window: TimeWindow.LastWeek,
|
|
484
442
|
* });
|
|
485
443
|
* ```
|
|
486
444
|
*/
|
|
487
|
-
declare function
|
|
445
|
+
declare function useAssetBorrowHistory(args: UseAssetBorrowHistoryArgs): ReadResult<AssetBorrowSample[]>;
|
|
488
446
|
/**
|
|
489
|
-
*
|
|
447
|
+
* Fetch historical borrow data for a specific asset.
|
|
448
|
+
*
|
|
449
|
+
* Pausable loading state mode.
|
|
490
450
|
*
|
|
491
451
|
* ```tsx
|
|
492
|
-
* const { data, error, loading } =
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
* user: evmAddress('0x742d35cc...'),
|
|
496
|
-
* delegatee: evmAddress('0x5678...'),
|
|
497
|
-
* chainId: chainId(1),
|
|
452
|
+
* const { data, error, loading, paused } = useAssetBorrowHistory({
|
|
453
|
+
* token: { chainId: chainId(1), address: evmAddress('0x123...') },
|
|
454
|
+
* pause: true,
|
|
498
455
|
* });
|
|
499
456
|
* ```
|
|
500
457
|
*/
|
|
501
|
-
declare function
|
|
458
|
+
declare function useAssetBorrowHistory(args: Pausable<UseAssetBorrowHistoryArgs>): PausableReadResult<AssetBorrowSample[]>;
|
|
502
459
|
|
|
460
|
+
type UseReserveArgs = Prettify<ReserveRequest & CurrencyQueryOptions>;
|
|
503
461
|
/**
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
* ```ts
|
|
507
|
-
* const [supply, supplying] = useSupply();
|
|
508
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
462
|
+
* Fetch a specific reserve by reserve ID, spoke, and chain.
|
|
509
463
|
*
|
|
510
|
-
*
|
|
511
|
-
* const error = supplying.error || sending.error;
|
|
464
|
+
* This signature supports React Suspense:
|
|
512
465
|
*
|
|
513
|
-
*
|
|
466
|
+
* ```tsx
|
|
467
|
+
* const { data } = useReserve({
|
|
468
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
469
|
+
* user: evmAddress('0xabc...'),
|
|
470
|
+
* suspense: true,
|
|
471
|
+
* });
|
|
472
|
+
* // data will be Reserve | null
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
declare function useReserve(args: UseReserveArgs & Suspendable): SuspenseResult<Reserve | null>;
|
|
476
|
+
/**
|
|
477
|
+
* Fetch a specific reserve by reserve ID, spoke, and chain.
|
|
514
478
|
*
|
|
515
|
-
*
|
|
516
|
-
* .andThen((plan) => {
|
|
517
|
-
* switch (plan.__typename) {
|
|
518
|
-
* case 'TransactionRequest':
|
|
519
|
-
* return sendTransaction(plan);
|
|
479
|
+
* Pausable suspense mode.
|
|
520
480
|
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
481
|
+
* ```tsx
|
|
482
|
+
* const { data } = useReserve({
|
|
483
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
484
|
+
* suspense: true,
|
|
485
|
+
* pause: true,
|
|
486
|
+
* });
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
declare function useReserve(args: Pausable<UseReserveArgs> & Suspendable): PausableSuspenseResult<Reserve | null>;
|
|
490
|
+
/**
|
|
491
|
+
* Fetch a specific reserve by reserve ID, spoke, and chain.
|
|
524
492
|
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
493
|
+
* ```tsx
|
|
494
|
+
* const { data, error, loading } = useReserve({
|
|
495
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
496
|
+
* user: evmAddress('0xabc...'),
|
|
497
|
+
* });
|
|
498
|
+
* // data will be Reserve | null
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
declare function useReserve(args: UseReserveArgs): ReadResult<Reserve | null>;
|
|
502
|
+
/**
|
|
503
|
+
* Fetch a specific reserve by reserve ID, spoke, and chain.
|
|
531
504
|
*
|
|
532
|
-
*
|
|
533
|
-
* console.error(result.error);
|
|
534
|
-
* return;
|
|
535
|
-
* }
|
|
505
|
+
* Pausable loading state mode.
|
|
536
506
|
*
|
|
537
|
-
*
|
|
507
|
+
* ```tsx
|
|
508
|
+
* const { data, error, loading, paused } = useReserve({
|
|
509
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
510
|
+
* pause: true,
|
|
511
|
+
* });
|
|
538
512
|
* ```
|
|
539
513
|
*/
|
|
540
|
-
declare function
|
|
514
|
+
declare function useReserve(args: Pausable<UseReserveArgs>): PausableReadResult<Reserve | null>;
|
|
541
515
|
/**
|
|
542
|
-
*
|
|
516
|
+
* Low-level hook to execute a {@link reserve} action directly.
|
|
543
517
|
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
518
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
519
|
+
* @remarks
|
|
520
|
+
* This hook **does not** actively watch for updated data on the reserve.
|
|
521
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
522
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
547
523
|
*
|
|
548
|
-
*
|
|
549
|
-
* const
|
|
524
|
+
* ```ts
|
|
525
|
+
* const [execute, { called, data, error, loading }] = useReserveAction();
|
|
550
526
|
*
|
|
551
527
|
* // …
|
|
552
528
|
*
|
|
553
|
-
* const result = await
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
* case 'TransactionRequest':
|
|
557
|
-
* return sendTransaction(plan);
|
|
558
|
-
*
|
|
559
|
-
* case 'ApprovalRequired':
|
|
560
|
-
* return sendTransaction(plan.approval)
|
|
561
|
-
* .andThen(() => sendTransaction(plan.originalTransaction));
|
|
562
|
-
*
|
|
563
|
-
* case 'InsufficientBalanceError':
|
|
564
|
-
* return errAsync(
|
|
565
|
-
* new Error(`Insufficient balance: ${plan.required.value} required.`)
|
|
566
|
-
* );
|
|
567
|
-
* }
|
|
568
|
-
* });
|
|
529
|
+
* const result = await execute({
|
|
530
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
531
|
+
* });
|
|
569
532
|
*
|
|
570
|
-
* if (result.
|
|
533
|
+
* if (result.isOk()) {
|
|
534
|
+
* console.log(result.value); // Reserve | null
|
|
535
|
+
* } else {
|
|
571
536
|
* console.error(result.error);
|
|
572
|
-
* return;
|
|
573
537
|
* }
|
|
574
|
-
*
|
|
575
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
576
538
|
* ```
|
|
577
539
|
*/
|
|
578
|
-
declare function
|
|
540
|
+
declare function useReserveAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<ReserveRequest, Reserve | null, UnexpectedError>;
|
|
541
|
+
type UseReservesArgs<T = Reserve[]> = Prettify<ReservesRequest & CurrencyQueryOptions & {
|
|
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
|
+
}>;
|
|
579
552
|
/**
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* ```ts
|
|
583
|
-
* const [repay, repaying] = useRepay();
|
|
584
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
553
|
+
* Fetch reserves based on specified criteria.
|
|
585
554
|
*
|
|
586
|
-
*
|
|
587
|
-
* const error = repaying.error || sending.error;
|
|
588
|
-
*
|
|
589
|
-
* // …
|
|
590
|
-
*
|
|
591
|
-
* const result = await repay({ ... })
|
|
592
|
-
* .andThen((plan) => {
|
|
593
|
-
* switch (plan.__typename) {
|
|
594
|
-
* case 'TransactionRequest':
|
|
595
|
-
* return sendTransaction(plan);
|
|
596
|
-
*
|
|
597
|
-
* case 'ApprovalRequired':
|
|
598
|
-
* return sendTransaction(plan.approval)
|
|
599
|
-
* .andThen(() => sendTransaction(plan.originalTransaction));
|
|
555
|
+
* This signature supports React Suspense:
|
|
600
556
|
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
557
|
+
* ```tsx
|
|
558
|
+
* const { data } = useReserves({
|
|
559
|
+
* query: {
|
|
560
|
+
* spoke: {
|
|
561
|
+
* address: evmAddress('0x123...'),
|
|
562
|
+
* chainId: chainId(1)
|
|
605
563
|
* }
|
|
606
|
-
* }
|
|
564
|
+
* },
|
|
565
|
+
* filter: ReservesRequestFilter.All,
|
|
566
|
+
* orderBy: { name: 'ASC' },
|
|
567
|
+
* suspense: true,
|
|
568
|
+
* });
|
|
569
|
+
* ```
|
|
607
570
|
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
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
|
+
* ```
|
|
612
584
|
*
|
|
613
|
-
*
|
|
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
|
+
* });
|
|
614
597
|
* ```
|
|
615
598
|
*/
|
|
616
|
-
declare function
|
|
599
|
+
declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T> & Suspendable): SuspenseResult<T>;
|
|
617
600
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* ```ts
|
|
621
|
-
* const [withdraw, withdrawing] = useWithdraw();
|
|
622
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
623
|
-
*
|
|
624
|
-
* const loading = withdrawing.loading && sending.loading;
|
|
625
|
-
* const error = withdrawing.error || sending.error;
|
|
626
|
-
*
|
|
627
|
-
* // …
|
|
601
|
+
* Fetch reserves based on specified criteria.
|
|
628
602
|
*
|
|
629
|
-
*
|
|
630
|
-
* .andThen((plan) => {
|
|
631
|
-
* switch (plan.__typename) {
|
|
632
|
-
* case 'TransactionRequest':
|
|
633
|
-
* return sendTransaction(plan);
|
|
603
|
+
* Pausable suspense mode.
|
|
634
604
|
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* new Error(`Insufficient balance: ${plan.required.value} required.`)
|
|
642
|
-
* );
|
|
605
|
+
* ```tsx
|
|
606
|
+
* const { data } = useReserves({
|
|
607
|
+
* query: {
|
|
608
|
+
* spoke: {
|
|
609
|
+
* address: evmAddress('0x123...'),
|
|
610
|
+
* chainId: chainId(1)
|
|
643
611
|
* }
|
|
644
|
-
* }
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
* return;
|
|
649
|
-
* }
|
|
650
|
-
*
|
|
651
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
612
|
+
* },
|
|
613
|
+
* suspense: true,
|
|
614
|
+
* pause: true,
|
|
615
|
+
* });
|
|
652
616
|
* ```
|
|
653
617
|
*/
|
|
654
|
-
declare function
|
|
618
|
+
declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>> & Suspendable): PausableSuspenseResult<T>;
|
|
655
619
|
/**
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
* ```
|
|
659
|
-
* const
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
620
|
+
* Fetch reserves based on specified criteria.
|
|
621
|
+
*
|
|
622
|
+
* ```tsx
|
|
623
|
+
* const { data, error, loading } = useReserves({
|
|
624
|
+
* query: {
|
|
625
|
+
* spoke: {
|
|
626
|
+
* address: evmAddress('0x123...'),
|
|
627
|
+
* chainId: chainId(1)
|
|
628
|
+
* }
|
|
629
|
+
* },
|
|
630
|
+
* filter: ReservesRequestFilter.All,
|
|
631
|
+
* orderBy: { name: 'ASC' },
|
|
632
|
+
* });
|
|
633
|
+
* ```
|
|
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
|
+
*/
|
|
661
|
+
declare function useReserves<T = Reserve[]>(args: UseReservesArgs<T>): ReadResult<T>;
|
|
662
|
+
/**
|
|
663
|
+
* Fetch reserves based on specified criteria.
|
|
664
|
+
*
|
|
665
|
+
* Pausable loading state mode.
|
|
666
|
+
*
|
|
667
|
+
* ```tsx
|
|
668
|
+
* const { data, error, loading, paused } = useReserves({
|
|
669
|
+
* query: {
|
|
670
|
+
* spoke: {
|
|
671
|
+
* address: evmAddress('0x123...'),
|
|
672
|
+
* chainId: chainId(1)
|
|
673
|
+
* }
|
|
674
|
+
* },
|
|
675
|
+
* pause: true,
|
|
676
|
+
* });
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
declare function useReserves<T = Reserve[]>(args: Pausable<UseReservesArgs<T>>): PausableReadResult<T>;
|
|
680
|
+
/**
|
|
681
|
+
* Low-level hook to execute a {@link reserves} action directly.
|
|
682
|
+
*
|
|
683
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
684
|
+
* @remarks
|
|
685
|
+
* This hook **does not** actively watch for updated data on the reserves.
|
|
686
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
687
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
688
|
+
*
|
|
689
|
+
* ```ts
|
|
690
|
+
* const [execute, { called, data, error, loading }] = useReservesAction();
|
|
691
|
+
*
|
|
692
|
+
* // …
|
|
693
|
+
*
|
|
694
|
+
* const result = await execute({
|
|
695
|
+
* query: {
|
|
696
|
+
* spoke: {
|
|
697
|
+
* address: evmAddress('0x1234…'),
|
|
698
|
+
* chainId: chainId(1)
|
|
699
|
+
* }
|
|
700
|
+
* }
|
|
701
|
+
* });
|
|
702
|
+
*
|
|
703
|
+
* if (result.isOk()) {
|
|
704
|
+
* console.log(result.value); // Reserve[]
|
|
705
|
+
* } else {
|
|
706
|
+
* console.error(result.error);
|
|
707
|
+
* }
|
|
708
|
+
* ```
|
|
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
|
+
*/
|
|
740
|
+
declare function useReservesAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<ReservesRequest, Reserve[], UnexpectedError>;
|
|
741
|
+
type UseBorrowApyHistoryArgs = BorrowAPYHistoryRequest;
|
|
742
|
+
/**
|
|
743
|
+
* Fetch borrow APY history for a specific reserve over time.
|
|
744
|
+
*
|
|
745
|
+
* This signature supports React Suspense:
|
|
746
|
+
*
|
|
747
|
+
* ```tsx
|
|
748
|
+
* const { data } = useBorrowApyHistory({
|
|
749
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
750
|
+
* window: TimeWindow.LastWeek,
|
|
751
|
+
* suspense: true,
|
|
752
|
+
* });
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs & Suspendable): SuspenseResult<APYSample[]>;
|
|
756
|
+
/**
|
|
757
|
+
* Fetch borrow APY history for a specific reserve over time.
|
|
758
|
+
*
|
|
759
|
+
* Pausable suspense mode.
|
|
760
|
+
*
|
|
761
|
+
* ```tsx
|
|
762
|
+
* const { data } = useBorrowApyHistory({
|
|
763
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
764
|
+
* window: TimeWindow.LastWeek,
|
|
765
|
+
* suspense: true,
|
|
766
|
+
* pause: true,
|
|
767
|
+
* });
|
|
768
|
+
* ```
|
|
769
|
+
*/
|
|
770
|
+
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs> & Suspendable): PausableSuspenseResult<APYSample[]>;
|
|
771
|
+
/**
|
|
772
|
+
* Fetch borrow APY history for a specific reserve over time.
|
|
773
|
+
*
|
|
774
|
+
* ```tsx
|
|
775
|
+
* const { data, error, loading } = useBorrowApyHistory({
|
|
776
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
777
|
+
* window: TimeWindow.LastWeek,
|
|
778
|
+
* });
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
declare function useBorrowApyHistory(args: UseBorrowApyHistoryArgs): ReadResult<APYSample[]>;
|
|
782
|
+
/**
|
|
783
|
+
* Fetch borrow APY history for a specific reserve over time.
|
|
784
|
+
*
|
|
785
|
+
* Pausable loading state mode.
|
|
786
|
+
*
|
|
787
|
+
* ```tsx
|
|
788
|
+
* const { data, error, loading, paused } = useBorrowApyHistory({
|
|
789
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
790
|
+
* window: TimeWindow.LastWeek,
|
|
791
|
+
* pause: true,
|
|
792
|
+
* });
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
declare function useBorrowApyHistory(args: Pausable<UseBorrowApyHistoryArgs>): PausableReadResult<APYSample[]>;
|
|
796
|
+
type UseSupplyApyHistoryArgs = SupplyAPYHistoryRequest;
|
|
797
|
+
/**
|
|
798
|
+
* Fetch supply APY history for a specific reserve over time.
|
|
799
|
+
*
|
|
800
|
+
* This signature supports React Suspense:
|
|
801
|
+
*
|
|
802
|
+
* ```tsx
|
|
803
|
+
* const { data } = useSupplyApyHistory({
|
|
804
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
805
|
+
* window: TimeWindow.LastWeek,
|
|
806
|
+
* suspense: true,
|
|
807
|
+
* });
|
|
808
|
+
* ```
|
|
809
|
+
*/
|
|
810
|
+
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs & Suspendable): SuspenseResult<APYSample[]>;
|
|
811
|
+
/**
|
|
812
|
+
* Fetch supply APY history for a specific reserve over time.
|
|
813
|
+
*
|
|
814
|
+
* Pausable suspense mode.
|
|
815
|
+
*
|
|
816
|
+
* ```tsx
|
|
817
|
+
* const { data } = useSupplyApyHistory({
|
|
818
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
819
|
+
* window: TimeWindow.LastWeek,
|
|
820
|
+
* suspense: true,
|
|
821
|
+
* pause: true,
|
|
822
|
+
* });
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs> & Suspendable): PausableSuspenseResult<APYSample[]>;
|
|
826
|
+
/**
|
|
827
|
+
* Fetch supply APY history for a specific reserve over time.
|
|
828
|
+
*
|
|
829
|
+
* ```tsx
|
|
830
|
+
* const { data, error, loading } = useSupplyApyHistory({
|
|
831
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
832
|
+
* window: TimeWindow.LastWeek,
|
|
833
|
+
* });
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
declare function useSupplyApyHistory(args: UseSupplyApyHistoryArgs): ReadResult<APYSample[]>;
|
|
837
|
+
/**
|
|
838
|
+
* Fetch supply APY history for a specific reserve over time.
|
|
839
|
+
*
|
|
840
|
+
* Pausable loading state mode.
|
|
841
|
+
*
|
|
842
|
+
* ```tsx
|
|
843
|
+
* const { data, error, loading, paused } = useSupplyApyHistory({
|
|
844
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
845
|
+
* window: TimeWindow.LastWeek,
|
|
846
|
+
* pause: true,
|
|
847
|
+
* });
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
declare function useSupplyApyHistory(args: Pausable<UseSupplyApyHistoryArgs>): PausableReadResult<APYSample[]>;
|
|
851
|
+
|
|
852
|
+
type UseSpokeArgs = SpokeRequest;
|
|
853
|
+
/**
|
|
854
|
+
* Fetch a specific spoke.
|
|
855
|
+
*
|
|
856
|
+
* This signature supports React Suspense:
|
|
857
|
+
*
|
|
858
|
+
* ```tsx
|
|
859
|
+
* const { data } = useSpoke({
|
|
860
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
861
|
+
* suspense: true,
|
|
862
|
+
* });
|
|
863
|
+
* // data will be Spoke | null
|
|
864
|
+
* ```
|
|
865
|
+
*/
|
|
866
|
+
declare function useSpoke(args: UseSpokeArgs & Suspendable): SuspenseResult<Spoke | null>;
|
|
867
|
+
/**
|
|
868
|
+
* Fetch a specific spoke.
|
|
869
|
+
*
|
|
870
|
+
* Pausable suspense mode.
|
|
871
|
+
*
|
|
872
|
+
* ```tsx
|
|
873
|
+
* const { data } = useSpoke({
|
|
874
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
875
|
+
* suspense: true,
|
|
876
|
+
* pause: true,
|
|
877
|
+
* });
|
|
878
|
+
* ```
|
|
879
|
+
*/
|
|
880
|
+
declare function useSpoke(args: Pausable<UseSpokeArgs> & Suspendable): PausableSuspenseResult<Spoke | null>;
|
|
881
|
+
/**
|
|
882
|
+
* Fetch a specific spoke.
|
|
883
|
+
*
|
|
884
|
+
* ```tsx
|
|
885
|
+
* const { data, error, loading } = useSpoke({
|
|
886
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
887
|
+
* });
|
|
888
|
+
* // data will be Spoke | null
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
declare function useSpoke(args: UseSpokeArgs): ReadResult<Spoke | null>;
|
|
892
|
+
/**
|
|
893
|
+
* Fetch a specific spoke.
|
|
894
|
+
*
|
|
895
|
+
* Pausable loading state mode.
|
|
896
|
+
*
|
|
897
|
+
* ```tsx
|
|
898
|
+
* const { data, error, loading, paused } = useSpoke({
|
|
899
|
+
* query: { spokeId: spokeId('SGVsbG8h') },
|
|
900
|
+
* pause: true,
|
|
901
|
+
* });
|
|
902
|
+
* ```
|
|
903
|
+
*/
|
|
904
|
+
declare function useSpoke(args: Pausable<UseSpokeArgs>): PausableReadResult<Spoke | null>;
|
|
905
|
+
type UseSpokesArgs = SpokesRequest;
|
|
906
|
+
/**
|
|
907
|
+
* Fetch spokes based on specified criteria.
|
|
908
|
+
*
|
|
909
|
+
* This signature supports React Suspense:
|
|
910
|
+
*
|
|
911
|
+
* ```tsx
|
|
912
|
+
* const { data } = useSpokes({
|
|
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.
|
|
921
|
+
*
|
|
922
|
+
* Pausable suspense mode.
|
|
923
|
+
*
|
|
924
|
+
* ```tsx
|
|
925
|
+
* const { data } = useSpokes({
|
|
926
|
+
* query: { chainIds: [chainId(1)] },
|
|
927
|
+
* suspense: true,
|
|
928
|
+
* pause: true,
|
|
929
|
+
* });
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
declare function useSpokes(args: Pausable<UseSpokesArgs> & Suspendable): PausableSuspenseResult<Spoke[]>;
|
|
933
|
+
/**
|
|
934
|
+
* Fetch spokes based on specified criteria.
|
|
935
|
+
*
|
|
936
|
+
* ```tsx
|
|
937
|
+
* const { data, error, loading } = useSpokes({
|
|
938
|
+
* query: { chainIds: [chainId(1)] },
|
|
939
|
+
* });
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
942
|
+
declare function useSpokes(args: UseSpokesArgs): ReadResult<Spoke[]>;
|
|
943
|
+
/**
|
|
944
|
+
* Fetch spokes based on specified criteria.
|
|
945
|
+
*
|
|
946
|
+
* Pausable loading state mode.
|
|
947
|
+
*
|
|
948
|
+
* ```tsx
|
|
949
|
+
* const { data, error, loading, paused } = useSpokes({
|
|
950
|
+
* query: { chainIds: [chainId(1)] },
|
|
951
|
+
* pause: true,
|
|
952
|
+
* });
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
declare function useSpokes(args: Pausable<UseSpokesArgs>): PausableReadResult<Spoke[]>;
|
|
956
|
+
type UseSpokePositionManagersArgs = SpokePositionManagersRequest;
|
|
957
|
+
/**
|
|
958
|
+
* Fetches all the positions manager for a specific spoke.
|
|
959
|
+
*
|
|
960
|
+
* This signature supports React Suspense:
|
|
961
|
+
*
|
|
962
|
+
* ```tsx
|
|
963
|
+
* const { data } = useSpokePositionManagers({
|
|
964
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
965
|
+
* suspense: true,
|
|
966
|
+
* });
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
declare function useSpokePositionManagers(args: UseSpokePositionManagersArgs & Suspendable): SuspenseResult<PaginatedSpokePositionManagerResult>;
|
|
970
|
+
/**
|
|
971
|
+
* Fetches all the positions manager for a specific spoke.
|
|
972
|
+
*
|
|
973
|
+
* Pausable suspense mode.
|
|
974
|
+
*
|
|
975
|
+
* ```tsx
|
|
976
|
+
* const { data } = useSpokePositionManagers({
|
|
977
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
978
|
+
* suspense: true,
|
|
979
|
+
* pause: true,
|
|
980
|
+
* });
|
|
981
|
+
* ```
|
|
982
|
+
*/
|
|
983
|
+
declare function useSpokePositionManagers(args: Pausable<UseSpokePositionManagersArgs> & Suspendable): PausableSuspenseResult<PaginatedSpokePositionManagerResult>;
|
|
984
|
+
/**
|
|
985
|
+
* Fetches all the positions manager for a specific spoke.
|
|
986
|
+
*
|
|
987
|
+
* ```tsx
|
|
988
|
+
* const { data, error, loading } = useSpokePositionManagers({
|
|
989
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
990
|
+
* });
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
declare function useSpokePositionManagers(args: UseSpokePositionManagersArgs): ReadResult<PaginatedSpokePositionManagerResult>;
|
|
994
|
+
/**
|
|
995
|
+
* Fetches all the positions manager for a specific spoke.
|
|
996
|
+
*
|
|
997
|
+
* Pausable loading state mode.
|
|
998
|
+
*
|
|
999
|
+
* ```tsx
|
|
1000
|
+
* const { data, error, loading, paused } = useSpokePositionManagers({
|
|
1001
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
1002
|
+
* pause: true,
|
|
1003
|
+
* });
|
|
1004
|
+
* ```
|
|
1005
|
+
*/
|
|
1006
|
+
declare function useSpokePositionManagers(args: Pausable<UseSpokePositionManagersArgs>): PausableReadResult<PaginatedSpokePositionManagerResult>;
|
|
1007
|
+
type UseSpokeUserPositionManagersArgs = SpokeUserPositionManagersRequest;
|
|
1008
|
+
/**
|
|
1009
|
+
* Fetches all the position managers of a user for a specific spoke
|
|
1010
|
+
*
|
|
1011
|
+
* This signature supports React Suspense:
|
|
1012
|
+
*
|
|
1013
|
+
* ```tsx
|
|
1014
|
+
* const { data } = useSpokeUserPositionManagers({
|
|
1015
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
1016
|
+
* user: evmAddress('0x123...'),
|
|
1017
|
+
* suspense: true,
|
|
1018
|
+
* });
|
|
1019
|
+
* ```
|
|
1020
|
+
*/
|
|
1021
|
+
declare function useSpokeUserPositionManagers(args: UseSpokeUserPositionManagersArgs & Suspendable): SuspenseResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Fetches all the position managers of a user for a specific spoke
|
|
1024
|
+
*
|
|
1025
|
+
* Pausable suspense mode.
|
|
1026
|
+
*
|
|
1027
|
+
* ```tsx
|
|
1028
|
+
* const { data } = useSpokeUserPositionManagers({
|
|
1029
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
1030
|
+
* user: evmAddress('0x123...'),
|
|
1031
|
+
* suspense: true,
|
|
1032
|
+
* pause: true,
|
|
1033
|
+
* });
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function useSpokeUserPositionManagers(args: Pausable<UseSpokeUserPositionManagersArgs> & Suspendable): PausableSuspenseResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Fetches all the position managers of a user for a specific spoke
|
|
1039
|
+
*
|
|
1040
|
+
* ```tsx
|
|
1041
|
+
* const { data, error, loading } = useSpokeUserPositionManagers({
|
|
1042
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
1043
|
+
* user: evmAddress('0x123...'),
|
|
1044
|
+
* });
|
|
1045
|
+
* ```
|
|
1046
|
+
*/
|
|
1047
|
+
declare function useSpokeUserPositionManagers(args: UseSpokeUserPositionManagersArgs): ReadResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Fetches all the position managers of a user for a specific spoke
|
|
1050
|
+
*
|
|
1051
|
+
* Pausable loading state mode.
|
|
1052
|
+
*
|
|
1053
|
+
* ```tsx
|
|
1054
|
+
* const { data, error, loading, paused } = useSpokeUserPositionManagers({
|
|
1055
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
1056
|
+
* user: evmAddress('0x123...'),
|
|
1057
|
+
* pause: true,
|
|
1058
|
+
* });
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
declare function useSpokeUserPositionManagers(args: Pausable<UseSpokeUserPositionManagersArgs>): PausableReadResult<PaginatedSpokeUserPositionManagerResult>;
|
|
1062
|
+
|
|
1063
|
+
type UseSwapQuoteArgs = Prettify<SwapQuoteRequest & CurrencyQueryOptions>;
|
|
1064
|
+
/**
|
|
1065
|
+
* @internal
|
|
1066
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1067
|
+
*
|
|
1068
|
+
* This signature supports React Suspense:
|
|
1069
|
+
*
|
|
1070
|
+
* ```tsx
|
|
1071
|
+
* const { data } = useSwapQuote({
|
|
1072
|
+
* chainId: chainId(1),
|
|
1073
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1074
|
+
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1075
|
+
* amount: bigDecimal('1000'),
|
|
1076
|
+
* kind: SwapKind.SELL,
|
|
1077
|
+
* suspense: true,
|
|
1078
|
+
* });
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
declare function useSwapQuote(args: UseSwapQuoteArgs & Suspendable): SuspenseResult<SwapQuote>;
|
|
1082
|
+
/**
|
|
1083
|
+
* @internal
|
|
1084
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1085
|
+
*
|
|
1086
|
+
* Pausable suspense mode.
|
|
1087
|
+
*
|
|
1088
|
+
* ```tsx
|
|
1089
|
+
* const { data } = useSwapQuote({
|
|
1090
|
+
* chainId: chainId(1),
|
|
1091
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1092
|
+
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1093
|
+
* amount: bigDecimal('1000'),
|
|
1094
|
+
* kind: SwapKind.SELL,
|
|
1095
|
+
* from: evmAddress('0x742d35cc...'),
|
|
1096
|
+
* suspense: true,
|
|
1097
|
+
* pause: true,
|
|
1098
|
+
* });
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
declare function useSwapQuote(args: Pausable<UseSwapQuoteArgs> & Suspendable): PausableSuspenseResult<SwapQuote>;
|
|
1102
|
+
/**
|
|
1103
|
+
* @internal
|
|
1104
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1105
|
+
*
|
|
1106
|
+
* ```tsx
|
|
1107
|
+
* const { data, error, loading } = useSwapQuote({
|
|
1108
|
+
* chainId: chainId(1),
|
|
1109
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1110
|
+
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1111
|
+
* amount: bigDecimal('1000'),
|
|
1112
|
+
* kind: SwapKind.SELL,
|
|
1113
|
+
* });
|
|
1114
|
+
* ```
|
|
1115
|
+
*/
|
|
1116
|
+
declare function useSwapQuote(args: UseSwapQuoteArgs): ReadResult<SwapQuote>;
|
|
1117
|
+
/**
|
|
1118
|
+
* @internal
|
|
1119
|
+
* Fetch a swap quote for the specified trade parameters.
|
|
1120
|
+
*
|
|
1121
|
+
* Pausable loading state mode.
|
|
1122
|
+
*
|
|
1123
|
+
* ```tsx
|
|
1124
|
+
* const { data, error, loading, paused } = useSwapQuote({
|
|
1125
|
+
* chainId: chainId(1),
|
|
1126
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1127
|
+
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1128
|
+
* amount: bigDecimal('1000'),
|
|
1129
|
+
* kind: SwapKind.SELL,
|
|
1130
|
+
* from: evmAddress('0x742d35cc...'),
|
|
1131
|
+
* pause: true,
|
|
1132
|
+
* });
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
declare function useSwapQuote(args: Pausable<UseSwapQuoteArgs>): PausableReadResult<SwapQuote>;
|
|
1136
|
+
/**
|
|
1137
|
+
* @internal
|
|
1138
|
+
* Low-level hook to execute a swap quote action directly.
|
|
1139
|
+
*
|
|
1140
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
1141
|
+
* @remarks
|
|
1142
|
+
* 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).
|
|
1145
|
+
*
|
|
1146
|
+
* ```ts
|
|
1147
|
+
* const [getQuote, { called, data, error, loading }] = useSwapQuoteAction();
|
|
664
1148
|
*
|
|
665
1149
|
* // …
|
|
666
1150
|
*
|
|
667
|
-
* const result = await
|
|
668
|
-
*
|
|
1151
|
+
* const result = await getQuote({
|
|
1152
|
+
* chainId: chainId(1),
|
|
1153
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1154
|
+
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1155
|
+
* amount: bigDecimal('1000'),
|
|
1156
|
+
* kind: SwapKind.SELL,
|
|
1157
|
+
* });
|
|
1158
|
+
*
|
|
1159
|
+
* if (result.isOk()) {
|
|
1160
|
+
* console.log('Swap quote:', result.value);
|
|
1161
|
+
* } else {
|
|
1162
|
+
* console.error(result.error);
|
|
1163
|
+
* }
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
1166
|
+
declare function useSwapQuoteAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<SwapQuoteRequest, SwapQuote, UnexpectedError$1>;
|
|
1167
|
+
type UseSwappableTokensArgs = SwappableTokensRequest;
|
|
1168
|
+
/**
|
|
1169
|
+
* @internal
|
|
1170
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1171
|
+
*
|
|
1172
|
+
* This signature supports React Suspense:
|
|
1173
|
+
*
|
|
1174
|
+
* ```tsx
|
|
1175
|
+
* const { data } = useSwappableTokens({
|
|
1176
|
+
* query: { chainIds: [chainId(1)] },
|
|
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.
|
|
1185
|
+
*
|
|
1186
|
+
* Pausable suspense mode.
|
|
1187
|
+
*
|
|
1188
|
+
* ```tsx
|
|
1189
|
+
* const { data } = useSwappableTokens({
|
|
1190
|
+
* query: { chainIds: [chainId(1)] },
|
|
1191
|
+
* suspense: true,
|
|
1192
|
+
* pause: true,
|
|
1193
|
+
* });
|
|
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
|
+
*
|
|
1201
|
+
* ```tsx
|
|
1202
|
+
* const { data, error, loading } = useSwappableTokens({
|
|
1203
|
+
* query: { chainIds: [chainId(1)] },
|
|
1204
|
+
* });
|
|
1205
|
+
* ```
|
|
1206
|
+
*/
|
|
1207
|
+
declare function useSwappableTokens(args: UseSwappableTokensArgs): ReadResult<Token[]>;
|
|
1208
|
+
/**
|
|
1209
|
+
* @internal
|
|
1210
|
+
* Fetch the list of tokens available for swapping on a specific chain.
|
|
1211
|
+
*
|
|
1212
|
+
* Pausable loading state mode.
|
|
1213
|
+
*
|
|
1214
|
+
* ```tsx
|
|
1215
|
+
* const { data, error, loading, paused } = useSwappableTokens({
|
|
1216
|
+
* query: { chainIds: [chainId(1)] },
|
|
1217
|
+
* pause: true,
|
|
1218
|
+
* });
|
|
1219
|
+
* ```
|
|
1220
|
+
*/
|
|
1221
|
+
declare function useSwappableTokens(args: Pausable<UseSwappableTokensArgs>): PausableReadResult<Token[]>;
|
|
1222
|
+
type UseUserSwapsArgs = Prettify<UserSwapsRequest & CurrencyQueryOptions>;
|
|
1223
|
+
/**
|
|
1224
|
+
* @internal
|
|
1225
|
+
* Fetch the user's swap history for a specific chain.
|
|
1226
|
+
*
|
|
1227
|
+
* This signature supports React Suspense:
|
|
1228
|
+
*
|
|
1229
|
+
* ```tsx
|
|
1230
|
+
* const { data } = useUserSwaps({
|
|
1231
|
+
* chainId: chainId(1),
|
|
1232
|
+
* user: evmAddress('0x742d35cc...'),
|
|
1233
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1234
|
+
* suspense: true,
|
|
1235
|
+
* });
|
|
1236
|
+
* ```
|
|
1237
|
+
*/
|
|
1238
|
+
declare function useUserSwaps(args: UseUserSwapsArgs & Suspendable): SuspenseResult<PaginatedUserSwapsResult>;
|
|
1239
|
+
/**
|
|
1240
|
+
* @internal
|
|
1241
|
+
* Fetch the user's swap history for a specific chain.
|
|
1242
|
+
*
|
|
1243
|
+
* Pausable suspense mode.
|
|
1244
|
+
*
|
|
1245
|
+
* ```tsx
|
|
1246
|
+
* const { data } = useUserSwaps({
|
|
1247
|
+
* chainId: chainId(1),
|
|
1248
|
+
* user: evmAddress('0x742d35cc...'),
|
|
1249
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1250
|
+
* suspense: true,
|
|
1251
|
+
* pause: true,
|
|
1252
|
+
* });
|
|
1253
|
+
* ```
|
|
1254
|
+
*/
|
|
1255
|
+
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs> & Suspendable): PausableSuspenseResult<PaginatedUserSwapsResult>;
|
|
1256
|
+
/**
|
|
1257
|
+
* @internal
|
|
1258
|
+
* Fetch the user's swap history for a specific chain.
|
|
1259
|
+
*
|
|
1260
|
+
* ```tsx
|
|
1261
|
+
* const { data, error, loading } = useUserSwaps({
|
|
1262
|
+
* chainId: chainId(1),
|
|
1263
|
+
* user: evmAddress('0x742d35cc...'),
|
|
1264
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1265
|
+
* });
|
|
1266
|
+
* ```
|
|
1267
|
+
*/
|
|
1268
|
+
declare function useUserSwaps(args: UseUserSwapsArgs): ReadResult<PaginatedUserSwapsResult>;
|
|
1269
|
+
/**
|
|
1270
|
+
* @internal
|
|
1271
|
+
* Fetch the user's swap history for a specific chain.
|
|
1272
|
+
*
|
|
1273
|
+
* Pausable loading state mode.
|
|
1274
|
+
*
|
|
1275
|
+
* ```tsx
|
|
1276
|
+
* const { data, error, loading, paused } = useUserSwaps({
|
|
1277
|
+
* chainId: chainId(1),
|
|
1278
|
+
* user: evmAddress('0x742d35cc...'),
|
|
1279
|
+
* filterBy: [SwapStatusFilter.FULFILLED, SwapStatusFilter.OPEN],
|
|
1280
|
+
* pause: true,
|
|
1281
|
+
* });
|
|
1282
|
+
* ```
|
|
1283
|
+
*/
|
|
1284
|
+
declare function useUserSwaps(args: Pausable<UseUserSwapsArgs>): PausableReadResult<PaginatedUserSwapsResult>;
|
|
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>;
|
|
1291
|
+
/**
|
|
1292
|
+
* @internal
|
|
1293
|
+
* Orchestrate the swap execution plan.
|
|
1294
|
+
*
|
|
1295
|
+
* ```tsx
|
|
1296
|
+
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
1297
|
+
* const [signSwapByIntentWith, signing] = useSignSwapByIntentWith(wallet);
|
|
1298
|
+
*
|
|
1299
|
+
* const [swap, swapping] = useSwapTokens((plan) => {
|
|
1300
|
+
* switch (plan.__typename) {
|
|
1301
|
+
* case 'SwapByIntentTypedData':
|
|
1302
|
+
* return signSwapByIntentWith(plan);
|
|
1303
|
+
*
|
|
1304
|
+
* case 'SwapApprovalRequired':
|
|
1305
|
+
* case 'SwapByIntentWithApprovalRequired':
|
|
1306
|
+
* return sendTransaction(plan.transaction);
|
|
1307
|
+
*
|
|
1308
|
+
* case 'SwapTransactionRequest':
|
|
1309
|
+
* return sendTransaction(plan.transaction);
|
|
1310
|
+
* }
|
|
1311
|
+
* });
|
|
1312
|
+
*
|
|
1313
|
+
* const result = await swap({
|
|
1314
|
+
* market: {
|
|
1315
|
+
* chainId: chainId(1),
|
|
1316
|
+
* buy: { erc20: evmAddress('0xA0b86a33E6...') },
|
|
1317
|
+
* sell: { erc20: evmAddress('0x6B175474E...') },
|
|
1318
|
+
* amount: bigDecimal('1000'),
|
|
1319
|
+
* kind: SwapKind.SELL,
|
|
1320
|
+
* user: evmAddress('0x742d35cc...'),
|
|
1321
|
+
* },
|
|
1322
|
+
* });
|
|
669
1323
|
*
|
|
670
1324
|
* if (result.isErr()) {
|
|
671
1325
|
* console.error(result.error);
|
|
672
1326
|
* return;
|
|
673
1327
|
* }
|
|
674
1328
|
*
|
|
675
|
-
*
|
|
1329
|
+
* // result.value: SwapReceipt
|
|
1330
|
+
* ```
|
|
1331
|
+
*/
|
|
1332
|
+
declare function useSwapTokens(handler: SwapHandler): UseAsyncTask<PrepareSwapRequest, SwapReceipt, SendTransactionError | PendingTransactionError | ValidationError<InsufficientBalanceError>>;
|
|
1333
|
+
type CancelSwapHandler = (data: CancelSwapTypedData | TransactionRequest) => ResultAsync<ERC20PermitSignature | PendingTransaction, SigningError | UnexpectedError$1>;
|
|
1334
|
+
declare class CannotCancelSwapError extends ResultAwareError {
|
|
1335
|
+
name: "CannotCancelSwapError";
|
|
1336
|
+
}
|
|
1337
|
+
type CancelSwapError = CancelError | CannotCancelSwapError | SigningError | TimeoutError | TransactionError | UnexpectedError$1;
|
|
1338
|
+
/**
|
|
1339
|
+
* @internal
|
|
1340
|
+
* Executes the complete swap cancellation workflow combining preparation and execution.
|
|
1341
|
+
*
|
|
1342
|
+
* ```tsx
|
|
1343
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1344
|
+
* const [signSwapCancelWith] = useSignSwapCancelWith(wallet);
|
|
1345
|
+
*
|
|
1346
|
+
* const [cancelSwap, {loading, error}] = useCancelSwap((plan: CancelSwapTypedData | TransactionRequest) => {
|
|
1347
|
+
* switch (plan.__typename) {
|
|
1348
|
+
* case 'TransactionRequest':
|
|
1349
|
+
* return sendTransaction(plan);
|
|
1350
|
+
*
|
|
1351
|
+
* case 'CancelSwapTypedData':
|
|
1352
|
+
* return signSwapCancelWith(plan);
|
|
1353
|
+
* }
|
|
1354
|
+
* });
|
|
1355
|
+
*
|
|
1356
|
+
* const result = await cancelSwap({
|
|
1357
|
+
* id: swapId('123...'),
|
|
1358
|
+
* });
|
|
1359
|
+
*
|
|
1360
|
+
* if (result.isErr()) {
|
|
1361
|
+
* console.error(result.error);
|
|
1362
|
+
* return;
|
|
1363
|
+
* }
|
|
1364
|
+
*
|
|
1365
|
+
* // result.value: SwapCancelled
|
|
1366
|
+
* console.log('Swap cancelled:', result.value);
|
|
676
1367
|
* ```
|
|
677
1368
|
*/
|
|
678
|
-
declare function
|
|
1369
|
+
declare function useCancelSwap(handler: CancelSwapHandler): UseAsyncTask<PrepareSwapCancelRequest, SwapCancelled, CancelSwapError>;
|
|
1370
|
+
|
|
679
1371
|
/**
|
|
680
|
-
* A hook that provides a way to
|
|
1372
|
+
* A hook that provides a way to supply assets to an Aave reserve.
|
|
681
1373
|
*
|
|
682
1374
|
* ```ts
|
|
683
|
-
* const [
|
|
684
|
-
* const [
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
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
|
+
* });
|
|
688
1385
|
*
|
|
689
1386
|
* // …
|
|
690
1387
|
*
|
|
691
|
-
* const result = await
|
|
692
|
-
* .andThen(sendTransaction);
|
|
1388
|
+
* const result = await supply({ ... });
|
|
693
1389
|
*
|
|
694
1390
|
* if (result.isErr()) {
|
|
695
|
-
*
|
|
1391
|
+
* switch (result.error.name) {
|
|
1392
|
+
* case 'CancelError':
|
|
1393
|
+
* // The user cancelled the operation
|
|
1394
|
+
* return;
|
|
1395
|
+
*
|
|
1396
|
+
* case 'SigningError':
|
|
1397
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1398
|
+
* break;
|
|
1399
|
+
*
|
|
1400
|
+
* case 'TimeoutError':
|
|
1401
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1402
|
+
* break;
|
|
1403
|
+
*
|
|
1404
|
+
* case 'TransactionError':
|
|
1405
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1406
|
+
* break;
|
|
1407
|
+
*
|
|
1408
|
+
* case 'ValidationError':
|
|
1409
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1410
|
+
* break;
|
|
1411
|
+
*
|
|
1412
|
+
* case 'UnexpectedError':
|
|
1413
|
+
* console.error(result.error.message);
|
|
1414
|
+
* break;
|
|
1415
|
+
* }
|
|
696
1416
|
* return;
|
|
697
1417
|
* }
|
|
698
1418
|
*
|
|
699
1419
|
* console.log('Transaction sent with hash:', result.value);
|
|
700
1420
|
* ```
|
|
1421
|
+
*
|
|
1422
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
701
1423
|
*/
|
|
702
|
-
declare function
|
|
1424
|
+
declare function useSupply(handler: TransactionHandler): UseAsyncTask<SupplyRequest, TxHash, SendTransactionError | PendingTransactionError | ValidationError$1<InsufficientBalanceError>>;
|
|
703
1425
|
/**
|
|
704
|
-
* A hook that provides a way to
|
|
1426
|
+
* A hook that provides a way to borrow assets from an Aave reserve.
|
|
705
1427
|
*
|
|
706
1428
|
* ```ts
|
|
707
|
-
* const [
|
|
708
|
-
* const [
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
1429
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1430
|
+
* const [borrow, { loading, error }] = useBorrow((plan, { cancel }) => {
|
|
1431
|
+
* switch (plan.__typename) {
|
|
1432
|
+
* case 'TransactionRequest':
|
|
1433
|
+
* return sendTransaction(plan);
|
|
1434
|
+
* case 'Erc20ApprovalRequired':
|
|
1435
|
+
* case 'PreContractActionRequired':
|
|
1436
|
+
* return sendTransaction(plan.transaction);
|
|
1437
|
+
* }
|
|
1438
|
+
* });
|
|
712
1439
|
*
|
|
713
1440
|
* // …
|
|
714
1441
|
*
|
|
715
|
-
* const result = await
|
|
716
|
-
* .andThen(sendTransaction);
|
|
1442
|
+
* const result = await borrow({ ... });
|
|
717
1443
|
*
|
|
718
1444
|
* if (result.isErr()) {
|
|
719
|
-
*
|
|
1445
|
+
* switch (result.error.name) {
|
|
1446
|
+
* case 'CancelError':
|
|
1447
|
+
* // The user cancelled the operation
|
|
1448
|
+
* return;
|
|
1449
|
+
*
|
|
1450
|
+
* case 'SigningError':
|
|
1451
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1452
|
+
* break;
|
|
1453
|
+
*
|
|
1454
|
+
* case 'TimeoutError':
|
|
1455
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1456
|
+
* break;
|
|
1457
|
+
*
|
|
1458
|
+
* case 'TransactionError':
|
|
1459
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1460
|
+
* break;
|
|
1461
|
+
*
|
|
1462
|
+
* case 'ValidationError':
|
|
1463
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1464
|
+
* break;
|
|
1465
|
+
*
|
|
1466
|
+
* case 'UnexpectedError':
|
|
1467
|
+
* console.error(result.error.message);
|
|
1468
|
+
* break;
|
|
1469
|
+
* }
|
|
720
1470
|
* return;
|
|
721
1471
|
* }
|
|
722
1472
|
*
|
|
723
1473
|
* console.log('Transaction sent with hash:', result.value);
|
|
724
1474
|
* ```
|
|
1475
|
+
*
|
|
1476
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
725
1477
|
*/
|
|
726
|
-
declare function
|
|
1478
|
+
declare function useBorrow(handler: TransactionHandler): UseAsyncTask<BorrowRequest, TxHash, SendTransactionError | PendingTransactionError | ValidationError$1<InsufficientBalanceError>>;
|
|
727
1479
|
/**
|
|
728
|
-
* A hook that provides a way to
|
|
1480
|
+
* A hook that provides a way to repay borrowed assets to an Aave reserve.
|
|
729
1481
|
*
|
|
730
1482
|
* ```ts
|
|
731
|
-
* const [
|
|
732
|
-
* const [
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
1483
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1484
|
+
* const [repay, { loading, error }] = useRepay((plan, { cancel }) => {
|
|
1485
|
+
* switch (plan.__typename) {
|
|
1486
|
+
* case 'TransactionRequest':
|
|
1487
|
+
* return sendTransaction(plan);
|
|
1488
|
+
* case 'Erc20ApprovalRequired':
|
|
1489
|
+
* case 'PreContractActionRequired':
|
|
1490
|
+
* return sendTransaction(plan.transaction);
|
|
1491
|
+
* }
|
|
1492
|
+
* });
|
|
736
1493
|
*
|
|
737
1494
|
* // …
|
|
738
1495
|
*
|
|
739
|
-
* const result = await
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
1496
|
+
* const result = await repay({ ... });
|
|
1497
|
+
*
|
|
1498
|
+
* if (result.isErr()) {
|
|
1499
|
+
* switch (result.error.name) {
|
|
1500
|
+
* case 'CancelError':
|
|
1501
|
+
* // The user cancelled the operation
|
|
1502
|
+
* return;
|
|
1503
|
+
*
|
|
1504
|
+
* case 'SigningError':
|
|
1505
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1506
|
+
* break;
|
|
1507
|
+
*
|
|
1508
|
+
* case 'TimeoutError':
|
|
1509
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1510
|
+
* break;
|
|
1511
|
+
*
|
|
1512
|
+
* case 'TransactionError':
|
|
1513
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1514
|
+
* break;
|
|
1515
|
+
*
|
|
1516
|
+
* case 'ValidationError':
|
|
1517
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1518
|
+
* break;
|
|
1519
|
+
*
|
|
1520
|
+
* case 'UnexpectedError':
|
|
1521
|
+
* console.error(result.error.message);
|
|
1522
|
+
* break;
|
|
1523
|
+
* }
|
|
1524
|
+
* return;
|
|
1525
|
+
* }
|
|
1526
|
+
*
|
|
1527
|
+
* console.log('Transaction sent with hash:', result.value);
|
|
1528
|
+
* ```
|
|
744
1529
|
*
|
|
745
|
-
*
|
|
746
|
-
|
|
747
|
-
|
|
1530
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
1531
|
+
*/
|
|
1532
|
+
declare function useRepay(handler: TransactionHandler): UseAsyncTask<RepayRequest, TxHash, SendTransactionError | PendingTransactionError | ValidationError$1<InsufficientBalanceError>>;
|
|
1533
|
+
/**
|
|
1534
|
+
* A hook that provides a way to withdraw supplied assets from an Aave reserve.
|
|
748
1535
|
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
1536
|
+
* ```ts
|
|
1537
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1538
|
+
* const [withdraw, { loading, error }] = useWithdraw((plan, { cancel }) => {
|
|
1539
|
+
* switch (plan.__typename) {
|
|
1540
|
+
* case 'TransactionRequest':
|
|
1541
|
+
* return sendTransaction(plan);
|
|
1542
|
+
* case 'Erc20ApprovalRequired':
|
|
1543
|
+
* case 'PreContractActionRequired':
|
|
1544
|
+
* return sendTransaction(plan.transaction);
|
|
1545
|
+
* }
|
|
1546
|
+
* });
|
|
1547
|
+
*
|
|
1548
|
+
* // …
|
|
1549
|
+
*
|
|
1550
|
+
* const result = await withdraw({ ... });
|
|
755
1551
|
*
|
|
756
1552
|
* if (result.isErr()) {
|
|
757
|
-
*
|
|
1553
|
+
* switch (result.error.name) {
|
|
1554
|
+
* case 'CancelError':
|
|
1555
|
+
* // The user cancelled the operation
|
|
1556
|
+
* return;
|
|
1557
|
+
*
|
|
1558
|
+
* case 'SigningError':
|
|
1559
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1560
|
+
* break;
|
|
1561
|
+
*
|
|
1562
|
+
* case 'TimeoutError':
|
|
1563
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1564
|
+
* break;
|
|
1565
|
+
*
|
|
1566
|
+
* case 'TransactionError':
|
|
1567
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1568
|
+
* break;
|
|
1569
|
+
*
|
|
1570
|
+
* case 'ValidationError':
|
|
1571
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1572
|
+
* break;
|
|
1573
|
+
*
|
|
1574
|
+
* case 'UnexpectedError':
|
|
1575
|
+
* console.error(result.error.message);
|
|
1576
|
+
* break;
|
|
1577
|
+
* }
|
|
758
1578
|
* return;
|
|
759
1579
|
* }
|
|
760
1580
|
*
|
|
761
1581
|
* console.log('Transaction sent with hash:', result.value);
|
|
762
1582
|
* ```
|
|
1583
|
+
*
|
|
1584
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
763
1585
|
*/
|
|
764
|
-
declare function
|
|
1586
|
+
declare function useWithdraw(handler: TransactionHandler): UseAsyncTask<WithdrawRequest, TxHash, SendTransactionError | PendingTransactionError | ValidationError$1<InsufficientBalanceError>>;
|
|
765
1587
|
/**
|
|
766
|
-
* A hook that provides a way to
|
|
1588
|
+
* A hook that provides a way to renounce a position manager of a user for a specific spoke.
|
|
767
1589
|
*
|
|
768
1590
|
* ```ts
|
|
769
|
-
* const [
|
|
770
|
-
* const [
|
|
1591
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1592
|
+
* const [renounceSpokeUserPositionManager, { loading, error }] = useRenounceSpokeUserPositionManager(sendTransaction);
|
|
771
1593
|
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
1594
|
+
* // …
|
|
1595
|
+
*
|
|
1596
|
+
* const result = await renounceSpokeUserPositionManager({ ... });
|
|
1597
|
+
*
|
|
1598
|
+
* if (result.isErr()) {
|
|
1599
|
+
* switch (result.error.name) {
|
|
1600
|
+
* case 'CancelError':
|
|
1601
|
+
* // The user cancelled the operation
|
|
1602
|
+
* return;
|
|
1603
|
+
*
|
|
1604
|
+
* case 'SigningError':
|
|
1605
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1606
|
+
* break;
|
|
1607
|
+
*
|
|
1608
|
+
* case 'TimeoutError':
|
|
1609
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1610
|
+
* break;
|
|
1611
|
+
*
|
|
1612
|
+
* case 'TransactionError':
|
|
1613
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1614
|
+
* break;
|
|
1615
|
+
*
|
|
1616
|
+
* case 'UnexpectedError':
|
|
1617
|
+
* console.error(result.error.message);
|
|
1618
|
+
* break;
|
|
1619
|
+
* }
|
|
1620
|
+
* return;
|
|
1621
|
+
* }
|
|
1622
|
+
*
|
|
1623
|
+
* console.log('Transaction sent with hash:', result.value);
|
|
1624
|
+
* ```
|
|
1625
|
+
*
|
|
1626
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1627
|
+
*/
|
|
1628
|
+
declare function useRenounceSpokeUserPositionManager(handler: TransactionHandler): UseAsyncTask<RenounceSpokeUserPositionManagerRequest, TxHash, SendTransactionError | PendingTransactionError>;
|
|
1629
|
+
/**
|
|
1630
|
+
* A hook that provides a way to update the user risk premium for a spoke.
|
|
1631
|
+
*
|
|
1632
|
+
* ```ts
|
|
1633
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1634
|
+
* const [updateUserRiskPremium, { loading, error }] = useUpdateUserRiskPremium((transaction, { cancel }) => {
|
|
1635
|
+
* return sendTransaction(transaction);
|
|
1636
|
+
* });
|
|
774
1637
|
*
|
|
775
1638
|
* // …
|
|
776
1639
|
*
|
|
777
|
-
* const result = await
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
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
|
+
* }
|
|
782
1666
|
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
* .andThen(() => sendTransaction(plan.originalTransaction));
|
|
1667
|
+
* console.log('Transaction sent with hash:', result.value);
|
|
1668
|
+
* ```
|
|
786
1669
|
*
|
|
787
|
-
*
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
*
|
|
792
|
-
*
|
|
1670
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1671
|
+
*/
|
|
1672
|
+
declare function useUpdateUserRiskPremium(handler: TransactionHandler): UseAsyncTask<UpdateUserRiskPremiumRequest, TxHash, SendTransactionError | PendingTransactionError>;
|
|
1673
|
+
/**
|
|
1674
|
+
* A hook that provides a way to update the user dynamic configuration for a spoke.
|
|
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({ ... });
|
|
793
1685
|
*
|
|
794
1686
|
* if (result.isErr()) {
|
|
795
|
-
*
|
|
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;
|
|
1703
|
+
*
|
|
1704
|
+
* case 'UnexpectedError':
|
|
1705
|
+
* console.error(result.error.message);
|
|
1706
|
+
* break;
|
|
1707
|
+
* }
|
|
796
1708
|
* return;
|
|
797
1709
|
* }
|
|
798
1710
|
*
|
|
799
1711
|
* console.log('Transaction sent with hash:', result.value);
|
|
800
1712
|
* ```
|
|
1713
|
+
*
|
|
1714
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
801
1715
|
*/
|
|
802
|
-
declare function
|
|
1716
|
+
declare function useUpdateUserDynamicConfig(handler: TransactionHandler): UseAsyncTask<UpdateUserDynamicConfigRequest, TxHash, SendTransactionError | PendingTransactionError>;
|
|
803
1717
|
/**
|
|
804
|
-
*
|
|
1718
|
+
* Hook for setting whether a user's supply should be used as collateral.
|
|
805
1719
|
*
|
|
806
1720
|
* ```ts
|
|
807
|
-
* const [
|
|
808
|
-
* const [
|
|
1721
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1722
|
+
* const [setUserSupplyAsCollateral, { loading, error }] = useSetUserSupplyAsCollateral((transaction, { cancel }) => {
|
|
1723
|
+
* return sendTransaction(transaction);
|
|
1724
|
+
* });
|
|
1725
|
+
*
|
|
1726
|
+
* const result = await setUserSupplyAsCollateral({
|
|
1727
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
1728
|
+
* sender: evmAddress('0x456...'),
|
|
1729
|
+
* enableCollateral: true,
|
|
1730
|
+
* });
|
|
1731
|
+
*
|
|
1732
|
+
* if (result.isErr()) {
|
|
1733
|
+
* switch (result.error.name) {
|
|
1734
|
+
* case 'CancelError':
|
|
1735
|
+
* // The user cancelled the operation
|
|
1736
|
+
* return;
|
|
1737
|
+
*
|
|
1738
|
+
* case 'SigningError':
|
|
1739
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1740
|
+
* break;
|
|
1741
|
+
*
|
|
1742
|
+
* case 'TimeoutError':
|
|
1743
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1744
|
+
* break;
|
|
1745
|
+
*
|
|
1746
|
+
* case 'TransactionError':
|
|
1747
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1748
|
+
* break;
|
|
1749
|
+
*
|
|
1750
|
+
* case 'UnexpectedError':
|
|
1751
|
+
* console.error(result.error.message);
|
|
1752
|
+
* break;
|
|
1753
|
+
* }
|
|
1754
|
+
* return;
|
|
1755
|
+
* }
|
|
809
1756
|
*
|
|
810
|
-
*
|
|
811
|
-
*
|
|
1757
|
+
* console.log('Transaction sent with hash:', result.value);
|
|
1758
|
+
* ```
|
|
1759
|
+
*
|
|
1760
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1761
|
+
*/
|
|
1762
|
+
declare function useSetUserSupplyAsCollateral(handler: TransactionHandler): UseAsyncTask<SetUserSupplyAsCollateralRequest, TxHash, SendTransactionError | PendingTransactionError>;
|
|
1763
|
+
/**
|
|
1764
|
+
* A hook that provides a way to liquidate a user's position.
|
|
1765
|
+
*
|
|
1766
|
+
* ```ts
|
|
1767
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1768
|
+
* const [liquidatePosition, { loading, error }] = useLiquidatePosition((plan, { cancel }) => {
|
|
1769
|
+
* switch (plan.__typename) {
|
|
1770
|
+
* case 'TransactionRequest':
|
|
1771
|
+
* return sendTransaction(plan);
|
|
1772
|
+
* case 'Erc20ApprovalRequired':
|
|
1773
|
+
* case 'PreContractActionRequired':
|
|
1774
|
+
* return sendTransaction(plan.transaction);
|
|
1775
|
+
* }
|
|
1776
|
+
* });
|
|
812
1777
|
*
|
|
813
1778
|
* // …
|
|
814
1779
|
*
|
|
815
|
-
* const result = await
|
|
816
|
-
*
|
|
1780
|
+
* const result = await liquidatePosition({
|
|
1781
|
+
* collateral: reserveId('SGVsbG8h'),
|
|
1782
|
+
* debt: reserveId('Q2lhbyE= '),
|
|
1783
|
+
* amount: amount,
|
|
1784
|
+
* liquidator: liquidator,
|
|
1785
|
+
* borrower: borrower,
|
|
1786
|
+
* });
|
|
817
1787
|
*
|
|
818
1788
|
* if (result.isErr()) {
|
|
819
|
-
*
|
|
1789
|
+
* switch (result.error.name) {
|
|
1790
|
+
* case 'CancelError':
|
|
1791
|
+
* // The user cancelled the operation
|
|
1792
|
+
* return;
|
|
1793
|
+
*
|
|
1794
|
+
* case 'SigningError':
|
|
1795
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1796
|
+
* break;
|
|
1797
|
+
*
|
|
1798
|
+
* case 'TimeoutError':
|
|
1799
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1800
|
+
* break;
|
|
1801
|
+
*
|
|
1802
|
+
* case 'TransactionError':
|
|
1803
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1804
|
+
* break;
|
|
1805
|
+
*
|
|
1806
|
+
* case 'ValidationError':
|
|
1807
|
+
* console.error(`Insufficient balance: ${result.error.cause.required.value} required.`);
|
|
1808
|
+
* break;
|
|
1809
|
+
*
|
|
1810
|
+
* case 'UnexpectedError':
|
|
1811
|
+
* console.error(result.error.message);
|
|
1812
|
+
* break;
|
|
1813
|
+
* }
|
|
820
1814
|
* return;
|
|
821
1815
|
* }
|
|
822
1816
|
*
|
|
823
1817
|
* console.log('Transaction sent with hash:', result.value);
|
|
824
1818
|
* ```
|
|
1819
|
+
*
|
|
1820
|
+
* @param handler - The handler that will be used to handle the transactions.
|
|
825
1821
|
*/
|
|
826
|
-
declare function
|
|
1822
|
+
declare function useLiquidatePosition(handler: TransactionHandler): UseAsyncTask<LiquidatePositionRequest, TxHash, SendTransactionError | PendingTransactionError | ValidationError$1<InsufficientBalanceError>>;
|
|
827
1823
|
/**
|
|
828
|
-
* A hook that provides a way to
|
|
1824
|
+
* A hook that provides a way to set or remove a position manager for a user on a specific spoke.
|
|
1825
|
+
*
|
|
1826
|
+
* **Position managers** can perform transactions on behalf of other users, including:
|
|
1827
|
+
* - Supply assets
|
|
1828
|
+
* - Borrow assets
|
|
1829
|
+
* - Withdraw assets
|
|
1830
|
+
* - Enable/disable collateral
|
|
1831
|
+
*
|
|
1832
|
+
* The `signature` parameter is an **ERC712 signature** that must be signed by the **user**
|
|
1833
|
+
* (the account granting permissions) to authorize the position manager. The signature contains:
|
|
1834
|
+
* - `value`: The actual cryptographic signature
|
|
1835
|
+
* - `deadline`: Unix timestamp when the authorization expires
|
|
829
1836
|
*
|
|
830
1837
|
* ```ts
|
|
831
|
-
* const [
|
|
832
|
-
* const [
|
|
1838
|
+
* const [sendTransaction] = useSendTransaction(wallet);
|
|
1839
|
+
* const [setSpokeUserPositionManager, { loading, error }] = useSetSpokeUserPositionManager((transaction, { cancel }) => {
|
|
1840
|
+
* return sendTransaction(transaction);
|
|
1841
|
+
* });
|
|
1842
|
+
*
|
|
1843
|
+
* const result = await setSpokeUserPositionManager({
|
|
1844
|
+
* spoke: spokeId('SGVsbG8h'),
|
|
1845
|
+
* manager: evmAddress('0x9abc…'), // Address that will become the position manager
|
|
1846
|
+
* approve: true, // true to approve, false to remove the manager
|
|
1847
|
+
* user: evmAddress('0xdef0…'), // User granting the permission (must sign the signature)
|
|
1848
|
+
* signature: {
|
|
1849
|
+
* value: '0x1234...', // ERC712 signature signed by the user
|
|
1850
|
+
* deadline: 1735689600, // Unix timestamp when signature expires
|
|
1851
|
+
* },
|
|
1852
|
+
* });
|
|
1853
|
+
*
|
|
1854
|
+
* if (result.isErr()) {
|
|
1855
|
+
* switch (result.error.name) {
|
|
1856
|
+
* case 'CancelError':
|
|
1857
|
+
* // The user cancelled the operation
|
|
1858
|
+
* return;
|
|
1859
|
+
*
|
|
1860
|
+
* case 'SigningError':
|
|
1861
|
+
* console.error(`Failed to sign the transaction: ${result.error.message}`);
|
|
1862
|
+
* break;
|
|
1863
|
+
*
|
|
1864
|
+
* case 'TimeoutError':
|
|
1865
|
+
* console.error(`Transaction timed out: ${result.error.message}`);
|
|
1866
|
+
* break;
|
|
1867
|
+
*
|
|
1868
|
+
* case 'TransactionError':
|
|
1869
|
+
* console.error(`Transaction failed: ${result.error.message}`);
|
|
1870
|
+
* break;
|
|
1871
|
+
*
|
|
1872
|
+
* case 'UnexpectedError':
|
|
1873
|
+
* console.error(result.error.message);
|
|
1874
|
+
* break;
|
|
1875
|
+
* }
|
|
1876
|
+
* return;
|
|
1877
|
+
* }
|
|
1878
|
+
*
|
|
1879
|
+
* console.log('Transaction sent with hash:', result.value);
|
|
1880
|
+
* ```
|
|
1881
|
+
*
|
|
1882
|
+
* @param handler - The handler that will be used to handle the transaction.
|
|
1883
|
+
*/
|
|
1884
|
+
declare function useSetSpokeUserPositionManager(handler: TransactionHandler): UseAsyncTask<SetSpokeUserPositionManagerRequest, TxHash, SendTransactionError | PendingTransactionError>;
|
|
1885
|
+
/**
|
|
1886
|
+
* Preview the impact of a potential action on a user's position.
|
|
833
1887
|
*
|
|
834
|
-
*
|
|
835
|
-
* const
|
|
1888
|
+
* ```tsx
|
|
1889
|
+
* const [getPreview, previewing] = usePreviewAction();
|
|
1890
|
+
*
|
|
1891
|
+
* const loading = previewing.loading;
|
|
1892
|
+
* const error = previewing.error;
|
|
836
1893
|
*
|
|
837
1894
|
* // …
|
|
838
1895
|
*
|
|
839
|
-
* const result = await
|
|
840
|
-
*
|
|
1896
|
+
* const result = await getPreview({
|
|
1897
|
+
* action: {
|
|
1898
|
+
* supply: {
|
|
1899
|
+
* reserve: reserveId('SGVsbG8h'),
|
|
1900
|
+
* amount: {
|
|
1901
|
+
* erc20: {
|
|
1902
|
+
* value: '1000',
|
|
1903
|
+
* },
|
|
1904
|
+
* },
|
|
1905
|
+
* sender: evmAddress('0x9abc…'),
|
|
1906
|
+
* },
|
|
1907
|
+
* },
|
|
1908
|
+
* });
|
|
841
1909
|
*
|
|
842
1910
|
* if (result.isErr()) {
|
|
843
1911
|
* console.error(result.error);
|
|
844
1912
|
* return;
|
|
845
1913
|
* }
|
|
846
1914
|
*
|
|
847
|
-
* console.log('
|
|
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.
|
|
1946
|
+
*
|
|
1947
|
+
* Pausable suspense mode.
|
|
1948
|
+
*
|
|
1949
|
+
* ```tsx
|
|
1950
|
+
* const { data } = usePreview({
|
|
1951
|
+
* action: {
|
|
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.
|
|
1971
|
+
*
|
|
1972
|
+
* ```tsx
|
|
1973
|
+
* const { data, error, loading } = usePreview({
|
|
1974
|
+
* action: {
|
|
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.
|
|
1992
|
+
*
|
|
1993
|
+
* Pausable loading state mode.
|
|
1994
|
+
*
|
|
1995
|
+
* ```tsx
|
|
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
|
+
* });
|
|
2011
|
+
* ```
|
|
2012
|
+
*/
|
|
2013
|
+
declare function usePreview(args: Pausable<UsePreviewArgs>): PausableReadResult<PreviewUserPosition>;
|
|
2014
|
+
type UseActivitiesArgs = Prettify<ActivitiesRequest & CurrencyQueryOptions>;
|
|
2015
|
+
/**
|
|
2016
|
+
* Fetch paginated list of activities.
|
|
2017
|
+
*
|
|
2018
|
+
* This signature supports React Suspense:
|
|
2019
|
+
*
|
|
2020
|
+
* ```tsx
|
|
2021
|
+
* const { data } = useActivities({
|
|
2022
|
+
* query: {
|
|
2023
|
+
* chainId: chainId(1),
|
|
2024
|
+
* },
|
|
2025
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2026
|
+
* suspense: true,
|
|
2027
|
+
* });
|
|
2028
|
+
*
|
|
2029
|
+
* // data.items: ActivityItem[]
|
|
2030
|
+
* ```
|
|
2031
|
+
*/
|
|
2032
|
+
declare function useActivities(args: UseActivitiesArgs & Suspendable): SuspenseResult<PaginatedActivitiesResult>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Fetch paginated list of activities.
|
|
2035
|
+
*
|
|
2036
|
+
* Pausable suspense mode.
|
|
2037
|
+
*
|
|
2038
|
+
* ```tsx
|
|
2039
|
+
* const { data } = useActivities({
|
|
2040
|
+
* query: {
|
|
2041
|
+
* chainId: chainId(1),
|
|
2042
|
+
* },
|
|
2043
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2044
|
+
* suspense: true,
|
|
2045
|
+
* pause: true,
|
|
2046
|
+
* });
|
|
2047
|
+
*
|
|
2048
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2049
|
+
* ```
|
|
2050
|
+
*/
|
|
2051
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs> & Suspendable): PausableSuspenseResult<PaginatedActivitiesResult>;
|
|
2052
|
+
/**
|
|
2053
|
+
* Fetch paginated list of activities.
|
|
2054
|
+
*
|
|
2055
|
+
* ```tsx
|
|
2056
|
+
* const { data, error, loading } = useActivities({
|
|
2057
|
+
* query: {
|
|
2058
|
+
* chainId: chainId(1),
|
|
2059
|
+
* },
|
|
2060
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2061
|
+
* });
|
|
848
2062
|
* ```
|
|
849
2063
|
*/
|
|
850
|
-
declare function
|
|
2064
|
+
declare function useActivities(args: UseActivitiesArgs): ReadResult<PaginatedActivitiesResult>;
|
|
851
2065
|
/**
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
* ```ts
|
|
855
|
-
* const [deploy, deploying] = useVaultDeploy();
|
|
856
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
2066
|
+
* Fetch paginated list of activities.
|
|
857
2067
|
*
|
|
858
|
-
*
|
|
859
|
-
* const error = deploying.error || sending.error;
|
|
2068
|
+
* Pausable loading state mode.
|
|
860
2069
|
*
|
|
861
|
-
*
|
|
2070
|
+
* ```tsx
|
|
2071
|
+
* const { data, error, loading } = useActivities({
|
|
2072
|
+
* query: {
|
|
2073
|
+
* chainId: chainId(1),
|
|
2074
|
+
* },
|
|
2075
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2076
|
+
* pause: true,
|
|
2077
|
+
* });
|
|
862
2078
|
*
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
*
|
|
866
|
-
*
|
|
867
|
-
|
|
2079
|
+
* // data?.items: ActivityItem[] | undefined
|
|
2080
|
+
* // error: UnexpectedError | undefined
|
|
2081
|
+
* // loading: boolean | undefined
|
|
2082
|
+
* ```
|
|
2083
|
+
*/
|
|
2084
|
+
declare function useActivities(args: Pausable<UseActivitiesArgs>): PausableReadResult<PaginatedActivitiesResult>;
|
|
2085
|
+
/**
|
|
2086
|
+
* Low-level hook to execute a {@link activities} action directly.
|
|
868
2087
|
*
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
2088
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2089
|
+
* @remarks
|
|
2090
|
+
* This hook does not actively watch for updates. Use it to fetch activities on demand
|
|
2091
|
+
* (e.g., in an event handler when paginating or refining filters).
|
|
872
2092
|
*
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
2093
|
+
* @param options - The query options.
|
|
2094
|
+
* @returns The user history.
|
|
2095
|
+
*/
|
|
2096
|
+
declare function useActivitiesAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<ActivitiesRequest, PaginatedActivitiesResult, UnexpectedError>;
|
|
2097
|
+
|
|
2098
|
+
type UseUserSuppliesArgs = Prettify<UserSuppliesRequest & CurrencyQueryOptions>;
|
|
2099
|
+
/**
|
|
2100
|
+
* Fetch all user supply positions.
|
|
879
2101
|
*
|
|
880
|
-
*
|
|
881
|
-
* console.error(result.error);
|
|
882
|
-
* return;
|
|
883
|
-
* }
|
|
2102
|
+
* This signature supports React Suspense:
|
|
884
2103
|
*
|
|
885
|
-
*
|
|
2104
|
+
* ```tsx
|
|
2105
|
+
* const { data } = useUserSupplies({
|
|
2106
|
+
* query: {
|
|
2107
|
+
* userSpoke: {
|
|
2108
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2109
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2110
|
+
* },
|
|
2111
|
+
* },
|
|
2112
|
+
* orderBy: { name: 'ASC' },
|
|
2113
|
+
* suspense: true,
|
|
2114
|
+
* });
|
|
886
2115
|
* ```
|
|
887
2116
|
*/
|
|
888
|
-
declare function
|
|
2117
|
+
declare function useUserSupplies(args: UseUserSuppliesArgs & Suspendable): SuspenseResult<UserSupplyItem[]>;
|
|
889
2118
|
/**
|
|
890
|
-
*
|
|
2119
|
+
* Fetch all user supply positions.
|
|
891
2120
|
*
|
|
892
|
-
*
|
|
893
|
-
* const [setFee, setting] = useVaultSetFee();
|
|
894
|
-
* const [sendTransaction, sending] = useSendTransaction(wallet);
|
|
2121
|
+
* Pausable suspense mode.
|
|
895
2122
|
*
|
|
896
|
-
*
|
|
897
|
-
* const
|
|
2123
|
+
* ```tsx
|
|
2124
|
+
* const { data } = useUserSupplies({
|
|
2125
|
+
* query: {
|
|
2126
|
+
* userSpoke: {
|
|
2127
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2128
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2129
|
+
* },
|
|
2130
|
+
* },
|
|
2131
|
+
* orderBy: { name: 'ASC' },
|
|
2132
|
+
* suspense: true,
|
|
2133
|
+
* pause: true,
|
|
2134
|
+
* });
|
|
898
2135
|
*
|
|
899
|
-
* //
|
|
2136
|
+
* // data?.length: number | undefined
|
|
2137
|
+
* ```
|
|
2138
|
+
*/
|
|
2139
|
+
declare function useUserSupplies(args: Pausable<UseUserSuppliesArgs> & Suspendable): PausableSuspenseResult<UserSupplyItem[]>;
|
|
2140
|
+
/**
|
|
2141
|
+
* Fetch all user supply positions.
|
|
2142
|
+
*
|
|
2143
|
+
* ```tsx
|
|
2144
|
+
* const { data, error, loading } = useUserSupplies({
|
|
2145
|
+
* query: {
|
|
2146
|
+
* userSpoke: {
|
|
2147
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2148
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2149
|
+
* },
|
|
2150
|
+
* },
|
|
2151
|
+
* orderBy: { name: 'ASC' },
|
|
2152
|
+
* });
|
|
2153
|
+
* ```
|
|
2154
|
+
*/
|
|
2155
|
+
declare function useUserSupplies(args: UseUserSuppliesArgs): ReadResult<UserSupplyItem[]>;
|
|
2156
|
+
/**
|
|
2157
|
+
* Fetch all user supply positions.
|
|
900
2158
|
*
|
|
901
|
-
*
|
|
902
|
-
* .andThen(sendTransaction);
|
|
2159
|
+
* Pausable loading state mode.
|
|
903
2160
|
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
2161
|
+
* ```tsx
|
|
2162
|
+
* const { data, error, loading, paused } = useUserSupplies({
|
|
2163
|
+
* query: {
|
|
2164
|
+
* userSpoke: {
|
|
2165
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2166
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2167
|
+
* },
|
|
2168
|
+
* },
|
|
2169
|
+
* orderBy: { name: 'ASC' },
|
|
2170
|
+
* pause: true,
|
|
2171
|
+
* });
|
|
908
2172
|
*
|
|
909
|
-
*
|
|
2173
|
+
* // data?.length: number | undefined
|
|
2174
|
+
* // error: UnexpectedError | undefined
|
|
2175
|
+
* // loading: boolean | undefined
|
|
2176
|
+
* // paused: boolean
|
|
910
2177
|
* ```
|
|
911
2178
|
*/
|
|
912
|
-
declare function
|
|
2179
|
+
declare function useUserSupplies(args: Pausable<UseUserSuppliesArgs>): PausableReadResult<UserSupplyItem[]>;
|
|
913
2180
|
/**
|
|
914
|
-
*
|
|
2181
|
+
* Low-level hook to execute a {@link userSupplies} action directly.
|
|
915
2182
|
*
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
2183
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2184
|
+
* @remarks
|
|
2185
|
+
* This hook **does not** actively watch for updated data on user supplies.
|
|
2186
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
2187
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
919
2188
|
*
|
|
920
|
-
*
|
|
921
|
-
* const
|
|
2189
|
+
* ```ts
|
|
2190
|
+
* const [execute, { called, data, error, loading }] = useUserSuppliesAction();
|
|
922
2191
|
*
|
|
923
2192
|
* // …
|
|
924
2193
|
*
|
|
925
|
-
* const result = await
|
|
926
|
-
*
|
|
2194
|
+
* const result = await execute({
|
|
2195
|
+
* query: {
|
|
2196
|
+
* userSpoke: {
|
|
2197
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2198
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2199
|
+
* },
|
|
2200
|
+
* },
|
|
2201
|
+
* orderBy: { name: 'ASC' },
|
|
2202
|
+
* });
|
|
927
2203
|
*
|
|
928
|
-
* if (result.
|
|
2204
|
+
* if (result.isOk()) {
|
|
2205
|
+
* console.log(result.value); // UserSupplyItem[]
|
|
2206
|
+
* } else {
|
|
929
2207
|
* console.error(result.error);
|
|
930
|
-
* return;
|
|
931
2208
|
* }
|
|
932
|
-
*
|
|
933
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
934
2209
|
* ```
|
|
935
2210
|
*/
|
|
936
|
-
declare function
|
|
2211
|
+
declare function useUserSuppliesAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<UserSuppliesRequest, UserSupplyItem[], UnexpectedError>;
|
|
2212
|
+
type UseUserBorrowsArgs = Prettify<UserBorrowsRequest & CurrencyQueryOptions>;
|
|
937
2213
|
/**
|
|
938
|
-
*
|
|
2214
|
+
* Fetch all user borrow positions.
|
|
939
2215
|
*
|
|
940
|
-
*
|
|
941
|
-
*
|
|
942
|
-
*
|
|
2216
|
+
* This signature supports React Suspense:
|
|
2217
|
+
*
|
|
2218
|
+
* ```tsx
|
|
2219
|
+
* const { data } = useUserBorrows({
|
|
2220
|
+
* query: {
|
|
2221
|
+
* userSpoke: {
|
|
2222
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2223
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2224
|
+
* },
|
|
2225
|
+
* },
|
|
2226
|
+
* orderBy: { name: 'ASC' },
|
|
2227
|
+
* suspense: true,
|
|
2228
|
+
* });
|
|
2229
|
+
* ```
|
|
2230
|
+
*/
|
|
2231
|
+
declare function useUserBorrows(args: UseUserBorrowsArgs & Suspendable): SuspenseResult<UserBorrowItem[]>;
|
|
2232
|
+
/**
|
|
2233
|
+
* Fetch all user borrow positions.
|
|
943
2234
|
*
|
|
944
|
-
*
|
|
945
|
-
* const error = transferring.error || sending.error;
|
|
2235
|
+
* Pausable suspense mode.
|
|
946
2236
|
*
|
|
947
|
-
*
|
|
2237
|
+
* ```tsx
|
|
2238
|
+
* const { data } = useUserBorrows({
|
|
2239
|
+
* query: {
|
|
2240
|
+
* userSpoke: {
|
|
2241
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2242
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2243
|
+
* },
|
|
2244
|
+
* },
|
|
2245
|
+
* orderBy: { name: 'ASC' },
|
|
2246
|
+
* suspense: true,
|
|
2247
|
+
* pause: true,
|
|
2248
|
+
* });
|
|
2249
|
+
* ```
|
|
2250
|
+
*/
|
|
2251
|
+
declare function useUserBorrows(args: Pausable<UseUserBorrowsArgs> & Suspendable): PausableSuspenseResult<UserBorrowItem[]>;
|
|
2252
|
+
/**
|
|
2253
|
+
* Fetch all user borrow positions.
|
|
948
2254
|
*
|
|
949
|
-
*
|
|
950
|
-
*
|
|
2255
|
+
* ```tsx
|
|
2256
|
+
* const { data, error, loading } = useUserBorrows({
|
|
2257
|
+
* query: {
|
|
2258
|
+
* userSpoke: {
|
|
2259
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2260
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2261
|
+
* },
|
|
2262
|
+
* },
|
|
2263
|
+
* orderBy: { name: 'ASC' },
|
|
2264
|
+
* });
|
|
2265
|
+
* ```
|
|
2266
|
+
*/
|
|
2267
|
+
declare function useUserBorrows(args: UseUserBorrowsArgs): ReadResult<UserBorrowItem[]>;
|
|
2268
|
+
/**
|
|
2269
|
+
* Fetch all user borrow positions.
|
|
951
2270
|
*
|
|
952
|
-
*
|
|
953
|
-
* console.error(result.error);
|
|
954
|
-
* return;
|
|
955
|
-
* }
|
|
2271
|
+
* Pausable loading state mode.
|
|
956
2272
|
*
|
|
957
|
-
*
|
|
2273
|
+
* ```tsx
|
|
2274
|
+
* const { data, error, loading, paused } = useUserBorrows({
|
|
2275
|
+
* query: {
|
|
2276
|
+
* userSpoke: {
|
|
2277
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2278
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2279
|
+
* },
|
|
2280
|
+
* },
|
|
2281
|
+
* orderBy: { name: 'ASC' },
|
|
2282
|
+
* pause: true,
|
|
2283
|
+
* });
|
|
958
2284
|
* ```
|
|
959
2285
|
*/
|
|
960
|
-
declare function
|
|
2286
|
+
declare function useUserBorrows(args: Pausable<UseUserBorrowsArgs>): PausableReadResult<UserBorrowItem[]>;
|
|
961
2287
|
/**
|
|
962
|
-
*
|
|
2288
|
+
* Low-level hook to execute a {@link userBorrows} action directly.
|
|
963
2289
|
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
966
|
-
*
|
|
2290
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2291
|
+
* @remarks
|
|
2292
|
+
* This hook **does not** actively watch for updated data on user borrows.
|
|
2293
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
2294
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
967
2295
|
*
|
|
968
|
-
*
|
|
969
|
-
* const
|
|
2296
|
+
* ```ts
|
|
2297
|
+
* const [execute, { called, data, error, loading }] = useUserBorrowsAction();
|
|
970
2298
|
*
|
|
971
2299
|
* // …
|
|
972
2300
|
*
|
|
973
|
-
* const result = await
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
*
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
* }
|
|
2301
|
+
* const result = await execute({
|
|
2302
|
+
* query: {
|
|
2303
|
+
* userSpoke: {
|
|
2304
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2305
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2306
|
+
* },
|
|
2307
|
+
* },
|
|
2308
|
+
* orderBy: { name: 'ASC' },
|
|
2309
|
+
* });
|
|
981
2310
|
*
|
|
982
|
-
* if (result.
|
|
2311
|
+
* if (result.isOk()) {
|
|
2312
|
+
* console.log(result.value); // UserBorrowItem[]
|
|
2313
|
+
* } else {
|
|
983
2314
|
* console.error(result.error);
|
|
984
|
-
* return;
|
|
985
2315
|
* }
|
|
986
|
-
*
|
|
987
|
-
* console.log('Transaction sent with hash:', result.value);
|
|
988
2316
|
* ```
|
|
989
2317
|
*/
|
|
990
|
-
declare function
|
|
991
|
-
|
|
992
|
-
type UseUserSuppliesArgs = UserSuppliesRequest;
|
|
2318
|
+
declare function useUserBorrowsAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<UserBorrowsRequest, UserBorrowItem[], UnexpectedError>;
|
|
2319
|
+
type UseUserSummaryArgs = Prettify<UserSummaryRequest & TimeWindowQueryOptions & CurrencyQueryOptions>;
|
|
993
2320
|
/**
|
|
994
|
-
* Fetch
|
|
2321
|
+
* Fetch a user's financial summary.
|
|
995
2322
|
*
|
|
996
2323
|
* This signature supports React Suspense:
|
|
997
2324
|
*
|
|
998
2325
|
* ```tsx
|
|
999
|
-
* const { data } =
|
|
1000
|
-
* markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
|
|
2326
|
+
* const { data } = useUserSummary({
|
|
1001
2327
|
* user: evmAddress('0x742d35cc…'),
|
|
1002
|
-
*
|
|
2328
|
+
* filter: {
|
|
2329
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2330
|
+
* },
|
|
1003
2331
|
* suspense: true,
|
|
1004
2332
|
* });
|
|
1005
2333
|
* ```
|
|
1006
2334
|
*/
|
|
1007
|
-
declare function
|
|
2335
|
+
declare function useUserSummary(args: UseUserSummaryArgs & Suspendable): SuspenseResult<UserSummary>;
|
|
1008
2336
|
/**
|
|
1009
|
-
* Fetch
|
|
2337
|
+
* Fetch a user's financial summary.
|
|
2338
|
+
*
|
|
2339
|
+
* Pausable suspense mode.
|
|
1010
2340
|
*
|
|
1011
2341
|
* ```tsx
|
|
1012
|
-
* const { data
|
|
1013
|
-
* markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
|
|
2342
|
+
* const { data } = useUserSummary({
|
|
1014
2343
|
* user: evmAddress('0x742d35cc…'),
|
|
1015
|
-
*
|
|
2344
|
+
* filter: {
|
|
2345
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2346
|
+
* },
|
|
2347
|
+
* suspense: true,
|
|
2348
|
+
* pause: true,
|
|
1016
2349
|
* });
|
|
1017
2350
|
* ```
|
|
1018
2351
|
*/
|
|
1019
|
-
declare function
|
|
1020
|
-
type UseUserBorrowsArgs = UserBorrowsRequest;
|
|
2352
|
+
declare function useUserSummary(args: Pausable<UseUserSummaryArgs> & Suspendable): PausableSuspenseResult<UserSummary>;
|
|
1021
2353
|
/**
|
|
1022
|
-
* Fetch
|
|
1023
|
-
*
|
|
1024
|
-
* This signature supports React Suspense:
|
|
2354
|
+
* Fetch a user's financial summary.
|
|
1025
2355
|
*
|
|
1026
2356
|
* ```tsx
|
|
1027
|
-
* const { data } =
|
|
1028
|
-
* markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
|
|
2357
|
+
* const { data, error, loading } = useUserSummary({
|
|
1029
2358
|
* user: evmAddress('0x742d35cc…'),
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
2359
|
+
* filter: {
|
|
2360
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2361
|
+
* },
|
|
1032
2362
|
* });
|
|
1033
2363
|
* ```
|
|
1034
2364
|
*/
|
|
1035
|
-
declare function
|
|
2365
|
+
declare function useUserSummary(args: UseUserSummaryArgs): ReadResult<UserSummary>;
|
|
1036
2366
|
/**
|
|
1037
|
-
* Fetch
|
|
2367
|
+
* Fetch a user's financial summary.
|
|
2368
|
+
*
|
|
2369
|
+
* Pausable loading state mode.
|
|
1038
2370
|
*
|
|
1039
2371
|
* ```tsx
|
|
1040
|
-
* const { data, error, loading } =
|
|
1041
|
-
* markets: [{ address: evmAddress('0x87870bca…'), chainId: chainId(1) }],
|
|
2372
|
+
* const { data, error, loading, paused } = useUserSummary({
|
|
1042
2373
|
* user: evmAddress('0x742d35cc…'),
|
|
1043
|
-
*
|
|
2374
|
+
* filter: {
|
|
2375
|
+
* spoke: { address: evmAddress('0x87870bca…'), chainId: chainId(1) },
|
|
2376
|
+
* },
|
|
2377
|
+
* pause: true,
|
|
1044
2378
|
* });
|
|
1045
2379
|
* ```
|
|
1046
2380
|
*/
|
|
1047
|
-
declare function
|
|
1048
|
-
type
|
|
2381
|
+
declare function useUserSummary(args: Pausable<UseUserSummaryArgs>): PausableReadResult<UserSummary>;
|
|
2382
|
+
type UseUserPositionsArgs = Prettify<UserPositionsRequest & UserPositionQueryOptions>;
|
|
1049
2383
|
/**
|
|
1050
|
-
* Fetch user
|
|
2384
|
+
* Fetch all user positions across specified chains.
|
|
1051
2385
|
*
|
|
1052
2386
|
* This signature supports React Suspense:
|
|
1053
2387
|
*
|
|
1054
2388
|
* ```tsx
|
|
1055
|
-
* const { data } =
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
2389
|
+
* const { data } = useUserPositions({
|
|
2390
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2391
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2392
|
+
* orderBy: { balance: 'DESC' },
|
|
1059
2393
|
* suspense: true,
|
|
1060
2394
|
* });
|
|
1061
2395
|
* ```
|
|
1062
2396
|
*/
|
|
1063
|
-
declare function
|
|
2397
|
+
declare function useUserPositions(args: UseUserPositionsArgs & Suspendable): SuspenseResult<UserPosition[]>;
|
|
1064
2398
|
/**
|
|
1065
|
-
* Fetch user
|
|
2399
|
+
* Fetch all user positions across specified chains.
|
|
2400
|
+
*
|
|
2401
|
+
* Pausable suspense mode.
|
|
1066
2402
|
*
|
|
1067
2403
|
* ```tsx
|
|
1068
|
-
* const { data
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
2404
|
+
* const { data } = useUserPositions({
|
|
2405
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2406
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2407
|
+
* orderBy: { balance: 'DESC' },
|
|
2408
|
+
* suspense: true,
|
|
2409
|
+
* pause: true,
|
|
1072
2410
|
* });
|
|
1073
2411
|
* ```
|
|
1074
2412
|
*/
|
|
1075
|
-
declare function
|
|
1076
|
-
type UseUserTransactionHistoryArgs = UserTransactionHistoryRequest;
|
|
2413
|
+
declare function useUserPositions(args: Pausable<UseUserPositionsArgs> & Suspendable): PausableSuspenseResult<UserPosition[]>;
|
|
1077
2414
|
/**
|
|
1078
|
-
* Fetch user
|
|
1079
|
-
*
|
|
1080
|
-
* This signature supports React Suspense:
|
|
2415
|
+
* Fetch all user positions across specified chains.
|
|
1081
2416
|
*
|
|
1082
2417
|
* ```tsx
|
|
1083
|
-
* const { data } =
|
|
1084
|
-
*
|
|
2418
|
+
* const { data, error, loading } = useUserPositions({
|
|
2419
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2420
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2421
|
+
* orderBy: { balance: 'DESC' },
|
|
1085
2422
|
* });
|
|
1086
2423
|
* ```
|
|
1087
2424
|
*/
|
|
1088
|
-
declare function
|
|
2425
|
+
declare function useUserPositions(args: UseUserPositionsArgs): ReadResult<UserPosition[]>;
|
|
1089
2426
|
/**
|
|
1090
|
-
* Fetch user
|
|
2427
|
+
* Fetch all user positions across specified chains.
|
|
2428
|
+
*
|
|
2429
|
+
* Pausable loading state mode.
|
|
1091
2430
|
*
|
|
1092
2431
|
* ```tsx
|
|
1093
|
-
* const { data, error, loading } =
|
|
2432
|
+
* const { data, error, loading, paused } = useUserPositions({
|
|
2433
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2434
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2435
|
+
* orderBy: { balance: 'DESC' },
|
|
2436
|
+
* pause: true,
|
|
2437
|
+
* });
|
|
1094
2438
|
* ```
|
|
1095
2439
|
*/
|
|
1096
|
-
declare function
|
|
1097
|
-
|
|
1098
|
-
type UseVaultArgs = VaultRequest;
|
|
2440
|
+
declare function useUserPositions(args: Pausable<UseUserPositionsArgs>): PausableReadResult<UserPosition[]>;
|
|
1099
2441
|
/**
|
|
1100
|
-
*
|
|
2442
|
+
* Low-level hook to execute a {@link userPositions} action directly.
|
|
1101
2443
|
*
|
|
1102
|
-
* This
|
|
2444
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2445
|
+
* @remarks
|
|
2446
|
+
* This hook **does not** actively watch for updated data on user positions.
|
|
2447
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
2448
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
1103
2449
|
*
|
|
1104
|
-
* ```
|
|
1105
|
-
* const { data } =
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
2450
|
+
* ```ts
|
|
2451
|
+
* const [execute, { called, data, error, loading }] = useUserPositionsAction();
|
|
2452
|
+
*
|
|
2453
|
+
* // …
|
|
2454
|
+
*
|
|
2455
|
+
* const result = await execute({
|
|
2456
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2457
|
+
* filter: {
|
|
2458
|
+
* chainIds: [chainId(1), chainId(137)]
|
|
1108
2459
|
* },
|
|
1109
|
-
*
|
|
1110
|
-
* user: evmAddress('0x5678…'),
|
|
1111
|
-
* suspense: true,
|
|
2460
|
+
* orderBy: { balance: 'DESC' },
|
|
1112
2461
|
* });
|
|
2462
|
+
*
|
|
2463
|
+
* if (result.isOk()) {
|
|
2464
|
+
* console.log(result.value); // UserPosition[]
|
|
2465
|
+
* } else {
|
|
2466
|
+
* console.error(result.error);
|
|
2467
|
+
* }
|
|
1113
2468
|
* ```
|
|
1114
2469
|
*/
|
|
1115
|
-
declare function
|
|
2470
|
+
declare function useUserPositionsAction(options?: UserPositionQueryOptions): UseAsyncTask<UserPositionsRequest, UserPosition[], UnexpectedError>;
|
|
2471
|
+
type UseUserPositionArgs = Prettify<UserPositionRequest & UserPositionQueryOptions>;
|
|
1116
2472
|
/**
|
|
1117
|
-
* Fetch a
|
|
2473
|
+
* Fetch a specific user position by ID.
|
|
2474
|
+
*
|
|
2475
|
+
* This signature supports React Suspense:
|
|
1118
2476
|
*
|
|
1119
2477
|
* ```tsx
|
|
1120
|
-
* const { data
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
2478
|
+
* const { data } = useUserPosition({
|
|
2479
|
+
* id: userPositionId('SGVsbG8h'),
|
|
2480
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2481
|
+
* suspense: true,
|
|
1124
2482
|
* });
|
|
1125
2483
|
* ```
|
|
1126
2484
|
*/
|
|
1127
|
-
declare function
|
|
1128
|
-
type UseVaultsArgs = VaultsRequest;
|
|
2485
|
+
declare function useUserPosition(args: UseUserPositionArgs & Suspendable): SuspenseResult<UserPosition>;
|
|
1129
2486
|
/**
|
|
1130
|
-
* Fetch
|
|
2487
|
+
* Fetch a specific user position by ID.
|
|
1131
2488
|
*
|
|
1132
|
-
*
|
|
2489
|
+
* Pausable suspense mode.
|
|
1133
2490
|
*
|
|
1134
2491
|
* ```tsx
|
|
1135
|
-
* const { data } =
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
* },
|
|
1139
|
-
* pageSize: PageSize.Ten,
|
|
1140
|
-
* user: evmAddress('0x5678…'),
|
|
2492
|
+
* const { data } = useUserPosition({
|
|
2493
|
+
* id: userPositionId('SGVsbG8h'),
|
|
2494
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1141
2495
|
* suspense: true,
|
|
2496
|
+
* pause: true,
|
|
1142
2497
|
* });
|
|
1143
2498
|
* ```
|
|
1144
2499
|
*/
|
|
1145
|
-
declare function
|
|
2500
|
+
declare function useUserPosition(args: Pausable<UseUserPositionArgs> & Suspendable): PausableSuspenseResult<UserPosition>;
|
|
1146
2501
|
/**
|
|
1147
|
-
* Fetch
|
|
2502
|
+
* Fetch a specific user position by ID.
|
|
1148
2503
|
*
|
|
1149
2504
|
* ```tsx
|
|
1150
|
-
* const { data, error, loading } =
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
* },
|
|
1154
|
-
* pageSize: PageSize.Ten,
|
|
1155
|
-
* user: evmAddress('0x5678…'),
|
|
2505
|
+
* const { data, error, loading } = useUserPosition({
|
|
2506
|
+
* id: userPositionId('SGVsbG8h'),
|
|
2507
|
+
* user: evmAddress('0x742d35cc…'),
|
|
1156
2508
|
* });
|
|
1157
2509
|
* ```
|
|
1158
2510
|
*/
|
|
1159
|
-
declare function
|
|
1160
|
-
type UseUserVaultsArgs = UserVaultsRequest;
|
|
2511
|
+
declare function useUserPosition(args: UseUserPositionArgs): ReadResult<UserPosition>;
|
|
1161
2512
|
/**
|
|
1162
|
-
* Fetch
|
|
2513
|
+
* Fetch a specific user position by ID.
|
|
1163
2514
|
*
|
|
1164
|
-
*
|
|
2515
|
+
* Pausable loading state mode.
|
|
1165
2516
|
*
|
|
1166
2517
|
* ```tsx
|
|
1167
|
-
* const { data } =
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
* },
|
|
1172
|
-
* orderBy: { shares: OrderDirection.Desc },
|
|
1173
|
-
* pageSize: PageSize.Fifty,
|
|
1174
|
-
* suspense: true,
|
|
2518
|
+
* const { data, error, loading, paused } = useUserPosition({
|
|
2519
|
+
* id: userPositionId('SGVsbG8h'),
|
|
2520
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2521
|
+
* pause: true,
|
|
1175
2522
|
* });
|
|
1176
2523
|
* ```
|
|
1177
2524
|
*/
|
|
1178
|
-
declare function
|
|
2525
|
+
declare function useUserPosition(args: Pausable<UseUserPositionArgs>): PausableReadResult<UserPosition>;
|
|
2526
|
+
type UseUserBalancesArgs = Prettify<UserBalancesRequest & CurrencyQueryOptions>;
|
|
1179
2527
|
/**
|
|
1180
|
-
* Fetch
|
|
2528
|
+
* Fetch all user balances across specified chains.
|
|
2529
|
+
*
|
|
2530
|
+
* This signature supports React Suspense:
|
|
1181
2531
|
*
|
|
1182
2532
|
* ```tsx
|
|
1183
|
-
* const { data
|
|
1184
|
-
* user: evmAddress('
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
* },
|
|
1188
|
-
* orderBy: { shares: OrderDirection.Desc },
|
|
1189
|
-
* pageSize: PageSize.Fifty,
|
|
2533
|
+
* const { data } = useUserBalances({
|
|
2534
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2535
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2536
|
+
* suspense: true,
|
|
1190
2537
|
* });
|
|
1191
2538
|
* ```
|
|
1192
2539
|
*/
|
|
1193
|
-
declare function
|
|
2540
|
+
declare function useUserBalances(args: UseUserBalancesArgs & Suspendable): SuspenseResult<UserBalance[]>;
|
|
1194
2541
|
/**
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
* ```ts
|
|
1198
|
-
* const [preview, { loading, error }] = useVaultDepositPreview();
|
|
2542
|
+
* Fetch all user balances across specified chains.
|
|
1199
2543
|
*
|
|
1200
|
-
*
|
|
2544
|
+
* Pausable suspense mode.
|
|
1201
2545
|
*
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
2546
|
+
* ```tsx
|
|
2547
|
+
* const { data } = useUserBalances({
|
|
2548
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2549
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2550
|
+
* suspense: true,
|
|
2551
|
+
* pause: true,
|
|
1206
2552
|
* });
|
|
1207
|
-
*
|
|
1208
|
-
* if (result.isErr()) {
|
|
1209
|
-
* console.error(result.error);
|
|
1210
|
-
* } else {
|
|
1211
|
-
* console.log(result.value);
|
|
1212
|
-
* }
|
|
1213
2553
|
* ```
|
|
1214
2554
|
*/
|
|
1215
|
-
declare function
|
|
2555
|
+
declare function useUserBalances(args: Pausable<UseUserBalancesArgs> & Suspendable): PausableSuspenseResult<UserBalance[]>;
|
|
1216
2556
|
/**
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
* ```ts
|
|
1220
|
-
* const [preview, { loading, error }] = useVaultMintPreview();
|
|
2557
|
+
* Fetch all user balances across specified chains.
|
|
1221
2558
|
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
* chainId: chainId(1),
|
|
1227
|
-
* amount: bigDecimal('500'),
|
|
2559
|
+
* ```tsx
|
|
2560
|
+
* const { data, error, loading } = useUserBalances({
|
|
2561
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2562
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
1228
2563
|
* });
|
|
1229
|
-
*
|
|
1230
|
-
* if (result.isErr()) {
|
|
1231
|
-
* console.error(result.error);
|
|
1232
|
-
* } else {
|
|
1233
|
-
* console.log(result.value);
|
|
1234
|
-
* }
|
|
1235
2564
|
* ```
|
|
1236
2565
|
*/
|
|
1237
|
-
declare function
|
|
2566
|
+
declare function useUserBalances(args: UseUserBalancesArgs): ReadResult<UserBalance[]>;
|
|
1238
2567
|
/**
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
* ```ts
|
|
1242
|
-
* const [preview, { loading, error }] = useVaultWithdrawPreview();
|
|
2568
|
+
* Fetch all user balances across specified chains.
|
|
1243
2569
|
*
|
|
1244
|
-
*
|
|
2570
|
+
* Pausable loading state mode.
|
|
1245
2571
|
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
2572
|
+
* ```tsx
|
|
2573
|
+
* const { data, error, loading, paused } = useUserBalances({
|
|
2574
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2575
|
+
* chainIds: [chainId(1), chainId(137)],
|
|
2576
|
+
* pause: true,
|
|
1250
2577
|
* });
|
|
1251
|
-
*
|
|
1252
|
-
* if (result.isErr()) {
|
|
1253
|
-
* console.error(result.error);
|
|
1254
|
-
* } else {
|
|
1255
|
-
* console.log(result.value);
|
|
1256
|
-
* }
|
|
1257
2578
|
* ```
|
|
1258
2579
|
*/
|
|
1259
|
-
declare function
|
|
2580
|
+
declare function useUserBalances(args: Pausable<UseUserBalancesArgs>): PausableReadResult<UserBalance[]>;
|
|
1260
2581
|
/**
|
|
1261
|
-
*
|
|
2582
|
+
* Low-level hook to execute a {@link userBalances} action directly.
|
|
1262
2583
|
*
|
|
1263
|
-
* This
|
|
2584
|
+
* @experimental This hook is experimental and may be subject to breaking changes.
|
|
2585
|
+
* @remarks
|
|
2586
|
+
* This hook **does not** actively watch for updated data on user balances.
|
|
2587
|
+
* Use this hook to retrieve data on demand as part of a larger workflow
|
|
2588
|
+
* (e.g., in an event handler in order to move to the next step).
|
|
1264
2589
|
*
|
|
1265
2590
|
* ```ts
|
|
1266
|
-
* const [
|
|
2591
|
+
* const [execute, { called, data, error, loading }] = useUserBalancesAction();
|
|
1267
2592
|
*
|
|
1268
2593
|
* // …
|
|
1269
2594
|
*
|
|
1270
|
-
* const result = await
|
|
1271
|
-
*
|
|
1272
|
-
*
|
|
1273
|
-
*
|
|
2595
|
+
* const result = await execute({
|
|
2596
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2597
|
+
* filter: {
|
|
2598
|
+
* chainIds: [chainId(1), chainId(137)]
|
|
2599
|
+
* },
|
|
1274
2600
|
* });
|
|
1275
2601
|
*
|
|
1276
|
-
* if (result.
|
|
1277
|
-
* console.
|
|
2602
|
+
* if (result.isOk()) {
|
|
2603
|
+
* console.log(result.value); // UserBalance[]
|
|
1278
2604
|
* } else {
|
|
1279
|
-
* console.
|
|
2605
|
+
* console.error(result.error);
|
|
1280
2606
|
* }
|
|
1281
2607
|
* ```
|
|
1282
2608
|
*/
|
|
1283
|
-
declare function
|
|
1284
|
-
type
|
|
2609
|
+
declare function useUserBalancesAction(options?: Required<CurrencyQueryOptions>): UseAsyncTask<UserBalancesRequest, UserBalance[], UnexpectedError>;
|
|
2610
|
+
type UseUserSummaryHistoryArgs = Prettify<UserSummaryHistoryRequest & CurrencyQueryOptions>;
|
|
1285
2611
|
/**
|
|
1286
|
-
* Fetch user
|
|
2612
|
+
* Fetch user summary history over time.
|
|
1287
2613
|
*
|
|
1288
2614
|
* This signature supports React Suspense:
|
|
1289
2615
|
*
|
|
1290
2616
|
* ```tsx
|
|
1291
|
-
* const { data } =
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
2617
|
+
* const { data } = useUserSummaryHistory({
|
|
2618
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2619
|
+
* window: TimeWindow.LastWeek,
|
|
2620
|
+
* filter: { chainIds: [chainId(1)] },
|
|
1295
2621
|
* suspense: true,
|
|
1296
2622
|
* });
|
|
1297
2623
|
* ```
|
|
1298
2624
|
*/
|
|
1299
|
-
declare function
|
|
2625
|
+
declare function useUserSummaryHistory(args: UseUserSummaryHistoryArgs & Suspendable): SuspenseResult<UserSummaryHistoryItem[]>;
|
|
1300
2626
|
/**
|
|
1301
|
-
* Fetch user
|
|
2627
|
+
* Fetch user summary history over time.
|
|
2628
|
+
*
|
|
2629
|
+
* Pausable suspense mode.
|
|
1302
2630
|
*
|
|
1303
2631
|
* ```tsx
|
|
1304
|
-
* const { data
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
2632
|
+
* const { data } = useUserSummaryHistory({
|
|
2633
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2634
|
+
* window: TimeWindow.LastWeek,
|
|
2635
|
+
* filter: { chainIds: [chainId(1)] },
|
|
2636
|
+
* suspense: true,
|
|
2637
|
+
* pause: true,
|
|
1308
2638
|
* });
|
|
1309
2639
|
* ```
|
|
1310
2640
|
*/
|
|
1311
|
-
declare function
|
|
1312
|
-
type UseVaultUserActivityArgs = VaultUserActivityRequest;
|
|
2641
|
+
declare function useUserSummaryHistory(args: Pausable<UseUserSummaryHistoryArgs> & Suspendable): PausableSuspenseResult<UserSummaryHistoryItem[]>;
|
|
1313
2642
|
/**
|
|
1314
|
-
* Fetch user
|
|
1315
|
-
*
|
|
1316
|
-
* This signature supports React Suspense:
|
|
2643
|
+
* Fetch user summary history over time.
|
|
1317
2644
|
*
|
|
1318
2645
|
* ```tsx
|
|
1319
|
-
* const { data } =
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
* suspense: true,
|
|
2646
|
+
* const { data, error, loading } = useUserSummaryHistory({
|
|
2647
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2648
|
+
* window: TimeWindow.LastWeek,
|
|
2649
|
+
* filter: { chainIds: [chainId(1)] },
|
|
1324
2650
|
* });
|
|
1325
2651
|
* ```
|
|
1326
2652
|
*/
|
|
1327
|
-
declare function
|
|
2653
|
+
declare function useUserSummaryHistory(args: UseUserSummaryHistoryArgs): ReadResult<UserSummaryHistoryItem[]>;
|
|
1328
2654
|
/**
|
|
1329
|
-
* Fetch user
|
|
2655
|
+
* Fetch user summary history over time.
|
|
2656
|
+
*
|
|
2657
|
+
* Pausable loading state mode.
|
|
1330
2658
|
*
|
|
1331
2659
|
* ```tsx
|
|
1332
|
-
* const { data, error, loading } =
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
2660
|
+
* const { data, error, loading, paused } = useUserSummaryHistory({
|
|
2661
|
+
* user: evmAddress('0x742d35cc…'),
|
|
2662
|
+
* window: TimeWindow.LastWeek,
|
|
2663
|
+
* filter: { chainIds: [chainId(1)] },
|
|
2664
|
+
* pause: true,
|
|
1336
2665
|
* });
|
|
1337
|
-
*
|
|
1338
|
-
* if (data) {
|
|
1339
|
-
* console.log('Total earned:', data.earned.amount.value);
|
|
1340
|
-
* data.breakdown.forEach(activity => {
|
|
1341
|
-
* console.log('Date:', activity.date);
|
|
1342
|
-
* console.log('Balance:', activity.balance.amount.value);
|
|
1343
|
-
* });
|
|
1344
|
-
* }
|
|
1345
2666
|
* ```
|
|
1346
2667
|
*/
|
|
1347
|
-
declare function
|
|
2668
|
+
declare function useUserSummaryHistory(args: Pausable<UseUserSummaryHistoryArgs>): PausableReadResult<UserSummaryHistoryItem[]>;
|
|
1348
2669
|
|
|
1349
|
-
export { AaveProvider, type AaveProviderProps, type
|
|
2670
|
+
export { AaveProvider, type AaveProviderProps, type CancelSwapError, type CancelSwapHandler, CannotCancelSwapError, SendTransactionError, type SwapHandler, type SwapHandlerOptions, type SwapIntent, type UseActivitiesArgs, type UseAssetArgs, type UseAssetBorrowHistoryArgs, type UseAssetPriceHistoryArgs, type UseAssetSupplyHistoryArgs, UseAsyncTask, type UseBorrowApyHistoryArgs, type UseHubArgs, type UseHubAssetsArgs, type UseHubsArgs, type UsePreviewArgs, type UseReserveArgs, type UseReservesArgs, type UseSpokeArgs, type UseSpokePositionManagersArgs, type UseSpokeUserPositionManagersArgs, type UseSpokesArgs, type UseSupplyApyHistoryArgs, type UseSwapQuoteArgs, type UseSwapTokensRequest, type UseSwappableTokensArgs, type UseUserBalancesArgs, type UseUserBorrowsArgs, type UseUserPositionArgs, type UseUserPositionsArgs, type UseUserSummaryArgs, type UseUserSummaryHistoryArgs, type UseUserSuppliesArgs, type UseUserSwapsArgs, useAaveClient, useActivities, useActivitiesAction, useAsset, useAssetBorrowHistory, useAssetPriceHistory, useAssetSupplyHistory, useBorrow, useBorrowApyHistory, useCancelSwap, useHub, useHubAssets, useHubs, useHubsAction, useLiquidatePosition, usePermitTypedDataAction, usePreview, usePreviewAction, useRenounceSpokeUserPositionManager, useRepay, useReserve, useReserveAction, useReserves, useReservesAction, useSetSpokeUserPositionManager, useSetUserSupplyAsCollateral, useSpoke, useSpokePositionManagers, useSpokeUserPositionManagers, useSpokes, useSupply, useSupplyApyHistory, useSwapQuote, useSwapQuoteAction, useSwapTokens, useSwappableTokens, useUpdateUserDynamicConfig, useUpdateUserRiskPremium, useUserBalances, useUserBalancesAction, useUserBorrows, useUserBorrowsAction, useUserPosition, useUserPositions, useUserPositionsAction, useUserSummary, useUserSummaryHistory, useUserSupplies, useUserSuppliesAction, useUserSwaps, useWithdraw };
|