@defisaver/positions-sdk 2.0.12 → 2.0.14-dev-portfolio
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/CLAUDE.md +32 -0
- package/README.md +64 -64
- 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 +2667 -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 +2882 -23
- package/cjs/contracts.js +10 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- 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 +8 -0
- package/cjs/liquityV2/index.js +161 -0
- 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 +256 -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 +2667 -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 +2882 -23
- package/esm/contracts.js +9 -0
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- 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 +8 -0
- package/esm/liquityV2/index.js +162 -1
- 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 +260 -14
- 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 +47 -47
- package/src/aaveV2/index.ts +237 -236
- package/src/aaveV3/index.ts +586 -488
- 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/compoundV2/index.ts +240 -240
- package/src/compoundV3/index.ts +270 -270
- package/src/config/contracts.ts +1208 -1108
- package/src/constants/index.ts +10 -6
- package/src/contracts.ts +121 -108
- package/src/curveUsd/index.ts +250 -250
- package/src/eulerV2/index.ts +314 -314
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1568 -1568
- package/src/helpers/aaveHelpers/index.ts +170 -170
- package/src/helpers/compoundHelpers/index.ts +261 -261
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +259 -259
- package/src/helpers/fluidHelpers/index.ts +324 -324
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +80 -80
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +390 -390
- package/src/helpers/sparkHelpers/index.ts +155 -155
- package/src/index.ts +47 -45
- package/src/liquity/index.ts +160 -105
- package/src/liquityV2/index.ts +583 -408
- package/src/llamaLend/index.ts +296 -296
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +116 -116
- package/src/markets/aave/marketAssets.ts +49 -49
- package/src/markets/compound/index.ts +227 -227
- package/src/markets/compound/marketsAssets.ts +90 -90
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2456 -2456
- package/src/markets/index.ts +25 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +11 -11
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoBlue/index.ts +259 -222
- package/src/portfolio/index.ts +533 -285
- package/src/services/priceService.ts +159 -159
- package/src/services/utils.ts +100 -64
- package/src/services/viem.ts +32 -32
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +457 -456
- package/src/staking/staking.ts +194 -193
- package/src/types/aave.ts +194 -194
- package/src/types/claiming.ts +109 -0
- package/src/types/common.ts +88 -88
- package/src/types/compound.ts +136 -136
- package/src/types/curveUsd.ts +121 -121
- package/src/types/euler.ts +174 -174
- package/src/types/fluid.ts +450 -450
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +157 -157
- package/src/types/maker.ts +63 -63
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/portfolio.ts +60 -60
- package/src/types/spark.ts +137 -137
- 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');
|
|
@@ -128,73 +128,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, provider, network)
|
|
|
128
128
|
});
|
|
129
129
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
130
130
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
131
|
-
const MARKET_QUERY = `
|
|
132
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
133
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
134
|
-
reallocatableLiquidityAssets
|
|
135
|
-
targetBorrowUtilization
|
|
136
|
-
loanAsset {
|
|
137
|
-
address
|
|
138
|
-
decimals
|
|
139
|
-
priceUsd
|
|
140
|
-
}
|
|
141
|
-
state {
|
|
142
|
-
liquidityAssets
|
|
143
|
-
borrowAssets
|
|
144
|
-
supplyAssets
|
|
145
|
-
}
|
|
146
|
-
publicAllocatorSharedLiquidity {
|
|
147
|
-
assets
|
|
148
|
-
vault {
|
|
149
|
-
address
|
|
150
|
-
name
|
|
151
|
-
}
|
|
152
|
-
allocationMarket {
|
|
153
|
-
uniqueKey
|
|
154
|
-
loanAsset {
|
|
155
|
-
address
|
|
156
|
-
}
|
|
157
|
-
collateralAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
irmAddress
|
|
161
|
-
oracle {
|
|
162
|
-
address
|
|
163
|
-
}
|
|
164
|
-
lltv
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
loanAsset {
|
|
168
|
-
address
|
|
169
|
-
}
|
|
170
|
-
collateralAsset {
|
|
171
|
-
address
|
|
172
|
-
}
|
|
173
|
-
oracle {
|
|
174
|
-
address
|
|
175
|
-
}
|
|
176
|
-
irmAddress
|
|
177
|
-
lltv
|
|
178
|
-
}
|
|
179
|
-
}
|
|
131
|
+
const MARKET_QUERY = `
|
|
132
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
133
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
134
|
+
reallocatableLiquidityAssets
|
|
135
|
+
targetBorrowUtilization
|
|
136
|
+
loanAsset {
|
|
137
|
+
address
|
|
138
|
+
decimals
|
|
139
|
+
priceUsd
|
|
140
|
+
}
|
|
141
|
+
state {
|
|
142
|
+
liquidityAssets
|
|
143
|
+
borrowAssets
|
|
144
|
+
supplyAssets
|
|
145
|
+
}
|
|
146
|
+
publicAllocatorSharedLiquidity {
|
|
147
|
+
assets
|
|
148
|
+
vault {
|
|
149
|
+
address
|
|
150
|
+
name
|
|
151
|
+
}
|
|
152
|
+
allocationMarket {
|
|
153
|
+
uniqueKey
|
|
154
|
+
loanAsset {
|
|
155
|
+
address
|
|
156
|
+
}
|
|
157
|
+
collateralAsset {
|
|
158
|
+
address
|
|
159
|
+
}
|
|
160
|
+
irmAddress
|
|
161
|
+
oracle {
|
|
162
|
+
address
|
|
163
|
+
}
|
|
164
|
+
lltv
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
loanAsset {
|
|
168
|
+
address
|
|
169
|
+
}
|
|
170
|
+
collateralAsset {
|
|
171
|
+
address
|
|
172
|
+
}
|
|
173
|
+
oracle {
|
|
174
|
+
address
|
|
175
|
+
}
|
|
176
|
+
irmAddress
|
|
177
|
+
lltv
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
180
|
`;
|
|
181
|
-
const REWARDS_QUERY = `
|
|
182
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
183
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
184
|
-
uniqueKey
|
|
185
|
-
state {
|
|
186
|
-
rewards {
|
|
187
|
-
amountPerSuppliedToken
|
|
188
|
-
supplyApr
|
|
189
|
-
amountPerBorrowedToken
|
|
190
|
-
borrowApr
|
|
191
|
-
asset {
|
|
192
|
-
address
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
181
|
+
const REWARDS_QUERY = `
|
|
182
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
183
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
184
|
+
uniqueKey
|
|
185
|
+
state {
|
|
186
|
+
rewards {
|
|
187
|
+
amountPerSuppliedToken
|
|
188
|
+
supplyApr
|
|
189
|
+
amountPerBorrowedToken
|
|
190
|
+
borrowApr
|
|
191
|
+
asset {
|
|
192
|
+
address
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
198
|
`;
|
|
199
199
|
/**
|
|
200
200
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
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<{
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -300,3 +300,164 @@ const getLiquityV2ClaimableCollateral = (collSurplusPoolAddress, account, provid
|
|
|
300
300
|
return claimableCollateral.toString();
|
|
301
301
|
});
|
|
302
302
|
exports.getLiquityV2ClaimableCollateral = getLiquityV2ClaimableCollateral;
|
|
303
|
+
// const stabilityPoolAddrForMarket: Record<LiquityV2Versions, EthAddress> = {
|
|
304
|
+
// [LiquityV2Versions.LiquityV2Eth]: '0x5721cbbd64fc7Ae3Ef44A0A3F9a790A9264Cf9BF',
|
|
305
|
+
// [LiquityV2Versions.LiquityV2WstEth]: '0x9502b7c397e9aa22fe9db7ef7daf21cd2aebe56b',
|
|
306
|
+
// [LiquityV2Versions.LiquityV2REth]: '0xd442e41019b7f5c4dd78f50dc03726c446148695',
|
|
307
|
+
// [LiquityV2Versions.LiquityV2EthLegacy]: '0x',
|
|
308
|
+
// [LiquityV2Versions.LiquityV2REthLegacy]: '0x',
|
|
309
|
+
// [LiquityV2Versions.LiquityV2WstEthLegacy]: '0x',
|
|
310
|
+
// };
|
|
311
|
+
// const activePoolAddrForMarket: Record<LiquityV2Versions, EthAddress> = {
|
|
312
|
+
// [LiquityV2Versions.LiquityV2Eth]: '0xeB5A8C825582965f1d84606E078620a84ab16AfE',
|
|
313
|
+
// [LiquityV2Versions.LiquityV2WstEth]: '0x531a8f99c70d6a56a7cee02d6b4281650d7919a0',
|
|
314
|
+
// [LiquityV2Versions.LiquityV2REth]: '0x9074d72cc82dad1e13e454755aa8f144c479532f',
|
|
315
|
+
// [LiquityV2Versions.LiquityV2EthLegacy]: '0x',
|
|
316
|
+
// [LiquityV2Versions.LiquityV2WstEthLegacy]: '0x',
|
|
317
|
+
// [LiquityV2Versions.LiquityV2REthLegacy]: '0x',
|
|
318
|
+
// };
|
|
319
|
+
//
|
|
320
|
+
// function ceilDiv(a: string, b: string) {
|
|
321
|
+
// return new Dec(a).add(new Dec(b).sub(1)).div(b).toString();
|
|
322
|
+
// }
|
|
323
|
+
// const SP_YIELD_SPLIT = new Dec(75).mul(10 ** 16).toString(); // 75%
|
|
324
|
+
//
|
|
325
|
+
// const calcPendingSPYield = (
|
|
326
|
+
// aggWeightedDebtSum: string,
|
|
327
|
+
// lastAggUpdateTime: string,
|
|
328
|
+
// currentTime: string,
|
|
329
|
+
// ) => {
|
|
330
|
+
// const a = new Dec(aggWeightedDebtSum).mul(
|
|
331
|
+
// new Dec(currentTime).sub(new Dec(lastAggUpdateTime)),
|
|
332
|
+
// ).toString();
|
|
333
|
+
// const b = new Dec(SECONDS_PER_YEAR).mul(1000).mul(1e18).toString();
|
|
334
|
+
// return new Dec(ceilDiv(a, b)).mul(SP_YIELD_SPLIT).div(1e18).toString();
|
|
335
|
+
// };
|
|
336
|
+
//
|
|
337
|
+
//
|
|
338
|
+
// const calculateStabilityPoolApy = (
|
|
339
|
+
// spYieldGainParams: SPYieldGainParameters,
|
|
340
|
+
// ) => {
|
|
341
|
+
// const {
|
|
342
|
+
// aggWeightedDebtSum, totalBoldDeposits, lastAggUpdateTime, yieldGainsPending,
|
|
343
|
+
// } = spYieldGainParams;
|
|
344
|
+
//
|
|
345
|
+
// if (new Dec(totalBoldDeposits).eq(0)) {
|
|
346
|
+
// return '0';
|
|
347
|
+
// }
|
|
348
|
+
//
|
|
349
|
+
// const now = Date.now().toString();
|
|
350
|
+
// const lastAggUpdateTimeScaled = new Dec(lastAggUpdateTime).mul(1000).toString();
|
|
351
|
+
//
|
|
352
|
+
// const pendingSPYield = new Dec(calcPendingSPYield(
|
|
353
|
+
// aggWeightedDebtSum,
|
|
354
|
+
// lastAggUpdateTimeScaled,
|
|
355
|
+
// now,
|
|
356
|
+
// )).add(yieldGainsPending).toString();
|
|
357
|
+
//
|
|
358
|
+
// const annualizedYield = new Dec(pendingSPYield).mul(SECONDS_PER_YEAR).mul(1000).div(new Dec(now).minus(lastAggUpdateTimeScaled))
|
|
359
|
+
// .toString();
|
|
360
|
+
// return new Dec(annualizedYield).div(totalBoldDeposits).mul(100).toString();
|
|
361
|
+
// };
|
|
362
|
+
//
|
|
363
|
+
// const getYBoldApyApi = async () => {
|
|
364
|
+
// const url = 'https://ydaemon.yearn.fi/1/vaults/0x23346B04a7f55b8760E5860AA5A77383D63491cD?strategiesDetails=withDetails&strategiesCondition=inQueue';
|
|
365
|
+
//
|
|
366
|
+
// const yBoldData = await fetch(url)
|
|
367
|
+
// .then(res => res.json())
|
|
368
|
+
// .catch(console.error);
|
|
369
|
+
//
|
|
370
|
+
// return new Dec(yBoldData.apr.netAPR).mul(100).toString();
|
|
371
|
+
// };
|
|
372
|
+
//
|
|
373
|
+
// export const getLiquityV2Staking = async (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress) => {
|
|
374
|
+
// const stabilityPoolView = createViemContractFromConfigFunc('LiquityV2StabilityPool', stabilityPoolAddrForMarket[market])(provider, network);
|
|
375
|
+
// const activePoolView = createViemContractFromConfigFunc('LiquityV2ActivePool', activePoolAddrForMarket[market])(provider, network);
|
|
376
|
+
//
|
|
377
|
+
// const sBold = LiquityV2sBoldVaultViem(provider, network);
|
|
378
|
+
// const yBold = createViemContractFromConfigFunc('Erc4626', '0x9F4330700a36B29952869fac9b33f45EEdd8A3d8')(provider, network);
|
|
379
|
+
// const stYBold = createViemContractFromConfigFunc('Erc4626', '0x23346B04a7f55b8760E5860AA5A77383D63491cD')(provider, network);
|
|
380
|
+
//
|
|
381
|
+
// const debtTokenInfo = getAssetInfo(LiquityV2Markets(network)[market].debtToken);
|
|
382
|
+
// const debtTokenContract = createViemContractFromConfigFunc('Erc20', debtTokenInfo.address)(provider, network);
|
|
383
|
+
//
|
|
384
|
+
// const [
|
|
385
|
+
// stabilityRewardColl,
|
|
386
|
+
// stabilityRewardYield,
|
|
387
|
+
// compoundedBoldDeposit,
|
|
388
|
+
// totalBoldDeposits,
|
|
389
|
+
// P,
|
|
390
|
+
// currentScale,
|
|
391
|
+
// yieldGainsPending,
|
|
392
|
+
// debtTokenBalance,
|
|
393
|
+
//
|
|
394
|
+
// aggWeightedDebtSum,
|
|
395
|
+
// lastAggUpdateTime,
|
|
396
|
+
//
|
|
397
|
+
// sBoldTotalAssets,
|
|
398
|
+
// sBoldConvertToShares,
|
|
399
|
+
// sBoldMaxWithdraw,
|
|
400
|
+
//
|
|
401
|
+
// wethApy,
|
|
402
|
+
// wsETHApy,
|
|
403
|
+
// rETHApy,
|
|
404
|
+
//
|
|
405
|
+
// yBoldTotalAssets,
|
|
406
|
+
// yBoldMaxWithdraw,
|
|
407
|
+
// stYBoldConvertToShares,
|
|
408
|
+
// ] = await Promise.all([
|
|
409
|
+
// stabilityPoolView.read.getDepositorCollGain([user]),
|
|
410
|
+
// stabilityPoolView.read.getDepositorYieldGain([user]),
|
|
411
|
+
// stabilityPoolView.read.getCompoundedBoldDeposit([user]),
|
|
412
|
+
// stabilityPoolView.read.getTotalBoldDeposits(),
|
|
413
|
+
// stabilityPoolView.read.P(),
|
|
414
|
+
// stabilityPoolView.read.currentScale(),
|
|
415
|
+
// stabilityPoolView.read.getYieldGainsPending(),
|
|
416
|
+
// debtTokenContract.read.balanceOf([user]),
|
|
417
|
+
//
|
|
418
|
+
// activePoolView.read.aggWeightedDebtSum(),
|
|
419
|
+
// activePoolView.read.lastAggUpdateTime(),
|
|
420
|
+
//
|
|
421
|
+
// sBold.read.totalAssets(),
|
|
422
|
+
// sBold.read.convertToShares([BigInt(1e18)]),
|
|
423
|
+
// sBold.read.maxWithdraw([user]),
|
|
424
|
+
//
|
|
425
|
+
// sBold.read.sps([BigInt(0)]),
|
|
426
|
+
// sBold.read.sps([BigInt(1)]),
|
|
427
|
+
// sBold.read.sps([BigInt(2)]),
|
|
428
|
+
//
|
|
429
|
+
// yBold.read.totalAssets(),
|
|
430
|
+
// yBold.read.maxWithdraw([user]),
|
|
431
|
+
// stYBold.read.convertToShares([BigInt(1e18)]),
|
|
432
|
+
// ]);
|
|
433
|
+
//
|
|
434
|
+
//
|
|
435
|
+
// const stabilityPoolYieldParams: SPYieldGainParameters = {
|
|
436
|
+
// aggWeightedDebtSum: aggWeightedDebtSum.toString(),
|
|
437
|
+
// lastAggUpdateTime: lastAggUpdateTime.toString(),
|
|
438
|
+
// P: P.toString(),
|
|
439
|
+
// currentScale: currentScale.toString(),
|
|
440
|
+
// yieldGainsPending: yieldGainsPending.toString(),
|
|
441
|
+
// totalBoldDeposits: totalBoldDeposits.toString(),
|
|
442
|
+
// };
|
|
443
|
+
//
|
|
444
|
+
// const stabilityPoolApy = calculateStabilityPoolApy(stabilityPoolYieldParams);
|
|
445
|
+
//
|
|
446
|
+
// const stakedBOLDBalanceForUser = getEthAmountForDecimals(compoundedBoldDeposit.toString(), 18);
|
|
447
|
+
// const stabilityRewardCollForUser = getEthAmountForDecimals(stabilityRewardColl.toString(), 18);
|
|
448
|
+
// const stabilityRewardYieldForUser = getEthAmountForDecimals(stabilityRewardYield.toString(), 18);
|
|
449
|
+
//
|
|
450
|
+
// const accountData = {
|
|
451
|
+
// totalBOLDDeposited: getEthAmountForDecimals(totalBoldDeposits.toString(), 18),
|
|
452
|
+
// stakedBOLDBalance: stakedBOLDBalanceForUser,
|
|
453
|
+
// stabilityRewardColl: stabilityRewardCollForUser,
|
|
454
|
+
// stabilityRewardYield: stabilityRewardYieldForUser,
|
|
455
|
+
// showStakingBalances: !!(+stakedBOLDBalanceForUser || +stabilityRewardCollForUser || +stabilityRewardYieldForUser),
|
|
456
|
+
// debtTokenBalance: getEthAmountForDecimals(debtTokenBalance.toString(), debtTokenInfo.decimals),
|
|
457
|
+
// };
|
|
458
|
+
//
|
|
459
|
+
//
|
|
460
|
+
// const yBoldApy = await getYBoldApyApi();
|
|
461
|
+
//
|
|
462
|
+
// return yBoldApy;
|
|
463
|
+
// };
|
|
@@ -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
|
+
}>;
|