@elizaos/plugin-aave 1.2.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/.npmignore +11 -0
- package/README.md +443 -0
- package/dist/index.d.ts +335 -0
- package/dist/index.js +2395 -0
- package/dist/index.js.map +1 -0
- package/package.json +100 -0
- package/tsup.config.ts +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { Action, Provider, Plugin } from '@elizaos/core';
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
export { default as BigNumber } from 'bignumber.js';
|
|
4
|
+
export { Address, Hash, Hex } from 'viem';
|
|
5
|
+
|
|
6
|
+
declare const supplyAction: Action;
|
|
7
|
+
|
|
8
|
+
declare const borrowAction: Action;
|
|
9
|
+
|
|
10
|
+
declare const repayAction: Action;
|
|
11
|
+
|
|
12
|
+
declare const withdrawAction: Action;
|
|
13
|
+
|
|
14
|
+
declare const rateSwitchAction: Action;
|
|
15
|
+
|
|
16
|
+
declare const collateralManagementAction: Action;
|
|
17
|
+
|
|
18
|
+
declare const eModeAction: Action;
|
|
19
|
+
|
|
20
|
+
declare const flashLoanAction: Action;
|
|
21
|
+
|
|
22
|
+
declare const positionContextProvider: Provider;
|
|
23
|
+
|
|
24
|
+
declare const healthFactorProvider: Provider;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Aave V3 User Account Data
|
|
28
|
+
*/
|
|
29
|
+
interface UserAccountData {
|
|
30
|
+
totalCollateralETH: BigNumber;
|
|
31
|
+
totalDebtETH: BigNumber;
|
|
32
|
+
availableBorrowsETH: BigNumber;
|
|
33
|
+
currentLiquidationThreshold: BigNumber;
|
|
34
|
+
ltv: BigNumber;
|
|
35
|
+
healthFactor: BigNumber;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Aave Position Data
|
|
39
|
+
*/
|
|
40
|
+
interface AavePosition {
|
|
41
|
+
supplies: AaveAssetPosition[];
|
|
42
|
+
borrows: AaveAssetPosition[];
|
|
43
|
+
healthFactor: number;
|
|
44
|
+
totalCollateralETH: BigNumber;
|
|
45
|
+
totalDebtETH: BigNumber;
|
|
46
|
+
availableBorrowsETH: BigNumber;
|
|
47
|
+
currentLTV: number;
|
|
48
|
+
liquidationThreshold: number;
|
|
49
|
+
eModeCategory: number;
|
|
50
|
+
eModeEnabled: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Individual Asset Position
|
|
54
|
+
*/
|
|
55
|
+
interface AaveAssetPosition {
|
|
56
|
+
asset: string;
|
|
57
|
+
symbol: string;
|
|
58
|
+
balance: BigNumber;
|
|
59
|
+
apy: number;
|
|
60
|
+
isCollateral: boolean;
|
|
61
|
+
interestRateMode?: InterestRateMode;
|
|
62
|
+
stableRate?: number;
|
|
63
|
+
variableRate?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Interest Rate Mode Enum
|
|
67
|
+
*/
|
|
68
|
+
declare enum InterestRateMode {
|
|
69
|
+
NONE = 0,
|
|
70
|
+
STABLE = 1,
|
|
71
|
+
VARIABLE = 2
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Flash Loan Parameters
|
|
75
|
+
*/
|
|
76
|
+
interface FlashLoanParams {
|
|
77
|
+
assets: string[];
|
|
78
|
+
amounts: BigNumber[];
|
|
79
|
+
modes: number[];
|
|
80
|
+
onBehalfOf: string;
|
|
81
|
+
params: string;
|
|
82
|
+
referralCode: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Flash Loan Result
|
|
86
|
+
*/
|
|
87
|
+
interface FlashLoanResult {
|
|
88
|
+
transactionHash: string;
|
|
89
|
+
totalFees: BigNumber;
|
|
90
|
+
executionResult: any;
|
|
91
|
+
gasUsed: BigNumber;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* eMode Category Data
|
|
95
|
+
*/
|
|
96
|
+
interface eModeCategory {
|
|
97
|
+
id: number;
|
|
98
|
+
ltv: number;
|
|
99
|
+
liquidationThreshold: number;
|
|
100
|
+
liquidationBonus: number;
|
|
101
|
+
priceSource: string;
|
|
102
|
+
label: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* eMode Operation Result
|
|
106
|
+
*/
|
|
107
|
+
interface eModeResult {
|
|
108
|
+
transactionHash: string;
|
|
109
|
+
categoryId: number;
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
ltvImprovement: number;
|
|
112
|
+
liquidationThresholdImprovement: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Supply Operation Result
|
|
116
|
+
*/
|
|
117
|
+
interface SupplyResult {
|
|
118
|
+
transactionHash: string;
|
|
119
|
+
asset: string;
|
|
120
|
+
amount: BigNumber;
|
|
121
|
+
aTokenBalance: BigNumber;
|
|
122
|
+
apy: number;
|
|
123
|
+
collateralEnabled: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Borrow Operation Result
|
|
127
|
+
*/
|
|
128
|
+
interface BorrowResult {
|
|
129
|
+
transactionHash: string;
|
|
130
|
+
asset: string;
|
|
131
|
+
amount: BigNumber;
|
|
132
|
+
interestRateMode: InterestRateMode;
|
|
133
|
+
rate: number;
|
|
134
|
+
healthFactor: BigNumber;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Repay Operation Result
|
|
138
|
+
*/
|
|
139
|
+
interface RepayResult {
|
|
140
|
+
transactionHash: string;
|
|
141
|
+
asset: string;
|
|
142
|
+
amount: BigNumber;
|
|
143
|
+
remainingDebt: BigNumber;
|
|
144
|
+
healthFactor: BigNumber;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Withdraw Operation Result
|
|
148
|
+
*/
|
|
149
|
+
interface WithdrawResult {
|
|
150
|
+
transactionHash: string;
|
|
151
|
+
asset: string;
|
|
152
|
+
amount: BigNumber;
|
|
153
|
+
remainingSupply: BigNumber;
|
|
154
|
+
healthFactor: BigNumber;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Rate Switch Operation Result
|
|
158
|
+
*/
|
|
159
|
+
interface RateSwitchResult {
|
|
160
|
+
transactionHash: string;
|
|
161
|
+
asset: string;
|
|
162
|
+
newRateMode: InterestRateMode;
|
|
163
|
+
newRate: number;
|
|
164
|
+
previousRate: number;
|
|
165
|
+
projectedSavings: BigNumber;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Collateral Management Result
|
|
169
|
+
*/
|
|
170
|
+
interface CollateralResult {
|
|
171
|
+
transactionHash: string;
|
|
172
|
+
asset: string;
|
|
173
|
+
enabled: boolean;
|
|
174
|
+
healthFactorBefore: BigNumber;
|
|
175
|
+
healthFactorAfter: BigNumber;
|
|
176
|
+
availableBorrowsChange: BigNumber;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Reserve Data from Aave Protocol
|
|
180
|
+
*/
|
|
181
|
+
interface ReserveData {
|
|
182
|
+
underlyingAsset: string;
|
|
183
|
+
symbol: string;
|
|
184
|
+
decimals: number;
|
|
185
|
+
liquidityRate: BigNumber;
|
|
186
|
+
stableBorrowRate: BigNumber;
|
|
187
|
+
variableBorrowRate: BigNumber;
|
|
188
|
+
utilizationRate: BigNumber;
|
|
189
|
+
totalLiquidity: BigNumber;
|
|
190
|
+
availableLiquidity: BigNumber;
|
|
191
|
+
totalStableDebt: BigNumber;
|
|
192
|
+
totalVariableDebt: BigNumber;
|
|
193
|
+
liquidityIndex: BigNumber;
|
|
194
|
+
variableBorrowIndex: BigNumber;
|
|
195
|
+
lastUpdateTimestamp: number;
|
|
196
|
+
usageAsCollateralEnabled: boolean;
|
|
197
|
+
ltv: number;
|
|
198
|
+
liquidationThreshold: number;
|
|
199
|
+
liquidationBonus: number;
|
|
200
|
+
reserveFactor: number;
|
|
201
|
+
aTokenAddress: string;
|
|
202
|
+
stableDebtTokenAddress: string;
|
|
203
|
+
variableDebtTokenAddress: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Aave Plugin Configuration
|
|
207
|
+
*/
|
|
208
|
+
interface AaveConfig {
|
|
209
|
+
network: "base" | "base-sepolia";
|
|
210
|
+
rpcUrl: string;
|
|
211
|
+
aavePoolAddress: string;
|
|
212
|
+
aaveDataProviderAddress: string;
|
|
213
|
+
healthFactorThreshold: number;
|
|
214
|
+
maxGasPrice: BigNumber;
|
|
215
|
+
retryAttempts: number;
|
|
216
|
+
monitoringInterval: number;
|
|
217
|
+
flashLoanFeeThreshold: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Aave Error Response
|
|
221
|
+
*/
|
|
222
|
+
interface AaveErrorResponse {
|
|
223
|
+
code: string;
|
|
224
|
+
message: string;
|
|
225
|
+
details?: any;
|
|
226
|
+
suggestions?: string[];
|
|
227
|
+
healthFactorImpact?: number;
|
|
228
|
+
alternativeActions?: string[];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Transaction Parameters
|
|
232
|
+
*/
|
|
233
|
+
interface TransactionParams {
|
|
234
|
+
gasLimit?: bigint;
|
|
235
|
+
gasPrice?: bigint;
|
|
236
|
+
maxFeePerGas?: bigint;
|
|
237
|
+
maxPriorityFeePerGas?: bigint;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Action Parameter Interfaces
|
|
241
|
+
*/
|
|
242
|
+
interface SupplyParams {
|
|
243
|
+
asset: string;
|
|
244
|
+
amount: string;
|
|
245
|
+
enableCollateral?: boolean;
|
|
246
|
+
}
|
|
247
|
+
interface BorrowParams {
|
|
248
|
+
asset: string;
|
|
249
|
+
amount: string;
|
|
250
|
+
rateMode: "stable" | "variable";
|
|
251
|
+
}
|
|
252
|
+
interface RepayParams {
|
|
253
|
+
asset: string;
|
|
254
|
+
amount: string;
|
|
255
|
+
rateMode: "stable" | "variable";
|
|
256
|
+
}
|
|
257
|
+
interface WithdrawParams {
|
|
258
|
+
asset: string;
|
|
259
|
+
amount: string;
|
|
260
|
+
}
|
|
261
|
+
interface RateSwitchParams {
|
|
262
|
+
asset: string;
|
|
263
|
+
targetRateMode: "stable" | "variable";
|
|
264
|
+
}
|
|
265
|
+
interface CollateralManagementParams {
|
|
266
|
+
asset: string;
|
|
267
|
+
enable: boolean;
|
|
268
|
+
}
|
|
269
|
+
interface eModeParams {
|
|
270
|
+
categoryId: number;
|
|
271
|
+
enable: boolean;
|
|
272
|
+
}
|
|
273
|
+
interface FlashLoanActionParams {
|
|
274
|
+
assets: string[];
|
|
275
|
+
amounts: string[];
|
|
276
|
+
receiverAddress?: string;
|
|
277
|
+
params?: string;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Health Factor Status
|
|
281
|
+
*/
|
|
282
|
+
declare enum HealthFactorStatus {
|
|
283
|
+
CRITICAL = "CRITICAL",// < 1.1
|
|
284
|
+
RISKY = "RISKY",// 1.1 - 1.5
|
|
285
|
+
MODERATE = "MODERATE",// 1.5 - 2.0
|
|
286
|
+
SAFE = "SAFE",// 2.0 - 3.0
|
|
287
|
+
VERY_SAFE = "VERY_SAFE"
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Utility Types
|
|
291
|
+
*/
|
|
292
|
+
interface TokenInfo {
|
|
293
|
+
address: string;
|
|
294
|
+
symbol: string;
|
|
295
|
+
decimals: number;
|
|
296
|
+
name: string;
|
|
297
|
+
}
|
|
298
|
+
interface GasEstimate {
|
|
299
|
+
gasLimit: bigint;
|
|
300
|
+
gasPrice: bigint;
|
|
301
|
+
totalCost: bigint;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Market Data
|
|
305
|
+
*/
|
|
306
|
+
interface MarketData {
|
|
307
|
+
totalValueLocked: BigNumber;
|
|
308
|
+
totalBorrowed: BigNumber;
|
|
309
|
+
averageSupplyAPY: number;
|
|
310
|
+
averageBorrowAPY: number;
|
|
311
|
+
utilizationRate: number;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Notification Types
|
|
315
|
+
*/
|
|
316
|
+
interface HealthFactorAlert {
|
|
317
|
+
type: "health_factor_warning" | "liquidation_risk";
|
|
318
|
+
currentHealthFactor: number;
|
|
319
|
+
threshold: number;
|
|
320
|
+
suggestedActions: string[];
|
|
321
|
+
urgency: "low" | "medium" | "high" | "critical";
|
|
322
|
+
}
|
|
323
|
+
interface RateOptimizationOpportunity {
|
|
324
|
+
asset: string;
|
|
325
|
+
currentRateMode: InterestRateMode;
|
|
326
|
+
currentRate: number;
|
|
327
|
+
suggestedRateMode: InterestRateMode;
|
|
328
|
+
suggestedRate: number;
|
|
329
|
+
potentialSavings: BigNumber;
|
|
330
|
+
recommendation: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare const aavePlugin: Plugin;
|
|
334
|
+
|
|
335
|
+
export { type AaveAssetPosition, type AaveConfig, type AaveErrorResponse, type AavePosition, type BorrowParams, type BorrowResult, type CollateralManagementParams, type CollateralResult, type FlashLoanActionParams, type FlashLoanParams, type FlashLoanResult, type GasEstimate, type HealthFactorAlert, HealthFactorStatus, InterestRateMode, type MarketData, type RateOptimizationOpportunity, type RateSwitchParams, type RateSwitchResult, type RepayParams, type RepayResult, type ReserveData, type SupplyParams, type SupplyResult, type TokenInfo, type TransactionParams, type UserAccountData, type WithdrawParams, type WithdrawResult, aavePlugin, borrowAction, collateralManagementAction, aavePlugin as default, eModeAction, type eModeCategory, type eModeParams, type eModeResult, flashLoanAction, healthFactorProvider, positionContextProvider, rateSwitchAction, repayAction, supplyAction, withdrawAction };
|