@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/esm/fluid/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress, } from '@defisaver/tokens';
|
|
12
|
-
import { NetworkNumber } from '../types/common';
|
|
12
|
+
import { IncentiveKind, NetworkNumber, } from '../types/common';
|
|
13
13
|
import { FluidVaultType, } from '../types';
|
|
14
14
|
import { BTCPriceFeedContractViem, DFSFeedRegistryContractViem, ETHPriceFeedContractViem, FeedRegistryContractViem, FluidViewContractViem, } from '../contracts';
|
|
15
15
|
import { compareAddresses, DEFAULT_TIMEOUT, getEthAmountForDecimals, isMainnetNetwork, } from '../services/utils';
|
|
@@ -230,12 +230,17 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
230
230
|
canBeBorrowed: false,
|
|
231
231
|
supplyRate,
|
|
232
232
|
borrowRate: '0',
|
|
233
|
+
supplyIncentives: [],
|
|
234
|
+
borrowIncentives: [],
|
|
233
235
|
};
|
|
234
236
|
if (STAKING_ASSETS.includes(collAsset.symbol)) {
|
|
235
|
-
collAssetData.
|
|
236
|
-
|
|
237
|
+
collAssetData.supplyIncentives.push({
|
|
238
|
+
apy: yield getStakingApy(collAsset.symbol),
|
|
239
|
+
token: collAssetData.symbol,
|
|
240
|
+
incentiveKind: IncentiveKind.Staking,
|
|
241
|
+
description: `Native ${collAssetData.symbol} yield.`,
|
|
242
|
+
});
|
|
237
243
|
}
|
|
238
|
-
const incentiveSupplyRate = collAssetData.incentiveSupplyApy;
|
|
239
244
|
const debtAssetData = {
|
|
240
245
|
symbol: debtAsset.symbol,
|
|
241
246
|
address: debtAsset.address,
|
|
@@ -246,12 +251,17 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
246
251
|
canBeBorrowed: true,
|
|
247
252
|
supplyRate: '0',
|
|
248
253
|
borrowRate,
|
|
254
|
+
supplyIncentives: [],
|
|
255
|
+
borrowIncentives: [],
|
|
249
256
|
};
|
|
250
257
|
if (STAKING_ASSETS.includes(debtAssetData.symbol)) {
|
|
251
|
-
debtAssetData.
|
|
252
|
-
|
|
258
|
+
debtAssetData.borrowIncentives.push({
|
|
259
|
+
apy: new Dec(yield getStakingApy(debtAsset.symbol)).mul(-1).toString(),
|
|
260
|
+
token: debtAssetData.symbol,
|
|
261
|
+
incentiveKind: IncentiveKind.Reward,
|
|
262
|
+
description: `Due to the native yield of ${debtAssetData.symbol}, the value of the debt would increase over time.`,
|
|
263
|
+
});
|
|
253
264
|
}
|
|
254
|
-
const incentiveBorrowRate = debtAssetData.incentiveBorrowApy;
|
|
255
265
|
const assetsData = {
|
|
256
266
|
[collAsset.symbol]: collAssetData,
|
|
257
267
|
[debtAsset.symbol]: debtAssetData,
|
|
@@ -295,8 +305,6 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
295
305
|
liquidationMaxLimit,
|
|
296
306
|
borrowRate,
|
|
297
307
|
supplyRate,
|
|
298
|
-
incentiveSupplyRate,
|
|
299
|
-
incentiveBorrowRate,
|
|
300
308
|
oraclePrice,
|
|
301
309
|
};
|
|
302
310
|
return {
|
|
@@ -305,6 +313,7 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
305
313
|
};
|
|
306
314
|
});
|
|
307
315
|
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) {
|
|
316
|
+
var _a, _b, _c;
|
|
308
317
|
const collAsset0 = getAssetInfoByAddress(data.supplyToken0, network);
|
|
309
318
|
const collAsset1 = getAssetInfoByAddress(data.supplyToken1, network);
|
|
310
319
|
const debtAsset = getAssetInfoByAddress(data.borrowToken0, network);
|
|
@@ -331,10 +340,16 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
331
340
|
withdrawable: withdrawable0,
|
|
332
341
|
tokenPerSupplyShare: token0PerSupplyShare,
|
|
333
342
|
supplyReserves: reservesSupplyToken0,
|
|
343
|
+
supplyIncentives: [],
|
|
344
|
+
borrowIncentives: [],
|
|
334
345
|
};
|
|
335
346
|
if (STAKING_ASSETS.includes(collFirstAssetData.symbol)) {
|
|
336
|
-
collFirstAssetData.
|
|
337
|
-
|
|
347
|
+
collFirstAssetData.supplyIncentives.push({
|
|
348
|
+
apy: yield getStakingApy(collAsset0.symbol),
|
|
349
|
+
token: collAsset0.symbol,
|
|
350
|
+
incentiveKind: IncentiveKind.Staking,
|
|
351
|
+
description: `Native ${collAsset0.symbol} yield.`,
|
|
352
|
+
});
|
|
338
353
|
}
|
|
339
354
|
const collSecondAssetData = {
|
|
340
355
|
symbol: collAsset1.symbol,
|
|
@@ -347,13 +362,19 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
347
362
|
utilization: utilizationSupply1,
|
|
348
363
|
tokenPerSupplyShare: token1PerSupplyShare,
|
|
349
364
|
supplyReserves: reservesSupplyToken1,
|
|
365
|
+
supplyIncentives: [],
|
|
366
|
+
borrowIncentives: [],
|
|
350
367
|
};
|
|
351
368
|
if (STAKING_ASSETS.includes(collSecondAssetData.symbol)) {
|
|
352
|
-
collSecondAssetData.
|
|
353
|
-
|
|
369
|
+
collSecondAssetData.supplyIncentives.push({
|
|
370
|
+
apy: yield getStakingApy(collAsset1.symbol),
|
|
371
|
+
token: collAsset1.symbol,
|
|
372
|
+
incentiveKind: IncentiveKind.Staking,
|
|
373
|
+
description: `Native ${collAsset1.symbol} yield.`,
|
|
374
|
+
});
|
|
354
375
|
}
|
|
355
376
|
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collFirstAssetData.price, collSecondAssetData.price);
|
|
356
|
-
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collFirstAssetData.
|
|
377
|
+
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);
|
|
357
378
|
const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
|
|
358
379
|
const borrowRate = new Dec(data.borrowRateVault).div(100).toString();
|
|
359
380
|
const debtAssetData = {
|
|
@@ -363,12 +384,18 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
363
384
|
totalBorrow: data.totalBorrowVault.toString(),
|
|
364
385
|
canBeBorrowed: true,
|
|
365
386
|
borrowRate,
|
|
387
|
+
supplyIncentives: [],
|
|
388
|
+
borrowIncentives: [],
|
|
366
389
|
};
|
|
367
390
|
if (STAKING_ASSETS.includes(debtAssetData.symbol)) {
|
|
368
|
-
debtAssetData.
|
|
369
|
-
|
|
391
|
+
debtAssetData.borrowIncentives.push({
|
|
392
|
+
apy: new Dec(yield getStakingApy(debtAsset.symbol)).mul(-1).toString(),
|
|
393
|
+
token: debtAsset.symbol,
|
|
394
|
+
incentiveKind: IncentiveKind.Reward,
|
|
395
|
+
description: `Due to the native yield of ${debtAsset.symbol}, the value of the debt would increase over time.`,
|
|
396
|
+
});
|
|
370
397
|
}
|
|
371
|
-
const incentiveBorrowRate = debtAssetData.
|
|
398
|
+
const incentiveBorrowRate = new Dec(((_c = debtAssetData.borrowIncentives[0]) === null || _c === void 0 ? void 0 : _c.apy) || '0').mul(-1).toString();
|
|
372
399
|
const assetsData = [
|
|
373
400
|
[collAsset0.symbol, collFirstAssetData],
|
|
374
401
|
[collAsset1.symbol, collSecondAssetData],
|
|
@@ -439,6 +466,7 @@ const parseT2MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
439
466
|
};
|
|
440
467
|
});
|
|
441
468
|
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) {
|
|
469
|
+
var _a, _b, _c, _d;
|
|
442
470
|
const collAsset = getAssetInfoByAddress(data.supplyToken0, network);
|
|
443
471
|
const debtAsset0 = getAssetInfoByAddress(data.borrowToken0, network);
|
|
444
472
|
const debtAsset1 = getAssetInfoByAddress(data.borrowToken1, network);
|
|
@@ -462,12 +490,18 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
462
490
|
totalSupply: data.totalSupplyVault.toString(),
|
|
463
491
|
canBeSupplied: true,
|
|
464
492
|
supplyRate,
|
|
493
|
+
supplyIncentives: [],
|
|
494
|
+
borrowIncentives: [],
|
|
465
495
|
};
|
|
466
496
|
if (STAKING_ASSETS.includes(collAssetData.symbol)) {
|
|
467
|
-
collAssetData.
|
|
468
|
-
|
|
497
|
+
collAssetData.supplyIncentives.push({
|
|
498
|
+
apy: yield getStakingApy(collAsset.symbol),
|
|
499
|
+
token: collAsset.symbol,
|
|
500
|
+
incentiveKind: IncentiveKind.Staking,
|
|
501
|
+
description: `Native ${collAsset.symbol} yield.`,
|
|
502
|
+
});
|
|
469
503
|
}
|
|
470
|
-
const incentiveSupplyRate = collAssetData.
|
|
504
|
+
const incentiveSupplyRate = ((_b = (_a = collAssetData.supplyIncentives) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0';
|
|
471
505
|
const debtAsset0Data = {
|
|
472
506
|
symbol: debtAsset0.symbol,
|
|
473
507
|
address: debtAsset0.address,
|
|
@@ -479,10 +513,16 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
479
513
|
utilization: utilizationBorrow0,
|
|
480
514
|
tokenPerBorrowShare: token0PerBorrowShare,
|
|
481
515
|
borrowReserves: reservesBorrowToken0,
|
|
516
|
+
supplyIncentives: [],
|
|
517
|
+
borrowIncentives: [],
|
|
482
518
|
};
|
|
483
519
|
if (STAKING_ASSETS.includes(debtAsset0Data.symbol)) {
|
|
484
|
-
debtAsset0Data.
|
|
485
|
-
|
|
520
|
+
debtAsset0Data.borrowIncentives.push({
|
|
521
|
+
apy: new Dec(yield getStakingApy(debtAsset0.symbol)).mul(-1).toString(),
|
|
522
|
+
token: debtAsset0.symbol,
|
|
523
|
+
incentiveKind: IncentiveKind.Reward,
|
|
524
|
+
description: `Due to the native yield of ${debtAsset0.symbol}, the value of the debt would increase over time.`,
|
|
525
|
+
});
|
|
486
526
|
}
|
|
487
527
|
const debtAsset1Data = {
|
|
488
528
|
symbol: debtAsset1.symbol,
|
|
@@ -495,13 +535,19 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
495
535
|
utilization: utilizationBorrow1,
|
|
496
536
|
tokenPerBorrowShare: token1PerBorrowShare,
|
|
497
537
|
borrowReserves: reservesBorrowToken1,
|
|
538
|
+
supplyIncentives: [],
|
|
539
|
+
borrowIncentives: [],
|
|
498
540
|
};
|
|
499
541
|
if (STAKING_ASSETS.includes(debtAsset1Data.symbol)) {
|
|
500
|
-
debtAsset1Data.
|
|
501
|
-
|
|
542
|
+
debtAsset1Data.borrowIncentives.push({
|
|
543
|
+
apy: new Dec(yield getStakingApy(debtAsset1.symbol)).mul(-1).toString(),
|
|
544
|
+
token: debtAsset1.symbol,
|
|
545
|
+
incentiveKind: IncentiveKind.Reward,
|
|
546
|
+
description: `Due to the native yield of ${debtAsset1.symbol}, the value of the debt would increase over time.`,
|
|
547
|
+
});
|
|
502
548
|
}
|
|
503
549
|
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
|
|
504
|
-
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.
|
|
550
|
+
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, new Dec(((_c = debtAsset0Data.borrowIncentives[0]) === null || _c === void 0 ? void 0 : _c.apy) || '0').mul(-1).toString(), new Dec(((_d = debtAsset1Data.borrowIncentives[0]) === null || _d === void 0 ? void 0 : _d.apy) || '0').mul(-1).toString(), debtAsset0Data.price, debtAsset1Data.price);
|
|
505
551
|
const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
|
|
506
552
|
const assetsData = [
|
|
507
553
|
[collAsset.symbol, collAssetData],
|
|
@@ -569,6 +615,7 @@ const parseT3MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
569
615
|
};
|
|
570
616
|
});
|
|
571
617
|
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) {
|
|
618
|
+
var _a, _b, _c, _d;
|
|
572
619
|
const collAsset0 = getAssetInfoByAddress(data.supplyToken0, network);
|
|
573
620
|
const collAsset1 = getAssetInfoByAddress(data.supplyToken1, network);
|
|
574
621
|
const debtAsset0 = getAssetInfoByAddress(data.borrowToken0, network);
|
|
@@ -598,10 +645,16 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
598
645
|
withdrawable: withdrawable0,
|
|
599
646
|
tokenPerSupplyShare: token0PerSupplyShare,
|
|
600
647
|
supplyReserves: reservesSupplyToken0,
|
|
648
|
+
supplyIncentives: [],
|
|
649
|
+
borrowIncentives: [],
|
|
601
650
|
};
|
|
602
651
|
if (STAKING_ASSETS.includes(collAsset0Data.symbol)) {
|
|
603
|
-
collAsset0Data.
|
|
604
|
-
|
|
652
|
+
collAsset0Data.supplyIncentives.push({
|
|
653
|
+
apy: yield getStakingApy(collAsset0.symbol),
|
|
654
|
+
token: collAsset0.symbol,
|
|
655
|
+
incentiveKind: IncentiveKind.Staking,
|
|
656
|
+
description: `Native ${collAsset0.symbol} yield.`,
|
|
657
|
+
});
|
|
605
658
|
}
|
|
606
659
|
const collAsset1Data = {
|
|
607
660
|
symbol: collAsset1.symbol,
|
|
@@ -614,10 +667,16 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
614
667
|
utilization: utilizationSupply1,
|
|
615
668
|
tokenPerSupplyShare: token1PerSupplyShare,
|
|
616
669
|
supplyReserves: reservesSupplyToken1,
|
|
670
|
+
supplyIncentives: [],
|
|
671
|
+
borrowIncentives: [],
|
|
617
672
|
};
|
|
618
673
|
if (STAKING_ASSETS.includes(collAsset1Data.symbol)) {
|
|
619
|
-
collAsset1Data.
|
|
620
|
-
|
|
674
|
+
collAsset1Data.supplyIncentives.push({
|
|
675
|
+
apy: yield getStakingApy(collAsset1.symbol),
|
|
676
|
+
token: collAsset1.symbol,
|
|
677
|
+
incentiveKind: IncentiveKind.Staking,
|
|
678
|
+
description: `Native ${collAsset1.symbol} yield.`,
|
|
679
|
+
});
|
|
621
680
|
}
|
|
622
681
|
const debtAsset0Data = {
|
|
623
682
|
symbol: debtAsset0.symbol,
|
|
@@ -630,10 +689,16 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
630
689
|
utilization: utilizationBorrow0,
|
|
631
690
|
tokenPerBorrowShare: token0PerBorrowShare,
|
|
632
691
|
borrowReserves: reservesBorrowToken0,
|
|
692
|
+
supplyIncentives: [],
|
|
693
|
+
borrowIncentives: [],
|
|
633
694
|
};
|
|
634
695
|
if (STAKING_ASSETS.includes(debtAsset0Data.symbol)) {
|
|
635
|
-
debtAsset0Data.
|
|
636
|
-
|
|
696
|
+
debtAsset0Data.borrowIncentives.push({
|
|
697
|
+
apy: new Dec(yield getStakingApy(debtAsset0.symbol)).mul(-1).toString(),
|
|
698
|
+
token: debtAsset0.symbol,
|
|
699
|
+
incentiveKind: IncentiveKind.Reward,
|
|
700
|
+
description: `Due to the native yield of ${debtAsset0.symbol}, the value of the debt would increase over time.`,
|
|
701
|
+
});
|
|
637
702
|
}
|
|
638
703
|
const debtAsset1Data = {
|
|
639
704
|
symbol: debtAsset1.symbol,
|
|
@@ -646,17 +711,23 @@ const parseT4MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
|
|
|
646
711
|
utilization: utilizationBorrow1,
|
|
647
712
|
tokenPerBorrowShare: token1PerBorrowShare,
|
|
648
713
|
borrowReserves: reservesBorrowToken1,
|
|
714
|
+
supplyIncentives: [],
|
|
715
|
+
borrowIncentives: [],
|
|
649
716
|
};
|
|
650
717
|
if (STAKING_ASSETS.includes(debtAsset1Data.symbol)) {
|
|
651
|
-
debtAsset1Data.
|
|
652
|
-
|
|
718
|
+
debtAsset1Data.borrowIncentives.push({
|
|
719
|
+
apy: new Dec(yield getStakingApy(debtAsset1.symbol)).mul(-1).toString(),
|
|
720
|
+
token: debtAsset1.symbol,
|
|
721
|
+
incentiveKind: IncentiveKind.Reward,
|
|
722
|
+
description: `Due to the native yield of ${debtAsset1.symbol}, the value of the debt would increase over time.`,
|
|
723
|
+
});
|
|
653
724
|
}
|
|
654
725
|
const marketInfo = getFluidMarketInfoById(+(data.vaultId.toString()), network);
|
|
655
726
|
const marketBorrowRate = getMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, borrowRate0, borrowRate1, debtAsset0Data.price, debtAsset1Data.price);
|
|
656
|
-
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, debtAsset0Data.
|
|
727
|
+
const incentiveBorrowRate = getAdditionalMarketRateForDex(token1PerBorrowShare, token0PerBorrowShare, new Dec(((_a = debtAsset0Data.borrowIncentives[0]) === null || _a === void 0 ? void 0 : _a.apy) || '0').mul(-1).toString(), new Dec(((_b = debtAsset1Data.borrowIncentives[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0').mul(-1).toString(), debtAsset0Data.price, debtAsset1Data.price);
|
|
657
728
|
const tradingBorrowRate = yield getTradingApy(data.dexBorrowData.dexPool);
|
|
658
729
|
const marketSupplyRate = getMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, supplyRate0, supplyRate1, collAsset0Data.price, collAsset1Data.price);
|
|
659
|
-
const incentiveSupplyRate = getAdditionalMarketRateForDex(token1PerSupplyShare, token0PerSupplyShare, collAsset0Data.
|
|
730
|
+
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);
|
|
660
731
|
const tradingSupplyRate = yield getTradingApy(data.dexSupplyData.dexPool);
|
|
661
732
|
const assetsData = [
|
|
662
733
|
[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;
|
|
@@ -25,14 +25,14 @@ import { getEthAmountForDecimals, handleWbtcLegacy, wethToEth } from '../../serv
|
|
|
25
25
|
import { BLOCKS_IN_A_YEAR, borrowOperations, SECONDS_PER_YEAR } from '../../constants';
|
|
26
26
|
import { aprToApy, calcLeverageLiqPrice, calculateBorrowingAssetLimit, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
|
|
27
27
|
import { calculateNetApy } from '../../staking';
|
|
28
|
-
import { NetworkNumber } from '../../types/common';
|
|
28
|
+
import { IncentiveKind, NetworkNumber, } from '../../types/common';
|
|
29
29
|
import { CompoundLoanInfoContractViem, CompV3ViewContractViem } from '../../contracts';
|
|
30
30
|
import { getViemProvider } from '../../services/viem';
|
|
31
31
|
export const formatMarketData = (data, network, baseAssetPrice) => {
|
|
32
32
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
33
33
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
34
34
|
const price = getEthAmountForDecimals(data.price, 8);
|
|
35
|
-
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: true }));
|
|
35
|
+
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: true, supplyIncentives: [], borrowIncentives: [] }));
|
|
36
36
|
};
|
|
37
37
|
// TODO: maybe not hardcode decimals
|
|
38
38
|
export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
@@ -45,16 +45,20 @@ export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
|
45
45
|
totalSupply,
|
|
46
46
|
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: true, supplyCap: '0', rewardSupplySpeed: getEthAmountForDecimals(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: getEthAmountForDecimals(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: getEthAmountForDecimals(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
47
47
|
};
|
|
48
|
-
export const getIncentiveApys = (baseData, compPrice) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
export const getIncentiveApys = (baseData, compPrice) => ({
|
|
49
|
+
supplyIncentives: [{
|
|
50
|
+
token: 'COMP',
|
|
51
|
+
apy: aprToApy((100 * SECONDS_PER_YEAR * +baseData.rewardSupplySpeed * +compPrice) / +baseData.price / +baseData.totalSupply).toString(),
|
|
52
|
+
incentiveKind: IncentiveKind.Reward,
|
|
53
|
+
description: 'Eligible for protocol-level COMP incentives.',
|
|
54
|
+
}],
|
|
55
|
+
borrowIncentives: [{
|
|
56
|
+
token: 'COMP',
|
|
57
|
+
apy: aprToApy((100 * SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(),
|
|
58
|
+
incentiveKind: IncentiveKind.Reward,
|
|
59
|
+
description: 'Eligible for protocol-level COMP incentives.',
|
|
60
|
+
}],
|
|
61
|
+
});
|
|
58
62
|
export const getCompoundV2AggregatedData = (_a) => {
|
|
59
63
|
var { usedAssets, assetsData } = _a, rest = __rest(_a, ["usedAssets", "assetsData"]);
|
|
60
64
|
const payload = {};
|
|
@@ -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;
|
|
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
import Dec from 'decimal.js';
|
|
22
22
|
import { assetAmountInWei } from '@defisaver/tokens';
|
|
23
23
|
import { calcLeverageLiqPrice, getAssetsTotal, STABLE_ASSETS, } from '../../moneymarket';
|
|
24
|
-
import {
|
|
24
|
+
import { calculateNetApy } from '../../staking';
|
|
25
25
|
import { EulerV2ViewContractViem } from '../../contracts';
|
|
26
26
|
import { borrowOperations } from '../../constants';
|
|
27
27
|
import { getViemProvider } from '../../services/viem';
|
|
@@ -82,34 +82,6 @@ export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
|
82
82
|
leveragedVault: '',
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
export const calculateNetApy = (usedAssets, assetsData) => {
|
|
86
|
-
const sumValues = Object.values(usedAssets).reduce((_acc, usedAsset) => {
|
|
87
|
-
const acc = Object.assign({}, _acc);
|
|
88
|
-
const assetData = assetsData[usedAsset.vaultAddress.toLowerCase()];
|
|
89
|
-
if (usedAsset.isSupplied) {
|
|
90
|
-
const amount = usedAsset.suppliedUsd;
|
|
91
|
-
acc.suppliedUsd = new Dec(acc.suppliedUsd).add(amount).toString();
|
|
92
|
-
const rate = assetData.supplyRate;
|
|
93
|
-
const supplyInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
94
|
-
acc.supplyInterest = new Dec(acc.supplyInterest).add(supplyInterest.toString()).toString();
|
|
95
|
-
}
|
|
96
|
-
if (usedAsset.isBorrowed) {
|
|
97
|
-
const amount = usedAsset.borrowedUsd;
|
|
98
|
-
acc.borrowedUsd = new Dec(acc.borrowedUsd).add(amount).toString();
|
|
99
|
-
const rate = assetData.borrowRate;
|
|
100
|
-
const borrowInterest = calculateInterestEarned(amount, rate, 'year', true);
|
|
101
|
-
acc.borrowInterest = new Dec(acc.borrowInterest).sub(borrowInterest.toString()).toString();
|
|
102
|
-
}
|
|
103
|
-
return acc;
|
|
104
|
-
}, {
|
|
105
|
-
borrowInterest: '0', supplyInterest: '0', incentiveUsd: '0', borrowedUsd: '0', suppliedUsd: '0',
|
|
106
|
-
});
|
|
107
|
-
const { borrowedUsd, suppliedUsd, borrowInterest, supplyInterest, incentiveUsd, } = sumValues;
|
|
108
|
-
const totalInterestUsd = new Dec(borrowInterest).add(supplyInterest).add(incentiveUsd).toString();
|
|
109
|
-
const balance = new Dec(suppliedUsd).sub(borrowedUsd);
|
|
110
|
-
const netApy = new Dec(totalInterestUsd).div(balance).times(100).toString();
|
|
111
|
-
return { netApy, totalInterestUsd, incentiveUsd };
|
|
112
|
-
};
|
|
113
85
|
export const getEulerV2AggregatedData = (_a) => {
|
|
114
86
|
var { usedAssets, assetsData, network } = _a, rest = __rest(_a, ["usedAssets", "assetsData", "network"]);
|
|
115
87
|
const payload = {};
|
|
@@ -122,7 +94,7 @@ export const getEulerV2AggregatedData = (_a) => {
|
|
|
122
94
|
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
123
95
|
payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
124
96
|
payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedCollateralUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
|
|
125
|
-
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy(usedAssets, assetsData);
|
|
97
|
+
const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({ usedAssets, assetsData: assetsData });
|
|
126
98
|
payload.netApy = netApy;
|
|
127
99
|
payload.incentiveUsd = incentiveUsd;
|
|
128
100
|
payload.totalInterestUsd = totalInterestUsd;
|
|
@@ -174,6 +174,8 @@ const EMPTY_ASSET_DATA = {
|
|
|
174
174
|
canBeBorrowed: false,
|
|
175
175
|
supplyRate: '0',
|
|
176
176
|
borrowRate: '0',
|
|
177
|
+
supplyIncentives: [],
|
|
178
|
+
borrowIncentives: [],
|
|
177
179
|
};
|
|
178
180
|
export const mergeAssetData = (existing = {}, additional) => (Object.assign(Object.assign(Object.assign({}, EMPTY_ASSET_DATA), existing), additional));
|
|
179
181
|
export const EMPTY_USED_ASSET = {
|
|
@@ -8,8 +8,9 @@ export const calculateNetApyLiquityV2 = (usedAssets, assetsData, interestRate) =
|
|
|
8
8
|
if (usedAsset.suppliedUsd) {
|
|
9
9
|
const amount = usedAsset.suppliedUsd;
|
|
10
10
|
acc.suppliedUsd = new Dec(acc.suppliedUsd).add(amount).toString();
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
for (const supplyIncentive of assetData.supplyIncentives) {
|
|
12
|
+
const { apy } = supplyIncentive;
|
|
13
|
+
const incentiveInterest = calculateInterestEarned(amount, apy, 'year', true);
|
|
13
14
|
acc.incentiveUsd = new Dec(acc.incentiveUsd).add(incentiveInterest).toString();
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -118,73 +118,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, provider, n
|
|
|
118
118
|
return { borrowRate, supplyRate };
|
|
119
119
|
});
|
|
120
120
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
121
|
-
const MARKET_QUERY = `
|
|
122
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
123
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
124
|
-
reallocatableLiquidityAssets
|
|
125
|
-
targetBorrowUtilization
|
|
126
|
-
loanAsset {
|
|
127
|
-
address
|
|
128
|
-
decimals
|
|
129
|
-
priceUsd
|
|
130
|
-
}
|
|
131
|
-
state {
|
|
132
|
-
liquidityAssets
|
|
133
|
-
borrowAssets
|
|
134
|
-
supplyAssets
|
|
135
|
-
}
|
|
136
|
-
publicAllocatorSharedLiquidity {
|
|
137
|
-
assets
|
|
138
|
-
vault {
|
|
139
|
-
address
|
|
140
|
-
name
|
|
141
|
-
}
|
|
142
|
-
allocationMarket {
|
|
143
|
-
uniqueKey
|
|
144
|
-
loanAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
collateralAsset {
|
|
148
|
-
address
|
|
149
|
-
}
|
|
150
|
-
irmAddress
|
|
151
|
-
oracle {
|
|
152
|
-
address
|
|
153
|
-
}
|
|
154
|
-
lltv
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
loanAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
collateralAsset {
|
|
161
|
-
address
|
|
162
|
-
}
|
|
163
|
-
oracle {
|
|
164
|
-
address
|
|
165
|
-
}
|
|
166
|
-
irmAddress
|
|
167
|
-
lltv
|
|
168
|
-
}
|
|
169
|
-
}
|
|
121
|
+
const MARKET_QUERY = `
|
|
122
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
123
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
124
|
+
reallocatableLiquidityAssets
|
|
125
|
+
targetBorrowUtilization
|
|
126
|
+
loanAsset {
|
|
127
|
+
address
|
|
128
|
+
decimals
|
|
129
|
+
priceUsd
|
|
130
|
+
}
|
|
131
|
+
state {
|
|
132
|
+
liquidityAssets
|
|
133
|
+
borrowAssets
|
|
134
|
+
supplyAssets
|
|
135
|
+
}
|
|
136
|
+
publicAllocatorSharedLiquidity {
|
|
137
|
+
assets
|
|
138
|
+
vault {
|
|
139
|
+
address
|
|
140
|
+
name
|
|
141
|
+
}
|
|
142
|
+
allocationMarket {
|
|
143
|
+
uniqueKey
|
|
144
|
+
loanAsset {
|
|
145
|
+
address
|
|
146
|
+
}
|
|
147
|
+
collateralAsset {
|
|
148
|
+
address
|
|
149
|
+
}
|
|
150
|
+
irmAddress
|
|
151
|
+
oracle {
|
|
152
|
+
address
|
|
153
|
+
}
|
|
154
|
+
lltv
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
loanAsset {
|
|
158
|
+
address
|
|
159
|
+
}
|
|
160
|
+
collateralAsset {
|
|
161
|
+
address
|
|
162
|
+
}
|
|
163
|
+
oracle {
|
|
164
|
+
address
|
|
165
|
+
}
|
|
166
|
+
irmAddress
|
|
167
|
+
lltv
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
170
|
`;
|
|
171
|
-
const REWARDS_QUERY = `
|
|
172
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
173
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
174
|
-
uniqueKey
|
|
175
|
-
state {
|
|
176
|
-
rewards {
|
|
177
|
-
amountPerSuppliedToken
|
|
178
|
-
supplyApr
|
|
179
|
-
amountPerBorrowedToken
|
|
180
|
-
borrowApr
|
|
181
|
-
asset {
|
|
182
|
-
address
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
171
|
+
const REWARDS_QUERY = `
|
|
172
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
173
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
174
|
+
uniqueKey
|
|
175
|
+
state {
|
|
176
|
+
rewards {
|
|
177
|
+
amountPerSuppliedToken
|
|
178
|
+
supplyApr
|
|
179
|
+
amountPerBorrowedToken
|
|
180
|
+
borrowApr
|
|
181
|
+
asset {
|
|
182
|
+
address
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
188
|
`;
|
|
189
189
|
/**
|
|
190
190
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
package/esm/liquityV2/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
12
12
|
import { createViemContractFromConfigFunc, LiquityV2LegacyViewContractViem, LiquityV2ViewContractViem, } from '../contracts';
|
|
13
|
-
import { NetworkNumber } from '../types/common';
|
|
13
|
+
import { IncentiveKind, NetworkNumber, } from '../types/common';
|
|
14
14
|
import { LIQUITY_V2_TROVE_STATUS_ENUM, LiquityV2Versions, } from '../types';
|
|
15
15
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
16
|
import { getLiquityV2AggregatedPositionData } from '../helpers/liquityV2Helpers';
|
|
@@ -58,6 +58,8 @@ export const _getLiquityV2MarketData = (provider, network, selectedMarket) => __
|
|
|
58
58
|
canBeBorrowed: true,
|
|
59
59
|
leftToBorrowGlobal,
|
|
60
60
|
leftToWithdrawGlobal: '0',
|
|
61
|
+
supplyIncentives: [],
|
|
62
|
+
borrowIncentives: [],
|
|
61
63
|
};
|
|
62
64
|
assetsData[collateralToken] = {
|
|
63
65
|
symbol: collateralToken,
|
|
@@ -69,10 +71,16 @@ export const _getLiquityV2MarketData = (provider, network, selectedMarket) => __
|
|
|
69
71
|
canBeBorrowed: false,
|
|
70
72
|
leftToBorrowGlobal: '0',
|
|
71
73
|
leftToWithdrawGlobal,
|
|
74
|
+
supplyIncentives: [],
|
|
75
|
+
borrowIncentives: [],
|
|
72
76
|
};
|
|
73
77
|
if (STAKING_ASSETS.includes(collateralToken)) {
|
|
74
|
-
assetsData[collateralToken].
|
|
75
|
-
|
|
78
|
+
assetsData[collateralToken].supplyIncentives.push({
|
|
79
|
+
apy: yield getStakingApy(collateralToken),
|
|
80
|
+
token: collateralToken,
|
|
81
|
+
incentiveKind: IncentiveKind.Staking,
|
|
82
|
+
description: `Native ${collateralToken} yield.`,
|
|
83
|
+
});
|
|
76
84
|
}
|
|
77
85
|
return {
|
|
78
86
|
assetsData,
|