@defisaver/positions-sdk 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/aaveV3/index.js +0 -2
- package/cjs/compoundV3/index.js +8 -1
- package/esm/aaveV3/index.js +2 -4
- package/esm/compoundV3/index.js +8 -1
- package/package.json +1 -1
- package/src/aaveV3/index.ts +15 -4
- package/src/compoundV3/index.ts +9 -1
package/cjs/aaveV3/index.js
CHANGED
|
@@ -169,8 +169,6 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
169
169
|
/* eslint-disable no-param-reassign */
|
|
170
170
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
171
171
|
if (['wstETH', 'cbETH', 'rETH', 'sDAI'].includes(_market.symbol)) {
|
|
172
|
-
if (!(0, utils_1.isLayer2Network)(network) && _market.symbol === 'cbETH')
|
|
173
|
-
return;
|
|
174
172
|
_market.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(_market.symbol, defaultWeb3);
|
|
175
173
|
_market.incentiveSupplyToken = _market.symbol;
|
|
176
174
|
}
|
package/cjs/compoundV3/index.js
CHANGED
|
@@ -177,7 +177,14 @@ const getCompoundV3AccountData = (web3, network, address, proxyAddress, extracte
|
|
|
177
177
|
if (loanData.borrowAmount.toString() !== '0') {
|
|
178
178
|
usedAssets[baseAssetSymbol].isBorrowed = true;
|
|
179
179
|
usedAssets[baseAssetSymbol].borrowed = (0, tokens_1.assetAmountInEth)(loanData.borrowAmount, baseAssetInfo.symbol);
|
|
180
|
-
|
|
180
|
+
if (selectedMarket === (0, compound_2.COMPOUND_V3_ETH)(network)) {
|
|
181
|
+
usedAssets[baseAssetSymbol].borrowedUsd = new decimal_js_1.default((0, tokens_1.assetAmountInEth)(loanData.borrowValue, baseAssetInfo.symbol))
|
|
182
|
+
.mul(assetsData[baseAssetSymbol].price)
|
|
183
|
+
.toString();
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
usedAssets[baseAssetSymbol].borrowedUsd = (0, tokens_1.assetAmountInEth)(loanData.borrowValue, baseAssetInfo.symbol);
|
|
187
|
+
}
|
|
181
188
|
}
|
|
182
189
|
loanData.collAddr.forEach((coll, i) => {
|
|
183
190
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(coll, network);
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -9,14 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
|
|
12
|
-
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract,
|
|
12
|
+
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
13
13
|
import { addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth, } from '../services/utils';
|
|
14
14
|
import { NetworkNumber, } from '../types/common';
|
|
15
15
|
import { calculateNetApy, getStakingApy } from '../staking';
|
|
16
16
|
import { multicall } from '../multicall';
|
|
17
17
|
import { getAssetsBalances } from '../assets';
|
|
18
18
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
19
|
-
import { aaveAnyGetAggregatedPositionData, aaveV3IsInIsolationMode, aaveV3IsInSiloedMode } from '../helpers/aaveHelpers';
|
|
19
|
+
import { aaveAnyGetAggregatedPositionData, aaveV3IsInIsolationMode, aaveV3IsInSiloedMode, } from '../helpers/aaveHelpers';
|
|
20
20
|
import { AAVE_V3 } from '../markets/aave';
|
|
21
21
|
export const test = (web3, network) => {
|
|
22
22
|
const contract = AaveV3ViewContract(web3, 1);
|
|
@@ -160,8 +160,6 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
160
160
|
/* eslint-disable no-param-reassign */
|
|
161
161
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
162
162
|
if (['wstETH', 'cbETH', 'rETH', 'sDAI'].includes(_market.symbol)) {
|
|
163
|
-
if (!isLayer2Network(network) && _market.symbol === 'cbETH')
|
|
164
|
-
return;
|
|
165
163
|
_market.incentiveSupplyApy = yield getStakingApy(_market.symbol, defaultWeb3);
|
|
166
164
|
_market.incentiveSupplyToken = _market.symbol;
|
|
167
165
|
}
|
package/esm/compoundV3/index.js
CHANGED
|
@@ -169,7 +169,14 @@ export const getCompoundV3AccountData = (web3, network, address, proxyAddress, e
|
|
|
169
169
|
if (loanData.borrowAmount.toString() !== '0') {
|
|
170
170
|
usedAssets[baseAssetSymbol].isBorrowed = true;
|
|
171
171
|
usedAssets[baseAssetSymbol].borrowed = assetAmountInEth(loanData.borrowAmount, baseAssetInfo.symbol);
|
|
172
|
-
|
|
172
|
+
if (selectedMarket === COMPOUND_V3_ETH(network)) {
|
|
173
|
+
usedAssets[baseAssetSymbol].borrowedUsd = new Dec(assetAmountInEth(loanData.borrowValue, baseAssetInfo.symbol))
|
|
174
|
+
.mul(assetsData[baseAssetSymbol].price)
|
|
175
|
+
.toString();
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
usedAssets[baseAssetSymbol].borrowedUsd = assetAmountInEth(loanData.borrowValue, baseAssetInfo.symbol);
|
|
179
|
+
}
|
|
173
180
|
}
|
|
174
181
|
loanData.collAddr.forEach((coll, i) => {
|
|
175
182
|
const assetInfo = getAssetInfoByAddress(coll, network);
|
package/package.json
CHANGED
package/src/aaveV3/index.ts
CHANGED
|
@@ -4,15 +4,23 @@ import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tok
|
|
|
4
4
|
import {
|
|
5
5
|
AaveIncentiveDataProviderV3Contract,
|
|
6
6
|
AaveV3ViewContract,
|
|
7
|
-
GhoTokenContract,
|
|
8
7
|
getConfigContractAbi,
|
|
9
8
|
getConfigContractAddress,
|
|
9
|
+
GhoTokenContract,
|
|
10
10
|
} from '../contracts';
|
|
11
11
|
import {
|
|
12
12
|
addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth,
|
|
13
13
|
} from '../services/utils';
|
|
14
14
|
import {
|
|
15
|
-
AaveMarketInfo,
|
|
15
|
+
AaveMarketInfo,
|
|
16
|
+
AaveV3AssetData,
|
|
17
|
+
AaveV3AssetsData,
|
|
18
|
+
AaveV3IncentiveData,
|
|
19
|
+
AaveV3MarketData,
|
|
20
|
+
AaveV3PositionData,
|
|
21
|
+
AaveV3UsedAsset,
|
|
22
|
+
AaveV3UsedAssets,
|
|
23
|
+
EModeCategoryDataMapping,
|
|
16
24
|
} from '../types/aave';
|
|
17
25
|
import {
|
|
18
26
|
Blockish, EthAddress, NetworkNumber, PositionBalances,
|
|
@@ -22,7 +30,11 @@ import { multicall } from '../multicall';
|
|
|
22
30
|
import { IUiIncentiveDataProviderV3 } from '../types/contracts/generated/AaveUiIncentiveDataProviderV3';
|
|
23
31
|
import { getAssetsBalances } from '../assets';
|
|
24
32
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
25
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
aaveAnyGetAggregatedPositionData,
|
|
35
|
+
aaveV3IsInIsolationMode,
|
|
36
|
+
aaveV3IsInSiloedMode,
|
|
37
|
+
} from '../helpers/aaveHelpers';
|
|
26
38
|
import { AAVE_V3 } from '../markets/aave';
|
|
27
39
|
|
|
28
40
|
export const test = (web3: Web3, network: NetworkNumber) => {
|
|
@@ -246,7 +258,6 @@ export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, ma
|
|
|
246
258
|
/* eslint-disable no-param-reassign */
|
|
247
259
|
const rewardForMarket: IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput | undefined = rewardInfo?.[_market.underlyingTokenAddress as any];
|
|
248
260
|
if (['wstETH', 'cbETH', 'rETH', 'sDAI'].includes(_market.symbol)) {
|
|
249
|
-
if (!isLayer2Network(network) && _market.symbol === 'cbETH') return;
|
|
250
261
|
_market.incentiveSupplyApy = await getStakingApy(_market.symbol, defaultWeb3);
|
|
251
262
|
_market.incentiveSupplyToken = _market.symbol;
|
|
252
263
|
}
|
package/src/compoundV3/index.ts
CHANGED
|
@@ -213,7 +213,15 @@ export const getCompoundV3AccountData = async (
|
|
|
213
213
|
if (loanData.borrowAmount.toString() !== '0') {
|
|
214
214
|
usedAssets[baseAssetSymbol].isBorrowed = true;
|
|
215
215
|
usedAssets[baseAssetSymbol].borrowed = assetAmountInEth(loanData.borrowAmount, baseAssetInfo.symbol);
|
|
216
|
-
|
|
216
|
+
if (selectedMarket === COMPOUND_V3_ETH(network)) {
|
|
217
|
+
usedAssets[baseAssetSymbol].borrowedUsd = new Dec(
|
|
218
|
+
assetAmountInEth(loanData.borrowValue, baseAssetInfo.symbol),
|
|
219
|
+
)
|
|
220
|
+
.mul(assetsData[baseAssetSymbol].price)
|
|
221
|
+
.toString();
|
|
222
|
+
} else {
|
|
223
|
+
usedAssets[baseAssetSymbol].borrowedUsd = assetAmountInEth(loanData.borrowValue, baseAssetInfo.symbol);
|
|
224
|
+
}
|
|
217
225
|
}
|
|
218
226
|
loanData.collAddr.forEach((coll: string, i: number): void => {
|
|
219
227
|
const assetInfo = getAssetInfoByAddress(coll, network);
|