@sonarwatch/portfolio-core 0.11.11 → 0.11.13

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,14 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.11.13](https://github.com/sonarwatch/portfolio/compare/core-0.11.12...core-0.11.13) (2023-12-17)
6
+
7
+
8
+
9
+ ## [0.11.12](https://github.com/sonarwatch/portfolio/compare/core-0.11.11...core-0.11.12) (2023-12-15)
10
+
11
+
12
+
5
13
  ## [0.11.11](https://github.com/sonarwatch/portfolio/compare/core-0.11.10...core-0.11.11) (2023-12-15)
6
14
 
7
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonarwatch/portfolio-core",
3
- "version": "0.11.11",
3
+ "version": "0.11.13",
4
4
  "type": "commonjs",
5
5
  "dependencies": {
6
6
  "@ethersproject/address": "^5.7.0",
@@ -217,16 +217,17 @@ 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: number | null;
226
+ collateralRatio: null;
226
227
  /**
227
228
  * The health ratio of the portfolio element.
228
- * 1 means 100% / full health / no borrow.
229
- * 0 and <0 means can be liquidated.
229
+ * 1 means full health or no borrow.
230
+ * 0 or below means can be liquidated.
230
231
  * null means unknown.
231
232
  */
232
233
  healthRatio: number | null;
@@ -4,7 +4,6 @@ export declare function getElementLendingValues(suppliedAssets: PortfolioAsset[]
4
4
  borrowedValue: UsdValue;
5
5
  suppliedValue: UsdValue;
6
6
  rewardsValue: UsdValue;
7
- collateralRatio: number | null;
8
7
  healthRatio: number | null;
9
8
  value: number | null;
10
9
  };
@@ -1,21 +1,13 @@
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;
17
7
  if (suppliedLtvs && suppliedLtvs.length !== suppliedAssets.length)
18
8
  throw new Error('suppliedLtvs length doesnt match suppliedAssets');
9
+ if (borrowedAssets.length === 0)
10
+ return 1;
19
11
  const fBorrowedWeights = borrowedWeights || new Array(borrowedAssets.length).fill(1);
20
12
  if (fBorrowedWeights.length !== borrowedAssets.length)
21
13
  throw new Error('borrowedWeights length doesnt match borrowedAssets');
@@ -31,7 +23,6 @@ function getElementLendingValues(suppliedAssets, borrowedAssets, rewardAssets, s
31
23
  const rewardsValue = rewardAssets.reduce((acc, asset) => acc !== null && asset.value !== null ? acc + asset.value : null, 0);
32
24
  const suppliedValue = suppliedAssets.reduce((acc, asset) => acc !== null && asset.value !== null ? acc + asset.value : null, 0);
33
25
  const borrowedValue = borrowedAssets.reduce((acc, asset) => acc !== null && asset.value !== null ? acc + asset.value : null, 0);
34
- const collateralRatio = getCollateralRatio(suppliedValue, borrowedValue);
35
26
  const healthRatio = getHealthRatio(suppliedAssets, borrowedAssets, suppliedLtvs, borrowedWeights);
36
27
  // Total value
37
28
  let value = suppliedValue !== null && borrowedValue !== null
@@ -43,7 +34,6 @@ function getElementLendingValues(suppliedAssets, borrowedAssets, rewardAssets, s
43
34
  borrowedValue,
44
35
  suppliedValue,
45
36
  rewardsValue,
46
- collateralRatio,
47
37
  healthRatio,
48
38
  value,
49
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getElement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c;IACd,IAAI,KAAK,GACP,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,IAAI;QAC9C,CAAC,CAAC,aAAa,GAAG,aAAa;QAC/B,CAAC,CAAC,IAAI,CAAC;IACX,IAAI,YAAY,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI;QAAE,KAAK,IAAI,YAAY,CAAC;IAEnE,OAAO;QACL,aAAa;QACb,aAAa;QACb,YAAY;QACZ,eAAe;QACf,WAAW;QACX,KAAK;KACN,CAAC;AACJ,CAAC;AA7CD,0DA6CC"}
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,cAAc,CAAC,MAAM;QAC/D,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE1C,MAAM,gBAAgB,GACpB,eAAe,IAAI,IAAI,KAAK,CAAS,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtE,IAAI,gBAAgB,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM;QACnD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAExE,MAAM,qBAAqB,GAAW,cAAc,CAAC,MAAM,CACzD,CAAC,GAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAC5B,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI;QAClC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QACzC,CAAC,CAAC,CAAC,EACP,C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