@defisaver/positions-sdk 2.1.43-dev-stats-test-dev → 2.1.43
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +64 -64
- package/cjs/aaveV3/index.js +0 -13
- package/cjs/aaveV3/merit.js +0 -1
- package/cjs/aaveV3/merkl.js +0 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/savings/morphoVaults/index.js +17 -17
- package/cjs/savings/morphoVaults/options.js +1 -1
- package/esm/aaveV3/index.js +0 -13
- package/esm/aaveV3/merit.js +0 -1
- package/esm/aaveV3/merkl.js +0 -1
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/savings/morphoVaults/index.js +17 -17
- package/esm/savings/morphoVaults/options.js +1 -1
- package/package.json +48 -48
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +625 -634
- package/src/aaveV3/merit.ts +97 -98
- package/src/aaveV3/merkl.ts +74 -75
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/ethena.ts +61 -61
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1295 -1295
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +171 -171
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1800 -1800
- package/src/helpers/aaveHelpers/index.ts +187 -187
- package/src/helpers/compoundHelpers/index.ts +283 -283
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -222
- package/src/helpers/fluidHelpers/index.ts +326 -326
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +396 -396
- package/src/helpers/sparkHelpers/index.ts +158 -158
- package/src/index.ts +49 -49
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +118 -118
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/compound/index.ts +243 -243
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2900 -2900
- package/src/markets/index.ts +25 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +971 -971
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +85 -85
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +598 -598
- package/src/savings/index.ts +95 -95
- package/src/savings/makerDsr/index.ts +53 -53
- package/src/savings/makerDsr/options.ts +9 -9
- package/src/savings/morphoVaults/index.ts +80 -80
- package/src/savings/morphoVaults/options.ts +193 -193
- package/src/savings/skyOptions/index.ts +95 -95
- package/src/savings/skyOptions/options.ts +10 -10
- package/src/savings/sparkSavingsVaults/index.ts +60 -60
- package/src/savings/sparkSavingsVaults/options.ts +35 -35
- package/src/savings/yearnV3Vaults/index.ts +61 -61
- package/src/savings/yearnV3Vaults/options.ts +55 -55
- package/src/savings/yearnVaults/index.ts +73 -73
- package/src/savings/yearnVaults/options.ts +32 -32
- package/src/services/priceService.ts +278 -278
- package/src/services/utils.ts +115 -115
- package/src/services/viem.ts +34 -34
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +458 -458
- package/src/staking/eligibility.ts +53 -53
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +186 -186
- package/src/types/aave.ts +196 -196
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +107 -107
- package/src/types/compound.ts +144 -144
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +175 -175
- package/src/types/fluid.ts +483 -483
- package/src/types/index.ts +14 -14
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +159 -159
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +200 -200
- package/src/types/portfolio.ts +60 -60
- package/src/types/savings/index.ts +23 -23
- package/src/types/savings/makerDsr.ts +13 -13
- package/src/types/savings/morphoVaults.ts +32 -32
- package/src/types/savings/sky.ts +14 -14
- package/src/types/savings/sparkSavingsVaults.ts +15 -15
- package/src/types/savings/yearnV3Vaults.ts +17 -17
- package/src/types/savings/yearnVaults.ts +14 -14
- package/src/types/spark.ts +134 -134
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": "ts-node/register",
|
|
3
|
-
"extension": ["ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"require": "ts-node/register",
|
|
3
|
+
"extension": ["ts"]
|
|
4
|
+
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v20.17.0
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
# DeFi Saver Positions SDK
|
|
2
|
-
|
|
3
|
-
Supported protocols:
|
|
4
|
-
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
-
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
-
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
-
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
-
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
10
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
11
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
12
|
-
|
|
13
|
-
## Setup
|
|
14
|
-
Supported Node version is v10.
|
|
15
|
-
|
|
16
|
-
- run `npm install` (first time)
|
|
17
|
-
- run `npm run build`
|
|
18
|
-
|
|
19
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
20
|
-
|
|
21
|
-
## How to use
|
|
22
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
23
|
-
|
|
24
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
25
|
-
```js
|
|
26
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// every protocol has market data and user data getters
|
|
30
|
-
const {
|
|
31
|
-
getCompoundV3MarketsData,
|
|
32
|
-
getCompoundV3AccountData,
|
|
33
|
-
} = compoundV3;
|
|
34
|
-
|
|
35
|
-
const provider = 'Your RPC provider';
|
|
36
|
-
|
|
37
|
-
const user = '0x123...';
|
|
38
|
-
|
|
39
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
40
|
-
provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
41
|
-
1, // network
|
|
42
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
43
|
-
provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const userData = await getCompoundV3AccountData(
|
|
47
|
-
provider,
|
|
48
|
-
1, // network
|
|
49
|
-
userAddress, // EOA or DSProxy
|
|
50
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
51
|
-
{
|
|
52
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
53
|
-
assetsData,
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
59
|
-
|
|
60
|
-
## Testing
|
|
61
|
-
|
|
62
|
-
`npm run test` - Run all tests
|
|
63
|
-
|
|
64
|
-
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
1
|
+
# DeFi Saver Positions SDK
|
|
2
|
+
|
|
3
|
+
Supported protocols:
|
|
4
|
+
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
+
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
+
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
+
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
+
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
10
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
11
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
Supported Node version is v10.
|
|
15
|
+
|
|
16
|
+
- run `npm install` (first time)
|
|
17
|
+
- run `npm run build`
|
|
18
|
+
|
|
19
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
20
|
+
|
|
21
|
+
## How to use
|
|
22
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
23
|
+
|
|
24
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
25
|
+
```js
|
|
26
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// every protocol has market data and user data getters
|
|
30
|
+
const {
|
|
31
|
+
getCompoundV3MarketsData,
|
|
32
|
+
getCompoundV3AccountData,
|
|
33
|
+
} = compoundV3;
|
|
34
|
+
|
|
35
|
+
const provider = 'Your RPC provider';
|
|
36
|
+
|
|
37
|
+
const user = '0x123...';
|
|
38
|
+
|
|
39
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
40
|
+
provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
41
|
+
1, // network
|
|
42
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
43
|
+
provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const userData = await getCompoundV3AccountData(
|
|
47
|
+
provider,
|
|
48
|
+
1, // network
|
|
49
|
+
userAddress, // EOA or DSProxy
|
|
50
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
51
|
+
{
|
|
52
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
53
|
+
assetsData,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
59
|
+
|
|
60
|
+
## Testing
|
|
61
|
+
|
|
62
|
+
`npm run test` - Run all tests
|
|
63
|
+
|
|
64
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
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
|
@@ -68,7 +68,6 @@ const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
68
68
|
exports.fetchMeritRewardsData = fetchMeritRewardsData;
|
|
69
69
|
const getMeritCampaigns = (chainId, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
70
|
var _a;
|
|
71
|
-
console.log('Fetching Merit campaigns');
|
|
72
71
|
const meritData = yield (0, exports.fetchMeritRewardsData)();
|
|
73
72
|
const relevantCampaigns = {
|
|
74
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),
|
|
@@ -128,73 +128,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, provider, network)
|
|
|
128
128
|
});
|
|
129
129
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
130
130
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
131
|
-
const MARKET_QUERY = `
|
|
132
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
133
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
134
|
-
reallocatableLiquidityAssets
|
|
135
|
-
targetBorrowUtilization
|
|
136
|
-
loanAsset {
|
|
137
|
-
address
|
|
138
|
-
decimals
|
|
139
|
-
priceUsd
|
|
140
|
-
}
|
|
141
|
-
state {
|
|
142
|
-
liquidityAssets
|
|
143
|
-
borrowAssets
|
|
144
|
-
supplyAssets
|
|
145
|
-
}
|
|
146
|
-
publicAllocatorSharedLiquidity {
|
|
147
|
-
assets
|
|
148
|
-
vault {
|
|
149
|
-
address
|
|
150
|
-
name
|
|
151
|
-
}
|
|
152
|
-
allocationMarket {
|
|
153
|
-
uniqueKey
|
|
154
|
-
loanAsset {
|
|
155
|
-
address
|
|
156
|
-
}
|
|
157
|
-
collateralAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
irmAddress
|
|
161
|
-
oracle {
|
|
162
|
-
address
|
|
163
|
-
}
|
|
164
|
-
lltv
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
loanAsset {
|
|
168
|
-
address
|
|
169
|
-
}
|
|
170
|
-
collateralAsset {
|
|
171
|
-
address
|
|
172
|
-
}
|
|
173
|
-
oracle {
|
|
174
|
-
address
|
|
175
|
-
}
|
|
176
|
-
irmAddress
|
|
177
|
-
lltv
|
|
178
|
-
}
|
|
179
|
-
}
|
|
131
|
+
const MARKET_QUERY = `
|
|
132
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
133
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
134
|
+
reallocatableLiquidityAssets
|
|
135
|
+
targetBorrowUtilization
|
|
136
|
+
loanAsset {
|
|
137
|
+
address
|
|
138
|
+
decimals
|
|
139
|
+
priceUsd
|
|
140
|
+
}
|
|
141
|
+
state {
|
|
142
|
+
liquidityAssets
|
|
143
|
+
borrowAssets
|
|
144
|
+
supplyAssets
|
|
145
|
+
}
|
|
146
|
+
publicAllocatorSharedLiquidity {
|
|
147
|
+
assets
|
|
148
|
+
vault {
|
|
149
|
+
address
|
|
150
|
+
name
|
|
151
|
+
}
|
|
152
|
+
allocationMarket {
|
|
153
|
+
uniqueKey
|
|
154
|
+
loanAsset {
|
|
155
|
+
address
|
|
156
|
+
}
|
|
157
|
+
collateralAsset {
|
|
158
|
+
address
|
|
159
|
+
}
|
|
160
|
+
irmAddress
|
|
161
|
+
oracle {
|
|
162
|
+
address
|
|
163
|
+
}
|
|
164
|
+
lltv
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
loanAsset {
|
|
168
|
+
address
|
|
169
|
+
}
|
|
170
|
+
collateralAsset {
|
|
171
|
+
address
|
|
172
|
+
}
|
|
173
|
+
oracle {
|
|
174
|
+
address
|
|
175
|
+
}
|
|
176
|
+
irmAddress
|
|
177
|
+
lltv
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
180
|
`;
|
|
181
|
-
const REWARDS_QUERY = `
|
|
182
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
183
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
184
|
-
uniqueKey
|
|
185
|
-
state {
|
|
186
|
-
rewards {
|
|
187
|
-
amountPerSuppliedToken
|
|
188
|
-
supplyApr
|
|
189
|
-
amountPerBorrowedToken
|
|
190
|
-
borrowApr
|
|
191
|
-
asset {
|
|
192
|
-
address
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
181
|
+
const REWARDS_QUERY = `
|
|
182
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
183
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
184
|
+
uniqueKey
|
|
185
|
+
state {
|
|
186
|
+
rewards {
|
|
187
|
+
amountPerSuppliedToken
|
|
188
|
+
supplyApr
|
|
189
|
+
amountPerBorrowedToken
|
|
190
|
+
borrowApr
|
|
191
|
+
asset {
|
|
192
|
+
address
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
198
|
`;
|
|
199
199
|
/**
|
|
200
200
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -54,23 +54,23 @@ const morphoVaultsOptions = __importStar(require("./options"));
|
|
|
54
54
|
exports.morphoVaultsOptions = morphoVaultsOptions;
|
|
55
55
|
const viem_1 = require("../../services/viem");
|
|
56
56
|
const contracts_1 = require("../../contracts");
|
|
57
|
-
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
58
|
-
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
59
|
-
id,
|
|
60
|
-
dailyApy,
|
|
61
|
-
dailyApys {
|
|
62
|
-
apy, netApy
|
|
63
|
-
},
|
|
64
|
-
monthlyApys {
|
|
65
|
-
apy, netApy
|
|
66
|
-
},
|
|
67
|
-
liquidity {
|
|
68
|
-
underlying, usd,
|
|
69
|
-
},
|
|
70
|
-
asset {
|
|
71
|
-
priceUsd
|
|
72
|
-
}
|
|
73
|
-
}
|
|
57
|
+
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
58
|
+
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
59
|
+
id,
|
|
60
|
+
dailyApy,
|
|
61
|
+
dailyApys {
|
|
62
|
+
apy, netApy
|
|
63
|
+
},
|
|
64
|
+
monthlyApys {
|
|
65
|
+
apy, netApy
|
|
66
|
+
},
|
|
67
|
+
liquidity {
|
|
68
|
+
underlying, usd,
|
|
69
|
+
},
|
|
70
|
+
asset {
|
|
71
|
+
priceUsd
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
74
|
}`;
|
|
75
75
|
const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
|
|
76
76
|
const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -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/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
|
@@ -64,7 +64,6 @@ export const fetchMeritRewardsData = () => __awaiter(void 0, void 0, void 0, fun
|
|
|
64
64
|
});
|
|
65
65
|
export const getMeritCampaigns = (chainId, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
66
|
var _a;
|
|
67
|
-
console.log('Fetching Merit campaigns');
|
|
68
67
|
const meritData = yield fetchMeritRewardsData();
|
|
69
68
|
const relevantCampaigns = {
|
|
70
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),
|