@defisaver/positions-sdk 2.1.71 → 2.1.72-gho-plasma-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ exports.aaveV3AssetsDefaultMarketOpt = [
18
18
  exports.aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH', 'rsETH', 'tBTC'];
19
19
  exports.aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'GHO', 'wrsETH', 'LBTC', 'EURC', 'AAVE', 'tBTC', 'syrupUSDC'];
20
20
  exports.aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC', 'mUSD'];
21
- exports.aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr'];
21
+ exports.aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr', 'GHO'];
22
22
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
23
23
  exports.aaveV3AssetsDefaultMarket = {
24
24
  [common_1.NetworkNumber.Eth]: exports.aaveV3AssetsDefaultMarketEth,
@@ -5,6 +5,12 @@ export declare const isEligibleForEthenaUSDeRewards: (usedAssets: MMUsedAssets,
5
5
  isEligible: boolean;
6
6
  eligibleUSDAmount: string;
7
7
  };
8
+ export declare const isEligibleForEthenaGHORewards: (usedAssets: MMUsedAssets, { healthRatio }: {
9
+ healthRatio: string;
10
+ }) => {
11
+ isEligible: boolean;
12
+ eligibleUSDAmount: string;
13
+ };
8
14
  export declare const isEligibleForAaveV3ArbitrumEthSupply: (usedAssets: MMUsedAssets) => {
9
15
  isEligible: boolean;
10
16
  eligibleUSDAmount: string;
@@ -3,34 +3,51 @@ 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.isEligibleForAaveV3ArbitrumETHLSBorrow = exports.isEligibleForAaveV3ArbitrumEthSupply = exports.isEligibleForEthenaUSDeRewards = void 0;
6
+ exports.EligibilityMapping = exports.isEligibleForAaveV3ArbitrumETHLSBorrow = exports.isEligibleForAaveV3ArbitrumEthSupply = exports.isEligibleForEthenaGHORewards = exports.isEligibleForEthenaUSDeRewards = void 0;
7
7
  const decimal_js_1 = __importDefault(require("decimal.js"));
8
8
  const common_1 = require("../types/common");
9
- const isEligibleForEthenaUSDeRewards = (usedAssets, { healthRatio }) => {
10
- var _a, _b;
11
- const USDeUSDAmountSupplied = ((_a = usedAssets.USDe) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
12
- const sUSDeUSDAmountSupplied = ((_b = usedAssets.sUSDe) === null || _b === void 0 ? void 0 : _b.suppliedUsd) || '0';
13
- const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.symbol !== 'USDe' && asset.symbol !== 'sUSDe' && asset.isSupplied);
9
+ const isEligibleForEthenaPairRewards = (usedAssets, { healthRatio }, { baseSymbol, pairSymbol, allowedBorrowAssets, maxHealthRatio, rewardSymbol, requirePositiveBorrowSymbol, }) => {
10
+ var _a, _b, _c;
11
+ const baseSuppliedUsd = ((_a = usedAssets[baseSymbol]) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
12
+ const pairSuppliedUsd = ((_b = usedAssets[pairSymbol]) === null || _b === void 0 ? void 0 : _b.suppliedUsd) || '0';
13
+ const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.isSupplied && asset.symbol !== baseSymbol && asset.symbol !== pairSymbol);
14
14
  if (anythingElseSupplied)
15
15
  return { isEligible: false, eligibleUSDAmount: '0' };
16
- const totalAmountSupplied = new decimal_js_1.default(USDeUSDAmountSupplied).add(sUSDeUSDAmountSupplied).toString();
17
- const percentageInUSDe = new decimal_js_1.default(USDeUSDAmountSupplied).div(totalAmountSupplied).toNumber();
18
- if (percentageInUSDe < 0.45 || percentageInUSDe > 0.55)
19
- return { isEligible: false, eligibleUSDAmount: '0' }; // 45% - 55% of total amount supplied must be in USDe
20
- const percentageInSUSDe = new decimal_js_1.default(sUSDeUSDAmountSupplied).div(totalAmountSupplied).toNumber();
21
- if (percentageInSUSDe < 0.45 || percentageInSUSDe > 0.55)
22
- return { isEligible: false, eligibleUSDAmount: '0' }; // 45% - 55% of total amount supplied must be in sUSDe
23
- const allowedBorrowAssets = ['USDC', 'USDT', 'USDS'];
16
+ const totalAmountSupplied = new decimal_js_1.default(baseSuppliedUsd).add(pairSuppliedUsd);
17
+ if (totalAmountSupplied.eq(0))
18
+ return { isEligible: false, eligibleUSDAmount: '0' };
19
+ const percentageInBase = new decimal_js_1.default(baseSuppliedUsd).div(totalAmountSupplied).toNumber();
20
+ if (percentageInBase < 0.45 || percentageInBase > 0.55)
21
+ return { isEligible: false, eligibleUSDAmount: '0' };
22
+ const percentageInPair = new decimal_js_1.default(pairSuppliedUsd).div(totalAmountSupplied).toNumber();
23
+ if (percentageInPair < 0.45 || percentageInPair > 0.55)
24
+ return { isEligible: false, eligibleUSDAmount: '0' };
24
25
  const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
25
26
  if (anythingBorrowedNotAllowed)
26
27
  return { isEligible: false, eligibleUSDAmount: '0' };
27
- if (new decimal_js_1.default(healthRatio).gte(2.5))
28
- return { isEligible: false, eligibleUSDAmount: '0' }; // health ratio must be below 2.5
29
- const halfAmountSupplied = new decimal_js_1.default(totalAmountSupplied).div(2).toString();
30
- const USDeAmountEligibleForRewards = decimal_js_1.default.min(USDeUSDAmountSupplied, halfAmountSupplied).toString(); // rewards are given to amount of USDe supplied up to half of total amount supplied
31
- return { isEligible: true, eligibleUSDAmount: USDeAmountEligibleForRewards };
28
+ if (new decimal_js_1.default(healthRatio).gte(maxHealthRatio))
29
+ return { isEligible: false, eligibleUSDAmount: '0' };
30
+ const halfAmountSupplied = totalAmountSupplied.div(2);
31
+ const rewardSuppliedUsd = ((_c = usedAssets[rewardSymbol]) === null || _c === void 0 ? void 0 : _c.suppliedUsd) || '0';
32
+ const eligibleUSDAmount = decimal_js_1.default.min(rewardSuppliedUsd, halfAmountSupplied).toString();
33
+ return { isEligible: true, eligibleUSDAmount };
32
34
  };
35
+ const isEligibleForEthenaUSDeRewards = (usedAssets, { healthRatio }) => isEligibleForEthenaPairRewards(usedAssets, { healthRatio }, {
36
+ baseSymbol: 'USDe',
37
+ pairSymbol: 'sUSDe',
38
+ allowedBorrowAssets: ['USDC', 'USDT', 'USDS'],
39
+ maxHealthRatio: '2.5',
40
+ rewardSymbol: 'USDe',
41
+ });
33
42
  exports.isEligibleForEthenaUSDeRewards = isEligibleForEthenaUSDeRewards;
43
+ const isEligibleForEthenaGHORewards = (usedAssets, { healthRatio }) => isEligibleForEthenaPairRewards(usedAssets, { healthRatio }, {
44
+ baseSymbol: 'syrupUSDT',
45
+ pairSymbol: 'GHO',
46
+ allowedBorrowAssets: ['USDT'],
47
+ maxHealthRatio: '2',
48
+ rewardSymbol: 'GHO',
49
+ });
50
+ exports.isEligibleForEthenaGHORewards = isEligibleForEthenaGHORewards;
34
51
  const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets) => {
35
52
  var _a, _b;
36
53
  const ETHAmountSupplied = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
@@ -58,4 +75,5 @@ exports.EligibilityMapping = {
58
75
  [common_1.IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: exports.isEligibleForAaveV3ArbitrumEthSupply,
59
76
  [common_1.IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: exports.isEligibleForAaveV3ArbitrumETHLSBorrow,
60
77
  [common_1.IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasma]: exports.isEligibleForEthenaUSDeRewards,
78
+ [common_1.IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasmaGHO]: exports.isEligibleForEthenaGHORewards,
61
79
  };
@@ -6,7 +6,8 @@ export declare enum IncentiveEligibilityId {
6
6
  AaveV3EthenaLiquidLeverage = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL",
7
7
  AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
8
8
  AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
9
- AaveV3EthenaLiquidLeveragePlasma = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL"
9
+ AaveV3EthenaLiquidLeveragePlasma = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL",
10
+ AaveV3EthenaLiquidLeveragePlasmaGHO = "replace_when_known"
10
11
  }
11
12
  export declare enum LeverageType {
12
13
  Long = "long",
@@ -12,6 +12,7 @@ var IncentiveEligibilityId;
12
12
  IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
13
13
  IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
14
14
  IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL";
15
+ IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasmaGHO"] = "replace_when_known";
15
16
  })(IncentiveEligibilityId || (exports.IncentiveEligibilityId = IncentiveEligibilityId = {}));
16
17
  var LeverageType;
17
18
  (function (LeverageType) {
@@ -15,7 +15,7 @@ export const aaveV3AssetsDefaultMarketOpt = [
15
15
  export const aaveV3AssetsDefaultMarketArb = ['DAI', 'LINK', 'USDC.e', 'WBTC', 'ETH', 'USDT', 'AAVE', 'EURS', 'wstETH', 'MAI', 'rETH', 'LUSD', 'USDC', 'FRAX', 'ARB', 'weETH', 'GHO', 'ezETH', 'rsETH', 'tBTC'];
16
16
  export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH', 'USDC', 'weETH', 'cbBTC', 'ezETH', 'GHO', 'wrsETH', 'LBTC', 'EURC', 'AAVE', 'tBTC', 'syrupUSDC'];
17
17
  export const aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC', 'mUSD'];
18
- export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr'];
18
+ export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr', 'GHO'];
19
19
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
20
20
  export const aaveV3AssetsDefaultMarket = {
21
21
  [NetworkNumber.Eth]: aaveV3AssetsDefaultMarketEth,
@@ -5,6 +5,12 @@ export declare const isEligibleForEthenaUSDeRewards: (usedAssets: MMUsedAssets,
5
5
  isEligible: boolean;
6
6
  eligibleUSDAmount: string;
7
7
  };
8
+ export declare const isEligibleForEthenaGHORewards: (usedAssets: MMUsedAssets, { healthRatio }: {
9
+ healthRatio: string;
10
+ }) => {
11
+ isEligible: boolean;
12
+ eligibleUSDAmount: string;
13
+ };
8
14
  export declare const isEligibleForAaveV3ArbitrumEthSupply: (usedAssets: MMUsedAssets) => {
9
15
  isEligible: boolean;
10
16
  eligibleUSDAmount: string;
@@ -1,29 +1,45 @@
1
1
  import Dec from 'decimal.js';
2
2
  import { IncentiveEligibilityId } from '../types/common';
3
- export const isEligibleForEthenaUSDeRewards = (usedAssets, { healthRatio }) => {
4
- var _a, _b;
5
- const USDeUSDAmountSupplied = ((_a = usedAssets.USDe) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
6
- const sUSDeUSDAmountSupplied = ((_b = usedAssets.sUSDe) === null || _b === void 0 ? void 0 : _b.suppliedUsd) || '0';
7
- const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.symbol !== 'USDe' && asset.symbol !== 'sUSDe' && asset.isSupplied);
3
+ const isEligibleForEthenaPairRewards = (usedAssets, { healthRatio }, { baseSymbol, pairSymbol, allowedBorrowAssets, maxHealthRatio, rewardSymbol, requirePositiveBorrowSymbol, }) => {
4
+ var _a, _b, _c;
5
+ const baseSuppliedUsd = ((_a = usedAssets[baseSymbol]) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
6
+ const pairSuppliedUsd = ((_b = usedAssets[pairSymbol]) === null || _b === void 0 ? void 0 : _b.suppliedUsd) || '0';
7
+ const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.isSupplied && asset.symbol !== baseSymbol && asset.symbol !== pairSymbol);
8
8
  if (anythingElseSupplied)
9
9
  return { isEligible: false, eligibleUSDAmount: '0' };
10
- const totalAmountSupplied = new Dec(USDeUSDAmountSupplied).add(sUSDeUSDAmountSupplied).toString();
11
- const percentageInUSDe = new Dec(USDeUSDAmountSupplied).div(totalAmountSupplied).toNumber();
12
- if (percentageInUSDe < 0.45 || percentageInUSDe > 0.55)
13
- return { isEligible: false, eligibleUSDAmount: '0' }; // 45% - 55% of total amount supplied must be in USDe
14
- const percentageInSUSDe = new Dec(sUSDeUSDAmountSupplied).div(totalAmountSupplied).toNumber();
15
- if (percentageInSUSDe < 0.45 || percentageInSUSDe > 0.55)
16
- return { isEligible: false, eligibleUSDAmount: '0' }; // 45% - 55% of total amount supplied must be in sUSDe
17
- const allowedBorrowAssets = ['USDC', 'USDT', 'USDS'];
10
+ const totalAmountSupplied = new Dec(baseSuppliedUsd).add(pairSuppliedUsd);
11
+ if (totalAmountSupplied.eq(0))
12
+ return { isEligible: false, eligibleUSDAmount: '0' };
13
+ const percentageInBase = new Dec(baseSuppliedUsd).div(totalAmountSupplied).toNumber();
14
+ if (percentageInBase < 0.45 || percentageInBase > 0.55)
15
+ return { isEligible: false, eligibleUSDAmount: '0' };
16
+ const percentageInPair = new Dec(pairSuppliedUsd).div(totalAmountSupplied).toNumber();
17
+ if (percentageInPair < 0.45 || percentageInPair > 0.55)
18
+ return { isEligible: false, eligibleUSDAmount: '0' };
18
19
  const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
19
20
  if (anythingBorrowedNotAllowed)
20
21
  return { isEligible: false, eligibleUSDAmount: '0' };
21
- if (new Dec(healthRatio).gte(2.5))
22
- return { isEligible: false, eligibleUSDAmount: '0' }; // health ratio must be below 2.5
23
- const halfAmountSupplied = new Dec(totalAmountSupplied).div(2).toString();
24
- const USDeAmountEligibleForRewards = Dec.min(USDeUSDAmountSupplied, halfAmountSupplied).toString(); // rewards are given to amount of USDe supplied up to half of total amount supplied
25
- return { isEligible: true, eligibleUSDAmount: USDeAmountEligibleForRewards };
22
+ if (new Dec(healthRatio).gte(maxHealthRatio))
23
+ return { isEligible: false, eligibleUSDAmount: '0' };
24
+ const halfAmountSupplied = totalAmountSupplied.div(2);
25
+ const rewardSuppliedUsd = ((_c = usedAssets[rewardSymbol]) === null || _c === void 0 ? void 0 : _c.suppliedUsd) || '0';
26
+ const eligibleUSDAmount = Dec.min(rewardSuppliedUsd, halfAmountSupplied).toString();
27
+ return { isEligible: true, eligibleUSDAmount };
26
28
  };
29
+ export const isEligibleForEthenaUSDeRewards = (usedAssets, { healthRatio }) => isEligibleForEthenaPairRewards(usedAssets, { healthRatio }, {
30
+ baseSymbol: 'USDe',
31
+ pairSymbol: 'sUSDe',
32
+ allowedBorrowAssets: ['USDC', 'USDT', 'USDS'],
33
+ maxHealthRatio: '2.5',
34
+ rewardSymbol: 'USDe',
35
+ });
36
+ export const isEligibleForEthenaGHORewards = (usedAssets, { healthRatio }) => isEligibleForEthenaPairRewards(usedAssets, { healthRatio }, {
37
+ baseSymbol: 'syrupUSDT',
38
+ pairSymbol: 'GHO',
39
+ allowedBorrowAssets: ['USDT'],
40
+ maxHealthRatio: '2',
41
+ rewardSymbol: 'GHO',
42
+ });
27
43
  export const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets) => {
28
44
  var _a, _b;
29
45
  const ETHAmountSupplied = ((_a = usedAssets.ETH) === null || _a === void 0 ? void 0 : _a.suppliedUsd) || '0';
@@ -49,4 +65,5 @@ export const EligibilityMapping = {
49
65
  [IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: isEligibleForAaveV3ArbitrumEthSupply,
50
66
  [IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: isEligibleForAaveV3ArbitrumETHLSBorrow,
51
67
  [IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasma]: isEligibleForEthenaUSDeRewards,
68
+ [IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasmaGHO]: isEligibleForEthenaGHORewards,
52
69
  };
@@ -6,7 +6,8 @@ export declare enum IncentiveEligibilityId {
6
6
  AaveV3EthenaLiquidLeverage = "0x8014e0076e5393e62c49a7134070d8fccc922e46BORROW_BL",
7
7
  AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
8
8
  AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
9
- AaveV3EthenaLiquidLeveragePlasma = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL"
9
+ AaveV3EthenaLiquidLeveragePlasma = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL",
10
+ AaveV3EthenaLiquidLeveragePlasmaGHO = "replace_when_known"
10
11
  }
11
12
  export declare enum LeverageType {
12
13
  Long = "long",
@@ -9,6 +9,7 @@ export var IncentiveEligibilityId;
9
9
  IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
10
10
  IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
11
11
  IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL";
12
+ IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasmaGHO"] = "replace_when_known";
12
13
  })(IncentiveEligibilityId || (IncentiveEligibilityId = {}));
13
14
  export var LeverageType;
14
15
  (function (LeverageType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "2.1.71",
3
+ "version": "2.1.72-gho-plasma-dev",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -21,7 +21,7 @@
21
21
  "author": "",
22
22
  "license": "ISC",
23
23
  "dependencies": {
24
- "@defisaver/tokens": "^1.7.25",
24
+ "@defisaver/tokens": "1.7.26-gho-plasma-dev",
25
25
  "@types/lodash": "^4.17.15",
26
26
  "@types/memoizee": "^0.4.12",
27
27
  "decimal.js": "^10.6.0",
@@ -20,7 +20,7 @@ export const aaveV3AssetsDefaultMarketBase = ['ETH', 'cbETH', 'USDbC', 'wstETH',
20
20
 
21
21
  export const aaveV3AssetsDefaultMarketLinea = ['ETH', 'USDC', 'weETH', 'ezETH', 'USDT', 'wstETH', 'wrsETH', 'WBTC', 'mUSD'];
22
22
 
23
- export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr'];
23
+ export const aaveV3AssetsDefaultMarketPlasma = ['ETH', 'USDT', 'sUSDe', 'USDe', 'weETH', 'XAUt', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'XPL', 'PT USDe Apr', 'PT sUSDe Apr', 'GHO'];
24
24
 
25
25
  // @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
26
26
  export const aaveV3AssetsDefaultMarket = {
@@ -1,29 +1,82 @@
1
1
  import Dec from 'decimal.js';
2
2
  import { IncentiveEligibilityId, MMUsedAssets } from '../types/common';
3
3
 
4
- export const isEligibleForEthenaUSDeRewards = (usedAssets: MMUsedAssets, { healthRatio }: { healthRatio: string }) => {
5
- const USDeUSDAmountSupplied = usedAssets.USDe?.suppliedUsd || '0';
6
- const sUSDeUSDAmountSupplied = usedAssets.sUSDe?.suppliedUsd || '0';
7
- const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.symbol !== 'USDe' && asset.symbol !== 'sUSDe' && asset.isSupplied);
4
+ type EthenaPairEligibilityConfig = {
5
+ baseSymbol: string;
6
+ pairSymbol: string;
7
+ allowedBorrowAssets: string[];
8
+ maxHealthRatio: string; // exclusive upper bound
9
+ rewardSymbol: string;
10
+ requirePositiveBorrowSymbol?: string;
11
+ };
12
+
13
+ const isEligibleForEthenaPairRewards = (
14
+ usedAssets: MMUsedAssets,
15
+ { healthRatio }: { healthRatio: string },
16
+ {
17
+ baseSymbol,
18
+ pairSymbol,
19
+ allowedBorrowAssets,
20
+ maxHealthRatio,
21
+ rewardSymbol,
22
+ requirePositiveBorrowSymbol,
23
+ }: EthenaPairEligibilityConfig,
24
+ ) => {
25
+ const baseSuppliedUsd = usedAssets[baseSymbol]?.suppliedUsd || '0';
26
+ const pairSuppliedUsd = usedAssets[pairSymbol]?.suppliedUsd || '0';
27
+
28
+ const anythingElseSupplied = Object.values(usedAssets).some(
29
+ (asset) => asset.isSupplied && asset.symbol !== baseSymbol && asset.symbol !== pairSymbol,
30
+ );
8
31
  if (anythingElseSupplied) return { isEligible: false, eligibleUSDAmount: '0' };
9
- const totalAmountSupplied = new Dec(USDeUSDAmountSupplied).add(sUSDeUSDAmountSupplied).toString();
10
- const percentageInUSDe = new Dec(USDeUSDAmountSupplied).div(totalAmountSupplied).toNumber();
11
- if (percentageInUSDe < 0.45 || percentageInUSDe > 0.55) return { isEligible: false, eligibleUSDAmount: '0' }; // 45% - 55% of total amount supplied must be in USDe
12
- const percentageInSUSDe = new Dec(sUSDeUSDAmountSupplied).div(totalAmountSupplied).toNumber();
13
- if (percentageInSUSDe < 0.45 || percentageInSUSDe > 0.55) return { isEligible: false, eligibleUSDAmount: '0' }; // 45% - 55% of total amount supplied must be in sUSDe
14
32
 
15
- const allowedBorrowAssets = ['USDC', 'USDT', 'USDS'];
16
- const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
33
+ const totalAmountSupplied = new Dec(baseSuppliedUsd).add(pairSuppliedUsd);
34
+ if (totalAmountSupplied.eq(0)) return { isEligible: false, eligibleUSDAmount: '0' };
35
+
36
+ const percentageInBase = new Dec(baseSuppliedUsd).div(totalAmountSupplied).toNumber();
37
+ if (percentageInBase < 0.45 || percentageInBase > 0.55) return { isEligible: false, eligibleUSDAmount: '0' };
38
+
39
+ const percentageInPair = new Dec(pairSuppliedUsd).div(totalAmountSupplied).toNumber();
40
+ if (percentageInPair < 0.45 || percentageInPair > 0.55) return { isEligible: false, eligibleUSDAmount: '0' };
41
+
42
+ const anythingBorrowedNotAllowed = Object.values(usedAssets).some(
43
+ (asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol),
44
+ );
17
45
  if (anythingBorrowedNotAllowed) return { isEligible: false, eligibleUSDAmount: '0' };
18
46
 
19
- if (new Dec(healthRatio).gte(2.5)) return { isEligible: false, eligibleUSDAmount: '0' }; // health ratio must be below 2.5
47
+ if (new Dec(healthRatio).gte(maxHealthRatio)) return { isEligible: false, eligibleUSDAmount: '0' };
20
48
 
21
- const halfAmountSupplied = new Dec(totalAmountSupplied).div(2).toString();
22
- const USDeAmountEligibleForRewards = Dec.min(USDeUSDAmountSupplied, halfAmountSupplied).toString(); // rewards are given to amount of USDe supplied up to half of total amount supplied
49
+ const halfAmountSupplied = totalAmountSupplied.div(2);
50
+ const rewardSuppliedUsd = usedAssets[rewardSymbol]?.suppliedUsd || '0';
51
+ const eligibleUSDAmount = Dec.min(rewardSuppliedUsd, halfAmountSupplied).toString();
23
52
 
24
- return { isEligible: true, eligibleUSDAmount: USDeAmountEligibleForRewards };
53
+ return { isEligible: true, eligibleUSDAmount };
25
54
  };
26
55
 
56
+ export const isEligibleForEthenaUSDeRewards = (usedAssets: MMUsedAssets, { healthRatio }: { healthRatio: string }) => isEligibleForEthenaPairRewards(
57
+ usedAssets,
58
+ { healthRatio },
59
+ {
60
+ baseSymbol: 'USDe',
61
+ pairSymbol: 'sUSDe',
62
+ allowedBorrowAssets: ['USDC', 'USDT', 'USDS'],
63
+ maxHealthRatio: '2.5',
64
+ rewardSymbol: 'USDe',
65
+ },
66
+ );
67
+
68
+ export const isEligibleForEthenaGHORewards = (usedAssets: MMUsedAssets, { healthRatio }: { healthRatio: string }) => isEligibleForEthenaPairRewards(
69
+ usedAssets,
70
+ { healthRatio },
71
+ {
72
+ baseSymbol: 'syrupUSDT',
73
+ pairSymbol: 'GHO',
74
+ allowedBorrowAssets: ['USDT'],
75
+ maxHealthRatio: '2',
76
+ rewardSymbol: 'GHO',
77
+ },
78
+ );
79
+
27
80
  export const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets: MMUsedAssets) => {
28
81
  const ETHAmountSupplied = usedAssets.ETH?.suppliedUsd || '0';
29
82
  const ETHAmountBorrowed = usedAssets.ETH?.borrowedUsd || '0';
@@ -51,4 +104,5 @@ export const EligibilityMapping: { [key in IncentiveEligibilityId]: (usedAssets:
51
104
  [IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: isEligibleForAaveV3ArbitrumEthSupply,
52
105
  [IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: isEligibleForAaveV3ArbitrumETHLSBorrow,
53
106
  [IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasma]: isEligibleForEthenaUSDeRewards,
107
+ [IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasmaGHO]: isEligibleForEthenaGHORewards,
54
108
  };
@@ -8,6 +8,7 @@ export enum IncentiveEligibilityId {
8
8
  AaveV3ArbitrumEthSupply = '0x5d16261c6715a653248269861bbacf68a9774cde',
9
9
  AaveV3ArbitrumETHLSBorrow = '0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351',
10
10
  AaveV3EthenaLiquidLeveragePlasma = '0xeefac321069fbecc9d6b2aed2948f6d5503d8633BORROW_BL',
11
+ AaveV3EthenaLiquidLeveragePlasmaGHO = 'replace_when_known',
11
12
  }
12
13
 
13
14
  export enum LeverageType {