@defisaver/positions-sdk 2.1.71 → 2.1.72-gho-plasma-1-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.
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/staking/eligibility.d.ts +6 -0
- package/cjs/staking/eligibility.js +37 -19
- package/cjs/staking/staking.js +4 -2
- package/cjs/types/common.d.ts +2 -1
- package/cjs/types/common.js +1 -0
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/staking/eligibility.d.ts +6 -0
- package/esm/staking/eligibility.js +35 -18
- package/esm/staking/staking.js +4 -2
- package/esm/types/common.d.ts +2 -1
- package/esm/types/common.js +1 -0
- package/package.json +2 -2
- package/src/markets/aave/marketAssets.ts +1 -1
- package/src/staking/eligibility.ts +67 -15
- package/src/staking/staking.ts +3 -2
- package/src/types/common.ts +1 -0
|
@@ -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
|
|
10
|
-
var _a, _b;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.
|
|
9
|
+
const isEligibleForEthenaPairRewards = (usedAssets, { healthRatio }, { baseSymbol, pairSymbol, allowedBorrowAssets, maxHealthRatio, rewardSymbol, }) => {
|
|
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(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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(
|
|
28
|
-
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
29
|
-
const halfAmountSupplied =
|
|
30
|
-
const
|
|
31
|
-
|
|
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
|
};
|
package/cjs/staking/staking.js
CHANGED
|
@@ -72,7 +72,7 @@ exports.STAKING_ASSETS = [
|
|
|
72
72
|
'cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH',
|
|
73
73
|
'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS', 'tETH', 'PT sUSDe Sep', 'PT USDe Sep',
|
|
74
74
|
'PT sUSDe Nov', 'PT USDe Nov', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'syrupUSDC', 'wstUSR',
|
|
75
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
75
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'GHO',
|
|
76
76
|
];
|
|
77
77
|
exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaiter(void 0, [asset_1, ...args_1], void 0, function* (asset, network = common_1.NetworkNumber.Eth) {
|
|
78
78
|
try {
|
|
@@ -117,7 +117,7 @@ exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaite
|
|
|
117
117
|
if (asset === 'tETH')
|
|
118
118
|
return yield getApyFromDfsApi('tETH');
|
|
119
119
|
if (asset === 'USDe')
|
|
120
|
-
return yield getApyFromDfsApi('USDe');
|
|
120
|
+
return yield getApyFromDfsApi('USDe', network);
|
|
121
121
|
if (asset === 'PT sUSDe Nov')
|
|
122
122
|
return yield getApyFromDfsApi('PT sUSDe Nov', network);
|
|
123
123
|
if (asset === 'PT USDe Nov')
|
|
@@ -146,6 +146,8 @@ exports.getStakingApy = (0, memoizee_1.default)((asset_1, ...args_1) => __awaite
|
|
|
146
146
|
return yield getApyFromDfsApi('PT USDe May', network);
|
|
147
147
|
if (asset === 'PT srUSDe Apr')
|
|
148
148
|
return yield getApyFromDfsApi('PT srUSDe Apr', network);
|
|
149
|
+
if (asset === 'GHO')
|
|
150
|
+
return yield getApyFromDfsApi('GHO', network);
|
|
149
151
|
}
|
|
150
152
|
catch (e) {
|
|
151
153
|
console.error(`Failed to fetch APY for ${asset}`);
|
package/cjs/types/common.d.ts
CHANGED
|
@@ -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",
|
package/cjs/types/common.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
var _a, _b;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const anythingElseSupplied = Object.values(usedAssets).some((asset) => asset.
|
|
3
|
+
const isEligibleForEthenaPairRewards = (usedAssets, { healthRatio }, { baseSymbol, pairSymbol, allowedBorrowAssets, maxHealthRatio, rewardSymbol, }) => {
|
|
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(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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(
|
|
22
|
-
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
23
|
-
const halfAmountSupplied =
|
|
24
|
-
const
|
|
25
|
-
|
|
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
|
};
|
package/esm/staking/staking.js
CHANGED
|
@@ -66,7 +66,7 @@ export const STAKING_ASSETS = [
|
|
|
66
66
|
'cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH',
|
|
67
67
|
'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS', 'tETH', 'PT sUSDe Sep', 'PT USDe Sep',
|
|
68
68
|
'PT sUSDe Nov', 'PT USDe Nov', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'syrupUSDC', 'wstUSR',
|
|
69
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
69
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'GHO',
|
|
70
70
|
];
|
|
71
71
|
export const getStakingApy = memoize((asset_1, ...args_1) => __awaiter(void 0, [asset_1, ...args_1], void 0, function* (asset, network = NetworkNumber.Eth) {
|
|
72
72
|
try {
|
|
@@ -111,7 +111,7 @@ export const getStakingApy = memoize((asset_1, ...args_1) => __awaiter(void 0, [
|
|
|
111
111
|
if (asset === 'tETH')
|
|
112
112
|
return yield getApyFromDfsApi('tETH');
|
|
113
113
|
if (asset === 'USDe')
|
|
114
|
-
return yield getApyFromDfsApi('USDe');
|
|
114
|
+
return yield getApyFromDfsApi('USDe', network);
|
|
115
115
|
if (asset === 'PT sUSDe Nov')
|
|
116
116
|
return yield getApyFromDfsApi('PT sUSDe Nov', network);
|
|
117
117
|
if (asset === 'PT USDe Nov')
|
|
@@ -140,6 +140,8 @@ export const getStakingApy = memoize((asset_1, ...args_1) => __awaiter(void 0, [
|
|
|
140
140
|
return yield getApyFromDfsApi('PT USDe May', network);
|
|
141
141
|
if (asset === 'PT srUSDe Apr')
|
|
142
142
|
return yield getApyFromDfsApi('PT srUSDe Apr', network);
|
|
143
|
+
if (asset === 'GHO')
|
|
144
|
+
return yield getApyFromDfsApi('GHO', network);
|
|
143
145
|
}
|
|
144
146
|
catch (e) {
|
|
145
147
|
console.error(`Failed to fetch APY for ${asset}`);
|
package/esm/types/common.d.ts
CHANGED
|
@@ -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",
|
package/esm/types/common.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "2.1.72-gho-plasma-1-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": "
|
|
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,80 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { IncentiveEligibilityId, MMUsedAssets } from '../types/common';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
type EthenaPairEligibilityConfig = {
|
|
5
|
+
baseSymbol: string;
|
|
6
|
+
pairSymbol: string;
|
|
7
|
+
allowedBorrowAssets: string[];
|
|
8
|
+
maxHealthRatio: string; // exclusive upper bound
|
|
9
|
+
rewardSymbol: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const isEligibleForEthenaPairRewards = (
|
|
13
|
+
usedAssets: MMUsedAssets,
|
|
14
|
+
{ healthRatio }: { healthRatio: string },
|
|
15
|
+
{
|
|
16
|
+
baseSymbol,
|
|
17
|
+
pairSymbol,
|
|
18
|
+
allowedBorrowAssets,
|
|
19
|
+
maxHealthRatio,
|
|
20
|
+
rewardSymbol,
|
|
21
|
+
}: EthenaPairEligibilityConfig,
|
|
22
|
+
) => {
|
|
23
|
+
const baseSuppliedUsd = usedAssets[baseSymbol]?.suppliedUsd || '0';
|
|
24
|
+
const pairSuppliedUsd = usedAssets[pairSymbol]?.suppliedUsd || '0';
|
|
25
|
+
|
|
26
|
+
const anythingElseSupplied = Object.values(usedAssets).some(
|
|
27
|
+
(asset) => asset.isSupplied && asset.symbol !== baseSymbol && asset.symbol !== pairSymbol,
|
|
28
|
+
);
|
|
8
29
|
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
30
|
|
|
15
|
-
const
|
|
16
|
-
|
|
31
|
+
const totalAmountSupplied = new Dec(baseSuppliedUsd).add(pairSuppliedUsd);
|
|
32
|
+
if (totalAmountSupplied.eq(0)) return { isEligible: false, eligibleUSDAmount: '0' };
|
|
33
|
+
|
|
34
|
+
const percentageInBase = new Dec(baseSuppliedUsd).div(totalAmountSupplied).toNumber();
|
|
35
|
+
if (percentageInBase < 0.45 || percentageInBase > 0.55) return { isEligible: false, eligibleUSDAmount: '0' };
|
|
36
|
+
|
|
37
|
+
const percentageInPair = new Dec(pairSuppliedUsd).div(totalAmountSupplied).toNumber();
|
|
38
|
+
if (percentageInPair < 0.45 || percentageInPair > 0.55) return { isEligible: false, eligibleUSDAmount: '0' };
|
|
39
|
+
|
|
40
|
+
const anythingBorrowedNotAllowed = Object.values(usedAssets).some(
|
|
41
|
+
(asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol),
|
|
42
|
+
);
|
|
17
43
|
if (anythingBorrowedNotAllowed) return { isEligible: false, eligibleUSDAmount: '0' };
|
|
18
44
|
|
|
19
|
-
if (new Dec(healthRatio).gte(
|
|
45
|
+
if (new Dec(healthRatio).gte(maxHealthRatio)) return { isEligible: false, eligibleUSDAmount: '0' };
|
|
20
46
|
|
|
21
|
-
const halfAmountSupplied =
|
|
22
|
-
const
|
|
47
|
+
const halfAmountSupplied = totalAmountSupplied.div(2);
|
|
48
|
+
const rewardSuppliedUsd = usedAssets[rewardSymbol]?.suppliedUsd || '0';
|
|
49
|
+
const eligibleUSDAmount = Dec.min(rewardSuppliedUsd, halfAmountSupplied).toString();
|
|
23
50
|
|
|
24
|
-
return { isEligible: true, eligibleUSDAmount
|
|
51
|
+
return { isEligible: true, eligibleUSDAmount };
|
|
25
52
|
};
|
|
26
53
|
|
|
54
|
+
export const isEligibleForEthenaUSDeRewards = (usedAssets: MMUsedAssets, { healthRatio }: { healthRatio: string }) => isEligibleForEthenaPairRewards(
|
|
55
|
+
usedAssets,
|
|
56
|
+
{ healthRatio },
|
|
57
|
+
{
|
|
58
|
+
baseSymbol: 'USDe',
|
|
59
|
+
pairSymbol: 'sUSDe',
|
|
60
|
+
allowedBorrowAssets: ['USDC', 'USDT', 'USDS'],
|
|
61
|
+
maxHealthRatio: '2.5',
|
|
62
|
+
rewardSymbol: 'USDe',
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
export const isEligibleForEthenaGHORewards = (usedAssets: MMUsedAssets, { healthRatio }: { healthRatio: string }) => isEligibleForEthenaPairRewards(
|
|
67
|
+
usedAssets,
|
|
68
|
+
{ healthRatio },
|
|
69
|
+
{
|
|
70
|
+
baseSymbol: 'syrupUSDT',
|
|
71
|
+
pairSymbol: 'GHO',
|
|
72
|
+
allowedBorrowAssets: ['USDT'],
|
|
73
|
+
maxHealthRatio: '2',
|
|
74
|
+
rewardSymbol: 'GHO',
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
27
78
|
export const isEligibleForAaveV3ArbitrumEthSupply = (usedAssets: MMUsedAssets) => {
|
|
28
79
|
const ETHAmountSupplied = usedAssets.ETH?.suppliedUsd || '0';
|
|
29
80
|
const ETHAmountBorrowed = usedAssets.ETH?.borrowedUsd || '0';
|
|
@@ -51,4 +102,5 @@ export const EligibilityMapping: { [key in IncentiveEligibilityId]: (usedAssets:
|
|
|
51
102
|
[IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: isEligibleForAaveV3ArbitrumEthSupply,
|
|
52
103
|
[IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: isEligibleForAaveV3ArbitrumETHLSBorrow,
|
|
53
104
|
[IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasma]: isEligibleForEthenaUSDeRewards,
|
|
105
|
+
[IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasmaGHO]: isEligibleForEthenaGHORewards,
|
|
54
106
|
};
|
package/src/staking/staking.ts
CHANGED
|
@@ -64,7 +64,7 @@ export const STAKING_ASSETS = [
|
|
|
64
64
|
'cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH',
|
|
65
65
|
'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS', 'tETH', 'PT sUSDe Sep', 'PT USDe Sep',
|
|
66
66
|
'PT sUSDe Nov', 'PT USDe Nov', 'PT USDe Jan', 'PT sUSDe Jan', 'wrsETH', 'wstETH', 'syrupUSDT', 'syrupUSDC', 'wstUSR',
|
|
67
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
67
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'GHO',
|
|
68
68
|
];
|
|
69
69
|
|
|
70
70
|
export const getStakingApy = memoize(async (asset: string, network: number = NetworkNumber.Eth) => {
|
|
@@ -89,7 +89,7 @@ export const getStakingApy = memoize(async (asset: string, network: number = Net
|
|
|
89
89
|
if (asset === 'PT sUSDe Sep') return await getApyFromDfsApi('PT sUSDe Sep', network);
|
|
90
90
|
if (asset === 'PT USDe Sep') return await getApyFromDfsApi('PT USDe Sep', network);
|
|
91
91
|
if (asset === 'tETH') return await getApyFromDfsApi('tETH');
|
|
92
|
-
if (asset === 'USDe') return await getApyFromDfsApi('USDe');
|
|
92
|
+
if (asset === 'USDe') return await getApyFromDfsApi('USDe', network);
|
|
93
93
|
if (asset === 'PT sUSDe Nov') return await getApyFromDfsApi('PT sUSDe Nov', network);
|
|
94
94
|
if (asset === 'PT USDe Nov') return await getApyFromDfsApi('PT USDe Nov', network);
|
|
95
95
|
if (asset === 'PT USDe Jan') return await getApyFromDfsApi('PT USDe Jan', network);
|
|
@@ -104,6 +104,7 @@ export const getStakingApy = memoize(async (asset: string, network: number = Net
|
|
|
104
104
|
if (asset === 'PT sUSDe May') return await getApyFromDfsApi('PT sUSDe May', network);
|
|
105
105
|
if (asset === 'PT USDe May') return await getApyFromDfsApi('PT USDe May', network);
|
|
106
106
|
if (asset === 'PT srUSDe Apr') return await getApyFromDfsApi('PT srUSDe Apr', network);
|
|
107
|
+
if (asset === 'GHO') return await getApyFromDfsApi('GHO', network);
|
|
107
108
|
} catch (e) {
|
|
108
109
|
console.error(`Failed to fetch APY for ${asset}`);
|
|
109
110
|
}
|
package/src/types/common.ts
CHANGED
|
@@ -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 {
|