@defisaver/positions-sdk 2.1.79 → 2.1.82
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 +243 -0
- package/cjs/aaveV4/lend.d.ts +55 -0
- package/cjs/aaveV4/lend.js +131 -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/eulerV2/index.d.ts +1 -2
- package/cjs/eulerV2/index.js +4 -5
- package/cjs/helpers/aaveV4Helpers/index.d.ts +25 -0
- package/cjs/helpers/aaveV4Helpers/index.js +233 -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/moneymarket/moneymarketCommonService.js +1 -1
- package/cjs/portfolio/index.js +20 -0
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +3 -3
- package/cjs/types/aaveV4.d.ts +159 -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 +200 -0
- package/esm/aaveV4/lend.d.ts +55 -0
- package/esm/aaveV4/lend.js +124 -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/eulerV2/index.d.ts +1 -2
- package/esm/eulerV2/index.js +5 -6
- package/esm/helpers/aaveV4Helpers/index.d.ts +25 -0
- package/esm/helpers/aaveV4Helpers/index.js +221 -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/moneymarket/moneymarketCommonService.js +1 -1
- package/esm/portfolio/index.js +21 -1
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +1 -1
- package/esm/types/aaveV4.d.ts +159 -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 +221 -0
- package/src/aaveV4/lend.ts +185 -0
- package/src/config/contracts.ts +8 -0
- package/src/contracts.ts +2 -0
- package/src/eulerV2/index.ts +12 -7
- package/src/helpers/aaveV4Helpers/index.ts +291 -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/moneymarket/moneymarketCommonService.ts +1 -1
- package/src/portfolio/index.ts +20 -0
- package/src/services/utils.ts +1 -1
- package/src/types/aaveV4.ts +175 -0
- package/src/types/index.ts +2 -1
- package/src/types/portfolio.ts +4 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AaveV4HubInfo,
|
|
3
|
+
AaveV4HubsType,
|
|
4
|
+
AaveV4SpokeInfo,
|
|
5
|
+
AaveV4SpokesType,
|
|
6
|
+
NetworkNumber,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
|
|
9
|
+
// HUBS
|
|
10
|
+
|
|
11
|
+
export const AAVE_V4_CORE_HUB = (networkId: NetworkNumber): AaveV4HubInfo => ({
|
|
12
|
+
chainIds: [NetworkNumber.Eth],
|
|
13
|
+
label: 'Core Hub',
|
|
14
|
+
value: AaveV4HubsType.AaveV4CoreHub,
|
|
15
|
+
address: '0xCca852Bc40e560adC3b1Cc58CA5b55638ce826c9',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const AAVE_V4_PLUS_HUB = (networkId: NetworkNumber): AaveV4HubInfo => ({
|
|
19
|
+
chainIds: [NetworkNumber.Eth],
|
|
20
|
+
label: 'Plus Hub',
|
|
21
|
+
value: AaveV4HubsType.AaveV4PlusHub,
|
|
22
|
+
address: '0x06002e9c4412CB7814a791eA3666D905871E536A',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const AAVE_V4_PRIME_HUB = (networkId: NetworkNumber): AaveV4HubInfo => ({
|
|
26
|
+
chainIds: [NetworkNumber.Eth],
|
|
27
|
+
label: 'Prime Hub',
|
|
28
|
+
value: AaveV4HubsType.AaveV4PrimeHub,
|
|
29
|
+
address: '0x943827DCA022D0F354a8a8c332dA1e5Eb9f9F931',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const AaveV4Hubs = (networkId: NetworkNumber) => ({
|
|
33
|
+
[AaveV4HubsType.AaveV4CoreHub]: AAVE_V4_CORE_HUB(networkId),
|
|
34
|
+
[AaveV4HubsType.AaveV4PlusHub]: AAVE_V4_PLUS_HUB(networkId),
|
|
35
|
+
[AaveV4HubsType.AaveV4PrimeHub]: AAVE_V4_PRIME_HUB(networkId),
|
|
36
|
+
}) as const;
|
|
37
|
+
|
|
38
|
+
export const getAaveV4HubTypeInfo = (type: AaveV4HubsType, network?: NetworkNumber) => ({ ...AaveV4Hubs(network ?? NetworkNumber.Eth) }[type]);
|
|
39
|
+
|
|
40
|
+
export const getAaveV4HubByAddress = (networkId: NetworkNumber, address: string): AaveV4HubInfo | undefined => Object.values(AaveV4Hubs(networkId)).find(
|
|
41
|
+
hub => hub.address.toLowerCase() === address.toLowerCase(),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// SPOKES
|
|
45
|
+
|
|
46
|
+
export const AAVE_V4_BLUECHIP_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
47
|
+
chainIds: [NetworkNumber.Eth],
|
|
48
|
+
label: 'Bluechip',
|
|
49
|
+
value: AaveV4SpokesType.AaveV4BluechipSpoke,
|
|
50
|
+
url: 'bluechip',
|
|
51
|
+
address: '0x973a023A77420ba610f06b3858aD991Df6d85A08',
|
|
52
|
+
hubs: [
|
|
53
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
54
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
55
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const AAVE_V4_ETHENA_CORRELATED_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
60
|
+
chainIds: [NetworkNumber.Eth],
|
|
61
|
+
label: 'Ethena Correlated',
|
|
62
|
+
value: AaveV4SpokesType.AaveV4EthenaCorrelatedSpoke,
|
|
63
|
+
url: 'ethena-correlated',
|
|
64
|
+
address: '0x58131E79531caB1d52301228d1f7b842F26B9649',
|
|
65
|
+
hubs: [
|
|
66
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
67
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
68
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const AAVE_V4_ETHENA_ECOSYSTEM_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
73
|
+
chainIds: [NetworkNumber.Eth],
|
|
74
|
+
label: 'Ethena Ecosystem',
|
|
75
|
+
value: AaveV4SpokesType.AaveV4EthenaEcosystemSpoke,
|
|
76
|
+
url: 'ethena-ecosystem',
|
|
77
|
+
address: '0xba1B3D55D249692b669A164024A838309B7508AF',
|
|
78
|
+
hubs: [
|
|
79
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
80
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
81
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const AAVE_V4_ETHERFI_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
86
|
+
chainIds: [NetworkNumber.Eth],
|
|
87
|
+
label: 'Etherfi',
|
|
88
|
+
value: AaveV4SpokesType.AaveV4EtherfiSpoke,
|
|
89
|
+
url: 'etherfi',
|
|
90
|
+
address: '0xbF10BDfE177dE0336aFD7fcCF80A904E15386219',
|
|
91
|
+
hubs: [
|
|
92
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
93
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
94
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const AAVE_V4_FOREX_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
99
|
+
chainIds: [NetworkNumber.Eth],
|
|
100
|
+
label: 'Forex',
|
|
101
|
+
value: AaveV4SpokesType.AaveV4ForexSpoke,
|
|
102
|
+
url: 'forex',
|
|
103
|
+
address: '0xD8B93635b8C6d0fF98CbE90b5988E3F2d1Cd9da1',
|
|
104
|
+
hubs: [
|
|
105
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
106
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
107
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export const AAVE_V4_GOLD_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
112
|
+
chainIds: [NetworkNumber.Eth],
|
|
113
|
+
label: 'Gold',
|
|
114
|
+
value: AaveV4SpokesType.AaveV4GoldSpoke,
|
|
115
|
+
url: 'gold',
|
|
116
|
+
address: '0x65407b940966954b23dfA3caA5C0702bB42984DC',
|
|
117
|
+
hubs: [
|
|
118
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
119
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
120
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
121
|
+
],
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export const AAVE_V4_KELP_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
125
|
+
chainIds: [NetworkNumber.Eth],
|
|
126
|
+
label: 'Kelp',
|
|
127
|
+
value: AaveV4SpokesType.AaveV4KelpSpoke,
|
|
128
|
+
url: 'kelp',
|
|
129
|
+
address: '0x3131FE68C4722e726fe6B2819ED68e514395B9a4',
|
|
130
|
+
hubs: [
|
|
131
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
132
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
133
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const AAVE_V4_LIDO_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
138
|
+
chainIds: [NetworkNumber.Eth],
|
|
139
|
+
label: 'Lido',
|
|
140
|
+
value: AaveV4SpokesType.AaveV4LidoSpoke,
|
|
141
|
+
url: 'lido',
|
|
142
|
+
address: '0xe1900480ac69f0B296841Cd01cC37546d92F35Cd',
|
|
143
|
+
hubs: [
|
|
144
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
145
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
146
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const AAVE_V4_LOMBARD_BTC_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
151
|
+
chainIds: [NetworkNumber.Eth],
|
|
152
|
+
label: 'Lombard BTC',
|
|
153
|
+
value: AaveV4SpokesType.AaveV4LombardBtcSpoke,
|
|
154
|
+
url: 'lombard-btc',
|
|
155
|
+
address: '0x7EC68b5695e803e98a21a9A05d744F28b0a7753D',
|
|
156
|
+
hubs: [
|
|
157
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
158
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
159
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export const AAVE_V4_MAIN_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
164
|
+
chainIds: [NetworkNumber.Eth],
|
|
165
|
+
label: 'Main',
|
|
166
|
+
value: AaveV4SpokesType.AaveV4MainSpoke,
|
|
167
|
+
url: 'main',
|
|
168
|
+
address: '0x94e7A5dCbE816e498b89aB752661904E2F56c485',
|
|
169
|
+
hubs: [
|
|
170
|
+
AAVE_V4_CORE_HUB(NetworkNumber.Eth).address,
|
|
171
|
+
AAVE_V4_PLUS_HUB(NetworkNumber.Eth).address,
|
|
172
|
+
AAVE_V4_PRIME_HUB(NetworkNumber.Eth).address,
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export const AaveV4Spokes = (networkId: NetworkNumber) => ({
|
|
177
|
+
[AaveV4SpokesType.AaveV4BluechipSpoke]: AAVE_V4_BLUECHIP_SPOKE(networkId),
|
|
178
|
+
[AaveV4SpokesType.AaveV4EthenaCorrelatedSpoke]: AAVE_V4_ETHENA_CORRELATED_SPOKE(networkId),
|
|
179
|
+
[AaveV4SpokesType.AaveV4EthenaEcosystemSpoke]: AAVE_V4_ETHENA_ECOSYSTEM_SPOKE(networkId),
|
|
180
|
+
[AaveV4SpokesType.AaveV4EtherfiSpoke]: AAVE_V4_ETHERFI_SPOKE(networkId),
|
|
181
|
+
[AaveV4SpokesType.AaveV4ForexSpoke]: AAVE_V4_FOREX_SPOKE(networkId),
|
|
182
|
+
[AaveV4SpokesType.AaveV4GoldSpoke]: AAVE_V4_GOLD_SPOKE(networkId),
|
|
183
|
+
[AaveV4SpokesType.AaveV4KelpSpoke]: AAVE_V4_KELP_SPOKE(networkId),
|
|
184
|
+
[AaveV4SpokesType.AaveV4LidoSpoke]: AAVE_V4_LIDO_SPOKE(networkId),
|
|
185
|
+
[AaveV4SpokesType.AaveV4LombardBtcSpoke]: AAVE_V4_LOMBARD_BTC_SPOKE(networkId),
|
|
186
|
+
[AaveV4SpokesType.AaveV4MainSpoke]: AAVE_V4_MAIN_SPOKE(networkId),
|
|
187
|
+
}) as const;
|
|
188
|
+
|
|
189
|
+
export const getAaveV4SpokeTypeInfo = (type: AaveV4SpokesType, network?: NetworkNumber) => ({ ...AaveV4Spokes(network ?? NetworkNumber.Eth) }[type]);
|
|
190
|
+
|
|
191
|
+
|
package/src/markets/index.ts
CHANGED
|
@@ -21,5 +21,10 @@ export { LlamaLendMarkets } from './llamaLend';
|
|
|
21
21
|
export { LiquityV2Markets, findLiquityV2MarketByAddress } from './liquityV2';
|
|
22
22
|
export { EulerV2Markets } from './euler';
|
|
23
23
|
export {
|
|
24
|
-
FluidMarkets,
|
|
24
|
+
FluidMarkets,
|
|
25
|
+
getFluidVersionsDataForNetwork,
|
|
26
|
+
getFluidMarketInfoById,
|
|
27
|
+
getFTokenAddress,
|
|
28
|
+
getFluidMarketInfoByAddress,
|
|
25
29
|
} from './fluid';
|
|
30
|
+
export { AaveV4Spokes } from './aaveV4';
|
|
@@ -24,7 +24,7 @@ export const STABLE_ASSETS = [
|
|
|
24
24
|
'DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'USDA',
|
|
25
25
|
'USDe', 'sUSDe', 'USDS', 'sUSDS', 'USR', 'EURC', 'BOLD', 'BOLD Legacy', 'RLUSD', 'PT sUSDe July', 'PT eUSDe May',
|
|
26
26
|
'USDtb', 'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'PT sUSDe Sep', 'PT USDe Sep', 'PT sUSDe Nov', 'PT USDe Nov', 'PT sUSDe Jan', 'PT USDe Jan',
|
|
27
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
27
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'frxUSD',
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
export const isLeveragedPos = (usedAssets: MMUsedAssets, dustLimit = 5) => {
|
package/src/portfolio/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Dec from 'decimal.js';
|
|
|
2
2
|
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
3
3
|
import {
|
|
4
4
|
AaveMarkets,
|
|
5
|
+
AaveV4Spokes,
|
|
5
6
|
CompoundMarkets,
|
|
6
7
|
CrvUsdMarkets,
|
|
7
8
|
EulerV2Markets,
|
|
@@ -14,6 +15,7 @@ import { _getMorphoBlueAccountData, _getMorphoBlueMarketData, getMorphoEarn } fr
|
|
|
14
15
|
import {
|
|
15
16
|
AaveV2MarketData,
|
|
16
17
|
AaveV3MarketData,
|
|
18
|
+
AaveV4SpokeData,
|
|
17
19
|
AaveVersions,
|
|
18
20
|
CdpInfo,
|
|
19
21
|
CompoundV2MarketsData,
|
|
@@ -49,6 +51,7 @@ import { fetchSparkAirdropRewards, fetchSparkRewards } from '../claiming/spark';
|
|
|
49
51
|
import { fetchMorphoBlueRewards } from '../claiming/morphoBlue';
|
|
50
52
|
import { getKingRewards } from '../claiming/king';
|
|
51
53
|
import { fetchEthenaAirdropRewards } from '../claiming/ethena';
|
|
54
|
+
import { _getAaveV4AccountData, _getAaveV4SpokeData } from '../aaveV4';
|
|
52
55
|
|
|
53
56
|
export async function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], isSim = false): Promise<{
|
|
54
57
|
positions: PortfolioPositionsData;
|
|
@@ -71,6 +74,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
71
74
|
const llamaLendMarkets = [NetworkNumber.Eth, NetworkNumber.Arb].includes(network) ? Object.values(LlamaLendMarkets(network)).filter((market) => market.chainIds.includes(network)) : [];
|
|
72
75
|
const liquityV2Markets = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)) : [];
|
|
73
76
|
const liquityV2MarketsStaking = [NetworkNumber.Eth].includes(network) ? Object.values(LiquityV2Markets(network)).filter(market => !market.isLegacy) : [];
|
|
77
|
+
const aaveV4Spokes = Object.values(AaveV4Spokes(network)).filter((market) => market.chainIds.includes(network));
|
|
74
78
|
|
|
75
79
|
const args: [NetworkNumber, any?] = [network, { batch: { multicall: { batchSize: isSim ? 500_000 : 2_500_000 } } }];
|
|
76
80
|
const client = getViemProvider(provider, ...args);
|
|
@@ -87,6 +91,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
87
91
|
const crvUsdMarketsData: Record<string, CrvUSDGlobalMarketData> = {};
|
|
88
92
|
const llamaLendMarketsData: Record<string, LlamaLendGlobalMarketData> = {};
|
|
89
93
|
const liquityV2MarketsData: Record<string, LiquityV2MarketData> = {};
|
|
94
|
+
const aaveV4SpokesData: Record<string, AaveV4SpokeData> = {};
|
|
90
95
|
|
|
91
96
|
const markets = {
|
|
92
97
|
morphoMarketsData,
|
|
@@ -99,6 +104,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
99
104
|
crvUsdMarketsData,
|
|
100
105
|
llamaLendMarketsData,
|
|
101
106
|
liquityV2MarketsData,
|
|
107
|
+
aaveV4SpokesData,
|
|
102
108
|
};
|
|
103
109
|
|
|
104
110
|
const positions: PortfolioPositionsData = {};
|
|
@@ -109,6 +115,7 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
109
115
|
for (const address of allAddresses) {
|
|
110
116
|
positions[address.toLowerCase() as EthAddress] = {
|
|
111
117
|
aaveV3: {},
|
|
118
|
+
aaveV4: {},
|
|
112
119
|
morphoBlue: {},
|
|
113
120
|
compoundV3: {},
|
|
114
121
|
spark: {},
|
|
@@ -177,6 +184,10 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
177
184
|
const marketData = await _getAaveV3MarketData(client, network, market);
|
|
178
185
|
aaveV3MarketsData[market.value] = marketData;
|
|
179
186
|
}),
|
|
187
|
+
...aaveV4Spokes.map(async (spoke) => {
|
|
188
|
+
const spokeData = await _getAaveV4SpokeData(client, network, spoke);
|
|
189
|
+
aaveV4SpokesData[spoke.value] = spokeData;
|
|
190
|
+
}),
|
|
180
191
|
...aaveV2Markets.map(async (market) => {
|
|
181
192
|
const marketData = await _getAaveV2MarketsData(client, network, market);
|
|
182
193
|
aaveV2MarketsData[market.value] = marketData;
|
|
@@ -429,6 +440,15 @@ export async function getPortfolioData(provider: EthereumProvider, network: Netw
|
|
|
429
440
|
positions[address.toLowerCase() as EthAddress].aaveV3[market.value] = { error: `Error fetching AaveV3 account data for address ${address} on market ${market.value}`, data: null };
|
|
430
441
|
}
|
|
431
442
|
})).flat(),
|
|
443
|
+
...aaveV4Spokes.map((spoke) => allAddresses.map(async (address) => {
|
|
444
|
+
try {
|
|
445
|
+
const accData = await _getAaveV4AccountData(client, network, aaveV4SpokesData[spoke.value], address);
|
|
446
|
+
if (new Dec(accData.suppliedUsd).gt(0)) positions[address.toLowerCase() as EthAddress].aaveV4[spoke.value] = { error: '', data: accData };
|
|
447
|
+
} catch (error) {
|
|
448
|
+
console.error(`Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}:`, error);
|
|
449
|
+
positions[address.toLowerCase() as EthAddress].aaveV4[spoke.value] = { error: `Error fetching AaveV4 account data for address ${address} on spoke ${spoke.value}`, data: null };
|
|
450
|
+
}
|
|
451
|
+
})).flat(),
|
|
432
452
|
...morphoMarkets.map((market) => addresses.map(async (address) => {
|
|
433
453
|
try {
|
|
434
454
|
const [accDataPromise, earnDataPromise] = await Promise.allSettled([
|
package/src/services/utils.ts
CHANGED
|
@@ -49,7 +49,7 @@ export const isEnabledOnBitmap = (bitmap: number, assetId: number) => (BigInt(bi
|
|
|
49
49
|
|
|
50
50
|
export const MAXUINT:string = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
51
51
|
|
|
52
|
-
export const
|
|
52
|
+
export const isMaxUint = (amount: string) => compareAddresses(MAXUINT, amount);
|
|
53
53
|
|
|
54
54
|
export const isMainnetNetwork = (network: NetworkNumber) => network === NetworkNumber.Eth;
|
|
55
55
|
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EthAddress, IncentiveData, LeverageType, NetworkNumber,
|
|
3
|
+
} from './common';
|
|
4
|
+
|
|
5
|
+
export enum AaveV4HubsType {
|
|
6
|
+
AaveV4CoreHub = 'aave_v4_core_hub',
|
|
7
|
+
AaveV4PlusHub = 'aave_v4_plus_hub',
|
|
8
|
+
AaveV4PrimeHub = 'aave_v4_prime_hub',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum AaveV4SpokesType {
|
|
12
|
+
AaveV4BluechipSpoke = 'aave_v4_bluechip_spoke',
|
|
13
|
+
AaveV4EthenaCorrelatedSpoke = 'aave_v4_ethena_correlated_spoke',
|
|
14
|
+
AaveV4EthenaEcosystemSpoke = 'aave_v4_ethena_ecosystem_spoke',
|
|
15
|
+
AaveV4EtherfiSpoke = 'aave_v4_etherfi_spoke',
|
|
16
|
+
AaveV4ForexSpoke = 'aave_v4_forex_spoke',
|
|
17
|
+
AaveV4GoldSpoke = 'aave_v4_gold_spoke',
|
|
18
|
+
AaveV4KelpSpoke = 'aave_v4_kelp_spoke',
|
|
19
|
+
AaveV4LidoSpoke = 'aave_v4_lido_spoke',
|
|
20
|
+
AaveV4LombardBtcSpoke = 'aave_v4_lombard_btc_spoke',
|
|
21
|
+
AaveV4MainSpoke = 'aave_v4_main_spoke',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface AaveV4HubInfo {
|
|
25
|
+
chainIds: NetworkNumber[],
|
|
26
|
+
label: string,
|
|
27
|
+
value: AaveV4HubsType,
|
|
28
|
+
address: EthAddress,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AaveV4HubAssetOnChainData {
|
|
32
|
+
assetId: number,
|
|
33
|
+
drawnRate: bigint,
|
|
34
|
+
liquidity: bigint,
|
|
35
|
+
liquidityFee: number,
|
|
36
|
+
swept: bigint,
|
|
37
|
+
totalDrawn: bigint,
|
|
38
|
+
totalDrawnShares: bigint,
|
|
39
|
+
totalPremiumShares: bigint,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AaveV4HubOnChainData {
|
|
43
|
+
assets: Record<number, AaveV4HubAssetOnChainData>,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface AaveV4SpokeInfo {
|
|
47
|
+
chainIds: NetworkNumber[],
|
|
48
|
+
label: string,
|
|
49
|
+
value: AaveV4SpokesType,
|
|
50
|
+
url: string,
|
|
51
|
+
address: EthAddress,
|
|
52
|
+
hubs: EthAddress[],
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface AaveV4SpokeData {
|
|
56
|
+
assetsData: AaveV4AssetsData,
|
|
57
|
+
oracle: EthAddress,
|
|
58
|
+
oracleDecimals: number,
|
|
59
|
+
address: EthAddress,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AaveV4ReserveAssetOnChain {
|
|
63
|
+
underlying: EthAddress,
|
|
64
|
+
hub: EthAddress,
|
|
65
|
+
assetId: number,
|
|
66
|
+
decimals: number,
|
|
67
|
+
paused: boolean,
|
|
68
|
+
frozen: boolean,
|
|
69
|
+
borrowable: boolean,
|
|
70
|
+
collateralRisk: number,
|
|
71
|
+
collateralFactor: number,
|
|
72
|
+
maxLiquidationBonus: number,
|
|
73
|
+
liquidationFee: number,
|
|
74
|
+
price: bigint,
|
|
75
|
+
totalSupplied: bigint,
|
|
76
|
+
totalDrawn: bigint,
|
|
77
|
+
totalPremium: bigint,
|
|
78
|
+
totalDebt: bigint,
|
|
79
|
+
supplyCap: bigint,
|
|
80
|
+
borrowCap: bigint,
|
|
81
|
+
deficitRay: bigint,
|
|
82
|
+
spokeActive: boolean,
|
|
83
|
+
spokeHalted: boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface AaveV4ReserveAssetData {
|
|
87
|
+
symbol: string,
|
|
88
|
+
underlying: EthAddress,
|
|
89
|
+
hub: EthAddress,
|
|
90
|
+
hubName: string,
|
|
91
|
+
assetId: number,
|
|
92
|
+
reserveId: number,
|
|
93
|
+
paused: boolean,
|
|
94
|
+
frozen: boolean,
|
|
95
|
+
borrowable: boolean,
|
|
96
|
+
collateralRisk: number,
|
|
97
|
+
collateralFactor: number,
|
|
98
|
+
liquidationFee: number,
|
|
99
|
+
maxLiquidationBonus: number,
|
|
100
|
+
price: string,
|
|
101
|
+
totalSupplied: string,
|
|
102
|
+
totalDrawn: string,
|
|
103
|
+
totalPremium: string,
|
|
104
|
+
totalDebt: string,
|
|
105
|
+
supplyCap: string,
|
|
106
|
+
borrowCap: string,
|
|
107
|
+
spokeActive: boolean,
|
|
108
|
+
spokeHalted: boolean,
|
|
109
|
+
drawnRate: string,
|
|
110
|
+
supplyRate: string,
|
|
111
|
+
borrowRate: string,
|
|
112
|
+
supplyIncentives: IncentiveData[];
|
|
113
|
+
borrowIncentives: IncentiveData[];
|
|
114
|
+
canBeBorrowed: boolean;
|
|
115
|
+
canBeSupplied: boolean;
|
|
116
|
+
canBeWithdrawn: boolean;
|
|
117
|
+
canBePayBacked: boolean;
|
|
118
|
+
utilization: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type AaveV4AssetsData = Record<string, AaveV4ReserveAssetData>;
|
|
122
|
+
|
|
123
|
+
export interface AaveV4UsedReserveAsset {
|
|
124
|
+
symbol: string,
|
|
125
|
+
hubName: string,
|
|
126
|
+
assetId: number,
|
|
127
|
+
reserveId: number,
|
|
128
|
+
supplied: string,
|
|
129
|
+
suppliedUsd: string,
|
|
130
|
+
drawn: string,
|
|
131
|
+
drawnUsd: string,
|
|
132
|
+
premium: string,
|
|
133
|
+
premiumUsd: string,
|
|
134
|
+
borrowed: string,
|
|
135
|
+
borrowedUsd: string,
|
|
136
|
+
isSupplied: boolean,
|
|
137
|
+
isBorrowed: boolean,
|
|
138
|
+
collateral: boolean,
|
|
139
|
+
collateralFactor: number,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface AaveV4AggregatedPositionData {
|
|
143
|
+
suppliedUsd: string,
|
|
144
|
+
suppliedCollateralUsd: string,
|
|
145
|
+
borrowLimitUsd: string,
|
|
146
|
+
liquidationLimitUsd: string,
|
|
147
|
+
borrowedUsd: string,
|
|
148
|
+
drawnUsd: string,
|
|
149
|
+
premiumUsd: string,
|
|
150
|
+
leftToBorrowUsd: string,
|
|
151
|
+
ratio: string,
|
|
152
|
+
collRatio: string,
|
|
153
|
+
liqRatio: string,
|
|
154
|
+
liqPercent: string,
|
|
155
|
+
leveragedType: LeverageType,
|
|
156
|
+
leveragedAsset: string,
|
|
157
|
+
liquidationPrice: string,
|
|
158
|
+
minCollRatio: string,
|
|
159
|
+
collLiquidationRatio: string,
|
|
160
|
+
minHealthRatio: string,
|
|
161
|
+
healthRatio: string,
|
|
162
|
+
netApy: string,
|
|
163
|
+
incentiveUsd: string,
|
|
164
|
+
totalInterestUsd: string,
|
|
165
|
+
currentVolatilePairRatio?: string,
|
|
166
|
+
minRatio: string,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type AaveV4UsedReserveAssets = Record<string, AaveV4UsedReserveAsset>;
|
|
170
|
+
|
|
171
|
+
export interface AaveV4AccountData extends AaveV4AggregatedPositionData {
|
|
172
|
+
usedAssets: AaveV4UsedReserveAssets,
|
|
173
|
+
healthFactor: string,
|
|
174
|
+
riskPremiumBps: number,
|
|
175
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/portfolio.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';
|
|
@@ -54,6 +55,9 @@ export interface PortfolioPositionsDataForAddress {
|
|
|
54
55
|
[key: string]: FluidVaultData;
|
|
55
56
|
};
|
|
56
57
|
};
|
|
58
|
+
aaveV4: {
|
|
59
|
+
[key in AaveV4SpokesType]?: PortfolioProtocolData<AaveV4AccountData>;
|
|
60
|
+
};
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
export interface PortfolioPositionsData {
|