@defisaver/positions-sdk 2.0.15-dev-4 → 2.0.15-dev-6

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.
@@ -212,6 +212,7 @@ const getTradingApy = (poolAddress) => __awaiter(void 0, void 0, void 0, functio
212
212
  return new decimal_js_1.default(data.tradingApy).div(100).toString();
213
213
  });
214
214
  const parseT1MarketData = (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) {
215
+ var _a, _b;
215
216
  const collAsset = (0, tokens_1.getAssetInfoByAddress)(data.supplyToken0, network);
216
217
  const debtAsset = (0, tokens_1.getAssetInfoByAddress)(data.borrowToken0, network);
217
218
  const supplyRate = new decimal_js_1.default(data.supplyRateVault).div(100).toString();
@@ -312,6 +313,8 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
312
313
  borrowRate,
313
314
  supplyRate,
314
315
  oraclePrice,
316
+ incentiveSupplyRate: ((_a = collAssetData.supplyIncentives[0]) === null || _a === void 0 ? void 0 : _a.apy) || '0',
317
+ incentiveBorrowRate: ((_b = debtAssetData.borrowIncentives[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0',
315
318
  };
316
319
  return {
317
320
  assetsData,
@@ -68,12 +68,19 @@ const getIncentiveApys = (baseData, compPrice) => __awaiter(void 0, void 0, void
68
68
  description: `Native ${baseData.symbol} yield.`,
69
69
  }),
70
70
  ],
71
- borrowIncentives: [Object.assign({ token: 'COMP', apy: (0, moneymarket_1.aprToApy)((100 * constants_1.SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(), incentiveKind: common_1.IncentiveKind.Reward, description: 'Eligible for protocol-level COMP incentives.' }, (0, utils_1.addToArrayIf)(staking_1.STAKING_ASSETS.includes(baseData.symbol), {
71
+ borrowIncentives: [{
72
+ token: 'COMP',
73
+ apy: (0, moneymarket_1.aprToApy)((100 * constants_1.SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(),
74
+ incentiveKind: common_1.IncentiveKind.Reward,
75
+ description: 'Eligible for protocol-level COMP incentives.',
76
+ },
77
+ ...(0, utils_1.addToArrayIf)(staking_1.STAKING_ASSETS.includes(baseData.symbol), {
72
78
  apy: new decimal_js_1.default(yield (0, staking_1.getStakingApy)(baseData.symbol)).mul(-1).toString(),
73
79
  token: baseData.symbol,
74
80
  incentiveKind: common_1.IncentiveKind.Staking,
75
- description: `Native ${baseData.symbol} yield.`,
76
- }))],
81
+ description: `Due to the native yield of ${baseData.symbol}, the value of the debt would increase over time.`,
82
+ }),
83
+ ],
77
84
  });
78
85
  });
79
86
  exports.getIncentiveApys = getIncentiveApys;
@@ -3,6 +3,14 @@ export declare const isEligibleForEthenaUSDeRewards: (usedAssets: MMUsedAssets)
3
3
  isEligible: boolean;
4
4
  eligibleUSDAmount: string;
5
5
  };
6
+ export declare const isEligibleForAaveV3ArbitrumEthSupply: (usedAssets: MMUsedAssets) => {
7
+ isEligible: boolean;
8
+ eligibleUSDAmount: string;
9
+ };
10
+ export declare const isEligibleForAaveV3ArbitrumETHLSBorrow: (usedAssets: MMUsedAssets) => {
11
+ isEligible: boolean;
12
+ eligibleUSDAmount: string;
13
+ };
6
14
  export declare const EligibilityMapping: {
7
15
  [key in IncentiveEligibilityId]: (usedAssets: MMUsedAssets) => {
8
16
  isEligible: boolean;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EligibilityMapping = exports.isEligibleForEthenaUSDeRewards = void 0;
6
+ exports.EligibilityMapping = exports.isEligibleForAaveV3ArbitrumETHLSBorrow = exports.isEligibleForAaveV3ArbitrumEthSupply = exports.isEligibleForEthenaUSDeRewards = void 0;
7
7
  const decimal_js_1 = __importDefault(require("decimal.js"));
8
8
  const common_1 = require("../types/common");
9
9
  const isEligibleForEthenaUSDeRewards = (usedAssets) => {
@@ -38,6 +38,30 @@ const isEligibleForEthenaUSDeRewards = (usedAssets) => {
38
38
  return { isEligible: true, eligibleUSDAmount: USDeAmountEligibleForRewards };
39
39
  };
40
40
  exports.isEligibleForEthenaUSDeRewards = isEligibleForEthenaUSDeRewards;
41
+ const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets) => {
42
+ var _a, _b;
43
+ const ETHAmountSupplied = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
44
+ const ETHAmountBorrowed = ((_b = usedAssets.ETH) === null || _b === void 0 ? void 0 : _b.borrowedUsd) || '0';
45
+ const delta = new decimal_js_1.default(ETHAmountSupplied).sub(ETHAmountBorrowed).toString();
46
+ return { isEligible: true, eligibleUSDAmount: decimal_js_1.default.max(delta, 0).toString() };
47
+ };
48
+ exports.isEligibleForAaveV3ArbitrumEthSupply = isEligibleForAaveV3ArbitrumEthSupply;
49
+ const isEligibleForAaveV3ArbitrumETHLSBorrow = (usedAssets) => {
50
+ var _a;
51
+ const allowedBorrowAssets = ['ETH'];
52
+ const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
53
+ if (anythingBorrowedNotAllowed)
54
+ return { isEligible: false, eligibleUSDAmount: '0' };
55
+ const allowedSupplyAssets = ['wstETH', 'ezETH', 'weETH', 'rsETH'];
56
+ const anythingSuppliedNotAllowed = Object.values(usedAssets).some((asset) => asset.isSupplied && !allowedSupplyAssets.includes(asset.symbol));
57
+ if (anythingSuppliedNotAllowed)
58
+ return { isEligible: false, eligibleUSDAmount: '0' };
59
+ const ETHAmountBorrowed = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.borrowedUsd) || '0';
60
+ return { isEligible: true, eligibleUSDAmount: ETHAmountBorrowed };
61
+ };
62
+ exports.isEligibleForAaveV3ArbitrumETHLSBorrow = isEligibleForAaveV3ArbitrumETHLSBorrow;
41
63
  exports.EligibilityMapping = {
42
64
  [common_1.IncentiveEligibilityId.AaveV3EthenaLiquidLeverage]: exports.isEligibleForEthenaUSDeRewards,
65
+ [common_1.IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: exports.isEligibleForAaveV3ArbitrumEthSupply,
66
+ [common_1.IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: exports.isEligibleForAaveV3ArbitrumETHLSBorrow,
43
67
  };
@@ -3,7 +3,9 @@ export declare enum IncentiveKind {
3
3
  Reward = "reward"
4
4
  }
5
5
  export declare enum IncentiveEligibilityId {
6
- AaveV3EthenaLiquidLeverage = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL"
6
+ AaveV3EthenaLiquidLeverage = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL",
7
+ AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
8
+ AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351"
7
9
  }
8
10
  export interface IncentiveData {
9
11
  token: string;
@@ -9,6 +9,8 @@ var IncentiveKind;
9
9
  var IncentiveEligibilityId;
10
10
  (function (IncentiveEligibilityId) {
11
11
  IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL";
12
+ IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
13
+ IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
12
14
  })(IncentiveEligibilityId || (exports.IncentiveEligibilityId = IncentiveEligibilityId = {}));
13
15
  var NetworkNumber;
14
16
  (function (NetworkNumber) {
@@ -206,6 +206,7 @@ const getTradingApy = (poolAddress) => __awaiter(void 0, void 0, void 0, functio
206
206
  return new Dec(data.tradingApy).div(100).toString();
207
207
  });
208
208
  const parseT1MarketData = (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) {
209
+ var _a, _b;
209
210
  const collAsset = getAssetInfoByAddress(data.supplyToken0, network);
210
211
  const debtAsset = getAssetInfoByAddress(data.borrowToken0, network);
211
212
  const supplyRate = new Dec(data.supplyRateVault).div(100).toString();
@@ -306,6 +307,8 @@ const parseT1MarketData = (provider_1, data_1, network_1, ...args_1) => __awaite
306
307
  borrowRate,
307
308
  supplyRate,
308
309
  oraclePrice,
310
+ incentiveSupplyRate: ((_a = collAssetData.supplyIncentives[0]) === null || _a === void 0 ? void 0 : _a.apy) || '0',
311
+ incentiveBorrowRate: ((_b = debtAssetData.borrowIncentives[0]) === null || _b === void 0 ? void 0 : _b.apy) || '0',
309
312
  };
310
313
  return {
311
314
  assetsData,
@@ -60,12 +60,19 @@ export const getIncentiveApys = (baseData, compPrice) => __awaiter(void 0, void
60
60
  description: `Native ${baseData.symbol} yield.`,
61
61
  }),
62
62
  ],
63
- borrowIncentives: [Object.assign({ token: 'COMP', apy: aprToApy((100 * SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(), incentiveKind: IncentiveKind.Reward, description: 'Eligible for protocol-level COMP incentives.' }, addToArrayIf(STAKING_ASSETS.includes(baseData.symbol), {
63
+ borrowIncentives: [{
64
+ token: 'COMP',
65
+ apy: aprToApy((100 * SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(),
66
+ incentiveKind: IncentiveKind.Reward,
67
+ description: 'Eligible for protocol-level COMP incentives.',
68
+ },
69
+ ...addToArrayIf(STAKING_ASSETS.includes(baseData.symbol), {
64
70
  apy: new Dec(yield getStakingApy(baseData.symbol)).mul(-1).toString(),
65
71
  token: baseData.symbol,
66
72
  incentiveKind: IncentiveKind.Staking,
67
- description: `Native ${baseData.symbol} yield.`,
68
- }))],
73
+ description: `Due to the native yield of ${baseData.symbol}, the value of the debt would increase over time.`,
74
+ }),
75
+ ],
69
76
  });
70
77
  });
71
78
  export const getCompoundV2AggregatedData = (_a) => {
@@ -3,6 +3,14 @@ export declare const isEligibleForEthenaUSDeRewards: (usedAssets: MMUsedAssets)
3
3
  isEligible: boolean;
4
4
  eligibleUSDAmount: string;
5
5
  };
6
+ export declare const isEligibleForAaveV3ArbitrumEthSupply: (usedAssets: MMUsedAssets) => {
7
+ isEligible: boolean;
8
+ eligibleUSDAmount: string;
9
+ };
10
+ export declare const isEligibleForAaveV3ArbitrumETHLSBorrow: (usedAssets: MMUsedAssets) => {
11
+ isEligible: boolean;
12
+ eligibleUSDAmount: string;
13
+ };
6
14
  export declare const EligibilityMapping: {
7
15
  [key in IncentiveEligibilityId]: (usedAssets: MMUsedAssets) => {
8
16
  isEligible: boolean;
@@ -31,6 +31,28 @@ export const isEligibleForEthenaUSDeRewards = (usedAssets) => {
31
31
  const USDeAmountEligibleForRewards = Dec.min(USDeUSDAmountSupplied, halfAmountSupplied).toString(); // rewards are given to amount of USDe supplied up to half of total amount supplied
32
32
  return { isEligible: true, eligibleUSDAmount: USDeAmountEligibleForRewards };
33
33
  };
34
+ export const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets) => {
35
+ var _a, _b;
36
+ const ETHAmountSupplied = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
37
+ const ETHAmountBorrowed = ((_b = usedAssets.ETH) === null || _b === void 0 ? void 0 : _b.borrowedUsd) || '0';
38
+ const delta = new Dec(ETHAmountSupplied).sub(ETHAmountBorrowed).toString();
39
+ return { isEligible: true, eligibleUSDAmount: Dec.max(delta, 0).toString() };
40
+ };
41
+ export const isEligibleForAaveV3ArbitrumETHLSBorrow = (usedAssets) => {
42
+ var _a;
43
+ const allowedBorrowAssets = ['ETH'];
44
+ const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
45
+ if (anythingBorrowedNotAllowed)
46
+ return { isEligible: false, eligibleUSDAmount: '0' };
47
+ const allowedSupplyAssets = ['wstETH', 'ezETH', 'weETH', 'rsETH'];
48
+ const anythingSuppliedNotAllowed = Object.values(usedAssets).some((asset) => asset.isSupplied && !allowedSupplyAssets.includes(asset.symbol));
49
+ if (anythingSuppliedNotAllowed)
50
+ return { isEligible: false, eligibleUSDAmount: '0' };
51
+ const ETHAmountBorrowed = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.borrowedUsd) || '0';
52
+ return { isEligible: true, eligibleUSDAmount: ETHAmountBorrowed };
53
+ };
34
54
  export const EligibilityMapping = {
35
55
  [IncentiveEligibilityId.AaveV3EthenaLiquidLeverage]: isEligibleForEthenaUSDeRewards,
56
+ [IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: isEligibleForAaveV3ArbitrumEthSupply,
57
+ [IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: isEligibleForAaveV3ArbitrumETHLSBorrow,
36
58
  };
@@ -3,7 +3,9 @@ export declare enum IncentiveKind {
3
3
  Reward = "reward"
4
4
  }
5
5
  export declare enum IncentiveEligibilityId {
6
- AaveV3EthenaLiquidLeverage = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL"
6
+ AaveV3EthenaLiquidLeverage = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL",
7
+ AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
8
+ AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351"
7
9
  }
8
10
  export interface IncentiveData {
9
11
  token: string;
@@ -6,6 +6,8 @@ export var IncentiveKind;
6
6
  export var IncentiveEligibilityId;
7
7
  (function (IncentiveEligibilityId) {
8
8
  IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL";
9
+ IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
10
+ IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
9
11
  })(IncentiveEligibilityId || (IncentiveEligibilityId = {}));
10
12
  export var NetworkNumber;
11
13
  (function (NetworkNumber) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.0.15-dev-4",
3
+ "version": "2.0.15-dev-6",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -381,6 +381,8 @@ const parseT1MarketData = async (provider: PublicClient, data: FluidVaultDataStr
381
381
  borrowRate,
382
382
  supplyRate,
383
383
  oraclePrice,
384
+ incentiveSupplyRate: collAssetData.supplyIncentives[0]?.apy || '0',
385
+ incentiveBorrowRate: debtAssetData.borrowIncentives[0]?.apy || '0',
384
386
  };
385
387
 
386
388
  return {
@@ -105,13 +105,14 @@ export const getIncentiveApys = async (
105
105
  apy: aprToApy((100 * SECONDS_PER_YEAR * +baseData.rewardBorrowSpeed * +compPrice) / +baseData.price / +baseData.totalBorrow).toString(),
106
106
  incentiveKind: IncentiveKind.Reward,
107
107
  description: 'Eligible for protocol-level COMP incentives.',
108
- ...addToArrayIf(STAKING_ASSETS.includes(baseData.symbol), {
109
- apy: new Dec(await getStakingApy(baseData.symbol)).mul(-1).toString(),
110
- token: baseData.symbol,
111
- incentiveKind: IncentiveKind.Staking,
112
- description: `Native ${baseData.symbol} yield.`,
113
- }),
114
- }],
108
+ },
109
+ ...addToArrayIf(STAKING_ASSETS.includes(baseData.symbol), {
110
+ apy: new Dec(await getStakingApy(baseData.symbol)).mul(-1).toString(),
111
+ token: baseData.symbol,
112
+ incentiveKind: IncentiveKind.Staking,
113
+ description: `Due to the native yield of ${baseData.symbol}, the value of the debt would increase over time.`,
114
+ }),
115
+ ],
115
116
  });
116
117
 
117
118
  export const getCompoundV2AggregatedData = ({
@@ -32,6 +32,30 @@ export const isEligibleForEthenaUSDeRewards = (usedAssets: MMUsedAssets) => {
32
32
  return { isEligible: true, eligibleUSDAmount: USDeAmountEligibleForRewards };
33
33
  };
34
34
 
35
+ export const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets: MMUsedAssets) => {
36
+ const ETHAmountSupplied = usedAssets.ETH?.suppliedUsd || '0';
37
+ const ETHAmountBorrowed = usedAssets.ETH?.borrowedUsd || '0';
38
+ const delta = new Dec(ETHAmountSupplied).sub(ETHAmountBorrowed).toString();
39
+
40
+ return { isEligible: true, eligibleUSDAmount: Dec.max(delta, 0).toString() };
41
+ };
42
+
43
+ export const isEligibleForAaveV3ArbitrumETHLSBorrow = (usedAssets: MMUsedAssets) => {
44
+ const allowedBorrowAssets = ['ETH'];
45
+ const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
46
+ if (anythingBorrowedNotAllowed) return { isEligible: false, eligibleUSDAmount: '0' };
47
+
48
+ const allowedSupplyAssets = ['wstETH', 'ezETH', 'weETH', 'rsETH'];
49
+ const anythingSuppliedNotAllowed = Object.values(usedAssets).some((asset) => asset.isSupplied && !allowedSupplyAssets.includes(asset.symbol));
50
+ if (anythingSuppliedNotAllowed) return { isEligible: false, eligibleUSDAmount: '0' };
51
+
52
+ const ETHAmountBorrowed = usedAssets.ETH?.borrowedUsd || '0';
53
+
54
+ return { isEligible: true, eligibleUSDAmount: ETHAmountBorrowed };
55
+ };
56
+
35
57
  export const EligibilityMapping: { [key in IncentiveEligibilityId]: (usedAssets: MMUsedAssets) => { isEligible: boolean; eligibleUSDAmount: string } } = {
36
58
  [IncentiveEligibilityId.AaveV3EthenaLiquidLeverage]: isEligibleForEthenaUSDeRewards,
59
+ [IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: isEligibleForAaveV3ArbitrumEthSupply,
60
+ [IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: isEligibleForAaveV3ArbitrumETHLSBorrow,
37
61
  };
@@ -5,6 +5,8 @@ export enum IncentiveKind {
5
5
 
6
6
  export enum IncentiveEligibilityId {
7
7
  AaveV3EthenaLiquidLeverage = '0x8772bb231f3af13ead41d7ecf6abd60f5f716ec8BORROW_BL',
8
+ AaveV3ArbitrumEthSupply = '0x5d16261c6715a653248269861bbacf68a9774cde',
9
+ AaveV3ArbitrumETHLSBorrow = '0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351',
8
10
  }
9
11
 
10
12
  export interface IncentiveData {