@sonarwatch/portfolio-core 0.11.24 → 0.11.25
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 +4 -0
- package/package.json +1 -1
- package/src/utils/healthRatioToHealthFactor.d.ts +8 -0
- package/src/utils/healthRatioToHealthFactor.js +10 -0
- package/src/utils/healthRatioToHealthFactor.js.map +1 -1
- package/src/utils/sortPortfolioElement.d.ts +2 -1
- package/src/utils/sortPortfolioElement.js +9 -1
- package/src/utils/sortPortfolioElement.js.map +1 -1
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.25](https://github.com/sonarwatch/portfolio/compare/core-0.11.24...core-0.11.25) (2023-12-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [0.11.24](https://github.com/sonarwatch/portfolio/compare/core-0.11.23...core-0.11.24) (2023-12-20)
|
|
6
10
|
|
|
7
11
|
|
package/package.json
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a health ratio to a health factor.
|
|
3
|
+
*
|
|
4
|
+
* @param healthRatio The health ratio to convert.
|
|
5
|
+
* @returns The corresponding health factor.
|
|
6
|
+
* If the health ratio is null, returns null. Meaning health factor is unknown.
|
|
7
|
+
* If the health ratio is 1, returns -1. Meaning health factor is infinity.
|
|
8
|
+
*/
|
|
1
9
|
export declare function healthRatioToHealthFactor(healthRatio: number | null): number | null;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.healthRatioToHealthFactor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Converts a health ratio to a health factor.
|
|
6
|
+
*
|
|
7
|
+
* @param healthRatio The health ratio to convert.
|
|
8
|
+
* @returns The corresponding health factor.
|
|
9
|
+
* If the health ratio is null, returns null. Meaning health factor is unknown.
|
|
10
|
+
* If the health ratio is 1, returns -1. Meaning health factor is infinity.
|
|
11
|
+
*/
|
|
4
12
|
function healthRatioToHealthFactor(healthRatio) {
|
|
5
13
|
if (healthRatio === null)
|
|
6
14
|
return null;
|
|
15
|
+
if (healthRatio === 1)
|
|
16
|
+
return -1;
|
|
7
17
|
return 1 / (1 - healthRatio);
|
|
8
18
|
}
|
|
9
19
|
exports.healthRatioToHealthFactor = healthRatioToHealthFactor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"healthRatioToHealthFactor.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/healthRatioToHealthFactor.ts"],"names":[],"mappings":";;;AAAA,SAAgB,yBAAyB,CACvC,WAA0B;IAE1B,IAAI,WAAW,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC;AAC/B,CAAC;
|
|
1
|
+
{"version":3,"file":"healthRatioToHealthFactor.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/healthRatioToHealthFactor.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACvC,WAA0B;IAE1B,IAAI,WAAW,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtC,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC;AAC/B,CAAC;AAND,8DAMC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PortfolioElement, PortfolioElementBorrowLend, PortfolioElementLiquidity, PortfolioElementMultiple } from '../Portfolio';
|
|
1
|
+
import { PortfolioElement, PortfolioElementBorrowLend, PortfolioElementLiquidity, PortfolioElementMultiple, PortfolioLiquidity } from '../Portfolio';
|
|
2
2
|
export declare function sortPortfolioElement(element: PortfolioElement): PortfolioElement;
|
|
3
3
|
export declare function sortElementMultiple(element: PortfolioElementMultiple): PortfolioElementMultiple;
|
|
4
4
|
export declare function sortElementBorrowLend(element: PortfolioElementBorrowLend): PortfolioElementBorrowLend;
|
|
5
5
|
export declare function sortElementLiquidity(element: PortfolioElementLiquidity): PortfolioElementLiquidity;
|
|
6
|
+
export declare function sortPortfolioLiquidity(portfolioLiquidity: PortfolioLiquidity): PortfolioLiquidity;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sortElementLiquidity = exports.sortElementBorrowLend = exports.sortElementMultiple = exports.sortPortfolioElement = void 0;
|
|
3
|
+
exports.sortPortfolioLiquidity = exports.sortElementLiquidity = exports.sortElementBorrowLend = exports.sortElementMultiple = exports.sortPortfolioElement = void 0;
|
|
4
4
|
const compareUsdValue_1 = require("./compareUsdValue");
|
|
5
5
|
const Portfolio_1 = require("../Portfolio");
|
|
6
6
|
const sortAssets_1 = require("./sortAssets");
|
|
@@ -33,8 +33,16 @@ function sortElementBorrowLend(element) {
|
|
|
33
33
|
exports.sortElementBorrowLend = sortElementBorrowLend;
|
|
34
34
|
function sortElementLiquidity(element) {
|
|
35
35
|
const sortedElement = element;
|
|
36
|
+
sortedElement.data.liquidities = sortedElement.data.liquidities.map((l) => sortPortfolioLiquidity(l));
|
|
36
37
|
sortedElement.data.liquidities.sort((a, b) => (0, compareUsdValue_1.compareUsdValue)(a.value, b.value));
|
|
37
38
|
return sortedElement;
|
|
38
39
|
}
|
|
39
40
|
exports.sortElementLiquidity = sortElementLiquidity;
|
|
41
|
+
function sortPortfolioLiquidity(portfolioLiquidity) {
|
|
42
|
+
const sortedPortfolioLiquidity = portfolioLiquidity;
|
|
43
|
+
sortedPortfolioLiquidity.assets = (0, sortAssets_1.sortAssets)(sortedPortfolioLiquidity.assets);
|
|
44
|
+
sortedPortfolioLiquidity.rewardAssets = (0, sortAssets_1.sortAssets)(sortedPortfolioLiquidity.rewardAssets);
|
|
45
|
+
return sortedPortfolioLiquidity;
|
|
46
|
+
}
|
|
47
|
+
exports.sortPortfolioLiquidity = sortPortfolioLiquidity;
|
|
40
48
|
//# sourceMappingURL=sortPortfolioElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortPortfolioElement.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/sortPortfolioElement.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"sortPortfolioElement.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/sortPortfolioElement.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,4CAOsB;AACtB,6CAA0C;AAE1C,SAAgB,oBAAoB,CAClC,OAAyB;IAEzB,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,gCAAoB,CAAC,QAAQ;YAChC,OAAO,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACtC,KAAK,gCAAoB,CAAC,UAAU;YAClC,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,gCAAoB,CAAC,SAAS;YACjC,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACvC;YACE,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAbD,oDAaC;AAED,SAAgB,mBAAmB,CACjC,OAAiC;IAEjC,MAAM,aAAa,GAAG,OAAO,CAAC;IAC9B,aAAa,CAAC,IAAI,CAAC,MAAM,GAAG,IAAA,uBAAU,EAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClE,OAAO,aAAa,CAAC;AACvB,CAAC;AAND,kDAMC;AAED,SAAgB,qBAAqB,CACnC,OAAmC;IAEnC,MAAM,QAAQ,GAAG,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,cAAc,GAAG,IAAA,uBAAU,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