@1delta/margin-fetcher 0.0.38 → 0.0.40
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/lending/aave-v2-type/publicCallBuild.d.ts +2 -2
- package/dist/lending/aave-v2-type/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/aave-v2-type/publicCallBuild.js +1 -81
- package/dist/lending/aave-v2-type/publicCallParse.d.ts.map +1 -1
- package/dist/lending/aave-v2-type/publicCallParse.js +2 -196
- package/dist/lending/aave-v3-type/publicCallParse.d.ts.map +1 -1
- package/dist/lending/aave-v3-type/publicCallParse.js +46 -33
- package/dist/lending/fetchLenderAll.d.ts.map +1 -1
- package/dist/lending/fetchLenderAll.js +2 -0
- package/dist/lending/morpho/constants/markets.d.ts.map +1 -1
- package/dist/lending/morpho/constants/markets.js +30 -0
- package/dist/lending/morpho/fetchPublic.d.ts.map +1 -1
- package/dist/lending/morpho/fetchPublic.js +45 -13
- package/dist/lending/morpho/getMarketsFromChain.d.ts.map +1 -1
- package/dist/lending/user-data/aave-v2-type/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/aave-v2-type/userCallBuild.js +1 -67
- package/dist/lending/user-data/aave-v2-type/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/aave-v2-type/userCallParse.js +0 -158
- package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallBuild.js +1 -0
- package/dist/prices/main-prices/fetchOracleData.js +7 -7
- package/dist/utils/parsing.d.ts +1 -1
- package/dist/utils/parsing.d.ts.map +1 -1
- package/dist/utils/parsing.js +2 -2
- package/dist/yields/index.d.ts.map +1 -1
- package/dist/yields/index.js +28 -1
- package/package.json +1 -1
- package/src/lending/aave-v2-type/publicCallBuild.ts +0 -86
- package/src/lending/aave-v2-type/publicCallParse.ts +0 -357
- package/src/lending/aave-v3-type/publicCallParse.ts +80 -56
- package/src/lending/fetchLenderAll.ts +1 -0
- package/src/lending/morpho/constants/markets.ts +30 -0
- package/src/lending/morpho/fetchPublic.ts +50 -14
- package/src/lending/morpho/getMarketsFromChain.ts +0 -1
- package/src/lending/user-data/aave-v2-type/userCallBuild.ts +0 -77
- package/src/lending/user-data/aave-v2-type/userCallParse.ts +0 -262
- package/src/lending/user-data/morpho/userCallBuild.ts +1 -0
- package/src/prices/main-prices/fetchOracleData.ts +7 -7
- package/src/utils/parsing.ts +2 -2
- package/src/yields/index.ts +39 -0
- package/test/lenderData.test.ts +3 -3
- package/test/mainPrices.test.ts +1 -1
- package/test/mbChain.test.ts +3 -4
- package/test/morpho.test.ts +1 -1
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
} from '../../assets'
|
|
8
8
|
import {
|
|
9
9
|
BPS,
|
|
10
|
-
convertRateToApr,
|
|
11
10
|
formatAaveRawApyToApr,
|
|
12
11
|
parseRawAmount,
|
|
13
12
|
} from '../../utils/parsing'
|
|
@@ -15,7 +14,6 @@ import {
|
|
|
15
14
|
AaveV2GeneralPublicResponse,
|
|
16
15
|
AaveV2TypeGetReserveConfigurationData,
|
|
17
16
|
AaveV2TypeGetReserveDataIndexes,
|
|
18
|
-
AaveV2TypeIncentivesControllerPoolInfoIndexes,
|
|
19
17
|
} from './types'
|
|
20
18
|
import { AdditionalYields } from '../../types'
|
|
21
19
|
import { GenericTokenList } from '../types'
|
|
@@ -29,361 +27,6 @@ export const getAaveV2ReservesDataConverter = (
|
|
|
29
27
|
tokenList: GenericTokenList = {},
|
|
30
28
|
): [(data: any[]) => AaveV2GeneralPublicResponse | undefined, number] => {
|
|
31
29
|
switch (lender) {
|
|
32
|
-
case Lender.AURELIUS: {
|
|
33
|
-
const assetsToQuery = getAaveAssets(chainId, lender)
|
|
34
|
-
|
|
35
|
-
const expectedNumberOfCalls = assetsToQuery.length * 6
|
|
36
|
-
return [
|
|
37
|
-
(data: any[]) => {
|
|
38
|
-
if (data.length !== expectedNumberOfCalls) {
|
|
39
|
-
return undefined
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const resultReserves: any = {}
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < assetsToQuery.length; i++) {
|
|
45
|
-
const asset = assetsToQuery[i]
|
|
46
|
-
const reserveData = data[i * 6]
|
|
47
|
-
const configData = data[i * 6 + 1]
|
|
48
|
-
|
|
49
|
-
const [, emission0PerSecondCollateral, ,] = data[i * 6 + 2]
|
|
50
|
-
const [, emission1PerSecondCollateral, ,] = data[i * 6 + 3]
|
|
51
|
-
const [, emission0PerSecondDebt, ,] = data[i * 6 + 4]
|
|
52
|
-
const [, emission1PerSecondDebt, ,] = data[i * 6 + 5]
|
|
53
|
-
|
|
54
|
-
const assetMeta = tokenList[asset]
|
|
55
|
-
const decimals = assetMeta?.decimals ?? 18
|
|
56
|
-
const totalStableDebt = parseRawAmount(
|
|
57
|
-
reserveData?.[
|
|
58
|
-
AaveV2TypeGetReserveDataIndexes.totalStableDebt
|
|
59
|
-
]?.toString(),
|
|
60
|
-
decimals,
|
|
61
|
-
)
|
|
62
|
-
const totalVariableDebt = parseRawAmount(
|
|
63
|
-
reserveData?.[
|
|
64
|
-
AaveV2TypeGetReserveDataIndexes.totalVariableDebt
|
|
65
|
-
]?.toString(),
|
|
66
|
-
decimals,
|
|
67
|
-
)
|
|
68
|
-
const liquidity = parseRawAmount(
|
|
69
|
-
reserveData?.[
|
|
70
|
-
AaveV2TypeGetReserveDataIndexes.availableLiquidity
|
|
71
|
-
]?.toString(),
|
|
72
|
-
decimals,
|
|
73
|
-
)
|
|
74
|
-
const totalAToken =
|
|
75
|
-
Number(liquidity) +
|
|
76
|
-
Number(totalStableDebt) +
|
|
77
|
-
Number(totalVariableDebt)
|
|
78
|
-
|
|
79
|
-
const oracleKey =
|
|
80
|
-
toOracleKey(assetMeta?.assetGroup) ??
|
|
81
|
-
toGenericPriceKey(asset, chainId)
|
|
82
|
-
const price = prices[oracleKey] ?? 1
|
|
83
|
-
|
|
84
|
-
const totalDepositsUSD = totalAToken * price
|
|
85
|
-
const totalDebtUSD = Number(totalVariableDebt) * price
|
|
86
|
-
|
|
87
|
-
resultReserves[asset] = {
|
|
88
|
-
poolId: asset,
|
|
89
|
-
underlying: asset,
|
|
90
|
-
asset: assetMeta,
|
|
91
|
-
// token amounts
|
|
92
|
-
totalDeposits: totalAToken,
|
|
93
|
-
totalDebtStable: totalStableDebt,
|
|
94
|
-
totalDebt: totalVariableDebt,
|
|
95
|
-
totalLiquidity: liquidity,
|
|
96
|
-
// USD amounts
|
|
97
|
-
totalDepositsUSD,
|
|
98
|
-
totalDebtStableUSD: Number(totalStableDebt) * price,
|
|
99
|
-
totalDebtUSD,
|
|
100
|
-
totalLiquidityUSD: Number(liquidity) * price,
|
|
101
|
-
// rates
|
|
102
|
-
depositRate: formatAaveRawApyToApr(
|
|
103
|
-
reserveData?.[
|
|
104
|
-
AaveV2TypeGetReserveDataIndexes.liquidityRate
|
|
105
|
-
]?.toString(),
|
|
106
|
-
),
|
|
107
|
-
variableBorrowRate: formatAaveRawApyToApr(
|
|
108
|
-
reserveData?.[
|
|
109
|
-
AaveV2TypeGetReserveDataIndexes.variableBorrowRate
|
|
110
|
-
]?.toString(),
|
|
111
|
-
),
|
|
112
|
-
stableBorrowRate: formatAaveRawApyToApr(
|
|
113
|
-
reserveData?.[
|
|
114
|
-
AaveV2TypeGetReserveDataIndexes.stableBorrowRate
|
|
115
|
-
]?.toString(),
|
|
116
|
-
),
|
|
117
|
-
stakingYield: additionalYields.intrinsicYields[oracleKey] ?? 0,
|
|
118
|
-
|
|
119
|
-
// rewards
|
|
120
|
-
rewards: {
|
|
121
|
-
WMNT: {
|
|
122
|
-
depositRate:
|
|
123
|
-
(convertRateToApr(
|
|
124
|
-
parseRawAmount(emission0PerSecondCollateral),
|
|
125
|
-
) /
|
|
126
|
-
totalDepositsUSD) *
|
|
127
|
-
prices['WMNT'],
|
|
128
|
-
variableBorrowRate:
|
|
129
|
-
(convertRateToApr(parseRawAmount(emission0PerSecondDebt)) /
|
|
130
|
-
totalDebtUSD) *
|
|
131
|
-
prices['WMNT'],
|
|
132
|
-
stableBorrowRate: 0,
|
|
133
|
-
},
|
|
134
|
-
// oAU allows for a 50% discount to pruchase AU, hence the price is the price of AU divided by 2
|
|
135
|
-
OAU: {
|
|
136
|
-
depositRate:
|
|
137
|
-
((convertRateToApr(
|
|
138
|
-
parseRawAmount(emission1PerSecondCollateral),
|
|
139
|
-
) /
|
|
140
|
-
totalDepositsUSD) *
|
|
141
|
-
(prices['AU'] ?? 0)) /
|
|
142
|
-
2,
|
|
143
|
-
variableBorrowRate:
|
|
144
|
-
((convertRateToApr(parseRawAmount(emission1PerSecondDebt)) /
|
|
145
|
-
totalDebtUSD) *
|
|
146
|
-
(prices['AU'] ?? 0)) /
|
|
147
|
-
2,
|
|
148
|
-
stableBorrowRate: 0,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
decimals: Number(
|
|
152
|
-
configData?.[AaveV2TypeGetReserveConfigurationData.decimals],
|
|
153
|
-
),
|
|
154
|
-
config: {
|
|
155
|
-
[LENDER_MODE_NO_MODE]: {
|
|
156
|
-
category: LENDER_MODE_NO_MODE,
|
|
157
|
-
// collateral factors
|
|
158
|
-
borrowCollateralFactor:
|
|
159
|
-
Number(
|
|
160
|
-
configData?.[
|
|
161
|
-
AaveV2TypeGetReserveConfigurationData.ltv
|
|
162
|
-
].toString(),
|
|
163
|
-
) / BPS,
|
|
164
|
-
collateralFactor:
|
|
165
|
-
Number(
|
|
166
|
-
configData?.[
|
|
167
|
-
AaveV2TypeGetReserveConfigurationData
|
|
168
|
-
.liquidationThreshold
|
|
169
|
-
].toString(),
|
|
170
|
-
) / BPS,
|
|
171
|
-
borrowFactor: 1,
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
liquidationBonus:
|
|
175
|
-
Number(
|
|
176
|
-
configData?.[
|
|
177
|
-
AaveV2TypeGetReserveConfigurationData.liquidationBonus
|
|
178
|
-
].toString(),
|
|
179
|
-
) / BPS,
|
|
180
|
-
// flags
|
|
181
|
-
collateralActive:
|
|
182
|
-
configData?.[
|
|
183
|
-
AaveV2TypeGetReserveConfigurationData.usageAsCollateralEnabled
|
|
184
|
-
],
|
|
185
|
-
borrowingEnabled:
|
|
186
|
-
configData?.[
|
|
187
|
-
AaveV2TypeGetReserveConfigurationData.borrowingEnabled
|
|
188
|
-
],
|
|
189
|
-
hasStable:
|
|
190
|
-
configData?.[
|
|
191
|
-
AaveV2TypeGetReserveConfigurationData.stableBorrowRateEnabled
|
|
192
|
-
],
|
|
193
|
-
isActive:
|
|
194
|
-
configData?.[AaveV2TypeGetReserveConfigurationData.isActive],
|
|
195
|
-
isFrozen:
|
|
196
|
-
configData?.[AaveV2TypeGetReserveConfigurationData.isFrozen],
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
data: resultReserves,
|
|
202
|
-
chainId,
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
expectedNumberOfCalls,
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
case Lender.LENDLE: {
|
|
209
|
-
const assetsToQuery = getAaveAssets(chainId, lender)
|
|
210
|
-
const expectedNumberOfCalls = assetsToQuery.length * 4 + 2
|
|
211
|
-
|
|
212
|
-
return [
|
|
213
|
-
(data: any[]) => {
|
|
214
|
-
if (data.length !== expectedNumberOfCalls) {
|
|
215
|
-
return undefined
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const rewardsPerSecond = Number(
|
|
219
|
-
parseRawAmount(data[expectedNumberOfCalls - 2].toString(), 18),
|
|
220
|
-
)
|
|
221
|
-
const totalAllocPoint = Number(
|
|
222
|
-
data[expectedNumberOfCalls - 1].toString(),
|
|
223
|
-
)
|
|
224
|
-
|
|
225
|
-
const resultReserves: any = {}
|
|
226
|
-
|
|
227
|
-
const lendPrice = prices['LEND']
|
|
228
|
-
|
|
229
|
-
for (let i = 0; i < assetsToQuery.length; i++) {
|
|
230
|
-
const asset = assetsToQuery[i]
|
|
231
|
-
const reserveData = data[i * 4]
|
|
232
|
-
const configData = data[i * 4 + 1]
|
|
233
|
-
|
|
234
|
-
const collateralRewardIndex = i * 4 + 2
|
|
235
|
-
const borrowRewardIndex = i * 4 + 3
|
|
236
|
-
const collateralRewards =
|
|
237
|
-
(Number(
|
|
238
|
-
data?.[collateralRewardIndex]?.[
|
|
239
|
-
AaveV2TypeIncentivesControllerPoolInfoIndexes.allocPoint
|
|
240
|
-
].toString(),
|
|
241
|
-
) /
|
|
242
|
-
totalAllocPoint) *
|
|
243
|
-
rewardsPerSecond
|
|
244
|
-
const borrowRewards =
|
|
245
|
-
(Number(
|
|
246
|
-
data?.[borrowRewardIndex]?.[
|
|
247
|
-
AaveV2TypeIncentivesControllerPoolInfoIndexes.allocPoint
|
|
248
|
-
].toString(),
|
|
249
|
-
) /
|
|
250
|
-
totalAllocPoint) *
|
|
251
|
-
rewardsPerSecond
|
|
252
|
-
|
|
253
|
-
const assetMeta = tokenList[asset]
|
|
254
|
-
const decimals = assetMeta?.decimals ?? 18
|
|
255
|
-
|
|
256
|
-
const totalStableDebt = parseRawAmount(
|
|
257
|
-
reserveData?.[
|
|
258
|
-
AaveV2TypeGetReserveDataIndexes.totalStableDebt
|
|
259
|
-
]?.toString(),
|
|
260
|
-
decimals,
|
|
261
|
-
)
|
|
262
|
-
const totalVariableDebt = parseRawAmount(
|
|
263
|
-
reserveData?.[
|
|
264
|
-
AaveV2TypeGetReserveDataIndexes.totalVariableDebt
|
|
265
|
-
]?.toString(),
|
|
266
|
-
decimals,
|
|
267
|
-
)
|
|
268
|
-
const liquidity = parseRawAmount(
|
|
269
|
-
reserveData?.[
|
|
270
|
-
AaveV2TypeGetReserveDataIndexes.availableLiquidity
|
|
271
|
-
]?.toString(),
|
|
272
|
-
decimals,
|
|
273
|
-
)
|
|
274
|
-
const totalAToken =
|
|
275
|
-
Number(liquidity) +
|
|
276
|
-
Number(totalStableDebt) +
|
|
277
|
-
Number(totalVariableDebt)
|
|
278
|
-
const oracleKey =
|
|
279
|
-
toOracleKey(assetMeta?.assetGroup) ??
|
|
280
|
-
toGenericPriceKey(asset, chainId)
|
|
281
|
-
const price = prices?.[oracleKey] ?? 1
|
|
282
|
-
|
|
283
|
-
const totalDepositsUSD = totalAToken * price
|
|
284
|
-
const totalDebtUSD = Number(totalVariableDebt) * price
|
|
285
|
-
|
|
286
|
-
resultReserves[asset] = {
|
|
287
|
-
poolId: asset,
|
|
288
|
-
underlying: asset,
|
|
289
|
-
asset: assetMeta,
|
|
290
|
-
// token amounts
|
|
291
|
-
totalDeposits: totalAToken,
|
|
292
|
-
totalDebtStable: totalStableDebt,
|
|
293
|
-
totalDebt: totalVariableDebt,
|
|
294
|
-
totalLiquidity: liquidity,
|
|
295
|
-
// USD amounts
|
|
296
|
-
totalDepositsUSD,
|
|
297
|
-
totalDebtStableUSD: Number(totalStableDebt) * price,
|
|
298
|
-
totalDebtUSD,
|
|
299
|
-
totalLiquidityUSD: Number(liquidity) * price,
|
|
300
|
-
// rates
|
|
301
|
-
depositRate: formatAaveRawApyToApr(
|
|
302
|
-
reserveData?.[
|
|
303
|
-
AaveV2TypeGetReserveDataIndexes.liquidityRate
|
|
304
|
-
]?.toString(),
|
|
305
|
-
),
|
|
306
|
-
variableBorrowRate: formatAaveRawApyToApr(
|
|
307
|
-
reserveData?.[
|
|
308
|
-
AaveV2TypeGetReserveDataIndexes.variableBorrowRate
|
|
309
|
-
]?.toString(),
|
|
310
|
-
),
|
|
311
|
-
stableBorrowRate: formatAaveRawApyToApr(
|
|
312
|
-
reserveData?.[
|
|
313
|
-
AaveV2TypeGetReserveDataIndexes.stableBorrowRate
|
|
314
|
-
]?.toString(),
|
|
315
|
-
),
|
|
316
|
-
stakingYield: additionalYields.intrinsicYields[oracleKey] ?? 0,
|
|
317
|
-
|
|
318
|
-
// rewards
|
|
319
|
-
rewards: {
|
|
320
|
-
LEND: {
|
|
321
|
-
depositRate:
|
|
322
|
-
convertRateToApr(collateralRewards / totalDepositsUSD) *
|
|
323
|
-
lendPrice,
|
|
324
|
-
variableBorrowRate:
|
|
325
|
-
convertRateToApr(
|
|
326
|
-
totalDebtUSD > 0 ? borrowRewards / totalDebtUSD : 0,
|
|
327
|
-
) * lendPrice,
|
|
328
|
-
stableBorrowRate: 0,
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
decimals: Number(
|
|
332
|
-
configData?.[AaveV2TypeGetReserveConfigurationData.decimals],
|
|
333
|
-
),
|
|
334
|
-
config: {
|
|
335
|
-
[LENDER_MODE_NO_MODE]: {
|
|
336
|
-
category: LENDER_MODE_NO_MODE,
|
|
337
|
-
// collateral factors
|
|
338
|
-
borrowCollateralFactor:
|
|
339
|
-
Number(
|
|
340
|
-
configData?.[
|
|
341
|
-
AaveV2TypeGetReserveConfigurationData.ltv
|
|
342
|
-
].toString(),
|
|
343
|
-
) / BPS,
|
|
344
|
-
collateralFactor:
|
|
345
|
-
Number(
|
|
346
|
-
configData?.[
|
|
347
|
-
AaveV2TypeGetReserveConfigurationData
|
|
348
|
-
.liquidationThreshold
|
|
349
|
-
].toString(),
|
|
350
|
-
) / BPS,
|
|
351
|
-
borrowFactor: 1,
|
|
352
|
-
},
|
|
353
|
-
},
|
|
354
|
-
liquidationBonus:
|
|
355
|
-
Number(
|
|
356
|
-
configData?.[
|
|
357
|
-
AaveV2TypeGetReserveConfigurationData.liquidationBonus
|
|
358
|
-
].toString(),
|
|
359
|
-
) / BPS,
|
|
360
|
-
// flags
|
|
361
|
-
collateralActive:
|
|
362
|
-
configData?.[
|
|
363
|
-
AaveV2TypeGetReserveConfigurationData.usageAsCollateralEnabled
|
|
364
|
-
],
|
|
365
|
-
borrowingEnabled:
|
|
366
|
-
configData?.[
|
|
367
|
-
AaveV2TypeGetReserveConfigurationData.borrowingEnabled
|
|
368
|
-
],
|
|
369
|
-
hasStable:
|
|
370
|
-
configData?.[
|
|
371
|
-
AaveV2TypeGetReserveConfigurationData.stableBorrowRateEnabled
|
|
372
|
-
],
|
|
373
|
-
isActive:
|
|
374
|
-
configData?.[AaveV2TypeGetReserveConfigurationData.isActive],
|
|
375
|
-
isFrozen:
|
|
376
|
-
configData?.[AaveV2TypeGetReserveConfigurationData.isFrozen],
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
return {
|
|
380
|
-
data: resultReserves,
|
|
381
|
-
chainId,
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
expectedNumberOfCalls,
|
|
385
|
-
]
|
|
386
|
-
}
|
|
387
30
|
/** AAVE V2 style with rewards from state */
|
|
388
31
|
default: {
|
|
389
32
|
const assetsToQuery = getAaveAssets(chainId, lender)
|
|
@@ -158,31 +158,17 @@ export const getAaveV3ReservesDataConverter = (
|
|
|
158
158
|
configData?.[AaveV3GetreserveConfigDataIndexes.decimals],
|
|
159
159
|
),
|
|
160
160
|
|
|
161
|
-
config:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
? {
|
|
173
|
-
[eModeCategory]: {
|
|
174
|
-
category: eModeCategory,
|
|
175
|
-
label: eModeConfigs[eModeCategory]?.label ?? 'Default',
|
|
176
|
-
borrowCollateralFactor:
|
|
177
|
-
eModeConfigs[eModeCategory]?.borrowCollateralFactor ??
|
|
178
|
-
0,
|
|
179
|
-
collateralFactor:
|
|
180
|
-
eModeConfigs[eModeCategory]?.collateralFactor ?? 0,
|
|
181
|
-
borrowFactor: 1,
|
|
182
|
-
},
|
|
183
|
-
}
|
|
184
|
-
: {}),
|
|
185
|
-
},
|
|
161
|
+
config: populateEModes(
|
|
162
|
+
Number(configData?.[AaveV3GetreserveConfigDataIndexes.ltv]) /
|
|
163
|
+
BPS,
|
|
164
|
+
Number(
|
|
165
|
+
configData?.[
|
|
166
|
+
AaveV3GetreserveConfigDataIndexes.liquidationThreshold
|
|
167
|
+
],
|
|
168
|
+
) / BPS,
|
|
169
|
+
eModeCategory,
|
|
170
|
+
eModeConfigs,
|
|
171
|
+
),
|
|
186
172
|
|
|
187
173
|
// flags
|
|
188
174
|
collateralActive:
|
|
@@ -229,6 +215,8 @@ export const getAaveV3ReservesDataConverter = (
|
|
|
229
215
|
const populateEModes = (
|
|
230
216
|
borrowCollateralFactor: number,
|
|
231
217
|
collateralFactor: number,
|
|
218
|
+
eModeCategory: number,
|
|
219
|
+
eModeConfigs: any,
|
|
232
220
|
) => {
|
|
233
221
|
let data: any = {}
|
|
234
222
|
AAVE_V3_EMODES.forEach((e) => {
|
|
@@ -238,6 +226,56 @@ const populateEModes = (
|
|
|
238
226
|
collateralFactor,
|
|
239
227
|
borrowFactor: 1,
|
|
240
228
|
}
|
|
229
|
+
|
|
230
|
+
if (e > 0) data[e].debtDisabled = true
|
|
231
|
+
|
|
232
|
+
if (e > 0 && e === eModeCategory && eModeConfigs[e]) {
|
|
233
|
+
data[e] = {
|
|
234
|
+
...data[e],
|
|
235
|
+
category: e,
|
|
236
|
+
label: eModeConfigs[e]?.label ?? 'Default',
|
|
237
|
+
borrowCollateralFactor: eModeConfigs[e]?.borrowCollateralFactor ?? 0,
|
|
238
|
+
collateralFactor: eModeConfigs[e]?.collateralFactor ?? 0,
|
|
239
|
+
borrowFactor: 1,
|
|
240
|
+
debtDisabled: false,
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
return data
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const populateEModes32 = (
|
|
248
|
+
borrowCollateralFactor: number,
|
|
249
|
+
collateralFactor: number,
|
|
250
|
+
collateralBitmap: any,
|
|
251
|
+
debtBitmap: any,
|
|
252
|
+
assetIndex: number,
|
|
253
|
+
eModeConfigs: any,
|
|
254
|
+
) => {
|
|
255
|
+
let data: any = {}
|
|
256
|
+
AAVE_V3_EMODES.forEach((e) => {
|
|
257
|
+
data[e] = {
|
|
258
|
+
category: e,
|
|
259
|
+
borrowCollateralFactor,
|
|
260
|
+
collateralFactor,
|
|
261
|
+
borrowFactor: 1,
|
|
262
|
+
}
|
|
263
|
+
if (e > 0) data[e].debtDisabled = !!eModeConfigs[e]
|
|
264
|
+
if (e > 0 && eModeConfigs[e]) {
|
|
265
|
+
data[e] = {
|
|
266
|
+
...data[e],
|
|
267
|
+
category: e,
|
|
268
|
+
label: eModeConfigs[e]?.label ?? 'Default',
|
|
269
|
+
borrowCollateralFactor: eModeConfigs[e]?.borrowCollateralFactor ?? 0,
|
|
270
|
+
collateralFactor: eModeConfigs[e]?.collateralFactor ?? 0,
|
|
271
|
+
borrowFactor: 1,
|
|
272
|
+
collateralDisabled: !isReserveEnabledOnBitmap(
|
|
273
|
+
collateralBitmap[e],
|
|
274
|
+
assetIndex,
|
|
275
|
+
),
|
|
276
|
+
debtDisabled: !isReserveEnabledOnBitmap(debtBitmap[e], assetIndex),
|
|
277
|
+
}
|
|
278
|
+
}
|
|
241
279
|
})
|
|
242
280
|
return data
|
|
243
281
|
}
|
|
@@ -423,6 +461,7 @@ function parseAave32(
|
|
|
423
461
|
debtBitmap[mode] = emodeDataResult[3 * index + 1]
|
|
424
462
|
collateralBitmap[mode] = emodeDataResult[3 * index + 2]
|
|
425
463
|
})
|
|
464
|
+
|
|
426
465
|
// we get the reserves list to obtain the index per reserve
|
|
427
466
|
const lowerReservesList = (reservesList as string[])?.map((a) =>
|
|
428
467
|
a.toLowerCase(),
|
|
@@ -495,18 +534,14 @@ function parseAave32(
|
|
|
495
534
|
// rewards
|
|
496
535
|
rewards: {},
|
|
497
536
|
}
|
|
537
|
+
const assetIndex = lowerReservesList.indexOf(asset)
|
|
498
538
|
const activeEmodes = AAVE_V3_EMODES.map((mode) =>
|
|
499
|
-
isReserveEnabledOnBitmap(
|
|
500
|
-
|
|
501
|
-
lowerReservesList.indexOf(asset),
|
|
502
|
-
) ||
|
|
503
|
-
isReserveEnabledOnBitmap(
|
|
504
|
-
collateralBitmap[mode],
|
|
505
|
-
lowerReservesList.indexOf(asset),
|
|
506
|
-
)
|
|
539
|
+
isReserveEnabledOnBitmap(debtBitmap[mode], assetIndex) ||
|
|
540
|
+
isReserveEnabledOnBitmap(collateralBitmap[mode], assetIndex)
|
|
507
541
|
? mode
|
|
508
542
|
: -1,
|
|
509
543
|
).filter((m) => m !== undefined && m > 0)
|
|
544
|
+
|
|
510
545
|
const eModeCategory = activeEmodes.length === 0 ? 0 : activeEmodes[0] // Number(emodeResult[index].toString())
|
|
511
546
|
|
|
512
547
|
resultReserves[asset] = {
|
|
@@ -515,29 +550,18 @@ function parseAave32(
|
|
|
515
550
|
configData?.[AaveV3GetreserveConfigDataIndexes.decimals],
|
|
516
551
|
),
|
|
517
552
|
|
|
518
|
-
config:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
category: eModeCategory,
|
|
531
|
-
label: eModeConfigs[eModeCategory]?.label ?? 'Default',
|
|
532
|
-
borrowCollateralFactor:
|
|
533
|
-
eModeConfigs[eModeCategory]?.borrowCollateralFactor ?? 0,
|
|
534
|
-
collateralFactor:
|
|
535
|
-
eModeConfigs[eModeCategory]?.collateralFactor ?? 0,
|
|
536
|
-
borrowFactor: 1,
|
|
537
|
-
},
|
|
538
|
-
}
|
|
539
|
-
: {}),
|
|
540
|
-
},
|
|
553
|
+
config: populateEModes32(
|
|
554
|
+
Number(configData?.[AaveV3GetreserveConfigDataIndexes.ltv]) / BPS,
|
|
555
|
+
Number(
|
|
556
|
+
configData?.[
|
|
557
|
+
AaveV3GetreserveConfigDataIndexes.liquidationThreshold
|
|
558
|
+
],
|
|
559
|
+
) / BPS,
|
|
560
|
+
collateralBitmap,
|
|
561
|
+
debtBitmap,
|
|
562
|
+
assetIndex,
|
|
563
|
+
eModeConfigs,
|
|
564
|
+
),
|
|
541
565
|
|
|
542
566
|
// flags
|
|
543
567
|
collateralActive:
|
|
@@ -10,6 +10,7 @@ function lenderCanUseApi(lender: string, chainId: string) {
|
|
|
10
10
|
if (chainId === Chain.HYPEREVM) return false
|
|
11
11
|
if (chainId === Chain.OP_MAINNET) return false
|
|
12
12
|
if (chainId === Chain.SONEIUM) return false
|
|
13
|
+
if (chainId === Chain.HEMI_NETWORK) return false
|
|
13
14
|
return true
|
|
14
15
|
}
|
|
15
16
|
return false
|
|
@@ -18,6 +18,23 @@ export const MORPHO_MARKETS: { [chain: string]: string[] } = {
|
|
|
18
18
|
'0x19e47d37453628ebf0fd18766ce6fee1b08ea46752a5da83ca0bfecb270d07e8',
|
|
19
19
|
'0x1c6b87ae1b97071ef444eedcba9f5a92cfe974edbbcaa1946644fc7ab0e283af',
|
|
20
20
|
'0x1da89208e6cb5173e97a83461853b8400de4f7c37542cf010a10579a5f7ca451',
|
|
21
|
+
'0x292f0a3ddfb642fbaadf258ebcccf9e4b0048a9dc5af93036288502bde1a71b1',
|
|
22
|
+
'0xace279b5c6eff0a1ce7287249369fa6f4d3d32225e1629b04ef308e0eb568fb0',
|
|
23
|
+
'0x96c7abf76aed53d50b2cc84e2ed17846e0d1c4cc28236d95b6eb3b12dcc86909',
|
|
24
|
+
'0x5fe3ac84f3a2c4e3102c3e6e9accb1ec90c30f6ee87ab1fcafc197b8addeb94c',
|
|
25
|
+
'0x707dddc200e95dc984feb185abf1321cabec8486dca5a9a96fb5202184106e54',
|
|
26
|
+
'0x87272614b7a2022c31ddd7bba8eb21d5ab40a6bcbea671264d59dc732053721d',
|
|
27
|
+
'0xe9a9bb9ed3cc53f4ee9da4eea0370c2c566873d5de807e16559a99907c9ae227',
|
|
28
|
+
'0xb39e45107152f02502c001a46e2d3513f429d2363323cdaffbc55a951a69b998',
|
|
29
|
+
'0x1f79fe1822f6bfe7a70f8e7e5e768efd0c3f10db52af97c2f14e4b71e3130e70',
|
|
30
|
+
'0xe500760b79e397869927a5275d64987325faae43326daf6be5a560184e30a521',
|
|
31
|
+
'0x86d7bc359391486de8cd1204da45c53d6ada60ab9764450dc691e1775b2e8d69',
|
|
32
|
+
'0x920244a8682a53b17fe15597b63abdaa3aecec44e070379c5e43897fb9f42a2b',
|
|
33
|
+
'0xd4fd53f612eaf411a1acea053cfa28cbfeea683273c4133bf115b47a20130305',
|
|
34
|
+
'0x1df0d0ebcdc52069692452cb9a3e5cf6c017b237378141eaf08a05ce17205ed6',
|
|
35
|
+
'0x888679b2af61343a4c7c0da0639fc5ca5fc5727e246371c4425e4d634c09e1f6',
|
|
36
|
+
'0xe0a1de770a9a72a083087fe1745c998426aaea984ddf155ea3d5fbba5b759713',
|
|
37
|
+
'0x1df0d0ebcdc52069692452cb9a3e5cf6c017b237378141eaf08a05ce17205ed6',
|
|
21
38
|
'0x216bd19960f140177a4a3fb9cf258edcbadb1f5d54740fc944503bff4a00e65e',
|
|
22
39
|
'0x2acd218c67daa94dd2f92e81f477ffc9f8507319f0f2d698eae5ed631ae14039',
|
|
23
40
|
'0x2b62c4153d81d5b5a233d1d2b7ef899d3fca4076d458e215ff3a00176b415b0d',
|
|
@@ -27,8 +44,11 @@ export const MORPHO_MARKETS: { [chain: string]: string[] } = {
|
|
|
27
44
|
'0x53bf81793c2cc384c19a3bc9b032467e179a390a9225cd9542742ac10f539cc2',
|
|
28
45
|
'0x5ecb7a25d51c870ec57f810c880e3e20743e56d0524575b7b8934a778aaec1af',
|
|
29
46
|
'0x5ef35fe4418a6bcfcc70fe32efce30074f22e9a782f81d432c1e537ddbda11e2',
|
|
47
|
+
'0x64e7db7f042812d4335947a7cdf6af1093d29478aff5f1ccd93cc67f8aadfddc',
|
|
30
48
|
'0x65f2a559764859a559d8c39604cf665942bab7d10dfaa1b82e914c9d351038d4',
|
|
49
|
+
'0x707dddc200e95dc984feb185abf1321cabec8486dca5a9a96fb5202184106e54',
|
|
31
50
|
'0x7268244d330f1462f77ded7a14e2f868893e86e76e8b8eaa869405d588aff6ce',
|
|
51
|
+
'0x78f6b57d825ef01a5dc496ad1f426a6375c685047d07a30cd07ac5107ffc7976',
|
|
32
52
|
'0x83bab0d612f592d0f145b2ec82fd730144dfb3d72c8fc838b27555558e49c496',
|
|
33
53
|
'0x8eb8cfe3b1ac8f653608ae09fb099263fa2fe25d4a59305c309937292c2aeee9',
|
|
34
54
|
'0x964e7d1db11bdf32262c71274c297dcdb4710d73acb814f04fdca8b0c7cdf028',
|
|
@@ -36,6 +56,7 @@ export const MORPHO_MARKETS: { [chain: string]: string[] } = {
|
|
|
36
56
|
'0xa24d04c3aff60d49b3475f0084334546cbf66182e788b6bf173e6f9990b2c816',
|
|
37
57
|
'0xa62327642e110efd38ba2d153867a8625c8dc40832e1d211ba4f4151c3de9050',
|
|
38
58
|
'0xa7fe39c692f0192fb2f281a6cc16c8b2e1c8f9b9f2bc418e0c0c1e9374bf4b04',
|
|
59
|
+
'0xace279b5c6eff0a1ce7287249369fa6f4d3d32225e1629b04ef308e0eb568fb0',
|
|
39
60
|
'0xb142d65d7c624def0a9f4b49115b83f400a86bd2904d4f3339ec4441e28483ea',
|
|
40
61
|
'0xb5b575e402c7c19def8661069c39464c8bf3297b638e64d841b09a4eb2807de5',
|
|
41
62
|
'0xbc15a1782163f4be46c23ac61f5da50fed96ad40293f86a5ce0501ce4a246b32',
|
|
@@ -48,6 +69,7 @@ export const MORPHO_MARKETS: { [chain: string]: string[] } = {
|
|
|
48
69
|
'0xebeabb17bd69d4b8ed6929a821d69478b564f4cc604d0995944c9da8b5cb3f04',
|
|
49
70
|
'0xed00791e29eb08c9bc0d8b389fe1f00084699baf2a785ba2a42e915706b17b82',
|
|
50
71
|
'0xf25db2433ae650155eae04ebd8b3795d19bfcb318d22926a8a5e746e8028e0a8',
|
|
72
|
+
'0xfbe436e9aa361487f0c3e4ff94c88aea72887a4482c6b8bcfec60a8584cdb05e',
|
|
51
73
|
],
|
|
52
74
|
[Chain.OP_MAINNET]: [
|
|
53
75
|
'0x173b66359f0741b1c7f1963075cd271c739b6dc73b658e108a54ce6febeb279b',
|
|
@@ -61,4 +83,12 @@ export const MORPHO_MARKETS: { [chain: string]: string[] } = {
|
|
|
61
83
|
'0xebaf3dc6fa2fb3f78d18c87adcc37c06fe64874c5b2d69619ef7696088780df9',
|
|
62
84
|
'0x5869019d7ec9f92db2e90c0156b542cda7c0a679c626eac842aa5117a0483d4a',
|
|
63
85
|
],
|
|
86
|
+
[Chain.HEMI_NETWORK]: [
|
|
87
|
+
'0x36931ab4ffe6fed55ab0624afd2bf6eb1cebdbd6d5c98334e949841e402f86ff',
|
|
88
|
+
'0x08abb2b634eb6454a5819dbaa5c0229136989a9990ed757727c406dbcb4e606b',
|
|
89
|
+
'0xf1b97d86baa12ef4622eeca186a49fa7f7ea1ac2aa55ea4c20a26e815ddd6bc6',
|
|
90
|
+
'0xb7dd4c2e7c164de474b28c354cddb137deb0ce2583b925d20c33322074c22178',
|
|
91
|
+
'0x4b670128dfaa02a92f833bb9b99949262b685c2d3f55d4f7c97da1849d2b6355',
|
|
92
|
+
'0x7c985a3ba92fa76a362f661b37a68c9955490eb659b7905aab6019b91042b452',
|
|
93
|
+
],
|
|
64
94
|
}
|