@defisaver/positions-sdk 2.1.52 → 2.1.53
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/README.md +64 -64
- package/cjs/fluid/index.d.ts +6 -6
- package/cjs/helpers/aaveHelpers/index.d.ts +2 -2
- package/cjs/helpers/aaveHelpers/index.js +16 -5
- package/cjs/helpers/compoundHelpers/index.js +15 -18
- package/cjs/helpers/eulerHelpers/index.d.ts +2 -2
- package/cjs/helpers/eulerHelpers/index.js +21 -13
- package/cjs/helpers/fluidHelpers/index.js +16 -5
- package/cjs/helpers/morphoBlueHelpers/index.js +81 -71
- package/cjs/helpers/sparkHelpers/index.d.ts +2 -2
- package/cjs/helpers/sparkHelpers/index.js +15 -5
- package/cjs/moneymarket/moneymarketCommonService.d.ts +3 -3
- package/cjs/moneymarket/moneymarketCommonService.js +9 -9
- package/cjs/savings/morphoVaults/index.js +17 -17
- package/cjs/types/aave.d.ts +3 -3
- package/cjs/types/common.d.ts +7 -0
- package/cjs/types/common.js +9 -1
- package/cjs/types/compound.d.ts +3 -3
- package/cjs/types/curveUsd.d.ts +2 -2
- package/cjs/types/euler.d.ts +3 -3
- package/cjs/types/fluid.d.ts +3 -3
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/liquityV2.d.ts +3 -3
- package/cjs/types/llamaLend.d.ts +2 -2
- package/cjs/types/morphoBlue.d.ts +5 -5
- package/cjs/types/spark.d.ts +3 -3
- package/esm/fluid/index.d.ts +6 -6
- package/esm/helpers/aaveHelpers/index.d.ts +2 -2
- package/esm/helpers/aaveHelpers/index.js +16 -5
- package/esm/helpers/compoundHelpers/index.js +16 -19
- package/esm/helpers/eulerHelpers/index.d.ts +2 -2
- package/esm/helpers/eulerHelpers/index.js +21 -13
- package/esm/helpers/fluidHelpers/index.js +16 -5
- package/esm/helpers/morphoBlueHelpers/index.js +82 -72
- package/esm/helpers/sparkHelpers/index.d.ts +2 -2
- package/esm/helpers/sparkHelpers/index.js +16 -6
- package/esm/moneymarket/moneymarketCommonService.d.ts +3 -3
- package/esm/moneymarket/moneymarketCommonService.js +9 -9
- package/esm/savings/morphoVaults/index.js +17 -17
- package/esm/types/aave.d.ts +3 -3
- package/esm/types/common.d.ts +7 -0
- package/esm/types/common.js +8 -0
- package/esm/types/compound.d.ts +3 -3
- package/esm/types/curveUsd.d.ts +2 -2
- package/esm/types/euler.d.ts +3 -3
- package/esm/types/fluid.d.ts +3 -3
- package/esm/types/fluid.js +1 -1
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/liquityV2.d.ts +3 -3
- package/esm/types/llamaLend.d.ts +2 -2
- package/esm/types/morphoBlue.d.ts +5 -5
- package/esm/types/spark.d.ts +3 -3
- package/package.json +48 -48
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +635 -635
- package/src/aaveV3/merit.ts +97 -97
- package/src/aaveV3/merkl.ts +74 -74
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/ethena.ts +61 -61
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1320 -1320
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +171 -171
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1800 -1800
- package/src/helpers/aaveHelpers/index.ts +202 -191
- package/src/helpers/compoundHelpers/index.ts +276 -283
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +229 -222
- package/src/helpers/fluidHelpers/index.ts +335 -326
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +405 -396
- package/src/helpers/sparkHelpers/index.ts +169 -158
- package/src/index.ts +49 -49
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +703 -703
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +118 -118
- package/src/markets/aave/marketAssets.ts +54 -54
- package/src/markets/compound/index.ts +243 -243
- package/src/markets/compound/marketsAssets.ts +97 -97
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2900 -2900
- 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 +988 -988
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -12
- package/src/moneymarket/moneymarketCommonService.ts +84 -85
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +586 -586
- package/src/savings/index.ts +95 -95
- package/src/savings/makerDsr/index.ts +53 -53
- package/src/savings/makerDsr/options.ts +9 -9
- package/src/savings/morphoVaults/index.ts +80 -80
- package/src/savings/morphoVaults/options.ts +193 -193
- package/src/savings/skyOptions/index.ts +95 -95
- package/src/savings/skyOptions/options.ts +10 -10
- package/src/savings/sparkSavingsVaults/index.ts +60 -60
- package/src/savings/sparkSavingsVaults/options.ts +35 -35
- package/src/savings/yearnV3Vaults/index.ts +61 -61
- package/src/savings/yearnV3Vaults/options.ts +55 -55
- package/src/savings/yearnVaults/index.ts +73 -73
- package/src/savings/yearnVaults/options.ts +32 -32
- package/src/services/priceService.ts +278 -278
- package/src/services/utils.ts +115 -115
- package/src/services/viem.ts +57 -57
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +459 -459
- package/src/staking/eligibility.ts +53 -53
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +192 -192
- package/src/types/aave.ts +199 -198
- package/src/types/claiming.ts +114 -114
- package/src/types/common.ts +115 -107
- package/src/types/compound.ts +145 -144
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +176 -175
- package/src/types/fluid.ts +485 -483
- package/src/types/index.ts +16 -15
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +128 -126
- package/src/types/llamaLend.ts +161 -159
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +202 -202
- package/src/types/portfolio.ts +60 -60
- package/src/types/savings/index.ts +23 -23
- package/src/types/savings/makerDsr.ts +13 -13
- package/src/types/savings/morphoVaults.ts +32 -32
- package/src/types/savings/sky.ts +14 -14
- package/src/types/savings/sparkSavingsVaults.ts +15 -15
- package/src/types/savings/yearnV3Vaults.ts +17 -17
- package/src/types/savings/yearnVaults.ts +14 -14
- package/src/types/spark.ts +135 -134
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
|
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInWei, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
12
|
import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
|
|
13
13
|
import { calculateNetApy } from '../../staking';
|
|
14
|
-
import { NetworkNumber, } from '../../types/common';
|
|
14
|
+
import { LeverageType, NetworkNumber, } from '../../types/common';
|
|
15
15
|
import { borrowOperations, SECONDS_PER_YEAR, WAD } from '../../constants';
|
|
16
16
|
import { MorphoBlueViewContractViem } from '../../contracts';
|
|
17
17
|
import { compareAddresses, DEFAULT_TIMEOUT, wethToEth } from '../../services/utils';
|
|
@@ -45,12 +45,22 @@ export const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, ma
|
|
|
45
45
|
if (leveragedType !== '') {
|
|
46
46
|
payload.leveragedAsset = leveragedAsset;
|
|
47
47
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
48
|
-
if (leveragedType ===
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
if (leveragedType === LeverageType.VolatilePair) {
|
|
49
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
50
|
+
const borrowedAssetPrice = assetsData[borrowedAsset.symbol].price;
|
|
51
|
+
const leveragedAssetPrice = assetsData[leveragedAsset].price;
|
|
52
|
+
const isReverse = new Dec(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
53
|
+
if (isReverse) {
|
|
54
|
+
payload.leveragedType = LeverageType.VolatilePairReverse;
|
|
55
|
+
payload.currentVolatilePairRatio = new Dec(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
56
|
+
assetPrice = new Dec(borrowedAssetPrice).div(assetPrice).toString();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
assetPrice = new Dec(assetPrice).div(borrowedAssetPrice).toString();
|
|
60
|
+
payload.currentVolatilePairRatio = new Dec(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
|
-
payload.liquidationPrice = calcLeverageLiqPrice(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
63
|
+
payload.liquidationPrice = calcLeverageLiqPrice(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
54
64
|
}
|
|
55
65
|
payload.minCollRatio = new Dec(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
56
66
|
payload.collLiquidationRatio = new Dec(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -118,73 +128,73 @@ export const getApyAfterValuesEstimation = (selectedMarket, actions, provider, n
|
|
|
118
128
|
return { borrowRate, supplyRate };
|
|
119
129
|
});
|
|
120
130
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
121
|
-
const MARKET_QUERY = `
|
|
122
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
123
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
124
|
-
reallocatableLiquidityAssets
|
|
125
|
-
targetBorrowUtilization
|
|
126
|
-
loanAsset {
|
|
127
|
-
address
|
|
128
|
-
decimals
|
|
129
|
-
priceUsd
|
|
130
|
-
}
|
|
131
|
-
state {
|
|
132
|
-
liquidityAssets
|
|
133
|
-
borrowAssets
|
|
134
|
-
supplyAssets
|
|
135
|
-
}
|
|
136
|
-
publicAllocatorSharedLiquidity {
|
|
137
|
-
assets
|
|
138
|
-
vault {
|
|
139
|
-
address
|
|
140
|
-
name
|
|
141
|
-
}
|
|
142
|
-
allocationMarket {
|
|
143
|
-
uniqueKey
|
|
144
|
-
loanAsset {
|
|
145
|
-
address
|
|
146
|
-
}
|
|
147
|
-
collateralAsset {
|
|
148
|
-
address
|
|
149
|
-
}
|
|
150
|
-
irmAddress
|
|
151
|
-
oracle {
|
|
152
|
-
address
|
|
153
|
-
}
|
|
154
|
-
lltv
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
loanAsset {
|
|
158
|
-
address
|
|
159
|
-
}
|
|
160
|
-
collateralAsset {
|
|
161
|
-
address
|
|
162
|
-
}
|
|
163
|
-
oracle {
|
|
164
|
-
address
|
|
165
|
-
}
|
|
166
|
-
irmAddress
|
|
167
|
-
lltv
|
|
168
|
-
}
|
|
169
|
-
}
|
|
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
|
+
}
|
|
170
180
|
`;
|
|
171
|
-
const REWARDS_QUERY = `
|
|
172
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
173
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
174
|
-
uniqueKey
|
|
175
|
-
state {
|
|
176
|
-
rewards {
|
|
177
|
-
amountPerSuppliedToken
|
|
178
|
-
supplyApr
|
|
179
|
-
amountPerBorrowedToken
|
|
180
|
-
borrowApr
|
|
181
|
-
asset {
|
|
182
|
-
address
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
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
|
+
}
|
|
188
198
|
`;
|
|
189
199
|
/**
|
|
190
200
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SparkAggregatedPositionData, SparkAssetsData, SparkHelperCommon, SparkMarketData, SparkUsedAssets } from '../../types';
|
|
1
|
+
import { SparkAggregatedPositionData, SparkAssetsData, SparkHelperCommon, SparkMarketData, SparkUsedAsset, SparkUsedAssets } from '../../types';
|
|
2
2
|
import { EthereumProvider } from '../../types/common';
|
|
3
3
|
export declare const sparkIsInIsolationMode: ({ usedAssets, assetsData }: {
|
|
4
4
|
usedAssets: SparkUsedAssets;
|
|
@@ -6,7 +6,7 @@ export declare const sparkIsInIsolationMode: ({ usedAssets, assetsData }: {
|
|
|
6
6
|
}) => boolean;
|
|
7
7
|
export declare const sparkGetCollSuppliedAssets: ({ usedAssets }: {
|
|
8
8
|
usedAssets: SparkUsedAssets;
|
|
9
|
-
}) =>
|
|
9
|
+
}) => SparkUsedAsset[];
|
|
10
10
|
export declare const sparkGetSuppliableAssets: ({ usedAssets, eModeCategory, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => {
|
|
11
11
|
symbol: string;
|
|
12
12
|
canBeCollateral: boolean;
|
|
@@ -24,7 +24,7 @@ import { aprToApy, calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos, } from
|
|
|
24
24
|
import { calculateNetApy } from '../../staking';
|
|
25
25
|
import { ethToWeth, getNativeAssetFromWrapped, wethToEth } from '../../services/utils';
|
|
26
26
|
import { SparkViewContractViem } from '../../contracts';
|
|
27
|
-
import { NetworkNumber } from '../../types/common';
|
|
27
|
+
import { LeverageType, NetworkNumber, } from '../../types/common';
|
|
28
28
|
import { borrowOperations } from '../../constants';
|
|
29
29
|
import { getViemProvider } from '../../services/viem';
|
|
30
30
|
export const sparkIsInIsolationMode = ({ usedAssets, assetsData }) => Object.values(usedAssets).some(({ symbol, collateral }) => collateral && assetsData[symbol].isIsolated);
|
|
@@ -81,12 +81,22 @@ export const sparkGetAggregatedPositionData = (_a) => {
|
|
|
81
81
|
if (leveragedType !== '') {
|
|
82
82
|
payload.leveragedAsset = leveragedAsset;
|
|
83
83
|
let assetPrice = data.assetsData[leveragedAsset].price; // TODO sparkPrice or price??
|
|
84
|
-
if (leveragedType ===
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
if (leveragedType === LeverageType.VolatilePair) {
|
|
85
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
86
|
+
const borrowedAssetPrice = data.assetsData[borrowedAsset.symbol].price;
|
|
87
|
+
const leveragedAssetPrice = data.assetsData[leveragedAsset].price;
|
|
88
|
+
const isReverse = new Dec(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
89
|
+
if (isReverse) {
|
|
90
|
+
payload.leveragedType = LeverageType.VolatilePairReverse;
|
|
91
|
+
payload.currentVolatilePairRatio = new Dec(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
92
|
+
assetPrice = new Dec(borrowedAssetPrice).div(assetPrice).toString();
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
assetPrice = new Dec(assetPrice).div(borrowedAssetPrice).toString();
|
|
96
|
+
payload.currentVolatilePairRatio = new Dec(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
97
|
+
}
|
|
88
98
|
}
|
|
89
|
-
payload.liquidationPrice = calcLeverageLiqPrice(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
99
|
+
payload.liquidationPrice = calcLeverageLiqPrice(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
90
100
|
}
|
|
91
101
|
payload.minCollRatio = new Dec(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
92
102
|
payload.collLiquidationRatio = new Dec(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { MMUsedAssets } from '../types/common';
|
|
1
|
+
import { LeverageType, MMUsedAssets } from '../types/common';
|
|
2
2
|
export declare const getAssetsTotal: (assets: object, filter: any, transform: any) => any;
|
|
3
3
|
export declare const calcLongLiqPrice: (assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
|
|
4
4
|
export declare const calcShortLiqPrice: (assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
|
|
5
|
-
export declare const calcLeverageLiqPrice: (leverageType:
|
|
5
|
+
export declare const calcLeverageLiqPrice: (leverageType: LeverageType, assetPrice: string, borrowedUsd: string, borrowLimitUsd: string) => string;
|
|
6
6
|
export declare const calculateBorrowingAssetLimit: (assetBorrowedUsd: string, borrowLimitUsd: string) => string;
|
|
7
7
|
export declare const STABLE_ASSETS: string[];
|
|
8
8
|
export declare const isLeveragedPos: (usedAssets: MMUsedAssets, dustLimit?: number) => {
|
|
9
|
-
leveragedType:
|
|
9
|
+
leveragedType: LeverageType;
|
|
10
10
|
leveragedAsset: string;
|
|
11
11
|
};
|
|
12
12
|
export declare const aprToApy: (interest: string | number, frequency?: number) => string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
2
|
import { BLOCKS_IN_A_YEAR } from '../constants';
|
|
3
|
+
import { LeverageType } from '../types/common';
|
|
3
4
|
export const getAssetsTotal = (assets, filter, transform) => Object.values(assets)
|
|
4
5
|
.filter(filter)
|
|
5
6
|
.map(transform)
|
|
@@ -8,9 +9,9 @@ export const getAssetsTotal = (assets, filter, transform) => Object.values(asset
|
|
|
8
9
|
export const calcLongLiqPrice = (assetPrice, borrowedUsd, borrowLimitUsd) => new Dec(assetPrice).mul(borrowedUsd).div(borrowLimitUsd).toString();
|
|
9
10
|
export const calcShortLiqPrice = (assetPrice, borrowedUsd, borrowLimitUsd) => new Dec(assetPrice).div(borrowedUsd).mul(borrowLimitUsd).toString();
|
|
10
11
|
export const calcLeverageLiqPrice = (leverageType, assetPrice, borrowedUsd, borrowLimitUsd) => {
|
|
11
|
-
if (leverageType ===
|
|
12
|
+
if (leverageType === LeverageType.Short || leverageType === LeverageType.VolatilePairReverse)
|
|
12
13
|
return calcShortLiqPrice(assetPrice, borrowedUsd, borrowLimitUsd);
|
|
13
|
-
if (leverageType ===
|
|
14
|
+
if (leverageType === LeverageType.Long || leverageType === LeverageType.VolatilePair)
|
|
14
15
|
return calcLongLiqPrice(assetPrice, borrowedUsd, borrowLimitUsd);
|
|
15
16
|
console.error('invalid leverageType', leverageType);
|
|
16
17
|
return '0';
|
|
@@ -47,28 +48,27 @@ export const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
|
47
48
|
});
|
|
48
49
|
const isLong = borrowStable > 0 && borrowUnstable === 0 && supplyUnstable === 1 && supplyStable === 0;
|
|
49
50
|
const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
|
|
50
|
-
|
|
51
|
-
const isLsdLeveraged = supplyUnstable === 1 && borrowUnstable === 1 && shortAsset === 'ETH' && ['stETH', 'wstETH', 'cbETH', 'rETH', 'ezETH', 'weETH'].includes(longAsset);
|
|
51
|
+
const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
|
|
52
52
|
if (isLong) {
|
|
53
53
|
return {
|
|
54
|
-
leveragedType:
|
|
54
|
+
leveragedType: LeverageType.Long,
|
|
55
55
|
leveragedAsset: longAsset,
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
if (isShort) {
|
|
59
59
|
return {
|
|
60
|
-
leveragedType:
|
|
60
|
+
leveragedType: LeverageType.Short,
|
|
61
61
|
leveragedAsset: shortAsset,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
64
|
+
if (isVolatilePair) {
|
|
65
65
|
return {
|
|
66
|
-
leveragedType:
|
|
66
|
+
leveragedType: LeverageType.VolatilePair,
|
|
67
67
|
leveragedAsset: longAsset,
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
return {
|
|
71
|
-
leveragedType:
|
|
71
|
+
leveragedType: LeverageType.None,
|
|
72
72
|
leveragedAsset: '',
|
|
73
73
|
};
|
|
74
74
|
};
|
|
@@ -14,23 +14,23 @@ import * as morphoVaultsOptions from './options';
|
|
|
14
14
|
import { getViemProvider } from '../../services/viem';
|
|
15
15
|
import { getMorphoVaultContractViem } from '../../contracts';
|
|
16
16
|
export { morphoVaultsOptions, };
|
|
17
|
-
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
18
|
-
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
19
|
-
id,
|
|
20
|
-
dailyApy,
|
|
21
|
-
dailyApys {
|
|
22
|
-
apy, netApy
|
|
23
|
-
},
|
|
24
|
-
monthlyApys {
|
|
25
|
-
apy, netApy
|
|
26
|
-
},
|
|
27
|
-
liquidity {
|
|
28
|
-
underlying, usd,
|
|
29
|
-
},
|
|
30
|
-
asset {
|
|
31
|
-
priceUsd
|
|
32
|
-
}
|
|
33
|
-
}
|
|
17
|
+
const vaultDataQuery = (vaultAddress) => `query vaultByAddress {
|
|
18
|
+
vaultByAddress(chainId: 1, address: "${vaultAddress}") {
|
|
19
|
+
id,
|
|
20
|
+
dailyApy,
|
|
21
|
+
dailyApys {
|
|
22
|
+
apy, netApy
|
|
23
|
+
},
|
|
24
|
+
monthlyApys {
|
|
25
|
+
apy, netApy
|
|
26
|
+
},
|
|
27
|
+
liquidity {
|
|
28
|
+
underlying, usd,
|
|
29
|
+
},
|
|
30
|
+
asset {
|
|
31
|
+
priceUsd
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
}`;
|
|
35
35
|
const MORPHO_BLUE_API = 'https://blue-api.morpho.org/graphql';
|
|
36
36
|
export const _getMorphoVaultData = (provider, network, morphoVault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
package/esm/types/aave.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IncentiveData, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
1
|
+
import { IncentiveData, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
2
|
export declare enum AaveVersions {
|
|
3
3
|
AaveV1 = "v1",
|
|
4
4
|
AaveV2 = "v2default",
|
|
@@ -161,14 +161,14 @@ export interface AaveV3AggregatedPositionData {
|
|
|
161
161
|
totalInterestUsd: string;
|
|
162
162
|
liqRatio: string;
|
|
163
163
|
liqPercent: string;
|
|
164
|
-
leveragedType:
|
|
164
|
+
leveragedType: LeverageType;
|
|
165
165
|
leveragedAsset?: string;
|
|
166
|
-
leveragedLsdAssetRatio?: string;
|
|
167
166
|
liquidationPrice?: string;
|
|
168
167
|
minCollRatio?: string;
|
|
169
168
|
collLiquidationRatio?: string;
|
|
170
169
|
healthRatio?: string;
|
|
171
170
|
minHealthRatio?: string;
|
|
171
|
+
currentVolatilePairRatio?: string;
|
|
172
172
|
}
|
|
173
173
|
export interface AaveHelperCommon {
|
|
174
174
|
usedAssets: any;
|
package/esm/types/common.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ export declare enum IncentiveEligibilityId {
|
|
|
8
8
|
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
|
|
9
9
|
AaveV3EthenaLiquidLeveragePlasma = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL"
|
|
10
10
|
}
|
|
11
|
+
export declare enum LeverageType {
|
|
12
|
+
Long = "long",
|
|
13
|
+
Short = "short",
|
|
14
|
+
VolatilePair = "volatile-pair",
|
|
15
|
+
VolatilePairReverse = "volatile-pair-reverse",
|
|
16
|
+
None = ""
|
|
17
|
+
}
|
|
11
18
|
export interface IncentiveData {
|
|
12
19
|
token: string;
|
|
13
20
|
apy: string;
|
package/esm/types/common.js
CHANGED
|
@@ -10,6 +10,14 @@ export var IncentiveEligibilityId;
|
|
|
10
10
|
IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
|
|
11
11
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL";
|
|
12
12
|
})(IncentiveEligibilityId || (IncentiveEligibilityId = {}));
|
|
13
|
+
export var LeverageType;
|
|
14
|
+
(function (LeverageType) {
|
|
15
|
+
LeverageType["Long"] = "long";
|
|
16
|
+
LeverageType["Short"] = "short";
|
|
17
|
+
LeverageType["VolatilePair"] = "volatile-pair";
|
|
18
|
+
LeverageType["VolatilePairReverse"] = "volatile-pair-reverse";
|
|
19
|
+
LeverageType["None"] = "";
|
|
20
|
+
})(LeverageType || (LeverageType = {}));
|
|
13
21
|
export var NetworkNumber;
|
|
14
22
|
(function (NetworkNumber) {
|
|
15
23
|
NetworkNumber[NetworkNumber["Eth"] = 1] = "Eth";
|
package/esm/types/compound.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
2
|
export declare enum CompoundVersions {
|
|
3
3
|
'CompoundV2' = "v2",
|
|
4
4
|
'CompoundV3USDC' = "v3-USDC",
|
|
@@ -94,9 +94,9 @@ export interface CompoundAggregatedPositionData {
|
|
|
94
94
|
totalInterestUsd: string;
|
|
95
95
|
liqRatio: string;
|
|
96
96
|
liqPercent: string;
|
|
97
|
-
leveragedType:
|
|
97
|
+
leveragedType: LeverageType;
|
|
98
98
|
leveragedAsset?: string;
|
|
99
|
-
|
|
99
|
+
currentVolatilePairRatio?: string;
|
|
100
100
|
liquidationPrice?: string;
|
|
101
101
|
minRatio: string;
|
|
102
102
|
debtTooLow: boolean;
|
package/esm/types/curveUsd.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, LeverageType, NetworkNumber } from './common';
|
|
2
2
|
export declare enum CrvUSDVersions {
|
|
3
3
|
'crvUSDwstETH' = "wstETH",
|
|
4
4
|
'crvUSDWBTC' = "WBTC",
|
|
@@ -71,7 +71,7 @@ export interface CrvUSDAggregatedPositionData {
|
|
|
71
71
|
borrowLimitUsd: string;
|
|
72
72
|
minAllowedRatio: number;
|
|
73
73
|
collFactor: string;
|
|
74
|
-
leveragedType:
|
|
74
|
+
leveragedType: LeverageType;
|
|
75
75
|
leveragedAsset?: string;
|
|
76
76
|
liquidationPrice?: string;
|
|
77
77
|
}
|
package/esm/types/euler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, IncentiveData, MMPositionData, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, MMPositionData, NetworkNumber } from './common';
|
|
2
2
|
export declare enum EulerV2Versions {
|
|
3
3
|
eUSDC2 = "eUSDC-2",
|
|
4
4
|
eWETH2 = "eWETH-2"
|
|
@@ -141,9 +141,9 @@ export interface EulerV2AggregatedPositionData {
|
|
|
141
141
|
totalInterestUsd: string;
|
|
142
142
|
liqRatio: string;
|
|
143
143
|
liqPercent: string;
|
|
144
|
-
leveragedType:
|
|
144
|
+
leveragedType: LeverageType;
|
|
145
145
|
leveragedAsset?: string;
|
|
146
|
-
|
|
146
|
+
currentVolatilePairRatio?: string;
|
|
147
147
|
liquidationPrice?: string;
|
|
148
148
|
minRatio: string;
|
|
149
149
|
minDebt: string;
|
package/esm/types/fluid.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, IncentiveData, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
|
|
2
2
|
export interface FluidMarketInfo {
|
|
3
3
|
chainIds: number[];
|
|
4
4
|
label: string;
|
|
@@ -323,10 +323,10 @@ export interface FluidAggregatedVaultData {
|
|
|
323
323
|
collRatio: string;
|
|
324
324
|
minRatio: string;
|
|
325
325
|
totalInterestUsd: string;
|
|
326
|
-
leveragedType?:
|
|
326
|
+
leveragedType?: LeverageType;
|
|
327
327
|
leveragedAsset?: string;
|
|
328
328
|
liquidationPrice?: string;
|
|
329
|
-
|
|
329
|
+
currentVolatilePairRatio?: string;
|
|
330
330
|
minCollRatio?: string;
|
|
331
331
|
collLiquidationRatio?: string;
|
|
332
332
|
}
|
package/esm/types/fluid.js
CHANGED
package/esm/types/index.d.ts
CHANGED
package/esm/types/index.js
CHANGED
package/esm/types/liquityV2.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, IncentiveData, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
|
|
2
2
|
export declare enum LiquityV2Versions {
|
|
3
3
|
LiquityV2Eth = "liquityv2eth",
|
|
4
4
|
LiquityV2WstEth = "liquityv2wsteth",
|
|
@@ -88,7 +88,7 @@ export interface LiquityV2AggregatedTroveData {
|
|
|
88
88
|
netApy: string;
|
|
89
89
|
incentiveUsd: string;
|
|
90
90
|
totalInterestUsd: string;
|
|
91
|
-
leveragedType:
|
|
91
|
+
leveragedType: LeverageType;
|
|
92
92
|
leveragedAsset: string;
|
|
93
93
|
liquidationPrice: string;
|
|
94
94
|
ratio: string;
|
|
@@ -110,7 +110,7 @@ export interface LiquityV2TroveData {
|
|
|
110
110
|
totalInterestUsd: string;
|
|
111
111
|
interestBatchManager: EthAddress;
|
|
112
112
|
troveStatus: string;
|
|
113
|
-
leveragedType:
|
|
113
|
+
leveragedType: LeverageType;
|
|
114
114
|
leveragedAsset: string;
|
|
115
115
|
liquidationPrice: string;
|
|
116
116
|
debtInFront: string;
|
package/esm/types/llamaLend.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, IncentiveData, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, NetworkNumber } from './common';
|
|
2
2
|
import { BandData, UserBandData } from './curveUsd';
|
|
3
3
|
export declare enum LLVersionsEth {
|
|
4
4
|
LLWstethCrvusd = "llamaLendwstETHcrvUSD",
|
|
@@ -112,7 +112,7 @@ export interface LlamaLendAggregatedPositionData {
|
|
|
112
112
|
borrowLimitUsd: string;
|
|
113
113
|
minAllowedRatio: number;
|
|
114
114
|
collFactor: string;
|
|
115
|
-
leveragedType:
|
|
115
|
+
leveragedType: LeverageType;
|
|
116
116
|
leveragedAsset?: string;
|
|
117
117
|
liquidationPrice?: string;
|
|
118
118
|
netApy: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EthAddress, IncentiveData, MMUsedAssets, NetworkNumber } from './common';
|
|
1
|
+
import { EthAddress, IncentiveData, LeverageType, MMUsedAssets, NetworkNumber } from './common';
|
|
2
2
|
export declare enum MorphoBlueVersions {
|
|
3
3
|
MorphoBlueWstEthUSDC = "morphobluewstethusdc",// wstETH/USDC
|
|
4
4
|
MorphoBlueSDAIUSDC = "morphobluesdaiusdc",// sDAI/USDC
|
|
@@ -121,9 +121,9 @@ export interface MorphoBlueAggregatedPositionData {
|
|
|
121
121
|
totalInterestUsd: string;
|
|
122
122
|
ltv: string;
|
|
123
123
|
ratio: string;
|
|
124
|
-
leveragedType:
|
|
124
|
+
leveragedType: LeverageType;
|
|
125
125
|
leveragedAsset?: string;
|
|
126
|
-
|
|
126
|
+
currentVolatilePairRatio?: string;
|
|
127
127
|
liquidationPrice?: string;
|
|
128
128
|
minCollRatio?: string;
|
|
129
129
|
collLiquidationRatio?: string;
|
|
@@ -142,9 +142,9 @@ export interface MorphoBluePositionData {
|
|
|
142
142
|
totalInterestUsd: string;
|
|
143
143
|
ltv: string;
|
|
144
144
|
ratio: string;
|
|
145
|
-
leveragedType:
|
|
145
|
+
leveragedType: LeverageType;
|
|
146
146
|
leveragedAsset?: string;
|
|
147
|
-
|
|
147
|
+
currentVolatilePairRatio?: string;
|
|
148
148
|
liquidationPrice?: string;
|
|
149
149
|
supplyShares: string;
|
|
150
150
|
borrowShares: string;
|
package/esm/types/spark.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EModeCategoriesData } from './aave';
|
|
2
|
-
import { EthAddress, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
|
+
import { EthAddress, LeverageType, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
3
3
|
export declare enum SparkVersions {
|
|
4
4
|
SparkV1 = "v1default"
|
|
5
5
|
}
|
|
@@ -90,9 +90,9 @@ export interface SparkAggregatedPositionData {
|
|
|
90
90
|
totalInterestUsd: string;
|
|
91
91
|
liqRatio: string;
|
|
92
92
|
liqPercent: string;
|
|
93
|
-
leveragedType:
|
|
93
|
+
leveragedType: LeverageType;
|
|
94
94
|
leveragedAsset?: string;
|
|
95
|
-
|
|
95
|
+
currentVolatilePairRatio?: string;
|
|
96
96
|
liquidationPrice?: string;
|
|
97
97
|
minCollRatio: string;
|
|
98
98
|
collLiquidationRatio: string;
|