@defisaver/positions-sdk 2.1.89 → 2.1.90
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/compoundV3/index.js +5 -3
- package/cjs/helpers/compoundHelpers/index.d.ts +2 -2
- package/cjs/helpers/compoundHelpers/index.js +4 -4
- package/cjs/types/compound.d.ts +1 -0
- package/esm/compoundV3/index.js +5 -3
- package/esm/helpers/compoundHelpers/index.d.ts +2 -2
- package/esm/helpers/compoundHelpers/index.js +4 -4
- package/esm/types/compound.d.ts +1 -0
- package/package.json +1 -1
- package/src/compoundV3/index.ts +6 -3
- package/src/helpers/compoundHelpers/index.ts +6 -4
- package/src/types/compound.ts +1 -0
package/cjs/compoundV3/index.js
CHANGED
|
@@ -38,16 +38,18 @@ const getBaseAssetPriceFunction = (asset) => {
|
|
|
38
38
|
};
|
|
39
39
|
const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const contract = (0, contracts_1.CompV3ViewContractViem)(provider, network);
|
|
41
|
-
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos] = yield Promise.all([
|
|
41
|
+
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos, govInfo] = yield Promise.all([
|
|
42
42
|
getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultProvider),
|
|
43
43
|
(0, priceService_1.getCompPrice)(defaultProvider),
|
|
44
44
|
contract.read.getFullBaseTokenInfo([selectedMarket.baseMarketAddress]),
|
|
45
45
|
contract.read.getFullCollInfos([selectedMarket.baseMarketAddress]),
|
|
46
|
+
contract.read.getGovernanceInfoFull([selectedMarket.baseMarketAddress]),
|
|
46
47
|
]);
|
|
48
|
+
const { isSupplyPaused, isWithdrawPaused } = govInfo;
|
|
47
49
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
48
50
|
const colls = collInfos
|
|
49
51
|
.filter((coll) => supportedAssetsAddresses.includes(coll.tokenAddr.toLowerCase()))
|
|
50
|
-
.map((coll) => (0, compoundHelpers_1.formatMarketData)(coll, network, baseAssetPrice));
|
|
52
|
+
.map((coll) => (0, compoundHelpers_1.formatMarketData)(coll, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused));
|
|
51
53
|
for (const coll of colls) {
|
|
52
54
|
if (staking_1.STAKING_ASSETS.includes(coll.symbol)) {
|
|
53
55
|
coll.supplyIncentives.push({
|
|
@@ -58,7 +60,7 @@ const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultPro
|
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
const base = (0, compoundHelpers_1.formatBaseData)(baseTokenInfo, network, baseAssetPrice);
|
|
63
|
+
const base = (0, compoundHelpers_1.formatBaseData)(baseTokenInfo, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused);
|
|
62
64
|
const payload = {};
|
|
63
65
|
const baseObj = Object.assign(Object.assign({}, base), (yield (0, compoundHelpers_1.getIncentiveApys)(base, compPrice)));
|
|
64
66
|
const allAssets = [baseObj, ...colls];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAdditionalAssetData, CompoundAggregatedPositionData, CompoundMarketData, CompoundV2AssetsData, CompoundV2UsedAssets, CompoundV3AssetData, CompoundV3AssetsData, CompoundV3UsedAssets } from '../../types';
|
|
2
2
|
import { EthAddress, EthereumProvider, IncentiveData, NetworkNumber } from '../../types/common';
|
|
3
|
-
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData;
|
|
4
|
-
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
3
|
+
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData;
|
|
4
|
+
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
5
5
|
export declare const getIncentiveApys: (baseData: CompoundV3AssetData & BaseAdditionalAssetData, compPrice: string) => Promise<{
|
|
6
6
|
supplyIncentives: IncentiveData[];
|
|
7
7
|
borrowIncentives: IncentiveData[];
|
|
@@ -34,15 +34,15 @@ const staking_1 = require("../../staking");
|
|
|
34
34
|
const common_1 = require("../../types/common");
|
|
35
35
|
const contracts_1 = require("../../contracts");
|
|
36
36
|
const viem_1 = require("../../services/viem");
|
|
37
|
-
const formatMarketData = (data, network, baseAssetPrice) => {
|
|
37
|
+
const formatMarketData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
38
38
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(data.tokenAddr, network);
|
|
39
39
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
40
40
|
const price = (0, utils_1.getEthAmountForDecimals)(data.price, 8);
|
|
41
|
-
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: new decimal_js_1.default(price).mul(baseAssetPrice).toString(), collateralFactor: (0, utils_1.getEthAmountForDecimals)(data.borrowCollateralFactor, 18), liquidationRatio: (0, utils_1.getEthAmountForDecimals)(data.liquidateCollateralFactor, 18), supplyCap: (0, utils_1.getEthAmountForDecimals)(data.supplyCap, assetInfo.decimals), totalSupply: (0, utils_1.getEthAmountForDecimals)(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied:
|
|
41
|
+
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: new decimal_js_1.default(price).mul(baseAssetPrice).toString(), collateralFactor: (0, utils_1.getEthAmountForDecimals)(data.borrowCollateralFactor, 18), liquidationRatio: (0, utils_1.getEthAmountForDecimals)(data.liquidateCollateralFactor, 18), supplyCap: (0, utils_1.getEthAmountForDecimals)(data.supplyCap, assetInfo.decimals), totalSupply: (0, utils_1.getEthAmountForDecimals)(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyIncentives: [], borrowIncentives: [] }));
|
|
42
42
|
};
|
|
43
43
|
exports.formatMarketData = formatMarketData;
|
|
44
44
|
// TODO: maybe not hardcode decimals
|
|
45
|
-
const formatBaseData = (data, network, baseAssetPrice) => {
|
|
45
|
+
const formatBaseData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
46
46
|
const assetInfo = (0, tokens_1.getAssetInfoByAddress)(data.tokenAddr, network);
|
|
47
47
|
const totalSupply = (0, utils_1.getEthAmountForDecimals)(new decimal_js_1.default(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
48
48
|
const totalBorrow = (0, utils_1.getEthAmountForDecimals)(new decimal_js_1.default(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -50,7 +50,7 @@ const formatBaseData = (data, network, baseAssetPrice) => {
|
|
|
50
50
|
.toString()), borrowRate: (0, moneymarket_1.aprToApy)(new decimal_js_1.default(data.borrowRate).div(1e18).mul(constants_1.SECONDS_PER_YEAR).mul(100)
|
|
51
51
|
.toString()), utilization: (0, utils_1.getEthAmountForDecimals)(data.utilization, 16), // utilization is totalSupply/totalBorrow in 1e18, but we need % so when we mul with 100 it's 16 decimals
|
|
52
52
|
totalSupply,
|
|
53
|
-
totalBorrow, marketLiquidity: new decimal_js_1.default(totalSupply).minus(totalBorrow).toString(), symbol: (0, utils_1.wethToEth)(assetInfo.symbol), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied:
|
|
53
|
+
totalBorrow, marketLiquidity: new decimal_js_1.default(totalSupply).minus(totalBorrow).toString(), symbol: (0, utils_1.wethToEth)(assetInfo.symbol), priceInBaseAsset: (0, utils_1.getEthAmountForDecimals)(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyCap: '0', rewardSupplySpeed: (0, utils_1.getEthAmountForDecimals)(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: (0, utils_1.getEthAmountForDecimals)(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: (0, utils_1.getEthAmountForDecimals)(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
54
54
|
};
|
|
55
55
|
exports.formatBaseData = formatBaseData;
|
|
56
56
|
const getIncentiveApys = (baseData, compPrice) => __awaiter(void 0, void 0, void 0, function* () {
|
package/cjs/types/compound.d.ts
CHANGED
package/esm/compoundV3/index.js
CHANGED
|
@@ -32,16 +32,18 @@ const getBaseAssetPriceFunction = (asset) => {
|
|
|
32
32
|
};
|
|
33
33
|
export const _getCompoundV3MarketsData = (provider, network, selectedMarket, defaultProvider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
const contract = CompV3ViewContractViem(provider, network);
|
|
35
|
-
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos] = yield Promise.all([
|
|
35
|
+
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos, govInfo] = yield Promise.all([
|
|
36
36
|
getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultProvider),
|
|
37
37
|
getCompPrice(defaultProvider),
|
|
38
38
|
contract.read.getFullBaseTokenInfo([selectedMarket.baseMarketAddress]),
|
|
39
39
|
contract.read.getFullCollInfos([selectedMarket.baseMarketAddress]),
|
|
40
|
+
contract.read.getGovernanceInfoFull([selectedMarket.baseMarketAddress]),
|
|
40
41
|
]);
|
|
42
|
+
const { isSupplyPaused, isWithdrawPaused } = govInfo;
|
|
41
43
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
42
44
|
const colls = collInfos
|
|
43
45
|
.filter((coll) => supportedAssetsAddresses.includes(coll.tokenAddr.toLowerCase()))
|
|
44
|
-
.map((coll) => formatMarketData(coll, network, baseAssetPrice));
|
|
46
|
+
.map((coll) => formatMarketData(coll, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused));
|
|
45
47
|
for (const coll of colls) {
|
|
46
48
|
if (STAKING_ASSETS.includes(coll.symbol)) {
|
|
47
49
|
coll.supplyIncentives.push({
|
|
@@ -52,7 +54,7 @@ export const _getCompoundV3MarketsData = (provider, network, selectedMarket, def
|
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice);
|
|
57
|
+
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused);
|
|
56
58
|
const payload = {};
|
|
57
59
|
const baseObj = Object.assign(Object.assign({}, base), (yield getIncentiveApys(base, compPrice)));
|
|
58
60
|
const allAssets = [baseObj, ...colls];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAdditionalAssetData, CompoundAggregatedPositionData, CompoundMarketData, CompoundV2AssetsData, CompoundV2UsedAssets, CompoundV3AssetData, CompoundV3AssetsData, CompoundV3UsedAssets } from '../../types';
|
|
2
2
|
import { EthAddress, EthereumProvider, IncentiveData, NetworkNumber } from '../../types/common';
|
|
3
|
-
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData;
|
|
4
|
-
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
3
|
+
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData;
|
|
4
|
+
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
5
5
|
export declare const getIncentiveApys: (baseData: CompoundV3AssetData & BaseAdditionalAssetData, compPrice: string) => Promise<{
|
|
6
6
|
supplyIncentives: IncentiveData[];
|
|
7
7
|
borrowIncentives: IncentiveData[];
|
|
@@ -28,14 +28,14 @@ import { calculateNetApy, getStakingApy, STAKING_ASSETS } from '../../staking';
|
|
|
28
28
|
import { IncentiveKind, LeverageType, NetworkNumber, } from '../../types/common';
|
|
29
29
|
import { CompoundLoanInfoContractViem, CompV3ViewContractViem } from '../../contracts';
|
|
30
30
|
import { getViemProvider } from '../../services/viem';
|
|
31
|
-
export const formatMarketData = (data, network, baseAssetPrice) => {
|
|
31
|
+
export const formatMarketData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
32
32
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
33
33
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
34
34
|
const price = getEthAmountForDecimals(data.price, 8);
|
|
35
|
-
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied:
|
|
35
|
+
return (Object.assign(Object.assign({}, data), { borrowCollateralFactor: data.borrowCollateralFactor.toString(), liquidateCollateralFactor: data.liquidateCollateralFactor.toString(), liquidationFactor: data.liquidationFactor.toString(), supplyReserved: data.supplyReserved.toString(), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyIncentives: [], borrowIncentives: [] }));
|
|
36
36
|
};
|
|
37
37
|
// TODO: maybe not hardcode decimals
|
|
38
|
-
export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
38
|
+
export const formatBaseData = (data, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused) => {
|
|
39
39
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
40
40
|
const totalSupply = getEthAmountForDecimals(new Dec(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
41
41
|
const totalBorrow = getEthAmountForDecimals(new Dec(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -43,7 +43,7 @@ export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
|
43
43
|
.toString()), borrowRate: aprToApy(new Dec(data.borrowRate).div(1e18).mul(SECONDS_PER_YEAR).mul(100)
|
|
44
44
|
.toString()), utilization: getEthAmountForDecimals(data.utilization, 16), // utilization is totalSupply/totalBorrow in 1e18, but we need % so when we mul with 100 it's 16 decimals
|
|
45
45
|
totalSupply,
|
|
46
|
-
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied:
|
|
46
|
+
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: !isSupplyPaused, canBeWithdrawn: !isWithdrawPaused, supplyCap: '0', rewardSupplySpeed: getEthAmountForDecimals(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: getEthAmountForDecimals(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: getEthAmountForDecimals(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
47
47
|
};
|
|
48
48
|
export const getIncentiveApys = (baseData, compPrice) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
49
|
return ({
|
package/esm/types/compound.d.ts
CHANGED
package/package.json
CHANGED
package/src/compoundV3/index.ts
CHANGED
|
@@ -43,18 +43,21 @@ const getBaseAssetPriceFunction = (asset: string) => {
|
|
|
43
43
|
export const _getCompoundV3MarketsData = async (provider: Client, network: NetworkNumber, selectedMarket: CompoundMarketData, defaultProvider: Client): Promise<CompoundV3MarketsData> => {
|
|
44
44
|
const contract = CompV3ViewContractViem(provider, network);
|
|
45
45
|
|
|
46
|
-
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos] = await Promise.all([
|
|
46
|
+
const [baseAssetPrice, compPrice, baseTokenInfo, collInfos, govInfo] = await Promise.all([
|
|
47
47
|
getBaseAssetPriceFunction(selectedMarket.baseAsset)(defaultProvider),
|
|
48
48
|
getCompPrice(defaultProvider),
|
|
49
49
|
contract.read.getFullBaseTokenInfo([selectedMarket.baseMarketAddress]),
|
|
50
50
|
contract.read.getFullCollInfos([selectedMarket.baseMarketAddress]),
|
|
51
|
+
contract.read.getGovernanceInfoFull([selectedMarket.baseMarketAddress]),
|
|
51
52
|
]);
|
|
52
53
|
|
|
54
|
+
const { isSupplyPaused, isWithdrawPaused } = govInfo;
|
|
55
|
+
|
|
53
56
|
const supportedAssetsAddresses = getSupportedAssetsAddressesForMarket(selectedMarket, network);
|
|
54
57
|
|
|
55
58
|
const colls = collInfos
|
|
56
59
|
.filter((coll: any) => supportedAssetsAddresses.includes(coll.tokenAddr.toLowerCase()))
|
|
57
|
-
.map((coll: any) => formatMarketData(coll, network, baseAssetPrice)) as CompoundV3AssetData[];
|
|
60
|
+
.map((coll: any) => formatMarketData(coll, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused)) as CompoundV3AssetData[];
|
|
58
61
|
|
|
59
62
|
for (const coll of colls) {
|
|
60
63
|
if (STAKING_ASSETS.includes(coll.symbol)) {
|
|
@@ -66,7 +69,7 @@ export const _getCompoundV3MarketsData = async (provider: Client, network: Netwo
|
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
|
-
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice);
|
|
72
|
+
const base = formatBaseData(baseTokenInfo, network, baseAssetPrice, isSupplyPaused, isWithdrawPaused);
|
|
70
73
|
|
|
71
74
|
const payload: CompoundV3AssetsData = {};
|
|
72
75
|
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { CompoundLoanInfoContractViem, CompV3ViewContractViem } from '../../contracts';
|
|
18
18
|
import { getViemProvider } from '../../services/viem';
|
|
19
19
|
|
|
20
|
-
export const formatMarketData = (data: any, network: NetworkNumber, baseAssetPrice: string): CompoundV3AssetData => {
|
|
20
|
+
export const formatMarketData = (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean): CompoundV3AssetData => {
|
|
21
21
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
22
22
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
23
23
|
const price = getEthAmountForDecimals(data.price, 8);
|
|
@@ -37,14 +37,15 @@ export const formatMarketData = (data: any, network: NetworkNumber, baseAssetPri
|
|
|
37
37
|
supplyRate: '0',
|
|
38
38
|
borrowRate: '0',
|
|
39
39
|
canBeBorrowed: false,
|
|
40
|
-
canBeSupplied:
|
|
40
|
+
canBeSupplied: !isSupplyPaused,
|
|
41
|
+
canBeWithdrawn: !isWithdrawPaused,
|
|
41
42
|
supplyIncentives: [],
|
|
42
43
|
borrowIncentives: [],
|
|
43
44
|
});
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
// TODO: maybe not hardcode decimals
|
|
47
|
-
export const formatBaseData = (data: any, network: NetworkNumber, baseAssetPrice: string): CompoundV3AssetData & BaseAdditionalAssetData => {
|
|
48
|
+
export const formatBaseData = (data: any, network: NetworkNumber, baseAssetPrice: string, isSupplyPaused: boolean, isWithdrawPaused: boolean): CompoundV3AssetData & BaseAdditionalAssetData => {
|
|
48
49
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
49
50
|
const totalSupply = getEthAmountForDecimals(new Dec(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
50
51
|
const totalBorrow = getEthAmountForDecimals(new Dec(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -71,7 +72,8 @@ export const formatBaseData = (data: any, network: NetworkNumber, baseAssetPrice
|
|
|
71
72
|
collateralFactor: '0',
|
|
72
73
|
liquidationRatio: '0',
|
|
73
74
|
canBeBorrowed: true,
|
|
74
|
-
canBeSupplied:
|
|
75
|
+
canBeSupplied: !isSupplyPaused,
|
|
76
|
+
canBeWithdrawn: !isWithdrawPaused,
|
|
75
77
|
supplyCap: '0',
|
|
76
78
|
rewardSupplySpeed: getEthAmountForDecimals(data.baseTrackingSupplyRewardsSpeed, 15),
|
|
77
79
|
rewardBorrowSpeed: getEthAmountForDecimals(data.baseTrackingBorrowRewardsSpeed, 15),
|
package/src/types/compound.ts
CHANGED