@defisaver/positions-sdk 0.0.83 → 0.0.85
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/.yarn/releases/yarn-1.22.1.cjs +147386 -0
- package/.yarn/releases/yarn-1.22.1.js +147386 -0
- package/.yarnrc.yml +1 -0
- package/cjs/aaveV2/index.js +4 -4
- package/cjs/aaveV3/index.js +2 -2
- package/cjs/markets/morphoBlue/index.d.ts +2 -0
- package/cjs/markets/morphoBlue/index.js +18 -1
- package/cjs/moneymarket/moneymarketCommonService.d.ts +1 -1
- package/cjs/moneymarket/moneymarketCommonService.js +1 -1
- package/cjs/morphoAaveV2/index.js +6 -6
- package/cjs/morphoAaveV3/index.js +2 -2
- package/cjs/spark/index.js +4 -4
- package/cjs/staking/staking.d.ts +0 -1
- package/cjs/staking/staking.js +9 -19
- package/cjs/types/morphoBlue.d.ts +1 -0
- package/cjs/types/morphoBlue.js +1 -0
- package/esm/aaveV2/index.js +5 -5
- package/esm/aaveV3/index.js +3 -3
- package/esm/markets/morphoBlue/index.d.ts +2 -0
- package/esm/markets/morphoBlue/index.js +16 -0
- package/esm/moneymarket/moneymarketCommonService.d.ts +1 -1
- package/esm/moneymarket/moneymarketCommonService.js +1 -1
- package/esm/morphoAaveV2/index.js +7 -7
- package/esm/morphoAaveV3/index.js +3 -3
- package/esm/spark/index.js +5 -5
- package/esm/staking/staking.d.ts +0 -1
- package/esm/staking/staking.js +8 -17
- package/esm/types/morphoBlue.d.ts +1 -0
- package/esm/types/morphoBlue.js +1 -0
- package/package.json +1 -2
- package/src/aaveV2/index.ts +5 -5
- package/src/aaveV3/index.ts +7 -8
- package/src/markets/morphoBlue/index.ts +16 -0
- package/src/moneymarket/moneymarketCommonService.ts +1 -1
- package/src/morphoAaveV2/index.ts +7 -7
- package/src/morphoAaveV3/index.ts +4 -4
- package/src/spark/index.ts +6 -6
- package/src/staking/staking.ts +8 -20
- package/src/types/morphoBlue.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"@defisaver/tokens": "^1.5.23",
|
|
23
23
|
"@ethersproject/bignumber": "^5.7.0",
|
|
24
24
|
"@morpho-org/morpho-aave-v3-sdk": "^1.5.3",
|
|
25
|
-
"@stakewise/v3-sdk": "^1.3.0",
|
|
26
25
|
"decimal.js": "^10.4.3"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
package/src/aaveV2/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { calculateNetApy, getStETHApr } from '../staking';
|
|
8
8
|
import { ethToWeth, wethToEth, wethToEthByAddress } from '../services/utils';
|
|
9
9
|
import { AaveLoanInfoV2Contract, createContractWrapper } from '../contracts';
|
|
10
|
-
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
10
|
+
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
11
11
|
import {
|
|
12
12
|
AaveMarketInfo, AaveV2AssetData, AaveV2AssetsData, AaveV2PositionData, AaveV2UsedAsset, AaveV2UsedAssets,
|
|
13
13
|
} from '../types';
|
|
@@ -26,9 +26,9 @@ export const getAaveV2MarketsData = async (web3: Web3, network: NetworkNumber, s
|
|
|
26
26
|
.map((market, i) => ({
|
|
27
27
|
symbol: selectedMarket.assets[i],
|
|
28
28
|
underlyingTokenAddress: market.underlyingTokenAddress,
|
|
29
|
-
supplyRate: new Dec(market.supplyRate.toString()).div(1e25).toString(),
|
|
30
|
-
borrowRate: new Dec(market.borrowRateVariable.toString()).div(1e25).toString(),
|
|
31
|
-
borrowRateStable: new Dec(market.borrowRateStable.toString()).div(1e25).toString(),
|
|
29
|
+
supplyRate: aprToApy(new Dec(market.supplyRate.toString()).div(1e25).toString()),
|
|
30
|
+
borrowRate: aprToApy(new Dec(market.borrowRateVariable.toString()).div(1e25).toString()),
|
|
31
|
+
borrowRateStable: aprToApy(new Dec(market.borrowRateStable.toString()).div(1e25).toString()),
|
|
32
32
|
collateralFactor: new Dec(market.collateralFactor.toString()).div(10000).toString(),
|
|
33
33
|
liquidationRatio: new Dec(market.liquidationRatio.toString()).div(10000).toString(),
|
|
34
34
|
marketLiquidity: assetAmountInEth(new Dec(market.totalSupply.toString())
|
|
@@ -173,7 +173,7 @@ export const getAaveV2AccountData = async (web3: Web3, network: NetworkNumber, a
|
|
|
173
173
|
suppliedUsd: new Dec(supplied).mul(assetsData[asset].price).toString(),
|
|
174
174
|
isSupplied,
|
|
175
175
|
collateral: enabledAsCollateral,
|
|
176
|
-
stableBorrowRate: new Dec(tokenInfo.stableBorrowRate).div(1e25).toString(),
|
|
176
|
+
stableBorrowRate: aprToApy(new Dec(tokenInfo.stableBorrowRate).div(1e25).toString()),
|
|
177
177
|
borrowedStable,
|
|
178
178
|
borrowedVariable,
|
|
179
179
|
borrowedUsdStable: new Dec(borrowedStable).mul(assetsData[asset].price).toString(),
|
package/src/aaveV3/index.ts
CHANGED
|
@@ -30,7 +30,7 @@ import { calculateNetApy, getStakingApy, STAKING_ASSETS } from '../staking';
|
|
|
30
30
|
import { multicall } from '../multicall';
|
|
31
31
|
import { IUiIncentiveDataProviderV3 } from '../types/contracts/generated/AaveUiIncentiveDataProviderV3';
|
|
32
32
|
import { getAssetsBalances } from '../assets';
|
|
33
|
-
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
33
|
+
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
34
34
|
import {
|
|
35
35
|
aaveAnyGetAggregatedPositionData,
|
|
36
36
|
aaveV3IsInIsolationMode,
|
|
@@ -206,7 +206,6 @@ export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, ma
|
|
|
206
206
|
if (new Dec(marketLiquidity).lt(0)) {
|
|
207
207
|
marketLiquidity = '0';
|
|
208
208
|
}
|
|
209
|
-
|
|
210
209
|
return ({
|
|
211
210
|
nativeAsset,
|
|
212
211
|
...addToObjectIf(nativeAsset, {
|
|
@@ -225,10 +224,10 @@ export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, ma
|
|
|
225
224
|
isolationModeTotalDebt: new Dec(tokenMarket.isolationModeTotalDebt).div(100).toString(),
|
|
226
225
|
assetId: Number(tokenMarket.assetId),
|
|
227
226
|
underlyingTokenAddress: tokenMarket.underlyingTokenAddress,
|
|
228
|
-
supplyRate: new Dec(tokenMarket.supplyRate.toString()).div(1e25).toString(),
|
|
229
|
-
borrowRate: new Dec(tokenMarket.borrowRateVariable.toString()).div(1e25).toString(),
|
|
230
|
-
borrowRateDiscounted: nativeAsset ? new Dec(tokenMarket.borrowRateVariable.toString()).div(1e25).mul(1 - parseFloat(discountRateOnBorrow)).toString() : '0',
|
|
231
|
-
borrowRateStable: new Dec(tokenMarket.borrowRateStable.toString()).div(1e25).toString(),
|
|
227
|
+
supplyRate: aprToApy(new Dec(tokenMarket.supplyRate.toString()).div(1e25).toString()),
|
|
228
|
+
borrowRate: aprToApy(new Dec(tokenMarket.borrowRateVariable.toString()).div(1e25).toString()),
|
|
229
|
+
borrowRateDiscounted: aprToApy(nativeAsset ? new Dec(tokenMarket.borrowRateVariable.toString()).div(1e25).mul(1 - parseFloat(discountRateOnBorrow)).toString() : '0'),
|
|
230
|
+
borrowRateStable: aprToApy(new Dec(tokenMarket.borrowRateStable.toString()).div(1e25).toString()),
|
|
232
231
|
collateralFactor: new Dec(tokenMarket.collateralFactor.toString()).div(10000).toString(),
|
|
233
232
|
liquidationRatio: new Dec(tokenMarket.liquidationRatio.toString()).div(10000).toString(),
|
|
234
233
|
marketLiquidity,
|
|
@@ -500,8 +499,8 @@ export const getAaveV3AccountData = async (web3: Web3, network: NetworkNumber, a
|
|
|
500
499
|
suppliedUsd: new Dec(supplied).mul(assetsData[asset].price).toString(),
|
|
501
500
|
isSupplied,
|
|
502
501
|
collateral: enabledAsCollateral,
|
|
503
|
-
stableBorrowRate: new Dec(tokenInfo.stableBorrowRate).div(1e25).toString(),
|
|
504
|
-
discountedBorrowRate: new Dec(assetsData[asset].borrowRate).mul(1 - parseFloat(discountRateOnBorrow)).toString(),
|
|
502
|
+
stableBorrowRate: aprToApy(new Dec(tokenInfo.stableBorrowRate).div(1e25).toString()),
|
|
503
|
+
discountedBorrowRate: aprToApy(new Dec(assetsData[asset].borrowRate).mul(1 - parseFloat(discountRateOnBorrow)).toString()),
|
|
505
504
|
borrowedStable,
|
|
506
505
|
borrowedVariable,
|
|
507
506
|
borrowedUsdStable: new Dec(borrowedStable).mul(assetsData[asset].price).toString(),
|
|
@@ -230,6 +230,21 @@ export const MORPHO_BLUE_EZETH_ETH = (networkId: NetworkNumber = NetworkNumber.E
|
|
|
230
230
|
marketId: '0x49bb2d114be9041a787432952927f6f144f05ad3e83196a7d062f374ee11d0ee',
|
|
231
231
|
protocolName: 'morpho-blue',
|
|
232
232
|
});
|
|
233
|
+
export const MORPHO_BLUE_MKR_USDC = (networkId: NetworkNumber = NetworkNumber.Eth): MorphoBlueMarketData => ({
|
|
234
|
+
chainIds: [1],
|
|
235
|
+
label: 'Morpho Blue',
|
|
236
|
+
shortLabel: 'MKR/USDC',
|
|
237
|
+
value: MorphoBlueVersions.MorphoBlueMKRUSDC,
|
|
238
|
+
url: 'mkrusdc',
|
|
239
|
+
loanToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
240
|
+
collateralToken: '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2',
|
|
241
|
+
oracle: '0x6686788B4315A4F93d822c1Bf73910556FCe2d5a',
|
|
242
|
+
oracleType: MorphoBlueOracleType.MARKET_RATE,
|
|
243
|
+
irm: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
244
|
+
lltv: 0.77,
|
|
245
|
+
marketId: '0x97bb820669a19ba5fa6de964a466292edd67957849f9631eb8b830c382f58b7f',
|
|
246
|
+
protocolName: 'morpho-blue',
|
|
247
|
+
});
|
|
233
248
|
// wstETH/WETH
|
|
234
249
|
export const MORPHO_BLUE_WSTETH_ETH_945 = (networkId: NetworkNumber = NetworkNumber.Eth): MorphoBlueMarketData => ({
|
|
235
250
|
chainIds: [1],
|
|
@@ -434,6 +449,7 @@ export const MorphoBlueMarkets = (networkId: NetworkNumber) => ({
|
|
|
434
449
|
[MorphoBlueVersions.MorphoBlueSUSDeUSDT]: MORPHO_BLUE_SUSDE_USDT(networkId),
|
|
435
450
|
[MorphoBlueVersions.MorphoBlueSDAIEth]: MORPHO_BLUE_SDAI_ETH(networkId),
|
|
436
451
|
[MorphoBlueVersions.MorphoBlueEzEthEth]: MORPHO_BLUE_EZETH_ETH(networkId),
|
|
452
|
+
[MorphoBlueVersions.MorphoBlueMKRUSDC]: MORPHO_BLUE_MKR_USDC(networkId),
|
|
437
453
|
// wstETH/WETH
|
|
438
454
|
[MorphoBlueVersions.MorphoBlueWstEthEth_945]: MORPHO_BLUE_WSTETH_ETH_945(networkId),
|
|
439
455
|
[MorphoBlueVersions.MorphoBlueWstEthEth_945_Exchange_Rate]: MORPHO_BLUE_WSTETH_ETH_945_EXCHANGE_RATE(networkId),
|
|
@@ -73,4 +73,4 @@ export const isLeveragedPos = (usedAssets: MMUsedAssets, dustLimit = 5) => {
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export const aprToApy = (interest:
|
|
76
|
+
export const aprToApy = (interest:string | number, frequency = BLOCKS_IN_A_YEAR) => new Dec(interest).div(100).div(frequency).plus(1).pow(frequency).minus(1).times(100).toString();
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
AavePositionData,
|
|
12
12
|
AaveVersions, MorphoAaveV2AssetData, MorphoAaveV2AssetsData, MorphoAaveV2MarketData, MorphoAaveV2PositionData,
|
|
13
13
|
} from '../types';
|
|
14
|
-
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
14
|
+
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
15
15
|
import { EMPTY_AAVE_DATA } from '../aaveV3';
|
|
16
16
|
import { aaveAnyGetAggregatedPositionData } from '../helpers/aaveHelpers';
|
|
17
17
|
import { getEthPrice } from '../services/priceService';
|
|
@@ -39,8 +39,8 @@ export const getMorphoAaveV2MarketsData = async (web3: Web3, network: NetworkNum
|
|
|
39
39
|
|
|
40
40
|
const morphoReward = morphoRewardsData?.markets?.[aaveInfo.aTokenAddress.toLowerCase()];
|
|
41
41
|
|
|
42
|
-
const supplyRateP2P = new Dec(market.p2pSupplyRate).div(1e25).toString();
|
|
43
|
-
const borrowRateP2P = new Dec(market.p2pBorrowRate).div(1e25).toString();
|
|
42
|
+
const supplyRateP2P = aprToApy(new Dec(market.p2pSupplyRate).div(1e25).toString());
|
|
43
|
+
const borrowRateP2P = aprToApy(new Dec(market.p2pBorrowRate).div(1e25).toString());
|
|
44
44
|
const hasDelta = new Dec(borrowRateP2P).minus(supplyRateP2P).gte(0.3);
|
|
45
45
|
|
|
46
46
|
return {
|
|
@@ -51,9 +51,9 @@ export const getMorphoAaveV2MarketsData = async (web3: Web3, network: NetworkNum
|
|
|
51
51
|
priceInEth: new Dec(aaveInfo.price).div(1e18).toString(),
|
|
52
52
|
price: new Dec(aaveInfo.price).div(1e18).times(ethPrice).toString(),
|
|
53
53
|
|
|
54
|
-
supplyRate: new Dec(market.poolSupplyRate).div(1e25).toString(),
|
|
54
|
+
supplyRate: aprToApy(new Dec(market.poolSupplyRate).div(1e25).toString()),
|
|
55
55
|
supplyRateP2P,
|
|
56
|
-
borrowRate: new Dec(market.poolBorrowRate).div(1e25).toString(),
|
|
56
|
+
borrowRate: aprToApy(new Dec(market.poolBorrowRate).div(1e25).toString()),
|
|
57
57
|
borrowRateP2P,
|
|
58
58
|
|
|
59
59
|
totalSupply: assetAmountInEth(aaveInfo.totalSupply, symbol),
|
|
@@ -216,8 +216,8 @@ export const getMorphoAaveV2AccountData = async (web3: Web3, network: NetworkNum
|
|
|
216
216
|
borrowedUsdVariable: borrowedUsd,
|
|
217
217
|
isSupplied: new Dec(supplied).gt(0),
|
|
218
218
|
isBorrowed: new Dec(borrowed).gt(0),
|
|
219
|
-
supplyRate: new Dec(market.userSupplyRate).div(1e25).toString(),
|
|
220
|
-
borrowRate: new Dec(market.userBorrowRate).div(1e25).toString(),
|
|
219
|
+
supplyRate: aprToApy(new Dec(market.userSupplyRate).div(1e25).toString()),
|
|
220
|
+
borrowRate: aprToApy(new Dec(market.userBorrowRate).div(1e25).toString()),
|
|
221
221
|
limit: '0',
|
|
222
222
|
|
|
223
223
|
collateral: true, // Morpho doesn't have all these, keeping it for compatability
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
MorphoAaveV3AssetData, MorphoAaveV3AssetsData, MorphoAaveV3MarketData, MorphoAaveV3MarketInfo, MorphoAaveV3PositionData,
|
|
25
25
|
} from '../types';
|
|
26
26
|
import { getDsrApy } from '../services/dsrService';
|
|
27
|
-
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
27
|
+
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
28
28
|
import { EMPTY_AAVE_DATA } from '../aaveV3';
|
|
29
29
|
import { aaveAnyGetAggregatedPositionData } from '../helpers/aaveHelpers';
|
|
30
30
|
import { MORPHO_AAVE_V3_ETH } from '../markets/aave';
|
|
@@ -229,9 +229,9 @@ export const getMorphoAaveV3MarketsData = async (web3: Web3, network: NetworkNum
|
|
|
229
229
|
underlyingTokenAddress: address,
|
|
230
230
|
price: new Dec(marketData.price.toString()).div(1e8).toString(), // is actually price in USD
|
|
231
231
|
|
|
232
|
-
supplyRate: new Dec(marketData.supplyRate.toString()).div(1e25).toString(),
|
|
232
|
+
supplyRate: aprToApy(new Dec(marketData.supplyRate.toString()).div(1e25).toString()),
|
|
233
233
|
supplyRateP2P: marketData.p2pSupplyAPY,
|
|
234
|
-
borrowRate: new Dec(marketData.borrowRateVariable.toString()).div(1e25).toString(),
|
|
234
|
+
borrowRate: aprToApy(new Dec(marketData.borrowRateVariable.toString()).div(1e25).toString()),
|
|
235
235
|
borrowRateP2P: marketData.p2pBorrowAPY,
|
|
236
236
|
totalSupply: assetAmountInEth(marketData.totalSupply.toString(), symbol),
|
|
237
237
|
totalBorrow: assetAmountInEth(marketData.totalBorrow.toString(), symbol),
|
|
@@ -617,4 +617,4 @@ export const getMorphoAaveV3FullPositionData = async (web3: Web3, network: Netwo
|
|
|
617
617
|
const marketData = await getMorphoAaveV3MarketsData(web3, network, market, mainnetWeb3);
|
|
618
618
|
const positionData = await getMorphoAaveV3AccountData(web3, network, address, marketData.assetsData, delegator, market);
|
|
619
619
|
return positionData;
|
|
620
|
-
};
|
|
620
|
+
};
|
package/src/spark/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from '../types';
|
|
30
30
|
import { multicall } from '../multicall';
|
|
31
31
|
import { sparkGetAggregatedPositionData, sparkIsInIsolationMode } from '../helpers/sparkHelpers';
|
|
32
|
-
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
32
|
+
import { aprToApy, calculateBorrowingAssetLimit } from '../moneymarket';
|
|
33
33
|
import { SPARK_V1 } from '../markets/spark';
|
|
34
34
|
|
|
35
35
|
export const sparkEmodeCategoriesMapping = (extractedState: { assetsData: SparkAssetsData }, usedAssets: SparkUsedAssets) => {
|
|
@@ -110,9 +110,9 @@ export const getSparkMarketsData = async (web3: Web3, network: NetworkNumber, se
|
|
|
110
110
|
isolationModeTotalDebt: new Dec(market.isolationModeTotalDebt).div(100).toString(),
|
|
111
111
|
assetId: Number(market.assetId),
|
|
112
112
|
underlyingTokenAddress: market.underlyingTokenAddress,
|
|
113
|
-
supplyRate: new Dec(market.supplyRate.toString()).div(1e25).toString(),
|
|
114
|
-
borrowRate: new Dec(market.borrowRateVariable.toString()).div(1e25).toString(),
|
|
115
|
-
borrowRateStable: new Dec(market.borrowRateStable.toString()).div(1e25).toString(),
|
|
113
|
+
supplyRate: aprToApy(new Dec(market.supplyRate.toString()).div(1e25).toString()),
|
|
114
|
+
borrowRate: aprToApy(new Dec(market.borrowRateVariable.toString()).div(1e25).toString()),
|
|
115
|
+
borrowRateStable: aprToApy(new Dec(market.borrowRateStable.toString()).div(1e25).toString()),
|
|
116
116
|
collateralFactor: new Dec(market.collateralFactor.toString()).div(10000).toString(),
|
|
117
117
|
liquidationRatio: new Dec(market.liquidationRatio.toString()).div(10000).toString(),
|
|
118
118
|
marketLiquidity,
|
|
@@ -374,7 +374,7 @@ export const getSparkAccountData = async (web3: Web3, network: NetworkNumber, ad
|
|
|
374
374
|
suppliedUsd: new Dec(supplied).mul(assetsData[asset].price).toString(),
|
|
375
375
|
isSupplied,
|
|
376
376
|
collateral: enabledAsCollateral,
|
|
377
|
-
stableBorrowRate: new Dec(tokenInfo.stableBorrowRate).div(1e25).toString(),
|
|
377
|
+
stableBorrowRate: aprToApy(new Dec(tokenInfo.stableBorrowRate).div(1e25).toString()),
|
|
378
378
|
borrowedStable,
|
|
379
379
|
borrowedVariable,
|
|
380
380
|
borrowedUsdStable: new Dec(borrowedStable).mul(assetsData[asset].price).toString(),
|
|
@@ -431,4 +431,4 @@ export const getSparkFullPositionData = async (web3: Web3, network: NetworkNumbe
|
|
|
431
431
|
const marketData = await getSparkMarketsData(web3, network, market, mainnetWeb3);
|
|
432
432
|
const positionData = await getSparkAccountData(web3, network, address, { assetsData: marketData.assetsData, selectedMarket: market });
|
|
433
433
|
return positionData;
|
|
434
|
-
};
|
|
434
|
+
};
|
package/src/staking/staking.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import Web3 from 'web3';
|
|
3
|
-
import { StakeWiseSDK, Network } from '@stakewise/v3-sdk';
|
|
4
3
|
import {
|
|
5
4
|
CbEthContract, LidoContract, PotContract, REthContract, wstETHContract,
|
|
6
5
|
} from '../contracts';
|
|
@@ -78,25 +77,13 @@ export const getDsrApy = async (web3: Web3, blockNumber: 'latest' | number = 'la
|
|
|
78
77
|
.toString();
|
|
79
78
|
};
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
const res = await fetch(
|
|
80
|
+
const getApyFromDfsApi = async (asset: string) => {
|
|
81
|
+
const res = await fetch(`https://app.defisaver.com/api/staking/apy?asset=${asset}`);
|
|
83
82
|
const data = await res.json();
|
|
84
83
|
return data.apy;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const getWeEthApr = async () => {
|
|
88
|
-
const res = await fetch('https://app.defisaver.com/api/staking/apy?asset=weETH');
|
|
89
|
-
const data = await res.json();
|
|
90
|
-
return data.apy;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const getOsETHApy = async () => {
|
|
94
|
-
const sdk = new StakeWiseSDK({ network: Network.Mainnet });
|
|
95
|
-
const apy = await sdk.osToken.getAPY();
|
|
96
|
-
return apy;
|
|
97
|
-
};
|
|
84
|
+
}
|
|
98
85
|
|
|
99
|
-
export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH'];
|
|
86
|
+
export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH'];
|
|
100
87
|
|
|
101
88
|
export const getStakingApy = (asset: string, web3: Web3, blockNumber: 'latest' | number = 'latest', fromBlock: number | undefined = undefined) => {
|
|
102
89
|
try {
|
|
@@ -104,9 +91,10 @@ export const getStakingApy = (asset: string, web3: Web3, blockNumber: 'latest' |
|
|
|
104
91
|
if (asset === 'cbETH') return getCbETHApr(web3, blockNumber);
|
|
105
92
|
if (asset === 'rETH') return getREthApr(web3, blockNumber);
|
|
106
93
|
if (asset === 'sDAI') return getDsrApy(web3);
|
|
107
|
-
if (asset === 'sUSDe') return
|
|
108
|
-
if (asset === 'weETH') return
|
|
109
|
-
if (asset === '
|
|
94
|
+
if (asset === 'sUSDe') return getApyFromDfsApi('sUSDe');
|
|
95
|
+
if (asset === 'weETH') return getApyFromDfsApi('weETH');
|
|
96
|
+
if (asset === 'ezETH') return getApyFromDfsApi('ezETH')
|
|
97
|
+
if (asset === 'osETH') return getApyFromDfsApi('osETH');
|
|
110
98
|
} catch (e) {
|
|
111
99
|
console.error(`Failed to fetch APY for ${asset}`);
|
|
112
100
|
return '0';
|
package/src/types/morphoBlue.ts
CHANGED
|
@@ -17,6 +17,7 @@ export enum MorphoBlueVersions {
|
|
|
17
17
|
MorphoBlueSUSDeUSDT = 'morphobluesusdeusdt', // sUSDe/USDT
|
|
18
18
|
MorphoBlueSDAIEth = 'morphobluesdaieth', // sDAI/ETH
|
|
19
19
|
MorphoBlueEzEthEth = 'morphoblueezetheth', // ezETH/ETH
|
|
20
|
+
MorphoBlueMKRUSDC = 'morphobluemkrusdc', // MKR/USDC
|
|
20
21
|
// wstETH/WETH
|
|
21
22
|
MorphoBlueWstEthEth_945 = 'morphobluewstetheth_945',
|
|
22
23
|
MorphoBlueWstEthEth_945_Exchange_Rate = 'morphobluewstetheth_945_exchange_rate',
|