@1delta/margin-fetcher 0.0.38 → 0.0.39
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-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/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-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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAK5B,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAOhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,eAAO,MAAM,8BAA8B,GACzC,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,2BAA2B,GAAG,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAK5B,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAOhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,eAAO,MAAM,8BAA8B,GACzC,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,2BAA2B,GAAG,SAAS,EAAE,MAAM,CA0LnE,CAAA;AAkFD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,GAAG,EACrB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,GAAG,GACb,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,SAAS,EAAE,MAAM,CAAC,CAuH5C"}
|
|
@@ -79,22 +79,8 @@ export const getAaveV3ReservesDataConverter = (lender, chainId, prices, addition
|
|
|
79
79
|
resultReserves[asset] = {
|
|
80
80
|
...resultReserves[asset],
|
|
81
81
|
decimals: Number(configData?.[AaveV3GetreserveConfigDataIndexes.decimals]),
|
|
82
|
-
config:
|
|
83
|
-
|
|
84
|
-
BPS, Number(configData?.[AaveV3GetreserveConfigDataIndexes.liquidationThreshold]) / BPS),
|
|
85
|
-
...(eModeCategory !== 0
|
|
86
|
-
? {
|
|
87
|
-
[eModeCategory]: {
|
|
88
|
-
category: eModeCategory,
|
|
89
|
-
label: eModeConfigs[eModeCategory]?.label ?? 'Default',
|
|
90
|
-
borrowCollateralFactor: eModeConfigs[eModeCategory]?.borrowCollateralFactor ??
|
|
91
|
-
0,
|
|
92
|
-
collateralFactor: eModeConfigs[eModeCategory]?.collateralFactor ?? 0,
|
|
93
|
-
borrowFactor: 1,
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
: {}),
|
|
97
|
-
},
|
|
82
|
+
config: populateEModes(Number(configData?.[AaveV3GetreserveConfigDataIndexes.ltv]) /
|
|
83
|
+
BPS, Number(configData?.[AaveV3GetreserveConfigDataIndexes.liquidationThreshold]) / BPS, eModeCategory, eModeConfigs),
|
|
98
84
|
// flags
|
|
99
85
|
collateralActive: configData?.[AaveV3GetreserveConfigDataIndexes.usageAsCollateralEnabled],
|
|
100
86
|
borrowingEnabled: configData?.[AaveV3GetreserveConfigDataIndexes.borrowingEnabled],
|
|
@@ -120,7 +106,7 @@ export const getAaveV3ReservesDataConverter = (lender, chainId, prices, addition
|
|
|
120
106
|
}
|
|
121
107
|
}
|
|
122
108
|
};
|
|
123
|
-
const populateEModes = (borrowCollateralFactor, collateralFactor) => {
|
|
109
|
+
const populateEModes = (borrowCollateralFactor, collateralFactor, eModeCategory, eModeConfigs) => {
|
|
124
110
|
let data = {};
|
|
125
111
|
AAVE_V3_EMODES.forEach((e) => {
|
|
126
112
|
data[e] = {
|
|
@@ -129,6 +115,45 @@ const populateEModes = (borrowCollateralFactor, collateralFactor) => {
|
|
|
129
115
|
collateralFactor,
|
|
130
116
|
borrowFactor: 1,
|
|
131
117
|
};
|
|
118
|
+
if (e > 0)
|
|
119
|
+
data[e].debtDisabled = true;
|
|
120
|
+
if (e > 0 && e === eModeCategory && eModeConfigs[e]) {
|
|
121
|
+
data[e] = {
|
|
122
|
+
...data[e],
|
|
123
|
+
category: e,
|
|
124
|
+
label: eModeConfigs[e]?.label ?? 'Default',
|
|
125
|
+
borrowCollateralFactor: eModeConfigs[e]?.borrowCollateralFactor ?? 0,
|
|
126
|
+
collateralFactor: eModeConfigs[e]?.collateralFactor ?? 0,
|
|
127
|
+
borrowFactor: 1,
|
|
128
|
+
debtDisabled: false,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return data;
|
|
133
|
+
};
|
|
134
|
+
const populateEModes32 = (borrowCollateralFactor, collateralFactor, collateralBitmap, debtBitmap, assetIndex, eModeConfigs) => {
|
|
135
|
+
let data = {};
|
|
136
|
+
AAVE_V3_EMODES.forEach((e) => {
|
|
137
|
+
data[e] = {
|
|
138
|
+
category: e,
|
|
139
|
+
borrowCollateralFactor,
|
|
140
|
+
collateralFactor,
|
|
141
|
+
borrowFactor: 1,
|
|
142
|
+
};
|
|
143
|
+
if (e > 0)
|
|
144
|
+
data[e].debtDisabled = !!eModeConfigs[e];
|
|
145
|
+
if (e > 0 && eModeConfigs[e]) {
|
|
146
|
+
data[e] = {
|
|
147
|
+
...data[e],
|
|
148
|
+
category: e,
|
|
149
|
+
label: eModeConfigs[e]?.label ?? 'Default',
|
|
150
|
+
borrowCollateralFactor: eModeConfigs[e]?.borrowCollateralFactor ?? 0,
|
|
151
|
+
collateralFactor: eModeConfigs[e]?.collateralFactor ?? 0,
|
|
152
|
+
borrowFactor: 1,
|
|
153
|
+
collateralDisabled: !isReserveEnabledOnBitmap(collateralBitmap[e], assetIndex),
|
|
154
|
+
debtDisabled: !isReserveEnabledOnBitmap(debtBitmap[e], assetIndex),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
132
157
|
});
|
|
133
158
|
return data;
|
|
134
159
|
};
|
|
@@ -281,28 +306,16 @@ function parseAave32(chainId, lender, prices, additionalYields, tokenList) {
|
|
|
281
306
|
// rewards
|
|
282
307
|
rewards: {},
|
|
283
308
|
};
|
|
284
|
-
const
|
|
285
|
-
|
|
309
|
+
const assetIndex = lowerReservesList.indexOf(asset);
|
|
310
|
+
const activeEmodes = AAVE_V3_EMODES.map((mode) => isReserveEnabledOnBitmap(debtBitmap[mode], assetIndex) ||
|
|
311
|
+
isReserveEnabledOnBitmap(collateralBitmap[mode], assetIndex)
|
|
286
312
|
? mode
|
|
287
313
|
: -1).filter((m) => m !== undefined && m > 0);
|
|
288
314
|
const eModeCategory = activeEmodes.length === 0 ? 0 : activeEmodes[0]; // Number(emodeResult[index].toString())
|
|
289
315
|
resultReserves[asset] = {
|
|
290
316
|
...resultReserves[asset],
|
|
291
317
|
decimals: Number(configData?.[AaveV3GetreserveConfigDataIndexes.decimals]),
|
|
292
|
-
config:
|
|
293
|
-
...populateEModes(Number(configData?.[AaveV3GetreserveConfigDataIndexes.ltv]) / BPS, Number(configData?.[AaveV3GetreserveConfigDataIndexes.liquidationThreshold]) / BPS),
|
|
294
|
-
...(eModeCategory !== 0
|
|
295
|
-
? {
|
|
296
|
-
[eModeCategory]: {
|
|
297
|
-
category: eModeCategory,
|
|
298
|
-
label: eModeConfigs[eModeCategory]?.label ?? 'Default',
|
|
299
|
-
borrowCollateralFactor: eModeConfigs[eModeCategory]?.borrowCollateralFactor ?? 0,
|
|
300
|
-
collateralFactor: eModeConfigs[eModeCategory]?.collateralFactor ?? 0,
|
|
301
|
-
borrowFactor: 1,
|
|
302
|
-
},
|
|
303
|
-
}
|
|
304
|
-
: {}),
|
|
305
|
-
},
|
|
318
|
+
config: populateEModes32(Number(configData?.[AaveV3GetreserveConfigDataIndexes.ltv]) / BPS, Number(configData?.[AaveV3GetreserveConfigDataIndexes.liquidationThreshold]) / BPS, collateralBitmap, debtBitmap, assetIndex, eModeConfigs),
|
|
306
319
|
// flags
|
|
307
320
|
collateralActive: configData?.[AaveV3GetreserveConfigDataIndexes.usageAsCollateralEnabled],
|
|
308
321
|
borrowingEnabled: configData?.[AaveV3GetreserveConfigDataIndexes.borrowingEnabled],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchLenderAll.d.ts","sourceRoot":"","sources":["../../src/lending/fetchLenderAll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"fetchLenderAll.d.ts","sourceRoot":"","sources":["../../src/lending/fetchLenderAll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAc1C,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,EACf,SAAS,MAAM,EAAE,EACjB,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,gBAAgB,sBAAsB,EACtC,YAAY,MAAM,OAAO,CAAC,gBAAgB,CAAC,KAC1C,OAAO,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAyBnC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markets.d.ts","sourceRoot":"","sources":["../../../../src/lending/morpho/constants/markets.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"markets.d.ts","sourceRoot":"","sources":["../../../../src/lending/morpho/constants/markets.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CA2FvD,CAAA"}
|
|
@@ -17,6 +17,23 @@ export const MORPHO_MARKETS = {
|
|
|
17
17
|
'0x19e47d37453628ebf0fd18766ce6fee1b08ea46752a5da83ca0bfecb270d07e8',
|
|
18
18
|
'0x1c6b87ae1b97071ef444eedcba9f5a92cfe974edbbcaa1946644fc7ab0e283af',
|
|
19
19
|
'0x1da89208e6cb5173e97a83461853b8400de4f7c37542cf010a10579a5f7ca451',
|
|
20
|
+
'0x292f0a3ddfb642fbaadf258ebcccf9e4b0048a9dc5af93036288502bde1a71b1',
|
|
21
|
+
'0xace279b5c6eff0a1ce7287249369fa6f4d3d32225e1629b04ef308e0eb568fb0',
|
|
22
|
+
'0x96c7abf76aed53d50b2cc84e2ed17846e0d1c4cc28236d95b6eb3b12dcc86909',
|
|
23
|
+
'0x5fe3ac84f3a2c4e3102c3e6e9accb1ec90c30f6ee87ab1fcafc197b8addeb94c',
|
|
24
|
+
'0x707dddc200e95dc984feb185abf1321cabec8486dca5a9a96fb5202184106e54',
|
|
25
|
+
'0x87272614b7a2022c31ddd7bba8eb21d5ab40a6bcbea671264d59dc732053721d',
|
|
26
|
+
'0xe9a9bb9ed3cc53f4ee9da4eea0370c2c566873d5de807e16559a99907c9ae227',
|
|
27
|
+
'0xb39e45107152f02502c001a46e2d3513f429d2363323cdaffbc55a951a69b998',
|
|
28
|
+
'0x1f79fe1822f6bfe7a70f8e7e5e768efd0c3f10db52af97c2f14e4b71e3130e70',
|
|
29
|
+
'0xe500760b79e397869927a5275d64987325faae43326daf6be5a560184e30a521',
|
|
30
|
+
'0x86d7bc359391486de8cd1204da45c53d6ada60ab9764450dc691e1775b2e8d69',
|
|
31
|
+
'0x920244a8682a53b17fe15597b63abdaa3aecec44e070379c5e43897fb9f42a2b',
|
|
32
|
+
'0xd4fd53f612eaf411a1acea053cfa28cbfeea683273c4133bf115b47a20130305',
|
|
33
|
+
'0x1df0d0ebcdc52069692452cb9a3e5cf6c017b237378141eaf08a05ce17205ed6',
|
|
34
|
+
'0x888679b2af61343a4c7c0da0639fc5ca5fc5727e246371c4425e4d634c09e1f6',
|
|
35
|
+
'0xe0a1de770a9a72a083087fe1745c998426aaea984ddf155ea3d5fbba5b759713',
|
|
36
|
+
'0x1df0d0ebcdc52069692452cb9a3e5cf6c017b237378141eaf08a05ce17205ed6',
|
|
20
37
|
'0x216bd19960f140177a4a3fb9cf258edcbadb1f5d54740fc944503bff4a00e65e',
|
|
21
38
|
'0x2acd218c67daa94dd2f92e81f477ffc9f8507319f0f2d698eae5ed631ae14039',
|
|
22
39
|
'0x2b62c4153d81d5b5a233d1d2b7ef899d3fca4076d458e215ff3a00176b415b0d',
|
|
@@ -26,8 +43,11 @@ export const MORPHO_MARKETS = {
|
|
|
26
43
|
'0x53bf81793c2cc384c19a3bc9b032467e179a390a9225cd9542742ac10f539cc2',
|
|
27
44
|
'0x5ecb7a25d51c870ec57f810c880e3e20743e56d0524575b7b8934a778aaec1af',
|
|
28
45
|
'0x5ef35fe4418a6bcfcc70fe32efce30074f22e9a782f81d432c1e537ddbda11e2',
|
|
46
|
+
'0x64e7db7f042812d4335947a7cdf6af1093d29478aff5f1ccd93cc67f8aadfddc',
|
|
29
47
|
'0x65f2a559764859a559d8c39604cf665942bab7d10dfaa1b82e914c9d351038d4',
|
|
48
|
+
'0x707dddc200e95dc984feb185abf1321cabec8486dca5a9a96fb5202184106e54',
|
|
30
49
|
'0x7268244d330f1462f77ded7a14e2f868893e86e76e8b8eaa869405d588aff6ce',
|
|
50
|
+
'0x78f6b57d825ef01a5dc496ad1f426a6375c685047d07a30cd07ac5107ffc7976',
|
|
31
51
|
'0x83bab0d612f592d0f145b2ec82fd730144dfb3d72c8fc838b27555558e49c496',
|
|
32
52
|
'0x8eb8cfe3b1ac8f653608ae09fb099263fa2fe25d4a59305c309937292c2aeee9',
|
|
33
53
|
'0x964e7d1db11bdf32262c71274c297dcdb4710d73acb814f04fdca8b0c7cdf028',
|
|
@@ -35,6 +55,7 @@ export const MORPHO_MARKETS = {
|
|
|
35
55
|
'0xa24d04c3aff60d49b3475f0084334546cbf66182e788b6bf173e6f9990b2c816',
|
|
36
56
|
'0xa62327642e110efd38ba2d153867a8625c8dc40832e1d211ba4f4151c3de9050',
|
|
37
57
|
'0xa7fe39c692f0192fb2f281a6cc16c8b2e1c8f9b9f2bc418e0c0c1e9374bf4b04',
|
|
58
|
+
'0xace279b5c6eff0a1ce7287249369fa6f4d3d32225e1629b04ef308e0eb568fb0',
|
|
38
59
|
'0xb142d65d7c624def0a9f4b49115b83f400a86bd2904d4f3339ec4441e28483ea',
|
|
39
60
|
'0xb5b575e402c7c19def8661069c39464c8bf3297b638e64d841b09a4eb2807de5',
|
|
40
61
|
'0xbc15a1782163f4be46c23ac61f5da50fed96ad40293f86a5ce0501ce4a246b32',
|
|
@@ -47,6 +68,7 @@ export const MORPHO_MARKETS = {
|
|
|
47
68
|
'0xebeabb17bd69d4b8ed6929a821d69478b564f4cc604d0995944c9da8b5cb3f04',
|
|
48
69
|
'0xed00791e29eb08c9bc0d8b389fe1f00084699baf2a785ba2a42e915706b17b82',
|
|
49
70
|
'0xf25db2433ae650155eae04ebd8b3795d19bfcb318d22926a8a5e746e8028e0a8',
|
|
71
|
+
'0xfbe436e9aa361487f0c3e4ff94c88aea72887a4482c6b8bcfec60a8584cdb05e',
|
|
50
72
|
],
|
|
51
73
|
[Chain.OP_MAINNET]: [
|
|
52
74
|
'0x173b66359f0741b1c7f1963075cd271c739b6dc73b658e108a54ce6febeb279b',
|
|
@@ -60,4 +82,12 @@ export const MORPHO_MARKETS = {
|
|
|
60
82
|
'0xebaf3dc6fa2fb3f78d18c87adcc37c06fe64874c5b2d69619ef7696088780df9',
|
|
61
83
|
'0x5869019d7ec9f92db2e90c0156b542cda7c0a679c626eac842aa5117a0483d4a',
|
|
62
84
|
],
|
|
85
|
+
[Chain.HEMI_NETWORK]: [
|
|
86
|
+
'0x36931ab4ffe6fed55ab0624afd2bf6eb1cebdbd6d5c98334e949841e402f86ff',
|
|
87
|
+
'0x08abb2b634eb6454a5819dbaa5c0229136989a9990ed757727c406dbcb4e606b',
|
|
88
|
+
'0xf1b97d86baa12ef4622eeca186a49fa7f7ea1ac2aa55ea4c20a26e815ddd6bc6',
|
|
89
|
+
'0xb7dd4c2e7c164de474b28c354cddb137deb0ce2583b925d20c33322074c22178',
|
|
90
|
+
'0x4b670128dfaa02a92f833bb9b99949262b685c2d3f55d4f7c97da1849d2b6355',
|
|
91
|
+
'0x7c985a3ba92fa76a362f661b37a68c9955490eb659b7905aab6019b91042b452',
|
|
92
|
+
],
|
|
63
93
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchPublic.d.ts","sourceRoot":"","sources":["../../../src/lending/morpho/fetchPublic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchPublic.d.ts","sourceRoot":"","sources":["../../../src/lending/morpho/fetchPublic.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,EAAE,SAAS,MAAM,WAoDjE,CAAA;AAID,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,gBAwDvD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Chain } from '@1delta/chain-registry';
|
|
1
2
|
export const query = (first, skip, chainId) => `
|
|
2
3
|
query GetMarkets {
|
|
3
4
|
markets(first: ${first}, skip: ${skip}, where: {
|
|
@@ -51,22 +52,53 @@ query GetMarkets {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
`;
|
|
54
|
-
const BASE_URL =
|
|
55
|
+
const BASE_URL = 'https://blue-api.morpho.org/graphql';
|
|
55
56
|
export async function fetchMorphoMarkets(chainId) {
|
|
56
|
-
|
|
57
|
+
if (chainId !== Chain.ETHEREUM_MAINNET) {
|
|
58
|
+
const requestBody = {
|
|
59
|
+
query: query(200, 0, chainId),
|
|
60
|
+
variables: {},
|
|
61
|
+
};
|
|
62
|
+
const response = await fetch(BASE_URL, {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers: {
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
},
|
|
67
|
+
body: JSON.stringify(requestBody),
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new Error(`Network error: ${response.status} - ${response.statusText}`);
|
|
71
|
+
}
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
return data.data;
|
|
74
|
+
}
|
|
75
|
+
const requestBody0 = {
|
|
57
76
|
query: query(200, 0, chainId),
|
|
58
77
|
variables: {},
|
|
59
78
|
};
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
const requestBody1 = {
|
|
80
|
+
query: query(200, 200, chainId),
|
|
81
|
+
variables: {},
|
|
82
|
+
};
|
|
83
|
+
const [data0, data1] = await Promise.all([
|
|
84
|
+
fetch(BASE_URL, {
|
|
85
|
+
method: 'POST',
|
|
86
|
+
headers: {
|
|
87
|
+
'Content-Type': 'application/json',
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify(requestBody0),
|
|
90
|
+
}).then((x) => x.json()),
|
|
91
|
+
fetch(BASE_URL, {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers: {
|
|
94
|
+
'Content-Type': 'application/json',
|
|
95
|
+
},
|
|
96
|
+
body: JSON.stringify(requestBody1),
|
|
97
|
+
}).then((x) => x.json()),
|
|
98
|
+
]);
|
|
99
|
+
return {
|
|
100
|
+
markets: {
|
|
101
|
+
items: [...data0.data.markets.items, ...data1.data.markets.items],
|
|
64
102
|
},
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
if (!response.ok) {
|
|
68
|
-
throw new Error(`Network error: ${response.status} - ${response.statusText}`);
|
|
69
|
-
}
|
|
70
|
-
const data = await response.json();
|
|
71
|
-
return data.data;
|
|
103
|
+
};
|
|
72
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMarketsFromChain.d.ts","sourceRoot":"","sources":["../../../src/lending/morpho/getMarketsFromChain.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAOrD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,EAAE,gBAAgB,YAIjC,EACD,MAAM,EAAE,gBAAgB,YAAK,EAC7B,MAAM,EAAE,GAAG;;
|
|
1
|
+
{"version":3,"file":"getMarketsFromChain.d.ts","sourceRoot":"","sources":["../../../src/lending/morpho/getMarketsFromChain.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAA;AAOrD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,gBAAgB,EAAE,gBAAgB,YAIjC,EACD,MAAM,EAAE,gBAAgB,YAAK,EAC7B,MAAM,EAAE,GAAG;;GAuLZ;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,GAAG,EACX,gBAAgB,GAAE,gBAIjB,EACD,MAAM,GAAE,gBAAqB,GAC5B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,SAAS,EAAE,MAAM,CAAC,CAqL5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/morpho/userCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAI/C,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/morpho/userCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAI/C,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAU9C,CAAA;AAyBD,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,gBAAgB,MAAM,EAAE,KACvB,IAAI,EAIN,CAAA;AAED,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,gBAAgB,MAAM,EAAE,KACvB,IAAI,EAaN,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { Chain } from '@1delta/chain-registry';
|
|
|
2
2
|
import { chunk } from 'lodash';
|
|
3
3
|
import { morphoPools } from '@1delta/data-sdk';
|
|
4
4
|
export const MORPHO_LENS = {
|
|
5
|
+
[Chain.HEMI_NETWORK]: '0x1170Ef5B1A7f9c4F0ce34Ddf66CC0e6090Fd107E',
|
|
5
6
|
[Chain.BASE]: '0x05f3f58716a88A52493Be45aA0871c55b3748f18',
|
|
6
7
|
[Chain.POLYGON_MAINNET]: '0x04102873b1A80647879Aa8B8a119F07aE08f457a',
|
|
7
8
|
[Chain.OP_MAINNET]: '0x61895aEB0a42679E2Df8EE64334C405a8d47D244',
|
|
@@ -73,7 +73,7 @@ export const fetchMainPrices = async (chainIds, rpcOverrides, lists = {}) => {
|
|
|
73
73
|
...RWADynamicOracleAbi,
|
|
74
74
|
...ProxyOracleAbi,
|
|
75
75
|
];
|
|
76
|
-
const result = await multicallRetry(chainId, allCalls, abis, undefined, 3, 0,
|
|
76
|
+
const result = await multicallRetry(chainId, allCalls, abis, undefined, 3, 0, false, rpcOverrides);
|
|
77
77
|
return {
|
|
78
78
|
chainId,
|
|
79
79
|
result,
|
|
@@ -317,17 +317,17 @@ const parseUniswapV2results = (data, chainId) => {
|
|
|
317
317
|
return {};
|
|
318
318
|
}
|
|
319
319
|
};
|
|
320
|
-
function
|
|
320
|
+
function getExponentForOracle(chainId, fork) {
|
|
321
321
|
// some chains only have high decimal oracles
|
|
322
322
|
if (chainId === Chain.AVALANCHE_C_CHAIN || chainId === Chain.MODE) {
|
|
323
|
-
return
|
|
323
|
+
return 10n;
|
|
324
324
|
}
|
|
325
325
|
if (chainId === Chain.XDC_NETWORK)
|
|
326
|
-
return
|
|
326
|
+
return 0n;
|
|
327
327
|
if (chainId === Chain.TELOS_EVM_MAINNET)
|
|
328
|
-
return
|
|
328
|
+
return 10n;
|
|
329
329
|
// otherwise, it depends on whether it is aave V3
|
|
330
|
-
return AAVE_V2_LENDERS.includes(fork);
|
|
330
|
+
return AAVE_V2_LENDERS.includes(fork) ? 0n : 10n;
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
333
333
|
* Parser for aave results in ulticall slice
|
|
@@ -343,7 +343,7 @@ const parseAaveResults = (chainId, data, queries, list = {}) => {
|
|
|
343
343
|
const details = queries[i];
|
|
344
344
|
details.assets.forEach((a, j) => {
|
|
345
345
|
const oracleId = list[a]?.assetGroup ?? chainId + '-' + a;
|
|
346
|
-
prices[oracleId] = formatAavePrice(d[j].toString(),
|
|
346
|
+
prices[oracleId] = formatAavePrice(d[j].toString(), getExponentForOracle(chainId, details.fork));
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
});
|
package/dist/utils/parsing.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export declare const formatAaveYieldToNumber: (n?: string | bigint) => number;
|
|
|
12
12
|
export declare const calculateRateForCompound: (n: string, chainId: string, lender?: Lender) => number;
|
|
13
13
|
export declare const formatAaveRawApyToApr: (raw: bigint | string | undefined) => number;
|
|
14
14
|
export declare const convertRateToApr: (ratePerSecond: number | string) => number;
|
|
15
|
-
export declare const formatAavePrice: (price: string,
|
|
15
|
+
export declare const formatAavePrice: (price: string, exponent?: bigint) => number;
|
|
16
16
|
export declare const formatMorphoPrice: (price: string, collateralDec: number, debtDec: number) => number;
|
|
17
17
|
//# sourceMappingURL=parsing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/utils/parsing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAIhD,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,iBAAa,KAAG,MAO/D,CAAA;AAED,oBAAY,SAAS;IACnB,KAAK,IAAA;IACL,EAAE,IAAA;CACH;AAYD,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,WAI1C,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,IAAI,MAAM,GAAG,MAAM,KAAG,MAG7D,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,GAAG,MAAM,EACT,SAAS,MAAM,EACf,eAAiC,KAChC,MAgBF,CAAA;AACD,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,WAGrE,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAI,eAAe,MAAM,GAAG,MAAM,WAI9D,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/utils/parsing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAIhD,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,iBAAa,KAAG,MAO/D,CAAA;AAED,oBAAY,SAAS;IACnB,KAAK,IAAA;IACL,EAAE,IAAA;CACH;AAYD,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,WAI1C,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,IAAI,MAAM,GAAG,MAAM,KAAG,MAG7D,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,GAAG,MAAM,EACT,SAAS,MAAM,EACf,eAAiC,KAChC,MAgBF,CAAA;AACD,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,WAGrE,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAI,eAAe,MAAM,GAAG,MAAM,WAI9D,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,iBAAc,KAAG,MAY/D,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,OAAO,MAAM,EACb,eAAe,MAAM,EACrB,SAAS,MAAM,KACd,MAYF,CAAA"}
|
package/dist/utils/parsing.js
CHANGED
|
@@ -65,11 +65,11 @@ export const convertRateToApr = (ratePerSecond) => {
|
|
|
65
65
|
return 0;
|
|
66
66
|
return rps * 3600 * 24 * 365 * 100;
|
|
67
67
|
};
|
|
68
|
-
export const formatAavePrice = (price,
|
|
68
|
+
export const formatAavePrice = (price, exponent = 10n) => {
|
|
69
69
|
try {
|
|
70
70
|
return Number(formatEther(BigInt(price ?? '0') *
|
|
71
71
|
// 10^(18 - decimals)
|
|
72
|
-
10n ** (
|
|
72
|
+
10n ** (exponent)));
|
|
73
73
|
}
|
|
74
74
|
catch {
|
|
75
75
|
return NaN;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/yields/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/yields/index.ts"],"names":[],"mappings":"AAwGA,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB,EAAE,GAAG,CAAA;IAC1B,oBAAoB,EAAE,GAAG,CAAA;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACxD,aAAa,EAAE;QACb,CAAC,OAAO,EAAE,MAAM,GAAG;YACjB,CAAC,MAAM,EAAE,MAAM,GAAG;gBAAE,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAA;aAAE,CAAA;SACzD,CAAA;KACF,CAAA;CACF;AAcD,eAAO,MAAM,kBAAkB,uCAmf9B,CAAA"}
|
package/dist/yields/index.js
CHANGED
|
@@ -31,6 +31,7 @@ const usdThree = 'Web 3 Dollar::USD3';
|
|
|
31
31
|
const jitoSol = 'Jito Staked SOL::JitoSOL';
|
|
32
32
|
const thBill = 'Theo Short Duration US Treasury Fund::THBILL';
|
|
33
33
|
const ssuperusd = 'SuperReturn sSuperUSD::SSUPERUSD';
|
|
34
|
+
const hbhype = 'hyperbeat x ether.fi HYPE::beHYPE';
|
|
34
35
|
const FeedData = {
|
|
35
36
|
WSTETH: 'https://eth-api.lido.fi/v1/protocol/steth/apr/sma',
|
|
36
37
|
STMATIC: 'https://polygon.lido.fi/api/stats',
|
|
@@ -65,6 +66,7 @@ const FeedData = {
|
|
|
65
66
|
THBILL: 'https://thbill-api.theo.xyz/snapshots',
|
|
66
67
|
YEARN_KATANA: 'https://katana-apr-service.vercel.app/api/vaults',
|
|
67
68
|
SSUPERUSD: 'https://www.superreturn.ai/api/trpc/cmc.getUSDCPrice,rewardBackend.getYield,rewardBackend.getTvlChange?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%221%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%222%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D',
|
|
69
|
+
HBHYPE: 'https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b',
|
|
68
70
|
};
|
|
69
71
|
const LenderAPIs = {
|
|
70
72
|
MERIDIAN: 'https://omnidex.bmaa3ajd1gjri.eu-west-2.cs.amazonlightsail.com/lending_yields',
|
|
@@ -147,6 +149,29 @@ export const fetchGeneralYields = async () => {
|
|
|
147
149
|
return 0;
|
|
148
150
|
}
|
|
149
151
|
});
|
|
152
|
+
const hbhypePromise = safeFetch('HBHYPE', async () => {
|
|
153
|
+
try {
|
|
154
|
+
const response = await fetch(FeedData.HBHYPE);
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
157
|
+
}
|
|
158
|
+
const result = await response.json();
|
|
159
|
+
// Ensure data exists and delegations is an array
|
|
160
|
+
if (!result.success ||
|
|
161
|
+
!result.data ||
|
|
162
|
+
!Array.isArray(result.data.delegations)) {
|
|
163
|
+
throw new Error('Invalid response structure');
|
|
164
|
+
}
|
|
165
|
+
const delegations = result.data.delegations;
|
|
166
|
+
// Compute average APR
|
|
167
|
+
const totalApr = delegations.reduce((sum, validator) => sum + Number(validator.apr ?? 0), 0);
|
|
168
|
+
const averageApr = totalApr / delegations.length;
|
|
169
|
+
return averageApr;
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
150
175
|
const ssuperusdPromise = safeFetch('SSUPERUSD', async () => {
|
|
151
176
|
try {
|
|
152
177
|
const res = await fetch(FeedData.SSUPERUSD, {
|
|
@@ -394,7 +419,7 @@ export const fetchGeneralYields = async () => {
|
|
|
394
419
|
},
|
|
395
420
|
})));
|
|
396
421
|
});
|
|
397
|
-
const [wstethData, ezethData, rethData, weethData, stmaticData, methData, maticXdata, susdeData, meridianData, savaxData, cbethData, rsethData, trumaticData, rtokensData, hypeData, osEthData, ethXData, pufEthData, angleData, susdsData, srUsdData, yusdData, rlpData, wstusrData, csusdlData, sdeusdData, rswethData, ynethxData, ethZeroData, usdZeroPlusData, jitoSolData, thBillData, yearnKatanaData, ssuperusdData,] = await Promise.all([
|
|
422
|
+
const [wstethData, ezethData, rethData, weethData, stmaticData, methData, maticXdata, susdeData, meridianData, savaxData, cbethData, rsethData, trumaticData, rtokensData, hypeData, osEthData, ethXData, pufEthData, angleData, susdsData, srUsdData, yusdData, rlpData, wstusrData, csusdlData, sdeusdData, rswethData, ynethxData, ethZeroData, usdZeroPlusData, jitoSolData, thBillData, yearnKatanaData, ssuperusdData, hbhypeData,] = await Promise.all([
|
|
398
423
|
wstethPromise,
|
|
399
424
|
ezethPromise,
|
|
400
425
|
rethPromise,
|
|
@@ -429,6 +454,7 @@ export const fetchGeneralYields = async () => {
|
|
|
429
454
|
thbillPromise,
|
|
430
455
|
yearnKatanaPromise,
|
|
431
456
|
ssuperusdPromise,
|
|
457
|
+
hbhypePromise,
|
|
432
458
|
]);
|
|
433
459
|
const data = {
|
|
434
460
|
intrinsicYields: {
|
|
@@ -464,6 +490,7 @@ export const fetchGeneralYields = async () => {
|
|
|
464
490
|
[jitoSol]: jitoSolData,
|
|
465
491
|
[thBill]: thBillData,
|
|
466
492
|
[ssuperusd]: ssuperusdData,
|
|
493
|
+
[hbhype]: hbhypeData,
|
|
467
494
|
...rtokensData,
|
|
468
495
|
...hypeData,
|
|
469
496
|
...angleData,
|
package/package.json
CHANGED
|
@@ -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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Chain } from '@1delta/chain-registry'
|
|
1
2
|
|
|
2
3
|
export const query = (first: number, skip: number, chainId: string) => `
|
|
3
4
|
query GetMarkets {
|
|
@@ -53,27 +54,62 @@ query GetMarkets {
|
|
|
53
54
|
}
|
|
54
55
|
`
|
|
55
56
|
|
|
56
|
-
const BASE_URL =
|
|
57
|
-
|
|
57
|
+
const BASE_URL = 'https://blue-api.morpho.org/graphql'
|
|
58
58
|
|
|
59
59
|
export async function fetchMorphoMarkets(chainId: string) {
|
|
60
|
+
if (chainId !== Chain.ETHEREUM_MAINNET) {
|
|
60
61
|
const requestBody = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
62
|
+
query: query(200, 0, chainId),
|
|
63
|
+
variables: {},
|
|
64
|
+
}
|
|
64
65
|
const response = await fetch(BASE_URL, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/json',
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(requestBody),
|
|
71
|
+
})
|
|
71
72
|
|
|
72
73
|
if (!response.ok) {
|
|
73
|
-
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Network error: ${response.status} - ${response.statusText}`,
|
|
76
|
+
)
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
const data: any = await response.json()
|
|
79
|
+
const data: any = await response.json()
|
|
77
80
|
|
|
78
81
|
return data.data
|
|
79
|
-
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const requestBody0 = {
|
|
85
|
+
query: query(200, 0, chainId),
|
|
86
|
+
variables: {},
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const requestBody1 = {
|
|
90
|
+
query: query(200, 200, chainId),
|
|
91
|
+
variables: {},
|
|
92
|
+
}
|
|
93
|
+
const [data0, data1] = await Promise.all([
|
|
94
|
+
fetch(BASE_URL, {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
headers: {
|
|
97
|
+
'Content-Type': 'application/json',
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify(requestBody0),
|
|
100
|
+
}).then((x) => x.json()),
|
|
101
|
+
fetch(BASE_URL, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: {
|
|
104
|
+
'Content-Type': 'application/json',
|
|
105
|
+
},
|
|
106
|
+
body: JSON.stringify(requestBody1),
|
|
107
|
+
}).then((x) => x.json()),
|
|
108
|
+
])
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
markets: {
|
|
112
|
+
items: [...data0.data.markets.items, ...data1.data.markets.items],
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -63,7 +63,6 @@ export async function getMarkets(
|
|
|
63
63
|
// get assets from list
|
|
64
64
|
const loanAsset = tokens[loanToken.toLowerCase()]
|
|
65
65
|
const collateralAsset = tokens[collateralToken.toLowerCase()]
|
|
66
|
-
|
|
67
66
|
const loanKey =
|
|
68
67
|
toOracleKey(loanAsset?.assetGroup!) ??
|
|
69
68
|
toGenericPriceKey(loanAsset.address, chainId)
|
|
@@ -5,6 +5,7 @@ import { chunk } from 'lodash'
|
|
|
5
5
|
import { morphoPools } from '@1delta/data-sdk'
|
|
6
6
|
|
|
7
7
|
export const MORPHO_LENS: { [c: string]: string } = {
|
|
8
|
+
[Chain.HEMI_NETWORK]: '0x1170Ef5B1A7f9c4F0ce34Ddf66CC0e6090Fd107E',
|
|
8
9
|
[Chain.BASE]: '0x05f3f58716a88A52493Be45aA0871c55b3748f18',
|
|
9
10
|
[Chain.POLYGON_MAINNET]: '0x04102873b1A80647879Aa8B8a119F07aE08f457a',
|
|
10
11
|
[Chain.OP_MAINNET]: '0x61895aEB0a42679E2Df8EE64334C405a8d47D244',
|
|
@@ -112,7 +112,7 @@ export const fetchMainPrices = async (
|
|
|
112
112
|
undefined,
|
|
113
113
|
3,
|
|
114
114
|
0,
|
|
115
|
-
|
|
115
|
+
false,
|
|
116
116
|
rpcOverrides,
|
|
117
117
|
)
|
|
118
118
|
|
|
@@ -451,15 +451,15 @@ const parseUniswapV2results = (data: any[], chainId: string) => {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
|
|
454
|
-
function
|
|
454
|
+
function getExponentForOracle(chainId: string, fork: string) {
|
|
455
455
|
// some chains only have high decimal oracles
|
|
456
456
|
if (chainId === Chain.AVALANCHE_C_CHAIN || chainId === Chain.MODE) {
|
|
457
|
-
return
|
|
457
|
+
return 10n
|
|
458
458
|
}
|
|
459
|
-
if (chainId === Chain.XDC_NETWORK) return
|
|
460
|
-
if (chainId === Chain.TELOS_EVM_MAINNET) return
|
|
459
|
+
if (chainId === Chain.XDC_NETWORK) return 0n
|
|
460
|
+
if (chainId === Chain.TELOS_EVM_MAINNET) return 10n
|
|
461
461
|
// otherwise, it depends on whether it is aave V3
|
|
462
|
-
return AAVE_V2_LENDERS.includes(fork as any)
|
|
462
|
+
return AAVE_V2_LENDERS.includes(fork as any) ? 0n : 10n
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
/**
|
|
@@ -484,7 +484,7 @@ const parseAaveResults = (
|
|
|
484
484
|
const oracleId = list[a]?.assetGroup ?? chainId + '-' + a
|
|
485
485
|
prices[oracleId] = formatAavePrice(
|
|
486
486
|
d[j].toString(),
|
|
487
|
-
|
|
487
|
+
getExponentForOracle(chainId, details.fork as any),
|
|
488
488
|
)
|
|
489
489
|
})
|
|
490
490
|
}
|
package/src/utils/parsing.ts
CHANGED
|
@@ -81,13 +81,13 @@ export const convertRateToApr = (ratePerSecond: number | string) => {
|
|
|
81
81
|
return rps * 3600 * 24 * 365 * 100
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export const formatAavePrice = (price: string,
|
|
84
|
+
export const formatAavePrice = (price: string, exponent = 10n): number => {
|
|
85
85
|
try {
|
|
86
86
|
return Number(
|
|
87
87
|
formatEther(
|
|
88
88
|
BigInt(price ?? '0') *
|
|
89
89
|
// 10^(18 - decimals)
|
|
90
|
-
10n ** (
|
|
90
|
+
10n ** (exponent),
|
|
91
91
|
),
|
|
92
92
|
)
|
|
93
93
|
} catch {
|
package/src/yields/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ const usdThree = 'Web 3 Dollar::USD3'
|
|
|
33
33
|
const jitoSol = 'Jito Staked SOL::JitoSOL'
|
|
34
34
|
const thBill = 'Theo Short Duration US Treasury Fund::THBILL'
|
|
35
35
|
const ssuperusd = 'SuperReturn sSuperUSD::SSUPERUSD'
|
|
36
|
+
const hbhype = 'hyperbeat x ether.fi HYPE::beHYPE'
|
|
36
37
|
const FeedData = {
|
|
37
38
|
WSTETH: 'https://eth-api.lido.fi/v1/protocol/steth/apr/sma',
|
|
38
39
|
STMATIC: 'https://polygon.lido.fi/api/stats',
|
|
@@ -70,6 +71,8 @@ const FeedData = {
|
|
|
70
71
|
YEARN_KATANA: 'https://katana-apr-service.vercel.app/api/vaults',
|
|
71
72
|
SSUPERUSD:
|
|
72
73
|
'https://www.superreturn.ai/api/trpc/cmc.getUSDCPrice,rewardBackend.getYield,rewardBackend.getTvlChange?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%221%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%2C%222%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D',
|
|
74
|
+
HBHYPE:
|
|
75
|
+
'https://api.hyperbeat.org/api/v1/staking?address=0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b',
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
const LenderAPIs = {
|
|
@@ -185,6 +188,39 @@ export const fetchGeneralYields = async () => {
|
|
|
185
188
|
}
|
|
186
189
|
})
|
|
187
190
|
|
|
191
|
+
const hbhypePromise = safeFetch('HBHYPE', async () => {
|
|
192
|
+
try {
|
|
193
|
+
const response = await fetch(FeedData.HBHYPE)
|
|
194
|
+
if (!response.ok) {
|
|
195
|
+
throw new Error(`HTTP error! Status: ${response.status}`)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const result = await response.json()
|
|
199
|
+
|
|
200
|
+
// Ensure data exists and delegations is an array
|
|
201
|
+
if (
|
|
202
|
+
!result.success ||
|
|
203
|
+
!result.data ||
|
|
204
|
+
!Array.isArray(result.data.delegations)
|
|
205
|
+
) {
|
|
206
|
+
throw new Error('Invalid response structure')
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const delegations = result.data.delegations
|
|
210
|
+
|
|
211
|
+
// Compute average APR
|
|
212
|
+
const totalApr = delegations.reduce(
|
|
213
|
+
(sum: any, validator: any) => sum + Number(validator.apr ?? 0),
|
|
214
|
+
0,
|
|
215
|
+
)
|
|
216
|
+
const averageApr = totalApr / delegations.length
|
|
217
|
+
|
|
218
|
+
return averageApr
|
|
219
|
+
} catch (e) {
|
|
220
|
+
return 0
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
188
224
|
const ssuperusdPromise = safeFetch('SSUPERUSD', async () => {
|
|
189
225
|
try {
|
|
190
226
|
const res = await fetch(FeedData.SSUPERUSD, {
|
|
@@ -507,6 +543,7 @@ export const fetchGeneralYields = async () => {
|
|
|
507
543
|
thBillData,
|
|
508
544
|
yearnKatanaData,
|
|
509
545
|
ssuperusdData,
|
|
546
|
+
hbhypeData,
|
|
510
547
|
] = await Promise.all([
|
|
511
548
|
wstethPromise,
|
|
512
549
|
ezethPromise,
|
|
@@ -542,6 +579,7 @@ export const fetchGeneralYields = async () => {
|
|
|
542
579
|
thbillPromise,
|
|
543
580
|
yearnKatanaPromise,
|
|
544
581
|
ssuperusdPromise,
|
|
582
|
+
hbhypePromise,
|
|
545
583
|
])
|
|
546
584
|
|
|
547
585
|
const data: YieldDataWithTimestamp = {
|
|
@@ -578,6 +616,7 @@ export const fetchGeneralYields = async () => {
|
|
|
578
616
|
[jitoSol]: jitoSolData,
|
|
579
617
|
[thBill]: thBillData,
|
|
580
618
|
[ssuperusd]: ssuperusdData,
|
|
619
|
+
[hbhype]: hbhypeData,
|
|
581
620
|
...rtokensData,
|
|
582
621
|
...hypeData,
|
|
583
622
|
...angleData,
|
package/test/lenderData.test.ts
CHANGED
|
@@ -20,7 +20,7 @@ describe(
|
|
|
20
20
|
it.only('should return lender data', async () => {
|
|
21
21
|
await fetchLenderMetaFromDirAndInitialize()
|
|
22
22
|
|
|
23
|
-
const chainId = Chain.
|
|
23
|
+
const chainId = Chain.OP_MAINNET
|
|
24
24
|
const list = await getDeltaTokenList(chainId)
|
|
25
25
|
const ps = [
|
|
26
26
|
fetchMainPrices([chainId], undefined, { [chainId]: { list } }),
|
|
@@ -32,7 +32,7 @@ describe(
|
|
|
32
32
|
// console.log("yields", yields)
|
|
33
33
|
// console.log("prices", prices)
|
|
34
34
|
|
|
35
|
-
const lenders = getLendersForChain(chainId) as any
|
|
35
|
+
const lenders =[Lender.AAVE_V3]// getLendersForChain(chainId) as any
|
|
36
36
|
console.log('lenders', lenders)
|
|
37
37
|
const lendingData = await getLenderPublicData(
|
|
38
38
|
chainId,
|
|
@@ -44,7 +44,7 @@ describe(
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
prettyPrint(lendingData)
|
|
47
|
-
})
|
|
47
|
+
},{timeout:50000})
|
|
48
48
|
|
|
49
49
|
it('should return pairs', async () => {
|
|
50
50
|
const chainId = Chain.POLYGON_MAINNET
|
package/test/mainPrices.test.ts
CHANGED
|
@@ -9,7 +9,7 @@ describe(
|
|
|
9
9
|
it('should return prices for valid tokens', async () => {
|
|
10
10
|
|
|
11
11
|
await fetchLenderMetaFromDirAndInitialize()
|
|
12
|
-
const chainId = Chain.
|
|
12
|
+
const chainId = Chain.HEMI_NETWORK
|
|
13
13
|
const list = await getDeltaTokenList(chainId)
|
|
14
14
|
const mainPrices = await fetchMainPrices([
|
|
15
15
|
chainId,
|
package/test/mbChain.test.ts
CHANGED
|
@@ -10,8 +10,7 @@ const fetchFromApi = async () =>
|
|
|
10
10
|
(a) => a.json(),
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const chainId = Chain.SONEIUM
|
|
13
|
+
const chainId = Chain.HEMI_NETWORK
|
|
15
14
|
|
|
16
15
|
describe(
|
|
17
16
|
'find prices',
|
|
@@ -27,8 +26,8 @@ describe(
|
|
|
27
26
|
|
|
28
27
|
const tokens = await getDeltaTokenList(chainId)
|
|
29
28
|
|
|
30
|
-
//
|
|
31
|
-
//
|
|
29
|
+
// const ms = ((await fetchFromApi()) as any).map((a:any) => a.marketId)
|
|
30
|
+
// console.log('ms', ms)
|
|
32
31
|
const marketDatas = await getMarkets(
|
|
33
32
|
chainId,
|
|
34
33
|
MORPHO_MARKETS[chainId],
|
package/test/morpho.test.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { convertMarketsToMorphoResponse } from "../src/lending/morpho/convertPub
|
|
|
8
8
|
describe('find MB lending data', () => {
|
|
9
9
|
|
|
10
10
|
it('should return and convert MB public data', async () => {
|
|
11
|
-
const chainId = Chain.
|
|
11
|
+
const chainId = Chain.ETHEREUM_MAINNET
|
|
12
12
|
|
|
13
13
|
const mbData = await fetchMorphoMarkets(chainId)
|
|
14
14
|
|