@sonarwatch/portfolio-core 0.16.3 → 0.16.5
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 +20 -0
- package/package.json +1 -1
- package/src/FetcherResult.d.ts +38 -0
- package/src/FetcherResult.js +3 -0
- package/src/FetcherResult.js.map +1 -0
- package/src/Portfolio.d.ts +7 -35
- package/src/Portfolio.js.map +1 -1
- package/src/Yield.d.ts +4 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +1 -0
- package/src/utils/index.js.map +1 -1
- package/src/utils/reduceYieldElements.d.ts +2 -0
- package/src/utils/reduceYieldElements.js +12 -0
- package/src/utils/reduceYieldElements.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.16.5](https://github.com/sonarwatch/portfolio/compare/core-0.16.4...core-0.16.5) (2025-07-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **core:** handle empty yield items and correct revenue calculations in calcYieldSummary ([39ba5f3](https://github.com/sonarwatch/portfolio/commit/39ba5f3b6bb334b970e7b8e146cf80d24d45293c))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **core:** add calcYieldSummary utility and FetcherResult types to enhance yield data calculations and integration ([9c26a0f](https://github.com/sonarwatch/portfolio/commit/9c26a0f618826a8dbec19ff7cf7685182aff27e5))
|
|
16
|
+
* **core:** add optional error field to FetcherResult ([76e3b84](https://github.com/sonarwatch/portfolio/commit/76e3b84bfb8ab07a42d3c238e256611885bd2b52))
|
|
17
|
+
* **plugins:** add netApy support across element builders and simplify yield calculations ([f0c97b7](https://github.com/sonarwatch/portfolio/commit/f0c97b74727e320370fcc6a298ff14eb7b74c256))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [0.16.4](https://github.com/sonarwatch/portfolio/compare/core-0.16.3...core-0.16.4) (2025-07-04)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
5
25
|
## [0.16.3](https://github.com/sonarwatch/portfolio/compare/core-0.16.2...core-0.16.3) (2025-07-04)
|
|
6
26
|
|
|
7
27
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NetworkIdType } from './Network';
|
|
2
|
+
import { AddressSystemType } from './Address';
|
|
3
|
+
import { UsdValue } from './UsdValue';
|
|
4
|
+
import { TokenInfo } from './TokenList';
|
|
5
|
+
import { PortfolioElement } from './Portfolio';
|
|
6
|
+
/**
|
|
7
|
+
* Represents the result of a fetcher.
|
|
8
|
+
*/
|
|
9
|
+
export type FetcherResult = {
|
|
10
|
+
owner: string;
|
|
11
|
+
fetcherId: string;
|
|
12
|
+
networdkId: NetworkIdType;
|
|
13
|
+
duration: number;
|
|
14
|
+
elements: PortfolioElement[];
|
|
15
|
+
error?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Represents the report of a fetcher.
|
|
19
|
+
*/
|
|
20
|
+
export type FetcherReport = {
|
|
21
|
+
id: string;
|
|
22
|
+
status: 'succeeded' | 'failed';
|
|
23
|
+
duration?: number;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Represents the result of multiple fetchers.
|
|
28
|
+
*/
|
|
29
|
+
export type FetchersResult = {
|
|
30
|
+
date: number;
|
|
31
|
+
owner: string;
|
|
32
|
+
addressSystem: AddressSystemType;
|
|
33
|
+
fetcherReports: FetcherReport[];
|
|
34
|
+
value: UsdValue;
|
|
35
|
+
elements: PortfolioElement[];
|
|
36
|
+
duration: number;
|
|
37
|
+
tokenInfo?: Partial<Record<NetworkIdType, Record<string, TokenInfo>>>;
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FetcherResult.js","sourceRoot":"","sources":["../../../../packages/core/src/FetcherResult.ts"],"names":[],"mappings":""}
|
package/src/Portfolio.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { UsdValue } from './UsdValue';
|
|
2
2
|
import { NetworkIdType } from './Network';
|
|
3
3
|
import { Yield } from './Yield';
|
|
4
|
-
import { AddressSystemType } from './Address';
|
|
5
|
-
import { TokenInfo } from './TokenList';
|
|
6
4
|
/**
|
|
7
5
|
* Represents the type of portfolio asset.
|
|
8
6
|
*/
|
|
@@ -154,6 +152,13 @@ export type PortfolioElementCommon = {
|
|
|
154
152
|
name?: string;
|
|
155
153
|
tags?: string[];
|
|
156
154
|
proxyInfo?: ProxyInfo;
|
|
155
|
+
/**
|
|
156
|
+
* Net APY (Annual Percentage Yield) as fraction.
|
|
157
|
+
* Includes internal token yields
|
|
158
|
+
* 0.28 means 28% APY
|
|
159
|
+
* -0.28 means -28% APR
|
|
160
|
+
*/
|
|
161
|
+
netApy?: number;
|
|
157
162
|
};
|
|
158
163
|
/**
|
|
159
164
|
* Represents the data of a multiple portfolio element.
|
|
@@ -391,36 +396,3 @@ export type PortfolioElementBorrowLend = PortfolioElementCommon & {
|
|
|
391
396
|
* Represents a portfolio element.
|
|
392
397
|
*/
|
|
393
398
|
export type PortfolioElement = PortfolioElementMultiple | PortfolioElementLiquidity | PortfolioElementLeverage | PortfolioElementBorrowLend | PortfolioElementTrade;
|
|
394
|
-
/**
|
|
395
|
-
* Represents the result of a fetcher.
|
|
396
|
-
*/
|
|
397
|
-
export type FetcherResult = {
|
|
398
|
-
owner: string;
|
|
399
|
-
fetcherId: string;
|
|
400
|
-
networdkId: NetworkIdType;
|
|
401
|
-
duration: number;
|
|
402
|
-
elements: PortfolioElement[];
|
|
403
|
-
error?: string;
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* Represents the report of a fetcher.
|
|
407
|
-
*/
|
|
408
|
-
export type FetcherReport = {
|
|
409
|
-
id: string;
|
|
410
|
-
status: 'succeeded' | 'failed';
|
|
411
|
-
duration?: number;
|
|
412
|
-
error?: string;
|
|
413
|
-
};
|
|
414
|
-
/**
|
|
415
|
-
* Represents the result of multiple fetchers.
|
|
416
|
-
*/
|
|
417
|
-
export type FetchersResult = {
|
|
418
|
-
date: number;
|
|
419
|
-
owner: string;
|
|
420
|
-
addressSystem: AddressSystemType;
|
|
421
|
-
fetcherReports: FetcherReport[];
|
|
422
|
-
value: UsdValue;
|
|
423
|
-
elements: PortfolioElement[];
|
|
424
|
-
duration: number;
|
|
425
|
-
tokenInfo?: Partial<Record<NetworkIdType, Record<string, TokenInfo>>>;
|
|
426
|
-
};
|
package/src/Portfolio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portfolio.js","sourceRoot":"","sources":["../../../../packages/core/src/Portfolio.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Portfolio.js","sourceRoot":"","sources":["../../../../packages/core/src/Portfolio.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACU,QAAA,kBAAkB,GAAG;IAChC,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,aAAa;CAClB,CAAC;AA6CX;;GAEG;AACU,QAAA,oBAAoB,GAAG;IAClC,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;CACN,CAAC;AAkPX,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|
package/src/Yield.d.ts
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -31,4 +31,5 @@ __exportStar(require("./TokenYield"), exports);
|
|
|
31
31
|
__exportStar(require("./Yield"), exports);
|
|
32
32
|
__exportStar(require("./BorrowLendRate"), exports);
|
|
33
33
|
__exportStar(require("./Transaction"), exports);
|
|
34
|
+
__exportStar(require("./FetcherResult"), exports);
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,0CAAwB;AACxB,mDAAiC;AACjC,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,0CAAwB;AACxB,mDAAiC;AACjC,gDAA8B;AAC9B,kDAAgC"}
|
package/src/utils/index.d.ts
CHANGED
package/src/utils/index.js
CHANGED
|
@@ -64,4 +64,5 @@ __exportStar(require("./getIsVerifiedFromAsset"), exports);
|
|
|
64
64
|
__exportStar(require("./TokenPriceMap"), exports);
|
|
65
65
|
__exportStar(require("./applyPricesToElements"), exports);
|
|
66
66
|
__exportStar(require("./fixUsdValue"), exports);
|
|
67
|
+
__exportStar(require("./reduceYieldElements"), exports);
|
|
67
68
|
//# sourceMappingURL=index.js.map
|
package/src/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,oDAAkC;AAClC,kEAAgD;AAChD,sDAAoC;AACpC,iDAA+B;AAC/B,sDAAoC;AACpC,kDAAgC;AAChC,uDAAqC;AACrC,4DAA0C;AAC1C,+DAA6C;AAC7C,gDAA8B;AAC9B,oDAAkC;AAClC,mDAAiC;AACjC,wDAAsC;AACtC,qDAAmC;AACnC,+DAA6C;AAC7C,2DAAyC;AACzC,uDAAqC;AACrC,mDAAiC;AACjC,wDAAsC;AACtC,2DAAyC;AACzC,+DAA6C;AAC7C,kEAAgD;AAChD,yDAAuC;AACvC,0DAAwC;AACxC,4DAA0C;AAC1C,8DAA4C;AAC5C,mDAAiC;AACjC,yDAAuC;AACvC,mEAAiD;AACjD,oEAAkD;AAClD,+CAA6B;AAC7B,yDAAuC;AACvC,0DAAwC;AACxC,4DAA0C;AAC1C,wDAAsC;AACtC,2DAAyC;AACzC,sDAAoC;AACpC,uDAAqC;AACrC,uDAAqC;AACrC,sDAAoC;AACpC,uDAAqC;AACrC,8DAA4C;AAC5C,8DAA4C;AAC5C,mDAAiC;AACjC,uDAAqC;AACrC,2DAAyC;AACzC,kDAAgC;AAChC,0DAAwC;AACxC,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,oDAAkC;AAClC,kEAAgD;AAChD,sDAAoC;AACpC,iDAA+B;AAC/B,sDAAoC;AACpC,kDAAgC;AAChC,uDAAqC;AACrC,4DAA0C;AAC1C,+DAA6C;AAC7C,gDAA8B;AAC9B,oDAAkC;AAClC,mDAAiC;AACjC,wDAAsC;AACtC,qDAAmC;AACnC,+DAA6C;AAC7C,2DAAyC;AACzC,uDAAqC;AACrC,mDAAiC;AACjC,wDAAsC;AACtC,2DAAyC;AACzC,+DAA6C;AAC7C,kEAAgD;AAChD,yDAAuC;AACvC,0DAAwC;AACxC,4DAA0C;AAC1C,8DAA4C;AAC5C,mDAAiC;AACjC,yDAAuC;AACvC,mEAAiD;AACjD,oEAAkD;AAClD,+CAA6B;AAC7B,yDAAuC;AACvC,0DAAwC;AACxC,4DAA0C;AAC1C,wDAAsC;AACtC,2DAAyC;AACzC,sDAAoC;AACpC,uDAAqC;AACrC,uDAAqC;AACrC,sDAAoC;AACpC,uDAAqC;AACrC,8DAA4C;AAC5C,8DAA4C;AAC5C,mDAAiC;AACjC,uDAAqC;AACrC,2DAAyC;AACzC,kDAAgC;AAChC,0DAAwC;AACxC,gDAA8B;AAC9B,wDAAsC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reduceYieldElements = void 0;
|
|
4
|
+
const getUsdValueSum_1 = require("./getUsdValueSum");
|
|
5
|
+
const reduceYieldElements = (yieldItems) => {
|
|
6
|
+
const totalValue = (0, getUsdValueSum_1.getUsdValueSum)(yieldItems.map((ye) => ye.value));
|
|
7
|
+
return yieldItems
|
|
8
|
+
.filter((ye) => ye.apy !== 0)
|
|
9
|
+
.reduce((sum, ye) => sum + (ye.apy * ye.value) / totalValue, 0);
|
|
10
|
+
};
|
|
11
|
+
exports.reduceYieldElements = reduceYieldElements;
|
|
12
|
+
//# sourceMappingURL=reduceYieldElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduceYieldElements.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/reduceYieldElements.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAG3C,MAAM,mBAAmB,GAAG,CAAC,UAA0B,EAAE,EAAE;IAChE,MAAM,UAAU,GAAG,IAAA,+BAAc,EAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,OAAO,UAAU;SACd,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;SAC5B,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B"}
|