@defisaver/positions-sdk 2.1.51-aave-v4-dev → 2.1.52-aave-v4
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.js +8 -1
- package/cjs/helpers/aaveV4Helpers/index.js +1 -1
- package/cjs/markets/aaveV4/index.d.ts +7 -1
- package/cjs/markets/aaveV4/index.js +18 -1
- package/cjs/types/aaveV4.d.ts +8 -0
- package/cjs/types/common.d.ts +1 -1
- package/cjs/types/common.js +1 -1
- package/esm/aaveV4/index.js +8 -1
- package/esm/helpers/aaveV4Helpers/index.js +1 -1
- package/esm/markets/aaveV4/index.d.ts +7 -1
- package/esm/markets/aaveV4/index.js +14 -1
- package/esm/types/aaveV4.d.ts +8 -0
- package/esm/types/common.d.ts +1 -1
- package/esm/types/common.js +1 -1
- package/package.json +1 -1
- package/src/aaveV4/index.ts +8 -1
- package/src/helpers/aaveV4Helpers/index.ts +1 -1
- package/src/markets/aaveV4/index.ts +25 -2
- package/src/types/aaveV4.ts +9 -0
- package/src/types/common.ts +1 -1
package/cjs/aaveV4/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const contracts_1 = require("../contracts");
|
|
|
24
24
|
const staking_1 = require("../staking");
|
|
25
25
|
const utils_1 = require("../services/utils");
|
|
26
26
|
const aaveV4Helpers_1 = require("../helpers/aaveV4Helpers");
|
|
27
|
+
const aaveV4_1 = require("../markets/aaveV4");
|
|
27
28
|
const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
29
|
const hubData = yield viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
29
30
|
return {
|
|
@@ -39,6 +40,10 @@ const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, voi
|
|
|
39
40
|
const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
41
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(reserveAsset.underlying, network);
|
|
41
42
|
const symbol = (0, utils_1.wethToEth)(assetInfo.symbol);
|
|
43
|
+
const hubInfo = (0, aaveV4_1.getAaveV4HubByAddress)(network, reserveAsset.hub);
|
|
44
|
+
if (!hubInfo) {
|
|
45
|
+
throw new Error(`Hub not found with address: ${reserveAsset.hub}`);
|
|
46
|
+
}
|
|
42
47
|
const isStakingAsset = staking_1.STAKING_ASSETS.includes(symbol);
|
|
43
48
|
const supplyIncentives = [];
|
|
44
49
|
const borrowIncentives = [];
|
|
@@ -63,7 +68,8 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
63
68
|
return ({
|
|
64
69
|
symbol,
|
|
65
70
|
underlying: reserveAsset.underlying,
|
|
66
|
-
hub:
|
|
71
|
+
hub: hubInfo.address,
|
|
72
|
+
hubName: hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.label,
|
|
67
73
|
assetId: reserveAsset.assetId,
|
|
68
74
|
reserveId,
|
|
69
75
|
paused: reserveAsset.paused,
|
|
@@ -134,6 +140,7 @@ function _getAaveV4AccountData(provider_1, network_1, spokeData_1, address_1) {
|
|
|
134
140
|
const borrowed = (0, tokens_1.assetAmountInEth)(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
|
|
135
141
|
acc[identifier] = {
|
|
136
142
|
symbol: reserveData.symbol,
|
|
143
|
+
hubName: reserveData.hubName,
|
|
137
144
|
assetId: reserveData.assetId,
|
|
138
145
|
reserveId: +usedReserveAsset.reserveId.toString(),
|
|
139
146
|
supplied,
|
|
@@ -81,7 +81,7 @@ const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, network, useU
|
|
|
81
81
|
payload.leveragedAsset = leveragedAsset;
|
|
82
82
|
payload.liquidationPrice = '';
|
|
83
83
|
if (leveragedType !== '') {
|
|
84
|
-
const leveragedAssetData =
|
|
84
|
+
const leveragedAssetData = assetsData[leveragedAsset];
|
|
85
85
|
let assetPrice = (leveragedAssetData === null || leveragedAssetData === void 0 ? void 0 : leveragedAssetData.price) || '0';
|
|
86
86
|
if (leveragedType === 'lsd-leverage') {
|
|
87
87
|
// Treat ETH like a stablecoin in a long stETH position
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
|
|
1
|
+
import { AaveV4HubInfo, AaveV4HubsType, AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
|
|
2
2
|
import { NetworkNumber } from '../../types/common';
|
|
3
3
|
export declare const AAVE_V4_CORE_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
4
4
|
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
5
5
|
readonly aave_v4_core_spoke: AaveV4SpokeInfo;
|
|
6
6
|
};
|
|
7
7
|
export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
|
|
8
|
+
export declare const AAVE_V4_CORE_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
9
|
+
export declare const AaveV4Hubs: (networkId: NetworkNumber) => {
|
|
10
|
+
readonly aave_v4_core_hub: AaveV4HubInfo;
|
|
11
|
+
};
|
|
12
|
+
export declare const getAaveV4HubTypeInfo: (type: AaveV4HubsType, network?: NetworkNumber) => AaveV4HubInfo;
|
|
13
|
+
export declare const getAaveV4HubByAddress: (networkId: NetworkNumber, address: string) => AaveV4HubInfo | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_CORE_SPOKE = void 0;
|
|
3
|
+
exports.getAaveV4HubByAddress = exports.getAaveV4HubTypeInfo = exports.AaveV4Hubs = exports.AAVE_V4_CORE_HUB = exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_CORE_SPOKE = void 0;
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
const common_1 = require("../../types/common");
|
|
6
|
+
// SPOKES
|
|
6
7
|
const AAVE_V4_CORE_SPOKE = (networkId) => ({
|
|
7
8
|
chainIds: [common_1.NetworkNumber.Eth],
|
|
8
9
|
label: 'Core Spoke',
|
|
@@ -20,3 +21,19 @@ const AaveV4Spokes = (networkId) => ({
|
|
|
20
21
|
exports.AaveV4Spokes = AaveV4Spokes;
|
|
21
22
|
const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Spokes)(network !== null && network !== void 0 ? network : common_1.NetworkNumber.Eth))[type]);
|
|
22
23
|
exports.getAaveV4SpokeTypeInfo = getAaveV4SpokeTypeInfo;
|
|
24
|
+
// HUBS
|
|
25
|
+
const AAVE_V4_CORE_HUB = (networkId) => ({
|
|
26
|
+
chainIds: [common_1.NetworkNumber.Eth],
|
|
27
|
+
label: 'Core Hub',
|
|
28
|
+
value: types_1.AaveV4HubsType.AaveV4CoreHub,
|
|
29
|
+
address: '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
30
|
+
});
|
|
31
|
+
exports.AAVE_V4_CORE_HUB = AAVE_V4_CORE_HUB;
|
|
32
|
+
const AaveV4Hubs = (networkId) => ({
|
|
33
|
+
[types_1.AaveV4HubsType.AaveV4CoreHub]: (0, exports.AAVE_V4_CORE_HUB)(networkId),
|
|
34
|
+
});
|
|
35
|
+
exports.AaveV4Hubs = AaveV4Hubs;
|
|
36
|
+
const getAaveV4HubTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Hubs)(network !== null && network !== void 0 ? network : common_1.NetworkNumber.Eth))[type]);
|
|
37
|
+
exports.getAaveV4HubTypeInfo = getAaveV4HubTypeInfo;
|
|
38
|
+
const getAaveV4HubByAddress = (networkId, address) => Object.values((0, exports.AaveV4Hubs)(networkId)).find(hub => hub.address.toLowerCase() === address.toLowerCase());
|
|
39
|
+
exports.getAaveV4HubByAddress = getAaveV4HubByAddress;
|
package/cjs/types/aaveV4.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export interface AaveV4SpokeInfo {
|
|
|
13
13
|
address: EthAddress;
|
|
14
14
|
hubs: EthAddress[];
|
|
15
15
|
}
|
|
16
|
+
export interface AaveV4HubInfo {
|
|
17
|
+
chainIds: NetworkNumber[];
|
|
18
|
+
label: string;
|
|
19
|
+
value: AaveV4HubsType;
|
|
20
|
+
address: EthAddress;
|
|
21
|
+
}
|
|
16
22
|
export interface AaveV4HubAssetOnChainData {
|
|
17
23
|
assetId: number;
|
|
18
24
|
drawnRate: bigint;
|
|
@@ -47,6 +53,7 @@ export interface AaveV4ReserveAssetData {
|
|
|
47
53
|
symbol: string;
|
|
48
54
|
underlying: EthAddress;
|
|
49
55
|
hub: EthAddress;
|
|
56
|
+
hubName: string;
|
|
50
57
|
assetId: number;
|
|
51
58
|
reserveId: number;
|
|
52
59
|
paused: boolean;
|
|
@@ -83,6 +90,7 @@ export interface AaveV4SpokeData {
|
|
|
83
90
|
}
|
|
84
91
|
export interface AaveV4UsedReserveAsset {
|
|
85
92
|
symbol: string;
|
|
93
|
+
hubName: string;
|
|
86
94
|
assetId: number;
|
|
87
95
|
reserveId: number;
|
|
88
96
|
supplied: string;
|
package/cjs/types/common.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare enum IncentiveKind {
|
|
|
3
3
|
Reward = "reward"
|
|
4
4
|
}
|
|
5
5
|
export declare enum IncentiveEligibilityId {
|
|
6
|
-
AaveV3EthenaLiquidLeverage = "
|
|
6
|
+
AaveV3EthenaLiquidLeverage = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL",
|
|
7
7
|
AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
|
|
8
8
|
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
|
|
9
9
|
AaveV3EthenaLiquidLeveragePlasma = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL"
|
package/cjs/types/common.js
CHANGED
|
@@ -8,7 +8,7 @@ var IncentiveKind;
|
|
|
8
8
|
})(IncentiveKind || (exports.IncentiveKind = IncentiveKind = {}));
|
|
9
9
|
var IncentiveEligibilityId;
|
|
10
10
|
(function (IncentiveEligibilityId) {
|
|
11
|
-
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "
|
|
11
|
+
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL";
|
|
12
12
|
IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
|
|
13
13
|
IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
|
|
14
14
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL";
|
package/esm/aaveV4/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { AaveV4ViewContractViem } from '../contracts';
|
|
|
15
15
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
16
|
import { wethToEth } from '../services/utils';
|
|
17
17
|
import { aaveV4GetAggregatedPositionData } from '../helpers/aaveV4Helpers';
|
|
18
|
+
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
18
19
|
const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
20
|
const hubData = yield viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
20
21
|
return {
|
|
@@ -30,6 +31,10 @@ const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, voi
|
|
|
30
31
|
const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
32
|
const assetInfo = getAssetInfoByAddress(reserveAsset.underlying, network);
|
|
32
33
|
const symbol = wethToEth(assetInfo.symbol);
|
|
34
|
+
const hubInfo = getAaveV4HubByAddress(network, reserveAsset.hub);
|
|
35
|
+
if (!hubInfo) {
|
|
36
|
+
throw new Error(`Hub not found with address: ${reserveAsset.hub}`);
|
|
37
|
+
}
|
|
33
38
|
const isStakingAsset = STAKING_ASSETS.includes(symbol);
|
|
34
39
|
const supplyIncentives = [];
|
|
35
40
|
const borrowIncentives = [];
|
|
@@ -54,7 +59,8 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
54
59
|
return ({
|
|
55
60
|
symbol,
|
|
56
61
|
underlying: reserveAsset.underlying,
|
|
57
|
-
hub:
|
|
62
|
+
hub: hubInfo.address,
|
|
63
|
+
hubName: hubInfo === null || hubInfo === void 0 ? void 0 : hubInfo.label,
|
|
58
64
|
assetId: reserveAsset.assetId,
|
|
59
65
|
reserveId,
|
|
60
66
|
paused: reserveAsset.paused,
|
|
@@ -125,6 +131,7 @@ export function _getAaveV4AccountData(provider_1, network_1, spokeData_1, addres
|
|
|
125
131
|
const borrowed = assetAmountInEth(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
|
|
126
132
|
acc[identifier] = {
|
|
127
133
|
symbol: reserveData.symbol,
|
|
134
|
+
hubName: reserveData.hubName,
|
|
128
135
|
assetId: reserveData.assetId,
|
|
129
136
|
reserveId: +usedReserveAsset.reserveId.toString(),
|
|
130
137
|
supplied,
|
|
@@ -73,7 +73,7 @@ export const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, networ
|
|
|
73
73
|
payload.leveragedAsset = leveragedAsset;
|
|
74
74
|
payload.liquidationPrice = '';
|
|
75
75
|
if (leveragedType !== '') {
|
|
76
|
-
const leveragedAssetData =
|
|
76
|
+
const leveragedAssetData = assetsData[leveragedAsset];
|
|
77
77
|
let assetPrice = (leveragedAssetData === null || leveragedAssetData === void 0 ? void 0 : leveragedAssetData.price) || '0';
|
|
78
78
|
if (leveragedType === 'lsd-leverage') {
|
|
79
79
|
// Treat ETH like a stablecoin in a long stETH position
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
|
|
1
|
+
import { AaveV4HubInfo, AaveV4HubsType, AaveV4SpokeInfo, AaveV4SpokesType } from '../../types';
|
|
2
2
|
import { NetworkNumber } from '../../types/common';
|
|
3
3
|
export declare const AAVE_V4_CORE_SPOKE: (networkId: NetworkNumber) => AaveV4SpokeInfo;
|
|
4
4
|
export declare const AaveV4Spokes: (networkId: NetworkNumber) => {
|
|
5
5
|
readonly aave_v4_core_spoke: AaveV4SpokeInfo;
|
|
6
6
|
};
|
|
7
7
|
export declare const getAaveV4SpokeTypeInfo: (type: AaveV4SpokesType, network?: NetworkNumber) => AaveV4SpokeInfo;
|
|
8
|
+
export declare const AAVE_V4_CORE_HUB: (networkId: NetworkNumber) => AaveV4HubInfo;
|
|
9
|
+
export declare const AaveV4Hubs: (networkId: NetworkNumber) => {
|
|
10
|
+
readonly aave_v4_core_hub: AaveV4HubInfo;
|
|
11
|
+
};
|
|
12
|
+
export declare const getAaveV4HubTypeInfo: (type: AaveV4HubsType, network?: NetworkNumber) => AaveV4HubInfo;
|
|
13
|
+
export declare const getAaveV4HubByAddress: (networkId: NetworkNumber, address: string) => AaveV4HubInfo | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AaveV4SpokesType } from '../../types';
|
|
1
|
+
import { AaveV4HubsType, AaveV4SpokesType, } from '../../types';
|
|
2
2
|
import { NetworkNumber } from '../../types/common';
|
|
3
|
+
// SPOKES
|
|
3
4
|
export const AAVE_V4_CORE_SPOKE = (networkId) => ({
|
|
4
5
|
chainIds: [NetworkNumber.Eth],
|
|
5
6
|
label: 'Core Spoke',
|
|
@@ -14,3 +15,15 @@ export const AaveV4Spokes = (networkId) => ({
|
|
|
14
15
|
[AaveV4SpokesType.AaveV4CoreSpoke]: AAVE_V4_CORE_SPOKE(networkId),
|
|
15
16
|
});
|
|
16
17
|
export const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, AaveV4Spokes(network !== null && network !== void 0 ? network : NetworkNumber.Eth))[type]);
|
|
18
|
+
// HUBS
|
|
19
|
+
export const AAVE_V4_CORE_HUB = (networkId) => ({
|
|
20
|
+
chainIds: [NetworkNumber.Eth],
|
|
21
|
+
label: 'Core Hub',
|
|
22
|
+
value: AaveV4HubsType.AaveV4CoreHub,
|
|
23
|
+
address: '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
24
|
+
});
|
|
25
|
+
export const AaveV4Hubs = (networkId) => ({
|
|
26
|
+
[AaveV4HubsType.AaveV4CoreHub]: AAVE_V4_CORE_HUB(networkId),
|
|
27
|
+
});
|
|
28
|
+
export const getAaveV4HubTypeInfo = (type, network) => (Object.assign({}, AaveV4Hubs(network !== null && network !== void 0 ? network : NetworkNumber.Eth))[type]);
|
|
29
|
+
export const getAaveV4HubByAddress = (networkId, address) => Object.values(AaveV4Hubs(networkId)).find(hub => hub.address.toLowerCase() === address.toLowerCase());
|
package/esm/types/aaveV4.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export interface AaveV4SpokeInfo {
|
|
|
13
13
|
address: EthAddress;
|
|
14
14
|
hubs: EthAddress[];
|
|
15
15
|
}
|
|
16
|
+
export interface AaveV4HubInfo {
|
|
17
|
+
chainIds: NetworkNumber[];
|
|
18
|
+
label: string;
|
|
19
|
+
value: AaveV4HubsType;
|
|
20
|
+
address: EthAddress;
|
|
21
|
+
}
|
|
16
22
|
export interface AaveV4HubAssetOnChainData {
|
|
17
23
|
assetId: number;
|
|
18
24
|
drawnRate: bigint;
|
|
@@ -47,6 +53,7 @@ export interface AaveV4ReserveAssetData {
|
|
|
47
53
|
symbol: string;
|
|
48
54
|
underlying: EthAddress;
|
|
49
55
|
hub: EthAddress;
|
|
56
|
+
hubName: string;
|
|
50
57
|
assetId: number;
|
|
51
58
|
reserveId: number;
|
|
52
59
|
paused: boolean;
|
|
@@ -83,6 +90,7 @@ export interface AaveV4SpokeData {
|
|
|
83
90
|
}
|
|
84
91
|
export interface AaveV4UsedReserveAsset {
|
|
85
92
|
symbol: string;
|
|
93
|
+
hubName: string;
|
|
86
94
|
assetId: number;
|
|
87
95
|
reserveId: number;
|
|
88
96
|
supplied: string;
|
package/esm/types/common.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare enum IncentiveKind {
|
|
|
3
3
|
Reward = "reward"
|
|
4
4
|
}
|
|
5
5
|
export declare enum IncentiveEligibilityId {
|
|
6
|
-
AaveV3EthenaLiquidLeverage = "
|
|
6
|
+
AaveV3EthenaLiquidLeverage = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL",
|
|
7
7
|
AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
|
|
8
8
|
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
|
|
9
9
|
AaveV3EthenaLiquidLeveragePlasma = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL"
|
package/esm/types/common.js
CHANGED
|
@@ -5,7 +5,7 @@ export var IncentiveKind;
|
|
|
5
5
|
})(IncentiveKind || (IncentiveKind = {}));
|
|
6
6
|
export var IncentiveEligibilityId;
|
|
7
7
|
(function (IncentiveEligibilityId) {
|
|
8
|
-
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "
|
|
8
|
+
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL";
|
|
9
9
|
IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
|
|
10
10
|
IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
|
|
11
11
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL";
|
package/package.json
CHANGED
package/src/aaveV4/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { AaveV4ViewContractViem } from '../contracts';
|
|
|
16
16
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
17
17
|
import { wethToEth } from '../services/utils';
|
|
18
18
|
import { aaveV4GetAggregatedPositionData } from '../helpers/aaveV4Helpers';
|
|
19
|
+
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
19
20
|
|
|
20
21
|
const fetchHubData = async (viewContract: ReturnType<typeof AaveV4ViewContractViem>, hubAddress: EthAddress): Promise<AaveV4HubOnChainData> => {
|
|
21
22
|
const hubData = await viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
@@ -33,6 +34,10 @@ const fetchHubData = async (viewContract: ReturnType<typeof AaveV4ViewContractVi
|
|
|
33
34
|
const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAsset: AaveV4HubAssetOnChainData, reserveId: number, oracleDecimals: number, network: NetworkNumber): Promise<AaveV4ReserveAssetData> => {
|
|
34
35
|
const assetInfo = getAssetInfoByAddress(reserveAsset.underlying, network);
|
|
35
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
|
+
}
|
|
36
41
|
|
|
37
42
|
const isStakingAsset = STAKING_ASSETS.includes(symbol);
|
|
38
43
|
const supplyIncentives: IncentiveData[] = [];
|
|
@@ -60,7 +65,8 @@ const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAs
|
|
|
60
65
|
return ({
|
|
61
66
|
symbol,
|
|
62
67
|
underlying: reserveAsset.underlying,
|
|
63
|
-
hub:
|
|
68
|
+
hub: hubInfo.address,
|
|
69
|
+
hubName: hubInfo?.label,
|
|
64
70
|
assetId: reserveAsset.assetId,
|
|
65
71
|
reserveId,
|
|
66
72
|
paused: reserveAsset.paused,
|
|
@@ -134,6 +140,7 @@ export async function _getAaveV4AccountData(provider: Client, network: NetworkNu
|
|
|
134
140
|
const borrowed = assetAmountInEth(usedReserveAsset.totalDebt.toString(), reserveData.symbol);
|
|
135
141
|
acc[identifier] = {
|
|
136
142
|
symbol: reserveData.symbol,
|
|
143
|
+
hubName: reserveData.hubName,
|
|
137
144
|
assetId: reserveData.assetId,
|
|
138
145
|
reserveId: +usedReserveAsset.reserveId.toString(),
|
|
139
146
|
supplied,
|
|
@@ -93,7 +93,7 @@ export const aaveV4GetAggregatedPositionData = ({
|
|
|
93
93
|
payload.leveragedAsset = leveragedAsset;
|
|
94
94
|
payload.liquidationPrice = '';
|
|
95
95
|
if (leveragedType !== '') {
|
|
96
|
-
const leveragedAssetData =
|
|
96
|
+
const leveragedAssetData = assetsData[leveragedAsset];
|
|
97
97
|
let assetPrice = leveragedAssetData?.price || '0';
|
|
98
98
|
if (leveragedType === 'lsd-leverage') {
|
|
99
99
|
// Treat ETH like a stablecoin in a long stETH position
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AaveV4HubInfo, AaveV4HubsType, AaveV4SpokeInfo, AaveV4SpokesType,
|
|
3
|
+
} from '../../types';
|
|
2
4
|
import { NetworkNumber } from '../../types/common';
|
|
3
5
|
|
|
6
|
+
// SPOKES
|
|
7
|
+
|
|
4
8
|
export const AAVE_V4_CORE_SPOKE = (networkId: NetworkNumber): AaveV4SpokeInfo => ({
|
|
5
9
|
chainIds: [NetworkNumber.Eth],
|
|
6
10
|
label: 'Core Spoke',
|
|
@@ -16,4 +20,23 @@ export const AaveV4Spokes = (networkId: NetworkNumber) => ({
|
|
|
16
20
|
[AaveV4SpokesType.AaveV4CoreSpoke]: AAVE_V4_CORE_SPOKE(networkId),
|
|
17
21
|
}) as const;
|
|
18
22
|
|
|
19
|
-
export const getAaveV4SpokeTypeInfo = (type: AaveV4SpokesType, network?: NetworkNumber) => ({ ...AaveV4Spokes(network ?? NetworkNumber.Eth) }[type]);
|
|
23
|
+
export const getAaveV4SpokeTypeInfo = (type: AaveV4SpokesType, network?: NetworkNumber) => ({ ...AaveV4Spokes(network ?? NetworkNumber.Eth) }[type]);
|
|
24
|
+
|
|
25
|
+
// HUBS
|
|
26
|
+
|
|
27
|
+
export const AAVE_V4_CORE_HUB = (networkId: NetworkNumber): AaveV4HubInfo => ({
|
|
28
|
+
chainIds: [NetworkNumber.Eth],
|
|
29
|
+
label: 'Core Hub',
|
|
30
|
+
value: AaveV4HubsType.AaveV4CoreHub,
|
|
31
|
+
address: '0xaD905aD5EA5B98cD50AE40Cfe368344686a21366',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const AaveV4Hubs = (networkId: NetworkNumber) => ({
|
|
35
|
+
[AaveV4HubsType.AaveV4CoreHub]: AAVE_V4_CORE_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
|
+
);
|
package/src/types/aaveV4.ts
CHANGED
|
@@ -17,6 +17,13 @@ export interface AaveV4SpokeInfo {
|
|
|
17
17
|
hubs: EthAddress[],
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export interface AaveV4HubInfo {
|
|
21
|
+
chainIds: NetworkNumber[],
|
|
22
|
+
label: string,
|
|
23
|
+
value: AaveV4HubsType,
|
|
24
|
+
address: EthAddress,
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
export interface AaveV4HubAssetOnChainData {
|
|
21
28
|
assetId: number,
|
|
22
29
|
drawnRate: bigint,
|
|
@@ -54,6 +61,7 @@ export interface AaveV4ReserveAssetData {
|
|
|
54
61
|
symbol: string,
|
|
55
62
|
underlying: EthAddress,
|
|
56
63
|
hub: EthAddress,
|
|
64
|
+
hubName: string,
|
|
57
65
|
assetId: number,
|
|
58
66
|
reserveId: number,
|
|
59
67
|
paused: boolean,
|
|
@@ -93,6 +101,7 @@ export interface AaveV4SpokeData {
|
|
|
93
101
|
|
|
94
102
|
export interface AaveV4UsedReserveAsset {
|
|
95
103
|
symbol: string,
|
|
104
|
+
hubName: string,
|
|
96
105
|
assetId: number,
|
|
97
106
|
reserveId: number,
|
|
98
107
|
supplied: string,
|
package/src/types/common.ts
CHANGED
|
@@ -4,7 +4,7 @@ export enum IncentiveKind {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export enum IncentiveEligibilityId {
|
|
7
|
-
AaveV3EthenaLiquidLeverage = '
|
|
7
|
+
AaveV3EthenaLiquidLeverage = '0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL',
|
|
8
8
|
AaveV3ArbitrumEthSupply = '0x5d16261c6715a653248269861bbacf68a9774cde',
|
|
9
9
|
AaveV3ArbitrumETHLSBorrow = '0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351',
|
|
10
10
|
AaveV3EthenaLiquidLeveragePlasma = '0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL',
|