@defisaver/positions-sdk 2.0.15-dev → 2.0.15-dev-2
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/aaveV2/index.js +9 -5
- package/cjs/aaveV3/index.js +50 -40
- package/cjs/aaveV3/merit.d.ts +17 -0
- package/cjs/aaveV3/merit.js +95 -0
- package/cjs/aaveV3/{rewards.d.ts → merkl.d.ts} +7 -2
- package/cjs/aaveV3/{rewards.js → merkl.js} +30 -14
- package/cjs/compoundV2/index.js +13 -7
- package/cjs/compoundV3/index.js +7 -2
- package/cjs/config/contracts.d.ts +6510 -1851
- package/cjs/config/contracts.js +33 -12
- package/cjs/contracts.d.ts +178 -0
- package/cjs/eulerV2/index.js +11 -2
- package/cjs/fluid/index.js +105 -34
- package/cjs/helpers/aaveHelpers/index.js +0 -1
- package/cjs/helpers/compoundHelpers/index.d.ts +3 -5
- package/cjs/helpers/compoundHelpers/index.js +15 -11
- package/cjs/helpers/eulerHelpers/index.d.ts +0 -5
- package/cjs/helpers/eulerHelpers/index.js +2 -31
- package/cjs/helpers/fluidHelpers/index.js +2 -0
- package/cjs/helpers/liquityV2Helpers/index.js +3 -2
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/liquityV2/index.js +10 -2
- package/cjs/llamaLend/index.js +10 -2
- package/cjs/morphoBlue/index.js +20 -6
- package/cjs/spark/index.js +20 -30
- package/cjs/staking/eligibility.d.ts +11 -0
- package/cjs/staking/eligibility.js +43 -0
- package/cjs/staking/index.d.ts +1 -0
- package/cjs/staking/index.js +1 -0
- package/cjs/staking/staking.d.ts +1 -7
- package/cjs/staking/staking.js +29 -55
- package/cjs/types/aave.d.ts +1 -7
- package/cjs/types/common.d.ts +16 -4
- package/cjs/types/common.js +10 -1
- package/cjs/types/euler.d.ts +3 -3
- package/cjs/types/fluid.d.ts +3 -5
- package/cjs/types/liquityV2.d.ts +3 -3
- package/cjs/types/llamaLend.d.ts +3 -1
- package/cjs/types/morphoBlue.d.ts +3 -5
- package/cjs/types/spark.d.ts +0 -3
- package/esm/aaveV2/index.js +9 -5
- package/esm/aaveV3/index.js +48 -38
- package/esm/aaveV3/merit.d.ts +17 -0
- package/esm/aaveV3/merit.js +90 -0
- package/esm/aaveV3/{rewards.d.ts → merkl.d.ts} +7 -2
- package/esm/aaveV3/{rewards.js → merkl.js} +28 -13
- package/esm/compoundV2/index.js +13 -7
- package/esm/compoundV3/index.js +7 -2
- package/esm/config/contracts.d.ts +6510 -1851
- package/esm/config/contracts.js +33 -12
- package/esm/contracts.d.ts +178 -0
- package/esm/eulerV2/index.js +11 -2
- package/esm/fluid/index.js +106 -35
- package/esm/helpers/aaveHelpers/index.js +0 -1
- package/esm/helpers/compoundHelpers/index.d.ts +3 -5
- package/esm/helpers/compoundHelpers/index.js +16 -12
- package/esm/helpers/eulerHelpers/index.d.ts +0 -5
- package/esm/helpers/eulerHelpers/index.js +2 -30
- package/esm/helpers/fluidHelpers/index.js +2 -0
- package/esm/helpers/liquityV2Helpers/index.js +3 -2
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/liquityV2/index.js +11 -3
- package/esm/llamaLend/index.js +11 -3
- package/esm/morphoBlue/index.js +21 -7
- package/esm/spark/index.js +21 -31
- package/esm/staking/eligibility.d.ts +11 -0
- package/esm/staking/eligibility.js +36 -0
- package/esm/staking/index.d.ts +1 -0
- package/esm/staking/index.js +1 -0
- package/esm/staking/staking.d.ts +1 -7
- package/esm/staking/staking.js +28 -53
- package/esm/types/aave.d.ts +1 -7
- package/esm/types/common.d.ts +16 -4
- package/esm/types/common.js +9 -0
- package/esm/types/euler.d.ts +3 -3
- package/esm/types/fluid.d.ts +3 -5
- package/esm/types/liquityV2.d.ts +3 -3
- package/esm/types/llamaLend.d.ts +3 -1
- package/esm/types/morphoBlue.d.ts +3 -5
- package/esm/types/spark.d.ts +0 -3
- package/package.json +47 -47
- package/src/aaveV2/index.ts +239 -236
- package/src/aaveV3/index.ts +511 -493
- package/src/aaveV3/merit.ts +98 -0
- package/src/aaveV3/{rewards.ts → merkl.ts} +141 -125
- package/src/compoundV2/index.ts +244 -240
- package/src/compoundV3/index.ts +274 -270
- package/src/config/contracts.ts +1129 -1108
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +107 -107
- package/src/curveUsd/index.ts +250 -250
- package/src/eulerV2/index.ts +324 -314
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1636 -1568
- package/src/helpers/aaveHelpers/index.ts +169 -170
- package/src/helpers/compoundHelpers/index.ts +267 -261
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -259
- package/src/helpers/fluidHelpers/index.ts +326 -324
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -80
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +390 -390
- package/src/helpers/sparkHelpers/index.ts +155 -155
- package/src/index.ts +45 -45
- package/src/liquity/index.ts +104 -104
- package/src/liquityV2/index.ts +418 -408
- package/src/llamaLend/index.ts +305 -296
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +116 -116
- package/src/markets/aave/marketAssets.ts +49 -49
- package/src/markets/compound/index.ts +227 -227
- package/src/markets/compound/marketsAssets.ts +90 -90
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2456 -2456
- 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 +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +11 -11
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoBlue/index.ts +236 -222
- package/src/portfolio/index.ts +285 -285
- package/src/services/priceService.ts +159 -159
- package/src/services/utils.ts +63 -63
- package/src/services/viem.ts +32 -32
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +444 -456
- package/src/staking/eligibility.ts +37 -0
- package/src/staking/index.ts +2 -1
- package/src/staking/staking.ts +169 -194
- package/src/types/aave.ts +189 -195
- package/src/types/common.ts +103 -88
- package/src/types/compound.ts +136 -136
- package/src/types/curveUsd.ts +121 -121
- package/src/types/euler.ts +175 -174
- package/src/types/fluid.ts +448 -450
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +159 -157
- package/src/types/maker.ts +63 -63
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/portfolio.ts +60 -60
- package/src/types/spark.ts +135 -137
package/cjs/fluid/index.js
CHANGED
|
@@ -236,12 +236,17 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
236
236
|
canBeBorrowed: false,
|
|
237
237
|
supplyRate,
|
|
238
238
|
borrowRate: '0',
|
|
239
|
+
supplyIncentives: [],
|
|
240
|
+
borrowIncentives: [],
|
|
239
241
|
};
|
|
240
242
|
if (staking_1.STAKING_ASSETS.includes(collAsset.symbol)) {
|
|
241
|
-
collAssetData.
|
|
242
|
-
|
|
243
|
+
collAssetData.supplyIncentives.push({
|
|
244
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset.symbol),
|
|
245
|
+
token: collAssetData.symbol,
|
|
246
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
247
|
+
description: `Native ${collAssetData.symbol} yield.`,
|
|
248
|
+
});
|
|
243
249
|
}
|
|
244
|
-
const incentiveSupplyRate = collAssetData.incentiveSupplyApy;
|
|
245
250
|
const debtAssetData = {
|
|
246
251
|
symbol: debtAsset.symbol,
|
|
247
252
|
address: debtAsset.address,
|
|
@@ -252,12 +257,17 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
252
257
|
canBeBorrowed: true,
|
|
253
258
|
supplyRate: '0',
|
|
254
259
|
borrowRate,
|
|
260
|
+
supplyIncentives: [],
|
|
261
|
+
borrowIncentives: [],
|
|
255
262
|
};
|
|
256
263
|
if (staking_1.STAKING_ASSETS.includes(debtAssetData.symbol)) {
|
|
257
|
-
debtAssetData.
|
|
258
|
-
|
|
264
|
+
debtAssetData.borrowIncentives.push({
|
|
265
|
+
apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(debtAsset.symbol)).mul(-1).toString(),
|
|
266
|
+
token: debtAssetData.symbol,
|
|
267
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
268
|
+
description: `Due to the native yield of ${debtAssetData.symbol}, the value of the debt would increase over time.`,
|
|
269
|
+
});
|
|
259
270
|
}
|
|
260
|
-
const incentiveBorrowRate = debtAssetData.incentiveBorrowApy;
|
|
261
271
|
const assetsData = {
|
|
262
272
|
[collAsset.symbol]: collAssetData,
|
|
263
273
|
[debtAsset.symbol]: debtAssetData,
|
|
@@ -301,8 +311,6 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
301
311
|
liquidationMaxLimit,
|
|
302
312
|
borrowRate,
|
|
303
313
|
supplyRate,
|
|
304
|
-
incentiveSupplyRate,
|
|
305
|
-
incentiveBorrowRate,
|
|
306
314
|
oraclePrice,
|
|
307
315
|
};
|
|
308
316
|
return {
|
|
@@ -311,6 +319,7 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
311
319
|
};
|
|
312
320
|
});
|
|
313
321
|
const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
322
|
+
var _a, _b, _c;
|
|
314
323
|
const collAsset0 = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
315
324
|
const collAsset1 = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken1, network);
|
|
316
325
|
const debtAsset = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
@@ -337,10 +346,16 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
337
346
|
withdrawable: withdrawable0,
|
|
338
347
|
tokenPerSupplyShare: token0PerSupplyShare,
|
|
339
348
|
supplyReserves: reservesSupplyToken0,
|
|
349
|
+
supplyIncentives: [],
|
|
350
|
+
borrowIncentives: [],
|
|
340
351
|
};
|
|
341
352
|
if (staking_1.STAKING_ASSETS.includes(collFirstAssetData.symbol)) {
|
|
342
|
-
collFirstAssetData.
|
|
343
|
-
|
|
353
|
+
collFirstAssetData.supplyIncentives.push({
|
|
354
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset0.symbol),
|
|
355
|
+
token: collAsset0.symbol,
|
|
356
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
357
|
+
description: `Native ${collAsset0.symbol} yield.`,
|
|
358
|
+
});
|
|
344
359
|
}
|
|
345
360
|
const collSecondAssetData = {
|
|
346
361
|
symbol: collAsset1.symbol,
|
|
@@ -353,13 +368,19 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
353
368
|
utilization: utilizationSupply1,
|
|
354
369
|
tokenPerSupplyShare: token1PerSupplyShare,
|
|
355
370
|
supplyReserves: reservesSupplyToken1,
|
|
371
|
+
supplyIncentives: [],
|
|
372
|
+
borrowIncentives: [],
|
|
356
373
|
};
|
|
357
374
|
if (staking_1.STAKING_ASSETS.includes(collSecondAssetData.symbol)) {
|
|
358
|
-
collSecondAssetData.
|
|
359
|
-
|
|
375
|
+
collSecondAssetData.supplyIncentives.push({
|
|
376
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset1.symbol),
|
|
377
|
+
token: collAsset1.symbol,
|
|
378
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
379
|
+
description: `Native ${collAsset1.symbol} yield.`,
|
|
380
|
+
});
|
|
360
381
|
}
|
|
361
382
|
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collFirstAssetData.price, collSecondAssetData.price);
|
|
362
|
-
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collFirstAssetData.
|
|
383
|
+
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, ((_a = collFirstAssetData.supplyIncentives[0]) === null || _a === void 0 ? void 0 : _a.apy) || '0', ((_b = collSecondAssetData.supplyIncentives[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0', collFirstAssetData.price, collSecondAssetData.price);
|
|
363
384
|
const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
|
|
364
385
|
const borrowRate = new decimal_js_1.default(data.borrowRateVault).div(100).toString();
|
|
365
386
|
const debtAssetData = {
|
|
@@ -369,12 +390,18 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
369
390
|
totalBorrow: data.totalBorrowVault.toString(),
|
|
370
391
|
canBeBorrowed: true,
|
|
371
392
|
borrowRate,
|
|
393
|
+
supplyIncentives: [],
|
|
394
|
+
borrowIncentives: [],
|
|
372
395
|
};
|
|
373
396
|
if (staking_1.STAKING_ASSETS.includes(debtAssetData.symbol)) {
|
|
374
|
-
debtAssetData.
|
|
375
|
-
|
|
397
|
+
debtAssetData.borrowIncentives.push({
|
|
398
|
+
apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(debtAsset.symbol)).mul(-1).toString(),
|
|
399
|
+
token: debtAsset.symbol,
|
|
400
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
401
|
+
description: `Due to the native yield of ${debtAsset.symbol}, the value of the debt would increase over time.`,
|
|
402
|
+
});
|
|
376
403
|
}
|
|
377
|
-
const incentiveBorrowRate = debtAssetData.
|
|
404
|
+
const incentiveBorrowRate = new decimal_js_1.default(((_c = debtAssetData.borrowIncentives[0]) === null || _c === void 0 ? void 0 : _c.apy) || '0').mul(-1).toString();
|
|
378
405
|
const assetsData = [
|
|
379
406
|
[collAsset0.symbol, collFirstAssetData],
|
|
380
407
|
[collAsset1.symbol, collSecondAssetData],
|
|
@@ -445,6 +472,7 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
445
472
|
};
|
|
446
473
|
});
|
|
447
474
|
const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
475
|
+
var _a, _b, _c, _d;
|
|
448
476
|
const collAsset = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
449
477
|
const debtAsset0 = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
450
478
|
const debtAsset1 = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken1, network);
|
|
@@ -468,12 +496,18 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
468
496
|
totalSupply: data.totalSupplyVault.toString(),
|
|
469
497
|
canBeSupplied: true,
|
|
470
498
|
supplyRate,
|
|
499
|
+
supplyIncentives: [],
|
|
500
|
+
borrowIncentives: [],
|
|
471
501
|
};
|
|
472
502
|
if (staking_1.STAKING_ASSETS.includes(collAssetData.symbol)) {
|
|
473
|
-
collAssetData.
|
|
474
|
-
|
|
503
|
+
collAssetData.supplyIncentives.push({
|
|
504
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset.symbol),
|
|
505
|
+
token: collAsset.symbol,
|
|
506
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
507
|
+
description: `Native ${collAsset.symbol} yield.`,
|
|
508
|
+
});
|
|
475
509
|
}
|
|
476
|
-
const incentiveSupplyRate = collAssetData.
|
|
510
|
+
const incentiveSupplyRate = ((_b = (_a = collAssetData.supplyIncentives) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0';
|
|
477
511
|
const debtAsset0Data = {
|
|
478
512
|
symbol: debtAsset0.symbol,
|
|
479
513
|
address: debtAsset0.address,
|
|
@@ -485,10 +519,16 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
485
519
|
utilization: utilizationBorrow0,
|
|
486
520
|
tokenPerBorrowShare: token0PerBorrowShare,
|
|
487
521
|
borrowReserves: reservesBorrowToken0,
|
|
522
|
+
supplyIncentives: [],
|
|
523
|
+
borrowIncentives: [],
|
|
488
524
|
};
|
|
489
525
|
if (staking_1.STAKING_ASSETS.includes(debtAsset0Data.symbol)) {
|
|
490
|
-
debtAsset0Data.
|
|
491
|
-
|
|
526
|
+
debtAsset0Data.borrowIncentives.push({
|
|
527
|
+
apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(debtAsset0.symbol)).mul(-1).toString(),
|
|
528
|
+
token: debtAsset0.symbol,
|
|
529
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
530
|
+
description: `Due to the native yield of ${debtAsset0.symbol}, the value of the debt would increase over time.`,
|
|
531
|
+
});
|
|
492
532
|
}
|
|
493
533
|
const debtAsset1Data = {
|
|
494
534
|
symbol: debtAsset1.symbol,
|
|
@@ -501,13 +541,19 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
501
541
|
utilization: utilizationBorrow1,
|
|
502
542
|
tokenPerBorrowShare: token1PerBorrowShare,
|
|
503
543
|
borrowReserves: reservesBorrowToken1,
|
|
544
|
+
supplyIncentives: [],
|
|
545
|
+
borrowIncentives: [],
|
|
504
546
|
};
|
|
505
547
|
if (staking_1.STAKING_ASSETS.includes(debtAsset1Data.symbol)) {
|
|
506
|
-
debtAsset1Data.
|
|
507
|
-
|
|
548
|
+
debtAsset1Data.borrowIncentives.push({
|
|
549
|
+
apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(debtAsset1.symbol)).mul(-1).toString(),
|
|
550
|
+
token: debtAsset1.symbol,
|
|
551
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
552
|
+
description: `Due to the native yield of ${debtAsset1.symbol}, the value of the debt would increase over time.`,
|
|
553
|
+
});
|
|
508
554
|
}
|
|
509
555
|
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
|
|
510
|
-
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.
|
|
556
|
+
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, new decimal_js_1.default(((_c = debtAsset0Data.borrowIncentives[0]) === null || _c === void 0 ? void 0 : _c.apy) || '0').mul(-1).toString(), new decimal_js_1.default(((_d = debtAsset1Data.borrowIncentives[0]) === null || _d === void 0 ? void 0 : _d.apy) || '0').mul(-1).toString(), debtAsset0Data.price, debtAsset1Data.price);
|
|
511
557
|
const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
|
|
512
558
|
const assetsData = [
|
|
513
559
|
[collAsset.symbol, collAssetData],
|
|
@@ -575,6 +621,7 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
575
621
|
};
|
|
576
622
|
});
|
|
577
623
|
const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaiter(void 0, [provider_1, data_1, network_1, ...args_1], void 0, function* (provider, data, network, tokenPrices = null) {
|
|
624
|
+
var _a, _b, _c, _d;
|
|
578
625
|
const collAsset0 = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
|
|
579
626
|
const collAsset1 = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken1, network);
|
|
580
627
|
const debtAsset0 = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
|
|
@@ -604,10 +651,16 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
604
651
|
withdrawable: withdrawable0,
|
|
605
652
|
tokenPerSupplyShare: token0PerSupplyShare,
|
|
606
653
|
supplyReserves: reservesSupplyToken0,
|
|
654
|
+
supplyIncentives: [],
|
|
655
|
+
borrowIncentives: [],
|
|
607
656
|
};
|
|
608
657
|
if (staking_1.STAKING_ASSETS.includes(collAsset0Data.symbol)) {
|
|
609
|
-
collAsset0Data.
|
|
610
|
-
|
|
658
|
+
collAsset0Data.supplyIncentives.push({
|
|
659
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset0.symbol),
|
|
660
|
+
token: collAsset0.symbol,
|
|
661
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
662
|
+
description: `Native ${collAsset0.symbol} yield.`,
|
|
663
|
+
});
|
|
611
664
|
}
|
|
612
665
|
const collAsset1Data = {
|
|
613
666
|
symbol: collAsset1.symbol,
|
|
@@ -620,10 +673,16 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
620
673
|
utilization: utilizationSupply1,
|
|
621
674
|
tokenPerSupplyShare: token1PerSupplyShare,
|
|
622
675
|
supplyReserves: reservesSupplyToken1,
|
|
676
|
+
supplyIncentives: [],
|
|
677
|
+
borrowIncentives: [],
|
|
623
678
|
};
|
|
624
679
|
if (staking_1.STAKING_ASSETS.includes(collAsset1Data.symbol)) {
|
|
625
|
-
collAsset1Data.
|
|
626
|
-
|
|
680
|
+
collAsset1Data.supplyIncentives.push({
|
|
681
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset1.symbol),
|
|
682
|
+
token: collAsset1.symbol,
|
|
683
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
684
|
+
description: `Native ${collAsset1.symbol} yield.`,
|
|
685
|
+
});
|
|
627
686
|
}
|
|
628
687
|
const debtAsset0Data = {
|
|
629
688
|
symbol: debtAsset0.symbol,
|
|
@@ -636,10 +695,16 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
636
695
|
utilization: utilizationBorrow0,
|
|
637
696
|
tokenPerBorrowShare: token0PerBorrowShare,
|
|
638
697
|
borrowReserves: reservesBorrowToken0,
|
|
698
|
+
supplyIncentives: [],
|
|
699
|
+
borrowIncentives: [],
|
|
639
700
|
};
|
|
640
701
|
if (staking_1.STAKING_ASSETS.includes(debtAsset0Data.symbol)) {
|
|
641
|
-
debtAsset0Data.
|
|
642
|
-
|
|
702
|
+
debtAsset0Data.borrowIncentives.push({
|
|
703
|
+
apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(debtAsset0.symbol)).mul(-1).toString(),
|
|
704
|
+
token: debtAsset0.symbol,
|
|
705
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
706
|
+
description: `Due to the native yield of ${debtAsset0.symbol}, the value of the debt would increase over time.`,
|
|
707
|
+
});
|
|
643
708
|
}
|
|
644
709
|
const debtAsset1Data = {
|
|
645
710
|
symbol: debtAsset1.symbol,
|
|
@@ -652,17 +717,23 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
652
717
|
utilization: utilizationBorrow1,
|
|
653
718
|
tokenPerBorrowShare: token1PerBorrowShare,
|
|
654
719
|
borrowReserves: reservesBorrowToken1,
|
|
720
|
+
supplyIncentives: [],
|
|
721
|
+
borrowIncentives: [],
|
|
655
722
|
};
|
|
656
723
|
if (staking_1.STAKING_ASSETS.includes(debtAsset1Data.symbol)) {
|
|
657
|
-
debtAsset1Data.
|
|
658
|
-
|
|
724
|
+
debtAsset1Data.borrowIncentives.push({
|
|
725
|
+
apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(debtAsset1.symbol)).mul(-1).toString(),
|
|
726
|
+
token: debtAsset1.symbol,
|
|
727
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
728
|
+
description: `Due to the native yield of ${debtAsset1.symbol}, the value of the debt would increase over time.`,
|
|
729
|
+
});
|
|
659
730
|
}
|
|
660
731
|
const marketInfo = (0, markets_1.getFluidMarketInfoById)(+(data.vaultId.toString()), network);
|
|
661
732
|
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
|
|
662
|
-
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.
|
|
733
|
+
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, new decimal_js_1.default(((_a = debtAsset0Data.borrowIncentives[0]) === null || _a === void 0 ? void 0 : _a.apy) || '0').mul(-1).toString(), new decimal_js_1.default(((_b = debtAsset1Data.borrowIncentives[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0').mul(-1).toString(), debtAsset0Data.price, debtAsset1Data.price);
|
|
663
734
|
const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
|
|
664
735
|
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collAsset0Data.price, collAsset1Data.price);
|
|
665
|
-
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collAsset0Data.
|
|
736
|
+
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, ((_c = collAsset0Data.supplyIncentives[0]) === null || _c === void 0 ? void 0 : _c.apy) || '0', ((_d = collAsset1Data.supplyIncentives[0]) === null || _d === void 0 ? void 0 : _d.apy) || '0', collAsset0Data.price, collAsset1Data.price);
|
|
666
737
|
const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
|
|
667
738
|
const assetsData = [
|
|
668
739
|
[collAsset0.symbol, collAsset0Data],
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { BaseAdditionalAssetData, CompoundAggregatedPositionData, CompoundMarketData, CompoundV2AssetsData, CompoundV2UsedAssets, CompoundV3AssetData, CompoundV3AssetsData, CompoundV3UsedAssets } from '../../types';
|
|
2
|
-
import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
|
|
2
|
+
import { EthAddress, EthereumProvider, IncentiveData, NetworkNumber } from '../../types/common';
|
|
3
3
|
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData;
|
|
4
4
|
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
5
5
|
export declare const getIncentiveApys: (baseData: CompoundV3AssetData & BaseAdditionalAssetData, compPrice: string) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
incentiveSupplyToken: string;
|
|
9
|
-
incentiveBorrowToken: string;
|
|
6
|
+
supplyIncentives: IncentiveData[];
|
|
7
|
+
borrowIncentives: IncentiveData[];
|
|
10
8
|
};
|
|
11
9
|
export declare const getCompoundV2AggregatedData: ({ usedAssets, assetsData, ...rest }: {
|
|
12
10
|
usedAssets: CompoundV2UsedAssets;
|
|
@@ -38,7 +38,7 @@ const formatMarketData = (data, network, baseAssetPrice) => {
|
|
|
38
38
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(data.tokenAddr, network);
|
|
39
39
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
40
40
|
const price = (0, utils_1.getEthAmountForDecimals)(data.price, 8);
|
|
41
|
-
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: new decimal_js_1.default(price).mul(baseAssetPrice).toString(), collateralFactor: (0, utils_1.getEthAmountForDecimals)(data.borrowCollateralFactor, 18), liquidationRatio: (0, utils_1.getEthAmountForDecimals)(data.liquidateCollateralFactor, 18), supplyCap: (0, utils_1.getEthAmountForDecimals)(data.supplyCap, assetInfo.decimals), totalSupply: (0, utils_1.getEthAmountForDecimals)(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: true }));
|
|
41
|
+
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: new decimal_js_1.default(price).mul(baseAssetPrice).toString(), collateralFactor: (0, utils_1.getEthAmountForDecimals)(data.borrowCollateralFactor, 18), liquidationRatio: (0, utils_1.getEthAmountForDecimals)(data.liquidateCollateralFactor, 18), supplyCap: (0, utils_1.getEthAmountForDecimals)(data.supplyCap, assetInfo.decimals), totalSupply: (0, utils_1.getEthAmountForDecimals)(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: true, supplyIncentives: [], borrowIncentives: [] }));
|
|
42
42
|
};
|
|
43
43
|
exports.formatMarketData = formatMarketData;
|
|
44
44
|
// TODO: maybe not hardcode decimals
|
|
@@ -53,16 +53,20 @@ const formatBaseData = (data, network, baseAssetPrice) => {
|
|
|
53
53
|
totalBorrow, marketLiquidity: new decimal_js_1.default(totalSupply).minus(totalBorrow).toString(), symbol: (0, utils_1.wethToEth)(assetInfo.symbol), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: true, supplyCap: '0', rewardSupplySpeed: (0, utils_1.getEthAmountForDecimals)(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: (0, utils_1.getEthAmountForDecimals)(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: (0, utils_1.getEthAmountForDecimals)(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
54
54
|
};
|
|
55
55
|
exports.formatBaseData = formatBaseData;
|
|
56
|
-
const getIncentiveApys = (baseData, compPrice) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
const getIncentiveApys = (baseData, compPrice) => ({
|
|
57
|
+
supplyIncentives: [{
|
|
58
|
+
token: 'COMP',
|
|
59
|
+
apy: (0, moneymarket_1.aprToApy)((100 * constants_1.SECONDS_PER_YEAR * +baseData.rewardSupplySpeed * +compPrice) / +baseData.price / +baseData.totalSupply).toString(),
|
|
60
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
61
|
+
description: 'Eligible for protocol-level COMP incentives.',
|
|
62
|
+
}],
|
|
63
|
+
borrowIncentives: [{
|
|
64
|
+
token: 'COMP',
|
|
65
|
+
apy: (0, moneymarket_1.aprToApy)((100 * constants_1.SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(),
|
|
66
|
+
incentiveKind: common_1.IncentiveKind.Reward,
|
|
67
|
+
description: 'Eligible for protocol-level COMP incentives.',
|
|
68
|
+
}],
|
|
69
|
+
});
|
|
66
70
|
exports.getIncentiveApys = getIncentiveApys;
|
|
67
71
|
const getCompoundV2AggregatedData = (_a) => {
|
|
68
72
|
var { usedAssets, assetsData } = _a, rest = __rest(_a, ["usedAssets", "assetsData"]);
|
|
@@ -5,11 +5,6 @@ export declare const isLeveragedPos: (usedAssets: EulerV2UsedAssets, dustLimit?:
|
|
|
5
5
|
leveragedAsset: string;
|
|
6
6
|
leveragedVault: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const calculateNetApy: (usedAssets: EulerV2UsedAssets, assetsData: EulerV2AssetsData) => {
|
|
9
|
-
netApy: string;
|
|
10
|
-
totalInterestUsd: string;
|
|
11
|
-
incentiveUsd: string;
|
|
12
|
-
};
|
|
13
8
|
export declare const getEulerV2AggregatedData: ({ usedAssets, assetsData, network, ...rest }: {
|
|
14
9
|
usedAssets: EulerV2UsedAssets;
|
|
15
10
|
assetsData: EulerV2AssetsData;
|
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getEulerV2SubAccounts = exports.getApyAfterValuesEstimationEulerV2 = exports.getEulerV2SupplyRate = exports.getUtilizationRate = exports.getEulerV2BorrowRate = exports.getEulerV2AggregatedData = exports.
|
|
26
|
+
exports.getEulerV2SubAccounts = exports.getApyAfterValuesEstimationEulerV2 = exports.getEulerV2SupplyRate = exports.getUtilizationRate = exports.getEulerV2BorrowRate = exports.getEulerV2AggregatedData = exports.isLeveragedPos = void 0;
|
|
27
27
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
28
28
|
const tokens_1 = require("@defisaver/tokens");
|
|
29
29
|
const moneymarket_1 = require("../../moneymarket");
|
|
@@ -89,35 +89,6 @@ const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
exports.isLeveragedPos = isLeveragedPos;
|
|
92
|
-
const calculateNetApy = (usedAssets, assetsData) => {
|
|
93
|
-
const sumValues = Object.values(usedAssets).reduce((_acc, usedAsset) => {
|
|
94
|
-
const acc = Object.assign({}, _acc);
|
|
95
|
-
const assetData = assetsData[usedAsset.vaultAddress.toLowerCase()];
|
|
96
|
-
if (usedAsset.isSupplied) {
|
|
97
|
-
const amount = usedAsset.suppliedUsd;
|
|
98
|
-
acc.suppliedUsd = new decimal_js_1.default(acc.suppliedUsd).add(amount).toString();
|
|
99
|
-
const rate = assetData.supplyRate;
|
|
100
|
-
const supplyInterest = (0, staking_1.calculateInterestEarned)(amount, rate, 'year', true);
|
|
101
|
-
acc.supplyInterest = new decimal_js_1.default(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
102
|
-
}
|
|
103
|
-
if (usedAsset.isBorrowed) {
|
|
104
|
-
const amount = usedAsset.borrowedUsd;
|
|
105
|
-
acc.borrowedUsd = new decimal_js_1.default(acc.borrowedUsd).add(amount).toString();
|
|
106
|
-
const rate = assetData.borrowRate;
|
|
107
|
-
const borrowInterest = (0, staking_1.calculateInterestEarned)(amount, rate, 'year', true);
|
|
108
|
-
acc.borrowInterest = new decimal_js_1.default(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
109
|
-
}
|
|
110
|
-
return acc;
|
|
111
|
-
}, {
|
|
112
|
-
borrowInterest: '0', supplyInterest: '0', incentiveUsd: '0', borrowedUsd: '0', suppliedUsd: '0',
|
|
113
|
-
});
|
|
114
|
-
const { borrowedUsd, suppliedUsd, borrowInterest, supplyInterest, incentiveUsd, } = sumValues;
|
|
115
|
-
const totalInterestUsd = new decimal_js_1.default(borrowInterest).add(supplyInterest).add(incentiveUsd).toString();
|
|
116
|
-
const balance = new decimal_js_1.default(suppliedUsd).sub(borrowedUsd);
|
|
117
|
-
const netApy = new decimal_js_1.default(totalInterestUsd).div(balance).times(100).toString();
|
|
118
|
-
return { netApy, totalInterestUsd, incentiveUsd };
|
|
119
|
-
};
|
|
120
|
-
exports.calculateNetApy = calculateNetApy;
|
|
121
92
|
const getEulerV2AggregatedData = (_a) => {
|
|
122
93
|
var { usedAssets, assetsData, network } = _a, rest = __rest(_a, ["usedAssets", "assetsData", "network"]);
|
|
123
94
|
const payload = {};
|
|
@@ -130,7 +101,7 @@ const getEulerV2AggregatedData = (_a) => {
|
|
|
130
101
|
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
131
102
|
payload.ratio = +payload.suppliedUsd ? new decimal_js_1.default(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
132
103
|
payload.collRatio = +payload.suppliedUsd ? new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
133
|
-
const { netApy, incentiveUsd, totalInterestUsd } = (0,
|
|
104
|
+
const { netApy, incentiveUsd, totalInterestUsd } = (0, staking_1.calculateNetApy)({ usedAssets, assetsData: assetsData });
|
|
134
105
|
payload.netApy = netApy;
|
|
135
106
|
payload.incentiveUsd = incentiveUsd;
|
|
136
107
|
payload.totalInterestUsd = totalInterestUsd;
|
|
@@ -183,6 +183,8 @@ const EMPTY_ASSET_DATA = {
|
|
|
183
183
|
canBeBorrowed: false,
|
|
184
184
|
supplyRate: '0',
|
|
185
185
|
borrowRate: '0',
|
|
186
|
+
supplyIncentives: [],
|
|
187
|
+
borrowIncentives: [],
|
|
186
188
|
};
|
|
187
189
|
const mergeAssetData = (existing = {}, additional) => (Object.assign(Object.assign(Object.assign({}, EMPTY_ASSET_DATA), existing), additional));
|
|
188
190
|
exports.mergeAssetData = mergeAssetData;
|
|
@@ -14,8 +14,9 @@ const calculateNetApyLiquityV2 = (usedAssets, assetsData, interestRate) => {
|
|
|
14
14
|
if (usedAsset.suppliedUsd) {
|
|
15
15
|
const amount = usedAsset.suppliedUsd;
|
|
16
16
|
acc.suppliedUsd = new decimal_js_1.default(acc.suppliedUsd).add(amount).toString();
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
18
|
+
const { apy } = supplyIncentive;
|
|
19
|
+
const incentiveInterest = (0, staking_1.calculateInterestEarned)(amount, apy, 'year', true);
|
|
19
20
|
acc.incentiveUsd = new decimal_js_1.default(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -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
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -64,6 +64,8 @@ const _getLiquityV2MarketData = (provider, network, selectedMarket) => __awaiter
|
|
|
64
64
|
canBeBorrowed: true,
|
|
65
65
|
leftToBorrowGlobal,
|
|
66
66
|
leftToWithdrawGlobal: '0',
|
|
67
|
+
supplyIncentives: [],
|
|
68
|
+
borrowIncentives: [],
|
|
67
69
|
};
|
|
68
70
|
assetsData[collateralToken] = {
|
|
69
71
|
symbol: collateralToken,
|
|
@@ -75,10 +77,16 @@ const _getLiquityV2MarketData = (provider, network, selectedMarket) => __awaiter
|
|
|
75
77
|
canBeBorrowed: false,
|
|
76
78
|
leftToBorrowGlobal: '0',
|
|
77
79
|
leftToWithdrawGlobal,
|
|
80
|
+
supplyIncentives: [],
|
|
81
|
+
borrowIncentives: [],
|
|
78
82
|
};
|
|
79
83
|
if (staking_1.STAKING_ASSETS.includes(collateralToken)) {
|
|
80
|
-
assetsData[collateralToken].
|
|
81
|
-
|
|
84
|
+
assetsData[collateralToken].supplyIncentives.push({
|
|
85
|
+
apy: yield (0, staking_1.getStakingApy)(collateralToken),
|
|
86
|
+
token: collateralToken,
|
|
87
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
88
|
+
description: `Native ${collateralToken} yield.`,
|
|
89
|
+
});
|
|
82
90
|
}
|
|
83
91
|
return {
|
|
84
92
|
assetsData,
|
package/cjs/llamaLend/index.js
CHANGED
|
@@ -95,6 +95,8 @@ const _getLlamaLendGlobalData = (provider, network, selectedMarket) => __awaiter
|
|
|
95
95
|
borrowRate,
|
|
96
96
|
canBeSupplied: true,
|
|
97
97
|
canBeBorrowed: true,
|
|
98
|
+
supplyIncentives: [],
|
|
99
|
+
borrowIncentives: [],
|
|
98
100
|
};
|
|
99
101
|
assetsData[collAsset] = {
|
|
100
102
|
symbol: collAsset,
|
|
@@ -104,10 +106,16 @@ const _getLlamaLendGlobalData = (provider, network, selectedMarket) => __awaiter
|
|
|
104
106
|
borrowRate: '0',
|
|
105
107
|
canBeSupplied: true,
|
|
106
108
|
canBeBorrowed: false,
|
|
109
|
+
supplyIncentives: [],
|
|
110
|
+
borrowIncentives: [],
|
|
107
111
|
};
|
|
108
112
|
if (staking_1.STAKING_ASSETS.includes(collAsset)) {
|
|
109
|
-
assetsData[collAsset].
|
|
110
|
-
|
|
113
|
+
assetsData[collAsset].supplyIncentives.push({
|
|
114
|
+
apy: yield (0, staking_1.getStakingApy)(collAsset),
|
|
115
|
+
token: collAsset,
|
|
116
|
+
incentiveKind: common_1.IncentiveKind.Staking,
|
|
117
|
+
description: `Native ${collAsset} yield.`,
|
|
118
|
+
});
|
|
111
119
|
}
|
|
112
120
|
return {
|
|
113
121
|
A: data.A.toString(),
|