@sonarwatch/portfolio-core 0.11.11 → 0.11.12
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.11.12](https://github.com/sonarwatch/portfolio/compare/core-0.11.11...core-0.11.12) (2023-12-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [0.11.11](https://github.com/sonarwatch/portfolio/compare/core-0.11.10...core-0.11.11) (2023-12-15)
|
|
6
10
|
|
|
7
11
|
|
package/package.json
CHANGED
package/src/Portfolio.d.ts
CHANGED
|
@@ -217,12 +217,13 @@ export type PortfolioElementBorrowLendData = {
|
|
|
217
217
|
*/
|
|
218
218
|
borrowedYields: Yield[][];
|
|
219
219
|
/**
|
|
220
|
+
* @deprecated
|
|
220
221
|
* The collateral ratio of the portfolio element.
|
|
221
222
|
* -1 means infinity/no borrow.
|
|
222
223
|
* null means unknown.
|
|
223
224
|
* 1.5 means 150%.
|
|
224
225
|
*/
|
|
225
|
-
collateralRatio:
|
|
226
|
+
collateralRatio: null;
|
|
226
227
|
/**
|
|
227
228
|
* The health ratio of the portfolio element.
|
|
228
229
|
* 1 means 100% / full health / no borrow.
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getElementLendingValues = void 0;
|
|
4
|
-
function getCollateralRatio(suppliedValue, borrowedValue) {
|
|
5
|
-
let collateralRatio = null;
|
|
6
|
-
if (borrowedValue === 0) {
|
|
7
|
-
collateralRatio = -1;
|
|
8
|
-
}
|
|
9
|
-
else if (suppliedValue && borrowedValue) {
|
|
10
|
-
collateralRatio = suppliedValue / borrowedValue;
|
|
11
|
-
}
|
|
12
|
-
return collateralRatio;
|
|
13
|
-
}
|
|
14
4
|
function getHealthRatio(suppliedAssets, borrowedAssets, suppliedLtvs, borrowedWeights) {
|
|
15
5
|
if (!suppliedLtvs)
|
|
16
6
|
return null;
|
|
@@ -31,7 +21,6 @@ function getElementLendingValues(suppliedAssets, borrowedAssets, rewardAssets, s
|
|
|
31
21
|
const rewardsValue = rewardAssets.reduce((acc, asset) => acc !== null && asset.value !== null ? acc + asset.value : null, 0);
|
|
32
22
|
const suppliedValue = suppliedAssets.reduce((acc, asset) => acc !== null && asset.value !== null ? acc + asset.value : null, 0);
|
|
33
23
|
const borrowedValue = borrowedAssets.reduce((acc, asset) => acc !== null && asset.value !== null ? acc + asset.value : null, 0);
|
|
34
|
-
const collateralRatio = getCollateralRatio(suppliedValue, borrowedValue);
|
|
35
24
|
const healthRatio = getHealthRatio(suppliedAssets, borrowedAssets, suppliedLtvs, borrowedWeights);
|
|
36
25
|
// Total value
|
|
37
26
|
let value = suppliedValue !== null && borrowedValue !== null
|
|
@@ -43,7 +32,6 @@ function getElementLendingValues(suppliedAssets, borrowedAssets, rewardAssets, s
|
|
|
43
32
|
borrowedValue,
|
|
44
33
|
suppliedValue,
|
|
45
34
|
rewardsValue,
|
|
46
|
-
collateralRatio,
|
|
47
35
|
healthRatio,
|
|
48
36
|
value,
|
|
49
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getElementLendingValues.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/getElementLendingValues.ts"],"names":[],"mappings":";;;AAGA,SAAS,
|
|
1
|
+
{"version":3,"file":"getElementLendingValues.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/getElementLendingValues.ts"],"names":[],"mappings":";;;AAGA,SAAS,cAAc,CACrB,cAAgC,EAChC,cAAgC,EAChC,YAAuB,EACvB,eAA0B;IAE1B,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAC/B,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK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