@defisaver/positions-sdk 2.0.13 → 2.0.14-dev-portfolio1
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/CLAUDE.md +32 -0
- package/cjs/aaveV2/index.js +1 -0
- package/cjs/aaveV3/index.d.ts +12 -0
- package/cjs/aaveV3/index.js +93 -1
- package/cjs/claiming/aaveV3.d.ts +9 -0
- package/cjs/claiming/aaveV3.js +148 -0
- package/cjs/claiming/compV3.d.ts +15 -0
- package/cjs/claiming/compV3.js +34 -0
- package/cjs/claiming/index.d.ts +6 -0
- package/cjs/claiming/index.js +46 -0
- package/cjs/claiming/king.d.ts +4 -0
- package/cjs/claiming/king.js +72 -0
- package/cjs/claiming/morphoBlue.d.ts +6 -0
- package/cjs/claiming/morphoBlue.js +113 -0
- package/cjs/claiming/spark.d.ts +6 -0
- package/cjs/claiming/spark.js +188 -0
- package/cjs/config/contracts.d.ts +2681 -0
- package/cjs/config/contracts.js +103 -2
- package/cjs/constants/index.d.ts +4 -0
- package/cjs/constants/index.js +6 -2
- package/cjs/contracts.d.ts +3027 -23
- package/cjs/contracts.js +10 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -1
- package/cjs/liquity/index.d.ts +11 -0
- package/cjs/liquity/index.js +39 -1
- package/cjs/liquityV2/index.d.ts +35 -0
- package/cjs/liquityV2/index.js +136 -1
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/markets/compound/marketsAssets.js +2 -2
- package/cjs/markets/spark/marketAssets.js +1 -1
- package/cjs/morphoBlue/index.d.ts +5 -0
- package/cjs/morphoBlue/index.js +38 -4
- package/cjs/portfolio/index.d.ts +6 -1
- package/cjs/portfolio/index.js +295 -10
- package/cjs/services/utils.d.ts +5 -0
- package/cjs/services/utils.js +33 -1
- package/cjs/services/viem.d.ts +12 -12
- package/cjs/spark/index.js +1 -0
- package/cjs/staking/staking.js +3 -1
- package/cjs/types/claiming.d.ts +93 -0
- package/cjs/types/claiming.js +27 -0
- package/cjs/umbrella/index.d.ts +5 -0
- package/cjs/umbrella/index.js +50 -0
- package/cjs/umbrella/umbrellaUtils.d.ts +22 -0
- package/cjs/umbrella/umbrellaUtils.js +34 -0
- package/esm/aaveV2/index.js +1 -0
- package/esm/aaveV3/index.d.ts +12 -0
- package/esm/aaveV3/index.js +91 -1
- package/esm/claiming/aaveV3.d.ts +9 -0
- package/esm/claiming/aaveV3.js +139 -0
- package/esm/claiming/compV3.d.ts +15 -0
- package/esm/claiming/compV3.js +30 -0
- package/esm/claiming/index.d.ts +6 -0
- package/esm/claiming/index.js +6 -0
- package/esm/claiming/king.d.ts +4 -0
- package/esm/claiming/king.js +64 -0
- package/esm/claiming/morphoBlue.d.ts +6 -0
- package/esm/claiming/morphoBlue.js +104 -0
- package/esm/claiming/spark.d.ts +6 -0
- package/esm/claiming/spark.js +179 -0
- package/esm/config/contracts.d.ts +2681 -0
- package/esm/config/contracts.js +102 -1
- package/esm/constants/index.d.ts +4 -0
- package/esm/constants/index.js +5 -1
- package/esm/contracts.d.ts +3027 -23
- package/esm/contracts.js +9 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/liquity/index.d.ts +11 -0
- package/esm/liquity/index.js +38 -1
- package/esm/liquityV2/index.d.ts +35 -0
- package/esm/liquityV2/index.js +137 -4
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/markets/compound/marketsAssets.js +2 -2
- package/esm/markets/spark/marketAssets.js +1 -1
- package/esm/morphoBlue/index.d.ts +5 -0
- package/esm/morphoBlue/index.js +38 -5
- package/esm/portfolio/index.d.ts +6 -1
- package/esm/portfolio/index.js +300 -15
- package/esm/services/utils.d.ts +5 -0
- package/esm/services/utils.js +31 -0
- package/esm/services/viem.d.ts +12 -12
- package/esm/spark/index.js +1 -0
- package/esm/staking/staking.js +3 -1
- package/esm/types/claiming.d.ts +93 -0
- package/esm/types/claiming.js +24 -0
- package/esm/umbrella/index.d.ts +5 -0
- package/esm/umbrella/index.js +46 -0
- package/esm/umbrella/umbrellaUtils.d.ts +22 -0
- package/esm/umbrella/umbrellaUtils.js +28 -0
- package/package.json +2 -2
- package/src/aaveV2/index.ts +2 -1
- package/src/aaveV3/index.ts +100 -2
- package/src/claiming/aaveV3.ts +163 -0
- package/src/claiming/compV3.ts +23 -0
- package/src/claiming/index.ts +13 -0
- package/src/claiming/king.ts +66 -0
- package/src/claiming/morphoBlue.ts +119 -0
- package/src/claiming/spark.ts +226 -0
- package/src/config/contracts.ts +105 -5
- package/src/constants/index.ts +5 -1
- package/src/contracts.ts +14 -1
- package/src/index.ts +2 -0
- package/src/liquity/index.ts +57 -2
- package/src/liquityV2/index.ts +241 -4
- package/src/markets/aave/marketAssets.ts +1 -1
- package/src/markets/compound/marketsAssets.ts +2 -2
- package/src/markets/spark/marketAssets.ts +1 -1
- package/src/morphoBlue/index.ts +43 -6
- package/src/portfolio/index.ts +302 -15
- package/src/services/utils.ts +37 -1
- package/src/spark/index.ts +2 -1
- package/src/staking/staking.ts +2 -1
- package/src/types/claiming.ts +109 -0
- package/src/umbrella/index.ts +70 -0
- package/src/umbrella/umbrellaUtils.ts +30 -0
package/cjs/contracts.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FluidViewContractViem = exports.LiquityV2LegacyViewContractViem = exports.LiquityV2ViewContractViem = exports.LiquityActivePoolContractViem = exports.LiquityPriceFeedContractViem = exports.LiquityTroveManagerContractViem = exports.LiquityCollSurplusPoolContractViem = exports.LiquityViewContractViem = exports.BTCPriceFeedContractViem = exports.WeETHPriceFeedContractViem = exports.ComptrollerContractViem = exports.CompoundLoanInfoContractViem = exports.McdJugContractViem = exports.McdDogContractViem = exports.McdSpotterContractViem = exports.McdVatContractViem = exports.McdViewContractViem = exports.McdGetCdpsContractViem = exports.LlamaLendViewContractViem = exports.CrvUSDFactoryContractViem = exports.CrvUSDViewContractViem = exports.EulerV2ViewContractViem = exports.SparkIncentiveDataProviderContractViem = exports.SparkViewContractViem = exports.CompV3ViewContractViem = exports.WstETHPriceFeedContractViem = exports.USDCPriceFeedContractViem = exports.ETHPriceFeedContractViem = exports.COMPPriceFeedContractViem = exports.DFSFeedRegistryContractViem = exports.FeedRegistryContractViem = exports.AaveIncentiveDataProviderV3ContractViem = exports.AaveV3ViewContractViem = exports.AaveLoanInfoV2ContractViem = exports.MorphoBlueViewContractViem = exports.createViemContractFromConfigFunc = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
36
|
+
exports.StkAAVEViem = exports.LiquityV2sBoldVaultViem = exports.AaveRewardsControllerViem = exports.SparkRewardsControllerViem = exports.UUPSViem = exports.LiquityStabilityPoolViem = exports.LiquityLQTYStakingViem = exports.AaveUmbrellaViewViem = exports.AaveIncentivesControllerViem = exports.FluidViewContractViem = exports.LiquityV2LegacyViewContractViem = exports.LiquityV2ViewContractViem = exports.LiquityActivePoolContractViem = exports.LiquityPriceFeedContractViem = exports.LiquityTroveManagerContractViem = exports.LiquityCollSurplusPoolContractViem = exports.LiquityViewContractViem = exports.BTCPriceFeedContractViem = exports.WeETHPriceFeedContractViem = exports.ComptrollerContractViem = exports.CompoundLoanInfoContractViem = exports.McdJugContractViem = exports.McdDogContractViem = exports.McdSpotterContractViem = exports.McdVatContractViem = exports.McdViewContractViem = exports.McdGetCdpsContractViem = exports.LlamaLendViewContractViem = exports.CrvUSDFactoryContractViem = exports.CrvUSDViewContractViem = exports.EulerV2ViewContractViem = exports.SparkIncentiveDataProviderContractViem = exports.SparkViewContractViem = exports.CompV3ViewContractViem = exports.WstETHPriceFeedContractViem = exports.USDCPriceFeedContractViem = exports.ETHPriceFeedContractViem = exports.COMPPriceFeedContractViem = exports.DFSFeedRegistryContractViem = exports.FeedRegistryContractViem = exports.AaveIncentiveDataProviderV3ContractViem = exports.AaveV3ViewContractViem = exports.AaveLoanInfoV2ContractViem = exports.MorphoBlueViewContractViem = exports.createViemContractFromConfigFunc = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
37
37
|
const viem_1 = require("viem");
|
|
38
38
|
const configRaw = __importStar(require("./config/contracts"));
|
|
39
39
|
// @ts-ignore
|
|
@@ -119,3 +119,12 @@ exports.LiquityActivePoolContractViem = (0, exports.createViemContractFromConfig
|
|
|
119
119
|
exports.LiquityV2ViewContractViem = (0, exports.createViemContractFromConfigFunc)('LiquityV2View');
|
|
120
120
|
exports.LiquityV2LegacyViewContractViem = (0, exports.createViemContractFromConfigFunc)('LiquityV2LegacyView');
|
|
121
121
|
exports.FluidViewContractViem = (0, exports.createViemContractFromConfigFunc)('FluidView');
|
|
122
|
+
exports.AaveIncentivesControllerViem = (0, exports.createViemContractFromConfigFunc)('AaveIncentivesController');
|
|
123
|
+
exports.AaveUmbrellaViewViem = (0, exports.createViemContractFromConfigFunc)('AaveUmbrellaView');
|
|
124
|
+
exports.LiquityLQTYStakingViem = (0, exports.createViemContractFromConfigFunc)('LiquityLQTYStaking');
|
|
125
|
+
exports.LiquityStabilityPoolViem = (0, exports.createViemContractFromConfigFunc)('LiquityStabilityPool');
|
|
126
|
+
exports.UUPSViem = (0, exports.createViemContractFromConfigFunc)('UUPS');
|
|
127
|
+
exports.SparkRewardsControllerViem = (0, exports.createViemContractFromConfigFunc)('SparkRewardsController');
|
|
128
|
+
exports.AaveRewardsControllerViem = (0, exports.createViemContractFromConfigFunc)('AaveRewardsController');
|
|
129
|
+
exports.LiquityV2sBoldVaultViem = (0, exports.createViemContractFromConfigFunc)('LiquityV2sBoldVault');
|
|
130
|
+
exports.StkAAVEViem = (0, exports.createViemContractFromConfigFunc)('StkAAVE');
|
package/cjs/index.d.ts
CHANGED
|
@@ -18,5 +18,6 @@ import * as morphoBlue from './morphoBlue';
|
|
|
18
18
|
import * as llamaLend from './llamaLend';
|
|
19
19
|
import * as eulerV2 from './eulerV2';
|
|
20
20
|
import * as portfolio from './portfolio';
|
|
21
|
+
import * as claiming from './claiming';
|
|
21
22
|
export * from './types';
|
|
22
|
-
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, };
|
|
23
|
+
export { aaveV2, aaveV3, compoundV2, compoundV3, spark, curveUsd, liquity, liquityV2, maker, exchange, staking, moneymarket, markets, helpers, morphoBlue, llamaLend, eulerV2, fluid, portfolio, claiming, };
|
package/cjs/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.portfolio = exports.fluid = exports.eulerV2 = exports.llamaLend = exports.morphoBlue = exports.helpers = exports.markets = exports.moneymarket = exports.staking = exports.exchange = exports.maker = exports.liquityV2 = exports.liquity = exports.curveUsd = exports.spark = exports.compoundV3 = exports.compoundV2 = exports.aaveV3 = exports.aaveV2 = void 0;
|
|
39
|
+
exports.claiming = exports.portfolio = exports.fluid = exports.eulerV2 = exports.llamaLend = exports.morphoBlue = exports.helpers = exports.markets = exports.moneymarket = exports.staking = exports.exchange = exports.maker = exports.liquityV2 = exports.liquity = exports.curveUsd = exports.spark = exports.compoundV3 = exports.compoundV2 = exports.aaveV3 = exports.aaveV2 = void 0;
|
|
40
40
|
require("./setup");
|
|
41
41
|
const fluid = __importStar(require("./fluid"));
|
|
42
42
|
exports.fluid = fluid;
|
|
@@ -76,4 +76,6 @@ const eulerV2 = __importStar(require("./eulerV2"));
|
|
|
76
76
|
exports.eulerV2 = eulerV2;
|
|
77
77
|
const portfolio = __importStar(require("./portfolio"));
|
|
78
78
|
exports.portfolio = portfolio;
|
|
79
|
+
const claiming = __importStar(require("./claiming"));
|
|
80
|
+
exports.claiming = claiming;
|
|
79
81
|
__exportStar(require("./types"), exports);
|
package/cjs/liquity/index.d.ts
CHANGED
|
@@ -8,3 +8,14 @@ export declare const getLiquityAccountBalances: (provider: EthereumProvider, net
|
|
|
8
8
|
export declare const getDebtInFront: (provider: EthereumProvider, address: EthAddress) => Promise<string>;
|
|
9
9
|
export declare const _getLiquityTroveInfo: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<LiquityTroveInfo>;
|
|
10
10
|
export declare const getLiquityTroveInfo: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress) => Promise<LiquityTroveInfo>;
|
|
11
|
+
export declare const getLiquityStakingData: (provider: Client, network: NetworkNumber, address: EthAddress) => Promise<{
|
|
12
|
+
totalLUSDDeposited: string;
|
|
13
|
+
totalLQTYStaked: string;
|
|
14
|
+
stakedLQTY: string;
|
|
15
|
+
stakedLUSDBalance: string;
|
|
16
|
+
rewardETH: string;
|
|
17
|
+
rewardLUSD: string;
|
|
18
|
+
stabilityRewardETH: string;
|
|
19
|
+
stabilityRewardLQTY: string;
|
|
20
|
+
showStakingBalances: boolean;
|
|
21
|
+
}>;
|
package/cjs/liquity/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getLiquityTroveInfo = exports._getLiquityTroveInfo = exports.getDebtInFront = exports.getLiquityAccountBalances = exports._getLiquityAccountBalances = exports.LIQUITY_RECOVERY_MODE_RATIO = exports.LIQUITY_NORMAL_MODE_RATIO = void 0;
|
|
15
|
+
exports.getLiquityStakingData = exports.getLiquityTroveInfo = exports._getLiquityTroveInfo = exports.getDebtInFront = exports.getLiquityAccountBalances = exports._getLiquityAccountBalances = exports.LIQUITY_RECOVERY_MODE_RATIO = exports.LIQUITY_NORMAL_MODE_RATIO = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const common_1 = require("../types/common");
|
|
@@ -20,6 +20,7 @@ const contracts_1 = require("../contracts");
|
|
|
20
20
|
const types_1 = require("../types");
|
|
21
21
|
const constants_1 = require("../constants");
|
|
22
22
|
const viem_1 = require("../services/viem");
|
|
23
|
+
const utils_1 = require("../services/utils");
|
|
23
24
|
exports.LIQUITY_NORMAL_MODE_RATIO = 110; // MCR
|
|
24
25
|
exports.LIQUITY_RECOVERY_MODE_RATIO = 150; // CCR
|
|
25
26
|
const _getLiquityAccountBalances = (provider, network, block, addressMapping, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -96,3 +97,40 @@ const _getLiquityTroveInfo = (provider, network, address) => __awaiter(void 0, v
|
|
|
96
97
|
exports._getLiquityTroveInfo = _getLiquityTroveInfo;
|
|
97
98
|
const getLiquityTroveInfo = (provider, network, address) => __awaiter(void 0, void 0, void 0, function* () { return (0, exports._getLiquityTroveInfo)((0, viem_1.getViemProvider)(provider, network, { batch: { multicall: true } }), network, address); });
|
|
98
99
|
exports.getLiquityTroveInfo = getLiquityTroveInfo;
|
|
100
|
+
const getLiquityStakingData = (provider, network, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
+
const lqtyStakingView = (0, contracts_1.LiquityLQTYStakingViem)(provider, network);
|
|
102
|
+
const stabilityPoolView = (0, contracts_1.LiquityStabilityPoolViem)(provider, network);
|
|
103
|
+
const [stakes, pendingETHGain, pendingLUSDGain, totalLQTYStakes, stabilityPoolETHGain, stabilityPoolLQTYGain, compoundedLUSDDeposit, totalLUSDDeposits,] = yield Promise.all([
|
|
104
|
+
lqtyStakingView.read.stakes([address]),
|
|
105
|
+
lqtyStakingView.read.getPendingETHGain([address]),
|
|
106
|
+
lqtyStakingView.read.getPendingLUSDGain([address]),
|
|
107
|
+
lqtyStakingView.read.totalLQTYStaked(),
|
|
108
|
+
stabilityPoolView.read.getDepositorETHGain([address]),
|
|
109
|
+
stabilityPoolView.read.getDepositorLQTYGain([address]),
|
|
110
|
+
stabilityPoolView.read.getCompoundedLUSDDeposit([address]),
|
|
111
|
+
stabilityPoolView.read.getTotalLUSDDeposits(),
|
|
112
|
+
]);
|
|
113
|
+
const totalLUSDDeposited = (0, utils_1.getEthAmountForDecimals)(totalLUSDDeposits, 18);
|
|
114
|
+
const totalLQTYStaked = (0, utils_1.getEthAmountForDecimals)(totalLQTYStakes, 18);
|
|
115
|
+
const stakedLQTY = (0, utils_1.getEthAmountForDecimals)(stakes, 18);
|
|
116
|
+
const stakedLUSDBalance = (0, utils_1.getEthAmountForDecimals)(compoundedLUSDDeposit, 18);
|
|
117
|
+
const rewardETH = (0, utils_1.getEthAmountForDecimals)(pendingETHGain, 18);
|
|
118
|
+
const rewardLUSD = (0, utils_1.getEthAmountForDecimals)(pendingLUSDGain, 18);
|
|
119
|
+
const stabilityRewardETH = (0, utils_1.getEthAmountForDecimals)(stabilityPoolETHGain, 18);
|
|
120
|
+
const stabilityRewardLQTY = (0, utils_1.getEthAmountForDecimals)(stabilityPoolLQTYGain, 18);
|
|
121
|
+
const showStakingBalances = !!(+stakedLQTY || +stakedLUSDBalance
|
|
122
|
+
|| +rewardETH || +rewardLUSD
|
|
123
|
+
|| +stabilityRewardETH || +stabilityRewardLQTY);
|
|
124
|
+
return {
|
|
125
|
+
totalLUSDDeposited,
|
|
126
|
+
totalLQTYStaked,
|
|
127
|
+
stakedLQTY,
|
|
128
|
+
stakedLUSDBalance,
|
|
129
|
+
rewardETH,
|
|
130
|
+
rewardLUSD,
|
|
131
|
+
stabilityRewardETH,
|
|
132
|
+
stabilityRewardLQTY,
|
|
133
|
+
showStakingBalances,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
exports.getLiquityStakingData = getLiquityStakingData;
|
package/cjs/liquityV2/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Client, PublicClient } from 'viem';
|
|
2
2
|
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
3
3
|
import { LiquityV2AssetsData, LiquityV2MarketData, LiquityV2MarketInfo, LiquityV2TroveData, LiquityV2Versions } from '../types';
|
|
4
|
+
export type SPYieldGainParameters = {
|
|
5
|
+
P: string;
|
|
6
|
+
aggWeightedDebtSum: string;
|
|
7
|
+
currentScale: string;
|
|
8
|
+
lastAggUpdateTime: string;
|
|
9
|
+
totalBoldDeposits: string;
|
|
10
|
+
yieldGainsPending: string;
|
|
11
|
+
};
|
|
4
12
|
export declare const _getLiquityV2MarketData: (provider: Client, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo) => Promise<LiquityV2MarketData>;
|
|
5
13
|
export declare const getLiquityV2MarketData: (provider: EthereumProvider, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo) => Promise<LiquityV2MarketData>;
|
|
6
14
|
export declare const _getLiquityV2UserTroveIds: (provider: PublicClient, network: NetworkNumber, selectedMarket: LiquityV2MarketInfo, troveNFTAddress: EthAddress, limitBlocksForEventFetching: boolean, account: EthAddress) => Promise<{
|
|
@@ -29,3 +37,30 @@ export declare const getLiquityV2TroveData: (provider: EthereumProvider, network
|
|
|
29
37
|
allMarketsData: Record<LiquityV2Versions, LiquityV2MarketData>;
|
|
30
38
|
}, fetchDebtInFront?: boolean) => Promise<LiquityV2TroveData>;
|
|
31
39
|
export declare const getLiquityV2ClaimableCollateral: (collSurplusPoolAddress: EthAddress, account: EthAddress, provider: EthereumProvider, network: NetworkNumber) => Promise<string>;
|
|
40
|
+
export type sBoldYieldParameters = {
|
|
41
|
+
WETH: string;
|
|
42
|
+
wsETH: string;
|
|
43
|
+
rETH: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const getLiquityV2Staking: (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress) => Promise<{
|
|
46
|
+
totalBOLDDeposited: string;
|
|
47
|
+
stakedBOLDBalance: string;
|
|
48
|
+
stabilityRewardColl: string;
|
|
49
|
+
stabilityRewardYield: string;
|
|
50
|
+
showStakingBalances: boolean;
|
|
51
|
+
debtTokenBalance: string;
|
|
52
|
+
stabilityPoolApy: string;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const getLiquitySAndYBold: (provider: Client, network: NetworkNumber, markets: any, user: EthAddress) => Promise<{
|
|
55
|
+
spApy: string;
|
|
56
|
+
yBoldApy: string;
|
|
57
|
+
totalBoldDepositedSBold: string;
|
|
58
|
+
boldRateSBold: string;
|
|
59
|
+
maxWithdrawSBold: string;
|
|
60
|
+
totalBoldDepositedYBold: string;
|
|
61
|
+
boldRateYBold: string;
|
|
62
|
+
maxWithdrawYBold: string;
|
|
63
|
+
sBoldBalance: string;
|
|
64
|
+
yBoldBalance: string;
|
|
65
|
+
stYBoldBalance: string;
|
|
66
|
+
}>;
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
15
|
+
exports.getLiquitySAndYBold = exports.getLiquityV2Staking = exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
@@ -300,3 +300,138 @@ const getLiquityV2ClaimableCollateral = (collSurplusPoolAddress, account, provid
|
|
|
300
300
|
return claimableCollateral.toString();
|
|
301
301
|
});
|
|
302
302
|
exports.getLiquityV2ClaimableCollateral = getLiquityV2ClaimableCollateral;
|
|
303
|
+
const stabilityPoolAddrForMarket = {
|
|
304
|
+
[types_1.LiquityV2Versions.LiquityV2Eth]: '0x5721cbbd64fc7Ae3Ef44A0A3F9a790A9264Cf9BF',
|
|
305
|
+
[types_1.LiquityV2Versions.LiquityV2WstEth]: '0x9502b7c397e9aa22fe9db7ef7daf21cd2aebe56b',
|
|
306
|
+
[types_1.LiquityV2Versions.LiquityV2REth]: '0xd442e41019b7f5c4dd78f50dc03726c446148695',
|
|
307
|
+
[types_1.LiquityV2Versions.LiquityV2EthLegacy]: '0x',
|
|
308
|
+
[types_1.LiquityV2Versions.LiquityV2REthLegacy]: '0x',
|
|
309
|
+
[types_1.LiquityV2Versions.LiquityV2WstEthLegacy]: '0x',
|
|
310
|
+
};
|
|
311
|
+
const activePoolAddrForMarket = {
|
|
312
|
+
[types_1.LiquityV2Versions.LiquityV2Eth]: '0xeB5A8C825582965f1d84606E078620a84ab16AfE',
|
|
313
|
+
[types_1.LiquityV2Versions.LiquityV2WstEth]: '0x531a8f99c70d6a56a7cee02d6b4281650d7919a0',
|
|
314
|
+
[types_1.LiquityV2Versions.LiquityV2REth]: '0x9074d72cc82dad1e13e454755aa8f144c479532f',
|
|
315
|
+
[types_1.LiquityV2Versions.LiquityV2EthLegacy]: '0x',
|
|
316
|
+
[types_1.LiquityV2Versions.LiquityV2WstEthLegacy]: '0x',
|
|
317
|
+
[types_1.LiquityV2Versions.LiquityV2REthLegacy]: '0x',
|
|
318
|
+
};
|
|
319
|
+
function ceilDiv(a, b) {
|
|
320
|
+
return new decimal_js_1.default(a).add(new decimal_js_1.default(b).sub(1)).div(b).toString();
|
|
321
|
+
}
|
|
322
|
+
const SP_YIELD_SPLIT = new decimal_js_1.default(75).mul(Math.pow(10, 16)).toString(); // 75%
|
|
323
|
+
const calcPendingSPYield = (aggWeightedDebtSum, lastAggUpdateTime, currentTime) => {
|
|
324
|
+
const a = new decimal_js_1.default(aggWeightedDebtSum).mul(new decimal_js_1.default(currentTime).sub(new decimal_js_1.default(lastAggUpdateTime))).toString();
|
|
325
|
+
const b = new decimal_js_1.default(constants_1.SECONDS_PER_YEAR).mul(1000).mul(1e18).toString();
|
|
326
|
+
return new decimal_js_1.default(ceilDiv(a, b)).mul(SP_YIELD_SPLIT).div(1e18).toString();
|
|
327
|
+
};
|
|
328
|
+
const calculateStabilityPoolApy = (spYieldGainParams) => {
|
|
329
|
+
const { aggWeightedDebtSum, totalBoldDeposits, lastAggUpdateTime, yieldGainsPending, } = spYieldGainParams;
|
|
330
|
+
if (new decimal_js_1.default(totalBoldDeposits).eq(0)) {
|
|
331
|
+
return '0';
|
|
332
|
+
}
|
|
333
|
+
const now = Date.now().toString();
|
|
334
|
+
const lastAggUpdateTimeScaled = new decimal_js_1.default(lastAggUpdateTime).mul(1000).toString();
|
|
335
|
+
const pendingSPYield = new decimal_js_1.default(calcPendingSPYield(aggWeightedDebtSum, lastAggUpdateTimeScaled, now)).add(yieldGainsPending).toString();
|
|
336
|
+
const annualizedYield = new decimal_js_1.default(pendingSPYield).mul(constants_1.SECONDS_PER_YEAR).mul(1000).div(new decimal_js_1.default(now).minus(lastAggUpdateTimeScaled))
|
|
337
|
+
.toString();
|
|
338
|
+
return new decimal_js_1.default(annualizedYield).div(totalBoldDeposits).mul(100).toString();
|
|
339
|
+
};
|
|
340
|
+
const getYBoldApyApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
|
+
const url = 'https://ydaemon.yearn.fi/1/vaults/0x23346B04a7f55b8760E5860AA5A77383D63491cD?strategiesDetails=withDetails&strategiesCondition=inQueue';
|
|
342
|
+
const yBoldData = yield fetch(url)
|
|
343
|
+
.then(res => res.json())
|
|
344
|
+
.catch(console.error);
|
|
345
|
+
return new decimal_js_1.default(yBoldData.apr.netAPR).mul(100).toString();
|
|
346
|
+
});
|
|
347
|
+
const calculateSPApy = (spYieldGainParams, spAPYs) => {
|
|
348
|
+
const { WETH, wsETH, rETH, } = spYieldGainParams;
|
|
349
|
+
const apy = new decimal_js_1.default(WETH).mul(spAPYs.apyEth).add(new decimal_js_1.default(wsETH).mul(spAPYs.apyWstEth)).add(new decimal_js_1.default(rETH).mul(spAPYs.apyREth))
|
|
350
|
+
.toString();
|
|
351
|
+
return apy;
|
|
352
|
+
};
|
|
353
|
+
const getLiquityV2Staking = (provider, network, market, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
354
|
+
const stabilityPoolView = (0, contracts_1.createViemContractFromConfigFunc)('LiquityV2StabilityPool', stabilityPoolAddrForMarket[market])(provider, network);
|
|
355
|
+
const activePoolView = (0, contracts_1.createViemContractFromConfigFunc)('LiquityV2ActivePool', activePoolAddrForMarket[market])(provider, network);
|
|
356
|
+
const debtTokenInfo = (0, tokens_1.getAssetInfo)((0, markets_1.LiquityV2Markets)(network)[market].debtToken, network);
|
|
357
|
+
const debtTokenContract = (0, contracts_1.createViemContractFromConfigFunc)('Erc20', debtTokenInfo.address)(provider, network);
|
|
358
|
+
const [stabilityRewardColl, stabilityRewardYield, compoundedBoldDeposit, totalBoldDeposits, P, currentScale, yieldGainsPending, debtTokenBalance, aggWeightedDebtSum, lastAggUpdateTime,] = yield Promise.all([
|
|
359
|
+
stabilityPoolView.read.getDepositorCollGain([user]),
|
|
360
|
+
stabilityPoolView.read.getDepositorYieldGain([user]),
|
|
361
|
+
stabilityPoolView.read.getCompoundedBoldDeposit([user]),
|
|
362
|
+
stabilityPoolView.read.getTotalBoldDeposits(),
|
|
363
|
+
stabilityPoolView.read.P(),
|
|
364
|
+
stabilityPoolView.read.currentScale(),
|
|
365
|
+
stabilityPoolView.read.getYieldGainsPending(),
|
|
366
|
+
debtTokenContract.read.balanceOf([user]),
|
|
367
|
+
activePoolView.read.aggWeightedDebtSum(),
|
|
368
|
+
activePoolView.read.lastAggUpdateTime(),
|
|
369
|
+
]);
|
|
370
|
+
const stabilityPoolYieldParams = {
|
|
371
|
+
aggWeightedDebtSum: aggWeightedDebtSum.toString(),
|
|
372
|
+
lastAggUpdateTime: lastAggUpdateTime.toString(),
|
|
373
|
+
P: P.toString(),
|
|
374
|
+
currentScale: currentScale.toString(),
|
|
375
|
+
yieldGainsPending: yieldGainsPending.toString(),
|
|
376
|
+
totalBoldDeposits: totalBoldDeposits.toString(),
|
|
377
|
+
};
|
|
378
|
+
const stabilityPoolApy = calculateStabilityPoolApy(stabilityPoolYieldParams);
|
|
379
|
+
const stakedBOLDBalanceForUser = (0, utils_1.getEthAmountForDecimals)(compoundedBoldDeposit.toString(), 18);
|
|
380
|
+
const stabilityRewardCollForUser = (0, utils_1.getEthAmountForDecimals)(stabilityRewardColl.toString(), 18);
|
|
381
|
+
const stabilityRewardYieldForUser = (0, utils_1.getEthAmountForDecimals)(stabilityRewardYield.toString(), 18);
|
|
382
|
+
return {
|
|
383
|
+
totalBOLDDeposited: (0, utils_1.getEthAmountForDecimals)(totalBoldDeposits.toString(), 18),
|
|
384
|
+
stakedBOLDBalance: stakedBOLDBalanceForUser,
|
|
385
|
+
stabilityRewardColl: stabilityRewardCollForUser,
|
|
386
|
+
stabilityRewardYield: stabilityRewardYieldForUser,
|
|
387
|
+
showStakingBalances: !!(+stakedBOLDBalanceForUser || +stabilityRewardCollForUser || +stabilityRewardYieldForUser),
|
|
388
|
+
debtTokenBalance: (0, utils_1.getEthAmountForDecimals)(debtTokenBalance.toString(), debtTokenInfo.decimals),
|
|
389
|
+
stabilityPoolApy,
|
|
390
|
+
};
|
|
391
|
+
});
|
|
392
|
+
exports.getLiquityV2Staking = getLiquityV2Staking;
|
|
393
|
+
const getLiquitySAndYBold = (provider, network, markets, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
394
|
+
const sBold = (0, contracts_1.LiquityV2sBoldVaultViem)(provider, network);
|
|
395
|
+
const yBold = (0, contracts_1.createViemContractFromConfigFunc)('Erc4626', '0x9F4330700a36B29952869fac9b33f45EEdd8A3d8')(provider, network);
|
|
396
|
+
const stYBold = (0, contracts_1.createViemContractFromConfigFunc)('Erc4626', '0x23346B04a7f55b8760E5860AA5A77383D63491cD')(provider, network);
|
|
397
|
+
const spAPYs = {
|
|
398
|
+
apyEth: markets[types_1.LiquityV2Versions.LiquityV2Eth].data.stabilityPoolApy,
|
|
399
|
+
apyWstEth: markets[types_1.LiquityV2Versions.LiquityV2WstEth].data.stabilityPoolApy,
|
|
400
|
+
apyREth: markets[types_1.LiquityV2Versions.LiquityV2REth].data.stabilityPoolApy,
|
|
401
|
+
};
|
|
402
|
+
const [sBoldTotalAssets, sBoldConvertToShares, sBoldMaxWithdraw, wethApy, wsETHApy, rETHApy, yBoldTotalAssets, yBoldMaxWithdraw, stYBoldConvertToShares, yBoldApy, sBoldBalance, yBoldBalance, stYBoldBalance,] = yield Promise.all([
|
|
403
|
+
sBold.read.totalAssets(),
|
|
404
|
+
sBold.read.convertToShares([BigInt(1e18)]),
|
|
405
|
+
sBold.read.maxWithdraw([user]),
|
|
406
|
+
sBold.read.sps([BigInt(0)]),
|
|
407
|
+
sBold.read.sps([BigInt(1)]),
|
|
408
|
+
sBold.read.sps([BigInt(2)]),
|
|
409
|
+
yBold.read.totalAssets(),
|
|
410
|
+
yBold.read.maxWithdraw([user]),
|
|
411
|
+
stYBold.read.convertToShares([BigInt(1e18)]),
|
|
412
|
+
getYBoldApyApi(),
|
|
413
|
+
sBold.read.balanceOf([user]),
|
|
414
|
+
yBold.read.balanceOf([user]),
|
|
415
|
+
stYBold.read.balanceOf([user]),
|
|
416
|
+
]);
|
|
417
|
+
const spMarketRes = {
|
|
418
|
+
WETH: new decimal_js_1.default(wethApy[1]).div(10000).toString(),
|
|
419
|
+
wsETH: new decimal_js_1.default(wsETHApy[1]).div(10000).toString(),
|
|
420
|
+
rETH: new decimal_js_1.default(rETHApy[1]).div(10000).toString(),
|
|
421
|
+
};
|
|
422
|
+
const spApy = calculateSPApy(spMarketRes, spAPYs);
|
|
423
|
+
return {
|
|
424
|
+
spApy,
|
|
425
|
+
yBoldApy,
|
|
426
|
+
totalBoldDepositedSBold: (0, tokens_1.assetAmountInEth)(sBoldTotalAssets.toString(), 'sBOLD'),
|
|
427
|
+
boldRateSBold: (0, tokens_1.assetAmountInEth)(sBoldConvertToShares.toString(), 'sBOLD'),
|
|
428
|
+
maxWithdrawSBold: (0, tokens_1.assetAmountInEth)(sBoldMaxWithdraw.toString(), 'sBOLD'),
|
|
429
|
+
totalBoldDepositedYBold: (0, tokens_1.assetAmountInEth)(yBoldTotalAssets.toString(), 'yBOLD'),
|
|
430
|
+
boldRateYBold: (0, tokens_1.assetAmountInEth)(stYBoldConvertToShares.toString(), 'yBOLD'),
|
|
431
|
+
maxWithdrawYBold: (0, tokens_1.assetAmountInEth)(yBoldMaxWithdraw.toString(), 'yBOLD'),
|
|
432
|
+
sBoldBalance: (0, tokens_1.assetAmountInEth)(sBoldBalance.toString(), 'sBOLD'),
|
|
433
|
+
yBoldBalance: (0, tokens_1.assetAmountInEth)(yBoldBalance.toString(), 'yBOLD'),
|
|
434
|
+
stYBoldBalance: (0, tokens_1.assetAmountInEth)(stYBoldBalance.toString(), 'yBOLD'),
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
exports.getLiquitySAndYBold = getLiquitySAndYBold;
|
|
@@ -10,7 +10,7 @@ exports.aaveV1AssetsDefaultMarket = [
|
|
|
10
10
|
exports.aaveV2AssetsDefaultMarket = ['USDT', 'WBTC', 'ETH', 'YFI', 'ZRX', 'UNI', 'AAVE', 'BAT', 'BUSD', 'DAI', 'ENJ', 'KNCL', 'LINK', 'MANA', 'MKR', 'REN', 'SNX', 'SUSD', 'TUSD', 'USDC', 'CRV', 'GUSD', 'BAL', 'xSUSHI', 'RENFIL', 'RAI', 'AMPL', 'USDP', 'DPI', 'FRAX', 'FEI', 'stETH', 'ENS', 'UST', 'CVX', '1INCH', 'LUSD'];
|
|
11
11
|
exports.aaveV3AssetsDefaultMarketEth = [
|
|
12
12
|
'ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH', 'USDe', 'ETHx', 'sUSDe', 'tBTC', 'cbBTC', 'USDS', 'rsETH', 'LBTC', 'eBTC', 'RLUSD', 'PT eUSDe May', 'PT sUSDe July', 'USDtb',
|
|
13
|
-
'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'EURC', 'FBTC', 'PT sUSDe Sep', 'PT USDe Sep', 'tETH', 'ezETH', 'XAUt', 'PT sUSDe Nov',
|
|
13
|
+
'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'EURC', 'FBTC', 'PT sUSDe Sep', 'PT USDe Sep', 'tETH', 'ezETH', 'XAUt', 'PT sUSDe Nov', 'PT USDe Nov',
|
|
14
14
|
];
|
|
15
15
|
exports.aaveV3AssetsDefaultMarketOpt = [
|
|
16
16
|
'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
|
|
@@ -7,7 +7,7 @@ exports.compoundV2CollateralAssets = [
|
|
|
7
7
|
'cETH', 'cDAI', 'cBAT', 'cZRX', 'cUSDC', 'cWBTC Legacy', 'cWBTC', 'cUSDT',
|
|
8
8
|
'cTUSD', 'cLINK', 'cUSDP', 'cUNI', 'cCOMP', 'cMKR', 'cSUSHI', 'cAAVE', 'cYFI',
|
|
9
9
|
].map((symbol) => (0, tokens_1.getAssetInfo)(symbol));
|
|
10
|
-
exports.v3USDCCollAssetsEth = ['COMP', 'WBTC', 'ETH', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'weETH', 'deUSD', 'sdeUSD'];
|
|
10
|
+
exports.v3USDCCollAssetsEth = ['COMP', 'WBTC', 'ETH', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'weETH', 'deUSD', 'sdeUSD', 'rsETH'];
|
|
11
11
|
exports.v3USDCCollAssetsArb = ['ARB', 'ETH', 'GMX', 'WBTC', 'wstETH', 'ezETH', 'wUSDM'];
|
|
12
12
|
exports.v3USDCCollAssetsBase = ['cbETH', 'ETH', 'wstETH', 'cbBTC', 'tBTC'];
|
|
13
13
|
exports.v3USDCCollAssetsOpt = ['ETH', 'OP', 'WBTC', 'wstETH'];
|
|
@@ -49,7 +49,7 @@ exports.v3USDbCCollAssets = {
|
|
|
49
49
|
[common_1.NetworkNumber.Base]: exports.v3USDbCCollAssetsBase,
|
|
50
50
|
[common_1.NetworkNumber.Linea]: [],
|
|
51
51
|
};
|
|
52
|
-
exports.v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
|
|
52
|
+
exports.v3USDTCollAssetsEth = ['COMP', 'ETH', 'WBTC', 'UNI', 'LINK', 'wstETH', 'cbBTC', 'tBTC', 'wUSDM', 'sFRAX', 'mETH', 'weETH', 'sdeUSD', 'deUSD'];
|
|
53
53
|
exports.v3USDTCollAssetsArb = ['ETH', 'WBTC', 'wstETH', 'ARB', 'GMX'];
|
|
54
54
|
exports.v3USDTCollAssetsOpt = ['ETH', 'WBTC', 'OP', 'wstETH'];
|
|
55
55
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sparkAssetsDefaultMarket = exports.sparkAssetsDefaultMarketEth = void 0;
|
|
4
4
|
const common_1 = require("../../types/common");
|
|
5
|
-
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS', 'LBTC', 'tBTC', 'ezETH', 'rsETH'];
|
|
5
|
+
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS', 'LBTC', 'tBTC', 'ezETH', 'rsETH', 'PYUSD'];
|
|
6
6
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
7
7
|
exports.sparkAssetsDefaultMarket = {
|
|
8
8
|
[common_1.NetworkNumber.Eth]: exports.sparkAssetsDefaultMarketEth,
|
|
@@ -7,3 +7,8 @@ export declare const _getMorphoBlueAccountBalances: (provider: Client, network:
|
|
|
7
7
|
export declare const getMorphoBlueAccountBalances: (provider: EthereumProvider, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress, selectedMarket: MorphoBlueMarketData) => Promise<PositionBalances>;
|
|
8
8
|
export declare function _getMorphoBlueAccountData(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBluePositionData>;
|
|
9
9
|
export declare function getMorphoBlueAccountData(provider: EthereumProvider, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<MorphoBluePositionData>;
|
|
10
|
+
export declare function getMorphoEarn(provider: Client, network: NetworkNumber, account: EthAddress, selectedMarket: MorphoBlueMarketData, marketInfo: MorphoBlueMarketInfo): Promise<{
|
|
11
|
+
apy: string;
|
|
12
|
+
amount: string;
|
|
13
|
+
amountUsd: string;
|
|
14
|
+
}>;
|
package/cjs/morphoBlue/index.js
CHANGED
|
@@ -17,6 +17,7 @@ exports._getMorphoBlueMarketData = _getMorphoBlueMarketData;
|
|
|
17
17
|
exports.getMorphoBlueMarketData = getMorphoBlueMarketData;
|
|
18
18
|
exports._getMorphoBlueAccountData = _getMorphoBlueAccountData;
|
|
19
19
|
exports.getMorphoBlueAccountData = getMorphoBlueAccountData;
|
|
20
|
+
exports.getMorphoEarn = getMorphoEarn;
|
|
20
21
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
21
22
|
const tokens_1 = require("@defisaver/tokens");
|
|
22
23
|
const common_1 = require("../types/common");
|
|
@@ -167,16 +168,15 @@ function _getMorphoBlueAccountData(provider, network, account, selectedMarket, m
|
|
|
167
168
|
]));
|
|
168
169
|
const usedAssets = {};
|
|
169
170
|
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
170
|
-
const loanTokenSupplied = (0, tokens_1.assetAmountInEth)(loanInfo.suppliedInAssets.toString(), marketInfo.loanToken);
|
|
171
171
|
const loanTokenBorrowed = (0, tokens_1.assetAmountInEth)(loanInfo.borrowedInAssets.toString(), marketInfo.loanToken);
|
|
172
172
|
usedAssets[marketInfo.loanToken] = {
|
|
173
173
|
symbol: loanTokenInfo.symbol,
|
|
174
|
-
supplied:
|
|
174
|
+
supplied: '0',
|
|
175
175
|
borrowed: loanTokenBorrowed,
|
|
176
|
-
isSupplied:
|
|
176
|
+
isSupplied: false,
|
|
177
177
|
isBorrowed: new decimal_js_1.default(loanInfo.borrowedInAssets.toString()).gt(0),
|
|
178
178
|
collateral: false,
|
|
179
|
-
suppliedUsd:
|
|
179
|
+
suppliedUsd: '0',
|
|
180
180
|
borrowedUsd: new decimal_js_1.default(loanTokenBorrowed).mul(loanTokenInfo.price).toString(),
|
|
181
181
|
};
|
|
182
182
|
const collateralTokenInfo = marketInfo.assetsData[marketInfo.collateralToken];
|
|
@@ -199,3 +199,37 @@ function getMorphoBlueAccountData(provider, network, account, selectedMarket, ma
|
|
|
199
199
|
return _getMorphoBlueAccountData((0, viem_1.getViemProvider)(provider, network), network, account, selectedMarket, marketInfo);
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
+
function getMorphoEarn(provider, network, account, selectedMarket, marketInfo) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const { loanToken, collateralToken, oracle, irm, lltv, } = selectedMarket;
|
|
205
|
+
const lltvInWei = new decimal_js_1.default(lltv).mul(constants_1.WAD).toString();
|
|
206
|
+
const viewContract = (0, contracts_1.MorphoBlueViewContractViem)(provider, network);
|
|
207
|
+
const loanInfo = (yield viewContract.read.getUserInfo([
|
|
208
|
+
{
|
|
209
|
+
loanToken, collateralToken, oracle, irm, lltv: BigInt(lltvInWei),
|
|
210
|
+
},
|
|
211
|
+
account
|
|
212
|
+
]));
|
|
213
|
+
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
214
|
+
const loanTokenSupplied = (0, tokens_1.assetAmountInEth)(loanInfo.suppliedInAssets.toString(), marketInfo.loanToken);
|
|
215
|
+
const loanTokenSuppliedUsd = new decimal_js_1.default(loanTokenSupplied).mul(loanTokenInfo.price).toString();
|
|
216
|
+
const usedAssets = {
|
|
217
|
+
[marketInfo.loanToken]: {
|
|
218
|
+
symbol: loanTokenInfo.symbol,
|
|
219
|
+
supplied: loanTokenSupplied,
|
|
220
|
+
borrowed: '0',
|
|
221
|
+
isSupplied: new decimal_js_1.default(loanInfo.suppliedInAssets.toString()).gt(0),
|
|
222
|
+
isBorrowed: false,
|
|
223
|
+
collateral: false,
|
|
224
|
+
suppliedUsd: loanTokenSuppliedUsd,
|
|
225
|
+
borrowedUsd: '0',
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
const { netApy } = (0, staking_1.calculateNetApy)({ usedAssets, assetsData: marketInfo.assetsData });
|
|
229
|
+
return {
|
|
230
|
+
apy: netApy,
|
|
231
|
+
amount: loanTokenSupplied,
|
|
232
|
+
amountUsd: loanTokenSuppliedUsd,
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
}
|
package/cjs/portfolio/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
2
2
|
import { PortfolioPositionsData } from '../types';
|
|
3
|
-
export declare function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], summerFiAddresses: EthAddress[]): Promise<
|
|
3
|
+
export declare function getPortfolioData(provider: EthereumProvider, network: NetworkNumber, defaultProvider: EthereumProvider, addresses: EthAddress[], summerFiAddresses: EthAddress[]): Promise<{
|
|
4
|
+
positions: PortfolioPositionsData;
|
|
5
|
+
stakingPositions: any;
|
|
6
|
+
rewardsData: any;
|
|
7
|
+
markets: any;
|
|
8
|
+
}>;
|