@defisaver/positions-sdk 2.1.98 → 2.1.102-aave-v4-merkl-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 +1 -0
- package/cjs/aaveV4/index.js +10 -2
- package/cjs/aaveV4/merkl.d.ts +8 -0
- package/cjs/aaveV4/merkl.js +90 -0
- package/cjs/claiming/ethena.js +1 -1
- package/cjs/config/contracts.d.ts +61 -1
- package/cjs/config/contracts.js +2 -2
- package/cjs/contracts.d.ts +2963 -82
- package/cjs/helpers/aaveV4Helpers/index.d.ts +11 -5
- package/cjs/helpers/aaveV4Helpers/index.js +58 -19
- package/cjs/types/aaveV4.d.ts +12 -0
- package/cjs/types/merkl.d.ts +14 -1
- package/esm/aaveV4/index.d.ts +1 -0
- package/esm/aaveV4/index.js +8 -1
- package/esm/aaveV4/merkl.d.ts +8 -0
- package/esm/aaveV4/merkl.js +85 -0
- package/esm/claiming/ethena.js +1 -1
- package/esm/config/contracts.d.ts +61 -1
- package/esm/config/contracts.js +2 -2
- package/esm/contracts.d.ts +2963 -82
- package/esm/helpers/aaveV4Helpers/index.d.ts +11 -5
- package/esm/helpers/aaveV4Helpers/index.js +56 -17
- package/esm/types/aaveV4.d.ts +12 -0
- package/esm/types/merkl.d.ts +14 -1
- package/package.json +1 -1
- package/src/aaveV4/index.ts +9 -1
- package/src/aaveV4/merkl.ts +92 -0
- package/src/claiming/ethena.ts +1 -2
- package/src/config/contracts.ts +2 -2
- package/src/helpers/aaveV4Helpers/index.ts +59 -26
- package/src/types/aaveV4.ts +12 -0
- package/src/types/merkl.ts +14 -2
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, LeverageType, NetworkNumber } from '../../types';
|
|
1
|
+
import { AaveV4AggregatedPositionData, AaveV4AssetsData, AaveV4ReserveAssetData, AaveV4SpokeInfo, AaveV4UsedReserveAsset, AaveV4UsedReserveAssets, EthereumProvider, LeverageType, NetworkNumber } from '../../types';
|
|
2
2
|
export declare const calcUserRiskPremiumBps: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => number;
|
|
3
|
-
export declare const getApyAfterValuesEstimation: (usedAssets: AaveV4UsedReserveAssets, assetsData: AaveV4AssetsData) => Record<string, {
|
|
4
|
-
borrowRate: string;
|
|
5
|
-
supplyRate: string;
|
|
6
|
-
}>;
|
|
7
3
|
export declare const calculateNetApyAaveV4: ({ usedAssets, assetsData, }: {
|
|
8
4
|
usedAssets: AaveV4UsedReserveAssets;
|
|
9
5
|
assetsData: AaveV4AssetsData;
|
|
@@ -23,3 +19,13 @@ export declare const aaveV4GetAggregatedPositionData: ({ usedAssets, assetsData,
|
|
|
23
19
|
network: NetworkNumber;
|
|
24
20
|
useUserCollateralFactor?: boolean;
|
|
25
21
|
}) => AaveV4AggregatedPositionData;
|
|
22
|
+
export declare const getAaveV4ApyAfterValuesEstimation: (selectedSpoke: AaveV4SpokeInfo, assetsData: AaveV4AssetsData, actions: {
|
|
23
|
+
action: string;
|
|
24
|
+
amount: string;
|
|
25
|
+
asset: string;
|
|
26
|
+
}[], provider: EthereumProvider, network: NetworkNumber) => Promise<{
|
|
27
|
+
[key: string]: {
|
|
28
|
+
supplyRate: string;
|
|
29
|
+
borrowRate: string;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
5
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
15
|
+
exports.getAaveV4ApyAfterValuesEstimation = exports.aaveV4GetAggregatedPositionData = exports.isLeveragedPosAaveV4 = exports.aaveV4GetCollateralFactor = exports.calculateNetApyAaveV4 = exports.calcUserRiskPremiumBps = void 0;
|
|
7
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
8
18
|
const moneymarket_1 = require("../../moneymarket");
|
|
9
19
|
const staking_1 = require("../../staking");
|
|
10
20
|
const types_1 = require("../../types");
|
|
21
|
+
const constants_1 = require("../../constants");
|
|
22
|
+
const contracts_1 = require("../../contracts");
|
|
23
|
+
const viem_1 = require("../../services/viem");
|
|
11
24
|
const calcUserRiskPremiumBps = (usedAssets, assetsData) => {
|
|
12
25
|
const collaterals = [];
|
|
13
26
|
const debts = [];
|
|
@@ -61,24 +74,6 @@ const calcUserRiskPremiumBps = (usedAssets, assetsData) => {
|
|
|
61
74
|
return riskPremiumBps.toNumber();
|
|
62
75
|
};
|
|
63
76
|
exports.calcUserRiskPremiumBps = calcUserRiskPremiumBps;
|
|
64
|
-
const getApyAfterValuesEstimation = (usedAssets, assetsData) => {
|
|
65
|
-
const riskPremiumBps = (0, exports.calcUserRiskPremiumBps)(usedAssets, assetsData);
|
|
66
|
-
const riskPremiumFraction = new decimal_js_1.default(riskPremiumBps).div(10000); // bps to fraction
|
|
67
|
-
const result = {};
|
|
68
|
-
Object.entries(assetsData).forEach(([identifier, assetData]) => {
|
|
69
|
-
const drawnRate = new decimal_js_1.default(assetData.drawnRate);
|
|
70
|
-
const baseBorrowApr = drawnRate.mul(100);
|
|
71
|
-
// finalBorrowRate = baseBorrowRate * (1 + riskPremiumFraction)
|
|
72
|
-
const userBorrowApr = baseBorrowApr.mul(new decimal_js_1.default(1).add(riskPremiumFraction));
|
|
73
|
-
result[identifier] = {
|
|
74
|
-
borrowRate: (0, moneymarket_1.aprToApy)(userBorrowApr.toString()),
|
|
75
|
-
// Supply rate is market-level (not user-specific), use existing value
|
|
76
|
-
supplyRate: assetData.supplyRate,
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
return result;
|
|
80
|
-
};
|
|
81
|
-
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
82
77
|
const calculateNetApyAaveV4 = ({ usedAssets, assetsData, }) => {
|
|
83
78
|
const riskPremiumBps = (0, exports.calcUserRiskPremiumBps)(usedAssets, assetsData);
|
|
84
79
|
const riskPremiumFraction = new decimal_js_1.default(riskPremiumBps).div(10000);
|
|
@@ -231,3 +226,47 @@ const aaveV4GetAggregatedPositionData = ({ usedAssets, assetsData, network, useU
|
|
|
231
226
|
return payload;
|
|
232
227
|
};
|
|
233
228
|
exports.aaveV4GetAggregatedPositionData = aaveV4GetAggregatedPositionData;
|
|
229
|
+
const getAaveV4ApyAfterValuesEstimationInner = (selectedSpoke, assetsData, actions, client, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
230
|
+
const params = actions.map(({ action, asset, amount }) => {
|
|
231
|
+
const isDebtAsset = constants_1.borrowOperations.includes(action);
|
|
232
|
+
const assetData = assetsData[asset];
|
|
233
|
+
const amountInWei = (0, tokens_1.assetAmountInWei)(amount, assetData.symbol);
|
|
234
|
+
let liquidityAdded;
|
|
235
|
+
let liquidityTaken;
|
|
236
|
+
if (isDebtAsset) {
|
|
237
|
+
liquidityAdded = action === 'payback' ? amountInWei : '0';
|
|
238
|
+
liquidityTaken = action === 'borrow' ? amountInWei : '0';
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
liquidityAdded = action === 'collateral' ? amountInWei : '0';
|
|
242
|
+
liquidityTaken = action === 'withdraw' ? amountInWei : '0';
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
reserveId: BigInt(assetData.reserveId),
|
|
246
|
+
liquidityAdded: BigInt(liquidityAdded),
|
|
247
|
+
liquidityTaken: BigInt(liquidityTaken),
|
|
248
|
+
isDebtAsset,
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
const viewContract = (0, contracts_1.AaveV4ViewContractViem)(client, network);
|
|
252
|
+
const data = yield viewContract.read.getApyAfterValuesEstimation([selectedSpoke.address, params]);
|
|
253
|
+
const rates = {};
|
|
254
|
+
data.forEach((item) => {
|
|
255
|
+
const { hubDrawnRateEstimation, hubTotalDrawnEstimation, hubTotalLiquidityEstimation, hubSwept, reserveId, } = item;
|
|
256
|
+
const drawnRate = new decimal_js_1.default(hubDrawnRateEstimation.toString()).div(new decimal_js_1.default(10).pow(27));
|
|
257
|
+
const borrowApr = drawnRate.mul(100);
|
|
258
|
+
const assetData = Object.values(assetsData).find(({ reserveId: rId }) => rId === Number(reserveId));
|
|
259
|
+
const totalDrawn = new decimal_js_1.default(hubTotalDrawnEstimation.toString());
|
|
260
|
+
const swept = new decimal_js_1.default(hubSwept.toString());
|
|
261
|
+
const hubUtilizationDenominator = totalDrawn.add(swept).add(hubTotalLiquidityEstimation.toString());
|
|
262
|
+
const hubUtilization = hubUtilizationDenominator.isZero() ? new decimal_js_1.default(0) : totalDrawn.div(hubUtilizationDenominator);
|
|
263
|
+
const supplyApr = borrowApr.mul(hubUtilization).mul((assetData === null || assetData === void 0 ? void 0 : assetData.premiumMultiplier) || '1').mul(new decimal_js_1.default(1).minus((assetData === null || assetData === void 0 ? void 0 : assetData.liquidityFee) || '0'));
|
|
264
|
+
rates[`${assetData === null || assetData === void 0 ? void 0 : assetData.symbol}-${assetData === null || assetData === void 0 ? void 0 : assetData.reserveId}`] = {
|
|
265
|
+
borrowRate: (0, moneymarket_1.aprToApy)(borrowApr.toString()),
|
|
266
|
+
supplyRate: (0, moneymarket_1.aprToApy)(supplyApr.toString()),
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
return rates;
|
|
270
|
+
});
|
|
271
|
+
const getAaveV4ApyAfterValuesEstimation = (selectedSpoke, assetsData, actions, provider, network) => __awaiter(void 0, void 0, void 0, function* () { return getAaveV4ApyAfterValuesEstimationInner(selectedSpoke, assetsData, actions, (0, viem_1.getViemProvider)(provider, network), network); });
|
|
272
|
+
exports.getAaveV4ApyAfterValuesEstimation = getAaveV4ApyAfterValuesEstimation;
|
package/cjs/types/aaveV4.d.ts
CHANGED
|
@@ -100,6 +100,16 @@ export interface AaveV4ReserveAssetData {
|
|
|
100
100
|
borrowRate: string;
|
|
101
101
|
supplyIncentives: IncentiveData[];
|
|
102
102
|
borrowIncentives: IncentiveData[];
|
|
103
|
+
/**
|
|
104
|
+
* Intrinsic incentives pre-combined with scope-specific Merkl rewards, ready to render per surface:
|
|
105
|
+
* - spoke* → spoke supply/borrow (Create page + dashboard market table)
|
|
106
|
+
* - hub* → hub supply/borrow (Lend page)
|
|
107
|
+
* `supplyIncentives`/`borrowIncentives` above remain intrinsic-only so the net-APY calc is unaffected.
|
|
108
|
+
*/
|
|
109
|
+
spokeSupplyIncentives?: IncentiveData[];
|
|
110
|
+
spokeBorrowIncentives?: IncentiveData[];
|
|
111
|
+
hubSupplyIncentives?: IncentiveData[];
|
|
112
|
+
hubBorrowIncentives?: IncentiveData[];
|
|
103
113
|
canBeBorrowed: boolean;
|
|
104
114
|
canBeSupplied: boolean;
|
|
105
115
|
canBeWithdrawn: boolean;
|
|
@@ -107,6 +117,8 @@ export interface AaveV4ReserveAssetData {
|
|
|
107
117
|
utilization: string;
|
|
108
118
|
/** Hub `liquidity` for this assetId (underlying amount), used for pool-level borrow/withdraw limits */
|
|
109
119
|
hubLiquidity: string;
|
|
120
|
+
premiumMultiplier: string;
|
|
121
|
+
liquidityFee: string;
|
|
110
122
|
}
|
|
111
123
|
export type AaveV4AssetsData = Record<string, AaveV4ReserveAssetData>;
|
|
112
124
|
export interface AaveV4UsedReserveAsset {
|
package/cjs/types/merkl.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData } from './common';
|
|
2
2
|
export declare enum OpportunityAction {
|
|
3
3
|
LEND = "LEND",
|
|
4
4
|
BORROW = "BORROW"
|
|
@@ -73,3 +73,16 @@ export type MerkleRewardMap = Record<EthAddress, {
|
|
|
73
73
|
supply?: MerkleRewardInfo;
|
|
74
74
|
borrow?: MerkleRewardInfo;
|
|
75
75
|
}>;
|
|
76
|
+
export type AaveV4MerklScopedReward = {
|
|
77
|
+
supply?: IncentiveData;
|
|
78
|
+
borrow?: IncentiveData;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Aave V4 Merkl reward campaigns split by scope:
|
|
82
|
+
* - `hub`: keyed by underlying token address (lowercase) — rewards for supplying to a hub
|
|
83
|
+
* - `spoke`: keyed by `${spokeAddress}_${underlyingAddress}` (both lowercase) — rewards for supplying/borrowing on a spoke
|
|
84
|
+
*/
|
|
85
|
+
export type AaveV4MerklRewardMap = {
|
|
86
|
+
hub: Record<string, AaveV4MerklScopedReward>;
|
|
87
|
+
spoke: Record<string, AaveV4MerklScopedReward>;
|
|
88
|
+
};
|
package/esm/aaveV4/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
2
|
import { AaveV4AccountData, AaveV4SpokeData, AaveV4SpokeInfo, EthAddress, EthereumProvider, NetworkNumber } from '../types';
|
|
3
3
|
export * as lend from './lend';
|
|
4
|
+
export { getAaveV4MerkleCampaigns } from './merkl';
|
|
4
5
|
export declare function _getAaveV4SpokeData(provider: Client, network: NetworkNumber, market: AaveV4SpokeInfo, blockNumber?: 'latest' | number): Promise<AaveV4SpokeData>;
|
|
5
6
|
export declare function getAaveV4SpokeData(provider: EthereumProvider, network: NetworkNumber, spoke: AaveV4SpokeInfo, blockNumber?: 'latest' | number): Promise<AaveV4SpokeData>;
|
|
6
7
|
export declare function _getAaveV4AccountData(provider: Client, network: NetworkNumber, spokeData: AaveV4SpokeData, address: EthAddress, blockNumber?: 'latest' | number): Promise<AaveV4AccountData>;
|
package/esm/aaveV4/index.js
CHANGED
|
@@ -17,7 +17,9 @@ import { isMaxUint, wethToEth } from '../services/utils';
|
|
|
17
17
|
import { aaveV4GetAggregatedPositionData, calcUserRiskPremiumBps } from '../helpers/aaveV4Helpers';
|
|
18
18
|
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
19
19
|
import { aprToApy } from '../moneymarket';
|
|
20
|
+
import { attachAaveV4MerklIncentives, getAaveV4MerkleCampaigns } from './merkl';
|
|
20
21
|
export * as lend from './lend';
|
|
22
|
+
export { getAaveV4MerkleCampaigns } from './merkl';
|
|
21
23
|
const fetchHubData = (viewContract, hubAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
24
|
const hubData = yield viewContract.read.getHubAllAssetsData([hubAddress]);
|
|
23
25
|
return {
|
|
@@ -121,12 +123,15 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
121
123
|
canBePayBacked: reserveAsset.spokeActive && !reserveAsset.spokeHalted && !reserveAsset.paused,
|
|
122
124
|
utilization,
|
|
123
125
|
hubLiquidity,
|
|
126
|
+
premiumMultiplier: premiumMultiplier.toString(),
|
|
127
|
+
liquidityFee: liquidityFee.toString(),
|
|
124
128
|
});
|
|
125
129
|
});
|
|
126
130
|
export function _getAaveV4SpokeData(provider_1, network_1, market_1) {
|
|
127
131
|
return __awaiter(this, arguments, void 0, function* (provider, network, market, blockNumber = 'latest') {
|
|
128
132
|
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
129
133
|
const hubsData = {};
|
|
134
|
+
const merklCampaignsPromise = getAaveV4MerkleCampaigns(network);
|
|
130
135
|
const [spokeData] = yield Promise.all([
|
|
131
136
|
viewContract.read.getSpokeDataFull([market.address]),
|
|
132
137
|
...market.hubs.map((hubAddress) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -134,8 +139,10 @@ export function _getAaveV4SpokeData(provider_1, network_1, market_1) {
|
|
|
134
139
|
})),
|
|
135
140
|
]);
|
|
136
141
|
const reserveAssetsArray = yield Promise.all(spokeData[1].map((reserveAssetOnChain, index) => __awaiter(this, void 0, void 0, function* () { return formatReserveAsset(reserveAssetOnChain, hubsData[reserveAssetOnChain.hub].assets[reserveAssetOnChain.assetId], index, +spokeData[0].oracleDecimals.toString(), network); })));
|
|
142
|
+
const merklCampaigns = yield merklCampaignsPromise;
|
|
143
|
+
const enrichedAssets = reserveAssetsArray.map((asset) => attachAaveV4MerklIncentives(asset, market.address, merklCampaigns));
|
|
137
144
|
return {
|
|
138
|
-
assetsData:
|
|
145
|
+
assetsData: enrichedAssets.reduce((acc, reserveAsset) => {
|
|
139
146
|
acc[`${reserveAsset.symbol}-${reserveAsset.reserveId}`] = reserveAsset;
|
|
140
147
|
return acc;
|
|
141
148
|
}, {}),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AaveV4MerklRewardMap, AaveV4ReserveAssetData } from '../types';
|
|
2
|
+
import { NetworkNumber } from '../types/common';
|
|
3
|
+
export declare const getAaveV4MerkleCampaigns: (chainId: NetworkNumber) => Promise<AaveV4MerklRewardMap>;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a copy of the asset with scope-specific incentive arrays pre-combined with the asset's
|
|
6
|
+
* intrinsic (staking) incentives, so each surface can render base yield + the rewards that apply to it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const attachAaveV4MerklIncentives: (asset: AaveV4ReserveAssetData, spokeAddress: string, campaigns: AaveV4MerklRewardMap) => AaveV4ReserveAssetData;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { aprToApy } from '../moneymarket';
|
|
11
|
+
import { DEFAULT_TIMEOUT } from '../services/utils';
|
|
12
|
+
import { IncentiveKind, OpportunityAction, OpportunityStatus, } from '../types';
|
|
13
|
+
/**
|
|
14
|
+
* Merkl tags Aave V4 reward campaigns by scope via the `type` field:
|
|
15
|
+
* - AAVE_V4_HUB_SUPPLY / AAVE_V4_HUB_BORROW → reward tied to a hub (matched per underlying token)
|
|
16
|
+
* - AAVE_V4_SPOKE_SUPPLY / AAVE_V4_SPOKE_BORROW → reward tied to a spoke (matched per spoke contract + underlying)
|
|
17
|
+
* Hub campaigns identify the underlying via `tokens[0]`; spoke campaigns identify the spoke via `explorerAddress`.
|
|
18
|
+
*/
|
|
19
|
+
const spokeKey = (spokeAddress, underlying) => `${spokeAddress.toLowerCase()}_${underlying.toLowerCase()}`;
|
|
20
|
+
const buildIncentive = (opportunity) => {
|
|
21
|
+
var _a, _b, _c, _d, _e;
|
|
22
|
+
const rewardToken = (_c = (_b = (_a = opportunity.rewardsRecord) === null || _a === void 0 ? void 0 : _a.breakdowns) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.token;
|
|
23
|
+
const token = (rewardToken === null || rewardToken === void 0 ? void 0 : rewardToken.symbol) || ((_e = (_d = opportunity.tokens) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.symbol) || '';
|
|
24
|
+
return {
|
|
25
|
+
apy: aprToApy(opportunity.apr),
|
|
26
|
+
token,
|
|
27
|
+
incentiveKind: IncentiveKind.Reward,
|
|
28
|
+
description: `Eligible for ${token} rewards through Merkl.`,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export const getAaveV4MerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const result = { hub: {}, spoke: {} };
|
|
33
|
+
try {
|
|
34
|
+
const res = yield fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
35
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
36
|
+
});
|
|
37
|
+
if (!res.ok)
|
|
38
|
+
throw new Error('Failed to fetch Aave V4 Merkle campaigns');
|
|
39
|
+
const opportunities = yield res.json();
|
|
40
|
+
opportunities
|
|
41
|
+
.filter((o) => o.chainId === chainId)
|
|
42
|
+
.filter((o) => o.status === OpportunityStatus.LIVE)
|
|
43
|
+
.filter((o) => typeof o.type === 'string' && o.type.startsWith('AAVE_V4_'))
|
|
44
|
+
.forEach((o) => {
|
|
45
|
+
var _a, _b, _c, _d;
|
|
46
|
+
const underlying = (_c = (_b = (_a = o.tokens) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.toLowerCase();
|
|
47
|
+
if (!underlying)
|
|
48
|
+
return;
|
|
49
|
+
const side = o.action === OpportunityAction.BORROW ? 'borrow' : 'supply';
|
|
50
|
+
const incentive = buildIncentive(o);
|
|
51
|
+
if (o.type.includes('HUB')) {
|
|
52
|
+
if (!result.hub[underlying])
|
|
53
|
+
result.hub[underlying] = {};
|
|
54
|
+
result.hub[underlying][side] = incentive;
|
|
55
|
+
}
|
|
56
|
+
else if (o.type.includes('SPOKE')) {
|
|
57
|
+
const spokeAddress = (_d = o.explorerAddress) === null || _d === void 0 ? void 0 : _d.toLowerCase();
|
|
58
|
+
if (!spokeAddress)
|
|
59
|
+
return;
|
|
60
|
+
const key = spokeKey(spokeAddress, underlying);
|
|
61
|
+
if (!result.spoke[key])
|
|
62
|
+
result.spoke[key] = {};
|
|
63
|
+
result.spoke[key][side] = incentive;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
console.error('Failed to fetch Aave V4 Merkle campaigns', e);
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Returns a copy of the asset with scope-specific incentive arrays pre-combined with the asset's
|
|
75
|
+
* intrinsic (staking) incentives, so each surface can render base yield + the rewards that apply to it.
|
|
76
|
+
*/
|
|
77
|
+
export const attachAaveV4MerklIncentives = (asset, spokeAddress, campaigns) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const underlying = (_a = asset.underlying) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
80
|
+
const baseSupply = asset.supplyIncentives || [];
|
|
81
|
+
const baseBorrow = asset.borrowIncentives || [];
|
|
82
|
+
const spokeScoped = (spokeAddress && underlying) ? campaigns.spoke[spokeKey(spokeAddress, underlying)] : undefined;
|
|
83
|
+
const hubScoped = underlying ? campaigns.hub[underlying] : undefined;
|
|
84
|
+
return Object.assign(Object.assign({}, asset), { spokeSupplyIncentives: (spokeScoped === null || spokeScoped === void 0 ? void 0 : spokeScoped.supply) ? [...baseSupply, spokeScoped.supply] : baseSupply, spokeBorrowIncentives: (spokeScoped === null || spokeScoped === void 0 ? void 0 : spokeScoped.borrow) ? [...baseBorrow, spokeScoped.borrow] : baseBorrow, hubSupplyIncentives: (hubScoped === null || hubScoped === void 0 ? void 0 : hubScoped.supply) ? [...baseSupply, hubScoped.supply] : baseSupply, hubBorrowIncentives: (hubScoped === null || hubScoped === void 0 ? void 0 : hubScoped.borrow) ? [...baseBorrow, hubScoped.borrow] : baseBorrow });
|
|
85
|
+
};
|
package/esm/claiming/ethena.js
CHANGED
|
@@ -15,7 +15,7 @@ import { getEthAmountForDecimals } from '../services/utils';
|
|
|
15
15
|
export const fetchEthenaAirdropReward = (address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
const checksumAddress = getAddress(address);
|
|
18
|
-
const response = yield fetch(`https://
|
|
18
|
+
const response = yield fetch(`https://d1o76ps6187jke.cloudfront.net/${checksumAddress}/0xb92954d91aa2793b3718414d8df2413d5bd648955dec4a75471e86ded263d585-${checksumAddress}.json`);
|
|
19
19
|
if (!response.ok) {
|
|
20
20
|
if (response.status === 403) {
|
|
21
21
|
// This is also okay, means that there are no rewards for the address
|
|
@@ -97696,6 +97696,66 @@ export declare const YearnV3Vault: {
|
|
|
97696
97696
|
};
|
|
97697
97697
|
export declare const AaveV4View: {
|
|
97698
97698
|
readonly abi: readonly [{
|
|
97699
|
+
readonly inputs: readonly [{
|
|
97700
|
+
readonly internalType: "address";
|
|
97701
|
+
readonly name: "_spoke";
|
|
97702
|
+
readonly type: "address";
|
|
97703
|
+
}, {
|
|
97704
|
+
readonly components: readonly [{
|
|
97705
|
+
readonly internalType: "uint256";
|
|
97706
|
+
readonly name: "reserveId";
|
|
97707
|
+
readonly type: "uint256";
|
|
97708
|
+
}, {
|
|
97709
|
+
readonly internalType: "uint256";
|
|
97710
|
+
readonly name: "liquidityAdded";
|
|
97711
|
+
readonly type: "uint256";
|
|
97712
|
+
}, {
|
|
97713
|
+
readonly internalType: "uint256";
|
|
97714
|
+
readonly name: "liquidityTaken";
|
|
97715
|
+
readonly type: "uint256";
|
|
97716
|
+
}, {
|
|
97717
|
+
readonly internalType: "bool";
|
|
97718
|
+
readonly name: "isDebtAsset";
|
|
97719
|
+
readonly type: "bool";
|
|
97720
|
+
}];
|
|
97721
|
+
readonly internalType: "struct AaveV4View.LiquidityChangeParams[]";
|
|
97722
|
+
readonly name: "_reserveParams";
|
|
97723
|
+
readonly type: "tuple[]";
|
|
97724
|
+
}];
|
|
97725
|
+
readonly name: "getApyAfterValuesEstimation";
|
|
97726
|
+
readonly outputs: readonly [{
|
|
97727
|
+
readonly components: readonly [{
|
|
97728
|
+
readonly internalType: "uint256";
|
|
97729
|
+
readonly name: "reserveId";
|
|
97730
|
+
readonly type: "uint256";
|
|
97731
|
+
}, {
|
|
97732
|
+
readonly internalType: "uint256";
|
|
97733
|
+
readonly name: "hubDrawnRateEstimation";
|
|
97734
|
+
readonly type: "uint256";
|
|
97735
|
+
}, {
|
|
97736
|
+
readonly internalType: "uint256";
|
|
97737
|
+
readonly name: "hubTotalDrawnEstimation";
|
|
97738
|
+
readonly type: "uint256";
|
|
97739
|
+
}, {
|
|
97740
|
+
readonly internalType: "uint256";
|
|
97741
|
+
readonly name: "hubTotalLiquidityEstimation";
|
|
97742
|
+
readonly type: "uint256";
|
|
97743
|
+
}, {
|
|
97744
|
+
readonly internalType: "uint256";
|
|
97745
|
+
readonly name: "hubSwept";
|
|
97746
|
+
readonly type: "uint256";
|
|
97747
|
+
}, {
|
|
97748
|
+
readonly internalType: "uint16";
|
|
97749
|
+
readonly name: "liquidityFee";
|
|
97750
|
+
readonly type: "uint16";
|
|
97751
|
+
}];
|
|
97752
|
+
readonly internalType: "struct AaveV4View.EstimatedRates[]";
|
|
97753
|
+
readonly name: "";
|
|
97754
|
+
readonly type: "tuple[]";
|
|
97755
|
+
}];
|
|
97756
|
+
readonly stateMutability: "view";
|
|
97757
|
+
readonly type: "function";
|
|
97758
|
+
}, {
|
|
97699
97759
|
readonly inputs: readonly [{
|
|
97700
97760
|
readonly internalType: "address";
|
|
97701
97761
|
readonly name: "_eoa";
|
|
@@ -99241,7 +99301,7 @@ export declare const AaveV4View: {
|
|
|
99241
99301
|
}];
|
|
99242
99302
|
readonly networks: {
|
|
99243
99303
|
readonly "1": {
|
|
99244
|
-
readonly address: "
|
|
99304
|
+
readonly address: "0xeCa884900ccC0481F1b65707a80eb294d1245F68";
|
|
99245
99305
|
};
|
|
99246
99306
|
};
|
|
99247
99307
|
};
|