@defisaver/positions-sdk 2.1.43-dev-stats-test-2-dev → 2.1.44-aave-v1-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/aaveV3/index.js +0 -13
- package/cjs/aaveV3/merit.js +1 -5
- package/cjs/aaveV3/merkl.js +0 -1
- package/cjs/savings/morphoVaults/options.js +1 -1
- package/cjs/staking/staking.js +26 -22
- package/esm/aaveV3/index.js +0 -13
- package/esm/aaveV3/merit.js +1 -5
- package/esm/aaveV3/merkl.js +0 -1
- package/esm/savings/morphoVaults/options.js +1 -1
- package/esm/staking/staking.js +26 -22
- package/package.json +1 -1
- package/src/aaveV3/index.ts +4 -14
- package/src/aaveV3/merit.ts +1 -3
- package/src/aaveV3/merkl.ts +0 -1
- package/src/savings/morphoVaults/options.ts +1 -1
- package/src/staking/staking.ts +24 -20
package/cjs/aaveV3/index.js
CHANGED
|
@@ -59,7 +59,6 @@ exports.aaveV3EmodeCategoriesMapping = aaveV3EmodeCategoriesMapping;
|
|
|
59
59
|
function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
60
60
|
return __awaiter(this, arguments, void 0, function* (provider, network, market, blockNumber = 'latest') {
|
|
61
61
|
const _addresses = market.assets.map(a => (0, tokens_1.getAssetInfo)((0, utils_1.getWrappedNativeAssetFromUnwrapped)(a), network).address);
|
|
62
|
-
console.log('Fetched addresses');
|
|
63
62
|
const isL2 = (0, utils_1.isLayer2Network)(network);
|
|
64
63
|
const loanInfoContract = (0, contracts_1.AaveV3ViewContractViem)(provider, network);
|
|
65
64
|
const aaveIncentivesContract = (0, contracts_1.AaveIncentiveDataProviderV3ContractViem)(provider, network);
|
|
@@ -74,7 +73,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
74
73
|
(0, merkl_1.getMerkleCampaigns)(network),
|
|
75
74
|
(0, merit_1.getMeritCampaigns)(network, market.value),
|
|
76
75
|
]);
|
|
77
|
-
console.log('Fetched tokens, emodes, campaigns, incentives');
|
|
78
76
|
isBorrowAllowed = (0, utils_1.isLayer2Network)(network) ? isBorrowAllowed : true;
|
|
79
77
|
const eModeCategoriesData = {};
|
|
80
78
|
for (let i = 0; i < eModesInfo.length; i++) {
|
|
@@ -92,7 +90,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
92
90
|
collateralAssets: [],
|
|
93
91
|
};
|
|
94
92
|
}
|
|
95
|
-
console.log('Parsed e modes info');
|
|
96
93
|
if (networksWithIncentives.includes(network) && rewardInfo) {
|
|
97
94
|
rewardInfo = rewardInfo.reduce((all, _market) => {
|
|
98
95
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -100,7 +97,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
100
97
|
return all;
|
|
101
98
|
}, {});
|
|
102
99
|
}
|
|
103
|
-
console.log('Parsed reward info');
|
|
104
100
|
const assetsData = yield Promise.all(loanInfo
|
|
105
101
|
.map((tokenMarket, i) => __awaiter(this, void 0, void 0, function* () {
|
|
106
102
|
const symbol = market.assets[i];
|
|
@@ -162,7 +158,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
162
158
|
borrowIncentives: [],
|
|
163
159
|
});
|
|
164
160
|
})));
|
|
165
|
-
console.log('Parsed assets data');
|
|
166
161
|
// Get incentives data
|
|
167
162
|
yield Promise.all(assetsData.map((_market, index) => __awaiter(this, void 0, void 0, function* () {
|
|
168
163
|
var _a, _b;
|
|
@@ -170,10 +165,8 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
170
165
|
// @ts-ignore
|
|
171
166
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
172
167
|
const isStakingAsset = staking_1.STAKING_ASSETS.includes(_market.symbol);
|
|
173
|
-
console.log('Processing market', _market.symbol);
|
|
174
168
|
if (isStakingAsset) {
|
|
175
169
|
const yieldApy = yield (0, staking_1.getStakingApy)(_market.symbol, network);
|
|
176
|
-
console.log('Got yield apy', yieldApy);
|
|
177
170
|
_market.supplyIncentives.push({
|
|
178
171
|
apy: yieldApy,
|
|
179
172
|
token: _market.symbol,
|
|
@@ -201,7 +194,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
201
194
|
eligibilityId: identifier,
|
|
202
195
|
});
|
|
203
196
|
}
|
|
204
|
-
console.log('Processed merkle a incentives');
|
|
205
197
|
const vTokenAddress = _market.vTokenAddress.toLowerCase(); // DEV: Should vTokenAddress be in AaveV3AssetData type?
|
|
206
198
|
if ((_b = merkleRewardsMap[vTokenAddress]) === null || _b === void 0 ? void 0 : _b.borrow) {
|
|
207
199
|
const { apy, rewardTokenSymbol, description, identifier, } = merkleRewardsMap[vTokenAddress].borrow;
|
|
@@ -213,7 +205,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
213
205
|
eligibilityId: identifier,
|
|
214
206
|
});
|
|
215
207
|
}
|
|
216
|
-
console.log('Processed merkle v incentives');
|
|
217
208
|
if (meritRewardsMap.supply[_market.symbol]) {
|
|
218
209
|
const { apy, rewardTokenSymbol, description } = meritRewardsMap.supply[_market.symbol];
|
|
219
210
|
_market.supplyIncentives.push({
|
|
@@ -223,7 +214,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
223
214
|
description,
|
|
224
215
|
});
|
|
225
216
|
}
|
|
226
|
-
console.log('Processed merit supply incentives');
|
|
227
217
|
if (meritRewardsMap.borrow[_market.symbol]) {
|
|
228
218
|
const { apy, rewardTokenSymbol, description } = meritRewardsMap.borrow[_market.symbol];
|
|
229
219
|
_market.borrowIncentives.push({
|
|
@@ -233,10 +223,8 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
233
223
|
description,
|
|
234
224
|
});
|
|
235
225
|
}
|
|
236
|
-
console.log('Processed merit borrow incentives');
|
|
237
226
|
if (!rewardForMarket)
|
|
238
227
|
return;
|
|
239
|
-
console.log('Reward for market', rewardForMarket);
|
|
240
228
|
// @ts-ignore
|
|
241
229
|
rewardForMarket.aIncentiveData.rewardsTokenInformation.forEach(supplyRewardData => {
|
|
242
230
|
if (supplyRewardData) {
|
|
@@ -303,7 +291,6 @@ function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
303
291
|
collateralAssets: assetsData.map((a) => a.symbol),
|
|
304
292
|
borrowAssets: assetsData.map((a) => a.symbol),
|
|
305
293
|
};
|
|
306
|
-
console.log('Parsed payload');
|
|
307
294
|
return { assetsData: payload, eModeCategoriesData };
|
|
308
295
|
});
|
|
309
296
|
}
|
package/cjs/aaveV3/merit.js
CHANGED
|
@@ -53,15 +53,12 @@ const MERIT_DATA_MAP = {
|
|
|
53
53
|
* Fetches merit rewards data from Aave API
|
|
54
54
|
*/
|
|
55
55
|
const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
var _a;
|
|
57
56
|
try {
|
|
58
57
|
const response = yield fetch('https://apps.aavechan.com/api/merit/aprs', {
|
|
59
58
|
signal: AbortSignal.timeout(5000),
|
|
60
59
|
});
|
|
61
|
-
if (!response.ok)
|
|
62
|
-
throw new Error('Failed to fetch Merit rewards data');
|
|
63
60
|
const data = yield response.json();
|
|
64
|
-
return
|
|
61
|
+
return data.currentAPR.actionsAPR;
|
|
65
62
|
}
|
|
66
63
|
catch (error) {
|
|
67
64
|
console.error('External API Failure: Failed to fetch merit rewards data:', error);
|
|
@@ -71,7 +68,6 @@ const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
71
68
|
exports.fetchMeritRewardsData = fetchMeritRewardsData;
|
|
72
69
|
const getMeritCampaigns = (chainId, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
70
|
var _a;
|
|
74
|
-
console.log('Fetching Merit campaigns');
|
|
75
71
|
const meritData = yield (0, exports.fetchMeritRewardsData)();
|
|
76
72
|
const relevantCampaigns = {
|
|
77
73
|
supply: {},
|
package/cjs/aaveV3/merkl.js
CHANGED
|
@@ -39,7 +39,6 @@ const formatAaveAsset = (_symbol) => {
|
|
|
39
39
|
};
|
|
40
40
|
exports.formatAaveAsset = formatAaveAsset;
|
|
41
41
|
const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
console.log('Fetching Merkle campaigns');
|
|
43
42
|
try {
|
|
44
43
|
const res = yield fetch('https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave', {
|
|
45
44
|
signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT),
|
|
@@ -118,7 +118,7 @@ exports.MORPHO_VAULT_STEAKHOUSE_ETH = {
|
|
|
118
118
|
exports.MORPHO_VAULT_STEAKHOUSE_PYUSD = {
|
|
119
119
|
type: types_1.MorphoVaultType.MorphoVaultSteakhousePYUSD,
|
|
120
120
|
name: 'Steakhouse PYUSD',
|
|
121
|
-
address: '
|
|
121
|
+
address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
|
|
122
122
|
asset: 'PYUSD',
|
|
123
123
|
deploymentBlock: 19043398,
|
|
124
124
|
isLegacy: false,
|
package/cjs/staking/staking.js
CHANGED
|
@@ -168,17 +168,19 @@ const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
168
168
|
const rate = assetData.supplyRate;
|
|
169
169
|
const supplyInterest = (0, exports.calculateInterestEarned)(amount, rate, 'year', true);
|
|
170
170
|
acc.supplyInterest = new decimal_js_1.default(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
171
|
+
if (assetData.supplyIncentives) {
|
|
172
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
173
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
174
|
+
const eligibilityCheck = eligibilityId ? eligibility_1.EligibilityMapping[eligibilityId] : null;
|
|
175
|
+
if (eligibilityCheck) {
|
|
176
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
177
|
+
const incentiveInterest = isEligible ? (0, exports.calculateInterestEarned)(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
178
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const incentiveInterest = (0, exports.calculateInterestEarned)(amount, apy, 'year', true);
|
|
182
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
183
|
+
}
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
186
|
}
|
|
@@ -188,17 +190,19 @@ const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
188
190
|
const rate = assetData.borrowRate;
|
|
189
191
|
const borrowInterest = (0, exports.calculateInterestEarned)(amount, rate, 'year', true);
|
|
190
192
|
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
193
|
+
if (assetData.borrowIncentives) {
|
|
194
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
195
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
196
|
+
const eligibilityCheck = eligibilityId ? eligibility_1.EligibilityMapping[eligibilityId] : null;
|
|
197
|
+
if (eligibilityCheck) {
|
|
198
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
199
|
+
const incentiveInterest = isEligible ? (0, exports.calculateInterestEarned)(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
200
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const incentiveInterest = (0, exports.calculateInterestEarned)(amount, apy, 'year', true);
|
|
204
|
+
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
205
|
+
}
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
}
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -48,7 +48,6 @@ export const aaveV3EmodeCategoriesMapping = (extractedState, usedAssets) => {
|
|
|
48
48
|
export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
49
49
|
return __awaiter(this, arguments, void 0, function* (provider, network, market, blockNumber = 'latest') {
|
|
50
50
|
const _addresses = market.assets.map(a => getAssetInfo(getWrappedNativeAssetFromUnwrapped(a), network).address);
|
|
51
|
-
console.log('Fetched addresses');
|
|
52
51
|
const isL2 = isLayer2Network(network);
|
|
53
52
|
const loanInfoContract = AaveV3ViewContractViem(provider, network);
|
|
54
53
|
const aaveIncentivesContract = AaveIncentiveDataProviderV3ContractViem(provider, network);
|
|
@@ -63,7 +62,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
63
62
|
getMerkleCampaigns(network),
|
|
64
63
|
getMeritCampaigns(network, market.value),
|
|
65
64
|
]);
|
|
66
|
-
console.log('Fetched tokens, emodes, campaigns, incentives');
|
|
67
65
|
isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
|
|
68
66
|
const eModeCategoriesData = {};
|
|
69
67
|
for (let i = 0; i < eModesInfo.length; i++) {
|
|
@@ -81,7 +79,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
81
79
|
collateralAssets: [],
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
|
-
console.log('Parsed e modes info');
|
|
85
82
|
if (networksWithIncentives.includes(network) && rewardInfo) {
|
|
86
83
|
rewardInfo = rewardInfo.reduce((all, _market) => {
|
|
87
84
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -89,7 +86,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
89
86
|
return all;
|
|
90
87
|
}, {});
|
|
91
88
|
}
|
|
92
|
-
console.log('Parsed reward info');
|
|
93
89
|
const assetsData = yield Promise.all(loanInfo
|
|
94
90
|
.map((tokenMarket, i) => __awaiter(this, void 0, void 0, function* () {
|
|
95
91
|
const symbol = market.assets[i];
|
|
@@ -151,7 +147,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
151
147
|
borrowIncentives: [],
|
|
152
148
|
});
|
|
153
149
|
})));
|
|
154
|
-
console.log('Parsed assets data');
|
|
155
150
|
// Get incentives data
|
|
156
151
|
yield Promise.all(assetsData.map((_market, index) => __awaiter(this, void 0, void 0, function* () {
|
|
157
152
|
var _a, _b;
|
|
@@ -159,10 +154,8 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
159
154
|
// @ts-ignore
|
|
160
155
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
161
156
|
const isStakingAsset = STAKING_ASSETS.includes(_market.symbol);
|
|
162
|
-
console.log('Processing market', _market.symbol);
|
|
163
157
|
if (isStakingAsset) {
|
|
164
158
|
const yieldApy = yield getStakingApy(_market.symbol, network);
|
|
165
|
-
console.log('Got yield apy', yieldApy);
|
|
166
159
|
_market.supplyIncentives.push({
|
|
167
160
|
apy: yieldApy,
|
|
168
161
|
token: _market.symbol,
|
|
@@ -190,7 +183,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
190
183
|
eligibilityId: identifier,
|
|
191
184
|
});
|
|
192
185
|
}
|
|
193
|
-
console.log('Processed merkle a incentives');
|
|
194
186
|
const vTokenAddress = _market.vTokenAddress.toLowerCase(); // DEV: Should vTokenAddress be in AaveV3AssetData type?
|
|
195
187
|
if ((_b = merkleRewardsMap[vTokenAddress]) === null || _b === void 0 ? void 0 : _b.borrow) {
|
|
196
188
|
const { apy, rewardTokenSymbol, description, identifier, } = merkleRewardsMap[vTokenAddress].borrow;
|
|
@@ -202,7 +194,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
202
194
|
eligibilityId: identifier,
|
|
203
195
|
});
|
|
204
196
|
}
|
|
205
|
-
console.log('Processed merkle v incentives');
|
|
206
197
|
if (meritRewardsMap.supply[_market.symbol]) {
|
|
207
198
|
const { apy, rewardTokenSymbol, description } = meritRewardsMap.supply[_market.symbol];
|
|
208
199
|
_market.supplyIncentives.push({
|
|
@@ -212,7 +203,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
212
203
|
description,
|
|
213
204
|
});
|
|
214
205
|
}
|
|
215
|
-
console.log('Processed merit supply incentives');
|
|
216
206
|
if (meritRewardsMap.borrow[_market.symbol]) {
|
|
217
207
|
const { apy, rewardTokenSymbol, description } = meritRewardsMap.borrow[_market.symbol];
|
|
218
208
|
_market.borrowIncentives.push({
|
|
@@ -222,10 +212,8 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
222
212
|
description,
|
|
223
213
|
});
|
|
224
214
|
}
|
|
225
|
-
console.log('Processed merit borrow incentives');
|
|
226
215
|
if (!rewardForMarket)
|
|
227
216
|
return;
|
|
228
|
-
console.log('Reward for market', rewardForMarket);
|
|
229
217
|
// @ts-ignore
|
|
230
218
|
rewardForMarket.aIncentiveData.rewardsTokenInformation.forEach(supplyRewardData => {
|
|
231
219
|
if (supplyRewardData) {
|
|
@@ -292,7 +280,6 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
292
280
|
collateralAssets: assetsData.map((a) => a.symbol),
|
|
293
281
|
borrowAssets: assetsData.map((a) => a.symbol),
|
|
294
282
|
};
|
|
295
|
-
console.log('Parsed payload');
|
|
296
283
|
return { assetsData: payload, eModeCategoriesData };
|
|
297
284
|
});
|
|
298
285
|
}
|
package/esm/aaveV3/merit.js
CHANGED
|
@@ -50,15 +50,12 @@ const MERIT_DATA_MAP = {
|
|
|
50
50
|
* Fetches merit rewards data from Aave API
|
|
51
51
|
*/
|
|
52
52
|
export const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
var _a;
|
|
54
53
|
try {
|
|
55
54
|
const response = yield fetch('https://apps.aavechan.com/api/merit/aprs', {
|
|
56
55
|
signal: AbortSignal.timeout(5000),
|
|
57
56
|
});
|
|
58
|
-
if (!response.ok)
|
|
59
|
-
throw new Error('Failed to fetch Merit rewards data');
|
|
60
57
|
const data = yield response.json();
|
|
61
|
-
return
|
|
58
|
+
return data.currentAPR.actionsAPR;
|
|
62
59
|
}
|
|
63
60
|
catch (error) {
|
|
64
61
|
console.error('External API Failure: Failed to fetch merit rewards data:', error);
|
|
@@ -67,7 +64,6 @@ export const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, fun
|
|
|
67
64
|
});
|
|
68
65
|
export const getMeritCampaigns = (chainId, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
66
|
var _a;
|
|
70
|
-
console.log('Fetching Merit campaigns');
|
|
71
67
|
const meritData = yield fetchMeritRewardsData();
|
|
72
68
|
const relevantCampaigns = {
|
|
73
69
|
supply: {},
|
package/esm/aaveV3/merkl.js
CHANGED
|
@@ -34,7 +34,6 @@ export const formatAaveAsset = (_symbol) => {
|
|
|
34
34
|
return _symbol;
|
|
35
35
|
};
|
|
36
36
|
export const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
console.log('Fetching Merkle campaigns');
|
|
38
37
|
try {
|
|
39
38
|
const res = yield fetch('https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave', {
|
|
40
39
|
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
@@ -115,7 +115,7 @@ export const MORPHO_VAULT_STEAKHOUSE_ETH = {
|
|
|
115
115
|
export const MORPHO_VAULT_STEAKHOUSE_PYUSD = {
|
|
116
116
|
type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
|
|
117
117
|
name: 'Steakhouse PYUSD',
|
|
118
|
-
address: '
|
|
118
|
+
address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
|
|
119
119
|
asset: 'PYUSD',
|
|
120
120
|
deploymentBlock: 19043398,
|
|
121
121
|
isLegacy: false,
|
package/esm/staking/staking.js
CHANGED
|
@@ -161,17 +161,19 @@ export const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
161
161
|
const rate = assetData.supplyRate;
|
|
162
162
|
const supplyInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
163
163
|
acc.supplyInterest = new Dec(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
if (assetData.supplyIncentives) {
|
|
165
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
166
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
167
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
168
|
+
if (eligibilityCheck) {
|
|
169
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
170
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
171
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
175
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
176
|
+
}
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
}
|
|
@@ -181,17 +183,19 @@ export const calculateNetApy = ({ usedAssets, assetsData, optionalData, }) => {
|
|
|
181
183
|
const rate = assetData.borrowRate;
|
|
182
184
|
const borrowInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
183
185
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
if (assetData.borrowIncentives) {
|
|
187
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
188
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
189
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
190
|
+
if (eligibilityCheck) {
|
|
191
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
192
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
193
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
197
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
198
|
+
}
|
|
195
199
|
}
|
|
196
200
|
}
|
|
197
201
|
}
|
package/package.json
CHANGED
package/src/aaveV3/index.ts
CHANGED
|
@@ -79,7 +79,6 @@ export const aaveV3EmodeCategoriesMapping = (extractedState: any, usedAssets: Aa
|
|
|
79
79
|
export async function _getAaveV3MarketData(provider: Client, network: NetworkNumber, market: AaveMarketInfo, blockNumber: 'latest' | number = 'latest'): Promise<AaveV3MarketData> {
|
|
80
80
|
const _addresses = market.assets.map(a => getAssetInfo(getWrappedNativeAssetFromUnwrapped(a), network).address);
|
|
81
81
|
|
|
82
|
-
console.log('Fetched addresses');
|
|
83
82
|
const isL2 = isLayer2Network(network);
|
|
84
83
|
const loanInfoContract = AaveV3ViewContractViem(provider, network);
|
|
85
84
|
const aaveIncentivesContract = AaveIncentiveDataProviderV3ContractViem(provider, network);
|
|
@@ -95,8 +94,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
95
94
|
getMerkleCampaigns(network),
|
|
96
95
|
getMeritCampaigns(network, market.value),
|
|
97
96
|
]);
|
|
98
|
-
console.log('Fetched tokens, emodes, campaigns, incentives');
|
|
99
|
-
|
|
100
97
|
isBorrowAllowed = isLayer2Network(network) ? isBorrowAllowed : true;
|
|
101
98
|
|
|
102
99
|
const eModeCategoriesData: EModeCategoriesData = {};
|
|
@@ -115,7 +112,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
115
112
|
};
|
|
116
113
|
}
|
|
117
114
|
|
|
118
|
-
console.log('Parsed e modes info');
|
|
119
115
|
if (networksWithIncentives.includes(network) && rewardInfo) {
|
|
120
116
|
rewardInfo = rewardInfo.reduce((all: any, _market: any) => {
|
|
121
117
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -124,7 +120,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
124
120
|
}, {});
|
|
125
121
|
}
|
|
126
122
|
|
|
127
|
-
console.log('Parsed reward info');
|
|
128
123
|
const assetsData: AaveV3AssetData[] = await Promise.all(loanInfo
|
|
129
124
|
.map(async (tokenMarket, i) => {
|
|
130
125
|
const symbol = market.assets[i];
|
|
@@ -189,17 +184,16 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
189
184
|
});
|
|
190
185
|
}),
|
|
191
186
|
);
|
|
192
|
-
|
|
187
|
+
|
|
193
188
|
// Get incentives data
|
|
194
189
|
await Promise.all(assetsData.map(async (_market: AaveV3AssetData, index) => {
|
|
195
190
|
/* eslint-disable no-param-reassign */
|
|
196
191
|
// @ts-ignore
|
|
197
192
|
const rewardForMarket = rewardInfo?.[_market.underlyingTokenAddress];
|
|
198
193
|
const isStakingAsset = STAKING_ASSETS.includes(_market.symbol);
|
|
199
|
-
|
|
194
|
+
|
|
200
195
|
if (isStakingAsset) {
|
|
201
196
|
const yieldApy = await getStakingApy(_market.symbol, network as NetworkNumber);
|
|
202
|
-
console.log('Got yield apy', yieldApy);
|
|
203
197
|
_market.supplyIncentives.push({
|
|
204
198
|
apy: yieldApy,
|
|
205
199
|
token: _market.symbol,
|
|
@@ -230,7 +224,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
230
224
|
eligibilityId: identifier as IncentiveEligibilityId,
|
|
231
225
|
});
|
|
232
226
|
}
|
|
233
|
-
console.log('Processed merkle a incentives');
|
|
234
227
|
|
|
235
228
|
const vTokenAddress = (_market as any).vTokenAddress.toLowerCase(); // DEV: Should vTokenAddress be in AaveV3AssetData type?
|
|
236
229
|
if (merkleRewardsMap[vTokenAddress]?.borrow) {
|
|
@@ -245,7 +238,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
245
238
|
eligibilityId: identifier as IncentiveEligibilityId,
|
|
246
239
|
});
|
|
247
240
|
}
|
|
248
|
-
console.log('Processed merkle v incentives');
|
|
249
241
|
|
|
250
242
|
if (meritRewardsMap.supply[_market.symbol]) {
|
|
251
243
|
const { apy, rewardTokenSymbol, description } = meritRewardsMap.supply[_market.symbol];
|
|
@@ -256,7 +248,7 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
256
248
|
description,
|
|
257
249
|
});
|
|
258
250
|
}
|
|
259
|
-
|
|
251
|
+
|
|
260
252
|
if (meritRewardsMap.borrow[_market.symbol]) {
|
|
261
253
|
const { apy, rewardTokenSymbol, description } = meritRewardsMap.borrow[_market.symbol];
|
|
262
254
|
_market.borrowIncentives.push({
|
|
@@ -266,9 +258,8 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
266
258
|
description,
|
|
267
259
|
});
|
|
268
260
|
}
|
|
269
|
-
|
|
261
|
+
|
|
270
262
|
if (!rewardForMarket) return;
|
|
271
|
-
console.log('Reward for market', rewardForMarket);
|
|
272
263
|
// @ts-ignore
|
|
273
264
|
rewardForMarket.aIncentiveData.rewardsTokenInformation.forEach(supplyRewardData => {
|
|
274
265
|
if (supplyRewardData) {
|
|
@@ -337,7 +328,6 @@ export async function _getAaveV3MarketData(provider: Client, network: NetworkNum
|
|
|
337
328
|
borrowAssets: assetsData.map((a) => a.symbol),
|
|
338
329
|
};
|
|
339
330
|
|
|
340
|
-
console.log('Parsed payload');
|
|
341
331
|
return { assetsData: payload, eModeCategoriesData };
|
|
342
332
|
}
|
|
343
333
|
|
package/src/aaveV3/merit.ts
CHANGED
|
@@ -62,9 +62,8 @@ export const fetchMeritRewardsData = async (): Promise<Record<string, number | n
|
|
|
62
62
|
const response = await fetch('https://apps.aavechan.com/api/merit/aprs', {
|
|
63
63
|
signal: AbortSignal.timeout(5000),
|
|
64
64
|
});
|
|
65
|
-
if (!response.ok) throw new Error('Failed to fetch Merit rewards data');
|
|
66
65
|
const data = await response.json();
|
|
67
|
-
return
|
|
66
|
+
return data.currentAPR.actionsAPR as Record<string, number | null>;
|
|
68
67
|
} catch (error) {
|
|
69
68
|
console.error('External API Failure: Failed to fetch merit rewards data:', error);
|
|
70
69
|
return {};
|
|
@@ -72,7 +71,6 @@ export const fetchMeritRewardsData = async (): Promise<Record<string, number | n
|
|
|
72
71
|
};
|
|
73
72
|
|
|
74
73
|
export const getMeritCampaigns = async (chainId: NetworkNumber, market: AaveVersions): Promise<MeritTokenRewardMap> => {
|
|
75
|
-
console.log('Fetching Merit campaigns');
|
|
76
74
|
const meritData = await fetchMeritRewardsData();
|
|
77
75
|
const relevantCampaigns = {
|
|
78
76
|
supply: {},
|
package/src/aaveV3/merkl.ts
CHANGED
|
@@ -30,7 +30,6 @@ export const formatAaveAsset = (_symbol: string) => {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const getMerkleCampaigns = async (chainId: NetworkNumber): Promise<MerkleRewardMap> => {
|
|
33
|
-
console.log('Fetching Merkle campaigns');
|
|
34
33
|
try {
|
|
35
34
|
const res = await fetch('https://api.merkl.xyz/v4/opportunities?mainProtocolId=aave', {
|
|
36
35
|
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
@@ -131,7 +131,7 @@ export const MORPHO_VAULT_STEAKHOUSE_ETH: MorphoVault = {
|
|
|
131
131
|
export const MORPHO_VAULT_STEAKHOUSE_PYUSD: MorphoVault = {
|
|
132
132
|
type: MorphoVaultType.MorphoVaultSteakhousePYUSD,
|
|
133
133
|
name: 'Steakhouse PYUSD',
|
|
134
|
-
address: '
|
|
134
|
+
address: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
|
|
135
135
|
asset: 'PYUSD',
|
|
136
136
|
deploymentBlock: 19043398,
|
|
137
137
|
isLegacy: false,
|
package/src/staking/staking.ts
CHANGED
|
@@ -135,16 +135,18 @@ export const calculateNetApy = ({
|
|
|
135
135
|
const supplyInterest = calculateInterestEarned(amount, rate as string, 'year', true);
|
|
136
136
|
acc.supplyInterest = new Dec(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
if (assetData.supplyIncentives) {
|
|
139
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
140
|
+
const { apy, eligibilityId } = supplyIncentive;
|
|
141
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
142
|
+
if (eligibilityCheck) {
|
|
143
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
144
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
145
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
146
|
+
} else {
|
|
147
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
148
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
149
|
+
}
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
}
|
|
@@ -156,16 +158,18 @@ export const calculateNetApy = ({
|
|
|
156
158
|
const borrowInterest = calculateInterestEarned(amount, rate as string, 'year', true);
|
|
157
159
|
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
158
160
|
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
if (assetData.borrowIncentives) {
|
|
162
|
+
for (const borrowIncentive of assetData.borrowIncentives) {
|
|
163
|
+
const { apy, eligibilityId } = borrowIncentive;
|
|
164
|
+
const eligibilityCheck = eligibilityId ? EligibilityMapping[eligibilityId] : null;
|
|
165
|
+
if (eligibilityCheck) {
|
|
166
|
+
const { isEligible, eligibleUSDAmount } = eligibilityCheck(usedAssets, optionalData);
|
|
167
|
+
const incentiveInterest = isEligible ? calculateInterestEarned(eligibleUSDAmount, apy, 'year', true) : '0';
|
|
168
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
169
|
+
} else {
|
|
170
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
171
|
+
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
}
|