@emberai/onchain-actions-registry 3.0.0-alpha.2 → 3.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,1536 +1,1362 @@
1
- "use strict";
1
+ //#region rolldown:runtime
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
8
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- BorrowTokensRequestSchema: () => BorrowTokensRequestSchema,
34
- BorrowTokensResponseSchema: () => BorrowTokensResponseSchema,
35
- ChainSchema: () => ChainSchema,
36
- ChainTypeSchema: () => ChainTypeSchema,
37
- ClosePerpetualsOrdersRequestSchema: () => ClosePerpetualsOrdersRequestSchema,
38
- ClosePerpetualsOrdersResponseSchema: () => ClosePerpetualsOrdersResponseSchema,
39
- CreatePerpetualsPositionRequestSchema: () => CreatePerpetualsPositionRequestSchema,
40
- CreatePerpetualsPositionResponseSchema: () => CreatePerpetualsPositionResponseSchema,
41
- DecreasePositionSwapTypeSchema: () => DecreasePositionSwapTypeSchema,
42
- FeeBreakdownSchema: () => FeeBreakdownSchema,
43
- GetLiquidityPoolsResponseSchema: () => GetLiquidityPoolsResponseSchema,
44
- GetPerpetualsMarketsOrdersRequestSchema: () => GetPerpetualsMarketsOrdersRequestSchema,
45
- GetPerpetualsMarketsOrdersResponseSchema: () => GetPerpetualsMarketsOrdersResponseSchema,
46
- GetPerpetualsMarketsPositionsRequestSchema: () => GetPerpetualsMarketsPositionsRequestSchema,
47
- GetPerpetualsMarketsPositionsResponseSchema: () => GetPerpetualsMarketsPositionsResponseSchema,
48
- GetPerpetualsMarketsRequestSchema: () => GetPerpetualsMarketsRequestSchema,
49
- GetPerpetualsMarketsResponseSchema: () => GetPerpetualsMarketsResponseSchema,
50
- GetWalletLendingPositionsRequestSchema: () => GetWalletLendingPositionsRequestSchema,
51
- GetWalletLendingPositionsResponseSchema: () => GetWalletLendingPositionsResponseSchema,
52
- GetWalletLiquidityPositionsRequestSchema: () => GetWalletLiquidityPositionsRequestSchema,
53
- GetWalletLiquidityPositionsResponseSchema: () => GetWalletLiquidityPositionsResponseSchema,
54
- LendTokenDetailSchema: () => LendTokenDetailSchema,
55
- LimitedLiquidityProvisionRangeSchema: () => LimitedLiquidityProvisionRangeSchema,
56
- LiquidityPayTokensSchema: () => LiquidityPayTokensSchema,
57
- LiquidityPoolSchema: () => LiquidityPoolSchema,
58
- LiquidityPoolTokens: () => LiquidityPoolTokens,
59
- LiquidityPositionRangeSchema: () => LiquidityPositionRangeSchema,
60
- LiquidityPositionSchema: () => LiquidityPositionSchema,
61
- LiquidityProvisionRangeSchema: () => LiquidityProvisionRangeSchema,
62
- LiquiditySuppliedTokenSchema: () => LiquiditySuppliedTokenSchema,
63
- OrderSchema: () => OrderSchema,
64
- OrderTypeSchema: () => OrderTypeSchema,
65
- OrdersDataSchema: () => OrdersDataSchema,
66
- PerpetualMarketSchema: () => PerpetualMarketSchema,
67
- PositionSchema: () => PositionSchema,
68
- PositionSideSchema: () => PositionSideSchema,
69
- PositionsDataSchema: () => PositionsDataSchema,
70
- ProviderTrackingInfoSchema: () => ProviderTrackingInfoSchema,
71
- ProviderTrackingStatusSchema: () => ProviderTrackingStatusSchema,
72
- PublicEmberPluginRegistry: () => PublicEmberPluginRegistry,
73
- RepayTokensRequestSchema: () => RepayTokensRequestSchema,
74
- RepayTokensResponseSchema: () => RepayTokensResponseSchema,
75
- SupplyLiquidityRequestSchema: () => SupplyLiquidityRequestSchema,
76
- SupplyLiquidityResponseSchema: () => SupplyLiquidityResponseSchema,
77
- SupplyTokensRequestSchema: () => SupplyTokensRequestSchema,
78
- SupplyTokensResponseSchema: () => SupplyTokensResponseSchema,
79
- SwapEstimationSchema: () => SwapEstimationSchema,
80
- SwapTokensRequestSchema: () => SwapTokensRequestSchema,
81
- SwapTokensResponseSchema: () => SwapTokensResponseSchema,
82
- TokenIdentifierSchema: () => TokenIdentifierSchema,
83
- TokenSchema: () => TokenSchema,
84
- TransactionPlanErrorSchema: () => TransactionPlanErrorSchema,
85
- TransactionPlanSchema: () => TransactionPlanSchema,
86
- TransactionTypeSchema: () => TransactionTypeSchema,
87
- TransactionTypes: () => TransactionTypes,
88
- WithdrawLiquidityRequestSchema: () => WithdrawLiquidityRequestSchema,
89
- WithdrawLiquidityResponseSchema: () => WithdrawLiquidityResponseSchema,
90
- WithdrawTokensRequestSchema: () => WithdrawTokensRequestSchema,
91
- WithdrawTokensResponseSchema: () => WithdrawTokensResponseSchema,
92
- initializePublicRegistry: () => initializePublicRegistry
93
- });
94
- module.exports = __toCommonJS(index_exports);
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
95
22
 
96
- // src/aave-lending-plugin/adapter.ts
97
- var import_contract_helpers2 = require("@aave/contract-helpers");
98
- var import_ethers3 = require("ethers");
23
+ //#endregion
24
+ let __aave_contract_helpers = require("@aave/contract-helpers");
25
+ let ethers = require("ethers");
26
+ let zod = require("zod");
27
+ let __bgd_labs_aave_address_book = require("@bgd-labs/aave-address-book");
28
+ __bgd_labs_aave_address_book = __toESM(__bgd_labs_aave_address_book);
29
+ let __aave_math_utils = require("@aave/math-utils");
99
30
 
