@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 +1266 -1440
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +857 -837
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1220 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1279 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/index.d.ts +0 -1200
- package/dist/index.js +0 -1450
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,1536 +1,1362 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
112
|
-
Object.values(TransactionTypes)
|
|
113
|
-
);
|
|
43
|
+
const TransactionTypeSchema = zod.z.enum(Object.values(TransactionTypes));
|
|
114
44
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
87
|
+
const ProviderTrackingInfoSchema = zod.z.object({
|
|
88
|
+
requestId: zod.z.string(),
|
|
89
|
+
providerName: zod.z.string(),
|
|
90
|
+
explorerUrl: zod.z.string()
|
|
160
91
|
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
92
|
+
const SwapEstimationSchema = zod.z.object({
|
|
93
|
+
effectivePrice: zod.z.string(),
|
|
94
|
+
timeEstimate: zod.z.string(),
|
|
95
|
+
expiration: zod.z.string()
|
|
165
96
|
});
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
118
|
+
const RepayTokensRequestSchema = zod.z.object({
|
|
119
|
+
repayToken: TokenSchema,
|
|
120
|
+
amount: zod.z.bigint(),
|
|
121
|
+
walletAddress: zod.z.string()
|
|
191
122
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
123
|
+
const RepayTokensResponseSchema = zod.z.object({
|
|
124
|
+
feeBreakdown: FeeBreakdownSchema.optional(),
|
|
125
|
+
transactions: zod.z.array(TransactionPlanSchema)
|
|
195
126
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
127
|
+
const SupplyTokensRequestSchema = zod.z.object({
|
|
128
|
+
supplyToken: TokenSchema,
|
|
129
|
+
amount: zod.z.bigint(),
|
|
130
|
+
walletAddress: zod.z.string()
|
|
200
131
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
132
|
+
const SupplyTokensResponseSchema = zod.z.object({
|
|
133
|
+
feeBreakdown: FeeBreakdownSchema.optional(),
|
|
134
|
+
transactions: zod.z.array(TransactionPlanSchema)
|
|
204
135
|
});
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
136
|
+
const WithdrawTokensRequestSchema = zod.z.object({
|
|
137
|
+
tokenToWithdraw: TokenSchema,
|
|
138
|
+
amount: zod.z.bigint(),
|
|
139
|
+
walletAddress: zod.z.string()
|
|
209
140
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
141
|
+
const WithdrawTokensResponseSchema = zod.z.object({
|
|
142
|
+
feeBreakdown: FeeBreakdownSchema.optional(),
|
|
143
|
+
transactions: zod.z.array(TransactionPlanSchema)
|
|
213
144
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
186
|
+
const LiquiditySuppliedTokenSchema = zod.z.object({
|
|
187
|
+
tokenUid: TokenIdentifierSchema,
|
|
188
|
+
suppliedAmount: zod.z.string(),
|
|
189
|
+
owedTokens: zod.z.string()
|
|
264
190
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
274
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
220
|
+
const WithdrawLiquidityRequestSchema = zod.z.object({
|
|
221
|
+
poolToken: TokenSchema,
|
|
222
|
+
walletAddress: zod.z.string()
|
|
295
223
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/core/schemas/perpetuals.ts
|
|
234
|
+
const DecreasePositionSwapTypeSchema = zod.z.enum([
|
|
235
|
+
"NoSwap",
|
|
236
|
+
"SwapPnlTokenToCollateralToken",
|
|
237
|
+
"SwapCollateralTokenToPnlToken"
|
|
320
238
|
]);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
400
|
-
|
|
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
|
-
|
|
403
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
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
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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
|
-
|
|
465
|
-
|
|
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
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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
|
-
|
|
528
|
-
|
|
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
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
-
|
|
889
|
-
|
|
890
|
-
|
|
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
|
-
|
|
826
|
+
//#endregion
|
|
827
|
+
//#region src/aave-lending-plugin/populateTransaction.ts
|
|
896
828
|
async function populateTransaction(tx) {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
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
|
-
|
|
922
|
-
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region src/aave-lending-plugin/userSummary.ts
|
|
923
848
|
function formatNumeric(value) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
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
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
`;
|
|
955
|
-
|
|
956
|
-
`;
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
`;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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
|
-
|
|
988
|
-
|
|
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
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
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
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
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
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
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
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
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
|
-
|
|
1250
|
+
//#endregion
|
|
1251
|
+
//#region src/registry.ts
|
|
1252
|
+
/**
|
|
1253
|
+
* Registry for public Ember plugins.
|
|
1254
|
+
*/
|
|
1431
1255
|
var PublicEmberPluginRegistry = class {
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
}
|
|
1471
|
-
return registry;
|
|
1296
|
+
const registry = new PublicEmberPluginRegistry();
|
|
1297
|
+
for (const chainConfig of chainConfigs) registerAave(chainConfig, registry);
|
|
1298
|
+
return registry;
|
|
1472
1299
|
}
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
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
|