@1delta/margin-fetcher 0.0.15 → 0.0.17
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/abis/oracle/ProxyOracle.d.ts +12 -0
- package/dist/abis/oracle/ProxyOracle.d.ts.map +1 -0
- package/dist/abis/oracle/ProxyOracle.js +15 -0
- package/dist/lending/aave-v3-type/publicCallParse.d.ts +4 -4
- package/dist/lending/aave-v3-type/publicCallParse.d.ts.map +1 -1
- package/dist/lending/aave-v3-type/publicCallParse.js +68 -44
- package/dist/lending/fetchLender.d.ts.map +1 -1
- package/dist/lending/morpho/convertPublic.d.ts.map +1 -1
- package/dist/lending/morpho/convertPublic.js +8 -2
- package/dist/lending/morpho/fetchPublic.d.ts.map +1 -1
- package/dist/lending/morpho/types.d.ts +2 -0
- package/dist/lending/morpho/types.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallParse.js +60 -0
- package/dist/prices/main-prices/addresses/morpho.d.ts +11 -0
- package/dist/prices/main-prices/addresses/morpho.d.ts.map +1 -0
- package/dist/prices/main-prices/addresses/morpho.js +903 -0
- package/dist/prices/main-prices/fetchOracleData.d.ts +1 -0
- package/dist/prices/main-prices/fetchOracleData.d.ts.map +1 -1
- package/dist/prices/main-prices/fetchOracleData.js +70 -4
- package/dist/types/providers.d.ts +1 -1
- package/dist/types/providers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/abis/oracle/ProxyOracle.ts +15 -0
- package/src/lending/aave-v3-type/publicCallParse.ts +312 -110
- package/src/lending/fetchLender.ts +1 -0
- package/src/lending/morpho/convertPublic.ts +10 -3
- package/src/lending/morpho/fetchPublic.ts +0 -1
- package/src/lending/morpho/types.ts +5 -0
- package/src/lending/user-data/morpho/userCallParse.ts +63 -0
- package/src/prices/main-prices/addresses/morpho.ts +912 -0
- package/src/prices/main-prices/fetchOracleData.ts +120 -8
- package/src/types/providers.ts +4 -3
- package/test/mainPriceMB.test.ts +32 -0
- package/test/morpho.ts +66 -0
- package/test/morphoPrice.test.ts +31 -0
- package/test/userDataAll.test.ts +82 -0
|
@@ -87,6 +87,11 @@ export interface MorphoGeneralPublicResponse {
|
|
|
87
87
|
totalDeposits: number;
|
|
88
88
|
totalDebtStable: 0;
|
|
89
89
|
totalDebt: number;
|
|
90
|
+
|
|
91
|
+
// liqs
|
|
92
|
+
totalLiquidity: number
|
|
93
|
+
totalLiquidityUSD: number
|
|
94
|
+
|
|
90
95
|
// USD amounts
|
|
91
96
|
totalDepositsUSD: number;
|
|
92
97
|
totalDebtStableUSD: 0;
|
|
@@ -6,6 +6,47 @@ import { parseRawAmount } from '../../../utils/parsing'
|
|
|
6
6
|
import { MorphoMarket } from '../../morpho/types'
|
|
7
7
|
import { BalanceInfo, decodePackedDataset } from './decoder'
|
|
8
8
|
|
|
9
|
+
const balanceData = {
|
|
10
|
+
'0': {
|
|
11
|
+
borrowDiscountedCollateral: 0,
|
|
12
|
+
collateral: 0,
|
|
13
|
+
deposits: 0,
|
|
14
|
+
debt: 0,
|
|
15
|
+
adjustedDebt: 0,
|
|
16
|
+
nav: 0,
|
|
17
|
+
deposits24h: 0,
|
|
18
|
+
debt24h: 0,
|
|
19
|
+
nav24h: 0,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// aggregated apr data
|
|
24
|
+
const aprData = {
|
|
25
|
+
'0': {
|
|
26
|
+
apr: 0,
|
|
27
|
+
borrowApr: 0,
|
|
28
|
+
depositApr: 0,
|
|
29
|
+
rewards: 0,
|
|
30
|
+
rewardApr: 0,
|
|
31
|
+
rewardDepositApr: 0,
|
|
32
|
+
rewardBorrowApr: 0,
|
|
33
|
+
stakingApr: 0,
|
|
34
|
+
stakingDepositApr: 0,
|
|
35
|
+
stakingBorrowApr: 0,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
const userDataEmpty = (account: string, chainId: string) => {
|
|
39
|
+
return {
|
|
40
|
+
account,
|
|
41
|
+
chainId,
|
|
42
|
+
balanceData,
|
|
43
|
+
aprData,
|
|
44
|
+
userConfigs: {
|
|
45
|
+
'0': { selectedMode: 0, id: account },
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
9
50
|
export const getMorphoUserDataConverterWithlens = (
|
|
10
51
|
lender: Lender,
|
|
11
52
|
chainId: string,
|
|
@@ -25,6 +66,7 @@ export const getMorphoUserDataConverterWithlens = (
|
|
|
25
66
|
if (data.length !== expectedNumberOfCalls) {
|
|
26
67
|
return undefined
|
|
27
68
|
}
|
|
69
|
+
let marketsHandled: string[] = []
|
|
28
70
|
// de-chunk the calldata
|
|
29
71
|
const returnDatas = data.flatMap((d) => decodePackedDataset(d))
|
|
30
72
|
|
|
@@ -34,6 +76,7 @@ export const getMorphoUserDataConverterWithlens = (
|
|
|
34
76
|
let totalDeposits24h = 0
|
|
35
77
|
const balanceData = returnDatas[i]
|
|
36
78
|
const markeId = markets[balanceData.index]
|
|
79
|
+
marketsHandled.push(markeId)
|
|
37
80
|
const market = lenderData[markeId]?.params?.market
|
|
38
81
|
const { dataForMarket, addedDebt, addedDeposits } =
|
|
39
82
|
createMorphoEntryFromMarketWithLens(
|
|
@@ -68,6 +111,26 @@ export const getMorphoUserDataConverterWithlens = (
|
|
|
68
111
|
id: market.id,
|
|
69
112
|
}
|
|
70
113
|
}
|
|
114
|
+
|
|
115
|
+
for (const [marketId, pubData] of Object.entries(lenderData ?? {})) {
|
|
116
|
+
if (marketsHandled.includes(marketId)) continue;
|
|
117
|
+
const payload = {
|
|
118
|
+
chainId,
|
|
119
|
+
account,
|
|
120
|
+
lendingPositions: { '0': {} },
|
|
121
|
+
rewards: {},
|
|
122
|
+
userEMode: 0,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const userData = userDataEmpty(account, chainId)
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
datas[marketId] = {
|
|
128
|
+
...payload,
|
|
129
|
+
...userData,
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
id: pubData?.params?.market.id,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
71
134
|
return datas
|
|
72
135
|
},
|
|
73
136
|
expectedNumberOfCalls,
|