@defisaver/positions-sdk 2.1.127-midnight-dev → 2.1.127-midnight-2-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 +7 -1
- package/cjs/aaveV4/lend.js +3 -3
- package/cjs/claiming/index.d.ts +2 -1
- package/cjs/claiming/index.js +3 -1
- package/cjs/claiming/uniswap.d.ts +5 -0
- package/cjs/claiming/uniswap.js +75 -0
- package/cjs/config/contracts.d.ts +22 -0
- package/cjs/config/contracts.js +9 -1
- package/cjs/contracts.d.ts +35 -0
- package/cjs/contracts.js +2 -1
- package/cjs/curveUsd/index.js +1 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +1 -0
- package/cjs/helpers/morphoMidnightHelpers/index.d.ts +62 -0
- package/cjs/helpers/morphoMidnightHelpers/index.js +156 -1
- package/cjs/llamaLend/index.js +1 -1
- package/cjs/markets/aaveV4/index.d.ts +2 -0
- package/cjs/markets/aaveV4/index.js +14 -1
- package/cjs/morphoBlue/index.d.ts +8 -6
- package/cjs/morphoBlue/index.js +69 -40
- package/cjs/morphoMidnight/index.js +25 -1
- package/cjs/portfolio/index.js +31 -2
- package/cjs/savings/summerVaults/options.js +10 -10
- package/cjs/staking/staking.js +3 -0
- package/cjs/types/aaveV4.d.ts +2 -1
- package/cjs/types/aaveV4.js +1 -0
- package/cjs/types/claiming.d.ts +10 -0
- package/cjs/types/claiming.js +2 -0
- package/cjs/types/morphoBlue.d.ts +9 -0
- package/cjs/types/morphoMidnight.d.ts +3 -0
- package/esm/aaveV3/index.js +7 -1
- package/esm/aaveV4/lend.js +3 -3
- package/esm/claiming/index.d.ts +2 -1
- package/esm/claiming/index.js +2 -1
- package/esm/claiming/uniswap.d.ts +5 -0
- package/esm/claiming/uniswap.js +67 -0
- package/esm/config/contracts.d.ts +22 -0
- package/esm/config/contracts.js +8 -0
- package/esm/contracts.d.ts +35 -0
- package/esm/contracts.js +1 -0
- package/esm/curveUsd/index.js +1 -1
- package/esm/helpers/morphoBlueHelpers/index.js +1 -0
- package/esm/helpers/morphoMidnightHelpers/index.d.ts +62 -0
- package/esm/helpers/morphoMidnightHelpers/index.js +149 -0
- package/esm/llamaLend/index.js +1 -1
- package/esm/markets/aaveV4/index.d.ts +2 -0
- package/esm/markets/aaveV4/index.js +12 -0
- package/esm/morphoBlue/index.d.ts +8 -6
- package/esm/morphoBlue/index.js +62 -39
- package/esm/morphoMidnight/index.js +26 -2
- package/esm/portfolio/index.js +32 -3
- package/esm/savings/summerVaults/options.js +10 -10
- package/esm/staking/staking.js +3 -0
- package/esm/types/aaveV4.d.ts +2 -1
- package/esm/types/aaveV4.js +1 -0
- package/esm/types/claiming.d.ts +10 -0
- package/esm/types/claiming.js +2 -0
- package/esm/types/morphoBlue.d.ts +9 -0
- package/esm/types/morphoMidnight.d.ts +3 -0
- package/package.json +2 -2
- package/src/aaveV3/index.ts +13 -1
- package/src/aaveV4/lend.ts +3 -3
- package/src/claiming/index.ts +2 -0
- package/src/claiming/uniswap.ts +70 -0
- package/src/config/contracts.ts +9 -0
- package/src/contracts.ts +2 -0
- package/src/curveUsd/index.ts +1 -1
- package/src/helpers/morphoBlueHelpers/index.ts +1 -0
- package/src/helpers/morphoMidnightHelpers/index.ts +206 -0
- package/src/llamaLend/index.ts +1 -1
- package/src/markets/aaveV4/index.ts +13 -0
- package/src/morphoBlue/index.ts +101 -44
- package/src/morphoMidnight/index.ts +29 -2
- package/src/portfolio/index.ts +32 -3
- package/src/savings/summerVaults/options.ts +10 -10
- package/src/staking/staking.ts +2 -0
- package/src/types/aaveV4.ts +1 -0
- package/src/types/claiming.ts +11 -0
- package/src/types/morphoBlue.ts +11 -0
- package/src/types/morphoMidnight.ts +6 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAaveV4SpokeByAddress = exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_USDG_PENDLE_SPOKE = exports.AAVE_V4_MAIN_SPOKE = exports.AAVE_V4_LOMBARD_BTC_SPOKE = exports.AAVE_V4_LIDO_SPOKE = exports.AAVE_V4_KELP_SPOKE = exports.AAVE_V4_GOLD_SPOKE = exports.AAVE_V4_FOREX_SPOKE = exports.AAVE_V4_ETHERFI_SPOKE = exports.AAVE_V4_ETHENA_ECOSYSTEM_SPOKE = exports.AAVE_V4_ETHENA_CORRELATED_SPOKE = exports.AAVE_V4_BLUECHIP_SPOKE = exports.getAaveV4HubByAddress = exports.getAaveV4HubTypeInfo = exports.AaveV4Hubs = exports.AAVE_V4_PAXOS_HUB = exports.AAVE_V4_PRIME_HUB = exports.AAVE_V4_PLUS_HUB = exports.AAVE_V4_CORE_HUB = void 0;
|
|
3
|
+
exports.findAaveV4SpokeByAddress = exports.getAaveV4SpokeTypeInfo = exports.AaveV4Spokes = exports.AAVE_V4_USDG_MAPLE_SPOKE = exports.AAVE_V4_USDG_PENDLE_SPOKE = exports.AAVE_V4_MAIN_SPOKE = exports.AAVE_V4_LOMBARD_BTC_SPOKE = exports.AAVE_V4_LIDO_SPOKE = exports.AAVE_V4_KELP_SPOKE = exports.AAVE_V4_GOLD_SPOKE = exports.AAVE_V4_FOREX_SPOKE = exports.AAVE_V4_ETHERFI_SPOKE = exports.AAVE_V4_ETHENA_ECOSYSTEM_SPOKE = exports.AAVE_V4_ETHENA_CORRELATED_SPOKE = exports.AAVE_V4_BLUECHIP_SPOKE = exports.getAaveV4HubByAddress = exports.getAaveV4HubTypeInfo = exports.AaveV4Hubs = exports.AAVE_V4_PAXOS_HUB = exports.AAVE_V4_PRIME_HUB = exports.AAVE_V4_PLUS_HUB = exports.AAVE_V4_CORE_HUB = void 0;
|
|
4
4
|
const types_1 = require("../../types");
|
|
5
5
|
// HUBS
|
|
6
6
|
const AAVE_V4_CORE_HUB = (networkId) => ({
|
|
@@ -185,6 +185,18 @@ const AAVE_V4_USDG_PENDLE_SPOKE = (networkId) => ({
|
|
|
185
185
|
],
|
|
186
186
|
});
|
|
187
187
|
exports.AAVE_V4_USDG_PENDLE_SPOKE = AAVE_V4_USDG_PENDLE_SPOKE;
|
|
188
|
+
const AAVE_V4_USDG_MAPLE_SPOKE = (networkId) => ({
|
|
189
|
+
chainIds: [types_1.NetworkNumber.Eth],
|
|
190
|
+
label: 'USDG Maple',
|
|
191
|
+
value: types_1.AaveV4SpokesType.AaveV4USDGMapleSpoke,
|
|
192
|
+
url: 'usdg-maple',
|
|
193
|
+
address: '0x774b9655413c34809c1f1b16b654465A89EBE989',
|
|
194
|
+
hubs: [
|
|
195
|
+
(0, exports.AAVE_V4_PAXOS_HUB)(types_1.NetworkNumber.Eth).address,
|
|
196
|
+
(0, exports.AAVE_V4_CORE_HUB)(types_1.NetworkNumber.Eth).address,
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
exports.AAVE_V4_USDG_MAPLE_SPOKE = AAVE_V4_USDG_MAPLE_SPOKE;
|
|
188
200
|
const AaveV4Spokes = (networkId) => ({
|
|
189
201
|
[types_1.AaveV4SpokesType.AaveV4BluechipSpoke]: (0, exports.AAVE_V4_BLUECHIP_SPOKE)(networkId),
|
|
190
202
|
[types_1.AaveV4SpokesType.AaveV4EthenaCorrelatedSpoke]: (0, exports.AAVE_V4_ETHENA_CORRELATED_SPOKE)(networkId),
|
|
@@ -197,6 +209,7 @@ const AaveV4Spokes = (networkId) => ({
|
|
|
197
209
|
[types_1.AaveV4SpokesType.AaveV4LombardBtcSpoke]: (0, exports.AAVE_V4_LOMBARD_BTC_SPOKE)(networkId),
|
|
198
210
|
[types_1.AaveV4SpokesType.AaveV4MainSpoke]: (0, exports.AAVE_V4_MAIN_SPOKE)(networkId),
|
|
199
211
|
[types_1.AaveV4SpokesType.AaveV4USDGPendleSpoke]: (0, exports.AAVE_V4_USDG_PENDLE_SPOKE)(networkId),
|
|
212
|
+
[types_1.AaveV4SpokesType.AaveV4USDGMapleSpoke]: (0, exports.AAVE_V4_USDG_MAPLE_SPOKE)(networkId),
|
|
200
213
|
});
|
|
201
214
|
exports.AaveV4Spokes = AaveV4Spokes;
|
|
202
215
|
const getAaveV4SpokeTypeInfo = (type, network) => (Object.assign({}, (0, exports.AaveV4Spokes)(network !== null && network !== void 0 ? network : types_1.NetworkNumber.Eth))[type]);
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
2
|
import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
-
import { MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBluePositionData } from '../types';
|
|
3
|
+
import { MorphoBlueEarnData, MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBlueMarketRewards, MorphoBluePositionData } from '../types';
|
|
4
|
+
export declare const addMorphoBlueRewardsToMarketInfo: (marketInfo: MorphoBlueMarketInfo, rewards: MorphoBlueMarketRewards) => MorphoBlueMarketInfo;
|
|
4
5
|
export declare function _getMorphoBlueMarketData(provider: Client, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo>;
|
|
6
|
+
export declare function _getMorphoBluePortfolioMarketData(provider: Client, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo>;
|
|
5
7
|
export declare function getMorphoBlueMarketData(provider: EthereumProvider, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo>;
|
|
8
|
+
export declare function getMorphoBluePortfolioMarketData(provider: EthereumProvider, network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketInfo>;
|
|
9
|
+
export declare const getMorphoBluePositionDataWithMarketInfo: (data: MorphoBluePositionData, marketInfo: MorphoBlueMarketInfo) => MorphoBluePositionData;
|
|
10
|
+
export declare const getMorphoEarnDataWithMarketInfo: (data: MorphoBlueEarnData, marketInfo: MorphoBlueMarketInfo) => MorphoBlueEarnData;
|
|
11
|
+
export declare function getMorphoBlueMarketRewards(network: NetworkNumber, selectedMarket: MorphoBlueMarketData): Promise<MorphoBlueMarketRewards>;
|
|
6
12
|
export declare const _getMorphoBlueAccountBalances: (provider: Client, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoBlueMarketData) => Promise<PositionBalances>;
|
|
7
13
|
export declare const getMorphoBlueAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoBlueMarketData) => Promise<PositionBalances>;
|
|
8
14
|
export declare function _getMorphoBlueAccountData(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBluePositionData>;
|
|
9
15
|
export declare function getMorphoBlueAccountData(provider: EthereumProvider, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBluePositionData>;
|
|
10
|
-
export declare function getMorphoEarn(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<
|
|
11
|
-
apy: string;
|
|
12
|
-
amount: string;
|
|
13
|
-
amountUsd: string;
|
|
14
|
-
}>;
|
|
16
|
+
export declare function getMorphoEarn(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBlueEarnData>;
|
package/cjs/morphoBlue/index.js
CHANGED
|
@@ -12,9 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getMorphoBlueAccountBalances = exports._getMorphoBlueAccountBalances = void 0;
|
|
15
|
+
exports.getMorphoBlueAccountBalances = exports._getMorphoBlueAccountBalances = exports.getMorphoEarnDataWithMarketInfo = exports.getMorphoBluePositionDataWithMarketInfo = exports.addMorphoBlueRewardsToMarketInfo = void 0;
|
|
16
16
|
exports._getMorphoBlueMarketData = _getMorphoBlueMarketData;
|
|
17
|
+
exports._getMorphoBluePortfolioMarketData = _getMorphoBluePortfolioMarketData;
|
|
17
18
|
exports.getMorphoBlueMarketData = getMorphoBlueMarketData;
|
|
19
|
+
exports.getMorphoBluePortfolioMarketData = getMorphoBluePortfolioMarketData;
|
|
20
|
+
exports.getMorphoBlueMarketRewards = getMorphoBlueMarketRewards;
|
|
18
21
|
exports._getMorphoBlueAccountData = _getMorphoBlueAccountData;
|
|
19
22
|
exports.getMorphoBlueAccountData = getMorphoBlueAccountData;
|
|
20
23
|
exports.getMorphoEarn = getMorphoEarn;
|
|
@@ -29,7 +32,21 @@ const morphoBlueHelpers_1 = require("../helpers/morphoBlueHelpers");
|
|
|
29
32
|
const priceService_1 = require("../services/priceService");
|
|
30
33
|
const viem_1 = require("../services/viem");
|
|
31
34
|
const HARDCODED_USD_STABLE_PRICE = '100000000'; // $1 with 8 decimals
|
|
32
|
-
|
|
35
|
+
const getMorphoRewardIncentives = (apy) => [{
|
|
36
|
+
token: 'MORPHO',
|
|
37
|
+
apy,
|
|
38
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
39
|
+
description: 'Eligible for protocol-level MORPHO incentives.',
|
|
40
|
+
}];
|
|
41
|
+
const addMorphoBlueRewardsToMarketInfo = (marketInfo, rewards) => (Object.assign(Object.assign({}, marketInfo), { assetsData: Object.assign(Object.assign({}, marketInfo.assetsData), { [marketInfo.loanToken]: Object.assign(Object.assign({}, marketInfo.assetsData[marketInfo.loanToken]), { supplyIncentives: [
|
|
42
|
+
...marketInfo.assetsData[marketInfo.loanToken].supplyIncentives.filter(({ token }) => token !== 'MORPHO'),
|
|
43
|
+
...getMorphoRewardIncentives(rewards.supplyApy),
|
|
44
|
+
], borrowIncentives: [
|
|
45
|
+
...marketInfo.assetsData[marketInfo.loanToken].borrowIncentives.filter(({ token }) => token !== 'MORPHO'),
|
|
46
|
+
...getMorphoRewardIncentives(rewards.borrowApy),
|
|
47
|
+
] }) }) }));
|
|
48
|
+
exports.addMorphoBlueRewardsToMarketInfo = addMorphoBlueRewardsToMarketInfo;
|
|
49
|
+
function getMorphoBlueMarketDataInternal(provider, network, selectedMarket) {
|
|
33
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
51
|
const { loanToken, collateralToken, oracle, irm, lltv, oracleType, } = selectedMarket;
|
|
35
52
|
const lltvInWei = new decimal_js_1.default(lltv).mul(constants_1.WAD).toString();
|
|
@@ -61,16 +78,6 @@ function _getMorphoBlueMarketData(provider, network, selectedMarket) {
|
|
|
61
78
|
marketInfo = _marketInfo;
|
|
62
79
|
loanTokenPrice = loanTokenPriceRound[1].toString();
|
|
63
80
|
}
|
|
64
|
-
let morphoSupplyApy = '0';
|
|
65
|
-
let morphoBorrowApy = '0';
|
|
66
|
-
try {
|
|
67
|
-
const { supplyApy: _morphoSupplyApy, borrowApy: _morphoBorrowApy } = yield (0, morphoBlueHelpers_1.getRewardsForMarket)(selectedMarket.marketId, network);
|
|
68
|
-
morphoSupplyApy = _morphoSupplyApy;
|
|
69
|
-
morphoBorrowApy = _morphoBorrowApy;
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
console.error(e);
|
|
73
|
-
}
|
|
74
81
|
const supplyRate = (0, morphoBlueHelpers_1.getSupplyRate)(marketInfo.totalSupplyAssets.toString(), marketInfo.totalBorrowAssets.toString(), marketInfo.borrowRate.toString(), marketInfo.fee.toString());
|
|
75
82
|
const compoundedBorrowRate = (0, morphoBlueHelpers_1.getBorrowRate)(marketInfo.borrowRate.toString(), marketInfo.totalBorrowShares.toString());
|
|
76
83
|
const utillization = new decimal_js_1.default(marketInfo.totalBorrowAssets.toString()).div(marketInfo.totalSupplyAssets.toString()).mul(100).toString();
|
|
@@ -89,18 +96,8 @@ function _getMorphoBlueMarketData(provider, network, selectedMarket) {
|
|
|
89
96
|
totalBorrow: new decimal_js_1.default(marketInfo.totalBorrowAssets.toString()).div(scale).toString(),
|
|
90
97
|
canBeSupplied: true,
|
|
91
98
|
canBeBorrowed: true,
|
|
92
|
-
supplyIncentives: [
|
|
93
|
-
|
|
94
|
-
apy: morphoSupplyApy,
|
|
95
|
-
incentiveKind: common_1.IncentiveKind.Reward,
|
|
96
|
-
description: 'Eligible for protocol-level MORPHO incentives.',
|
|
97
|
-
}],
|
|
98
|
-
borrowIncentives: [{
|
|
99
|
-
token: 'MORPHO',
|
|
100
|
-
apy: morphoBorrowApy,
|
|
101
|
-
incentiveKind: common_1.IncentiveKind.Reward,
|
|
102
|
-
description: 'Eligible for protocol-level MORPHO incentives.',
|
|
103
|
-
}],
|
|
99
|
+
supplyIncentives: [],
|
|
100
|
+
borrowIncentives: [],
|
|
104
101
|
};
|
|
105
102
|
assetsData[(0, utils_1.wethToEth)(collateralTokenInfo.symbol)] = {
|
|
106
103
|
symbol: (0, utils_1.wethToEth)(collateralTokenInfo.symbol),
|
|
@@ -135,11 +132,56 @@ function _getMorphoBlueMarketData(provider, network, selectedMarket) {
|
|
|
135
132
|
};
|
|
136
133
|
});
|
|
137
134
|
}
|
|
135
|
+
function _getMorphoBlueMarketData(provider, network, selectedMarket) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const marketInfo = yield getMorphoBlueMarketDataInternal(provider, network, selectedMarket);
|
|
138
|
+
try {
|
|
139
|
+
const rewards = yield (0, morphoBlueHelpers_1.getRewardsForMarket)(selectedMarket.marketId, network);
|
|
140
|
+
return (0, exports.addMorphoBlueRewardsToMarketInfo)(marketInfo, rewards);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.error(error);
|
|
144
|
+
return (0, exports.addMorphoBlueRewardsToMarketInfo)(marketInfo, { supplyApy: '0', borrowApy: '0' });
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function _getMorphoBluePortfolioMarketData(provider, network, selectedMarket) {
|
|
149
|
+
return getMorphoBlueMarketDataInternal(provider, network, selectedMarket);
|
|
150
|
+
}
|
|
138
151
|
function getMorphoBlueMarketData(provider, network, selectedMarket) {
|
|
139
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
153
|
return _getMorphoBlueMarketData((0, viem_1.getViemProvider)(provider, network), network, selectedMarket);
|
|
141
154
|
});
|
|
142
155
|
}
|
|
156
|
+
function getMorphoBluePortfolioMarketData(provider, network, selectedMarket) {
|
|
157
|
+
return _getMorphoBluePortfolioMarketData((0, viem_1.getViemProvider)(provider, network), network, selectedMarket);
|
|
158
|
+
}
|
|
159
|
+
const getMorphoBluePositionDataWithMarketInfo = (data, marketInfo) => (Object.assign(Object.assign({}, data), (0, morphoBlueHelpers_1.getMorphoBlueAggregatedPositionData)({
|
|
160
|
+
usedAssets: data.usedAssets,
|
|
161
|
+
assetsData: marketInfo.assetsData,
|
|
162
|
+
marketInfo,
|
|
163
|
+
})));
|
|
164
|
+
exports.getMorphoBluePositionDataWithMarketInfo = getMorphoBluePositionDataWithMarketInfo;
|
|
165
|
+
const getMorphoEarnDataWithMarketInfo = (data, marketInfo) => {
|
|
166
|
+
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
167
|
+
const usedAssets = {
|
|
168
|
+
[marketInfo.loanToken]: {
|
|
169
|
+
symbol: loanTokenInfo.symbol,
|
|
170
|
+
supplied: data.amount,
|
|
171
|
+
borrowed: '0',
|
|
172
|
+
isSupplied: new decimal_js_1.default(data.amount).gt(0),
|
|
173
|
+
isBorrowed: false,
|
|
174
|
+
collateral: false,
|
|
175
|
+
suppliedUsd: data.amountUsd,
|
|
176
|
+
borrowedUsd: '0',
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
return Object.assign(Object.assign({}, data), { apy: (0, staking_1.calculateNetApy)({ usedAssets, assetsData: marketInfo.assetsData }).netApy });
|
|
180
|
+
};
|
|
181
|
+
exports.getMorphoEarnDataWithMarketInfo = getMorphoEarnDataWithMarketInfo;
|
|
182
|
+
function getMorphoBlueMarketRewards(network, selectedMarket) {
|
|
183
|
+
return (0, morphoBlueHelpers_1.getRewardsForMarket)(selectedMarket.marketId, network);
|
|
184
|
+
}
|
|
143
185
|
const _getMorphoBlueAccountBalances = (provider, network, block, addressMapping, address, selectedMarket) => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
186
|
let balances = {
|
|
145
187
|
collateral: {},
|
|
@@ -229,23 +271,10 @@ function getMorphoEarn(provider, network, account, selectedMarket, marketInfo) {
|
|
|
229
271
|
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
230
272
|
const loanTokenSupplied = (0, tokens_1.assetAmountInEth)(loanInfo.suppliedInAssets.toString(), marketInfo.loanToken);
|
|
231
273
|
const loanTokenSuppliedUsd = new decimal_js_1.default(loanTokenSupplied).mul(loanTokenInfo.price).toString();
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
symbol: loanTokenInfo.symbol,
|
|
235
|
-
supplied: loanTokenSupplied,
|
|
236
|
-
borrowed: '0',
|
|
237
|
-
isSupplied: new decimal_js_1.default(loanInfo.suppliedInAssets.toString()).gt(0),
|
|
238
|
-
isBorrowed: false,
|
|
239
|
-
collateral: false,
|
|
240
|
-
suppliedUsd: loanTokenSuppliedUsd,
|
|
241
|
-
borrowedUsd: '0',
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
const { netApy } = (0, staking_1.calculateNetApy)({ usedAssets, assetsData: marketInfo.assetsData });
|
|
245
|
-
return {
|
|
246
|
-
apy: netApy,
|
|
274
|
+
return (0, exports.getMorphoEarnDataWithMarketInfo)({
|
|
275
|
+
apy: '0',
|
|
247
276
|
amount: loanTokenSupplied,
|
|
248
277
|
amountUsd: loanTokenSuppliedUsd,
|
|
249
|
-
};
|
|
278
|
+
}, marketInfo);
|
|
250
279
|
});
|
|
251
280
|
}
|
|
@@ -159,9 +159,33 @@ function _getMorphoMidnightAccountData(provider, network, account, selectedMarke
|
|
|
159
159
|
borrowedUsd: '0',
|
|
160
160
|
};
|
|
161
161
|
});
|
|
162
|
+
// Enrich borrower positions with the orderbook-derived rate + principal/interest split (off-chain).
|
|
163
|
+
// MidnightView only stores `debt` (= face value at maturity), so we default to full-debt-as-principal and
|
|
164
|
+
// override from the transactions API when available. Never throw here — the position must still render.
|
|
165
|
+
let borrowRate = '0';
|
|
166
|
+
let debtBase = debt; // fallback: treat the full on-chain debt as principal until fill history is known
|
|
167
|
+
let debtInterest = '0';
|
|
168
|
+
let assetsDataForApy = marketInfo.assetsData;
|
|
169
|
+
if (new decimal_js_1.default(positionInfo.debt.toString()).gt(0)) {
|
|
170
|
+
try {
|
|
171
|
+
const borrowInfo = yield (0, morphoMidnightHelpers_1.getMorphoMidnightUserBorrowInfo)(account, marketId, marketInfo.maturity, marketInfo.loanToken);
|
|
172
|
+
borrowRate = borrowInfo.borrowRate;
|
|
173
|
+
debtBase = borrowInfo.debtBase;
|
|
174
|
+
debtInterest = borrowInfo.debtInterest;
|
|
175
|
+
usedAssets[marketInfo.loanToken].borrowRate = borrowRate;
|
|
176
|
+
// Reflect the real borrow cost in netApy without mutating the shared marketInfo.assetsData.
|
|
177
|
+
assetsDataForApy = Object.assign(Object.assign({}, marketInfo.assetsData), { [marketInfo.loanToken]: Object.assign(Object.assign({}, loanTokenData), { borrowRate }) });
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
// Orderbook API unavailable — keep the on-chain-only fallback above.
|
|
181
|
+
}
|
|
182
|
+
}
|
|
162
183
|
return Object.assign({ usedAssets,
|
|
163
184
|
credit,
|
|
164
|
-
debt,
|
|
185
|
+
debt,
|
|
186
|
+
borrowRate,
|
|
187
|
+
debtBase,
|
|
188
|
+
debtInterest, maturity: marketInfo.maturity, isMatured: marketInfo.isMatured }, (0, morphoMidnightHelpers_1.getMorphoMidnightAggregatedPositionData)({ usedAssets, assetsData: assetsDataForApy, marketInfo }));
|
|
165
189
|
});
|
|
166
190
|
}
|
|
167
191
|
function getMorphoMidnightAccountData(provider, network, account, selectedMarket, marketInfo) {
|
package/cjs/portfolio/index.js
CHANGED
|
@@ -55,6 +55,7 @@ const spark_2 = require("../claiming/spark");
|
|
|
55
55
|
const king_1 = require("../claiming/king");
|
|
56
56
|
const ethena_1 = require("../claiming/ethena");
|
|
57
57
|
const aaveV4_1 = require("../aaveV4");
|
|
58
|
+
const uniswap_1 = require("../claiming/uniswap");
|
|
58
59
|
function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1) {
|
|
59
60
|
return __awaiter(this, arguments, void 0, function* (provider, network, defaultProvider, addresses, isSim = false) {
|
|
60
61
|
const isMainnet = network === common_1.NetworkNumber.Eth;
|
|
@@ -72,7 +73,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
72
73
|
const liquityV2Markets = [common_1.NetworkNumber.Eth].includes(network) ? Object.values((0, markets_1.LiquityV2Markets)(network)) : [];
|
|
73
74
|
const liquityV2MarketsStaking = [common_1.NetworkNumber.Eth].includes(network) ? Object.values((0, markets_1.LiquityV2Markets)(network)).filter(market => !market.isLegacy) : [];
|
|
74
75
|
const aaveV4Spokes = Object.values((0, markets_1.AaveV4Spokes)(network)).filter((market) => market.chainIds.includes(network));
|
|
75
|
-
const args = [network, { batch: { multicall: { batchSize: isSim ?
|
|
76
|
+
const args = [network, { batch: { multicall: { batchSize: isSim ? 2000 : 2500000 } } }];
|
|
76
77
|
const client = (0, viem_1.getViemProvider)(provider, ...args);
|
|
77
78
|
const defaultClient = (0, viem_1.getViemProvider)(defaultProvider, ...args);
|
|
78
79
|
const morphoMarketsData = {};
|
|
@@ -157,7 +158,7 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
157
158
|
yield Promise.allSettled([
|
|
158
159
|
// === MARKET DATA (needs to be fetched first) ===
|
|
159
160
|
...morphoMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
const marketData = yield (0, morphoBlue_1.
|
|
161
|
+
const marketData = yield (0, morphoBlue_1._getMorphoBluePortfolioMarketData)(client, network, market);
|
|
161
162
|
morphoMarketsData[market.value] = marketData;
|
|
162
163
|
})),
|
|
163
164
|
...morphoMidnightMarkets.map((market) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -319,6 +320,34 @@ function getPortfolioData(provider_1, network_1, defaultProvider_1, addresses_1)
|
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
}))(),
|
|
323
|
+
// Batch UNI rewards
|
|
324
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
try {
|
|
326
|
+
if (!isMainnet) {
|
|
327
|
+
for (const address of addresses) {
|
|
328
|
+
rewardsData[address.toLowerCase()].uniswap = { error: '', data: [] };
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const uniswapRewards = yield (0, uniswap_1.getUniswapRewards)(client, network, addresses);
|
|
333
|
+
for (const address of addresses) {
|
|
334
|
+
const lowerAddress = address.toLowerCase();
|
|
335
|
+
rewardsData[lowerAddress].uniswap = {
|
|
336
|
+
error: '',
|
|
337
|
+
data: uniswapRewards[lowerAddress] || [],
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
console.error('Error fetching Uniswap rewards data in batch:', error);
|
|
343
|
+
for (const address of addresses) {
|
|
344
|
+
rewardsData[address.toLowerCase()].uniswap = {
|
|
345
|
+
error: 'Error fetching Uniswap rewards data in batch',
|
|
346
|
+
data: null,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}))(),
|
|
322
351
|
...sparkMarkets.map((market) => addresses.map((address) => __awaiter(this, void 0, void 0, function* () {
|
|
323
352
|
try {
|
|
324
353
|
if (!isMainnet) {
|
|
@@ -10,7 +10,7 @@ exports.SUMMER_VAULT_USDC_MAINNET_LR = {
|
|
|
10
10
|
asset: 'USDC',
|
|
11
11
|
network: common_1.NetworkNumber.Eth,
|
|
12
12
|
deploymentBlock: 21795049,
|
|
13
|
-
isLegacy:
|
|
13
|
+
isLegacy: true,
|
|
14
14
|
};
|
|
15
15
|
exports.SUMMER_VAULT_USDC_MAINNET_HR = {
|
|
16
16
|
type: types_1.SummerVaultType.SummerVaultUSDCMainnetHR,
|
|
@@ -19,7 +19,7 @@ exports.SUMMER_VAULT_USDC_MAINNET_HR = {
|
|
|
19
19
|
asset: 'USDC',
|
|
20
20
|
network: common_1.NetworkNumber.Eth,
|
|
21
21
|
deploymentBlock: 22488041,
|
|
22
|
-
isLegacy:
|
|
22
|
+
isLegacy: true,
|
|
23
23
|
};
|
|
24
24
|
exports.SUMMER_VAULT_USDT_MAINNET_LR = {
|
|
25
25
|
type: types_1.SummerVaultType.SummerVaultUSDTMainnetLR,
|
|
@@ -28,7 +28,7 @@ exports.SUMMER_VAULT_USDT_MAINNET_LR = {
|
|
|
28
28
|
asset: 'USDT',
|
|
29
29
|
network: common_1.NetworkNumber.Eth,
|
|
30
30
|
deploymentBlock: 21795276,
|
|
31
|
-
isLegacy:
|
|
31
|
+
isLegacy: true,
|
|
32
32
|
};
|
|
33
33
|
exports.SUMMER_VAULT_ETH_MAINNET_LR = {
|
|
34
34
|
type: types_1.SummerVaultType.SummerVaultETHMainnetLR,
|
|
@@ -37,7 +37,7 @@ exports.SUMMER_VAULT_ETH_MAINNET_LR = {
|
|
|
37
37
|
asset: 'WETH',
|
|
38
38
|
network: common_1.NetworkNumber.Eth,
|
|
39
39
|
deploymentBlock: 21795390,
|
|
40
|
-
isLegacy:
|
|
40
|
+
isLegacy: true,
|
|
41
41
|
};
|
|
42
42
|
exports.SUMMER_VAULT_ETH_MAINNET_HR = {
|
|
43
43
|
type: types_1.SummerVaultType.SummerVaultETHMainnetHR,
|
|
@@ -46,7 +46,7 @@ exports.SUMMER_VAULT_ETH_MAINNET_HR = {
|
|
|
46
46
|
asset: 'WETH',
|
|
47
47
|
network: common_1.NetworkNumber.Eth,
|
|
48
48
|
deploymentBlock: 22291252,
|
|
49
|
-
isLegacy:
|
|
49
|
+
isLegacy: true,
|
|
50
50
|
};
|
|
51
51
|
exports.SUMMER_VAULT_USDC_ARBITRUM_LR = {
|
|
52
52
|
type: types_1.SummerVaultType.SummerVaultUSDCArbitrumLR,
|
|
@@ -55,7 +55,7 @@ exports.SUMMER_VAULT_USDC_ARBITRUM_LR = {
|
|
|
55
55
|
asset: 'USDC',
|
|
56
56
|
network: common_1.NetworkNumber.Arb,
|
|
57
57
|
deploymentBlock: 404339289,
|
|
58
|
-
isLegacy:
|
|
58
|
+
isLegacy: true,
|
|
59
59
|
};
|
|
60
60
|
exports.SUMMER_VAULT_USDT_ARBITRUM_LR = {
|
|
61
61
|
type: types_1.SummerVaultType.SummerVaultUSDTArbitrumLR,
|
|
@@ -64,7 +64,7 @@ exports.SUMMER_VAULT_USDT_ARBITRUM_LR = {
|
|
|
64
64
|
asset: 'USDT',
|
|
65
65
|
network: common_1.NetworkNumber.Arb,
|
|
66
66
|
deploymentBlock: 303594065,
|
|
67
|
-
isLegacy:
|
|
67
|
+
isLegacy: true,
|
|
68
68
|
};
|
|
69
69
|
exports.SUMMER_VAULT_USDC_BASE_LR = {
|
|
70
70
|
type: types_1.SummerVaultType.SummerVaultUSDCBaseLR,
|
|
@@ -73,7 +73,7 @@ exports.SUMMER_VAULT_USDC_BASE_LR = {
|
|
|
73
73
|
asset: 'USDC',
|
|
74
74
|
network: common_1.NetworkNumber.Base,
|
|
75
75
|
deploymentBlock: 303594065,
|
|
76
|
-
isLegacy:
|
|
76
|
+
isLegacy: true,
|
|
77
77
|
};
|
|
78
78
|
exports.SUMMER_VAULT_EURC_BASE_LR = {
|
|
79
79
|
type: types_1.SummerVaultType.SummerVaultEURCBaseLR,
|
|
@@ -82,7 +82,7 @@ exports.SUMMER_VAULT_EURC_BASE_LR = {
|
|
|
82
82
|
asset: 'EURC',
|
|
83
83
|
network: common_1.NetworkNumber.Base,
|
|
84
84
|
deploymentBlock: 27544064,
|
|
85
|
-
isLegacy:
|
|
85
|
+
isLegacy: true,
|
|
86
86
|
};
|
|
87
87
|
exports.SUMMER_VAULT_ETH_BASE_LR = {
|
|
88
88
|
type: types_1.SummerVaultType.SummerVaultETHBaseLR,
|
|
@@ -91,7 +91,7 @@ exports.SUMMER_VAULT_ETH_BASE_LR = {
|
|
|
91
91
|
asset: 'WETH',
|
|
92
92
|
network: common_1.NetworkNumber.Base,
|
|
93
93
|
deploymentBlock: 29066887,
|
|
94
|
-
isLegacy:
|
|
94
|
+
isLegacy: true,
|
|
95
95
|
};
|
|
96
96
|
exports.SUMMER_VAULTS = {
|
|
97
97
|
[types_1.SummerVaultType.SummerVaultUSDCMainnetLR]: exports.SUMMER_VAULT_USDC_MAINNET_LR,
|
package/cjs/staking/staking.js
CHANGED
|
@@ -74,6 +74,7 @@ exports.STAKING_ASSETS = [
|
|
|
74
74
|
'PT sUSDe Nov', 'PT USDe Nov', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'syrupUSDC', 'wstUSR',
|
|
75
75
|
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'GHO',
|
|
76
76
|
'PT sUSDe June', 'PT USDe June', 'PT srUSDe Jun', 'PT srUSDe Oct', 'PT USDG May', 'PT sUSDS Nov', 'PT sUSDe Oct', 'PT USDG Sep',
|
|
77
|
+
'syrupUSDG',
|
|
77
78
|
];
|
|
78
79
|
exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaiter(void 0, [asset_1, ...args_1], void 0, function* (asset, network = common_1.NetworkNumber.Eth) {
|
|
79
80
|
try {
|
|
@@ -131,6 +132,8 @@ exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaite
|
|
|
131
132
|
return yield getApyFromDfsApi('syrupUSDT');
|
|
132
133
|
if (asset === 'syrupUSDC')
|
|
133
134
|
return yield getApyFromDfsApi('syrupUSDC');
|
|
135
|
+
if (asset === 'syrupUSDG')
|
|
136
|
+
return yield getApyFromDfsApi('syrupUSDG');
|
|
134
137
|
if (asset === 'wstUSR')
|
|
135
138
|
return yield getApyFromDfsApi('wstUSR');
|
|
136
139
|
if (asset === 'PT sUSDe Feb')
|
package/cjs/types/aaveV4.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ export declare enum AaveV4SpokesType {
|
|
|
16
16
|
AaveV4LidoSpoke = "aave_v4_lido_spoke",
|
|
17
17
|
AaveV4LombardBtcSpoke = "aave_v4_lombard_btc_spoke",
|
|
18
18
|
AaveV4MainSpoke = "aave_v4_main_spoke",
|
|
19
|
-
AaveV4USDGPendleSpoke = "aave_v4_usdg_pendle_spoke"
|
|
19
|
+
AaveV4USDGPendleSpoke = "aave_v4_usdg_pendle_spoke",
|
|
20
|
+
AaveV4USDGMapleSpoke = "aave_v4_usdg_maple_spoke"
|
|
20
21
|
}
|
|
21
22
|
export interface AaveV4HubInfo {
|
|
22
23
|
chainIds: NetworkNumber[];
|
package/cjs/types/aaveV4.js
CHANGED
|
@@ -21,4 +21,5 @@ var AaveV4SpokesType;
|
|
|
21
21
|
AaveV4SpokesType["AaveV4LombardBtcSpoke"] = "aave_v4_lombard_btc_spoke";
|
|
22
22
|
AaveV4SpokesType["AaveV4MainSpoke"] = "aave_v4_main_spoke";
|
|
23
23
|
AaveV4SpokesType["AaveV4USDGPendleSpoke"] = "aave_v4_usdg_pendle_spoke";
|
|
24
|
+
AaveV4SpokesType["AaveV4USDGMapleSpoke"] = "aave_v4_usdg_maple_spoke";
|
|
24
25
|
})(AaveV4SpokesType || (exports.AaveV4SpokesType = AaveV4SpokesType = {}));
|
package/cjs/types/claiming.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare enum ClaimType {
|
|
|
14
14
|
SPARK_AIRDROP = "SPARK_AIRDROP",
|
|
15
15
|
/** Spark Airdrop */
|
|
16
16
|
SPARK_WST_ETH_REWARDS = "SPARK_WST_ETH_REWARDS",// TODO: This will be removed once we fully refactor spark rewards
|
|
17
|
+
/** UNI Airdrop */
|
|
18
|
+
UNI_REWARDS = "UNI_REWARDS",
|
|
17
19
|
ETHENA_AIRDROP = "ETHENA_AIRDROP"
|
|
18
20
|
}
|
|
19
21
|
type _ClaimableTokenPartial = {
|
|
@@ -81,5 +83,13 @@ export type SparkWstEthRewardsClaimableToken = _ClaimableTokenPartial & {
|
|
|
81
83
|
export type EthenaAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
82
84
|
claimType: ClaimType.ETHENA_AIRDROP;
|
|
83
85
|
};
|
|
86
|
+
export type UniswapAirdropClaimableToken = _ClaimableTokenPartial & {
|
|
87
|
+
claimType: ClaimType.UNI_REWARDS;
|
|
88
|
+
additionalClaimFields: {
|
|
89
|
+
index: number;
|
|
90
|
+
isClaimed: boolean;
|
|
91
|
+
proof: string[];
|
|
92
|
+
};
|
|
93
|
+
};
|
|
84
94
|
export type ClaimableToken = AaveRewardsClaimableToken | AaveMeritRewardsClaimableToken | CompoundV3CompClaimableToken | SparkRewardsClaimableToken | KingRewardsClaimableToken | SparkAirdropClaimableToken | SparkWstEthRewardsClaimableToken | EthenaAirdropClaimableToken;
|
|
85
95
|
export {};
|
package/cjs/types/claiming.js
CHANGED
|
@@ -17,6 +17,8 @@ var ClaimType;
|
|
|
17
17
|
ClaimType["SPARK_AIRDROP"] = "SPARK_AIRDROP";
|
|
18
18
|
/** Spark Airdrop */
|
|
19
19
|
ClaimType["SPARK_WST_ETH_REWARDS"] = "SPARK_WST_ETH_REWARDS";
|
|
20
|
+
/** UNI Airdrop */
|
|
21
|
+
ClaimType["UNI_REWARDS"] = "UNI_REWARDS";
|
|
20
22
|
ClaimType["ETHENA_AIRDROP"] = "ETHENA_AIRDROP";
|
|
21
23
|
})(ClaimType || (exports.ClaimType = ClaimType = {}));
|
|
22
24
|
var SparkAirdropType;
|
|
@@ -212,6 +212,15 @@ export interface MorphoBluePositionData {
|
|
|
212
212
|
borrowShares: string;
|
|
213
213
|
exposure: string;
|
|
214
214
|
}
|
|
215
|
+
export interface MorphoBlueEarnData {
|
|
216
|
+
apy: string;
|
|
217
|
+
amount: string;
|
|
218
|
+
amountUsd: string;
|
|
219
|
+
}
|
|
220
|
+
export interface MorphoBlueMarketRewards {
|
|
221
|
+
supplyApy: string;
|
|
222
|
+
borrowApy: string;
|
|
223
|
+
}
|
|
215
224
|
export interface MorphoBlueVault {
|
|
216
225
|
address: string;
|
|
217
226
|
}
|
|
@@ -86,6 +86,9 @@ export interface MorphoMidnightPositionData extends MorphoMidnightAggregatedPosi
|
|
|
86
86
|
usedAssets: MMUsedAssets;
|
|
87
87
|
credit: string;
|
|
88
88
|
debt: string;
|
|
89
|
+
borrowRate: string;
|
|
90
|
+
debtBase: string;
|
|
91
|
+
debtInterest: string;
|
|
89
92
|
maturity: number;
|
|
90
93
|
isMatured: boolean;
|
|
91
94
|
}
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -53,9 +53,15 @@ export function _getAaveV3MarketData(provider_1, network_1, market_1) {
|
|
|
53
53
|
const aaveIncentivesContract = AaveIncentiveDataProviderV3ContractViem(provider, network);
|
|
54
54
|
const marketAddress = market.providerAddress;
|
|
55
55
|
const networksWithIncentives = [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Opt, NetworkNumber.Linea, NetworkNumber.Plasma];
|
|
56
|
+
// Limit each view call to 10 tokens, run chunks concurrently, then combine their results into loanInfo.
|
|
57
|
+
const addressesPerRequest = 10;
|
|
58
|
+
const addressChunks = _addresses.length > addressesPerRequest
|
|
59
|
+
? Array.from({ length: Math.ceil(_addresses.length / addressesPerRequest) }, (_, index) => _addresses.slice(index * addressesPerRequest, (index + 1) * addressesPerRequest))
|
|
60
|
+
: [_addresses];
|
|
61
|
+
const loanInfoPromise = Promise.all(addressChunks.map((addresses) => loanInfoContract.read.getFullTokensInfo([marketAddress, addresses], setViemBlockNumber(blockNumber)))).then((loanInfoChunks) => loanInfoChunks.flat());
|
|
56
62
|
// eslint-disable-next-line prefer-const
|
|
57
63
|
let [loanInfo, eModesInfo, rewardInfo, merkleRewardsMap, meritRewardsMap] = yield Promise.all([
|
|
58
|
-
|
|
64
|
+
loanInfoPromise,
|
|
59
65
|
loanInfoContract.read.getAllEmodes([marketAddress], setViemBlockNumber(blockNumber)),
|
|
60
66
|
networksWithIncentives.includes(network) ? aaveIncentivesContract.read.getReservesIncentivesData([marketAddress], setViemBlockNumber(blockNumber)) : null,
|
|
61
67
|
getMerkleCampaigns(network),
|
package/esm/aaveV4/lend.js
CHANGED
|
@@ -30,9 +30,9 @@ export const AAVE_V4_TOKENIZED_SPOKES = {
|
|
|
30
30
|
GHO_PRIME: '0x900fD46d565d1ac8995928c0179052ec02a6D0E1',
|
|
31
31
|
USDC_PRIME: '0x486415fb1F8b062c89ED548f871cf64304AACb31',
|
|
32
32
|
USDT_PRIME: '0x46c588DD8453aC259c1f6a54b4C9A93C2aC3762D',
|
|
33
|
-
USDC_PAXOS: '
|
|
34
|
-
USDT_PAXOS: '
|
|
35
|
-
PT_USDG_Sep_PAXOS: '
|
|
33
|
+
USDC_PAXOS: '0xaed7c529bD2878170B61C758DfAa215AC7a4FD07',
|
|
34
|
+
USDT_PAXOS: '0xa0e97e45C2f89003730E467Bd484fA3eEcE5B4Cf',
|
|
35
|
+
PT_USDG_Sep_PAXOS: '0x7Df10B4A01350D2A1d95cFbE7c9207d7210A2663',
|
|
36
36
|
};
|
|
37
37
|
export const AAVE_V4_TOKENIZED_SPOKE_ADDRESSES = {
|
|
38
38
|
[NetworkNumber.Eth]: Object.values(AAVE_V4_TOKENIZED_SPOKES),
|
package/esm/claiming/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import * as aaveV3Claim from './aaveV3';
|
|
|
2
2
|
import * as compV3Claim from './compV3';
|
|
3
3
|
import * as kingV3Claim from './king';
|
|
4
4
|
import * as sparkClaim from './spark';
|
|
5
|
-
|
|
5
|
+
import * as uniswapClaim from './uniswap';
|
|
6
|
+
export { aaveV3Claim, compV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
|
package/esm/claiming/index.js
CHANGED
|
@@ -2,4 +2,5 @@ import * as aaveV3Claim from './aaveV3';
|
|
|
2
2
|
import * as compV3Claim from './compV3';
|
|
3
3
|
import * as kingV3Claim from './king';
|
|
4
4
|
import * as sparkClaim from './spark';
|
|
5
|
-
|
|
5
|
+
import * as uniswapClaim from './uniswap';
|
|
6
|
+
export { aaveV3Claim, compV3Claim, kingV3Claim, sparkClaim, uniswapClaim, };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import { EthAddress, NetworkNumber } from '../types';
|
|
3
|
+
import { UniswapAirdropClaimableToken } from '../types/claiming';
|
|
4
|
+
export declare const fetchUniswapRewardsData: (walletAddress: EthAddress) => Promise<any>;
|
|
5
|
+
export declare const getUniswapRewards: (provider: Client, network: NetworkNumber, walletAddresses: EthAddress[]) => Promise<Record<string, UniswapAirdropClaimableToken[]>>;
|
|
@@ -0,0 +1,67 @@
|
|
|
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 Dec from 'decimal.js';
|
|
11
|
+
import { assetAmountInEth } from '@defisaver/tokens';
|
|
12
|
+
import { UniswapTokenDistributorViem } from '../contracts';
|
|
13
|
+
import { ClaimType } from '../types/claiming';
|
|
14
|
+
const EMPTY_DATA = (walletAddress) => ({
|
|
15
|
+
address: walletAddress, index: 0, amount: '0x0', proof: [],
|
|
16
|
+
});
|
|
17
|
+
export const fetchUniswapRewardsData = (walletAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
const res = yield fetch(`https://fe.defisaver.com/api/rewards/uniswap?user=${walletAddress}`, { signal: AbortSignal.timeout(5000) });
|
|
20
|
+
if (!res.ok)
|
|
21
|
+
throw new Error(yield res.text());
|
|
22
|
+
const data = yield res.json();
|
|
23
|
+
if (data.data.error)
|
|
24
|
+
return EMPTY_DATA(walletAddress);
|
|
25
|
+
return data.data;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return EMPTY_DATA(walletAddress);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export const getUniswapRewards = (provider, network, walletAddresses) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
// Fetch all API data in parallel (these are external API calls, can't be batched with multicall)
|
|
33
|
+
const apiDataPromises = walletAddresses.map(address => fetchUniswapRewardsData(address));
|
|
34
|
+
const apiDataArray = yield Promise.all(apiDataPromises);
|
|
35
|
+
// Batch all contract calls using multicall
|
|
36
|
+
const contract = UniswapTokenDistributorViem(provider, network);
|
|
37
|
+
const cumulativePromises = apiDataArray.map(data => (data.index ? contract.read.isClaimed([data.index]) : Promise.resolve(false)));
|
|
38
|
+
const cumulativeResults = yield Promise.all(cumulativePromises);
|
|
39
|
+
// Process results
|
|
40
|
+
const results = {};
|
|
41
|
+
for (let i = 0; i < walletAddresses.length; i++) {
|
|
42
|
+
const walletAddress = walletAddresses[i];
|
|
43
|
+
const data = apiDataArray[i];
|
|
44
|
+
const cumulative = cumulativeResults[i];
|
|
45
|
+
const amountToClaim = new Dec(data.amount);
|
|
46
|
+
if (amountToClaim.lessThanOrEqualTo('0') || cumulative) {
|
|
47
|
+
results[walletAddress.toLowerCase()] = [];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
results[walletAddress.toLowerCase()] = [{
|
|
51
|
+
symbol: 'UNI',
|
|
52
|
+
underlyingSymbol: 'UNI',
|
|
53
|
+
label: 'Uniswap Airdrop',
|
|
54
|
+
tokenAddress: '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984',
|
|
55
|
+
amount: assetAmountInEth(amountToClaim.toString(), 'UNI'),
|
|
56
|
+
walletAddress,
|
|
57
|
+
claimType: ClaimType.UNI_REWARDS,
|
|
58
|
+
additionalClaimFields: {
|
|
59
|
+
index: data.index,
|
|
60
|
+
isClaimed: cumulative,
|
|
61
|
+
proof: data.proof,
|
|
62
|
+
},
|
|
63
|
+
}];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return results;
|
|
67
|
+
});
|