@defisaver/positions-sdk 2.1.79-aave-v4-2-dev → 2.1.79-aave-v4-4-dev
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/aaveV4/index.js +4 -3
- package/cjs/eulerV2/index.d.ts +1 -2
- package/cjs/eulerV2/index.js +4 -5
- package/cjs/moneymarket/moneymarketCommonService.js +1 -1
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +3 -3
- package/esm/aaveV4/index.js +5 -4
- package/esm/eulerV2/index.d.ts +1 -2
- package/esm/eulerV2/index.js +5 -6
- package/esm/moneymarket/moneymarketCommonService.js +1 -1
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +1 -1
- package/package.json +1 -1
- package/src/aaveV4/index.ts +5 -4
- package/src/eulerV2/index.ts +12 -7
- package/src/moneymarket/moneymarketCommonService.ts +1 -1
- package/src/services/utils.ts +1 -1
package/cjs/aaveV4/index.js
CHANGED
|
@@ -203,8 +203,8 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
203
203
|
totalDrawn: (0, tokens_1.assetAmountInEth)(totalDrawnRaw.toString(), symbol),
|
|
204
204
|
totalPremium: (0, tokens_1.assetAmountInEth)(totalPremiumRaw.toString(), symbol),
|
|
205
205
|
totalDebt: (0, tokens_1.assetAmountInEth)(totalDebtRaw.toString(), symbol),
|
|
206
|
-
supplyCap: (0, tokens_1.assetAmountInEth)(supplyCapRaw.toString(), symbol),
|
|
207
|
-
borrowCap: (0, tokens_1.assetAmountInEth)(borrowCapRaw.toString(), symbol),
|
|
206
|
+
supplyCap: (0, utils_1.isMaxUint)(supplyCapRaw.toString()) ? supplyCapRaw.toString() : (0, tokens_1.assetAmountInEth)(supplyCapRaw.toString(), symbol),
|
|
207
|
+
borrowCap: (0, utils_1.isMaxUint)(borrowCapRaw.toString()) ? borrowCapRaw.toString() : (0, tokens_1.assetAmountInEth)(borrowCapRaw.toString(), symbol),
|
|
208
208
|
spokeActive: reserveAsset.spokeActive,
|
|
209
209
|
spokeHalted: reserveAsset.spokeHalted,
|
|
210
210
|
drawnRate: drawnRate.toString(),
|
|
@@ -250,7 +250,8 @@ function _getAaveV4AccountData(provider_1, network_1, spokeData_1, address_1) {
|
|
|
250
250
|
return __awaiter(this, arguments, void 0, function* (provider, network, spokeData, address, blockNumber = 'latest') {
|
|
251
251
|
const viewContract = (0, contracts_1.AaveV4ViewContractViem)(provider, network, blockNumber);
|
|
252
252
|
const loanData = yield viewContract.read.getLoanData([spokeData.address, address]);
|
|
253
|
-
const
|
|
253
|
+
const healthFactorFromContract = new decimal_js_1.default(loanData.healthFactor.toString());
|
|
254
|
+
const healthFactor = (0, utils_1.isMaxUint)(healthFactorFromContract.toString()) ? '0' : healthFactorFromContract.div(1e18).toString();
|
|
254
255
|
const usedAssets = loanData.reserves.reduce((acc, usedReserveAsset) => {
|
|
255
256
|
const identifier = `${(0, utils_1.wethToEth)((0, tokens_1.getAssetInfoByAddress)(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
|
|
256
257
|
const reserveData = spokeData.assetsData[identifier];
|
package/cjs/eulerV2/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
|
-
import { EthAddress, EthereumProvider, NetworkNumber } from '../types
|
|
3
|
-
import { EulerV2AssetsData, EulerV2FullMarketData, EulerV2Market, EulerV2MarketInfoData, EulerV2PositionData } from '../types';
|
|
2
|
+
import { EulerV2AssetsData, EulerV2FullMarketData, EulerV2Market, EulerV2MarketInfoData, EulerV2PositionData, EthAddress, EthereumProvider, NetworkNumber } from '../types';
|
|
4
3
|
export declare const EMPTY_USED_ASSET: {
|
|
5
4
|
isSupplied: boolean;
|
|
6
5
|
isBorrowed: boolean;
|
package/cjs/eulerV2/index.js
CHANGED
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.getEulerV2AccountData = exports._getEulerV2AccountData = exports.EMPTY_EULER_V2_DATA = exports.getEulerV2MarketsData = exports._getEulerV2MarketsData = exports.EMPTY_USED_ASSET = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
|
-
const common_1 = require("../types/common");
|
|
19
18
|
const staking_1 = require("../staking");
|
|
20
19
|
const utils_1 = require("../services/utils");
|
|
21
20
|
const types_1 = require("../types");
|
|
@@ -65,7 +64,7 @@ const _getEulerV2MarketsData = (provider, network, selectedMarket) => __awaiter(
|
|
|
65
64
|
collateralFactor: new decimal_js_1.default(collateral.borrowLTV).div(10000).toString(),
|
|
66
65
|
totalBorrow: (0, utils_1.getEthAmountForDecimals)(collateral.totalBorrows.toString(), decimals), // parse
|
|
67
66
|
cash: (0, utils_1.getEthAmountForDecimals)(collateral.cash.toString(), decimals),
|
|
68
|
-
supplyCap: (0, utils_1.
|
|
67
|
+
supplyCap: (0, utils_1.isMaxUint)(collateral.supplyCap.toString()) ? collateral.supplyCap.toString() : (0, utils_1.getEthAmountForDecimals)(collateral.supplyCap.toString(), decimals),
|
|
69
68
|
borrowCap: '0',
|
|
70
69
|
price: isInUSD ? (0, tokens_1.assetAmountInEth)(collateral.assetPriceInUnit.toString()) : new decimal_js_1.default((0, tokens_1.assetAmountInEth)(collateral.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
71
70
|
canBeBorrowed: false,
|
|
@@ -83,7 +82,7 @@ const _getEulerV2MarketsData = (provider, network, selectedMarket) => __awaiter(
|
|
|
83
82
|
coll.supplyIncentives.push({
|
|
84
83
|
apy: yield (0, staking_1.getStakingApy)(coll.symbol),
|
|
85
84
|
token: coll.symbol,
|
|
86
|
-
incentiveKind:
|
|
85
|
+
incentiveKind: types_1.IncentiveKind.Staking,
|
|
87
86
|
description: `Native ${coll.symbol} yield.`,
|
|
88
87
|
});
|
|
89
88
|
}
|
|
@@ -105,8 +104,8 @@ const _getEulerV2MarketsData = (provider, network, selectedMarket) => __awaiter(
|
|
|
105
104
|
decimals,
|
|
106
105
|
totalBorrow: (0, utils_1.getEthAmountForDecimals)(data.totalBorrows.toString(), decimals), // parse
|
|
107
106
|
cash: (0, utils_1.getEthAmountForDecimals)(data.cash.toString(), decimals),
|
|
108
|
-
supplyCap: (0, utils_1.
|
|
109
|
-
borrowCap: (0, utils_1.
|
|
107
|
+
supplyCap: (0, utils_1.isMaxUint)(data.supplyCap.toString()) ? data.supplyCap.toString() : (0, utils_1.getEthAmountForDecimals)(data.supplyCap.toString(), decimals),
|
|
108
|
+
borrowCap: (0, utils_1.isMaxUint)(data.supplyCap.toString()) ? data.borrowCap.toString() : (0, utils_1.getEthAmountForDecimals)(data.borrowCap.toString(), decimals),
|
|
110
109
|
price: isInUSD ? (0, tokens_1.assetAmountInEth)(data.assetPriceInUnit.toString()) : new decimal_js_1.default((0, tokens_1.assetAmountInEth)(data.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
111
110
|
sortIndex: 0,
|
|
112
111
|
canBeBorrowed: true,
|
|
@@ -32,7 +32,7 @@ exports.STABLE_ASSETS = [
|
|
|
32
32
|
'DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'USDA',
|
|
33
33
|
'USDe', 'sUSDe', 'USDS', 'sUSDS', 'USR', 'EURC', 'BOLD', 'BOLD Legacy', 'RLUSD', 'PT sUSDe July', 'PT eUSDe May',
|
|
34
34
|
'USDtb', 'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'PT sUSDe Sep', 'PT USDe Sep', 'PT sUSDe Nov', 'PT USDe Nov', 'PT sUSDe Jan', 'PT USDe Jan',
|
|
35
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
35
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'frxUSD',
|
|
36
36
|
];
|
|
37
37
|
const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
38
38
|
let borrowUnstable = 0;
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const bytesToString: (hex: string) => string;
|
|
|
18
18
|
export declare const mapRange: (input: number | string, minInput: number | string, maxInput: number | string, minOutput: number | string, maxOutput: number | string) => number;
|
|
19
19
|
export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) => bigint;
|
|
20
20
|
export declare const MAXUINT: string;
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const isMaxUint: (amount: string) => boolean;
|
|
22
22
|
export declare const isMainnetNetwork: (network: NetworkNumber) => network is NetworkNumber.Eth;
|
|
23
23
|
export declare const DEFAULT_TIMEOUT = 2000;
|
|
24
24
|
export declare const LONGER_TIMEOUT = 5000;
|
package/cjs/services/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getNativeAssetFromWrapped = exports.getWrappedNativeAssetFromUnwrapped = exports.wxplToXpl = exports.xplToWxpl = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.convertHybridArraysToObjects = exports.LONGER_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.isMainnetNetwork = exports.
|
|
6
|
+
exports.getNativeAssetFromWrapped = exports.getWrappedNativeAssetFromUnwrapped = exports.wxplToXpl = exports.xplToWxpl = exports.ethToWethByAddress = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.convertHybridArraysToObjects = exports.LONGER_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.isMainnetNetwork = exports.isMaxUint = exports.MAXUINT = exports.isEnabledOnBitmap = exports.mapRange = exports.bytesToString = exports.handleWbtcLegacy = exports.getEthAmountForDecimals = exports.getWeiAmountForDecimals = exports.compareAddresses = exports.isAddress = exports.ADDRESS_REGEX = exports.getAbiItem = exports.wstEthToStEth = exports.stEthToWstEth = exports.addToArrayIf = exports.addToObjectIf = exports.isLayer2Network = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const tokens_1 = require("@defisaver/tokens");
|
|
9
9
|
const common_1 = require("../types/common");
|
|
@@ -51,8 +51,8 @@ exports.mapRange = mapRange;
|
|
|
51
51
|
const isEnabledOnBitmap = (bitmap, assetId) => (BigInt(bitmap) >> BigInt(assetId)) & BigInt(1);
|
|
52
52
|
exports.isEnabledOnBitmap = isEnabledOnBitmap;
|
|
53
53
|
exports.MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
54
|
-
const
|
|
55
|
-
exports.
|
|
54
|
+
const isMaxUint = (amount) => (0, exports.compareAddresses)(exports.MAXUINT, amount);
|
|
55
|
+
exports.isMaxUint = isMaxUint;
|
|
56
56
|
const isMainnetNetwork = (network) => network === common_1.NetworkNumber.Eth;
|
|
57
57
|
exports.isMainnetNetwork = isMainnetNetwork;
|
|
58
58
|
exports.DEFAULT_TIMEOUT = 2000; // 2 seconds
|
package/esm/aaveV4/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getViemProvider } from '../services/viem';
|
|
|
13
13
|
import { IncentiveKind, } from '../types';
|
|
14
14
|
import { AaveV4ViewContractViem } from '../contracts';
|
|
15
15
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
|
-
import { wethToEth } from '../services/utils';
|
|
16
|
+
import { isMaxUint, wethToEth } from '../services/utils';
|
|
17
17
|
import { aaveV4GetAggregatedPositionData } from '../helpers/aaveV4Helpers';
|
|
18
18
|
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
19
19
|
import { aprToApy } from '../moneymarket';
|
|
@@ -160,8 +160,8 @@ const formatReserveAsset = (reserveAsset, hubAsset, reserveId, oracleDecimals, n
|
|
|
160
160
|
totalDrawn: assetAmountInEth(totalDrawnRaw.toString(), symbol),
|
|
161
161
|
totalPremium: assetAmountInEth(totalPremiumRaw.toString(), symbol),
|
|
162
162
|
totalDebt: assetAmountInEth(totalDebtRaw.toString(), symbol),
|
|
163
|
-
supplyCap: assetAmountInEth(supplyCapRaw.toString(), symbol),
|
|
164
|
-
borrowCap: assetAmountInEth(borrowCapRaw.toString(), symbol),
|
|
163
|
+
supplyCap: isMaxUint(supplyCapRaw.toString()) ? supplyCapRaw.toString() : assetAmountInEth(supplyCapRaw.toString(), symbol),
|
|
164
|
+
borrowCap: isMaxUint(borrowCapRaw.toString()) ? borrowCapRaw.toString() : assetAmountInEth(borrowCapRaw.toString(), symbol),
|
|
165
165
|
spokeActive: reserveAsset.spokeActive,
|
|
166
166
|
spokeHalted: reserveAsset.spokeHalted,
|
|
167
167
|
drawnRate: drawnRate.toString(),
|
|
@@ -207,7 +207,8 @@ export function _getAaveV4AccountData(provider_1, network_1, spokeData_1, addres
|
|
|
207
207
|
return __awaiter(this, arguments, void 0, function* (provider, network, spokeData, address, blockNumber = 'latest') {
|
|
208
208
|
const viewContract = AaveV4ViewContractViem(provider, network, blockNumber);
|
|
209
209
|
const loanData = yield viewContract.read.getLoanData([spokeData.address, address]);
|
|
210
|
-
const
|
|
210
|
+
const healthFactorFromContract = new Dec(loanData.healthFactor.toString());
|
|
211
|
+
const healthFactor = isMaxUint(healthFactorFromContract.toString()) ? '0' : healthFactorFromContract.div(1e18).toString();
|
|
211
212
|
const usedAssets = loanData.reserves.reduce((acc, usedReserveAsset) => {
|
|
212
213
|
const identifier = `${wethToEth(getAssetInfoByAddress(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
|
|
213
214
|
const reserveData = spokeData.assetsData[identifier];
|
package/esm/eulerV2/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
|
-
import { EthAddress, EthereumProvider, NetworkNumber } from '../types
|
|
3
|
-
import { EulerV2AssetsData, EulerV2FullMarketData, EulerV2Market, EulerV2MarketInfoData, EulerV2PositionData } from '../types';
|
|
2
|
+
import { EulerV2AssetsData, EulerV2FullMarketData, EulerV2Market, EulerV2MarketInfoData, EulerV2PositionData, EthAddress, EthereumProvider, NetworkNumber } from '../types';
|
|
4
3
|
export declare const EMPTY_USED_ASSET: {
|
|
5
4
|
isSupplied: boolean;
|
|
6
5
|
isBorrowed: boolean;
|
package/esm/eulerV2/index.js
CHANGED
|
@@ -9,10 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
|
-
import { IncentiveKind, } from '../types/common';
|
|
13
12
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
14
|
-
import { compareAddresses, getEthAmountForDecimals,
|
|
15
|
-
import { EulerV2VaultType, } from '../types';
|
|
13
|
+
import { compareAddresses, getEthAmountForDecimals, isMaxUint, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
14
|
+
import { EulerV2VaultType, IncentiveKind, } from '../types';
|
|
16
15
|
import { getEulerV2AggregatedData, getEulerV2BorrowRate, getEulerV2SupplyRate, getUtilizationRate, } from '../helpers/eulerHelpers';
|
|
17
16
|
import { ZERO_ADDRESS } from '../constants';
|
|
18
17
|
import { EulerV2ViewContractViem } from '../contracts';
|
|
@@ -59,7 +58,7 @@ export const _getEulerV2MarketsData = (provider, network, selectedMarket) => __a
|
|
|
59
58
|
collateralFactor: new Dec(collateral.borrowLTV).div(10000).toString(),
|
|
60
59
|
totalBorrow: getEthAmountForDecimals(collateral.totalBorrows.toString(), decimals), // parse
|
|
61
60
|
cash: getEthAmountForDecimals(collateral.cash.toString(), decimals),
|
|
62
|
-
supplyCap:
|
|
61
|
+
supplyCap: isMaxUint(collateral.supplyCap.toString()) ? collateral.supplyCap.toString() : getEthAmountForDecimals(collateral.supplyCap.toString(), decimals),
|
|
63
62
|
borrowCap: '0',
|
|
64
63
|
price: isInUSD ? assetAmountInEth(collateral.assetPriceInUnit.toString()) : new Dec(assetAmountInEth(collateral.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
65
64
|
canBeBorrowed: false,
|
|
@@ -99,8 +98,8 @@ export const _getEulerV2MarketsData = (provider, network, selectedMarket) => __a
|
|
|
99
98
|
decimals,
|
|
100
99
|
totalBorrow: getEthAmountForDecimals(data.totalBorrows.toString(), decimals), // parse
|
|
101
100
|
cash: getEthAmountForDecimals(data.cash.toString(), decimals),
|
|
102
|
-
supplyCap:
|
|
103
|
-
borrowCap:
|
|
101
|
+
supplyCap: isMaxUint(data.supplyCap.toString()) ? data.supplyCap.toString() : getEthAmountForDecimals(data.supplyCap.toString(), decimals),
|
|
102
|
+
borrowCap: isMaxUint(data.supplyCap.toString()) ? data.borrowCap.toString() : getEthAmountForDecimals(data.borrowCap.toString(), decimals),
|
|
104
103
|
price: isInUSD ? assetAmountInEth(data.assetPriceInUnit.toString()) : new Dec(assetAmountInEth(data.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
105
104
|
sortIndex: 0,
|
|
106
105
|
canBeBorrowed: true,
|
|
@@ -21,7 +21,7 @@ export const STABLE_ASSETS = [
|
|
|
21
21
|
'DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'USDA',
|
|
22
22
|
'USDe', 'sUSDe', 'USDS', 'sUSDS', 'USR', 'EURC', 'BOLD', 'BOLD Legacy', 'RLUSD', 'PT sUSDe July', 'PT eUSDe May',
|
|
23
23
|
'USDtb', 'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'PT sUSDe Sep', 'PT USDe Sep', 'PT sUSDe Nov', 'PT USDe Nov', 'PT sUSDe Jan', 'PT USDe Jan',
|
|
24
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
24
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'frxUSD',
|
|
25
25
|
];
|
|
26
26
|
export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
27
27
|
let borrowUnstable = 0;
|
package/esm/services/utils.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const bytesToString: (hex: string) => string;
|
|
|
18
18
|
export declare const mapRange: (input: number | string, minInput: number | string, maxInput: number | string, minOutput: number | string, maxOutput: number | string) => number;
|
|
19
19
|
export declare const isEnabledOnBitmap: (bitmap: number, assetId: number) => bigint;
|
|
20
20
|
export declare const MAXUINT: string;
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const isMaxUint: (amount: string) => boolean;
|
|
22
22
|
export declare const isMainnetNetwork: (network: NetworkNumber) => network is NetworkNumber.Eth;
|
|
23
23
|
export declare const DEFAULT_TIMEOUT = 2000;
|
|
24
24
|
export declare const LONGER_TIMEOUT = 5000;
|
package/esm/services/utils.js
CHANGED
|
@@ -31,7 +31,7 @@ export const mapRange = (input, minInput, maxInput, minOutput, maxOutput) => {
|
|
|
31
31
|
// eslint-disable-next-line no-bitwise
|
|
32
32
|
export const isEnabledOnBitmap = (bitmap, assetId) => (BigInt(bitmap) >> BigInt(assetId)) & BigInt(1);
|
|
33
33
|
export const MAXUINT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
34
|
-
export const
|
|
34
|
+
export const isMaxUint = (amount) => compareAddresses(MAXUINT, amount);
|
|
35
35
|
export const isMainnetNetwork = (network) => network === NetworkNumber.Eth;
|
|
36
36
|
export const DEFAULT_TIMEOUT = 2000; // 2 seconds
|
|
37
37
|
export const LONGER_TIMEOUT = 5000; // 5 seconds
|
package/package.json
CHANGED
package/src/aaveV4/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from '../types';
|
|
21
21
|
import { AaveV4ViewContractViem } from '../contracts';
|
|
22
22
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
23
|
-
import { wethToEth } from '../services/utils';
|
|
23
|
+
import { isMaxUint, wethToEth } from '../services/utils';
|
|
24
24
|
import { aaveV4GetAggregatedPositionData } from '../helpers/aaveV4Helpers';
|
|
25
25
|
import { getAaveV4HubByAddress } from '../markets/aaveV4';
|
|
26
26
|
import { aprToApy } from '../moneymarket';
|
|
@@ -189,8 +189,8 @@ const formatReserveAsset = async (reserveAsset: AaveV4ReserveAssetOnChain, hubAs
|
|
|
189
189
|
totalDrawn: assetAmountInEth(totalDrawnRaw.toString(), symbol),
|
|
190
190
|
totalPremium: assetAmountInEth(totalPremiumRaw.toString(), symbol),
|
|
191
191
|
totalDebt: assetAmountInEth(totalDebtRaw.toString(), symbol),
|
|
192
|
-
supplyCap: assetAmountInEth(supplyCapRaw.toString(), symbol),
|
|
193
|
-
borrowCap: assetAmountInEth(borrowCapRaw.toString(), symbol),
|
|
192
|
+
supplyCap: isMaxUint(supplyCapRaw.toString()) ? supplyCapRaw.toString() : assetAmountInEth(supplyCapRaw.toString(), symbol),
|
|
193
|
+
borrowCap: isMaxUint(borrowCapRaw.toString()) ? borrowCapRaw.toString() : assetAmountInEth(borrowCapRaw.toString(), symbol),
|
|
194
194
|
spokeActive: reserveAsset.spokeActive,
|
|
195
195
|
spokeHalted: reserveAsset.spokeHalted,
|
|
196
196
|
drawnRate: drawnRate.toString(),
|
|
@@ -239,7 +239,8 @@ export async function _getAaveV4AccountData(provider: Client, network: NetworkNu
|
|
|
239
239
|
|
|
240
240
|
const loanData = await viewContract.read.getLoanData([spokeData.address, address]);
|
|
241
241
|
|
|
242
|
-
const
|
|
242
|
+
const healthFactorFromContract = new Dec(loanData.healthFactor.toString());
|
|
243
|
+
const healthFactor = isMaxUint(healthFactorFromContract.toString()) ? '0' : healthFactorFromContract.div(1e18).toString();
|
|
243
244
|
const usedAssets = loanData.reserves.reduce((acc: AaveV4UsedReserveAssets, usedReserveAsset) => {
|
|
244
245
|
const identifier = `${wethToEth(getAssetInfoByAddress(usedReserveAsset.underlying, network).symbol)}-${+usedReserveAsset.reserveId.toString()}`;
|
|
245
246
|
const reserveData = spokeData.assetsData[identifier];
|
package/src/eulerV2/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { assetAmountInEth, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
3
3
|
import { Client } from 'viem';
|
|
4
|
-
import {
|
|
5
|
-
EthAddress, EthereumProvider, IncentiveKind, NetworkNumber,
|
|
6
|
-
} from '../types/common';
|
|
7
4
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
8
5
|
import {
|
|
9
|
-
compareAddresses,
|
|
6
|
+
compareAddresses,
|
|
7
|
+
getEthAmountForDecimals,
|
|
8
|
+
isMaxUint,
|
|
9
|
+
wethToEth,
|
|
10
|
+
wethToEthByAddress,
|
|
10
11
|
} from '../services/utils';
|
|
11
12
|
import {
|
|
12
13
|
EulerV2AssetData,
|
|
@@ -17,6 +18,10 @@ import {
|
|
|
17
18
|
EulerV2PositionData,
|
|
18
19
|
EulerV2UsedAssets,
|
|
19
20
|
EulerV2VaultType,
|
|
21
|
+
EthAddress,
|
|
22
|
+
EthereumProvider,
|
|
23
|
+
IncentiveKind,
|
|
24
|
+
NetworkNumber,
|
|
20
25
|
} from '../types';
|
|
21
26
|
import {
|
|
22
27
|
getEulerV2AggregatedData,
|
|
@@ -80,7 +85,7 @@ export const _getEulerV2MarketsData = async (provider: Client, network: NetworkN
|
|
|
80
85
|
collateralFactor: new Dec(collateral.borrowLTV).div(10_000).toString(),
|
|
81
86
|
totalBorrow: getEthAmountForDecimals(collateral.totalBorrows.toString(), decimals), // parse
|
|
82
87
|
cash: getEthAmountForDecimals(collateral.cash.toString(), decimals),
|
|
83
|
-
supplyCap:
|
|
88
|
+
supplyCap: isMaxUint(collateral.supplyCap.toString()) ? collateral.supplyCap.toString() : getEthAmountForDecimals(collateral.supplyCap.toString(), decimals),
|
|
84
89
|
borrowCap: '0',
|
|
85
90
|
price: isInUSD ? assetAmountInEth(collateral.assetPriceInUnit.toString()) : new Dec(assetAmountInEth(collateral.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
86
91
|
canBeBorrowed: false,
|
|
@@ -128,8 +133,8 @@ export const _getEulerV2MarketsData = async (provider: Client, network: NetworkN
|
|
|
128
133
|
decimals,
|
|
129
134
|
totalBorrow: getEthAmountForDecimals(data.totalBorrows.toString(), decimals), // parse
|
|
130
135
|
cash: getEthAmountForDecimals(data.cash.toString(), decimals),
|
|
131
|
-
supplyCap:
|
|
132
|
-
borrowCap:
|
|
136
|
+
supplyCap: isMaxUint(data.supplyCap.toString()) ? data.supplyCap.toString() : getEthAmountForDecimals(data.supplyCap.toString(), decimals),
|
|
137
|
+
borrowCap: isMaxUint(data.supplyCap.toString()) ? data.borrowCap.toString() : getEthAmountForDecimals(data.borrowCap.toString(), decimals),
|
|
133
138
|
price: isInUSD ? assetAmountInEth(data.assetPriceInUnit.toString()) : new Dec(assetAmountInEth(data.assetPriceInUnit.toString())).mul(usdPrice).toString(), // 1e18 -> price in unitOfAccount (so it could be USD or any other token)
|
|
134
139
|
sortIndex: 0,
|
|
135
140
|
canBeBorrowed: true,
|
|
@@ -24,7 +24,7 @@ export const STABLE_ASSETS = [
|
|
|
24
24
|
'DAI', 'USDC', 'USDT', 'TUSD', 'USDP', 'GUSD', 'BUSD', 'SUSD', 'FRAX', 'LUSD', 'USDC.e', 'GHO', 'sDAI', 'USDA',
|
|
25
25
|
'USDe', 'sUSDe', 'USDS', 'sUSDS', 'USR', 'EURC', 'BOLD', 'BOLD Legacy', 'RLUSD', 'PT sUSDe July', 'PT eUSDe May',
|
|
26
26
|
'USDtb', 'eUSDe', 'PT USDe July', 'PT eUSDe Aug', 'PT sUSDe Sep', 'PT USDe Sep', 'PT sUSDe Nov', 'PT USDe Nov', 'PT sUSDe Jan', 'PT USDe Jan',
|
|
27
|
-
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr',
|
|
27
|
+
'PT sUSDe Feb', 'PT USDe Feb', 'PT sUSDe Apr', 'PT USDe Apr', 'PT sUSDe May', 'PT USDe May', 'PT srUSDe Apr', 'frxUSD',
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
export const isLeveragedPos = (usedAssets: MMUsedAssets, dustLimit = 5) => {
|
package/src/services/utils.ts
CHANGED
|
@@ -49,7 +49,7 @@ export const isEnabledOnBitmap = (bitmap: number, assetId: number) => (BigInt(bi
|
|
|
49
49
|
|
|
50
50
|
export const MAXUINT:string = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
51
51
|
|
|
52
|
-
export const
|
|
52
|
+
export const isMaxUint = (amount: string) => compareAddresses(MAXUINT, amount);
|
|
53
53
|
|
|
54
54
|
export const isMainnetNetwork = (network: NetworkNumber) => network === NetworkNumber.Eth;
|
|
55
55
|
|