@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
package/.mocharc.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"require": "ts-node/register",
|
|
3
|
-
"extension": ["ts"]
|
|
4
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"require": "ts-node/register",
|
|
3
|
+
"extension": ["ts"]
|
|
4
|
+
}
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
v20.17.0
|
|
1
|
+
v20.17.0
|
package/README.md
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
# DeFi Saver Positions SDK
|
|
2
|
-
|
|
3
|
-
Supported protocols:
|
|
4
|
-
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
-
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
-
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
-
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
-
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
-
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
10
|
-
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
11
|
-
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
12
|
-
|
|
13
|
-
## Setup
|
|
14
|
-
Supported Node version is v10.
|
|
15
|
-
|
|
16
|
-
- run `npm install` (first time)
|
|
17
|
-
- run `npm run build`
|
|
18
|
-
|
|
19
|
-
`build` command will generate contracts and build ejs and esm folders
|
|
20
|
-
|
|
21
|
-
## How to use
|
|
22
|
-
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
23
|
-
|
|
24
|
-
This is a Compound V3 example, and every other protocol is similar
|
|
25
|
-
```js
|
|
26
|
-
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// every protocol has market data and user data getters
|
|
30
|
-
const {
|
|
31
|
-
getCompoundV3MarketsData,
|
|
32
|
-
getCompoundV3AccountData,
|
|
33
|
-
} = compoundV3;
|
|
34
|
-
|
|
35
|
-
const provider = 'Your RPC provider';
|
|
36
|
-
|
|
37
|
-
const user = '0x123...';
|
|
38
|
-
|
|
39
|
-
const { assetsData } = await getCompoundV3MarketsData(
|
|
40
|
-
provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
41
|
-
1, // network
|
|
42
|
-
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
43
|
-
provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const userData = await getCompoundV3AccountData(
|
|
47
|
-
provider,
|
|
48
|
-
1, // network
|
|
49
|
-
userAddress, // EOA or DSProxy
|
|
50
|
-
'', // proxy address of the user, or just empty string if checking for EOA
|
|
51
|
-
{
|
|
52
|
-
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
53
|
-
assetsData,
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
59
|
-
|
|
60
|
-
## Testing
|
|
61
|
-
|
|
62
|
-
`npm run test` - Run all tests
|
|
63
|
-
|
|
64
|
-
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
|
1
|
+
# DeFi Saver Positions SDK
|
|
2
|
+
|
|
3
|
+
Supported protocols:
|
|
4
|
+
- [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
|
|
5
|
+
- [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
|
|
6
|
+
- [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
|
|
7
|
+
- [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
|
|
8
|
+
- [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
|
|
9
|
+
- [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
|
|
10
|
+
- [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
|
|
11
|
+
- [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
Supported Node version is v10.
|
|
15
|
+
|
|
16
|
+
- run `npm install` (first time)
|
|
17
|
+
- run `npm run build`
|
|
18
|
+
|
|
19
|
+
`build` command will generate contracts and build ejs and esm folders
|
|
20
|
+
|
|
21
|
+
## How to use
|
|
22
|
+
[All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
|
|
23
|
+
|
|
24
|
+
This is a Compound V3 example, and every other protocol is similar
|
|
25
|
+
```js
|
|
26
|
+
import { compoundV3 } from '@defisaver/positions-sdk';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// every protocol has market data and user data getters
|
|
30
|
+
const {
|
|
31
|
+
getCompoundV3MarketsData,
|
|
32
|
+
getCompoundV3AccountData,
|
|
33
|
+
} = compoundV3;
|
|
34
|
+
|
|
35
|
+
const provider = 'Your RPC provider';
|
|
36
|
+
|
|
37
|
+
const user = '0x123...';
|
|
38
|
+
|
|
39
|
+
const { assetsData } = await getCompoundV3MarketsData(
|
|
40
|
+
provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
|
|
41
|
+
1, // network
|
|
42
|
+
selectedMarket, // market object like in /src/markets/compound/index.ts
|
|
43
|
+
provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const userData = await getCompoundV3AccountData(
|
|
47
|
+
provider,
|
|
48
|
+
1, // network
|
|
49
|
+
userAddress, // EOA or DSProxy
|
|
50
|
+
'', // proxy address of the user, or just empty string if checking for EOA
|
|
51
|
+
{
|
|
52
|
+
selectedMarket, // market object as in /src/markets/compound/index.ts
|
|
53
|
+
assetsData,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
|
|
59
|
+
|
|
60
|
+
## Testing
|
|
61
|
+
|
|
62
|
+
`npm run test` - Run all tests
|
|
63
|
+
|
|
64
|
+
`npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
|
package/cjs/fluid/index.d.ts
CHANGED
|
@@ -130,10 +130,10 @@ export declare const _getUserPositions: (provider: PublicClient, network: Networ
|
|
|
130
130
|
collRatio: string;
|
|
131
131
|
minRatio: string;
|
|
132
132
|
totalInterestUsd: string;
|
|
133
|
-
leveragedType?:
|
|
133
|
+
leveragedType?: import("../types").LeverageType;
|
|
134
134
|
leveragedAsset?: string;
|
|
135
135
|
liquidationPrice?: string;
|
|
136
|
-
|
|
136
|
+
currentVolatilePairRatio?: string;
|
|
137
137
|
minCollRatio?: string;
|
|
138
138
|
collLiquidationRatio?: string;
|
|
139
139
|
owner: string;
|
|
@@ -161,10 +161,10 @@ export declare const getUserPositions: (provider: EthereumProvider, network: Net
|
|
|
161
161
|
collRatio: string;
|
|
162
162
|
minRatio: string;
|
|
163
163
|
totalInterestUsd: string;
|
|
164
|
-
leveragedType?:
|
|
164
|
+
leveragedType?: import("../types").LeverageType;
|
|
165
165
|
leveragedAsset?: string;
|
|
166
166
|
liquidationPrice?: string;
|
|
167
|
-
|
|
167
|
+
currentVolatilePairRatio?: string;
|
|
168
168
|
minCollRatio?: string;
|
|
169
169
|
collLiquidationRatio?: string;
|
|
170
170
|
owner: string;
|
|
@@ -192,10 +192,10 @@ export declare const _getUserPositionsPortfolio: (provider: PublicClient, networ
|
|
|
192
192
|
collRatio: string;
|
|
193
193
|
minRatio: string;
|
|
194
194
|
totalInterestUsd: string;
|
|
195
|
-
leveragedType?:
|
|
195
|
+
leveragedType?: import("../types").LeverageType;
|
|
196
196
|
leveragedAsset?: string;
|
|
197
197
|
liquidationPrice?: string;
|
|
198
|
-
|
|
198
|
+
currentVolatilePairRatio?: string;
|
|
199
199
|
minCollRatio?: string;
|
|
200
200
|
collLiquidationRatio?: string;
|
|
201
201
|
owner: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AaveHelperCommon, AaveMarketInfo, AaveV3AggregatedPositionData, AaveV3AssetsData, AaveV3UsedAssets, AaveVersions } from '../../types';
|
|
1
|
+
import { AaveHelperCommon, AaveMarketInfo, AaveV3AggregatedPositionData, AaveV3AssetsData, AaveV3UsedAsset, AaveV3UsedAssets, AaveVersions } from '../../types';
|
|
2
2
|
import { EthereumProvider, NetworkNumber } from '../../types/common';
|
|
3
3
|
export declare const AAVE_V3_MARKETS: AaveVersions[];
|
|
4
4
|
export declare const isAaveV2: ({ selectedMarket }: {
|
|
@@ -17,7 +17,7 @@ export declare const aaveV3IsInSiloedMode: ({ usedAssets, assetsData }: {
|
|
|
17
17
|
}) => boolean;
|
|
18
18
|
export declare const aaveAnyGetCollSuppliedAssets: ({ usedAssets }: {
|
|
19
19
|
usedAssets: AaveV3UsedAssets;
|
|
20
|
-
}) =>
|
|
20
|
+
}) => AaveV3UsedAsset[];
|
|
21
21
|
export declare const aaveAnyGetSuppliableAssets: ({ usedAssets, eModeCategory, assetsData, selectedMarket, network, ...rest }: AaveHelperCommon) => {
|
|
22
22
|
symbol: string;
|
|
23
23
|
canBeCollateral: boolean;
|
|
@@ -31,6 +31,7 @@ const utils_1 = require("../../services/utils");
|
|
|
31
31
|
const moneymarket_1 = require("../../moneymarket");
|
|
32
32
|
const staking_1 = require("../../staking");
|
|
33
33
|
const constants_1 = require("../../constants");
|
|
34
|
+
const common_1 = require("../../types/common");
|
|
34
35
|
const contracts_1 = require("../../contracts");
|
|
35
36
|
const viem_1 = require("../../services/viem");
|
|
36
37
|
exports.AAVE_V3_MARKETS = [types_1.AaveVersions.AaveV3, types_1.AaveVersions.AaveV3Lido, types_1.AaveVersions.AaveV3Etherfi];
|
|
@@ -103,12 +104,22 @@ const aaveAnyGetAggregatedPositionData = (_a) => {
|
|
|
103
104
|
payload.liquidationPrice = '';
|
|
104
105
|
if (leveragedType !== '') {
|
|
105
106
|
let assetPrice = data.assetsData[leveragedAsset].price;
|
|
106
|
-
if (leveragedType ===
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
108
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
109
|
+
const borrowedAssetPrice = data.assetsData[borrowedAsset.symbol].price;
|
|
110
|
+
const leveragedAssetPrice = data.assetsData[leveragedAsset].price;
|
|
111
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
112
|
+
if (isReverse) {
|
|
113
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
114
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
115
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
119
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
120
|
+
}
|
|
110
121
|
}
|
|
111
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
122
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
112
123
|
}
|
|
113
124
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
114
125
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -150,28 +150,25 @@ const getCompoundV3AggregatedData = (_a) => {
|
|
|
150
150
|
if (leveragedType !== '') {
|
|
151
151
|
payload.leveragedAsset = leveragedAsset;
|
|
152
152
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
153
|
-
if (leveragedType ===
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
154
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
155
|
+
const borrowedAssetPrice = assetsData[borrowedAsset.symbol].price;
|
|
156
|
+
const leveragedAssetPrice = assetsData[leveragedAsset].price;
|
|
157
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
158
|
+
if (isReverse) {
|
|
159
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
160
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
161
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
165
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
166
|
+
}
|
|
156
167
|
}
|
|
157
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
168
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
158
169
|
}
|
|
159
170
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
160
171
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
161
|
-
// TO DO: handle strategies
|
|
162
|
-
/* const subscribedStrategies = rest.compoundStrategies
|
|
163
|
-
? compoundV3GetSubscribedStrategies({ selectedMarket, compoundStrategies: rest.compoundStrategies })
|
|
164
|
-
: []; */
|
|
165
|
-
// TODO possibly move to global helper, since every protocol has the same graphData?
|
|
166
|
-
// payload.ratioTooLow = false;
|
|
167
|
-
// payload.ratioTooHigh = false;
|
|
168
|
-
// TO DO: handle strategies
|
|
169
|
-
/* if (subscribedStrategies.length) {
|
|
170
|
-
subscribedStrategies.forEach(({ graphData }) => {
|
|
171
|
-
payload.ratioTooLow = parseFloat(payload.ratio) < parseFloat(graphData.minRatio);
|
|
172
|
-
payload.ratioTooHigh = graphData.boostEnabled && parseFloat(payload.ratio) > parseFloat(graphData.maxRatio);
|
|
173
|
-
});
|
|
174
|
-
} */
|
|
175
172
|
return payload;
|
|
176
173
|
};
|
|
177
174
|
exports.getCompoundV3AggregatedData = getCompoundV3AggregatedData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
|
|
1
|
+
import { EthAddress, EthereumProvider, LeverageType, NetworkNumber } from '../../types/common';
|
|
2
2
|
import { EulerV2AggregatedPositionData, EulerV2AssetsData, EulerV2UsedAssets } from '../../types';
|
|
3
3
|
export declare const isLeveragedPos: (usedAssets: EulerV2UsedAssets, dustLimit?: number) => {
|
|
4
|
-
leveragedType:
|
|
4
|
+
leveragedType: LeverageType;
|
|
5
5
|
leveragedAsset: string;
|
|
6
6
|
leveragedVault: string;
|
|
7
7
|
};
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.getEulerV2SubAccounts = exports.getApyAfterValuesEstimationEulerV2 = exports.getEulerV2SupplyRate = exports.getUtilizationRate = exports.getEulerV2BorrowRate = exports.getEulerV2AggregatedData = exports.isLeveragedPos = void 0;
|
|
27
27
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
28
28
|
const tokens_1 = require("@defisaver/tokens");
|
|
29
|
+
const common_1 = require("../../types/common");
|
|
29
30
|
const moneymarket_1 = require("../../moneymarket");
|
|
30
31
|
const staking_1 = require("../../staking");
|
|
31
32
|
const contracts_1 = require("../../contracts");
|
|
@@ -59,31 +60,30 @@ const isLeveragedPos = (usedAssets, dustLimit = 5) => {
|
|
|
59
60
|
});
|
|
60
61
|
const isLong = borrowStable > 0 && borrowUnstable === 0 && supplyUnstable === 1 && supplyStable === 0;
|
|
61
62
|
const isShort = supplyStable > 0 && supplyUnstable === 0 && borrowUnstable === 1 && borrowStable === 0;
|
|
62
|
-
|
|
63
|
-
const isLsdLeveraged = supplyUnstable === 1 && borrowUnstable === 1 && shortAsset === 'ETH' && ['stETH', 'wstETH', 'cbETH', 'rETH'].includes(longAsset);
|
|
63
|
+
const isVolatilePair = supplyUnstable === 1 && borrowUnstable === 1 && supplyStable === 0 && borrowStable === 0;
|
|
64
64
|
if (isLong) {
|
|
65
65
|
return {
|
|
66
|
-
leveragedType:
|
|
66
|
+
leveragedType: common_1.LeverageType.Long,
|
|
67
67
|
leveragedAsset: longAsset,
|
|
68
68
|
leveragedVault: leverageAssetVault,
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
if (isShort) {
|
|
72
72
|
return {
|
|
73
|
-
leveragedType:
|
|
73
|
+
leveragedType: common_1.LeverageType.Short,
|
|
74
74
|
leveragedAsset: shortAsset,
|
|
75
75
|
leveragedVault: leverageAssetVault,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
if (
|
|
78
|
+
if (isVolatilePair) {
|
|
79
79
|
return {
|
|
80
|
-
leveragedType:
|
|
80
|
+
leveragedType: common_1.LeverageType.VolatilePair,
|
|
81
81
|
leveragedAsset: longAsset,
|
|
82
82
|
leveragedVault: leverageAssetVault,
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
return {
|
|
86
|
-
leveragedType:
|
|
86
|
+
leveragedType: common_1.LeverageType.None,
|
|
87
87
|
leveragedAsset: '',
|
|
88
88
|
leveragedVault: '',
|
|
89
89
|
};
|
|
@@ -113,14 +113,22 @@ const getEulerV2AggregatedData = (_a) => {
|
|
|
113
113
|
if (leveragedType !== '') {
|
|
114
114
|
payload.leveragedAsset = leveragedAsset;
|
|
115
115
|
let assetPrice = assetsData[leveragedVault.toLowerCase()].price;
|
|
116
|
-
if (leveragedType ===
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
117
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
118
|
+
const borrowedAssetPrice = assetsData[borrowedAsset.vaultAddress.toLowerCase()].price;
|
|
119
|
+
const leveragedAssetPrice = assetsData[leveragedVault.toLowerCase()].price;
|
|
120
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
121
|
+
if (isReverse) {
|
|
122
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
123
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
124
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
128
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
131
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
124
132
|
}
|
|
125
133
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
126
134
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -9,6 +9,7 @@ const tokens_1 = require("@defisaver/tokens");
|
|
|
9
9
|
const types_1 = require("../../types");
|
|
10
10
|
const moneymarket_1 = require("../../moneymarket");
|
|
11
11
|
const staking_1 = require("../../staking");
|
|
12
|
+
const common_1 = require("../../types/common");
|
|
12
13
|
const utils_1 = require("../../services/utils");
|
|
13
14
|
const calculateNetApyDex = ({ marketData, suppliedUsd, borrowedUsd }) => {
|
|
14
15
|
const { borrowRate, supplyRate, incentiveBorrowRate, incentiveSupplyRate, tradingBorrowRate, tradingSupplyRate, } = marketData;
|
|
@@ -55,12 +56,22 @@ const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }, supplyS
|
|
|
55
56
|
if (leveragedType !== '') {
|
|
56
57
|
payload.leveragedAsset = leveragedAsset;
|
|
57
58
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
58
|
-
if (leveragedType ===
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
60
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
61
|
+
const borrowedAssetPrice = assetsData[borrowedAsset.symbol].price;
|
|
62
|
+
const leveragedAssetPrice = assetsData[leveragedAsset].price;
|
|
63
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
64
|
+
if (isReverse) {
|
|
65
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
66
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
67
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
71
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
72
|
+
}
|
|
62
73
|
}
|
|
63
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
74
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
64
75
|
}
|
|
65
76
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
66
77
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -51,12 +51,22 @@ const getMorphoBlueAggregatedPositionData = ({ usedAssets, assetsData, marketInf
|
|
|
51
51
|
if (leveragedType !== '') {
|
|
52
52
|
payload.leveragedAsset = leveragedAsset;
|
|
53
53
|
let assetPrice = assetsData[leveragedAsset].price;
|
|
54
|
-
if (leveragedType ===
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
55
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
56
|
+
const borrowedAssetPrice = assetsData[borrowedAsset.symbol].price;
|
|
57
|
+
const leveragedAssetPrice = assetsData[leveragedAsset].price;
|
|
58
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
59
|
+
if (isReverse) {
|
|
60
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
61
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
62
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
66
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
69
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
60
70
|
}
|
|
61
71
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
62
72
|
payload.collLiquidationRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.liquidationLimitUsd).mul(100).toString();
|
|
@@ -128,73 +138,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, provider, network)
|
|
|
128
138
|
});
|
|
129
139
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
130
140
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
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
|
-
}
|
|
141
|
+
const MARKET_QUERY = `
|
|
142
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
143
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
144
|
+
reallocatableLiquidityAssets
|
|
145
|
+
targetBorrowUtilization
|
|
146
|
+
loanAsset {
|
|
147
|
+
address
|
|
148
|
+
decimals
|
|
149
|
+
priceUsd
|
|
150
|
+
}
|
|
151
|
+
state {
|
|
152
|
+
liquidityAssets
|
|
153
|
+
borrowAssets
|
|
154
|
+
supplyAssets
|
|
155
|
+
}
|
|
156
|
+
publicAllocatorSharedLiquidity {
|
|
157
|
+
assets
|
|
158
|
+
vault {
|
|
159
|
+
address
|
|
160
|
+
name
|
|
161
|
+
}
|
|
162
|
+
allocationMarket {
|
|
163
|
+
uniqueKey
|
|
164
|
+
loanAsset {
|
|
165
|
+
address
|
|
166
|
+
}
|
|
167
|
+
collateralAsset {
|
|
168
|
+
address
|
|
169
|
+
}
|
|
170
|
+
irmAddress
|
|
171
|
+
oracle {
|
|
172
|
+
address
|
|
173
|
+
}
|
|
174
|
+
lltv
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
loanAsset {
|
|
178
|
+
address
|
|
179
|
+
}
|
|
180
|
+
collateralAsset {
|
|
181
|
+
address
|
|
182
|
+
}
|
|
183
|
+
oracle {
|
|
184
|
+
address
|
|
185
|
+
}
|
|
186
|
+
irmAddress
|
|
187
|
+
lltv
|
|
188
|
+
}
|
|
189
|
+
}
|
|
180
190
|
`;
|
|
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
|
-
}
|
|
191
|
+
const REWARDS_QUERY = `
|
|
192
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
193
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
194
|
+
uniqueKey
|
|
195
|
+
state {
|
|
196
|
+
rewards {
|
|
197
|
+
amountPerSuppliedToken
|
|
198
|
+
supplyApr
|
|
199
|
+
amountPerBorrowedToken
|
|
200
|
+
borrowApr
|
|
201
|
+
asset {
|
|
202
|
+
address
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
198
208
|
`;
|
|
199
209
|
/**
|
|
200
210
|
* 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;
|
|
@@ -92,12 +92,22 @@ const sparkGetAggregatedPositionData = (_a) => {
|
|
|
92
92
|
if (leveragedType !== '') {
|
|
93
93
|
payload.leveragedAsset = leveragedAsset;
|
|
94
94
|
let assetPrice = data.assetsData[leveragedAsset].price; // TODO sparkPrice or price??
|
|
95
|
-
if (leveragedType ===
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
if (leveragedType === common_1.LeverageType.VolatilePair) {
|
|
96
|
+
const borrowedAsset = Object.values(usedAssets).find(({ borrowedUsd }) => +borrowedUsd > 0);
|
|
97
|
+
const borrowedAssetPrice = data.assetsData[borrowedAsset.symbol].price;
|
|
98
|
+
const leveragedAssetPrice = data.assetsData[leveragedAsset].price;
|
|
99
|
+
const isReverse = new decimal_js_1.default(leveragedAssetPrice).lt(borrowedAssetPrice);
|
|
100
|
+
if (isReverse) {
|
|
101
|
+
payload.leveragedType = common_1.LeverageType.VolatilePairReverse;
|
|
102
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(borrowedAssetPrice).div(leveragedAssetPrice).toDP(18).toString();
|
|
103
|
+
assetPrice = new decimal_js_1.default(borrowedAssetPrice).div(assetPrice).toString();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
assetPrice = new decimal_js_1.default(assetPrice).div(borrowedAssetPrice).toString();
|
|
107
|
+
payload.currentVolatilePairRatio = new decimal_js_1.default(leveragedAssetPrice).div(borrowedAssetPrice).toDP(18).toString();
|
|
108
|
+
}
|
|
99
109
|
}
|
|
100
|
-
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
110
|
+
payload.liquidationPrice = (0, moneymarket_1.calcLeverageLiqPrice)(payload.leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
|
|
101
111
|
}
|
|
102
112
|
payload.minCollRatio = new decimal_js_1.default(payload.suppliedCollateralUsd).div(payload.borrowLimitUsd).mul(100).toString();
|
|
103
113
|
payload.collLiquidationRatio = new decimal_js_1.default(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;
|