@defisaver/positions-sdk 2.1.78 → 2.1.79-aave-v4-1-dev
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/cjs/aaveV4/index.d.ts +7 -0
- package/cjs/aaveV4/index.js +298 -0
- package/cjs/aaveV4/lend.d.ts +45 -0
- package/cjs/aaveV4/lend.js +141 -0
- package/cjs/claiming/spark.js +1 -1
- package/cjs/config/contracts.d.ts +1551 -0
- package/cjs/config/contracts.js +9 -0
- package/cjs/contracts.d.ts +32741 -0
- package/cjs/contracts.js +2 -1
- package/cjs/helpers/aaveV4Helpers/index.d.ts +12 -0
- package/cjs/helpers/aaveV4Helpers/index.js +117 -0
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +2 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/markets/aaveV4/index.d.ts +34 -0
- package/cjs/markets/aaveV4/index.js +182 -0
- package/cjs/markets/index.d.ts +1 -0
- package/cjs/markets/index.js +3 -1
- package/cjs/portfolio/index.js +20 -0
- package/cjs/types/aaveV4.d.ts +156 -0
- package/cjs/types/aaveV4.js +22 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/portfolio.d.ts +4 -0
- package/esm/aaveV4/index.d.ts +7 -0
- package/esm/aaveV4/index.js +255 -0
- package/esm/aaveV4/lend.d.ts +45 -0
- package/esm/aaveV4/lend.js +134 -0
- package/esm/claiming/spark.js +1 -1
- package/esm/config/contracts.d.ts +1551 -0
- package/esm/config/contracts.js +8 -0
- package/esm/contracts.d.ts +32741 -0
- package/esm/contracts.js +1 -0
- package/esm/helpers/aaveV4Helpers/index.d.ts +12 -0
- package/esm/helpers/aaveV4Helpers/index.js +108 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/markets/aaveV4/index.d.ts +34 -0
- package/esm/markets/aaveV4/index.js +161 -0
- package/esm/markets/index.d.ts +1 -0
- package/esm/markets/index.js +1 -0
- package/esm/portfolio/index.js +21 -1
- package/esm/types/aaveV4.d.ts +156 -0
- package/esm/types/aaveV4.js +19 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/portfolio.d.ts +4 -0
- package/package.json +2 -2
- package/src/aaveV4/index.ts +291 -0
- package/src/aaveV4/lend.ts +180 -0
- package/src/claiming/spark.ts +1 -1
- package/src/config/contracts.ts +8 -0
- package/src/contracts.ts +2 -0
- package/src/helpers/aaveV4Helpers/index.ts +133 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/markets/aaveV4/index.ts +191 -0
- package/src/markets/index.ts +6 -1
- package/src/portfolio/index.ts +20 -0
- package/src/types/aaveV4.ts +172 -0
- package/src/types/index.ts +2 -1
- package/src/types/portfolio.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.79-aave-v4-1-dev",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@defisaver/tokens": "
|
|
24
|
+
"@defisaver/tokens": "1.7.26-aave-v4-dev",
|
|
25
25
|
"@types/lodash": "^4.17.15",
|
|
26
26
|
"@types/memoizee": "^0.4.12",
|
|
27
27
|
"decimal.js": "^10.6.0",
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import Dec from 'decimal.js';
|
|
3
|
+
import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
4
|
+
import { getViemProvider } from '../services/viem';
|
|
5
|
+
import {
|
|
6
|
+
AaveV4AccountData,
|
|
7
|
+
AaveV4HubAssetOnChainData,
|
|
8
|
+
AaveV4HubOnChainData,
|
|
9
|
+
AaveV4ReserveAssetData,
|
|
10
|
+
AaveV4ReserveAssetOnChain,
|
|
11
|
+
AaveV4SpokeData,
|
|
12
|
+
AaveV4SpokeInfo,
|
|
13
|
+
AaveV4UsedReserveAssets,
|
|
14
|
+
AaveV4AssetsData,
|
|
15
|
+
EthAddress,
|
|
16
|
+
EthereumProvider,
|
|
17
|
+
IncentiveData,
|
|
18
|
+
IncentiveKind,
|
|
19
|
+
NetworkNumber,
|
|
20
|
+
} from '../types';
|
|
21
|
+
import { AaveV4ViewContractViem } from '../contracts';
|
|
22
|
+
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
23
|
+
import { wethToEth } from '../services/utils';
|
|
24
|
+
import { aaveV4GetAggregatedPositionData } from '../helpers/aaveV4Helpers';
|
|
25
|
+
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
26
|
+
import { aprToApy } from '../moneymarket';
|
|
27
|
+
|
|
28
|
+
export * as lend from './lend';
|
|
29
|
+
|
|
30
|
+
const fetchHubData = async (viewContract: ReturnType<typeof AaveV4ViewContractViem>, hubAddress: EthAddress): Promise<AaveV4HubOnChainData> => {
|
|
31
|
+
const hubData = await viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
32
|
+
return {
|
|
33
|
+
assets: hubData.reduce((acc: Record<number, AaveV4HubAssetOnChainData>, assetOnChainData) => {
|
|
34
|
+
acc[assetOnChainData.assetId] = {
|
|
35
|
+
assetId: assetOnChainData.assetId,
|
|
36
|
+
drawnRate: assetOnChainData.drawnRate,
|
|
37
|
+
liquidity: assetOnChainData.liquidity,
|
|
38
|
+
liquidityFee: assetOnChainData.liquidityFee,
|
|
39
|
+
swept: assetOnChainData.swept,
|
|
40
|
+
totalDrawn: assetOnChainData.totalDrawn,
|
|
41
|
+
totalDrawnShares: assetOnChainData.totalDrawnShares,
|
|
42
|
+
totalPremiumShares: assetOnChainData.totalPremiumShares,
|
|
43
|
+
};
|
|
44
|
+
return acc;
|
|
45
|
+
}, {}),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// TODO AaveV4: Will be used for after values, onchain data is available when fetching position data
|
|
50
|
+
const calcUserRiskPremiumBps = (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData): number => {
|
|
51
|
+
type CollateralInfo = { riskBps: number; valueUsd: Dec };
|
|
52
|
+
type DebtInfo = { valueUsd: Dec };
|
|
53
|
+
|
|
54
|
+
const collaterals: CollateralInfo[] = [];
|
|
55
|
+
const debts: DebtInfo[] = [];
|
|
56
|
+
|
|
57
|
+
Object.entries(usedAssets).forEach(([identifier, asset]) => {
|
|
58
|
+
const reserveData = assetsData[identifier];
|
|
59
|
+
if (!reserveData) return;
|
|
60
|
+
|
|
61
|
+
const borrowedUsdDec = new Dec(asset.borrowedUsd || '0');
|
|
62
|
+
if (asset.isBorrowed && borrowedUsdDec.gt(0)) {
|
|
63
|
+
debts.push({ valueUsd: borrowedUsdDec });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const suppliedUsdDec = new Dec(asset.suppliedUsd || '0');
|
|
67
|
+
const isActiveCollateral = asset.collateral
|
|
68
|
+
&& asset.isSupplied
|
|
69
|
+
&& asset.collateralFactor > 0
|
|
70
|
+
&& suppliedUsdDec.gt(0);
|
|
71
|
+
|
|
72
|
+
if (isActiveCollateral) {
|
|
73
|
+
// collateralRisk is stored as a fraction (e.g. 0.25), convert back to bps
|
|
74
|
+
const riskBps = new Dec(reserveData.collateralRisk).mul(10000).toNumber();
|
|
75
|
+
collaterals.push({
|
|
76
|
+
riskBps,
|
|
77
|
+
valueUsd: suppliedUsdDec,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const totalDebtUsd = debts.reduce((sum, d) => sum.add(d.valueUsd), new Dec(0));
|
|
83
|
+
|
|
84
|
+
if (totalDebtUsd.lte(0)) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// sort by risk ASC, value DESC
|
|
89
|
+
collaterals.sort((a, b) => {
|
|
90
|
+
if (a.riskBps !== b.riskBps) return a.riskBps - b.riskBps;
|
|
91
|
+
return b.valueUsd.comparedTo(a.valueUsd);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
let debtLeftToCover = totalDebtUsd;
|
|
95
|
+
let numerator = new Dec(0); // sum(coveredUsd * riskBps)
|
|
96
|
+
let coveredDebt = new Dec(0); // sum(coveredUsd)
|
|
97
|
+
|
|
98
|
+
collaterals.forEach(({ riskBps, valueUsd }) => {
|
|
99
|
+
if (debtLeftToCover.lte(0)) return;
|
|
100
|
+
|
|
101
|
+
const coveredUsd = Dec.min(valueUsd, debtLeftToCover);
|
|
102
|
+
|
|
103
|
+
numerator = numerator.add(coveredUsd.mul(riskBps));
|
|
104
|
+
coveredDebt = coveredDebt.add(coveredUsd);
|
|
105
|
+
|
|
106
|
+
debtLeftToCover = debtLeftToCover.sub(coveredUsd);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (coveredDebt.lte(0)) {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const riskPremiumBps = numerator.div(coveredDebt);
|
|
114
|
+
return riskPremiumBps.toNumber();
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAsset: AaveV4HubAssetOnChainData, reserveId: number, oracleDecimals: number, network: NetworkNumber): Promise<AaveV4ReserveAssetData> => {
|
|
118
|
+
const assetInfo = getAssetInfoByAddress(reserveAsset.underlying, network);
|
|
119
|
+
const symbol = wethToEth(assetInfo.symbol);
|
|
120
|
+
const hubInfo = getAaveV4HubByAddress(network, reserveAsset.hub);
|
|
121
|
+
if (!hubInfo) {
|
|
122
|
+
throw new Error(`Hub not found with address: ${reserveAsset.hub}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const isStakingAsset = STAKING_ASSETS.includes(symbol);
|
|
126
|
+
const supplyIncentives: IncentiveData[] = [];
|
|
127
|
+
const borrowIncentives: IncentiveData[] = [];
|
|
128
|
+
|
|
129
|
+
if (isStakingAsset) {
|
|
130
|
+
const yieldApy = await getStakingApy(symbol, network as NetworkNumber);
|
|
131
|
+
supplyIncentives.push({
|
|
132
|
+
apy: yieldApy,
|
|
133
|
+
token: symbol,
|
|
134
|
+
incentiveKind: IncentiveKind.Staking,
|
|
135
|
+
description: `Native ${symbol} yield.`,
|
|
136
|
+
});
|
|
137
|
+
if (reserveAsset.borrowable) {
|
|
138
|
+
// When borrowing assets whose value increases over time
|
|
139
|
+
borrowIncentives.push({
|
|
140
|
+
apy: new Dec(yieldApy).mul(-1).toString(),
|
|
141
|
+
token: symbol,
|
|
142
|
+
incentiveKind: IncentiveKind.Reward,
|
|
143
|
+
description: `Due to the native yield of ${symbol}, the value of the debt would increase over time.`,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const totalSuppliedRaw = reserveAsset.totalSupplied ?? 0;
|
|
149
|
+
const totalDrawnRaw = reserveAsset.totalDrawn ?? 0;
|
|
150
|
+
const totalPremiumRaw = reserveAsset.totalPremium ?? 0;
|
|
151
|
+
const totalDebtRaw = reserveAsset.totalDebt ?? 0;
|
|
152
|
+
const supplyCapRaw = reserveAsset.supplyCap ?? 0;
|
|
153
|
+
const borrowCapRaw = reserveAsset.borrowCap ?? 0;
|
|
154
|
+
const totalSuppliedDec = new Dec(totalSuppliedRaw.toString());
|
|
155
|
+
const totalDrawnDec = new Dec(totalDrawnRaw.toString());
|
|
156
|
+
const utilization = totalSuppliedDec.isZero() ? '0' : totalDrawnDec.times(100).div(totalSuppliedDec).toString();
|
|
157
|
+
|
|
158
|
+
/** @DEV Hub related calculations */
|
|
159
|
+
const drawnRate = new Dec(hubAsset.drawnRate.toString()).div(new Dec(10).pow(27));
|
|
160
|
+
const borrowApr = drawnRate.mul(100);
|
|
161
|
+
const totalDrawn = new Dec(hubAsset.totalDrawn.toString());
|
|
162
|
+
const liquidity = new Dec(hubAsset.liquidity.toString());
|
|
163
|
+
const swept = new Dec(hubAsset.swept.toString());
|
|
164
|
+
const hubUtilizationDenominator = totalDrawn.add(swept).add(liquidity);
|
|
165
|
+
const hubUtilization = hubUtilizationDenominator.isZero() ? new Dec(0) : totalDrawn.div(hubUtilizationDenominator);
|
|
166
|
+
const liquidityFee = new Dec(hubAsset.liquidityFee.toString()).div(new Dec(10).pow(4));
|
|
167
|
+
const totalDrawnShares = new Dec(hubAsset.totalDrawnShares.toString());
|
|
168
|
+
const totalPremiumShares = new Dec(hubAsset.totalPremiumShares.toString());
|
|
169
|
+
// TODO JK@JK premiumMultiplier should be added to supplyApr calculation (.mul(premiumMultiplier)
|
|
170
|
+
// TODO JKJ@JK when we confirm that this is the right way to calculate it
|
|
171
|
+
const premiumMultiplier = totalDrawnShares.isZero() ? new Dec(1) : totalDrawnShares.add(totalPremiumShares).div(totalDrawnShares);
|
|
172
|
+
const supplyApr = borrowApr.mul(hubUtilization).mul(new Dec(1).minus(liquidityFee));
|
|
173
|
+
|
|
174
|
+
return ({
|
|
175
|
+
symbol,
|
|
176
|
+
underlying: reserveAsset.underlying,
|
|
177
|
+
hub: hubInfo.address,
|
|
178
|
+
hubName: hubInfo?.label,
|
|
179
|
+
assetId: reserveAsset.assetId,
|
|
180
|
+
reserveId,
|
|
181
|
+
paused: reserveAsset.paused,
|
|
182
|
+
frozen: reserveAsset.frozen,
|
|
183
|
+
borrowable: reserveAsset.borrowable,
|
|
184
|
+
collateralRisk: new Dec(reserveAsset.collateralRisk).div(10000).toNumber(),
|
|
185
|
+
collateralFactor: new Dec(reserveAsset.collateralFactor).div(10000).toNumber(),
|
|
186
|
+
liquidationFee: new Dec(reserveAsset.liquidationFee).div(10000).toNumber(),
|
|
187
|
+
price: new Dec(reserveAsset.price).div(new Dec(10).pow(oracleDecimals)).toString(),
|
|
188
|
+
totalSupplied: assetAmountInEth(totalSuppliedRaw.toString(), symbol),
|
|
189
|
+
totalDrawn: assetAmountInEth(totalDrawnRaw.toString(), symbol),
|
|
190
|
+
totalPremium: assetAmountInEth(totalPremiumRaw.toString(), symbol),
|
|
191
|
+
totalDebt: assetAmountInEth(totalDebtRaw.toString(), symbol),
|
|
192
|
+
supplyCap: assetAmountInEth(supplyCapRaw.toString(), symbol),
|
|
193
|
+
borrowCap: assetAmountInEth(borrowCapRaw.toString(), symbol),
|
|
194
|
+
spokeActive: reserveAsset.spokeActive,
|
|
195
|
+
spokeHalted: reserveAsset.spokeHalted,
|
|
196
|
+
drawnRate: drawnRate.toString(),
|
|
197
|
+
borrowRate: aprToApy(borrowApr.toString()),
|
|
198
|
+
supplyRate: aprToApy(supplyApr.toString()),
|
|
199
|
+
supplyIncentives,
|
|
200
|
+
borrowIncentives,
|
|
201
|
+
canBeBorrowed: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen && reserveAsset.borrowable,
|
|
202
|
+
canBeSupplied: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
|
|
203
|
+
canBeWithdrawn: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
|
|
204
|
+
canBePayBacked: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
|
|
205
|
+
utilization,
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export async function _getAaveV4SpokeData(provider: Client, network: NetworkNumber, market: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
210
|
+
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
211
|
+
|
|
212
|
+
const hubsData: Record<EthAddress, AaveV4HubOnChainData> = {};
|
|
213
|
+
const [spokeData] = await Promise.all([
|
|
214
|
+
viewContract.read.getSpokeDataFull([market.address]),
|
|
215
|
+
...market.hubs.map(async (hubAddress) => {
|
|
216
|
+
hubsData[hubAddress] = await fetchHubData(viewContract, hubAddress);
|
|
217
|
+
}),
|
|
218
|
+
]);
|
|
219
|
+
|
|
220
|
+
const reserveAssetsArray = await Promise.all(spokeData[1].map(async (reserveAssetOnChain: AaveV4ReserveAssetOnChain, index: number) => formatReserveAsset(reserveAssetOnChain, hubsData[reserveAssetOnChain.hub].assets[reserveAssetOnChain.assetId], index, +spokeData[0].oracleDecimals.toString(), network)));
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
assetsData: reserveAssetsArray.reduce((acc: Record<string, AaveV4ReserveAssetData>, reserveAsset: AaveV4ReserveAssetData) => {
|
|
224
|
+
acc[`${reserveAsset.symbol}-${reserveAsset.reserveId}`] = reserveAsset;
|
|
225
|
+
return acc;
|
|
226
|
+
}, {}),
|
|
227
|
+
oracle: spokeData[0].oracle,
|
|
228
|
+
oracleDecimals: +spokeData[0].oracleDecimals.toString(),
|
|
229
|
+
address: market.address,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export async function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
234
|
+
return _getAaveV4SpokeData(getViemProvider(provider, network), network, spoke, blockNumber);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export async function _getAaveV4AccountData(provider: Client, network: NetworkNumber, spokeData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4AccountData> {
|
|
238
|
+
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
239
|
+
|
|
240
|
+
const loanData = await viewContract.read.getLoanData([spokeData.address, address]);
|
|
241
|
+
|
|
242
|
+
const healthFactor = new Dec(loanData.healthFactor).div(1e18).toString();
|
|
243
|
+
const usedAssets = loanData.reserves.reduce((acc: AaveV4UsedReserveAssets, usedReserveAsset) => {
|
|
244
|
+
const identifier = `${wethToEth(getAssetInfoByAddress(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
|
|
245
|
+
const reserveData = spokeData.assetsData[identifier];
|
|
246
|
+
const price = reserveData.price;
|
|
247
|
+
const supplied = assetAmountInEth(usedReserveAsset.supplied.toString(), reserveData.symbol);
|
|
248
|
+
const drawn = assetAmountInEth(usedReserveAsset.drawn.toString(), reserveData.symbol);
|
|
249
|
+
const premium = assetAmountInEth(usedReserveAsset.premium.toString(), reserveData.symbol);
|
|
250
|
+
const borrowed = assetAmountInEth(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
|
|
251
|
+
acc[identifier] = {
|
|
252
|
+
symbol: reserveData.symbol,
|
|
253
|
+
hubName: reserveData.hubName,
|
|
254
|
+
assetId: reserveData.assetId,
|
|
255
|
+
reserveId: +usedReserveAsset.reserveId.toString(),
|
|
256
|
+
supplied,
|
|
257
|
+
suppliedUsd: new Dec(supplied).mul(price).toString(),
|
|
258
|
+
drawn,
|
|
259
|
+
drawnUsd: new Dec(drawn).mul(price).toString(),
|
|
260
|
+
premium,
|
|
261
|
+
premiumUsd: new Dec(premium).mul(price).toString(),
|
|
262
|
+
borrowed,
|
|
263
|
+
borrowedUsd: new Dec(borrowed).mul(price).toString(),
|
|
264
|
+
isSupplied: !new Dec(supplied).eq(0),
|
|
265
|
+
isBorrowed: usedReserveAsset.isBorrowing,
|
|
266
|
+
collateral: usedReserveAsset.isUsingAsCollateral,
|
|
267
|
+
collateralFactor: new Dec(usedReserveAsset.collateralFactor).div(10000).toNumber(),
|
|
268
|
+
};
|
|
269
|
+
return acc;
|
|
270
|
+
}, {});
|
|
271
|
+
|
|
272
|
+
const aggregated = aaveV4GetAggregatedPositionData({
|
|
273
|
+
usedAssets,
|
|
274
|
+
assetsData: spokeData.assetsData,
|
|
275
|
+
network,
|
|
276
|
+
useUserCollateralFactor: true,
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
const riskPremiumBps = calcUserRiskPremiumBps(usedAssets, spokeData.assetsData);
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
...aggregated,
|
|
283
|
+
usedAssets,
|
|
284
|
+
healthFactor,
|
|
285
|
+
riskPremiumBps,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export async function getAaveV4AccountData(provider: EthereumProvider, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<any> {
|
|
290
|
+
return _getAaveV4AccountData(getViemProvider(provider, network), network, marketData, address, blockNumber);
|
|
291
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
2
|
+
import { AaveV4ViewContractViem } from '../contracts';
|
|
3
|
+
import { getViemProvider } from '../services/viem';
|
|
4
|
+
import { wethToEth } from '../services/utils';
|
|
5
|
+
import {
|
|
6
|
+
EthAddress,
|
|
7
|
+
EthereumProvider,
|
|
8
|
+
NetworkNumber,
|
|
9
|
+
} from '../types/common';
|
|
10
|
+
|
|
11
|
+
export interface AaveV4TokenizationSpokeData {
|
|
12
|
+
underlyingAsset: EthAddress;
|
|
13
|
+
assetId: string;
|
|
14
|
+
decimals: number;
|
|
15
|
+
spoke: EthAddress;
|
|
16
|
+
spokeActive: boolean;
|
|
17
|
+
spokeHalted: boolean;
|
|
18
|
+
spokeDepositCap: string;
|
|
19
|
+
spokeTotalAssets: string;
|
|
20
|
+
spokeTotalShares: string;
|
|
21
|
+
hub: EthAddress;
|
|
22
|
+
hubLiquidity: string;
|
|
23
|
+
hubDrawnRate: string;
|
|
24
|
+
convertToShares: string;
|
|
25
|
+
convertToAssets: string;
|
|
26
|
+
user: EthAddress;
|
|
27
|
+
userSuppliedAssets: string;
|
|
28
|
+
userSuppliedShares: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const AAVE_V4_TOKENIZED_SPOKES: Record<string, EthAddress> = {
|
|
32
|
+
AAVE_CORE: '0x08309234884cF7E015b07Bf22569017Aa035cdeF',
|
|
33
|
+
EURC_CORE: '0x73596dED4B2Eb0aC85e477b3c8dB56FC427E6774',
|
|
34
|
+
GHO_CORE: '0xf7E1f1b43922527e5054bD77E7f863Cf182b194D',
|
|
35
|
+
GHO_PRIME: '0xeF1cAd5c6a2C9cb83c952b4B96bbD35b3F61F18f',
|
|
36
|
+
LBTC_CORE: '0x8f4D423590F22833131e3493bf67A27213398f8e',
|
|
37
|
+
LINK_CORE: '0xBE1197750b423e30137E97d9183065d33E903BE6',
|
|
38
|
+
PT_USDe_PLUS: '0x8cA27Ab284F2aA2BcF33D9129e11c101aD2d16de',
|
|
39
|
+
PT_sUSDe_PLUS: '0xb8A464EC56071a98c854f30fE19CfeCc41FA6233',
|
|
40
|
+
PYUSD_CORE: '0x203FB463087005698d50768FcA837047f738632d',
|
|
41
|
+
RLUSD_CORE: '0xa9afdd0c54fb153CaE39cE86E49626B5e9d15513',
|
|
42
|
+
USDC_CORE: '0xa2e476f4cbB06C7bFA8Ad51bCcbF198cd32CfD35',
|
|
43
|
+
USDC_PLUS: '0x320Bec4fB7a25e64c003A007D0AeF7AB3D6C30d7',
|
|
44
|
+
USDC_PRIME: '0x0A0507F7A1129892b5cf74b8B4e911442c466b87',
|
|
45
|
+
USDG_CORE: '0x87c224256f09a014C1BC3e9FbB094C3AdD8fBaCC',
|
|
46
|
+
USDT_CORE: '0x3f12BD5999b9172550893FF52691c980676f9E73',
|
|
47
|
+
USDT_PLUS: '0xa4E74a78bED2d3ab8971e8AB26fb39f26DD8eEd9',
|
|
48
|
+
USDT_PRIME: '0xF565fB55bc96d65561887898bfeb25C1dE7e06d2',
|
|
49
|
+
USDe_PLUS: '0xA0d346ab2699B689AC67aba5174164A84206BB73',
|
|
50
|
+
WBTC_CORE: '0x837Ab872A665e0CF467d41cF56a054031b4A38bc',
|
|
51
|
+
WBTC_PRIME: '0xeae98b8a1798738182B2123DF1eB93d97BD29F34',
|
|
52
|
+
WETH_CORE: '0x3961a75099E986F59a1a31c6f945061641dFD2b2',
|
|
53
|
+
WETH_PRIME: '0xa411826a6ef5d289c0FAa7d5B45FE8aAB52257F6',
|
|
54
|
+
XAUt_CORE: '0x470341bC0e2B833C54D0120642713BdF762A494F',
|
|
55
|
+
cbBTC_CORE: '0xe8D5E595d5b6b5EFf84B7064765fd0e8DfD214C9',
|
|
56
|
+
cbBTC_PRIME: '0x0E986545150DcDDe46Ea9df355D0fD2af33bd75D',
|
|
57
|
+
frxUSD_CORE: '0x00C8A6a42947Cc4E7B6f27963Cab0143ccaaD2B5',
|
|
58
|
+
frxUSD_PLUS: '0xCAB288d37CAb5a9db7b503F086455276Dcde61F1',
|
|
59
|
+
rsETH_CORE: '0x6eEce89caE2163584bA7Ff9743861B9633c245E0',
|
|
60
|
+
sUSDe_PLUS: '0xdf47fc43c88B06edC47753b7d647ff18037D2F3d',
|
|
61
|
+
weETH_CORE: '0xB67F20bFF413C8E5d633B54BD28899c4c9e33ed0',
|
|
62
|
+
wstETH_CORE: '0x474602394d0B02F43AC3D7C8c5cFc0814b03fd40',
|
|
63
|
+
wstETH_PRIME: '0xAcCdAb49ECB9A801CfF62a92fc80D52339b33770',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const AAVE_V4_TOKENIZED_SPOKE_ADDRESSES: Partial<Record<NetworkNumber, EthAddress[]>> = {
|
|
67
|
+
[NetworkNumber.Eth]: Object.values(AAVE_V4_TOKENIZED_SPOKES),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type AaveV4TokenizedHubKey = 'CORE' | 'PLUS' | 'PRIME';
|
|
71
|
+
|
|
72
|
+
export const aaveV4GetTokenizedHubKey = (hubNameOrKey?: string | null): AaveV4TokenizedHubKey | null => {
|
|
73
|
+
if (!hubNameOrKey) return null;
|
|
74
|
+
const normalized = hubNameOrKey.trim().toUpperCase();
|
|
75
|
+
|
|
76
|
+
// TODO AaveV4 Maybe turn into constants
|
|
77
|
+
if (normalized === 'CORE' || normalized === 'CORE HUB') return 'CORE';
|
|
78
|
+
if (normalized === 'PLUS' || normalized === 'PLUS HUB') return 'PLUS';
|
|
79
|
+
if (normalized === 'PRIME' || normalized === 'PRIME HUB') return 'PRIME';
|
|
80
|
+
|
|
81
|
+
if (normalized.includes('CORE')) return 'CORE';
|
|
82
|
+
if (normalized.includes('PLUS')) return 'PLUS';
|
|
83
|
+
if (normalized.includes('PRIME')) return 'PRIME';
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const aaveV4GetTokenizedVaultKey = (
|
|
89
|
+
symbol: string,
|
|
90
|
+
hubNameOrKey?: string | null,
|
|
91
|
+
): string | null => {
|
|
92
|
+
if (!symbol) return null;
|
|
93
|
+
const hubKey = aaveV4GetTokenizedHubKey(hubNameOrKey);
|
|
94
|
+
if (!hubKey) return null;
|
|
95
|
+
|
|
96
|
+
const normalizedSymbol = symbol.trim().replace(/-/g, '_');
|
|
97
|
+
|
|
98
|
+
return `${normalizedSymbol}_${hubKey}`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const aaveV4GetTokenizedVaultAddress = (
|
|
102
|
+
network: NetworkNumber,
|
|
103
|
+
symbol: string,
|
|
104
|
+
hubNameOrKey?: string | null,
|
|
105
|
+
): EthAddress | undefined => {
|
|
106
|
+
if (network !== NetworkNumber.Eth) return undefined;
|
|
107
|
+
const key = aaveV4GetTokenizedVaultKey(symbol, hubNameOrKey);
|
|
108
|
+
if (!key) return undefined;
|
|
109
|
+
return AAVE_V4_TOKENIZED_SPOKES[key];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** Parsed tokenization spoke data with human-readable supplied amounts for display */
|
|
113
|
+
export interface AaveV4TokenizationSpokeDataParsed {
|
|
114
|
+
vaultAddress: EthAddress;
|
|
115
|
+
key: string | null;
|
|
116
|
+
symbol: string;
|
|
117
|
+
hubKey: string;
|
|
118
|
+
userSuppliedAssetsEth: string;
|
|
119
|
+
userSuppliedSharesEth: string;
|
|
120
|
+
userSuppliedAssets: string;
|
|
121
|
+
userSuppliedShares: string;
|
|
122
|
+
underlyingAsset: EthAddress;
|
|
123
|
+
spoke: EthAddress;
|
|
124
|
+
decimals: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const AAVE_V4_TOKENIZED_SPOKE_ADDRESS_TO_KEY: Record<string, string> = Object.entries(
|
|
128
|
+
AAVE_V4_TOKENIZED_SPOKES,
|
|
129
|
+
).reduce((acc, [k, v]) => {
|
|
130
|
+
acc[v.toLowerCase()] = k;
|
|
131
|
+
return acc;
|
|
132
|
+
}, {} as Record<string, string>);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Fetches tokenization vault data for the given user via getTokenizationSpokesData.
|
|
136
|
+
* Returns parsed data including userSuppliedAssets in human-readable form for each vault.
|
|
137
|
+
*/
|
|
138
|
+
export async function getAaveV4TokenizationSpokesData(
|
|
139
|
+
provider: EthereumProvider,
|
|
140
|
+
network: NetworkNumber,
|
|
141
|
+
userAddress: EthAddress,
|
|
142
|
+
): Promise<AaveV4TokenizationSpokeDataParsed[]> {
|
|
143
|
+
const spokes = AAVE_V4_TOKENIZED_SPOKE_ADDRESSES[network] ?? [];
|
|
144
|
+
if (spokes.length === 0) return [];
|
|
145
|
+
|
|
146
|
+
const client = getViemProvider(provider, network);
|
|
147
|
+
const viewContract = AaveV4ViewContractViem(client, network);
|
|
148
|
+
const raw = await viewContract.read.getTokenizationSpokesData([spokes, userAddress]);
|
|
149
|
+
|
|
150
|
+
return raw.map((r: any, i: number) => {
|
|
151
|
+
const vaultAddress = spokes[i];
|
|
152
|
+
const key = AAVE_V4_TOKENIZED_SPOKE_ADDRESS_TO_KEY[vaultAddress.toLowerCase()] ?? null;
|
|
153
|
+
const symbol = wethToEth(getAssetInfoByAddress(r.underlyingAsset, network).symbol);
|
|
154
|
+
if (symbol === '?') { // unsupported asset
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const hubKey = key ? key.split('_').pop() ?? '' : '';
|
|
158
|
+
const decimals = Number(r.decimals ?? 18);
|
|
159
|
+
const userSuppliedAssetsRaw = r.userSuppliedAssets ?? 0;
|
|
160
|
+
const userSuppliedSharesRaw = r.userSuppliedShares ?? 0;
|
|
161
|
+
|
|
162
|
+
const userSuppliedAssetsEth = assetAmountInEth(userSuppliedAssetsRaw.toString(), symbol);
|
|
163
|
+
const userSuppliedSharesEth = assetAmountInEth(userSuppliedSharesRaw.toString(), symbol);
|
|
164
|
+
return {
|
|
165
|
+
vaultAddress,
|
|
166
|
+
key,
|
|
167
|
+
symbol,
|
|
168
|
+
hubKey,
|
|
169
|
+
userSuppliedAssetsEth,
|
|
170
|
+
userSuppliedSharesEth,
|
|
171
|
+
userSuppliedAssets: userSuppliedAssetsRaw.toString(),
|
|
172
|
+
userSuppliedShares: userSuppliedSharesRaw.toString(),
|
|
173
|
+
underlyingAsset: r.underlyingAsset,
|
|
174
|
+
spoke: r.spoke,
|
|
175
|
+
decimals,
|
|
176
|
+
};
|
|
177
|
+
}).filter(item => item != null);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
package/src/claiming/spark.ts
CHANGED
|
@@ -73,7 +73,7 @@ export const fetchSparkAirdropRewards = async (
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// Filter out IGNITION_REWARDS since they are no longer active
|
|
76
|
-
const filteredData = data.filter((rewardInfo: { type: SparkAirdropType; }) => rewardInfo.type !== SparkAirdropType.SPARK_IGNITION);
|
|
76
|
+
const filteredData = data.filter((rewardInfo: { type: SparkAirdropType; }) => rewardInfo.type !== SparkAirdropType.SPARK_IGNITION && rewardInfo.type !== SparkAirdropType.PRE_FARMING_AND_SOCIAL);
|
|
77
77
|
|
|
78
78
|
allClaimData.push({ walletAddress, data: filteredData });
|
|
79
79
|
|
package/src/config/contracts.ts
CHANGED
|
@@ -1323,3 +1323,11 @@ export const SkySavings = {
|
|
|
1323
1323
|
export const YearnV3Vault = {
|
|
1324
1324
|
"abi": [{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"addr","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalAssets","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalDebt","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]}]
|
|
1325
1325
|
} as const;
|
|
1326
|
+
export const AaveV4View = {
|
|
1327
|
+
"abi": [{"inputs":[{"internalType":"address","name":"_eoa","type":"address"},{"internalType":"address","name":"_proxy","type":"address"},{"internalType":"address","name":"_spoke","type":"address"}],"name":"getEOAApprovalsAndBalances","outputs":[{"components":[{"internalType":"address","name":"eoa","type":"address"},{"internalType":"address","name":"proxy","type":"address"},{"internalType":"address","name":"spoke","type":"address"},{"internalType":"bool","name":"giverPositionManagerEnabled","type":"bool"},{"internalType":"bool","name":"takerPositionManagerEnabled","type":"bool"},{"internalType":"bool","name":"configPositionManagerEnabled","type":"bool"},{"internalType":"bool","name":"canSetUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"canUpdateUserRiskPremium","type":"bool"},{"internalType":"bool","name":"canUpdateUserDynamicConfig","type":"bool"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"delegateeBorrowApproval","type":"uint256"},{"internalType":"uint256","name":"delegateeWithdrawApproval","type":"uint256"},{"internalType":"uint256","name":"eoaReserveBalance","type":"uint256"}],"internalType":"struct AaveV4View.EOAReserveApprovalData[]","name":"reserveApprovals","type":"tuple[]"}],"internalType":"struct AaveV4View.EOAApprovalData","name":"data","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getHealthFactor","outputs":[{"internalType":"uint256","name":"healthFactor","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hub","type":"address"}],"name":"getHubAllAssetsData","outputs":[{"components":[{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"totalDrawnShares","type":"uint256"},{"internalType":"uint256","name":"totalPremiumShares","type":"uint256"},{"internalType":"uint256","name":"swept","type":"uint256"},{"internalType":"uint16","name":"liquidityFee","type":"uint16"},{"internalType":"uint120","name":"drawnIndex","type":"uint120"},{"internalType":"uint96","name":"drawnRate","type":"uint96"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"},{"internalType":"address","name":"irStrategy","type":"address"},{"internalType":"address","name":"reinvestmentController","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"},{"internalType":"uint256","name":"deficitRay","type":"uint256"}],"internalType":"struct AaveV4View.HubAssetData[]","name":"hubAssetData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hub","type":"address"},{"internalType":"uint256","name":"_assetId","type":"uint256"}],"name":"getHubAssetData","outputs":[{"components":[{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"totalDrawnShares","type":"uint256"},{"internalType":"uint256","name":"totalPremiumShares","type":"uint256"},{"internalType":"uint256","name":"swept","type":"uint256"},{"internalType":"uint16","name":"liquidityFee","type":"uint16"},{"internalType":"uint120","name":"drawnIndex","type":"uint120"},{"internalType":"uint96","name":"drawnRate","type":"uint96"},{"internalType":"uint40","name":"lastUpdateTimestamp","type":"uint40"},{"internalType":"address","name":"irStrategy","type":"address"},{"internalType":"address","name":"reinvestmentController","type":"address"},{"internalType":"address","name":"feeReceiver","type":"address"},{"internalType":"uint256","name":"deficitRay","type":"uint256"}],"internalType":"struct AaveV4View.HubAssetData","name":"hubAssetData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getLoanData","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsdRay","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"struct AaveV4View.UserReserveData[]","name":"reserves","type":"tuple[]"}],"internalType":"struct AaveV4View.LoanData","name":"loanData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address[]","name":"_spokes","type":"address[]"}],"name":"getLoanDataForMultipleSpokes","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsdRay","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"struct AaveV4View.UserReserveData[]","name":"reserves","type":"tuple[]"}],"internalType":"struct AaveV4View.LoanData[]","name":"loans","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"getLoanDataForMultipleUsers","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsdRay","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"struct AaveV4View.UserReserveData[]","name":"reserves","type":"tuple[]"}],"internalType":"struct AaveV4View.LoanData[]","name":"loans","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getLoanDataFull","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"riskPremium","type":"uint256"},{"internalType":"uint256","name":"avgCollateralFactor","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"},{"internalType":"uint256","name":"totalCollateralInUsd","type":"uint256"},{"internalType":"uint256","name":"totalDebtInUsdRay","type":"uint256"},{"internalType":"uint256","name":"activeCollateralCount","type":"uint256"},{"internalType":"uint256","name":"borrowCount","type":"uint256"},{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"},{"internalType":"bool","name":"reservePaused","type":"bool"},{"internalType":"bool","name":"reserveFrozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokeHalted","type":"bool"},{"internalType":"uint256","name":"userSupplied","type":"uint256"},{"internalType":"uint256","name":"userDrawn","type":"uint256"},{"internalType":"uint256","name":"userPremium","type":"uint256"},{"internalType":"uint256","name":"userTotalDebt","type":"uint256"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"userCollateralFactor","type":"uint16"},{"internalType":"uint32","name":"userMaxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"userLiquidationFee","type":"uint16"},{"internalType":"uint16","name":"latestCollateralFactor","type":"uint16"},{"internalType":"uint32","name":"latestMaxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"latestLiquidationFee","type":"uint16"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"hubAssetId","type":"uint16"},{"internalType":"uint256","name":"hubLiquidity","type":"uint256"},{"internalType":"uint96","name":"drawnRate","type":"uint96"},{"internalType":"uint120","name":"drawnIndex","type":"uint120"},{"internalType":"uint256","name":"spokeTotalSupplied","type":"uint256"},{"internalType":"uint256","name":"spokeTotalDrawn","type":"uint256"},{"internalType":"uint256","name":"spokeTotalPremium","type":"uint256"},{"internalType":"uint256","name":"spokeTotalDebt","type":"uint256"},{"internalType":"uint256","name":"spokeSupplyCap","type":"uint256"},{"internalType":"uint256","name":"spokeBorrowCap","type":"uint256"},{"internalType":"uint256","name":"spokeDeficitRay","type":"uint256"}],"internalType":"struct AaveV4View.UserReserveDataFull[]","name":"reserves","type":"tuple[]"}],"internalType":"struct AaveV4View.LoanDataWithFullReserves","name":"loanData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"}],"name":"getReserveData","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct AaveV4View.ReserveData","name":"reserveData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"}],"name":"getReserveDataFull","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"borrowCap","type":"uint256"},{"internalType":"uint256","name":"deficitRay","type":"uint256"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokeHalted","type":"bool"}],"internalType":"struct AaveV4View.ReserveDataFull","name":"reserveData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256","name":"_reserveId","type":"uint256"}],"name":"getReservePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getReservePrices","outputs":[{"internalType":"uint256[]","name":"prices","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getReservesData","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct AaveV4View.ReserveData[]","name":"reserveData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getReservesDataFull","outputs":[{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"borrowCap","type":"uint256"},{"internalType":"uint256","name":"deficitRay","type":"uint256"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokeHalted","type":"bool"}],"internalType":"struct AaveV4View.ReserveDataFull[]","name":"reserveData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"}],"name":"getSpokeData","outputs":[{"components":[{"internalType":"uint128","name":"targetHealthFactor","type":"uint128"},{"internalType":"uint64","name":"healthFactorForMaxBonus","type":"uint64"},{"internalType":"uint16","name":"liquidationBonusFactor","type":"uint16"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint256","name":"oracleDecimals","type":"uint256"},{"internalType":"uint256","name":"reserveCount","type":"uint256"}],"internalType":"struct AaveV4View.SpokeData","name":"spokeData","type":"tuple"},{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct AaveV4View.ReserveData[]","name":"reserves","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"}],"name":"getSpokeDataFull","outputs":[{"components":[{"internalType":"uint128","name":"targetHealthFactor","type":"uint128"},{"internalType":"uint64","name":"healthFactorForMaxBonus","type":"uint64"},{"internalType":"uint16","name":"liquidationBonusFactor","type":"uint16"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"uint256","name":"oracleDecimals","type":"uint256"},{"internalType":"uint256","name":"reserveCount","type":"uint256"}],"internalType":"struct AaveV4View.SpokeData","name":"spokeData","type":"tuple"},{"components":[{"internalType":"address","name":"underlying","type":"address"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"frozen","type":"bool"},{"internalType":"bool","name":"borrowable","type":"bool"},{"internalType":"uint24","name":"collateralRisk","type":"uint24"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"totalSupplied","type":"uint256"},{"internalType":"uint256","name":"totalDrawn","type":"uint256"},{"internalType":"uint256","name":"totalPremium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"supplyCap","type":"uint256"},{"internalType":"uint256","name":"borrowCap","type":"uint256"},{"internalType":"uint256","name":"deficitRay","type":"uint256"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokeHalted","type":"bool"}],"internalType":"struct AaveV4View.ReserveDataFull[]","name":"reserves","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hub","type":"address"},{"internalType":"uint256","name":"_assetId","type":"uint256"}],"name":"getSpokesForAsset","outputs":[{"internalType":"address[]","name":"spokes","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"getTokenizationSpokeData","outputs":[{"components":[{"internalType":"address","name":"underlyingAsset","type":"address"},{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address","name":"spoke","type":"address"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokeHalted","type":"bool"},{"internalType":"uint256","name":"spokeDepositCap","type":"uint256"},{"internalType":"uint256","name":"spokeTotalAssets","type":"uint256"},{"internalType":"uint256","name":"spokeTotalShares","type":"uint256"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint256","name":"hubLiquidity","type":"uint256"},{"internalType":"uint96","name":"hubDrawnRate","type":"uint96"},{"internalType":"uint256","name":"convertToShares","type":"uint256"},{"internalType":"uint256","name":"convertToAssets","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"userSuppliedAssets","type":"uint256"},{"internalType":"uint256","name":"userSuppliedShares","type":"uint256"}],"internalType":"struct AaveV4View.TokenizationSpokeData","name":"spokeData","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_spokes","type":"address[]"},{"internalType":"address","name":"_user","type":"address"}],"name":"getTokenizationSpokesData","outputs":[{"components":[{"internalType":"address","name":"underlyingAsset","type":"address"},{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"address","name":"spoke","type":"address"},{"internalType":"bool","name":"spokeActive","type":"bool"},{"internalType":"bool","name":"spokeHalted","type":"bool"},{"internalType":"uint256","name":"spokeDepositCap","type":"uint256"},{"internalType":"uint256","name":"spokeTotalAssets","type":"uint256"},{"internalType":"uint256","name":"spokeTotalShares","type":"uint256"},{"internalType":"address","name":"hub","type":"address"},{"internalType":"uint256","name":"hubLiquidity","type":"uint256"},{"internalType":"uint96","name":"hubDrawnRate","type":"uint96"},{"internalType":"uint256","name":"convertToShares","type":"uint256"},{"internalType":"uint256","name":"convertToAssets","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"userSuppliedAssets","type":"uint256"},{"internalType":"uint256","name":"userSuppliedShares","type":"uint256"}],"internalType":"struct AaveV4View.TokenizationSpokeData[]","name":"spokeData","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spoke","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256[]","name":"_reserveIds","type":"uint256[]"}],"name":"getUserReserveData","outputs":[{"components":[{"internalType":"uint256","name":"reserveId","type":"uint256"},{"internalType":"uint16","name":"assetId","type":"uint16"},{"internalType":"address","name":"underlying","type":"address"},{"internalType":"uint256","name":"supplied","type":"uint256"},{"internalType":"uint256","name":"drawn","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint16","name":"collateralFactor","type":"uint16"},{"internalType":"uint32","name":"maxLiquidationBonus","type":"uint32"},{"internalType":"uint16","name":"liquidationFee","type":"uint16"},{"internalType":"bool","name":"isUsingAsCollateral","type":"bool"},{"internalType":"bool","name":"isBorrowing","type":"bool"}],"internalType":"struct AaveV4View.UserReserveData[]","name":"_userReserves","type":"tuple[]"}],"stateMutability":"view","type":"function"}],
|
|
1328
|
+
"networks": {
|
|
1329
|
+
"1": {
|
|
1330
|
+
"address": "0x10B748Dc504C2515Bb6A9e23CB2F686090b6c584",
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
} as const;
|
package/src/contracts.ts
CHANGED
|
@@ -179,3 +179,5 @@ export const YearnViewContractViem = createViemContractFromConfigFunc('YearnView
|
|
|
179
179
|
export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr');
|
|
180
180
|
|
|
181
181
|
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
182
|
+
|
|
183
|
+
export const AaveV4ViewContractViem = createViemContractFromConfigFunc('AaveV4View');
|