100
- // src/core/schemas/core.ts
101
- var import_zod2 = require("zod");
102
-
103
- // src/core/schemas/enums.ts
104
- var import_zod = require("zod");
105
- var ChainTypeSchema = import_zod.z.enum(["UNSPECIFIED", "EVM", "SOLANA", "COSMOS"]);
106
- var TransactionTypes = {
107
- TRANSACTION_TYPE_UNSPECIFIED: "TRANSACTION_TYPE_UNSPECIFIED",
108
- EVM_TX: "EVM_TX",
109
- SOLANA_TX: "SOLANA_TX"
31
+ //#region src/core/schemas/enums.ts
32
+ const ChainTypeSchema = zod.z.enum([
33
+ "UNSPECIFIED",
34
+ "EVM",
35
+ "SOLANA",
36
+ "COSMOS"
37
+ ]);
38
+ const TransactionTypes = {
39
+ TRANSACTION_TYPE_UNSPECIFIED: "TRANSACTION_TYPE_UNSPECIFIED",
40
+ EVM_TX: "EVM_TX",
41
+ SOLANA_TX: "SOLANA_TX"
110
42
  };
111
- var TransactionTypeSchema = import_zod.z.enum(
112
- Object.values(TransactionTypes)
113
- );
43
+ const TransactionTypeSchema = zod.z.enum(Object.values(TransactionTypes));
114
44
 
115
- // src/core/schemas/core.ts
116
- var TokenIdentifierSchema = import_zod2.z.object({
117
- chainId: import_zod2.z.string(),
118
- address: import_zod2.z.string()
45
+ //#endregion
46
+ //#region src/core/schemas/core.ts
47
+ const TokenIdentifierSchema = zod.z.object({
48
+ chainId: zod.z.string(),
49
+ address: zod.z.string()
119
50
  });
120
- var TokenSchema = import_zod2.z.object({
121
- tokenUid: TokenIdentifierSchema,
122
- name: import_zod2.z.string(),
123
- symbol: import_zod2.z.string(),
124
- isNative: import_zod2.z.boolean(),
125
- decimals: import_zod2.z.number().int(),
126
- iconUri: import_zod2.z.string().nullish(),
127
- isVetted: import_zod2.z.boolean()
51
+ const TokenSchema = zod.z.object({
52
+ tokenUid: TokenIdentifierSchema,
53
+ name: zod.z.string(),
54
+ symbol: zod.z.string(),
55
+ isNative: zod.z.boolean(),
56
+ decimals: zod.z.number().int(),
57
+ iconUri: zod.z.string().nullish(),
58
+ isVetted: zod.z.boolean()
128
59
  });
129
- var ChainSchema = import_zod2.z.object({
130
- chainId: import_zod2.z.string(),
131
- type: ChainTypeSchema,
132
- iconUri: import_zod2.z.string(),
133
- nativeToken: TokenSchema,
134
- httpRpcUrl: import_zod2.z.string(),
135
- name: import_zod2.z.string(),
136
- blockExplorerUrls: import_zod2.z.array(import_zod2.z.string())
60
+ const ChainSchema = zod.z.object({
61
+ chainId: zod.z.string(),
62
+ type: ChainTypeSchema,
63
+ iconUri: zod.z.string(),
64
+ nativeToken: TokenSchema,
65
+ httpRpcUrl: zod.z.string(),
66
+ name: zod.z.string(),
67
+ blockExplorerUrls: zod.z.array(zod.z.string())
137
68
  });
138
- var FeeBreakdownSchema = import_zod2.z.object({
139
- serviceFee: import_zod2.z.string(),
140
- slippageCost: import_zod2.z.string(),
141
- total: import_zod2.z.string(),
142
- feeDenomination: import_zod2.z.string()
69
+ const FeeBreakdownSchema = zod.z.object({
70
+ serviceFee: zod.z.string(),
71
+ slippageCost: zod.z.string(),
72
+ total: zod.z.string(),
73
+ feeDenomination: zod.z.string()
143
74
  });
144
- var TransactionPlanSchema = import_zod2.z.object({
145
- type: TransactionTypeSchema,
146
- to: import_zod2.z.string(),
147
- data: import_zod2.z.string(),
148
- value: import_zod2.z.string(),
149
- chainId: import_zod2.z.string()
75
+ const TransactionPlanSchema = zod.z.object({
76
+ type: TransactionTypeSchema,
77
+ to: zod.z.string(),
78
+ data: zod.z.string(),
79
+ value: zod.z.string(),
80
+ chainId: zod.z.string()
150
81
  });
151
- var TransactionPlanErrorSchema = import_zod2.z.object({
152
- code: import_zod2.z.string(),
153
- message: import_zod2.z.string(),
154
- details: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.string())
82
+ const TransactionPlanErrorSchema = zod.z.object({
83
+ code: zod.z.string(),
84
+ message: zod.z.string(),
85
+ details: zod.z.record(zod.z.string(), zod.z.string())
155
86
  });
156
- var ProviderTrackingInfoSchema = import_zod2.z.object({
157
- requestId: import_zod2.z.string(),
158
- providerName: import_zod2.z.string(),
159
- explorerUrl: import_zod2.z.string()
87
+ const ProviderTrackingInfoSchema = zod.z.object({
88
+ requestId: zod.z.string(),
89
+ providerName: zod.z.string(),
90
+ explorerUrl: zod.z.string()
160
91
  });
161
- var SwapEstimationSchema = import_zod2.z.object({
162
- effectivePrice: import_zod2.z.string(),
163
- timeEstimate: import_zod2.z.string(),
164
- expiration: import_zod2.z.string()
92
+ const SwapEstimationSchema = zod.z.object({
93
+ effectivePrice: zod.z.string(),
94
+ timeEstimate: zod.z.string(),
95
+ expiration: zod.z.string()
165
96
  });
166
- var ProviderTrackingStatusSchema = import_zod2.z.object({
167
- requestId: import_zod2.z.string(),
168
- transactionId: import_zod2.z.string(),
169
- providerName: import_zod2.z.string(),
170
- explorerUrl: import_zod2.z.string(),
171
- status: import_zod2.z.string()
97
+ const ProviderTrackingStatusSchema = zod.z.object({
98
+ requestId: zod.z.string(),
99
+ transactionId: zod.z.string(),
100
+ providerName: zod.z.string(),
101
+ explorerUrl: zod.z.string(),
102
+ status: zod.z.string()
172
103
  });
173
104
 
174
- // src/core/schemas/lending.ts
175
- var import_zod3 = require("zod");
176
- var BorrowTokensRequestSchema = import_zod3.z.object({
177
- borrowToken: TokenSchema,
178
- amount: import_zod3.z.bigint(),
179
- walletAddress: import_zod3.z.string()
105
+ //#endregion
106
+ //#region src/core/schemas/lending.ts
107
+ const BorrowTokensRequestSchema = zod.z.object({
108
+ borrowToken: TokenSchema,
109
+ amount: zod.z.bigint(),
110
+ walletAddress: zod.z.string()
180
111
  });
181
- var BorrowTokensResponseSchema = import_zod3.z.object({
182
- currentBorrowApy: import_zod3.z.string(),
183
- liquidationThreshold: import_zod3.z.string(),
184
- feeBreakdown: FeeBreakdownSchema.optional(),
185
- transactions: import_zod3.z.array(TransactionPlanSchema)
112
+ const BorrowTokensResponseSchema = zod.z.object({
113
+ currentBorrowApy: zod.z.string(),
114
+ liquidationThreshold: zod.z.string(),
115
+ feeBreakdown: FeeBreakdownSchema.optional(),
116
+ transactions: zod.z.array(TransactionPlanSchema)
186
117
  });
187
- var RepayTokensRequestSchema = import_zod3.z.object({
188
- repayToken: TokenSchema,
189
- amount: import_zod3.z.bigint(),
190
- walletAddress: import_zod3.z.string()
118
+ const RepayTokensRequestSchema = zod.z.object({
119
+ repayToken: TokenSchema,
120
+ amount: zod.z.bigint(),
121
+ walletAddress: zod.z.string()
191
122
  });
192
- var RepayTokensResponseSchema = import_zod3.z.object({
193
- feeBreakdown: FeeBreakdownSchema.optional(),
194
- transactions: import_zod3.z.array(TransactionPlanSchema)
123
+ const RepayTokensResponseSchema = zod.z.object({
124
+ feeBreakdown: FeeBreakdownSchema.optional(),
125
+ transactions: zod.z.array(TransactionPlanSchema)
195
126
  });
196
- var SupplyTokensRequestSchema = import_zod3.z.object({
197
- supplyToken: TokenSchema,
198
- amount: import_zod3.z.bigint(),
199
- walletAddress: import_zod3.z.string()
127
+ const SupplyTokensRequestSchema = zod.z.object({
128
+ supplyToken: TokenSchema,
129
+ amount: zod.z.bigint(),
130
+ walletAddress: zod.z.string()
200
131
  });
201
- var SupplyTokensResponseSchema = import_zod3.z.object({
202
- feeBreakdown: FeeBreakdownSchema.optional(),
203
- transactions: import_zod3.z.array(TransactionPlanSchema)
132
+ const SupplyTokensResponseSchema = zod.z.object({
133
+ feeBreakdown: FeeBreakdownSchema.optional(),
134
+ transactions: zod.z.array(TransactionPlanSchema)
204
135
  });
205
- var WithdrawTokensRequestSchema = import_zod3.z.object({
206
- tokenToWithdraw: TokenSchema,
207
- amount: import_zod3.z.bigint(),
208
- walletAddress: import_zod3.z.string()
136
+ const WithdrawTokensRequestSchema = zod.z.object({
137
+ tokenToWithdraw: TokenSchema,
138
+ amount: zod.z.bigint(),
139
+ walletAddress: zod.z.string()
209
140
  });
210
- var WithdrawTokensResponseSchema = import_zod3.z.object({
211
- feeBreakdown: FeeBreakdownSchema.optional(),
212
- transactions: import_zod3.z.array(TransactionPlanSchema)
141
+ const WithdrawTokensResponseSchema = zod.z.object({
142
+ feeBreakdown: FeeBreakdownSchema.optional(),
143
+ transactions: zod.z.array(TransactionPlanSchema)
213
144
  });
214
- var GetWalletLendingPositionsRequestSchema = import_zod3.z.object({
215
- walletAddress: import_zod3.z.string(),
216
- chainId: import_zod3.z.string().optional(),
217
- tokenAddress: import_zod3.z.string().optional()
145
+ const GetWalletLendingPositionsRequestSchema = zod.z.object({
146
+ walletAddress: zod.z.string(),
147
+ chainId: zod.z.string().optional(),
148
+ tokenAddress: zod.z.string().optional()
218
149
  });
219
- var LendTokenDetailSchema = import_zod3.z.object({
220
- tokenUid: TokenIdentifierSchema,
221
- underlyingBalance: import_zod3.z.string(),
222
- underlyingBalanceUsd: import_zod3.z.string(),
223
- variableBorrows: import_zod3.z.string(),
224
- variableBorrowsUsd: import_zod3.z.string(),
225
- totalBorrows: import_zod3.z.string(),
226
- totalBorrowsUsd: import_zod3.z.string()
150
+ const LendTokenDetailSchema = zod.z.object({
151
+ tokenUid: TokenIdentifierSchema,
152
+ underlyingBalance: zod.z.string(),
153
+ underlyingBalanceUsd: zod.z.string(),
154
+ variableBorrows: zod.z.string(),
155
+ variableBorrowsUsd: zod.z.string(),
156
+ totalBorrows: zod.z.string(),
157
+ totalBorrowsUsd: zod.z.string()
227
158
  });
228
- var GetWalletLendingPositionsResponseSchema = import_zod3.z.object({
229
- userReserves: import_zod3.z.array(LendTokenDetailSchema),
230
- totalLiquidityUsd: import_zod3.z.string(),
231
- totalCollateralUsd: import_zod3.z.string(),
232
- totalBorrowsUsd: import_zod3.z.string(),
233
- netWorthUsd: import_zod3.z.string(),
234
- availableBorrowsUsd: import_zod3.z.string(),
235
- currentLoanToValue: import_zod3.z.string(),
236
- currentLiquidationThreshold: import_zod3.z.string(),
237
- healthFactor: import_zod3.z.string()
159
+ const GetWalletLendingPositionsResponseSchema = zod.z.object({
160
+ userReserves: zod.z.array(LendTokenDetailSchema),
161
+ totalLiquidityUsd: zod.z.string(),
162
+ totalCollateralUsd: zod.z.string(),
163
+ totalBorrowsUsd: zod.z.string(),
164
+ netWorthUsd: zod.z.string(),
165
+ availableBorrowsUsd: zod.z.string(),
166
+ currentLoanToValue: zod.z.string(),
167
+ currentLiquidationThreshold: zod.z.string(),
168
+ healthFactor: zod.z.string()
238
169
  });
239
170
 
240
- // src/core/schemas/liquidity.ts
241
- var import_zod4 = require("zod");
242
- var LimitedLiquidityProvisionRangeSchema = import_zod4.z.object({
243
- minPrice: import_zod4.z.string(),
244
- maxPrice: import_zod4.z.string()
171
+ //#endregion
172
+ //#region src/core/schemas/liquidity.ts
173
+ const LimitedLiquidityProvisionRangeSchema = zod.z.object({
174
+ minPrice: zod.z.string(),
175
+ maxPrice: zod.z.string()
245
176
  });
246
- var LiquidityProvisionRangeSchema = import_zod4.z.discriminatedUnion("type", [
247
- import_zod4.z.object({
248
- type: import_zod4.z.literal("full")
249
- }),
250
- import_zod4.z.object({
251
- type: import_zod4.z.literal("limited"),
252
- minPrice: import_zod4.z.string(),
253
- maxPrice: import_zod4.z.string()
254
- })
255
- ]);
256
- var LiquidityPositionRangeSchema = import_zod4.z.object({
257
- fromPrice: import_zod4.z.string(),
258
- toPrice: import_zod4.z.string()
177
+ const LiquidityProvisionRangeSchema = zod.z.discriminatedUnion("type", [zod.z.object({ type: zod.z.literal("full") }), zod.z.object({
178
+ type: zod.z.literal("limited"),
179
+ minPrice: zod.z.string(),
180
+ maxPrice: zod.z.string()
181
+ })]);
182
+ const LiquidityPositionRangeSchema = zod.z.object({
183
+ fromPrice: zod.z.string(),
184
+ toPrice: zod.z.string()
259
185
  });
260
- var LiquiditySuppliedTokenSchema = import_zod4.z.object({
261
- tokenUid: TokenIdentifierSchema,
262
- suppliedAmount: import_zod4.z.string(),
263
- owedTokens: import_zod4.z.string()
186
+ const LiquiditySuppliedTokenSchema = zod.z.object({
187
+ tokenUid: TokenIdentifierSchema,
188
+ suppliedAmount: zod.z.string(),
189
+ owedTokens: zod.z.string()
264
190
  });
265
- var LiquidityPositionSchema = import_zod4.z.object({
266
- poolIdentifier: TokenIdentifierSchema,
267
- operator: import_zod4.z.string(),
268
- suppliedTokens: import_zod4.z.array(LiquiditySuppliedTokenSchema),
269
- price: import_zod4.z.string(),
270
- providerId: import_zod4.z.string(),
271
- positionRange: LiquidityPositionRangeSchema.optional()
191
+ const LiquidityPositionSchema = zod.z.object({
192
+ poolIdentifier: TokenIdentifierSchema,
193
+ operator: zod.z.string(),
194
+ suppliedTokens: zod.z.array(LiquiditySuppliedTokenSchema),
195
+ price: zod.z.string(),
196
+ providerId: zod.z.string(),
197
+ positionRange: LiquidityPositionRangeSchema.optional()
272
198
  });
273
- var LiquidityPoolTokens = import_zod4.z.object({
274
- tokenUid: TokenIdentifierSchema
199
+ const LiquidityPoolTokens = zod.z.object({ tokenUid: TokenIdentifierSchema });
200
+ const LiquidityPoolSchema = zod.z.object({
201
+ identifier: TokenIdentifierSchema,
202
+ tokens: zod.z.array(LiquidityPoolTokens),
203
+ price: zod.z.string(),
204
+ providerId: zod.z.string()
275
205
  });
276
- var LiquidityPoolSchema = import_zod4.z.object({
277
- identifier: TokenIdentifierSchema,
278
- tokens: import_zod4.z.array(LiquidityPoolTokens),
279
- price: import_zod4.z.string(),
280
- providerId: import_zod4.z.string()
206
+ const LiquidityPayTokensSchema = zod.z.object({
207
+ token: TokenSchema,
208
+ supplyAmount: zod.z.bigint()
281
209
  });
282
- var LiquidityPayTokensSchema = import_zod4.z.object({
283
- token: TokenSchema,
284
- supplyAmount: import_zod4.z.bigint()
210
+ const SupplyLiquidityRequestSchema = zod.z.object({
211
+ walletAddress: zod.z.string(),
212
+ poolToken: TokenSchema,
213
+ payTokens: zod.z.array(LiquidityPayTokensSchema),
214
+ range: LiquidityProvisionRangeSchema.optional()
285
215
  });
286
- var SupplyLiquidityRequestSchema = import_zod4.z.object({
287
- walletAddress: import_zod4.z.string(),
288
- poolToken: TokenSchema,
289
- payTokens: import_zod4.z.array(LiquidityPayTokensSchema),
290
- range: LiquidityProvisionRangeSchema.optional()
216
+ const SupplyLiquidityResponseSchema = zod.z.object({
217
+ transactions: zod.z.array(TransactionPlanSchema),
218
+ poolIdentifier: TokenIdentifierSchema
291
219
  });
292
- var SupplyLiquidityResponseSchema = import_zod4.z.object({
293
- transactions: import_zod4.z.array(TransactionPlanSchema),
294
- poolIdentifier: TokenIdentifierSchema
220
+ const WithdrawLiquidityRequestSchema = zod.z.object({
221
+ poolToken: TokenSchema,
222
+ walletAddress: zod.z.string()
295
223
  });
296
- var WithdrawLiquidityRequestSchema = import_zod4.z.object({
297
- poolToken: TokenSchema,
298
- walletAddress: import_zod4.z.string()
299
- });
300
- var WithdrawLiquidityResponseSchema = import_zod4.z.object({
301
- transactions: import_zod4.z.array(TransactionPlanSchema),
302
- chainId: import_zod4.z.string()
303
- });
304
- var GetWalletLiquidityPositionsRequestSchema = import_zod4.z.object({
305
- walletAddress: import_zod4.z.string()
306
- });
307
- var GetWalletLiquidityPositionsResponseSchema = import_zod4.z.object({
308
- positions: import_zod4.z.array(LiquidityPositionSchema)
309
- });
310
- var GetLiquidityPoolsResponseSchema = import_zod4.z.object({
311
- liquidityPools: import_zod4.z.array(LiquidityPoolSchema)
224
+ const WithdrawLiquidityResponseSchema = zod.z.object({
225
+ transactions: zod.z.array(TransactionPlanSchema),
226
+ chainId: zod.z.string()
312
227
  });
228
+ const GetWalletLiquidityPositionsRequestSchema = zod.z.object({ walletAddress: zod.z.string() });
229
+ const GetWalletLiquidityPositionsResponseSchema = zod.z.object({ positions: zod.z.array(LiquidityPositionSchema) });
230
+ const GetLiquidityPoolsResponseSchema = zod.z.object({ liquidityPools: zod.z.array(LiquidityPoolSchema) });
313
231
 
314
- // src/core/schemas/perpetuals.ts
315
- var import_zod5 = require("zod");
316
- var DecreasePositionSwapTypeSchema = import_zod5.z.enum([
317
- "NoSwap",
318
- "SwapPnlTokenToCollateralToken",
319
- "SwapCollateralTokenToPnlToken"
232
+ //#endregion
233
+ //#region src/core/schemas/perpetuals.ts
234
+ const DecreasePositionSwapTypeSchema = zod.z.enum([
235
+ "NoSwap",
236
+ "SwapPnlTokenToCollateralToken",
237
+ "SwapCollateralTokenToPnlToken"
320
238
  ]);
321
- var PositionSideSchema = import_zod5.z.enum(["long", "short"]);
322
- var PositionSchema = import_zod5.z.object({
323
- chainId: import_zod5.z.string(),
324
- key: import_zod5.z.string(),
325
- contractKey: import_zod5.z.string(),
326
- account: import_zod5.z.string(),
327
- marketAddress: import_zod5.z.string(),
328
- collateralTokenAddress: import_zod5.z.string(),
329
- sizeInUsd: import_zod5.z.string(),
330
- sizeInTokens: import_zod5.z.string(),
331
- collateralAmount: import_zod5.z.string(),
332
- pendingBorrowingFeesUsd: import_zod5.z.string(),
333
- increasedAtTime: import_zod5.z.string(),
334
- decreasedAtTime: import_zod5.z.string(),
335
- positionSide: PositionSideSchema,
336
- isLong: import_zod5.z.boolean(),
337
- fundingFeeAmount: import_zod5.z.string(),
338
- claimableLongTokenAmount: import_zod5.z.string(),
339
- claimableShortTokenAmount: import_zod5.z.string(),
340
- isOpening: import_zod5.z.boolean().optional(),
341
- pnl: import_zod5.z.string(),
342
- positionFeeAmount: import_zod5.z.string(),
343
- traderDiscountAmount: import_zod5.z.string(),
344
- uiFeeAmount: import_zod5.z.string(),
345
- data: import_zod5.z.string().optional()
239
+ const PositionSideSchema = zod.z.enum(["long", "short"]);
240
+ const PositionSchema = zod.z.object({
241
+ chainId: zod.z.string(),
242
+ key: zod.z.string(),
243
+ contractKey: zod.z.string(),
244
+ account: zod.z.string(),
245
+ marketAddress: zod.z.string(),
246
+ collateralTokenAddress: zod.z.string(),
247
+ sizeInUsd: zod.z.string(),
248
+ sizeInTokens: zod.z.string(),
249
+ collateralAmount: zod.z.string(),
250
+ pendingBorrowingFeesUsd: zod.z.string(),
251
+ increasedAtTime: zod.z.string(),
252
+ decreasedAtTime: zod.z.string(),
253
+ positionSide: PositionSideSchema,
254
+ isLong: zod.z.boolean(),
255
+ fundingFeeAmount: zod.z.string(),
256
+ claimableLongTokenAmount: zod.z.string(),
257
+ claimableShortTokenAmount: zod.z.string(),
258
+ isOpening: zod.z.boolean().optional(),
259
+ pnl: zod.z.string(),
260
+ positionFeeAmount: zod.z.string(),
261
+ traderDiscountAmount: zod.z.string(),
262
+ uiFeeAmount: zod.z.string(),
263
+ data: zod.z.string().optional()
346
264
  });
347
- var PositionsDataSchema = import_zod5.z.array(PositionSchema);
348
- var OrderTypeSchema = import_zod5.z.enum([
349
- "MarketSwap",
350
- "LimitSwap",
351
- "MarketIncrease",
352
- "LimitIncrease",
353
- "MarketDecrease",
354
- "LimitDecrease",
355
- "StopLossDecrease",
356
- "Liquidation",
357
- "StopIncrease"
265
+ const PositionsDataSchema = zod.z.array(PositionSchema);
266
+ const OrderTypeSchema = zod.z.enum([
267
+ "MarketSwap",
268
+ "LimitSwap",
269
+ "MarketIncrease",
270
+ "LimitIncrease",
271
+ "MarketDecrease",
272
+ "LimitDecrease",
273
+ "StopLossDecrease",
274
+ "Liquidation",
275
+ "StopIncrease"
358
276
  ]);
359
- var OrderSchema = import_zod5.z.object({
360
- chainId: import_zod5.z.string(),
361
- key: import_zod5.z.string(),
362
- account: import_zod5.z.string(),
363
- callbackContract: import_zod5.z.string(),
364
- initialCollateralTokenAddress: import_zod5.z.string(),
365
- marketAddress: import_zod5.z.string(),
366
- decreasePositionSwapType: DecreasePositionSwapTypeSchema,
367
- receiver: import_zod5.z.string(),
368
- swapPath: import_zod5.z.array(import_zod5.z.string()),
369
- contractAcceptablePrice: import_zod5.z.string(),
370
- contractTriggerPrice: import_zod5.z.string(),
371
- callbackGasLimit: import_zod5.z.string(),
372
- executionFee: import_zod5.z.string(),
373
- initialCollateralDeltaAmount: import_zod5.z.string(),
374
- minOutputAmount: import_zod5.z.string(),
375
- sizeDeltaUsd: import_zod5.z.string(),
376
- updatedAtTime: import_zod5.z.string(),
377
- isFrozen: import_zod5.z.boolean(),
378
- positionSide: PositionSideSchema,
379
- orderType: OrderTypeSchema,
380
- shouldUnwrapNativeToken: import_zod5.z.boolean(),
381
- autoCancel: import_zod5.z.boolean(),
382
- data: import_zod5.z.string().optional(),
383
- uiFeeReceiver: import_zod5.z.string(),
384
- validFromTime: import_zod5.z.string(),
385
- title: import_zod5.z.string().optional()
386
- });
387
- var OrdersDataSchema = import_zod5.z.array(OrderSchema);
388
- var CreatePerpetualsPositionRequestSchema = import_zod5.z.object({
389
- amount: import_zod5.z.bigint(),
390
- walletAddress: import_zod5.z.string(),
391
- chainId: import_zod5.z.string(),
392
- marketAddress: import_zod5.z.string(),
393
- payTokenAddress: import_zod5.z.string(),
394
- collateralTokenAddress: import_zod5.z.string(),
395
- referralCode: import_zod5.z.string().optional(),
396
- limitPrice: import_zod5.z.string().optional(),
397
- leverage: import_zod5.z.string()
277
+ const OrderSchema = zod.z.object({
278
+ chainId: zod.z.string(),
279
+ key: zod.z.string(),
280
+ account: zod.z.string(),
281
+ callbackContract: zod.z.string(),
282
+ initialCollateralTokenAddress: zod.z.string(),
283
+ marketAddress: zod.z.string(),
284
+ decreasePositionSwapType: DecreasePositionSwapTypeSchema,
285
+ receiver: zod.z.string(),
286
+ swapPath: zod.z.array(zod.z.string()),
287
+ contractAcceptablePrice: zod.z.string(),
288
+ contractTriggerPrice: zod.z.string(),
289
+ callbackGasLimit: zod.z.string(),
290
+ executionFee: zod.z.string(),
291
+ initialCollateralDeltaAmount: zod.z.string(),
292
+ minOutputAmount: zod.z.string(),
293
+ sizeDeltaUsd: zod.z.string(),
294
+ updatedAtTime: zod.z.string(),
295
+ isFrozen: zod.z.boolean(),
296
+ positionSide: PositionSideSchema,
297
+ orderType: OrderTypeSchema,
298
+ shouldUnwrapNativeToken: zod.z.boolean(),
299
+ autoCancel: zod.z.boolean(),
300
+ data: zod.z.string().optional(),
301
+ uiFeeReceiver: zod.z.string(),
302
+ validFromTime: zod.z.string(),
303
+ title: zod.z.string().optional()
398
304
  });
399
- var CreatePerpetualsPositionResponseSchema = import_zod5.z.object({
400
- transactions: import_zod5.z.array(TransactionPlanSchema)
305
+ const OrdersDataSchema = zod.z.array(OrderSchema);
306
+ const CreatePerpetualsPositionRequestSchema = zod.z.object({
307
+ amount: zod.z.bigint(),
308
+ walletAddress: zod.z.string(),
309
+ chainId: zod.z.string(),
310
+ marketAddress: zod.z.string(),
311
+ payTokenAddress: zod.z.string(),
312
+ collateralTokenAddress: zod.z.string(),
313
+ referralCode: zod.z.string().optional(),
314
+ limitPrice: zod.z.string().optional(),
315
+ leverage: zod.z.string()
401
316
  });
402
- var GetPerpetualsMarketsPositionsRequestSchema = import_zod5.z.object({
403
- walletAddress: import_zod5.z.string().describe("User's wallet address")
317
+ const CreatePerpetualsPositionResponseSchema = zod.z.object({ transactions: zod.z.array(TransactionPlanSchema) });
318
+ const GetPerpetualsMarketsPositionsRequestSchema = zod.z.object({ walletAddress: zod.z.string().describe("User's wallet address") });
319
+ const GetPerpetualsMarketsPositionsResponseSchema = zod.z.object({ positions: PositionsDataSchema });
320
+ const GetPerpetualsMarketsOrdersRequestSchema = zod.z.object({ walletAddress: zod.z.string().describe("User's wallet address") });
321
+ const GetPerpetualsMarketsOrdersResponseSchema = zod.z.object({ orders: OrdersDataSchema });
322
+ const ClosePerpetualsOrdersRequestSchema = zod.z.object({
323
+ walletAddress: zod.z.string().describe("User's wallet address"),
324
+ key: zod.z.string()
404
325
  });
405
- var GetPerpetualsMarketsPositionsResponseSchema = import_zod5.z.object({
406
- positions: PositionsDataSchema
407
- });
408
- var GetPerpetualsMarketsOrdersRequestSchema = import_zod5.z.object({
409
- walletAddress: import_zod5.z.string().describe("User's wallet address")
410
- });
411
- var GetPerpetualsMarketsOrdersResponseSchema = import_zod5.z.object({
412
- orders: OrdersDataSchema
413
- });
414
- var ClosePerpetualsOrdersRequestSchema = import_zod5.z.object({
415
- walletAddress: import_zod5.z.string().describe("User's wallet address"),
416
- key: import_zod5.z.string()
417
- });
418
- var ClosePerpetualsOrdersResponseSchema = import_zod5.z.object({
419
- transactions: import_zod5.z.array(TransactionPlanSchema)
420
- });
421
- var GetPerpetualsMarketsRequestSchema = import_zod5.z.object({
422
- chainIds: import_zod5.z.array(import_zod5.z.string())
423
- });
424
- var PerpetualMarketSchema = import_zod5.z.object({
425
- marketToken: TokenIdentifierSchema,
426
- indexToken: TokenIdentifierSchema,
427
- longToken: TokenIdentifierSchema,
428
- shortToken: TokenIdentifierSchema,
429
- longFundingFee: import_zod5.z.string(),
430
- shortFundingFee: import_zod5.z.string(),
431
- longBorrowingFee: import_zod5.z.string(),
432
- shortBorrowingFee: import_zod5.z.string(),
433
- chainId: import_zod5.z.string(),
434
- name: import_zod5.z.string()
435
- });
436
- var GetPerpetualsMarketsResponseSchema = import_zod5.z.object({
437
- markets: import_zod5.z.array(PerpetualMarketSchema)
326
+ const ClosePerpetualsOrdersResponseSchema = zod.z.object({ transactions: zod.z.array(TransactionPlanSchema) });
327
+ const GetPerpetualsMarketsRequestSchema = zod.z.object({ chainIds: zod.z.array(zod.z.string()) });
328
+ const PerpetualMarketSchema = zod.z.object({
329
+ marketToken: TokenIdentifierSchema,
330
+ indexToken: TokenIdentifierSchema,
331
+ longToken: TokenIdentifierSchema,
332
+ shortToken: TokenIdentifierSchema,
333
+ longFundingFee: zod.z.string(),
334
+ shortFundingFee: zod.z.string(),
335
+ longBorrowingFee: zod.z.string(),
336
+ shortBorrowingFee: zod.z.string(),
337
+ chainId: zod.z.string(),
338
+ name: zod.z.string()
438
339
  });
340
+ const GetPerpetualsMarketsResponseSchema = zod.z.object({ markets: zod.z.array(PerpetualMarketSchema) });
439
341
 
440
- // src/core/schemas/swap.ts
441
- var import_zod6 = require("zod");
442
- var SwapTokensRequestSchema = import_zod6.z.object({
443
- fromToken: TokenSchema,
444
- toToken: TokenSchema,
445
- amount: import_zod6.z.bigint(),
446
- limitPrice: import_zod6.z.string().optional(),
447
- slippageTolerance: import_zod6.z.string().optional(),
448
- expiration: import_zod6.z.string().optional(),
449
- recipient: import_zod6.z.string()
342
+ //#endregion
343
+ //#region src/core/schemas/swap.ts
344
+ const SwapTokensRequestSchema = zod.z.object({
345
+ fromToken: TokenSchema,
346
+ toToken: TokenSchema,
347
+ amount: zod.z.bigint(),
348
+ limitPrice: zod.z.string().optional(),
349
+ slippageTolerance: zod.z.string().optional(),
350
+ expiration: zod.z.string().optional(),
351
+ recipient: zod.z.string()
450
352
  });
451
- var SwapTokensResponseSchema = import_zod6.z.object({
452
- fromToken: TokenSchema,
453
- toToken: TokenSchema,
454
- exactFromAmount: import_zod6.z.string(),
455
- displayFromAmount: import_zod6.z.string(),
456
- exactToAmount: import_zod6.z.string(),
457
- displayToAmount: import_zod6.z.string(),
458
- transactions: import_zod6.z.array(TransactionPlanSchema),
459
- feeBreakdown: FeeBreakdownSchema.optional(),
460
- estimation: SwapEstimationSchema.optional(),
461
- providerTracking: ProviderTrackingInfoSchema.optional()
353
+ const SwapTokensResponseSchema = zod.z.object({
354
+ fromToken: TokenSchema,
355
+ toToken: TokenSchema,
356
+ exactFromAmount: zod.z.string(),
357
+ displayFromAmount: zod.z.string(),
358
+ exactToAmount: zod.z.string(),
359
+ displayToAmount: zod.z.string(),
360
+ transactions: zod.z.array(TransactionPlanSchema),
361
+ feeBreakdown: FeeBreakdownSchema.optional(),
362
+ estimation: SwapEstimationSchema.optional(),
363
+ providerTracking: ProviderTrackingInfoSchema.optional()
462
364
  });
463
365
 
464
- // src/aave-lending-plugin/chain.ts
465
- var import_ethers = require("ethers");
366
+ //#endregion
367
+ //#region src/aave-lending-plugin/chain.ts
368
+ /**
369
+ * Represents a blockchain network configuration used to create JSON-RPC providers and
370
+ * hold basic chain-specific metadata.
371
+ *
372
+ * The Chain class encapsulates:
373
+ * - a numeric chain identifier (id),
374
+ * - an RPC URL to connect to the chain (rpcUrl),
375
+ * - an optional wrapped native token address (wrappedNativeTokenAddress).
376
+ *
377
+ * @param id - The numeric identifier for the chain (e.g., 1 for Ethereum mainnet).
378
+ * @param rpcUrl - The JSON-RPC endpoint URL used to create providers for this chain.
379
+ * @param wrappedNativeTokenAddress - Optional address of the chain's wrapped native token (if applicable).
380
+ */
466
381
  var Chain = class {
467
- constructor(id, rpcUrl, wrappedNativeTokenAddress) {
468
- this.id = id;
469
- this.rpcUrl = rpcUrl;
470
- this.wrappedNativeTokenAddress = wrappedNativeTokenAddress;
471
- }
472
- /**
473
- * Create and return an ethers.js JsonRpcProvider configured with this chain's RPC URL.
474
- *
475
- * This method constructs a new ethers.providers.JsonRpcProvider each time it is called.
476
- * Consumers may cache the provider if they intend to reuse it to avoid allocating multiple instances.
477
- *
478
- * @returns An instance of ethers.providers.JsonRpcProvider configured with the chain's rpcUrl.
479
- */
480
- getProvider() {
481
- return new import_ethers.ethers.providers.JsonRpcProvider(this.rpcUrl);
482
- }
382
+ constructor(id, rpcUrl, wrappedNativeTokenAddress) {
383
+ this.id = id;
384
+ this.rpcUrl = rpcUrl;
385
+ this.wrappedNativeTokenAddress = wrappedNativeTokenAddress;
386
+ }
387
+ /**
388
+ * Create and return an ethers.js JsonRpcProvider configured with this chain's RPC URL.
389
+ *
390
+ * This method constructs a new ethers.providers.JsonRpcProvider each time it is called.
391
+ * Consumers may cache the provider if they intend to reuse it to avoid allocating multiple instances.
392
+ *
393
+ * @returns An instance of ethers.providers.JsonRpcProvider configured with the chain's rpcUrl.
394
+ */
395
+ getProvider() {
396
+ return new ethers.ethers.providers.JsonRpcProvider(this.rpcUrl);
397
+ }
483
398
  };
484
399
 
485
- // src/aave-lending-plugin/dataProvider.ts
486
- var import_contract_helpers = require("@aave/contract-helpers");
487
- var UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN = {
488
- 11155111: import_contract_helpers.LegacyUiPoolDataProvider,
489
- 42161: import_contract_helpers.UiPoolDataProvider,
490
- 1: import_contract_helpers.UiPoolDataProvider
400
+ //#endregion
401
+ //#region src/aave-lending-plugin/dataProvider.ts
402
+ const UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN = {
403
+ 11155111: __aave_contract_helpers.LegacyUiPoolDataProvider,
404
+ 42161: __aave_contract_helpers.UiPoolDataProvider,
405
+ 1: __aave_contract_helpers.UiPoolDataProvider
491
406
  };
492
- var getUiPoolDataProviderImpl = (chainId) => {
493
- const res = UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN[chainId];
494
- if (!res) {
495
- throw new Error(
496
- "UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN does not contain this chain ID. Edit providers/aave/dataProvider.ts."
497
- );
498
- }
499
- return res;
407
+ const getUiPoolDataProviderImpl = (chainId) => {
408
+ const res = UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN[chainId];
409
+ if (!res) throw new Error("UI_POOL_DATA_PROVIDER_INTERFACE_PER_CHAIN does not contain this chain ID. Edit providers/aave/dataProvider.ts.");
410
+ return res;
500
411
  };
501
412
 
502
- // src/aave-lending-plugin/market.ts
503
- var markets = __toESM(require("@bgd-labs/aave-address-book"), 1);
504
- var marketMap = {
505
- 1: "AaveV3Ethereum",
506
- 11155111: "AaveV3Sepolia",
507
- 42161: "AaveV3Arbitrum",
508
- 421614: "AaveV3ArbitrumSepolia",
509
- 8453: "AaveV3Base",
510
- 137: "AaveV3Polygon",
511
- 10: "AaveV3Optimism"
413
+ //#endregion
414
+ //#region src/aave-lending-plugin/market.ts
415
+ const marketMap = {
416
+ 1: "AaveV3Ethereum",
417
+ 11155111: "AaveV3Sepolia",
418
+ 42161: "AaveV3Arbitrum",
419
+ 421614: "AaveV3ArbitrumSepolia",
420
+ 8453: "AaveV3Base",
421
+ 137: "AaveV3Polygon",
422
+ 10: "AaveV3Optimism"
512
423
  };
513
- var getMarket = (chainId) => {
514
- const marketKey = marketMap[chainId];
515
- if (!marketKey) {
516
- throw new Error(
517
- `AAVE: no market found for chain ID ${chainId}: modify providers/aave/market.ts`
518
- );
519
- }
520
- const market = markets[marketKey];
521
- if (!market) {
522
- throw new Error(`No such market: ${marketKey}`);
523
- }
524
- return market;
424
+ const getMarket = (chainId) => {
425
+ const marketKey = marketMap[chainId];
426
+ if (!marketKey) throw new Error(`AAVE: no market found for chain ID ${chainId}: modify providers/aave/market.ts`);
427
+ const market = __bgd_labs_aave_address_book[marketKey];
428
+ if (!market) throw new Error(`No such market: ${marketKey}`);
429
+ return market;
525
430
  };
526
431
 
527
- // src/aave-lending-plugin/populateTransaction.ts
528
- var import_ethers2 = require("ethers");
529
-
530
- // src/aave-lending-plugin/errors.ts
432
+ //#endregion
433
+ //#region src/aave-lending-plugin/errors.ts
531
434
  var AaveError = class extends Error {
532
- description;
533
- message;
534
- constructor(code, name, description) {
535
- const message = name + ` (${code}): ` + description;
536
- super(message);
537
- this.name = "AaveError";
538
- this.description = description;
539
- this.message = message;
540
- Object.setPrototypeOf(this, new.target.prototype);
541
- }
435
+ description;
436
+ message;
437
+ constructor(code, name, description) {
438
+ const message = name + ` (${code}): ` + description;
439
+ super(message);
440
+ this.name = "AaveError";
441
+ this.description = description;
442
+ this.message = message;
443
+ Object.setPrototypeOf(this, new.target.prototype);
444
+ }
542
445
  };
543
- var AAVE_ERROR_CODES = {
544
- "1": {
545
- name: "CALLER_NOT_POOL_ADMIN",
546
- description: "The caller of the function is not a pool admin"
547
- },
548
- "2": {
549
- name: "CALLER_NOT_EMERGENCY_ADMIN",
550
- description: "The caller of the function is not an emergency admin"
551
- },
552
- "3": {
553
- name: "CALLER_NOT_POOL_OR_EMERGENCY_ADMIN",
554
- description: "The caller of the function is not a pool or emergency admin"
555
- },
556
- "4": {
557
- name: "CALLER_NOT_RISK_OR_POOL_ADMIN",
558
- description: "The caller of the function is not a risk or pool admin"
559
- },
560
- "5": {
561
- name: "CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN",
562
- description: "The caller of the function is not an asset listing or pool admin"
563
- },
564
- "6": {
565
- name: "CALLER_NOT_BRIDGE",
566
- description: "The caller of the function is not a bridge"
567
- },
568
- "7": {
569
- name: "ADDRESSES_PROVIDER_NOT_REGISTERED",
570
- description: "Pool addresses provider is not registered"
571
- },
572
- "8": {
573
- name: "INVALID_ADDRESSES_PROVIDER_ID",
574
- description: "Invalid id for the pool addresses provider"
575
- },
576
- "9": { name: "NOT_CONTRACT", description: "Address is not a contract" },
577
- "10": {
578
- name: "CALLER_NOT_POOL_CONFIGURATOR",
579
- description: "The caller of the function is not the pool configurator"
580
- },
581
- "11": {
582
- name: "CALLER_NOT_ATOKEN",
583
- description: "The caller of the function is not an AToken"
584
- },
585
- "12": {
586
- name: "INVALID_ADDRESSES_PROVIDER",
587
- description: "The address of the pool addresses provider is invalid"
588
- },
589
- "13": {
590
- name: "INVALID_FLASHLOAN_EXECUTOR_RETURN",
591
- description: "Invalid return value of the flashloan executor function"
592
- },
593
- "14": {
594
- name: "RESERVE_ALREADY_ADDED",
595
- description: "Reserve has already been added to reserve list"
596
- },
597
- "15": {
598
- name: "NO_MORE_RESERVES_ALLOWED",
599
- description: "Maximum amount of reserves in the pool reached"
600
- },
601
- "16": {
602
- name: "EMODE_CATEGORY_RESERVED",
603
- description: "Zero eMode category is reserved for volatile heterogeneous assets"
604
- },
605
- "17": {
606
- name: "INVALID_EMODE_CATEGORY_ASSIGNMENT",
607
- description: "Invalid eMode category assignment to asset"
608
- },
609
- "18": {
610
- name: "RESERVE_LIQUIDITY_NOT_ZERO",
611
- description: "The liquidity of the reserve needs to be 0"
612
- },
613
- "19": {
614
- name: "FLASHLOAN_PREMIUM_INVALID",
615
- description: "Invalid flashloan premium"
616
- },
617
- "20": {
618
- name: "INVALID_RESERVE_PARAMS",
619
- description: "Invalid risk parameters for the reserve"
620
- },
621
- "21": {
622
- name: "INVALID_EMODE_CATEGORY_PARAMS",
623
- description: "Invalid risk parameters for the eMode category"
624
- },
625
- "22": {
626
- name: "BRIDGE_PROTOCOL_FEE_INVALID",
627
- description: "Invalid bridge protocol fee"
628
- },
629
- "23": {
630
- name: "CALLER_MUST_BE_POOL",
631
- description: "The caller of this function must be a pool"
632
- },
633
- "24": { name: "INVALID_MINT_AMOUNT", description: "Invalid amount to mint" },
634
- "25": { name: "INVALID_BURN_AMOUNT", description: "Invalid amount to burn" },
635
- "26": {
636
- name: "INVALID_AMOUNT",
637
- description: "Amount must be greater than 0"
638
- },
639
- "27": {
640
- name: "RESERVE_INACTIVE",
641
- description: "Action requires an active reserve"
642
- },
643
- "28": {
644
- name: "RESERVE_FROZEN",
645
- description: "Action cannot be performed because the reserve is frozen"
646
- },
647
- "29": {
648
- name: "RESERVE_PAUSED",
649
- description: "Action cannot be performed because the reserve is paused"
650
- },
651
- "30": {
652
- name: "BORROWING_NOT_ENABLED",
653
- description: "Borrowing is not enabled"
654
- },
655
- "32": {
656
- name: "NOT_ENOUGH_AVAILABLE_USER_BALANCE",
657
- description: "User cannot withdraw more than the available balance"
658
- },
659
- "33": {
660
- name: "INVALID_INTEREST_RATE_MODE_SELECTED",
661
- description: "Invalid interest rate mode selected"
662
- },
663
- "34": {
664
- name: "COLLATERAL_BALANCE_IS_ZERO",
665
- description: "The collateral balance is 0"
666
- },
667
- "35": {
668
- name: "HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD",
669
- description: "Health factor is lesser than the liquidation threshold"
670
- },
671
- "36": {
672
- name: "COLLATERAL_CANNOT_COVER_NEW_BORROW",
673
- description: "There is not enough collateral to cover a new borrow"
674
- },
675
- "37": {
676
- name: "COLLATERAL_SAME_AS_BORROWING_CURRENCY",
677
- description: "Collateral is (mostly) the same currency that is being borrowed"
678
- },
679
- "39": {
680
- name: "NO_DEBT_OF_SELECTED_TYPE",
681
- description: "For repayment of a specific type of debt, the user needs to have debt that type"
682
- },
683
- "40": {
684
- name: "NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF",
685
- description: "To repay on behalf of a user an explicit amount to repay is needed"
686
- },
687
- "42": {
688
- name: "NO_OUTSTANDING_VARIABLE_DEBT",
689
- description: "User does not have outstanding variable rate debt on this reserve"
690
- },
691
- "43": {
692
- name: "UNDERLYING_BALANCE_ZERO",
693
- description: "The underlying balance needs to be greater than 0"
694
- },
695
- "44": {
696
- name: "INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET",
697
- description: "Interest rate rebalance conditions were not met"
698
- },
699
- "45": {
700
- name: "HEALTH_FACTOR_NOT_BELOW_THRESHOLD",
701
- description: "Health factor is not below the threshold"
702
- },
703
- "46": {
704
- name: "COLLATERAL_CANNOT_BE_LIQUIDATED",
705
- description: "The collateral chosen cannot be liquidated"
706
- },
707
- "47": {
708
- name: "SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER",
709
- description: "User did not borrow the specified currency"
710
- },
711
- "49": {
712
- name: "INCONSISTENT_FLASHLOAN_PARAMS",
713
- description: "Inconsistent flashloan parameters"
714
- },
715
- "50": { name: "BORROW_CAP_EXCEEDED", description: "Borrow cap is exceeded" },
716
- "51": { name: "SUPPLY_CAP_EXCEEDED", description: "Supply cap is exceeded" },
717
- "52": {
718
- name: "UNBACKED_MINT_CAP_EXCEEDED",
719
- description: "Unbacked mint cap is exceeded"
720
- },
721
- "53": {
722
- name: "DEBT_CEILING_EXCEEDED",
723
- description: "Debt ceiling is exceeded"
724
- },
725
- "54": {
726
- name: "UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO",
727
- description: "Claimable rights over underlying not zero (aToken supply or accruedToTreasury)"
728
- },
729
- "56": {
730
- name: "VARIABLE_DEBT_SUPPLY_NOT_ZERO",
731
- description: "Variable debt supply is not zero"
732
- },
733
- "57": { name: "LTV_VALIDATION_FAILED", description: "Ltv validation failed" },
734
- "58": {
735
- name: "INCONSISTENT_EMODE_CATEGORY",
736
- description: "Inconsistent eMode category"
737
- },
738
- "59": {
739
- name: "PRICE_ORACLE_SENTINEL_CHECK_FAILED",
740
- description: "Price oracle sentinel validation failed"
741
- },
742
- "60": {
743
- name: "ASSET_NOT_BORROWABLE_IN_ISOLATION",
744
- description: "Asset is not borrowable in isolation mode"
745
- },
746
- "61": {
747
- name: "RESERVE_ALREADY_INITIALIZED",
748
- description: "Reserve has already been initialized"
749
- },
750
- "62": {
751
- name: "USER_IN_ISOLATION_MODE_OR_LTV_ZERO",
752
- description: "User is in isolation mode or ltv is zero"
753
- },
754
- "63": {
755
- name: "INVALID_LTV",
756
- description: "Invalid ltv parameter for the reserve"
757
- },
758
- "64": {
759
- name: "INVALID_LIQ_THRESHOLD",
760
- description: "Invalid liquidity threshold parameter for the reserve"
761
- },
762
- "65": {
763
- name: "INVALID_LIQ_BONUS",
764
- description: "Invalid liquidity bonus parameter for the reserve"
765
- },
766
- "66": {
767
- name: "INVALID_DECIMALS",
768
- description: "Invalid decimals parameter of the underlying asset of the reserve"
769
- },
770
- "67": {
771
- name: "INVALID_RESERVE_FACTOR",
772
- description: "Invalid reserve factor parameter for the reserve"
773
- },
774
- "68": {
775
- name: "INVALID_BORROW_CAP",
776
- description: "Invalid borrow cap for the reserve"
777
- },
778
- "69": {
779
- name: "INVALID_SUPPLY_CAP",
780
- description: "Invalid supply cap for the reserve"
781
- },
782
- "70": {
783
- name: "INVALID_LIQUIDATION_PROTOCOL_FEE",
784
- description: "Invalid liquidation protocol fee for the reserve"
785
- },
786
- "71": {
787
- name: "INVALID_EMODE_CATEGORY",
788
- description: "Invalid eMode category for the reserve"
789
- },
790
- "72": {
791
- name: "INVALID_UNBACKED_MINT_CAP",
792
- description: "Invalid unbacked mint cap for the reserve"
793
- },
794
- "73": {
795
- name: "INVALID_DEBT_CEILING",
796
- description: "Invalid debt ceiling for the reserve"
797
- },
798
- "74": { name: "INVALID_RESERVE_INDEX", description: "Invalid reserve index" },
799
- "75": {
800
- name: "ACL_ADMIN_CANNOT_BE_ZERO",
801
- description: "ACL admin cannot be set to the zero address"
802
- },
803
- "76": {
804
- name: "INCONSISTENT_PARAMS_LENGTH",
805
- description: "Array parameters that should be equal length are not"
806
- },
807
- "77": {
808
- name: "ZERO_ADDRESS_NOT_VALID",
809
- description: "Zero address not valid"
810
- },
811
- "78": { name: "INVALID_EXPIRATION", description: "Invalid expiration" },
812
- "79": { name: "INVALID_SIGNATURE", description: "Invalid signature" },
813
- "80": {
814
- name: "OPERATION_NOT_SUPPORTED",
815
- description: "Operation not supported"
816
- },
817
- "81": {
818
- name: "DEBT_CEILING_NOT_ZERO",
819
- description: "Debt ceiling is not zero"
820
- },
821
- "82": { name: "ASSET_NOT_LISTED", description: "Asset is not listed" },
822
- "83": {
823
- name: "INVALID_OPTIMAL_USAGE_RATIO",
824
- description: "Invalid optimal usage ratio"
825
- },
826
- "85": {
827
- name: "UNDERLYING_CANNOT_BE_RESCUED",
828
- description: "The underlying asset cannot be rescued"
829
- },
830
- "86": {
831
- name: "ADDRESSES_PROVIDER_ALREADY_ADDED",
832
- description: "Reserve has already been added to reserve list"
833
- },
834
- "87": {
835
- name: "POOL_ADDRESSES_DO_NOT_MATCH",
836
- description: "The token implementation pool address and the pool address provided by the initializing pool do not match"
837
- },
838
- "89": {
839
- name: "SILOED_BORROWING_VIOLATION",
840
- description: "User is trying to borrow multiple assets including a siloed one"
841
- },
842
- "90": {
843
- name: "RESERVE_DEBT_NOT_ZERO",
844
- description: "The total debt of the reserve needs to be 0"
845
- },
846
- "91": {
847
- name: "FLASHLOAN_DISABLED",
848
- description: "FlashLoaning for this asset is disabled"
849
- },
850
- "92": {
851
- name: "INVALID_MAX_RATE",
852
- description: "The expect maximum borrow rate is invalid"
853
- },
854
- "93": {
855
- name: "WITHDRAW_TO_ATOKEN",
856
- description: "Withdrawing to the aToken is not allowed"
857
- },
858
- "94": {
859
- name: "SUPPLY_TO_ATOKEN",
860
- description: "Supplying to the aToken is not allowed"
861
- },
862
- "95": {
863
- name: "SLOPE_2_MUST_BE_GTE_SLOPE_1",
864
- description: "Variable interest rate slope 2 can not be lower than slope 1"
865
- },
866
- "96": {
867
- name: "CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN",
868
- description: "The caller of the function is not a risk, pool or emergency admin"
869
- },
870
- "97": {
871
- name: "LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED",
872
- description: "Liquidation grace sentinel validation failed"
873
- },
874
- "98": {
875
- name: "INVALID_GRACE_PERIOD",
876
- description: "Grace period above a valid range"
877
- },
878
- "99": {
879
- name: "INVALID_FREEZE_STATE",
880
- description: "Reserve is already in the passed freeze state"
881
- },
882
- "100": {
883
- name: "NOT_BORROWABLE_IN_EMODE",
884
- description: "Asset not borrowable in eMode"
885
- }
446
+ const AAVE_ERROR_CODES = {
447
+ "1": {
448
+ name: "CALLER_NOT_POOL_ADMIN",
449
+ description: "The caller of the function is not a pool admin"
450
+ },
451
+ "2": {
452
+ name: "CALLER_NOT_EMERGENCY_ADMIN",
453
+ description: "The caller of the function is not an emergency admin"
454
+ },
455
+ "3": {
456
+ name: "CALLER_NOT_POOL_OR_EMERGENCY_ADMIN",
457
+ description: "The caller of the function is not a pool or emergency admin"
458
+ },
459
+ "4": {
460
+ name: "CALLER_NOT_RISK_OR_POOL_ADMIN",
461
+ description: "The caller of the function is not a risk or pool admin"
462
+ },
463
+ "5": {
464
+ name: "CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN",
465
+ description: "The caller of the function is not an asset listing or pool admin"
466
+ },
467
+ "6": {
468
+ name: "CALLER_NOT_BRIDGE",
469
+ description: "The caller of the function is not a bridge"
470
+ },
471
+ "7": {
472
+ name: "ADDRESSES_PROVIDER_NOT_REGISTERED",
473
+ description: "Pool addresses provider is not registered"
474
+ },
475
+ "8": {
476
+ name: "INVALID_ADDRESSES_PROVIDER_ID",
477
+ description: "Invalid id for the pool addresses provider"
478
+ },
479
+ "9": {
480
+ name: "NOT_CONTRACT",
481
+ description: "Address is not a contract"
482
+ },
483
+ "10": {
484
+ name: "CALLER_NOT_POOL_CONFIGURATOR",
485
+ description: "The caller of the function is not the pool configurator"
486
+ },
487
+ "11": {
488
+ name: "CALLER_NOT_ATOKEN",
489
+ description: "The caller of the function is not an AToken"
490
+ },
491
+ "12": {
492
+ name: "INVALID_ADDRESSES_PROVIDER",
493
+ description: "The address of the pool addresses provider is invalid"
494
+ },
495
+ "13": {
496
+ name: "INVALID_FLASHLOAN_EXECUTOR_RETURN",
497
+ description: "Invalid return value of the flashloan executor function"
498
+ },
499
+ "14": {
500
+ name: "RESERVE_ALREADY_ADDED",
501
+ description: "Reserve has already been added to reserve list"
502
+ },
503
+ "15": {
504
+ name: "NO_MORE_RESERVES_ALLOWED",
505
+ description: "Maximum amount of reserves in the pool reached"
506
+ },
507
+ "16": {
508
+ name: "EMODE_CATEGORY_RESERVED",
509
+ description: "Zero eMode category is reserved for volatile heterogeneous assets"
510
+ },
511
+ "17": {
512
+ name: "INVALID_EMODE_CATEGORY_ASSIGNMENT",
513
+ description: "Invalid eMode category assignment to asset"
514
+ },
515
+ "18": {
516
+ name: "RESERVE_LIQUIDITY_NOT_ZERO",
517
+ description: "The liquidity of the reserve needs to be 0"
518
+ },
519
+ "19": {
520
+ name: "FLASHLOAN_PREMIUM_INVALID",
521
+ description: "Invalid flashloan premium"
522
+ },
523
+ "20": {
524
+ name: "INVALID_RESERVE_PARAMS",
525
+ description: "Invalid risk parameters for the reserve"
526
+ },
527
+ "21": {
528
+ name: "INVALID_EMODE_CATEGORY_PARAMS",
529
+ description: "Invalid risk parameters for the eMode category"
530
+ },
531
+ "22": {
532
+ name: "BRIDGE_PROTOCOL_FEE_INVALID",
533
+ description: "Invalid bridge protocol fee"
534
+ },
535
+ "23": {
536
+ name: "CALLER_MUST_BE_POOL",
537
+ description: "The caller of this function must be a pool"
538
+ },
539
+ "24": {
540
+ name: "INVALID_MINT_AMOUNT",
541
+ description: "Invalid amount to mint"
542
+ },
543
+ "25": {
544
+ name: "INVALID_BURN_AMOUNT",
545
+ description: "Invalid amount to burn"
546
+ },
547
+ "26": {
548
+ name: "INVALID_AMOUNT",
549
+ description: "Amount must be greater than 0"
550
+ },
551
+ "27": {
552
+ name: "RESERVE_INACTIVE",
553
+ description: "Action requires an active reserve"
554
+ },
555
+ "28": {
556
+ name: "RESERVE_FROZEN",
557
+ description: "Action cannot be performed because the reserve is frozen"
558
+ },
559
+ "29": {
560
+ name: "RESERVE_PAUSED",
561
+ description: "Action cannot be performed because the reserve is paused"
562
+ },
563
+ "30": {
564
+ name: "BORROWING_NOT_ENABLED",
565
+ description: "Borrowing is not enabled"
566
+ },
567
+ "32": {
568
+ name: "NOT_ENOUGH_AVAILABLE_USER_BALANCE",
569
+ description: "User cannot withdraw more than the available balance"
570
+ },
571
+ "33": {
572
+ name: "INVALID_INTEREST_RATE_MODE_SELECTED",
573
+ description: "Invalid interest rate mode selected"
574
+ },
575
+ "34": {
576
+ name: "COLLATERAL_BALANCE_IS_ZERO",
577
+ description: "The collateral balance is 0"
578
+ },
579
+ "35": {
580
+ name: "HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD",
581
+ description: "Health factor is lesser than the liquidation threshold"
582
+ },
583
+ "36": {
584
+ name: "COLLATERAL_CANNOT_COVER_NEW_BORROW",
585
+ description: "There is not enough collateral to cover a new borrow"
586
+ },
587
+ "37": {
588
+ name: "COLLATERAL_SAME_AS_BORROWING_CURRENCY",
589
+ description: "Collateral is (mostly) the same currency that is being borrowed"
590
+ },
591
+ "39": {
592
+ name: "NO_DEBT_OF_SELECTED_TYPE",
593
+ description: "For repayment of a specific type of debt, the user needs to have debt that type"
594
+ },
595
+ "40": {
596
+ name: "NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF",
597
+ description: "To repay on behalf of a user an explicit amount to repay is needed"
598
+ },
599
+ "42": {
600
+ name: "NO_OUTSTANDING_VARIABLE_DEBT",
601
+ description: "User does not have outstanding variable rate debt on this reserve"
602
+ },
603
+ "43": {
604
+ name: "UNDERLYING_BALANCE_ZERO",
605
+ description: "The underlying balance needs to be greater than 0"
606
+ },
607
+ "44": {
608
+ name: "INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET",
609
+ description: "Interest rate rebalance conditions were not met"
610
+ },
611
+ "45": {
612
+ name: "HEALTH_FACTOR_NOT_BELOW_THRESHOLD",
613
+ description: "Health factor is not below the threshold"
614
+ },
615
+ "46": {
616
+ name: "COLLATERAL_CANNOT_BE_LIQUIDATED",
617
+ description: "The collateral chosen cannot be liquidated"
618
+ },
619
+ "47": {
620
+ name: "SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER",
621
+ description: "User did not borrow the specified currency"
622
+ },
623
+ "49": {
624
+ name: "INCONSISTENT_FLASHLOAN_PARAMS",
625
+ description: "Inconsistent flashloan parameters"
626
+ },
627
+ "50": {
628
+ name: "BORROW_CAP_EXCEEDED",
629
+ description: "Borrow cap is exceeded"
630
+ },
631
+ "51": {
632
+ name: "SUPPLY_CAP_EXCEEDED",
633
+ description: "Supply cap is exceeded"
634
+ },
635
+ "52": {
636
+ name: "UNBACKED_MINT_CAP_EXCEEDED",
637
+ description: "Unbacked mint cap is exceeded"
638
+ },
639
+ "53": {
640
+ name: "DEBT_CEILING_EXCEEDED",
641
+ description: "Debt ceiling is exceeded"
642
+ },
643
+ "54": {
644
+ name: "UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO",
645
+ description: "Claimable rights over underlying not zero (aToken supply or accruedToTreasury)"
646
+ },
647
+ "56": {
648
+ name: "VARIABLE_DEBT_SUPPLY_NOT_ZERO",
649
+ description: "Variable debt supply is not zero"
650
+ },
651
+ "57": {
652
+ name: "LTV_VALIDATION_FAILED",
653
+ description: "Ltv validation failed"
654
+ },
655
+ "58": {
656
+ name: "INCONSISTENT_EMODE_CATEGORY",
657
+ description: "Inconsistent eMode category"
658
+ },
659
+ "59": {
660
+ name: "PRICE_ORACLE_SENTINEL_CHECK_FAILED",
661
+ description: "Price oracle sentinel validation failed"
662
+ },
663
+ "60": {
664
+ name: "ASSET_NOT_BORROWABLE_IN_ISOLATION",
665
+ description: "Asset is not borrowable in isolation mode"
666
+ },
667
+ "61": {
668
+ name: "RESERVE_ALREADY_INITIALIZED",
669
+ description: "Reserve has already been initialized"
670
+ },
671
+ "62": {
672
+ name: "USER_IN_ISOLATION_MODE_OR_LTV_ZERO",
673
+ description: "User is in isolation mode or ltv is zero"
674
+ },
675
+ "63": {
676
+ name: "INVALID_LTV",
677
+ description: "Invalid ltv parameter for the reserve"
678
+ },
679
+ "64": {
680
+ name: "INVALID_LIQ_THRESHOLD",
681
+ description: "Invalid liquidity threshold parameter for the reserve"
682
+ },
683
+ "65": {
684
+ name: "INVALID_LIQ_BONUS",
685
+ description: "Invalid liquidity bonus parameter for the reserve"
686
+ },
687
+ "66": {
688
+ name: "INVALID_DECIMALS",
689
+ description: "Invalid decimals parameter of the underlying asset of the reserve"
690
+ },
691
+ "67": {
692
+ name: "INVALID_RESERVE_FACTOR",
693
+ description: "Invalid reserve factor parameter for the reserve"
694
+ },
695
+ "68": {
696
+ name: "INVALID_BORROW_CAP",
697
+ description: "Invalid borrow cap for the reserve"
698
+ },
699
+ "69": {
700
+ name: "INVALID_SUPPLY_CAP",
701
+ description: "Invalid supply cap for the reserve"
702
+ },
703
+ "70": {
704
+ name: "INVALID_LIQUIDATION_PROTOCOL_FEE",
705
+ description: "Invalid liquidation protocol fee for the reserve"
706
+ },
707
+ "71": {
708
+ name: "INVALID_EMODE_CATEGORY",
709
+ description: "Invalid eMode category for the reserve"
710
+ },
711
+ "72": {
712
+ name: "INVALID_UNBACKED_MINT_CAP",
713
+ description: "Invalid unbacked mint cap for the reserve"
714
+ },
715
+ "73": {
716
+ name: "INVALID_DEBT_CEILING",
717
+ description: "Invalid debt ceiling for the reserve"
718
+ },
719
+ "74": {
720
+ name: "INVALID_RESERVE_INDEX",
721
+ description: "Invalid reserve index"
722
+ },
723
+ "75": {
724
+ name: "ACL_ADMIN_CANNOT_BE_ZERO",
725
+ description: "ACL admin cannot be set to the zero address"
726
+ },
727
+ "76": {
728
+ name: "INCONSISTENT_PARAMS_LENGTH",
729
+ description: "Array parameters that should be equal length are not"
730
+ },
731
+ "77": {
732
+ name: "ZERO_ADDRESS_NOT_VALID",
733
+ description: "Zero address not valid"
734
+ },
735
+ "78": {
736
+ name: "INVALID_EXPIRATION",
737
+ description: "Invalid expiration"
738
+ },
739
+ "79": {
740
+ name: "INVALID_SIGNATURE",
741
+ description: "Invalid signature"
742
+ },
743
+ "80": {
744
+ name: "OPERATION_NOT_SUPPORTED",
745
+ description: "Operation not supported"
746
+ },
747
+ "81": {
748
+ name: "DEBT_CEILING_NOT_ZERO",
749
+ description: "Debt ceiling is not zero"
750
+ },
751
+ "82": {
752
+ name: "ASSET_NOT_LISTED",
753
+ description: "Asset is not listed"
754
+ },
755
+ "83": {
756
+ name: "INVALID_OPTIMAL_USAGE_RATIO",
757
+ description: "Invalid optimal usage ratio"
758
+ },
759
+ "85": {
760
+ name: "UNDERLYING_CANNOT_BE_RESCUED",
761
+ description: "The underlying asset cannot be rescued"
762
+ },
763
+ "86": {
764
+ name: "ADDRESSES_PROVIDER_ALREADY_ADDED",
765
+ description: "Reserve has already been added to reserve list"
766
+ },
767
+ "87": {
768
+ name: "POOL_ADDRESSES_DO_NOT_MATCH",
769
+ description: "The token implementation pool address and the pool address provided by the initializing pool do not match"
770
+ },
771
+ "89": {
772
+ name: "SILOED_BORROWING_VIOLATION",
773
+ description: "User is trying to borrow multiple assets including a siloed one"
774
+ },
775
+ "90": {
776
+ name: "RESERVE_DEBT_NOT_ZERO",
777
+ description: "The total debt of the reserve needs to be 0"
778
+ },
779
+ "91": {
780
+ name: "FLASHLOAN_DISABLED",
781
+ description: "FlashLoaning for this asset is disabled"
782
+ },
783
+ "92": {
784
+ name: "INVALID_MAX_RATE",
785
+ description: "The expect maximum borrow rate is invalid"
786
+ },
787
+ "93": {
788
+ name: "WITHDRAW_TO_ATOKEN",
789
+ description: "Withdrawing to the aToken is not allowed"
790
+ },
791
+ "94": {
792
+ name: "SUPPLY_TO_ATOKEN",
793
+ description: "Supplying to the aToken is not allowed"
794
+ },
795
+ "95": {
796
+ name: "SLOPE_2_MUST_BE_GTE_SLOPE_1",
797
+ description: "Variable interest rate slope 2 can not be lower than slope 1"
798
+ },
799
+ "96": {
800
+ name: "CALLER_NOT_RISK_OR_POOL_OR_EMERGENCY_ADMIN",
801
+ description: "The caller of the function is not a risk, pool or emergency admin"
802
+ },
803
+ "97": {
804
+ name: "LIQUIDATION_GRACE_SENTINEL_CHECK_FAILED",
805
+ description: "Liquidation grace sentinel validation failed"
806
+ },
807
+ "98": {
808
+ name: "INVALID_GRACE_PERIOD",
809
+ description: "Grace period above a valid range"
810
+ },
811
+ "99": {
812
+ name: "INVALID_FREEZE_STATE",
813
+ description: "Reserve is already in the passed freeze state"
814
+ },
815
+ "100": {
816
+ name: "NOT_BORROWABLE_IN_EMODE",
817
+ description: "Asset not borrowable in eMode"
818
+ }
886
819
  };
887
820
  function getAaveError(code) {
888
- const err = AAVE_ERROR_CODES[code];
889
- if (err) {
890
- return new AaveError(code, err.name, err.description);
891
- }
892
- return null;
821
+ const err = AAVE_ERROR_CODES[code];
822
+ if (err) return new AaveError(code, err.name, err.description);
823
+ return null;
893
824
  }
894
825
 
895
- // src/aave-lending-plugin/populateTransaction.ts
826
+ //#endregion
827
+ //#region src/aave-lending-plugin/populateTransaction.ts
896
828
  async function populateTransaction(tx) {
897
- let txData = null;
898
- try {
899
- txData = await tx.tx();
900
- } catch (unknownError) {
901
- const reason = typeof unknownError === "object" && unknownError !== null && "reason" in unknownError && typeof unknownError.reason === "string" ? unknownError.reason : "";
902
- const errorCode = reason.split(" ").pop();
903
- const aaveError = getAaveError(errorCode);
904
- if (aaveError !== null) {
905
- throw aaveError;
906
- } else {
907
- throw unknownError;
908
- }
909
- }
910
- if (!txData) {
911
- throw new Error("Failed to populate transaction");
912
- }
913
- return {
914
- value: import_ethers2.ethers.BigNumber.from(txData.value ?? 0),
915
- from: txData.from,
916
- to: txData.to,
917
- data: txData.data
918
- };
829
+ let txData = null;
830
+ try {
831
+ txData = await tx.tx();
832
+ } catch (unknownError) {
833
+ const aaveError = getAaveError((typeof unknownError === "object" && unknownError !== null && "reason" in unknownError && typeof unknownError.reason === "string" ? unknownError.reason : "").split(" ").pop());
834
+ if (aaveError !== null) throw aaveError;
835
+ else throw unknownError;
836
+ }
837
+ if (!txData) throw new Error("Failed to populate transaction");
838
+ return {
839
+ value: ethers.ethers.BigNumber.from(txData.value ?? 0),
840
+ from: txData.from,
841
+ to: txData.to,
842
+ data: txData.data
843
+ };
919
844
  }
920
845
 
921
- // src/aave-lending-plugin/userSummary.ts
922
- var import_math_utils = require("@aave/math-utils");
846
+ //#endregion
847
+ //#region src/aave-lending-plugin/userSummary.ts
923
848
  function formatNumeric(value) {
924
- const num = parseFloat(value);
925
- if (Number.isInteger(num)) return num.toString();
926
- return parseFloat(num.toFixed(2)).toString();
849
+ const num = parseFloat(value);
850
+ if (Number.isInteger(num)) return num.toString();
851
+ return parseFloat(num.toFixed(2)).toString();
927
852
  }
928
853
  var UserSummary = class {
929
- reserves;
930
- /**
931
- * @param userReservesResponse - The response from getUserReservesHumanized.
932
- * @param reservesResponse - The response from getReservesHumanized.
933
- */
934
- constructor(userReservesResponse, reservesResponse) {
935
- const currentTimestamp = Date.now() / 1e3;
936
- const formattedReserves = (0, import_math_utils.formatReserves)({
937
- reserves: reservesResponse.reservesData,
938
- currentTimestamp,
939
- marketReferenceCurrencyDecimals: reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,
940
- marketReferencePriceInUsd: reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd
941
- });
942
- this.reserves = (0, import_math_utils.formatUserSummary)({
943
- currentTimestamp,
944
- marketReferencePriceInUsd: reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,
945
- marketReferenceCurrencyDecimals: reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,
946
- userReserves: userReservesResponse.userReserves,
947
- formattedReserves,
948
- userEmodeCategoryId: userReservesResponse.userEmodeCategoryId
949
- });
950
- }
951
- toHumanReadable() {
952
- let output = "User Positions:\n";
953
- output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}
954
- `;
955
- output += `Total Collateral (USD): ${formatNumeric(this.reserves.totalCollateralUSD)}
956
- `;
957
- output += `Total Borrows (USD): ${formatNumeric(this.reserves.totalBorrowsUSD)}
958
- `;
959
- output += `Net Worth (USD): ${formatNumeric(this.reserves.netWorthUSD)}
960
- `;
961
- output += `Health Factor: ${formatNumeric(this.reserves.healthFactor)}
962
-
963
- `;
964
- output += "Deposits:\n";
965
- for (const entry of this.reserves.userReservesData) {
966
- if (parseFloat(entry.scaledATokenBalance) > 0) {
967
- const underlying = entry.underlyingBalance;
968
- const underlyingUSD = entry.underlyingBalanceUSD ? formatNumeric(entry.underlyingBalanceUSD) : "N/A";
969
- output += `- ${entry.reserve.symbol}: ${underlying} (USD: ${underlyingUSD})
970
- `;
971
- }
972
- }
973
- output += "\nLoans:\n";
974
- for (const entry of this.reserves.userReservesData) {
975
- const borrow = entry.totalBorrows || "0";
976
- if (parseFloat(borrow) > 0) {
977
- const totalBorrows = entry.totalBorrows;
978
- const totalBorrowsUSD = entry.totalBorrowsUSD ? formatNumeric(entry.totalBorrowsUSD) : "N/A";
979
- output += `- ${entry.reserve.symbol}: ${totalBorrows} (USD: ${totalBorrowsUSD})
980
- `;
981
- }
982
- }
983
- return output;
984
- }
854
+ reserves;
855
+ /**
856
+ * @param userReservesResponse - The response from getUserReservesHumanized.
857
+ * @param reservesResponse - The response from getReservesHumanized.
858
+ */
859
+ constructor(userReservesResponse, reservesResponse) {
860
+ const currentTimestamp = Date.now() / 1e3;
861
+ const formattedReserves = (0, __aave_math_utils.formatReserves)({
862
+ reserves: reservesResponse.reservesData,
863
+ currentTimestamp,
864
+ marketReferenceCurrencyDecimals: reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,
865
+ marketReferencePriceInUsd: reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd
866
+ });
867
+ this.reserves = (0, __aave_math_utils.formatUserSummary)({
868
+ currentTimestamp,
869
+ marketReferencePriceInUsd: reservesResponse.baseCurrencyData.marketReferenceCurrencyPriceInUsd,
870
+ marketReferenceCurrencyDecimals: reservesResponse.baseCurrencyData.marketReferenceCurrencyDecimals,
871
+ userReserves: userReservesResponse.userReserves,
872
+ formattedReserves,
873
+ userEmodeCategoryId: userReservesResponse.userEmodeCategoryId
874
+ });
875
+ }
876
+ toHumanReadable() {
877
+ let output = "User Positions:\n";
878
+ output += `Total Liquidity (USD): ${formatNumeric(this.reserves.totalLiquidityUSD)}\n`;
879
+ output += `Total Collateral (USD): ${formatNumeric(this.reserves.totalCollateralUSD)}\n`;
880
+ output += `Total Borrows (USD): ${formatNumeric(this.reserves.totalBorrowsUSD)}\n`;
881
+ output += `Net Worth (USD): ${formatNumeric(this.reserves.netWorthUSD)}\n`;
882
+ output += `Health Factor: ${formatNumeric(this.reserves.healthFactor)}\n\n`;
883
+ output += "Deposits:\n";
884
+ for (const entry of this.reserves.userReservesData) if (parseFloat(entry.scaledATokenBalance) > 0) {
885
+ const underlying = entry.underlyingBalance;
886
+ const underlyingUSD = entry.underlyingBalanceUSD ? formatNumeric(entry.underlyingBalanceUSD) : "N/A";
887
+ output += `- ${entry.reserve.symbol}: ${underlying} (USD: ${underlyingUSD})\n`;
888
+ }
889
+ output += "\nLoans:\n";
890
+ for (const entry of this.reserves.userReservesData) {
891
+ const borrow = entry.totalBorrows || "0";
892
+ if (parseFloat(borrow) > 0) {
893
+ const totalBorrows = entry.totalBorrows;
894
+ const totalBorrowsUSD = entry.totalBorrowsUSD ? formatNumeric(entry.totalBorrowsUSD) : "N/A";
895
+ output += `- ${entry.reserve.symbol}: ${totalBorrows} (USD: ${totalBorrowsUSD})\n`;
896
+ }
897
+ }
898
+ return output;
899
+ }
985
900
  };
986
901
 
987
- // src/aave-lending-plugin/adapter.ts
988
- var AAVE_ETH_PLACEHOLDER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
902
+ //#endregion
903
+ //#region src/aave-lending-plugin/adapter.ts
904
+ const AAVE_ETH_PLACEHOLDER = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
905
+ /**
906
+ * AAVEAdapter is the primary class wrapping Aave V3 interactions.
907
+ */
989
908
  var AAVEAdapter = class {
990
- chain;
991
- market;
992
- constructor(params) {
993
- this.chain = new Chain(params.chainId, params.rpcUrl);
994
- this.market = getMarket(this.chain.id);
995
- }
996
- /**
997
- * If the token is native, return AAVE's placeholder address instead of the ember address.
998
- * @param token - The token to normalize.
999
- * @returns The normalized token address.
1000
- */
1001
- normalizeTokenAddress(token) {
1002
- return token.isNative ? AAVE_ETH_PLACEHOLDER : token.tokenUid.address;
1003
- }
1004
- async createSupplyTransaction(params) {
1005
- const { supplyToken: token, amount, walletAddress } = params;
1006
- const txs = await this.supply(
1007
- this.normalizeTokenAddress(token),
1008
- amount.toString(),
1009
- walletAddress
1010
- );
1011
- return {
1012
- transactions: txs.map((t) => transactionPlanFromEthers(this.chain.id.toString(), t))
1013
- };
1014
- }
1015
- async createWithdrawTransaction(params) {
1016
- const { tokenToWithdraw, amount, walletAddress } = params;
1017
- const alphaTokenAddress = (await this.getReserves()).reservesData.find(
1018
- (reserve) => reserve.underlyingAsset === tokenToWithdraw.tokenUid.address
1019
- )?.aTokenAddress;
1020
- if (!alphaTokenAddress) {
1021
- throw new Error("No position can generate the token to withdraw");
1022
- }
1023
- const txs = await this.withdraw(alphaTokenAddress, amount, walletAddress, walletAddress);
1024
- return {
1025
- transactions: txs.map((t) => transactionPlanFromEthers(this.chain.id.toString(), t))
1026
- };
1027
- }
1028
- async createBorrowTransaction(params) {
1029
- const { borrowToken, amount, walletAddress } = params;
1030
- const normalizedTokenAddress = this.normalizeTokenAddress(borrowToken);
1031
- const poolData = await this.getPool(normalizedTokenAddress);
1032
- const reservesResponse = await this.getReserves();
1033
- let reserveLiquidationThreshold = null;
1034
- for (const reserve of reservesResponse.reservesData) {
1035
- const token = import_ethers3.ethers.utils.getAddress(reserve.underlyingAsset);
1036
- if (token === normalizedTokenAddress) {
1037
- reserveLiquidationThreshold = reserve.reserveLiquidationThreshold;
1038
- }
1039
- }
1040
- if (reserveLiquidationThreshold == null) {
1041
- throw new Error("Reserve not found in AAVE pool for a given token");
1042
- }
1043
- const txs = await this.borrow(normalizedTokenAddress, amount.toString(), walletAddress);
1044
- return {
1045
- liquidationThreshold: reserveLiquidationThreshold,
1046
- currentBorrowApy: poolData.variableBorrowRate,
1047
- transactions: txs.map((t) => transactionPlanFromEthers(this.chain.id.toString(), t))
1048
- };
1049
- }
1050
- async createRepayTransaction(params) {
1051
- const { repayToken, amount, walletAddress: from } = params;
1052
- const normalizedAsset = this.normalizeTokenAddress(repayToken);
1053
- const txs = await this.repay(normalizedAsset, amount.toString(), from, repayToken.decimals);
1054
- return {
1055
- transactions: txs.map((t) => transactionPlanFromEthers(this.chain.id.toString(), t))
1056
- };
1057
- }
1058
- async createRepayTransactionWithATokens(params) {
1059
- const { repayToken, amount, walletAddress: from } = params;
1060
- const normalizedAsset = this.normalizeTokenAddress(repayToken);
1061
- const txs = await this.repayWithATokens(
1062
- normalizedAsset,
1063
- amount.toString(),
1064
- from,
1065
- repayToken.decimals
1066
- );
1067
- return {
1068
- transactions: txs.map((t) => transactionPlanFromEthers(this.chain.id.toString(), t))
1069
- };
1070
- }
1071
- // Private Methods
1072
- getProvider() {
1073
- return this.chain.getProvider();
1074
- }
1075
- getPoolBundle() {
1076
- const provider = this.getProvider();
1077
- return new import_contract_helpers2.PoolBundle(provider, {
1078
- POOL: this.market.POOL,
1079
- WETH_GATEWAY: this.market.WETH_GATEWAY
1080
- });
1081
- }
1082
- getPoolDataProvider() {
1083
- const provider = this.getProvider();
1084
- const DataProviderImpl = getUiPoolDataProviderImpl(this.chain.id);
1085
- return new DataProviderImpl({
1086
- uiPoolDataProviderAddress: this.market.UI_POOL_DATA_PROVIDER,
1087
- provider,
1088
- chainId: this.chain.id
1089
- });
1090
- }
1091
- getPoolContract() {
1092
- const provider = this.getProvider();
1093
- return new import_contract_helpers2.Pool(provider, {
1094
- POOL: this.market.POOL,
1095
- WETH_GATEWAY: this.market.WETH_GATEWAY
1096
- });
1097
- }
1098
- async getPool(asset) {
1099
- const reservesResponse = await this.getReserves();
1100
- let targetAsset = asset;
1101
- if (asset === AAVE_ETH_PLACEHOLDER) {
1102
- const configuredWrappedNativeToken = this.chain.wrappedNativeTokenAddress;
1103
- if (!configuredWrappedNativeToken) {
1104
- throw new Error(`No wrapped native token configured for chain ${this.chain.id}`);
1105
- }
1106
- const wrappedNativeTokenReserve = reservesResponse.reservesData.find(
1107
- (r) => import_ethers3.ethers.utils.getAddress(r.underlyingAsset) === configuredWrappedNativeToken
1108
- );
1109
- if (!wrappedNativeTokenReserve) {
1110
- throw new Error(`Wrapped native token reserve not found for native token operations`);
1111
- }
1112
- targetAsset = wrappedNativeTokenReserve.underlyingAsset;
1113
- }
1114
- const reserve = reservesResponse.reservesData.find(
1115
- (r) => import_ethers3.ethers.utils.getAddress(r.underlyingAsset) === import_ethers3.ethers.utils.getAddress(targetAsset)
1116
- );
1117
- if (!reserve) {
1118
- throw new Error(`Asset ${asset} not found in reserves`);
1119
- }
1120
- return {
1121
- tokenAddress: reserve.underlyingAsset,
1122
- poolAddress: this.market.POOL,
1123
- variableBorrowRate: reserve.variableBorrowRate,
1124
- variableSupplyRate: reserve.liquidityRate,
1125
- ltv: reserve.baseLTVasCollateral,
1126
- availableLiquidity: reserve.availableLiquidity,
1127
- reserveSize: reserve.availableLiquidity
1128
- };
1129
- }
1130
- async getReserves() {
1131
- const reserves = this.getPoolDataProvider().getReservesHumanized({
1132
- lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER
1133
- });
1134
- return reserves;
1135
- }
1136
- async getUserSummary(params) {
1137
- const userSummaryResponse = await this._getUserSummary(params.walletAddress);
1138
- const {
1139
- totalLiquidityUSD,
1140
- totalCollateralUSD,
1141
- totalBorrowsUSD,
1142
- netWorthUSD,
1143
- availableBorrowsUSD,
1144
- currentLoanToValue,
1145
- currentLiquidationThreshold,
1146
- healthFactor,
1147
- userReservesData
1148
- } = userSummaryResponse.reserves;
1149
- const userReservesFormatted = [];
1150
- for (const {
1151
- reserve,
1152
- underlyingBalance,
1153
- underlyingBalanceUSD,
1154
- variableBorrows,
1155
- variableBorrowsUSD,
1156
- totalBorrows,
1157
- totalBorrowsUSD: totalBorrowsUSD2
1158
- } of userReservesData.filter((ur) => ur.underlyingBalanceUSD !== "0")) {
1159
- userReservesFormatted.push({
1160
- tokenUid: {
1161
- address: reserve.underlyingAsset,
1162
- chainId: this.chain.id.toString()
1163
- },
1164
- underlyingBalance,
1165
- underlyingBalanceUsd: underlyingBalanceUSD,
1166
- variableBorrows,
1167
- variableBorrowsUsd: variableBorrowsUSD,
1168
- totalBorrows,
1169
- totalBorrowsUsd: totalBorrowsUSD2
1170
- });
1171
- }
1172
- return {
1173
- userReserves: userReservesFormatted,
1174
- totalLiquidityUsd: totalLiquidityUSD,
1175
- totalCollateralUsd: totalCollateralUSD,
1176
- totalBorrowsUsd: totalBorrowsUSD,
1177
- netWorthUsd: netWorthUSD,
1178
- availableBorrowsUsd: availableBorrowsUSD,
1179
- currentLoanToValue,
1180
- currentLiquidationThreshold,
1181
- healthFactor
1182
- };
1183
- }
1184
- async _getUserSummary(userAddress) {
1185
- const validatedUser = import_ethers3.ethers.utils.getAddress(userAddress);
1186
- const poolDataProvider = this.getPoolDataProvider();
1187
- const reservesResponse = await this.getReserves();
1188
- const userReservesResponse = await poolDataProvider.getUserReservesHumanized({
1189
- lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,
1190
- user: validatedUser
1191
- });
1192
- return new UserSummary(userReservesResponse, reservesResponse);
1193
- }
1194
- borrow(asset, amount, from) {
1195
- import_ethers3.ethers.utils.getAddress(asset);
1196
- import_ethers3.ethers.utils.getAddress(from);
1197
- const bundle = this.getPoolBundle();
1198
- const tx = bundle.borrowTxBuilder.generateTxData({
1199
- user: from,
1200
- reserve: asset,
1201
- amount,
1202
- interestRateMode: import_contract_helpers2.InterestRate.Variable
1203
- });
1204
- return Promise.resolve([tx]);
1205
- }
1206
- async createApproval({
1207
- asset,
1208
- amount_raw,
1209
- user,
1210
- spender
1211
- }) {
1212
- const bundle = this.getPoolBundle();
1213
- let approvalTx = null;
1214
- const isApprovedEnough = await bundle.erc20Service.isApproved({
1215
- user,
1216
- token: asset,
1217
- spender,
1218
- amount: amount_raw,
1219
- nativeDecimals: true
1220
- });
1221
- if (!isApprovedEnough) {
1222
- approvalTx = bundle.erc20Service.approveTxData({
1223
- user,
1224
- token: asset,
1225
- spender,
1226
- amount: amount_raw
1227
- });
1228
- }
1229
- return approvalTx;
1230
- }
1231
- async supply(asset, amount, from) {
1232
- import_ethers3.ethers.utils.getAddress(asset);
1233
- import_ethers3.ethers.utils.getAddress(from);
1234
- const bundle = this.getPoolBundle();
1235
- const approvalTx = await this.createApproval({
1236
- asset,
1237
- amount_raw: amount,
1238
- user: from,
1239
- spender: bundle.poolAddress
1240
- });
1241
- const tx = bundle.supplyTxBuilder.generateTxData({
1242
- user: from,
1243
- reserve: asset,
1244
- amount,
1245
- onBehalfOf: from
1246
- });
1247
- return (approvalTx ? [approvalTx] : []).concat([tx]);
1248
- }
1249
- async repay(asset, amount_formatted, from, tokenDecimals) {
1250
- import_ethers3.ethers.utils.getAddress(asset);
1251
- import_ethers3.ethers.utils.getAddress(from);
1252
- const bundle = this.getPoolBundle();
1253
- const amount = import_ethers3.utils.parseUnits(amount_formatted, tokenDecimals).toString();
1254
- const tx = bundle.repayTxBuilder.generateTxData({
1255
- user: from,
1256
- reserve: asset,
1257
- amount,
1258
- interestRateMode: import_contract_helpers2.InterestRate.Variable,
1259
- onBehalfOf: from
1260
- });
1261
- const approvalTx = await this.createApproval({
1262
- asset,
1263
- amount_raw: amount,
1264
- user: from,
1265
- spender: bundle.poolAddress
1266
- });
1267
- return (approvalTx ? [approvalTx] : []).concat([tx]);
1268
- }
1269
- async repayWithATokens(asset, amount_formatted, from, tokenDecimals) {
1270
- import_ethers3.ethers.utils.getAddress(asset);
1271
- import_ethers3.ethers.utils.getAddress(from);
1272
- const bundle = this.getPoolBundle();
1273
- const amount = import_ethers3.utils.parseUnits(amount_formatted, tokenDecimals).toString();
1274
- const tx = bundle.repayWithATokensTxBuilder.generateTxData({
1275
- user: from,
1276
- reserve: asset,
1277
- amount,
1278
- rateMode: import_contract_helpers2.InterestRate.Variable
1279
- });
1280
- return [tx];
1281
- }
1282
- async withdraw(asset, amount, to, from) {
1283
- import_ethers3.ethers.utils.getAddress(asset);
1284
- import_ethers3.ethers.utils.getAddress(to);
1285
- import_ethers3.ethers.utils.getAddress(from);
1286
- const pool = this.getPoolContract();
1287
- const txs = await pool.withdraw({
1288
- user: from,
1289
- reserve: asset,
1290
- amount: amount.toString()
1291
- });
1292
- if (txs.length !== 1) {
1293
- throw new Error("AAVEInstance.withdraw: impossible happened");
1294
- }
1295
- return [await populateTransaction(txs[0])];
1296
- }
909
+ chain;
910
+ market;
911
+ constructor(params) {
912
+ this.chain = new Chain(params.chainId, params.rpcUrl);
913
+ this.market = getMarket(this.chain.id);
914
+ }
915
+ /**
916
+ * If the token is native, return AAVE's placeholder address instead of the ember address.
917
+ * @param token - The token to normalize.
918
+ * @returns The normalized token address.
919
+ */
920
+ normalizeTokenAddress(token) {
921
+ return token.isNative ? AAVE_ETH_PLACEHOLDER : token.tokenUid.address;
922
+ }
923
+ async createSupplyTransaction(params) {
924
+ const { supplyToken: token, amount, walletAddress } = params;
925
+ return { transactions: (await this.supply(this.normalizeTokenAddress(token), amount.toString(), walletAddress)).map((t) => transactionPlanFromEthers(this.chain.id.toString(), t)) };
926
+ }
927
+ async createWithdrawTransaction(params) {
928
+ const { tokenToWithdraw, amount, walletAddress } = params;
929
+ const alphaTokenAddress = (await this.getReserves()).reservesData.find((reserve) => reserve.underlyingAsset === tokenToWithdraw.tokenUid.address)?.aTokenAddress;
930
+ if (!alphaTokenAddress) throw new Error("No position can generate the token to withdraw");
931
+ return { transactions: (await this.withdraw(alphaTokenAddress, amount, walletAddress, walletAddress)).map((t) => transactionPlanFromEthers(this.chain.id.toString(), t)) };
932
+ }
933
+ async createBorrowTransaction(params) {
934
+ const { borrowToken, amount, walletAddress } = params;
935
+ const normalizedTokenAddress = this.normalizeTokenAddress(borrowToken);
936
+ const poolData = await this.getPool(normalizedTokenAddress);
937
+ const reservesResponse = await this.getReserves();
938
+ let reserveLiquidationThreshold = null;
939
+ for (const reserve of reservesResponse.reservesData) if (ethers.ethers.utils.getAddress(reserve.underlyingAsset) === normalizedTokenAddress) reserveLiquidationThreshold = reserve.reserveLiquidationThreshold;
940
+ if (reserveLiquidationThreshold == null) throw new Error("Reserve not found in AAVE pool for a given token");
941
+ const txs = await this.borrow(normalizedTokenAddress, amount.toString(), walletAddress);
942
+ return {
943
+ liquidationThreshold: reserveLiquidationThreshold,
944
+ currentBorrowApy: poolData.variableBorrowRate,
945
+ transactions: txs.map((t) => transactionPlanFromEthers(this.chain.id.toString(), t))
946
+ };
947
+ }
948
+ async createRepayTransaction(params) {
949
+ const { repayToken, amount, walletAddress: from } = params;
950
+ const normalizedAsset = this.normalizeTokenAddress(repayToken);
951
+ return { transactions: (await this.repay(normalizedAsset, amount.toString(), from, repayToken.decimals)).map((t) => transactionPlanFromEthers(this.chain.id.toString(), t)) };
952
+ }
953
+ async createRepayTransactionWithATokens(params) {
954
+ const { repayToken, amount, walletAddress: from } = params;
955
+ const normalizedAsset = this.normalizeTokenAddress(repayToken);
956
+ return { transactions: (await this.repayWithATokens(normalizedAsset, amount.toString(), from, repayToken.decimals)).map((t) => transactionPlanFromEthers(this.chain.id.toString(), t)) };
957
+ }
958
+ getProvider() {
959
+ return this.chain.getProvider();
960
+ }
961
+ getPoolBundle() {
962
+ return new __aave_contract_helpers.PoolBundle(this.getProvider(), {
963
+ POOL: this.market.POOL,
964
+ WETH_GATEWAY: this.market.WETH_GATEWAY
965
+ });
966
+ }
967
+ getPoolDataProvider() {
968
+ const provider = this.getProvider();
969
+ return new (getUiPoolDataProviderImpl(this.chain.id))({
970
+ uiPoolDataProviderAddress: this.market.UI_POOL_DATA_PROVIDER,
971
+ provider,
972
+ chainId: this.chain.id
973
+ });
974
+ }
975
+ getPoolContract() {
976
+ return new __aave_contract_helpers.Pool(this.getProvider(), {
977
+ POOL: this.market.POOL,
978
+ WETH_GATEWAY: this.market.WETH_GATEWAY
979
+ });
980
+ }
981
+ async getPool(asset) {
982
+ const reservesResponse = await this.getReserves();
983
+ let targetAsset = asset;
984
+ if (asset === AAVE_ETH_PLACEHOLDER) {
985
+ const configuredWrappedNativeToken = this.chain.wrappedNativeTokenAddress;
986
+ if (!configuredWrappedNativeToken) throw new Error(`No wrapped native token configured for chain ${this.chain.id}`);
987
+ const wrappedNativeTokenReserve = reservesResponse.reservesData.find((r) => ethers.ethers.utils.getAddress(r.underlyingAsset) === configuredWrappedNativeToken);
988
+ if (!wrappedNativeTokenReserve) throw new Error(`Wrapped native token reserve not found for native token operations`);
989
+ targetAsset = wrappedNativeTokenReserve.underlyingAsset;
990
+ }
991
+ const reserve = reservesResponse.reservesData.find((r) => ethers.ethers.utils.getAddress(r.underlyingAsset) === ethers.ethers.utils.getAddress(targetAsset));
992
+ if (!reserve) throw new Error(`Asset ${asset} not found in reserves`);
993
+ return {
994
+ tokenAddress: reserve.underlyingAsset,
995
+ poolAddress: this.market.POOL,
996
+ variableBorrowRate: reserve.variableBorrowRate,
997
+ variableSupplyRate: reserve.liquidityRate,
998
+ ltv: reserve.baseLTVasCollateral,
999
+ availableLiquidity: reserve.availableLiquidity,
1000
+ reserveSize: reserve.availableLiquidity
1001
+ };
1002
+ }
1003
+ async getReserves() {
1004
+ return this.getPoolDataProvider().getReservesHumanized({ lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER });
1005
+ }
1006
+ async getUserSummary(params) {
1007
+ const { totalLiquidityUSD, totalCollateralUSD, totalBorrowsUSD, netWorthUSD, availableBorrowsUSD, currentLoanToValue, currentLiquidationThreshold, healthFactor, userReservesData } = (await this._getUserSummary(params.walletAddress)).reserves;
1008
+ const userReservesFormatted = [];
1009
+ for (const { reserve, underlyingBalance, underlyingBalanceUSD, variableBorrows, variableBorrowsUSD, totalBorrows, totalBorrowsUSD: totalBorrowsUSD$1 } of userReservesData.filter((ur) => ur.underlyingBalanceUSD !== "0")) userReservesFormatted.push({
1010
+ tokenUid: {
1011
+ address: reserve.underlyingAsset,
1012
+ chainId: this.chain.id.toString()
1013
+ },
1014
+ underlyingBalance,
1015
+ underlyingBalanceUsd: underlyingBalanceUSD,
1016
+ variableBorrows,
1017
+ variableBorrowsUsd: variableBorrowsUSD,
1018
+ totalBorrows,
1019
+ totalBorrowsUsd: totalBorrowsUSD$1
1020
+ });
1021
+ return {
1022
+ userReserves: userReservesFormatted,
1023
+ totalLiquidityUsd: totalLiquidityUSD,
1024
+ totalCollateralUsd: totalCollateralUSD,
1025
+ totalBorrowsUsd: totalBorrowsUSD,
1026
+ netWorthUsd: netWorthUSD,
1027
+ availableBorrowsUsd: availableBorrowsUSD,
1028
+ currentLoanToValue,
1029
+ currentLiquidationThreshold,
1030
+ healthFactor
1031
+ };
1032
+ }
1033
+ async _getUserSummary(userAddress) {
1034
+ const validatedUser = ethers.ethers.utils.getAddress(userAddress);
1035
+ const poolDataProvider = this.getPoolDataProvider();
1036
+ const reservesResponse = await this.getReserves();
1037
+ return new UserSummary(await poolDataProvider.getUserReservesHumanized({
1038
+ lendingPoolAddressProvider: this.market.POOL_ADDRESSES_PROVIDER,
1039
+ user: validatedUser
1040
+ }), reservesResponse);
1041
+ }
1042
+ borrow(asset, amount, from) {
1043
+ ethers.ethers.utils.getAddress(asset);
1044
+ ethers.ethers.utils.getAddress(from);
1045
+ const tx = this.getPoolBundle().borrowTxBuilder.generateTxData({
1046
+ user: from,
1047
+ reserve: asset,
1048
+ amount,
1049
+ interestRateMode: __aave_contract_helpers.InterestRate.Variable
1050
+ });
1051
+ return Promise.resolve([tx]);
1052
+ }
1053
+ async createApproval({ asset, amount_raw, user, spender }) {
1054
+ const bundle = this.getPoolBundle();
1055
+ let approvalTx = null;
1056
+ if (!await bundle.erc20Service.isApproved({
1057
+ user,
1058
+ token: asset,
1059
+ spender,
1060
+ amount: amount_raw,
1061
+ nativeDecimals: true
1062
+ })) approvalTx = bundle.erc20Service.approveTxData({
1063
+ user,
1064
+ token: asset,
1065
+ spender,
1066
+ amount: amount_raw
1067
+ });
1068
+ return approvalTx;
1069
+ }
1070
+ async supply(asset, amount, from) {
1071
+ ethers.ethers.utils.getAddress(asset);
1072
+ ethers.ethers.utils.getAddress(from);
1073
+ const bundle = this.getPoolBundle();
1074
+ const approvalTx = await this.createApproval({
1075
+ asset,
1076
+ amount_raw: amount,
1077
+ user: from,
1078
+ spender: bundle.poolAddress
1079
+ });
1080
+ const tx = bundle.supplyTxBuilder.generateTxData({
1081
+ user: from,
1082
+ reserve: asset,
1083
+ amount,
1084
+ onBehalfOf: from
1085
+ });
1086
+ return (approvalTx ? [approvalTx] : []).concat([tx]);
1087
+ }
1088
+ async repay(asset, amount_formatted, from, tokenDecimals) {
1089
+ ethers.ethers.utils.getAddress(asset);
1090
+ ethers.ethers.utils.getAddress(from);
1091
+ const bundle = this.getPoolBundle();
1092
+ const amount = ethers.utils.parseUnits(amount_formatted, tokenDecimals).toString();
1093
+ const tx = bundle.repayTxBuilder.generateTxData({
1094
+ user: from,
1095
+ reserve: asset,
1096
+ amount,
1097
+ interestRateMode: __aave_contract_helpers.InterestRate.Variable,
1098
+ onBehalfOf: from
1099
+ });
1100
+ const approvalTx = await this.createApproval({
1101
+ asset,
1102
+ amount_raw: amount,
1103
+ user: from,
1104
+ spender: bundle.poolAddress
1105
+ });
1106
+ return (approvalTx ? [approvalTx] : []).concat([tx]);
1107
+ }
1108
+ async repayWithATokens(asset, amount_formatted, from, tokenDecimals) {
1109
+ ethers.ethers.utils.getAddress(asset);
1110
+ ethers.ethers.utils.getAddress(from);
1111
+ const bundle = this.getPoolBundle();
1112
+ const amount = ethers.utils.parseUnits(amount_formatted, tokenDecimals).toString();
1113
+ return [bundle.repayWithATokensTxBuilder.generateTxData({
1114
+ user: from,
1115
+ reserve: asset,
1116
+ amount,
1117
+ rateMode: __aave_contract_helpers.InterestRate.Variable
1118
+ })];
1119
+ }
1120
+ async withdraw(asset, amount, to, from) {
1121
+ ethers.ethers.utils.getAddress(asset);
1122
+ ethers.ethers.utils.getAddress(to);
1123
+ ethers.ethers.utils.getAddress(from);
1124
+ const txs = await this.getPoolContract().withdraw({
1125
+ user: from,
1126
+ reserve: asset,
1127
+ amount: amount.toString()
1128
+ });
1129
+ if (txs.length !== 1) throw new Error("AAVEInstance.withdraw: impossible happened");
1130
+ return [await populateTransaction(txs[0])];
1131
+ }
1297
1132
  };
1298
- var transactionPlanFromEthers = (chainId, tx) => {
1299
- return {
1300
- type: TransactionTypes.EVM_TX,
1301
- to: tx.to,
1302
- value: tx.value?.toString() || "0",
1303
- data: tx.data,
1304
- chainId
1305
- };
1133
+ const transactionPlanFromEthers = (chainId, tx) => {
1134
+ return {
1135
+ type: TransactionTypes.EVM_TX,
1136
+ to: tx.to,
1137
+ value: tx.value?.toString() || "0",
1138
+ data: tx.data,
1139
+ chainId
1140
+ };
1306
1141
  };
1307
1142
 
1308
- // src/aave-lending-plugin/index.ts
1143
+ //#endregion
1144
+ //#region src/aave-lending-plugin/index.ts
1145
+ /**
1146
+ * Get the AAVE Ember plugin.
1147
+ * @param params - Configuration parameters for the AAVEAdapter, including chainId and rpcUrl.
1148
+ * @returns The AAVE Ember plugin.
1149
+ */
1309
1150
  async function getAaveEmberPlugin(params) {
1310
- const adapter = new AAVEAdapter(params);
1311
- return {
1312
- id: `AAVE_CHAIN_${params.chainId}`,
1313
- type: "lending",
1314
- name: `AAVE lending for ${params.chainId}`,
1315
- description: "Aave V3 lending protocol",
1316
- website: "https://aave.com",
1317
- x: "https://x.com/aave",
1318
- actions: await getAaveActions(adapter),
1319
- queries: {
1320
- getPositions: adapter.getUserSummary.bind(adapter)
1321
- }
1322
- };
1151
+ const adapter = new AAVEAdapter(params);
1152
+ return {
1153
+ id: `AAVE_CHAIN_${params.chainId}`,
1154
+ type: "lending",
1155
+ name: `AAVE lending for ${params.chainId}`,
1156
+ description: "Aave V3 lending protocol",
1157
+ website: "https://aave.com",
1158
+ x: "https://x.com/aave",
1159
+ actions: await getAaveActions(adapter),
1160
+ queries: { getPositions: adapter.getUserSummary.bind(adapter) }
1161
+ };
1323
1162
  }
1163
+ /**
1164
+ * Get the AAVE actions for the lending protocol.
1165
+ * @param adapter - An instance of AAVEAdapter to interact with the AAVE protocol.
1166
+ * @returns An array of action definitions for the AAVE lending protocol.
1167
+ */
1324
1168
  async function getAaveActions(adapter) {
1325
- const reservesResponse = await adapter.getReserves();
1326
- const underlyingAssets = reservesResponse.reservesData.map(
1327
- (reserve) => reserve.underlyingAsset
1328
- );
1329
- const aTokens = reservesResponse.reservesData.map((reserve) => reserve.aTokenAddress);
1330
- const borrowableAssets = reservesResponse.reservesData.filter((reserve) => reserve.borrowingEnabled).map((reserve) => reserve.underlyingAsset);
1331
- return [
1332
- // Supply any of the underlying assets to get aTokens
1333
- {
1334
- type: "lending-supply",
1335
- name: `AAVE lending pools in chain ${adapter.chain.id}`,
1336
- inputTokens: async () => Promise.resolve([
1337
- {
1338
- chainId: adapter.chain.id.toString(),
1339
- tokens: underlyingAssets
1340
- }
1341
- ]),
1342
- outputTokens: async () => Promise.resolve([
1343
- {
1344
- chainId: adapter.chain.id.toString(),
1345
- tokens: aTokens
1346
- }
1347
- ]),
1348
- callback: adapter.createSupplyTransaction.bind(adapter)
1349
- },
1350
- // Borrow any of the borrowable assets if you have some alpha tokens as collateral
1351
- {
1352
- type: "lending-borrow",
1353
- name: `AAVE borrow in chain ${adapter.chain.id}`,
1354
- inputTokens: async () => Promise.resolve([
1355
- {
1356
- chainId: adapter.chain.id.toString(),
1357
- tokens: aTokens
1358
- }
1359
- ]),
1360
- outputTokens: async () => Promise.resolve([
1361
- {
1362
- chainId: adapter.chain.id.toString(),
1363
- tokens: borrowableAssets
1364
- }
1365
- ]),
1366
- callback: adapter.createBorrowTransaction.bind(adapter)
1367
- },
1368
- // Repay your borrow with the underlying asset
1369
- {
1370
- type: "lending-repay",
1371
- name: `AAVE repay in chain ${adapter.chain.id}`,
1372
- inputTokens: async () => Promise.resolve([
1373
- {
1374
- chainId: adapter.chain.id.toString(),
1375
- tokens: borrowableAssets
1376
- }
1377
- ]),
1378
- // Empty output tokens as this doesn't generate any token
1379
- outputTokens: async () => Promise.resolve([]),
1380
- callback: adapter.createRepayTransaction.bind(adapter)
1381
- },
1382
- // Repay your borrow with aTokens
1383
- {
1384
- type: "lending-repay",
1385
- name: `AAVE repay with aTokens in chain ${adapter.chain.id}`,
1386
- inputTokens: async () => Promise.resolve([
1387
- {
1388
- chainId: adapter.chain.id.toString(),
1389
- tokens: aTokens
1390
- }
1391
- ]),
1392
- // Empty output tokens as this doesn't generate any token
1393
- outputTokens: async () => Promise.resolve([]),
1394
- callback: adapter.createRepayTransactionWithATokens.bind(adapter)
1395
- },
1396
- // Withdraw from your aTokens to get the underlying asset back
1397
- {
1398
- type: "lending-withdraw",
1399
- name: `AAVE withdraw in chain ${adapter.chain.id}`,
1400
- inputTokens: async () => Promise.resolve([
1401
- {
1402
- chainId: adapter.chain.id.toString(),
1403
- tokens: aTokens
1404
- }
1405
- ]),
1406
- outputTokens: async () => Promise.resolve([
1407
- {
1408
- chainId: adapter.chain.id.toString(),
1409
- tokens: underlyingAssets
1410
- }
1411
- ]),
1412
- callback: adapter.createWithdrawTransaction.bind(adapter)
1413
- }
1414
- ];
1169
+ const reservesResponse = await adapter.getReserves();
1170
+ const underlyingAssets = reservesResponse.reservesData.map((reserve) => reserve.underlyingAsset);
1171
+ const aTokens = reservesResponse.reservesData.map((reserve) => reserve.aTokenAddress);
1172
+ const borrowableAssets = reservesResponse.reservesData.filter((reserve) => reserve.borrowingEnabled).map((reserve) => reserve.underlyingAsset);
1173
+ return [
1174
+ {
1175
+ type: "lending-supply",
1176
+ name: `AAVE lending pools in chain ${adapter.chain.id}`,
1177
+ inputTokens: async () => Promise.resolve([{
1178
+ chainId: adapter.chain.id.toString(),
1179
+ tokens: underlyingAssets
1180
+ }]),
1181
+ outputTokens: async () => Promise.resolve([{
1182
+ chainId: adapter.chain.id.toString(),
1183
+ tokens: aTokens
1184
+ }]),
1185
+ callback: adapter.createSupplyTransaction.bind(adapter)
1186
+ },
1187
+ {
1188
+ type: "lending-borrow",
1189
+ name: `AAVE borrow in chain ${adapter.chain.id}`,
1190
+ inputTokens: async () => Promise.resolve([{
1191
+ chainId: adapter.chain.id.toString(),
1192
+ tokens: aTokens
1193
+ }]),
1194
+ outputTokens: async () => Promise.resolve([{
1195
+ chainId: adapter.chain.id.toString(),
1196
+ tokens: borrowableAssets
1197
+ }]),
1198
+ callback: adapter.createBorrowTransaction.bind(adapter)
1199
+ },
1200
+ {
1201
+ type: "lending-repay",
1202
+ name: `AAVE repay in chain ${adapter.chain.id}`,
1203
+ inputTokens: async () => Promise.resolve([{
1204
+ chainId: adapter.chain.id.toString(),
1205
+ tokens: borrowableAssets
1206
+ }]),
1207
+ outputTokens: async () => Promise.resolve([]),
1208
+ callback: adapter.createRepayTransaction.bind(adapter)
1209
+ },
1210
+ {
1211
+ type: "lending-repay",
1212
+ name: `AAVE repay with aTokens in chain ${adapter.chain.id}`,
1213
+ inputTokens: async () => Promise.resolve([{
1214
+ chainId: adapter.chain.id.toString(),
1215
+ tokens: aTokens
1216
+ }]),
1217
+ outputTokens: async () => Promise.resolve([]),
1218
+ callback: adapter.createRepayTransactionWithATokens.bind(adapter)
1219
+ },
1220
+ {
1221
+ type: "lending-withdraw",
1222
+ name: `AAVE withdraw in chain ${adapter.chain.id}`,
1223
+ inputTokens: async () => Promise.resolve([{
1224
+ chainId: adapter.chain.id.toString(),
1225
+ tokens: aTokens
1226
+ }]),
1227
+ outputTokens: async () => Promise.resolve([{
1228
+ chainId: adapter.chain.id.toString(),
1229
+ tokens: underlyingAssets
1230
+ }]),
1231
+ callback: adapter.createWithdrawTransaction.bind(adapter)
1232
+ }
1233
+ ];
1415
1234
  }
1235
+ /**
1236
+ * Register the AAVE plugin for the specified chain configuration.
1237
+ * @param chainConfig - The chain configuration to check for AAVE support.
1238
+ * @param registry - The public Ember plugin registry to register the plugin with.
1239
+ * @returns A promise that resolves when the plugin is registered.
1240
+ */
1416
1241
  function registerAave(chainConfig, registry) {
1417
- const supportedChains = [42161];
1418
- if (!supportedChains.includes(chainConfig.chainId)) {
1419
- return;
1420
- }
1421
- registry.registerDeferredPlugin(
1422
- getAaveEmberPlugin({
1423
- chainId: chainConfig.chainId,
1424
- rpcUrl: chainConfig.rpcUrl,
1425
- wrappedNativeToken: chainConfig.wrappedNativeToken
1426
- })
1427
- );
1242
+ if (![42161].includes(chainConfig.chainId)) return;
1243
+ registry.registerDeferredPlugin(getAaveEmberPlugin({
1244
+ chainId: chainConfig.chainId,
1245
+ rpcUrl: chainConfig.rpcUrl,
1246
+ wrappedNativeToken: chainConfig.wrappedNativeToken
1247
+ }));
1428
1248
  }
1429
1249
 
1430
- // src/registry.ts
1250
+ //#endregion
1251
+ //#region src/registry.ts
1252
+ /**
1253
+ * Registry for public Ember plugins.
1254
+ */
1431
1255
  var PublicEmberPluginRegistry = class {
1432
- plugins = [];
1433
- deferredPlugins = [];
1434
- /**
1435
- * Register a new Ember plugin.
1436
- * @param plugin The plugin to register.
1437
- */
1438
- registerPlugin(plugin) {
1439
- this.plugins.push(plugin);
1440
- }
1441
- /**
1442
- * Register a new deferred Ember plugin.
1443
- * @param pluginPromise The promise resolving to the plugin to register.
1444
- */
1445
- registerDeferredPlugin(pluginPromise) {
1446
- this.deferredPlugins.push(pluginPromise);
1447
- }
1448
- /**
1449
- * Iterator for the registered Ember plugins.
1450
- */
1451
- async *getPlugins() {
1452
- yield* this.plugins;
1453
- for (const pluginPromise of this.deferredPlugins) {
1454
- const plugin = await pluginPromise;
1455
- this.registerPlugin(plugin);
1456
- yield plugin;
1457
- }
1458
- this.deferredPlugins = [];
1459
- }
1460
- get emberPlugins() {
1461
- return this.plugins;
1462
- }
1256
+ plugins = [];
1257
+ deferredPlugins = [];
1258
+ /**
1259
+ * Register a new Ember plugin.
1260
+ * @param plugin The plugin to register.
1261
+ */
1262
+ registerPlugin(plugin) {
1263
+ this.plugins.push(plugin);
1264
+ }
1265
+ /**
1266
+ * Register a new deferred Ember plugin.
1267
+ * @param pluginPromise The promise resolving to the plugin to register.
1268
+ */
1269
+ registerDeferredPlugin(pluginPromise) {
1270
+ this.deferredPlugins.push(pluginPromise);
1271
+ }
1272
+ /**
1273
+ * Iterator for the registered Ember plugins.
1274
+ */
1275
+ async *getPlugins() {
1276
+ yield* this.plugins;
1277
+ for (const pluginPromise of this.deferredPlugins) {
1278
+ const plugin = await pluginPromise;
1279
+ this.registerPlugin(plugin);
1280
+ yield plugin;
1281
+ }
1282
+ this.deferredPlugins = [];
1283
+ }
1284
+ get emberPlugins() {
1285
+ return this.plugins;
1286
+ }
1463
1287
  };
1464
1288
 
1465
- // src/index.ts
1289
+ //#endregion
1290
+ //#region src/index.ts
1291
+ /**
1292
+ * Initialize the public Ember plugin registry.
1293
+ * @returns The initialized public Ember plugin registry with registered plugins.
1294
+ */
1466
1295
  function initializePublicRegistry(chainConfigs) {
1467
- const registry = new PublicEmberPluginRegistry();
1468
- for (const chainConfig of chainConfigs) {
1469
- registerAave(chainConfig, registry);
1470
- }
1471
- return registry;
1296
+ const registry = new PublicEmberPluginRegistry();
1297
+ for (const chainConfig of chainConfigs) registerAave(chainConfig, registry);
1298
+ return registry;
1472
1299
  }
1473
- // Annotate the CommonJS export names for ESM import in node:
1474
- 0 && (module.exports = {
1475
- BorrowTokensRequestSchema,
1476
- BorrowTokensResponseSchema,
1477
- ChainSchema,
1478
- ChainTypeSchema,
1479
- ClosePerpetualsOrdersRequestSchema,
1480
- ClosePerpetualsOrdersResponseSchema,
1481
- CreatePerpetualsPositionRequestSchema,
1482
- CreatePerpetualsPositionResponseSchema,
1483
- DecreasePositionSwapTypeSchema,
1484
- FeeBreakdownSchema,
1485
- GetLiquidityPoolsResponseSchema,
1486
- GetPerpetualsMarketsOrdersRequestSchema,
1487
- GetPerpetualsMarketsOrdersResponseSchema,
1488
- GetPerpetualsMarketsPositionsRequestSchema,
1489
- GetPerpetualsMarketsPositionsResponseSchema,
1490
- GetPerpetualsMarketsRequestSchema,
1491
- GetPerpetualsMarketsResponseSchema,
1492
- GetWalletLendingPositionsRequestSchema,
1493
- GetWalletLendingPositionsResponseSchema,
1494
- GetWalletLiquidityPositionsRequestSchema,
1495
- GetWalletLiquidityPositionsResponseSchema,
1496
- LendTokenDetailSchema,
1497
- LimitedLiquidityProvisionRangeSchema,
1498
- LiquidityPayTokensSchema,
1499
- LiquidityPoolSchema,
1500
- LiquidityPoolTokens,
1501
- LiquidityPositionRangeSchema,
1502
- LiquidityPositionSchema,
1503
- LiquidityProvisionRangeSchema,
1504
- LiquiditySuppliedTokenSchema,
1505
- OrderSchema,
1506
- OrderTypeSchema,
1507
- OrdersDataSchema,
1508
- PerpetualMarketSchema,
1509
- PositionSchema,
1510
- PositionSideSchema,
1511
- PositionsDataSchema,
1512
- ProviderTrackingInfoSchema,
1513
- ProviderTrackingStatusSchema,
1514
- PublicEmberPluginRegistry,
1515
- RepayTokensRequestSchema,
1516
- RepayTokensResponseSchema,
1517
- SupplyLiquidityRequestSchema,
1518
- SupplyLiquidityResponseSchema,
1519
- SupplyTokensRequestSchema,
1520
- SupplyTokensResponseSchema,
1521
- SwapEstimationSchema,
1522
- SwapTokensRequestSchema,
1523
- SwapTokensResponseSchema,
1524
- TokenIdentifierSchema,
1525
- TokenSchema,
1526
- TransactionPlanErrorSchema,
1527
- TransactionPlanSchema,
1528
- TransactionTypeSchema,
1529
- TransactionTypes,
1530
- WithdrawLiquidityRequestSchema,
1531
- WithdrawLiquidityResponseSchema,
1532
- WithdrawTokensRequestSchema,
1533
- WithdrawTokensResponseSchema,
1534
- initializePublicRegistry
1535
- });
1300
+
1301
+ //#endregion
1302
+ exports.BorrowTokensRequestSchema = BorrowTokensRequestSchema;
1303
+ exports.BorrowTokensResponseSchema = BorrowTokensResponseSchema;
1304
+ exports.ChainSchema = ChainSchema;
1305
+ exports.ChainTypeSchema = ChainTypeSchema;
1306
+ exports.ClosePerpetualsOrdersRequestSchema = ClosePerpetualsOrdersRequestSchema;
1307
+ exports.ClosePerpetualsOrdersResponseSchema = ClosePerpetualsOrdersResponseSchema;
1308
+ exports.CreatePerpetualsPositionRequestSchema = CreatePerpetualsPositionRequestSchema;
1309
+ exports.CreatePerpetualsPositionResponseSchema = CreatePerpetualsPositionResponseSchema;
1310
+ exports.DecreasePositionSwapTypeSchema = DecreasePositionSwapTypeSchema;
1311
+ exports.FeeBreakdownSchema = FeeBreakdownSchema;
1312
+ exports.GetLiquidityPoolsResponseSchema = GetLiquidityPoolsResponseSchema;
1313
+ exports.GetPerpetualsMarketsOrdersRequestSchema = GetPerpetualsMarketsOrdersRequestSchema;
1314
+ exports.GetPerpetualsMarketsOrdersResponseSchema = GetPerpetualsMarketsOrdersResponseSchema;
1315
+ exports.GetPerpetualsMarketsPositionsRequestSchema = GetPerpetualsMarketsPositionsRequestSchema;
1316
+ exports.GetPerpetualsMarketsPositionsResponseSchema = GetPerpetualsMarketsPositionsResponseSchema;
1317
+ exports.GetPerpetualsMarketsRequestSchema = GetPerpetualsMarketsRequestSchema;
1318
+ exports.GetPerpetualsMarketsResponseSchema = GetPerpetualsMarketsResponseSchema;
1319
+ exports.GetWalletLendingPositionsRequestSchema = GetWalletLendingPositionsRequestSchema;
1320
+ exports.GetWalletLendingPositionsResponseSchema = GetWalletLendingPositionsResponseSchema;
1321
+ exports.GetWalletLiquidityPositionsRequestSchema = GetWalletLiquidityPositionsRequestSchema;
1322
+ exports.GetWalletLiquidityPositionsResponseSchema = GetWalletLiquidityPositionsResponseSchema;
1323
+ exports.LendTokenDetailSchema = LendTokenDetailSchema;
1324
+ exports.LimitedLiquidityProvisionRangeSchema = LimitedLiquidityProvisionRangeSchema;
1325
+ exports.LiquidityPayTokensSchema = LiquidityPayTokensSchema;
1326
+ exports.LiquidityPoolSchema = LiquidityPoolSchema;
1327
+ exports.LiquidityPoolTokens = LiquidityPoolTokens;
1328
+ exports.LiquidityPositionRangeSchema = LiquidityPositionRangeSchema;
1329
+ exports.LiquidityPositionSchema = LiquidityPositionSchema;
1330
+ exports.LiquidityProvisionRangeSchema = LiquidityProvisionRangeSchema;
1331
+ exports.LiquiditySuppliedTokenSchema = LiquiditySuppliedTokenSchema;
1332
+ exports.OrderSchema = OrderSchema;
1333
+ exports.OrderTypeSchema = OrderTypeSchema;
1334
+ exports.OrdersDataSchema = OrdersDataSchema;
1335
+ exports.PerpetualMarketSchema = PerpetualMarketSchema;
1336
+ exports.PositionSchema = PositionSchema;
1337
+ exports.PositionSideSchema = PositionSideSchema;
1338
+ exports.PositionsDataSchema = PositionsDataSchema;
1339
+ exports.ProviderTrackingInfoSchema = ProviderTrackingInfoSchema;
1340
+ exports.ProviderTrackingStatusSchema = ProviderTrackingStatusSchema;
1341
+ exports.PublicEmberPluginRegistry = PublicEmberPluginRegistry;
1342
+ exports.RepayTokensRequestSchema = RepayTokensRequestSchema;
1343
+ exports.RepayTokensResponseSchema = RepayTokensResponseSchema;
1344
+ exports.SupplyLiquidityRequestSchema = SupplyLiquidityRequestSchema;
1345
+ exports.SupplyLiquidityResponseSchema = SupplyLiquidityResponseSchema;
1346
+ exports.SupplyTokensRequestSchema = SupplyTokensRequestSchema;
1347
+ exports.SupplyTokensResponseSchema = SupplyTokensResponseSchema;
1348
+ exports.SwapEstimationSchema = SwapEstimationSchema;
1349
+ exports.SwapTokensRequestSchema = SwapTokensRequestSchema;
1350
+ exports.SwapTokensResponseSchema = SwapTokensResponseSchema;
1351
+ exports.TokenIdentifierSchema = TokenIdentifierSchema;
1352
+ exports.TokenSchema = TokenSchema;
1353
+ exports.TransactionPlanErrorSchema = TransactionPlanErrorSchema;
1354
+ exports.TransactionPlanSchema = TransactionPlanSchema;
1355
+ exports.TransactionTypeSchema = TransactionTypeSchema;
1356
+ exports.TransactionTypes = TransactionTypes;
1357
+ exports.WithdrawLiquidityRequestSchema = WithdrawLiquidityRequestSchema;
1358
+ exports.WithdrawLiquidityResponseSchema = WithdrawLiquidityResponseSchema;
1359
+ exports.WithdrawTokensRequestSchema = WithdrawTokensRequestSchema;
1360
+ exports.WithdrawTokensResponseSchema = WithdrawTokensResponseSchema;
1361
+ exports.initializePublicRegistry = initializePublicRegistry;
1536
1362
  //# sourceMappingURL=index.cjs.map