@defisaver/positions-sdk 2.1.71 → 2.1.72-aave-v4-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 +174 -0
- 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 +13 -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/aave/marketAssets.js +1 -1
- package/cjs/markets/aaveV4/index.d.ts +28 -0
- package/cjs/markets/aaveV4/index.js +140 -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/staking/eligibility.d.ts +6 -0
- package/cjs/staking/eligibility.js +37 -19
- package/cjs/staking/staking.js +4 -2
- package/cjs/types/aaveV4.d.ts +145 -0
- package/cjs/types/aaveV4.js +19 -0
- package/cjs/types/common.d.ts +2 -1
- package/cjs/types/common.js +1 -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 +165 -0
- 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 +13 -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/aave/marketAssets.js +1 -1
- package/esm/markets/aaveV4/index.d.ts +28 -0
- package/esm/markets/aaveV4/index.js +122 -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/staking/eligibility.d.ts +6 -0
- package/esm/staking/eligibility.js +35 -18
- package/esm/staking/staking.js +4 -2
- package/esm/types/aaveV4.d.ts +145 -0
- package/esm/types/aaveV4.js +16 -0
- package/esm/types/common.d.ts +2 -1
- package/esm/types/common.js +1 -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 +176 -0
- package/src/config/contracts.ts +9 -1
- package/src/contracts.ts +3 -1
- package/src/helpers/aaveV4Helpers/index.ts +128 -0
- package/src/helpers/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/markets/aave/marketAssets.ts +1 -1
- package/src/markets/aaveV4/index.ts +149 -0
- package/src/markets/index.ts +6 -1
- package/src/portfolio/index.ts +20 -0
- package/src/staking/eligibility.ts +67 -15
- package/src/staking/staking.ts +3 -2
- package/src/types/aaveV4.ts +161 -0
- package/src/types/common.ts +1 -0
- package/src/types/index.ts +2 -1
- package/src/types/portfolio.ts +4 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
|
|
2
|
+
export declare enum AaveV4HubsType {
|
|
3
|
+
AaveV4CoreHub = "aave_v4_core_hub",
|
|
4
|
+
AaveV4PlusHub = "aave_v4_plus_hub",
|
|
5
|
+
AaveV4PrimeHub = "aave_v4_prime_hub"
|
|
6
|
+
}
|
|
7
|
+
export declare enum AaveV4SpokesType {
|
|
8
|
+
AaveV4BluechipSpoke = "aave_v4_bluechip_spoke",
|
|
9
|
+
AaveV4EthenaSpoke = "aave_v4_ethena_spoke",
|
|
10
|
+
AaveV4EtherfiSpoke = "aave_v4_etherfi_spoke",
|
|
11
|
+
AaveV4GoldSpoke = "aave_v4_gold_spoke",
|
|
12
|
+
AaveV4KelpSpoke = "aave_v4_kelp_spoke",
|
|
13
|
+
AaveV4LidoSpoke = "aave_v4_lido_spoke",
|
|
14
|
+
AaveV4MainSpoke = "aave_v4_main_spoke"
|
|
15
|
+
}
|
|
16
|
+
export interface AaveV4HubInfo {
|
|
17
|
+
chainIds: NetworkNumber[];
|
|
18
|
+
label: string;
|
|
19
|
+
value: AaveV4HubsType;
|
|
20
|
+
address: EthAddress;
|
|
21
|
+
}
|
|
22
|
+
export interface AaveV4HubAssetOnChainData {
|
|
23
|
+
assetId: number;
|
|
24
|
+
drawnRate: bigint;
|
|
25
|
+
}
|
|
26
|
+
export interface AaveV4HubOnChainData {
|
|
27
|
+
assets: Record<number, AaveV4HubAssetOnChainData>;
|
|
28
|
+
}
|
|
29
|
+
export interface AaveV4SpokeInfo {
|
|
30
|
+
chainIds: NetworkNumber[];
|
|
31
|
+
label: string;
|
|
32
|
+
value: AaveV4SpokesType;
|
|
33
|
+
url: string;
|
|
34
|
+
address: EthAddress;
|
|
35
|
+
hubs: EthAddress[];
|
|
36
|
+
}
|
|
37
|
+
export interface AaveV4SpokeData {
|
|
38
|
+
assetsData: AaveV4AssetsData;
|
|
39
|
+
oracle: EthAddress;
|
|
40
|
+
oracleDecimals: number;
|
|
41
|
+
address: EthAddress;
|
|
42
|
+
}
|
|
43
|
+
export interface AaveV4ReserveAssetOnChain {
|
|
44
|
+
underlying: EthAddress;
|
|
45
|
+
hub: EthAddress;
|
|
46
|
+
assetId: number;
|
|
47
|
+
decimals: number;
|
|
48
|
+
paused: boolean;
|
|
49
|
+
frozen: boolean;
|
|
50
|
+
borrowable: boolean;
|
|
51
|
+
collateralRisk: number;
|
|
52
|
+
collateralFactor: number;
|
|
53
|
+
maxLiquidationBonus: number;
|
|
54
|
+
liquidationFee: number;
|
|
55
|
+
price: bigint;
|
|
56
|
+
totalSupplied: bigint;
|
|
57
|
+
totalDrawn: bigint;
|
|
58
|
+
totalPremium: bigint;
|
|
59
|
+
totalDebt: bigint;
|
|
60
|
+
supplyCap: bigint;
|
|
61
|
+
borrowCap: bigint;
|
|
62
|
+
deficitRay: bigint;
|
|
63
|
+
spokeActive: boolean;
|
|
64
|
+
spokeHalted: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface AaveV4ReserveAssetData {
|
|
67
|
+
symbol: string;
|
|
68
|
+
underlying: EthAddress;
|
|
69
|
+
hub: EthAddress;
|
|
70
|
+
hubName: string;
|
|
71
|
+
assetId: number;
|
|
72
|
+
reserveId: number;
|
|
73
|
+
paused: boolean;
|
|
74
|
+
frozen: boolean;
|
|
75
|
+
borrowable: boolean;
|
|
76
|
+
collateralRisk: number;
|
|
77
|
+
collateralFactor: number;
|
|
78
|
+
liquidationFee: number;
|
|
79
|
+
price: string;
|
|
80
|
+
totalSupplied: string;
|
|
81
|
+
totalDrawn: string;
|
|
82
|
+
totalPremium: string;
|
|
83
|
+
totalDebt: string;
|
|
84
|
+
supplyCap: string;
|
|
85
|
+
borrowCap: string;
|
|
86
|
+
spokeActive: boolean;
|
|
87
|
+
spokeHalted: boolean;
|
|
88
|
+
drawnRate: string;
|
|
89
|
+
supplyRate: string;
|
|
90
|
+
supplyIncentives: IncentiveData[];
|
|
91
|
+
borrowIncentives: IncentiveData[];
|
|
92
|
+
canBeBorrowed: boolean;
|
|
93
|
+
canBeSupplied: boolean;
|
|
94
|
+
canBeWithdrawn: boolean;
|
|
95
|
+
canBePayBacked: boolean;
|
|
96
|
+
utilization: string;
|
|
97
|
+
}
|
|
98
|
+
export type AaveV4AssetsData = Record<string, AaveV4ReserveAssetData>;
|
|
99
|
+
export interface AaveV4UsedReserveAsset {
|
|
100
|
+
symbol: string;
|
|
101
|
+
hubName: string;
|
|
102
|
+
assetId: number;
|
|
103
|
+
reserveId: number;
|
|
104
|
+
supplied: string;
|
|
105
|
+
suppliedUsd: string;
|
|
106
|
+
drawn: string;
|
|
107
|
+
drawnUsd: string;
|
|
108
|
+
premium: string;
|
|
109
|
+
premiumUsd: string;
|
|
110
|
+
borrowed: string;
|
|
111
|
+
borrowedUsd: string;
|
|
112
|
+
isSupplied: boolean;
|
|
113
|
+
isBorrowed: boolean;
|
|
114
|
+
collateral: boolean;
|
|
115
|
+
collateralFactor: number;
|
|
116
|
+
}
|
|
117
|
+
export interface AaveV4AggregatedPositionData {
|
|
118
|
+
suppliedUsd: string;
|
|
119
|
+
suppliedCollateralUsd: string;
|
|
120
|
+
borrowLimitUsd: string;
|
|
121
|
+
liquidationLimitUsd: string;
|
|
122
|
+
borrowedUsd: string;
|
|
123
|
+
drawnUsd: string;
|
|
124
|
+
premiumUsd: string;
|
|
125
|
+
leftToBorrowUsd: string;
|
|
126
|
+
ratio: string;
|
|
127
|
+
collRatio: string;
|
|
128
|
+
liqRatio: string;
|
|
129
|
+
liqPercent: string;
|
|
130
|
+
leveragedType: LeverageType;
|
|
131
|
+
leveragedAsset: string;
|
|
132
|
+
liquidationPrice: string;
|
|
133
|
+
minCollRatio: string;
|
|
134
|
+
collLiquidationRatio: string;
|
|
135
|
+
minHealthRatio: string;
|
|
136
|
+
netApy: string;
|
|
137
|
+
incentiveUsd: string;
|
|
138
|
+
totalInterestUsd: string;
|
|
139
|
+
currentVolatilePairRatio?: string;
|
|
140
|
+
}
|
|
141
|
+
export type AaveV4UsedReserveAssets = Record<string, AaveV4UsedReserveAsset>;
|
|
142
|
+
export interface AaveV4AccountData extends AaveV4AggregatedPositionData {
|
|
143
|
+
usedAssets: AaveV4UsedReserveAssets;
|
|
144
|
+
healthFactor: string;
|
|
145
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export var AaveV4HubsType;
|
|
2
|
+
(function (AaveV4HubsType) {
|
|
3
|
+
AaveV4HubsType["AaveV4CoreHub"] = "aave_v4_core_hub";
|
|
4
|
+
AaveV4HubsType["AaveV4PlusHub"] = "aave_v4_plus_hub";
|
|
5
|
+
AaveV4HubsType["AaveV4PrimeHub"] = "aave_v4_prime_hub";
|
|
6
|
+
})(AaveV4HubsType || (AaveV4HubsType = {}));
|
|
7
|
+
export var AaveV4SpokesType;
|
|
8
|
+
(function (AaveV4SpokesType) {
|
|
9
|
+
AaveV4SpokesType["AaveV4BluechipSpoke"] = "aave_v4_bluechip_spoke";
|
|
10
|
+
AaveV4SpokesType["AaveV4EthenaSpoke"] = "aave_v4_ethena_spoke";
|
|
11
|
+
AaveV4SpokesType["AaveV4EtherfiSpoke"] = "aave_v4_etherfi_spoke";
|
|
12
|
+
AaveV4SpokesType["AaveV4GoldSpoke"] = "aave_v4_gold_spoke";
|
|
13
|
+
AaveV4SpokesType["AaveV4KelpSpoke"] = "aave_v4_kelp_spoke";
|
|
14
|
+
AaveV4SpokesType["AaveV4LidoSpoke"] = "aave_v4_lido_spoke";
|
|
15
|
+
AaveV4SpokesType["AaveV4MainSpoke"] = "aave_v4_main_spoke";
|
|
16
|
+
})(AaveV4SpokesType || (AaveV4SpokesType = {}));
|
package/esm/types/common.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export declare enum IncentiveEligibilityId {
|
|
|
6
6
|
AaveV3EthenaLiquidLeverage = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL",
|
|
7
7
|
AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
|
|
8
8
|
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
|
|
9
|
-
AaveV3EthenaLiquidLeveragePlasma = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL"
|
|
9
|
+
AaveV3EthenaLiquidLeveragePlasma = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL",
|
|
10
|
+
AaveV3EthenaLiquidLeveragePlasmaGHO = "replace_when_known"
|
|
10
11
|
}
|
|
11
12
|
export declare enum LeverageType {
|
|
12
13
|
Long = "long",
|
package/esm/types/common.js
CHANGED
|
@@ -9,6 +9,7 @@ export var IncentiveEligibilityId;
|
|
|
9
9
|
IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
|
|
10
10
|
IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
|
|
11
11
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL";
|
|
12
|
+
IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasmaGHO"] = "replace_when_known";
|
|
12
13
|
})(IncentiveEligibilityId || (IncentiveEligibilityId = {}));
|
|
13
14
|
export var LeverageType;
|
|
14
15
|
(function (LeverageType) {
|
package/esm/types/index.d.ts
CHANGED
package/esm/types/index.js
CHANGED
package/esm/types/portfolio.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AaveV2PositionData, AaveV3PositionData, AaveVersions } from './aave';
|
|
2
|
+
import { AaveV4AccountData, AaveV4SpokesType } from './aaveV4';
|
|
2
3
|
import { EthAddress } from './common';
|
|
3
4
|
import { CompoundV2PositionData, CompoundV3PositionData, CompoundVersions } from './compound';
|
|
4
5
|
import { CrvUSDUserData, CrvUSDVersions } from './curveUsd';
|
|
@@ -51,6 +52,9 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
51
52
|
[key: string]: FluidVaultData;
|
|
52
53
|
};
|
|
53
54
|
};
|
|
55
|
+
aaveV4: {
|
|
56
|
+
[key in AaveV4SpokesType]?: PortfolioProtocolData<AaveV4AccountData>;
|
|
57
|
+
};
|
|
54
58
|
}
|
|
55
59
|
export interface PortfolioPositionsData {
|
|
56
60
|
[key: EthAddress]: PortfolioPositionsDataForAddress;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.72-aave-v4-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": "^1.7.
|
|
24
|
+
"@defisaver/tokens": "^1.7.26",
|
|
25
25
|
"@types/lodash": "^4.17.15",
|
|
26
26
|
"@types/memoizee": "^0.4.12",
|
|
27
27
|
"decimal.js": "^10.6.0",
|
|
@@ -0,0 +1,176 @@
|
|
|
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, AaveV4ReserveAssetOnChain, AaveV4SpokeData, AaveV4SpokeInfo,
|
|
10
|
+
AaveV4UsedReserveAssets,
|
|
11
|
+
} from '../types';
|
|
12
|
+
import {
|
|
13
|
+
EthAddress, EthereumProvider, IncentiveData, IncentiveKind, NetworkNumber,
|
|
14
|
+
} from '../types/common';
|
|
15
|
+
import { AaveV4ViewContractViem } from '../contracts';
|
|
16
|
+
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
17
|
+
import { wethToEth } from '../services/utils';
|
|
18
|
+
import { aaveV4GetAggregatedPositionData } from '../helpers/aaveV4Helpers';
|
|
19
|
+
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
20
|
+
|
|
21
|
+
const fetchHubData = async (viewContract: ReturnType<typeof AaveV4ViewContractViem>, hubAddress: EthAddress): Promise<AaveV4HubOnChainData> => {
|
|
22
|
+
const hubData = await viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
23
|
+
return {
|
|
24
|
+
assets: hubData.reduce((acc: Record<number, AaveV4HubAssetOnChainData>, assetOnChainData) => {
|
|
25
|
+
acc[assetOnChainData.assetId] = {
|
|
26
|
+
assetId: assetOnChainData.assetId,
|
|
27
|
+
drawnRate: assetOnChainData.drawnRate,
|
|
28
|
+
};
|
|
29
|
+
return acc;
|
|
30
|
+
}, {}),
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAsset: AaveV4HubAssetOnChainData, reserveId: number, oracleDecimals: number, network: NetworkNumber): Promise<AaveV4ReserveAssetData> => {
|
|
35
|
+
const assetInfo = getAssetInfoByAddress(reserveAsset.underlying, network);
|
|
36
|
+
const symbol = wethToEth(assetInfo.symbol);
|
|
37
|
+
const hubInfo = getAaveV4HubByAddress(network, reserveAsset.hub);
|
|
38
|
+
if (!hubInfo) {
|
|
39
|
+
throw new Error(`Hub not found with address: ${reserveAsset.hub}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const isStakingAsset = STAKING_ASSETS.includes(symbol);
|
|
43
|
+
const supplyIncentives: IncentiveData[] = [];
|
|
44
|
+
const borrowIncentives: IncentiveData[] = [];
|
|
45
|
+
|
|
46
|
+
if (isStakingAsset) {
|
|
47
|
+
const yieldApy = await getStakingApy(symbol, network as NetworkNumber);
|
|
48
|
+
supplyIncentives.push({
|
|
49
|
+
apy: yieldApy,
|
|
50
|
+
token: symbol,
|
|
51
|
+
incentiveKind: IncentiveKind.Staking,
|
|
52
|
+
description: `Native ${symbol} yield.`,
|
|
53
|
+
});
|
|
54
|
+
if (reserveAsset.borrowable) {
|
|
55
|
+
// when borrowing assets whose value increases over time
|
|
56
|
+
borrowIncentives.push({
|
|
57
|
+
apy: new Dec(yieldApy).mul(-1).toString(),
|
|
58
|
+
token: symbol,
|
|
59
|
+
incentiveKind: IncentiveKind.Reward,
|
|
60
|
+
description: `Due to the native yield of ${symbol}, the value of the debt would increase over time.`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return ({
|
|
66
|
+
symbol,
|
|
67
|
+
underlying: reserveAsset.underlying,
|
|
68
|
+
hub: hubInfo.address,
|
|
69
|
+
hubName: hubInfo?.label,
|
|
70
|
+
assetId: reserveAsset.assetId,
|
|
71
|
+
reserveId,
|
|
72
|
+
paused: reserveAsset.paused,
|
|
73
|
+
frozen: reserveAsset.frozen,
|
|
74
|
+
borrowable: reserveAsset.borrowable,
|
|
75
|
+
collateralRisk: new Dec(reserveAsset.collateralRisk).div(10000).toNumber(),
|
|
76
|
+
collateralFactor: new Dec(reserveAsset.collateralFactor).div(10000).toNumber(),
|
|
77
|
+
liquidationFee: new Dec(reserveAsset.liquidationFee).div(10000).toNumber(),
|
|
78
|
+
price: new Dec(reserveAsset.price).div(new Dec(10).pow(oracleDecimals)).toString(),
|
|
79
|
+
totalSupplied: assetAmountInEth(reserveAsset.totalSupplied.toString(), symbol),
|
|
80
|
+
totalDrawn: assetAmountInEth(reserveAsset.totalDrawn.toString(), symbol),
|
|
81
|
+
totalPremium: assetAmountInEth(reserveAsset.totalPremium.toString(), symbol),
|
|
82
|
+
totalDebt: assetAmountInEth(reserveAsset.totalDebt.toString(), symbol),
|
|
83
|
+
supplyCap: assetAmountInEth(reserveAsset.supplyCap.toString(), symbol),
|
|
84
|
+
borrowCap: assetAmountInEth(reserveAsset.borrowCap.toString(), symbol),
|
|
85
|
+
spokeActive: reserveAsset.spokeActive,
|
|
86
|
+
spokeHalted: reserveAsset.spokeHalted,
|
|
87
|
+
drawnRate: new Dec(hubAsset.drawnRate).div(new Dec(10).pow(27)).toString(),
|
|
88
|
+
supplyRate: '0', // To be implemented
|
|
89
|
+
supplyIncentives,
|
|
90
|
+
borrowIncentives,
|
|
91
|
+
canBeBorrowed: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
|
|
92
|
+
canBeSupplied: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused && !reserveAsset.frozen,
|
|
93
|
+
canBeWithdrawn: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
|
|
94
|
+
canBePayBacked: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
|
|
95
|
+
utilization: new Dec(reserveAsset.totalDrawn.toString()).times(100).div(new Dec(reserveAsset.totalSupplied.toString())).toString(),
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export async function _getAaveV4SpokeData(provider: Client, network: NetworkNumber, market: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
100
|
+
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
101
|
+
|
|
102
|
+
const hubsData: Record<EthAddress, AaveV4HubOnChainData> = {};
|
|
103
|
+
const [spokeData] = await Promise.all([
|
|
104
|
+
viewContract.read.getSpokeDataFull([market.address]),
|
|
105
|
+
...market.hubs.map(async (hubAddress) => {
|
|
106
|
+
hubsData[hubAddress] = await fetchHubData(viewContract, hubAddress);
|
|
107
|
+
}),
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
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)));
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
assetsData: reserveAssetsArray.reduce((acc: Record<string, AaveV4ReserveAssetData>, reserveAsset: AaveV4ReserveAssetData) => {
|
|
114
|
+
acc[`${reserveAsset.symbol}-${reserveAsset.reserveId}`] = reserveAsset;
|
|
115
|
+
return acc;
|
|
116
|
+
}, {}),
|
|
117
|
+
oracle: spokeData[0].oracle,
|
|
118
|
+
oracleDecimals: +spokeData[0].oracleDecimals.toString(),
|
|
119
|
+
address: market.address,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4SpokeData> {
|
|
124
|
+
return _getAaveV4SpokeData(getViemProvider(provider, network), network, spoke, blockNumber);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function _getAaveV4AccountData(provider: Client, network: NetworkNumber, spokeData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<AaveV4AccountData> {
|
|
128
|
+
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
129
|
+
|
|
130
|
+
const loanData = await viewContract.read.getLoanData([spokeData.address, address]);
|
|
131
|
+
|
|
132
|
+
const healthFactor = new Dec(loanData.healthFactor).div(1e18).toString();
|
|
133
|
+
const usedAssets = loanData.reserves.reduce((acc: AaveV4UsedReserveAssets, usedReserveAsset) => {
|
|
134
|
+
const identifier = `${wethToEth(getAssetInfoByAddress(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
|
|
135
|
+
const reserveData = spokeData.assetsData[identifier];
|
|
136
|
+
const price = reserveData.price;
|
|
137
|
+
const supplied = assetAmountInEth(usedReserveAsset.supplied.toString(), reserveData.symbol);
|
|
138
|
+
const drawn = assetAmountInEth(usedReserveAsset.drawn.toString(), reserveData.symbol);
|
|
139
|
+
const premium = assetAmountInEth(usedReserveAsset.premium.toString(), reserveData.symbol);
|
|
140
|
+
const borrowed = assetAmountInEth(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
|
|
141
|
+
acc[identifier] = {
|
|
142
|
+
symbol: reserveData.symbol,
|
|
143
|
+
hubName: reserveData.hubName,
|
|
144
|
+
assetId: reserveData.assetId,
|
|
145
|
+
reserveId: +usedReserveAsset.reserveId.toString(),
|
|
146
|
+
supplied,
|
|
147
|
+
suppliedUsd: new Dec(supplied).mul(price).toString(),
|
|
148
|
+
drawn,
|
|
149
|
+
drawnUsd: new Dec(drawn).mul(price).toString(),
|
|
150
|
+
premium,
|
|
151
|
+
premiumUsd: new Dec(premium).mul(price).toString(),
|
|
152
|
+
borrowed,
|
|
153
|
+
borrowedUsd: new Dec(borrowed).mul(price).toString(),
|
|
154
|
+
isSupplied: !new Dec(supplied).eq(0),
|
|
155
|
+
isBorrowed: usedReserveAsset.isBorrowing,
|
|
156
|
+
collateral: usedReserveAsset.isUsingAsCollateral,
|
|
157
|
+
collateralFactor: new Dec(usedReserveAsset.collateralFactor).div(10000).toNumber(),
|
|
158
|
+
};
|
|
159
|
+
return acc;
|
|
160
|
+
}, {});
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
usedAssets,
|
|
164
|
+
healthFactor,
|
|
165
|
+
...aaveV4GetAggregatedPositionData({
|
|
166
|
+
usedAssets,
|
|
167
|
+
assetsData: spokeData.assetsData,
|
|
168
|
+
network,
|
|
169
|
+
useUserCollateralFactor: true,
|
|
170
|
+
}),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export async function getAaveV4AccountData(provider: EthereumProvider, network: NetworkNumber, marketData: AaveV4SpokeData, address: EthAddress, blockNumber: 'latest' | number = 'latest'): Promise<any> {
|
|
175
|
+
return _getAaveV4AccountData(getViemProvider(provider, network), network, marketData, address, blockNumber);
|
|
176
|
+
}
|
package/src/config/contracts.ts
CHANGED
|
@@ -620,7 +620,7 @@ export const AaveLoanInfoV2 = {
|
|
|
620
620
|
"address": "0xEDf1087544a01596b70Da746F861B878F245B08f"
|
|
621
621
|
},
|
|
622
622
|
}
|
|
623
|
-
},
|
|
623
|
+
},
|
|
624
624
|
}
|
|
625
625
|
} as const;
|
|
626
626
|
export const LendingPoolAddressesProvider = {
|
|
@@ -1322,4 +1322,12 @@ export const SkySavings = {
|
|
|
1322
1322
|
} as const;
|
|
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
|
+
} 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": "0x34b6B5A3e8fB9135EbB47ACE4242b47E51064f5D",
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1325
1333
|
} as const;
|
package/src/contracts.ts
CHANGED
|
@@ -169,4 +169,6 @@ export const YearnViewContractViem = createViemContractFromConfigFunc('YearnView
|
|
|
169
169
|
|
|
170
170
|
export const MakerDsrContractViem = createViemContractFromConfigFunc('MakerDsr');
|
|
171
171
|
|
|
172
|
-
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
172
|
+
export const SkySavingsContractView = createViemContractFromConfigFunc('SkySavings');
|
|
173
|
+
|
|
174
|
+
export const AaveV4ViewContractViem = createViemContractFromConfigFunc('AaveV4View');
|