@sonarwatch/portfolio-core 0.16.77 → 0.16.79
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 +13 -0
- package/package.json +1 -1
- package/src/Portfolio.d.ts +18 -4
- package/src/Portfolio.js.map +1 -1
- package/src/TokenPrice.d.ts +16 -0
- package/src/TokenPrice.js +73 -44
- package/src/TokenPrice.js.map +1 -1
- package/src/utils/getAddressesFromElement.js +3 -0
- package/src/utils/getAddressesFromElement.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.16.79](https://github.com/sonarwatch/portfolio/compare/core-0.16.78...core-0.16.79) (2025-10-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [0.16.78](https://github.com/sonarwatch/portfolio/compare/core-0.16.77...core-0.16.78) (2025-10-23)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **dca:** update recurring order configuration with cycles, interval, and price range ([3ef9460](https://github.com/sonarwatch/portfolio/commit/3ef9460b8b424b5c1ea442cf872b9d75d50318b8))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
5
18
|
## [0.16.77](https://github.com/sonarwatch/portfolio/compare/core-0.16.76...core-0.16.77) (2025-10-22)
|
|
6
19
|
|
|
7
20
|
|
package/package.json
CHANGED
package/src/Portfolio.d.ts
CHANGED
|
@@ -219,10 +219,24 @@ export type PortfolioElementTradeData = {
|
|
|
219
219
|
/**
|
|
220
220
|
* Recurring order configuration
|
|
221
221
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
recurring?: {
|
|
223
|
+
/**
|
|
224
|
+
* The total number of orders.
|
|
225
|
+
*/
|
|
226
|
+
cycles: number;
|
|
227
|
+
/**
|
|
228
|
+
* The interval between two orders in ms.
|
|
229
|
+
*/
|
|
230
|
+
interval: number;
|
|
231
|
+
/**
|
|
232
|
+
* The price range for the recurring orders.
|
|
233
|
+
*/
|
|
234
|
+
priceRange?: {
|
|
235
|
+
/** Minimum usd price */
|
|
236
|
+
min?: number;
|
|
237
|
+
/** Maximum usd price */
|
|
238
|
+
max?: number;
|
|
239
|
+
};
|
|
226
240
|
};
|
|
227
241
|
contract?: string;
|
|
228
242
|
ref?: string;
|
package/src/Portfolio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAsDX;;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;
|
|
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;AAsDX;;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;AAwRX,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB"}
|
package/src/TokenPrice.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { PortfolioElementLabel, SourceRef } from './Portfolio';
|
|
|
3
3
|
export declare const primarySourceId = "primary";
|
|
4
4
|
export declare const coingeckoSourceId = "coingecko";
|
|
5
5
|
export declare const jupiterSourceId = "jupiter-datapi";
|
|
6
|
+
/**
|
|
7
|
+
* List of source ids to prioritise when computing the token price.
|
|
8
|
+
* The first id in the list has the highest priority.
|
|
9
|
+
* The last id has the lowest priority.
|
|
10
|
+
*/
|
|
11
|
+
export declare const prioritisedSourceIds: string[];
|
|
6
12
|
export declare const tokenPriceSourceTtl: number;
|
|
7
13
|
export type TokenPriceUnderlying = {
|
|
8
14
|
networkId: NetworkIdType;
|
|
@@ -49,3 +55,13 @@ export declare function pushTokenPriceSource(sources: TokenPriceSource[], source
|
|
|
49
55
|
export declare function updateTokenPriceSources(sources: TokenPriceSource[]): TokenPriceSource[] | undefined;
|
|
50
56
|
export declare function getTokenPriceUnderlyingFromTokenPrice(tokenPrice: TokenPrice, amountPerLp: number): TokenPriceUnderlying;
|
|
51
57
|
export declare function getTokenPricesUnderlyingsFromTokensPrices(tokensPrices: TokenPrice[], amountsPerLp: number[]): TokenPriceUnderlying[];
|
|
58
|
+
/**
|
|
59
|
+
* Get the price information from a list of sources.
|
|
60
|
+
* The price is determined by prioritising sources present in the prioritisedSourceIds list
|
|
61
|
+
* If no prioritised source is found, the price is calculated as a weighted average of all sources' price
|
|
62
|
+
* @sources : list of TokenPriceSources
|
|
63
|
+
*/
|
|
64
|
+
export declare function getPriceInfoFromSources(sources: TokenPriceSource[]): {
|
|
65
|
+
price: number;
|
|
66
|
+
priceChange24h?: number;
|
|
67
|
+
};
|
package/src/TokenPrice.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTokenPricesUnderlyingsFromTokensPrices = exports.getTokenPriceUnderlyingFromTokenPrice = exports.updateTokenPriceSources = exports.pushTokenPriceSource = exports.tokenPriceFromSources = exports.tokenPriceSourceTtl = exports.jupiterSourceId = exports.coingeckoSourceId = exports.primarySourceId = void 0;
|
|
3
|
+
exports.getPriceInfoFromSources = exports.getTokenPricesUnderlyingsFromTokensPrices = exports.getTokenPriceUnderlyingFromTokenPrice = exports.updateTokenPriceSources = exports.pushTokenPriceSource = exports.tokenPriceFromSources = exports.tokenPriceSourceTtl = exports.prioritisedSourceIds = exports.jupiterSourceId = exports.coingeckoSourceId = exports.primarySourceId = void 0;
|
|
4
4
|
const helpers_1 = require("./helpers");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
exports.primarySourceId = 'primary';
|
|
7
7
|
exports.coingeckoSourceId = 'coingecko';
|
|
8
8
|
exports.jupiterSourceId = 'jupiter-datapi';
|
|
9
|
+
/**
|
|
10
|
+
* List of source ids to prioritise when computing the token price.
|
|
11
|
+
* The first id in the list has the highest priority.
|
|
12
|
+
* The last id has the lowest priority.
|
|
13
|
+
*/
|
|
14
|
+
exports.prioritisedSourceIds = [
|
|
15
|
+
exports.primarySourceId,
|
|
16
|
+
exports.jupiterSourceId,
|
|
17
|
+
// Always leave coingeckoSourceId at the end to use it as fallback
|
|
18
|
+
exports.coingeckoSourceId,
|
|
19
|
+
];
|
|
9
20
|
exports.tokenPriceSourceTtl = 4 * 60 * 60 * 1000; // 4 hours
|
|
10
21
|
const MAX_N_SOURCES = 10;
|
|
11
22
|
function tokenPriceFromSources(sources) {
|
|
12
23
|
const updatedSources = updateTokenPriceSources(sources);
|
|
13
24
|
if (!updatedSources || updatedSources.length === 0)
|
|
14
25
|
return undefined;
|
|
15
|
-
|
|
26
|
+
// Determine which source should be used as the main source for the token informations (link, label, platformId, etc)
|
|
27
|
+
const displaySource = updatedSources.reduce((prev, current) => {
|
|
16
28
|
if (current.platformId !== constants_1.walletTokensPlatformId &&
|
|
17
29
|
prev.platformId !== constants_1.walletTokensPlatformId &&
|
|
18
30
|
current.platformId !== prev.platformId) {
|
|
@@ -25,52 +37,21 @@ function tokenPriceFromSources(sources) {
|
|
|
25
37
|
return current;
|
|
26
38
|
return prev;
|
|
27
39
|
});
|
|
28
|
-
|
|
29
|
-
let priceChange24h;
|
|
30
|
-
let jupiterSource;
|
|
31
|
-
let coingeckoSource;
|
|
32
|
-
let primarySource;
|
|
33
|
-
for (const source of updatedSources) {
|
|
34
|
-
if (source.id === exports.primarySourceId)
|
|
35
|
-
primarySource = source;
|
|
36
|
-
if (source.id === exports.jupiterSourceId)
|
|
37
|
-
jupiterSource = source;
|
|
38
|
-
if (source.id === exports.coingeckoSourceId)
|
|
39
|
-
coingeckoSource = source;
|
|
40
|
-
}
|
|
41
|
-
if (primarySource) {
|
|
42
|
-
price = primarySource.price;
|
|
43
|
-
}
|
|
44
|
-
else if (jupiterSource) {
|
|
45
|
-
price = jupiterSource.price;
|
|
46
|
-
if (jupiterSource.priceChange24h)
|
|
47
|
-
priceChange24h = jupiterSource.priceChange24h;
|
|
48
|
-
}
|
|
49
|
-
else if (coingeckoSource) {
|
|
50
|
-
price = coingeckoSource.price;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const [priceSum, weightSum] = updatedSources.reduce(([cPriceSum, cWeightSum], source) => [
|
|
54
|
-
cPriceSum + source.price * source.weight,
|
|
55
|
-
cWeightSum + source.weight,
|
|
56
|
-
], [0, 0]);
|
|
57
|
-
price = weightSum === 0 ? 0 : priceSum / weightSum;
|
|
58
|
-
}
|
|
40
|
+
const { price, priceChange24h } = getPriceInfoFromSources(updatedSources);
|
|
59
41
|
return {
|
|
60
|
-
address:
|
|
61
|
-
networkId:
|
|
62
|
-
platformId:
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
address: displaySource.address,
|
|
43
|
+
networkId: displaySource.networkId,
|
|
44
|
+
platformId: displaySource.platformId,
|
|
45
|
+
elementName: displaySource.elementName,
|
|
46
|
+
liquidityName: displaySource.liquidityName,
|
|
47
|
+
label: displaySource.label,
|
|
48
|
+
underlyings: displaySource.underlyings,
|
|
49
|
+
link: displaySource.link,
|
|
50
|
+
decimals: displaySource.decimals,
|
|
51
|
+
price: price,
|
|
65
52
|
priceChange24h,
|
|
66
|
-
underlyings: bestSource.underlyings,
|
|
67
|
-
elementName: bestSource.elementName,
|
|
68
|
-
label: bestSource.label,
|
|
69
|
-
liquidityName: bestSource.liquidityName,
|
|
70
53
|
timestamp: Date.now(),
|
|
71
54
|
sources: updatedSources,
|
|
72
|
-
link: bestSource.link,
|
|
73
|
-
sourceRefs: bestSource.sourceRefs,
|
|
74
55
|
};
|
|
75
56
|
}
|
|
76
57
|
exports.tokenPriceFromSources = tokenPriceFromSources;
|
|
@@ -122,4 +103,52 @@ function getTokenPricesUnderlyingsFromTokensPrices(tokensPrices, amountsPerLp) {
|
|
|
122
103
|
}));
|
|
123
104
|
}
|
|
124
105
|
exports.getTokenPricesUnderlyingsFromTokensPrices = getTokenPricesUnderlyingsFromTokensPrices;
|
|
106
|
+
/**
|
|
107
|
+
* Get the price information from a list of sources.
|
|
108
|
+
* The price is determined by prioritising sources present in the prioritisedSourceIds list
|
|
109
|
+
* If no prioritised source is found, the price is calculated as a weighted average of all sources' price
|
|
110
|
+
* @sources : list of TokenPriceSources
|
|
111
|
+
*/
|
|
112
|
+
function getPriceInfoFromSources(sources) {
|
|
113
|
+
const prioritisedSources = [];
|
|
114
|
+
let price;
|
|
115
|
+
let priceChange24h;
|
|
116
|
+
sources.forEach((s) => {
|
|
117
|
+
if (exports.prioritisedSourceIds.includes(s.id)) {
|
|
118
|
+
prioritisedSources.push(s);
|
|
119
|
+
}
|
|
120
|
+
// Get jupiter price change 24h if available
|
|
121
|
+
if (s.id === exports.jupiterSourceId) {
|
|
122
|
+
priceChange24h = s.priceChange24h;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const [priceSum, weightSum] = sources.reduce(([cPriceSum, cWeightSum], source) => [
|
|
126
|
+
cPriceSum + source.price * source.weight,
|
|
127
|
+
cWeightSum + source.weight,
|
|
128
|
+
], [0, 0]);
|
|
129
|
+
price = weightSum === 0 ? 0 : priceSum / weightSum;
|
|
130
|
+
// If there is no high priority sources, return the weighted average of all sources price
|
|
131
|
+
if (!prioritisedSources)
|
|
132
|
+
return {
|
|
133
|
+
price,
|
|
134
|
+
priceChange24h,
|
|
135
|
+
};
|
|
136
|
+
// Else, find the highest priority source available and use its price
|
|
137
|
+
let highestPrioritySource;
|
|
138
|
+
let highestSourceIndex = Number.MAX_SAFE_INTEGER;
|
|
139
|
+
for (const prioritySource of prioritisedSources) {
|
|
140
|
+
const sourceIndex = exports.prioritisedSourceIds.indexOf(prioritySource.id);
|
|
141
|
+
if (sourceIndex !== -1 && sourceIndex < highestSourceIndex) {
|
|
142
|
+
highestPrioritySource = prioritySource;
|
|
143
|
+
highestSourceIndex = sourceIndex;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (highestPrioritySource)
|
|
147
|
+
price = highestPrioritySource.price;
|
|
148
|
+
return {
|
|
149
|
+
price,
|
|
150
|
+
priceChange24h,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
exports.getPriceInfoFromSources = getPriceInfoFromSources;
|
|
125
154
|
//# sourceMappingURL=TokenPrice.js.map
|
package/src/TokenPrice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenPrice.js","sourceRoot":"","sources":["../../../../packages/core/src/TokenPrice.ts"],"names":[],"mappings":";;;AACA,uCAAsC;AACtC,2CAAqD;AAGxC,QAAA,eAAe,GAAG,SAAS,CAAC;AAC5B,QAAA,iBAAiB,GAAG,WAAW,CAAC;AAChC,QAAA,eAAe,GAAG,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"TokenPrice.js","sourceRoot":"","sources":["../../../../packages/core/src/TokenPrice.ts"],"names":[],"mappings":";;;AACA,uCAAsC;AACtC,2CAAqD;AAGxC,QAAA,eAA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;QACnC,CAAC;IACH,CAAC;IACD,IAAI,qBAAqB;QAAE,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC;IAE/D,OAAO;QACL,KAAK;QACL,cAAc;KACf,CAAC;AACJ,CAAC;AAnDD,0DAmDC"}
|
|
@@ -12,6 +12,9 @@ function getAddressesFromElement(element, tokenOnly = true) {
|
|
|
12
12
|
...(((_b = element.data.cross) === null || _b === void 0 ? void 0 : _b.positions.map((p) => p.address).filter((v) => v !== undefined)) || []),
|
|
13
13
|
];
|
|
14
14
|
}
|
|
15
|
+
if (element.type === Portfolio_1.PortfolioElementType.trade) {
|
|
16
|
+
return [element.data.inputAddress, element.data.outputAddress];
|
|
17
|
+
}
|
|
15
18
|
const assets = (0, getAssetsFromElement_1.getAssetsFromElement)(element);
|
|
16
19
|
const addressesFromAssets = (0, getAddressesFromAssets_1.getAddressesFromAssets)(assets, tokenOnly);
|
|
17
20
|
const addressesFromYields = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAddressesFromElement.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/getAddressesFromElement.ts"],"names":[],"mappings":";;;AAAA,4CAAsE;AACtE,iEAA8D;AAC9D,qEAAkE;AAElE,SAAgB,uBAAuB,CACrC,OAAyB,EACzB,SAAS,GAAG,IAAI;;IAEhB,IAAI,OAAO,CAAC,IAAI,KAAK,gCAAoB,CAAC,QAAQ,EAAE,CAAC;QACnD,OAAO;YACL,GAAI,CAAC,CAAA,MAAA,OAAO,CAAC,IAAI,CAAC,QAAQ,0CAAE,SAAS,CAClC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,KAAI,EAAE,CAAc;YACrD,GAAI,CAAC,CAAA,MAAA,OAAO,CAAC,IAAI,CAAC,KAAK,0CAAE,SAAS,CAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,KAAI,EAAE,CAAc;SACtD,CAAC;IACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"getAddressesFromElement.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/getAddressesFromElement.ts"],"names":[],"mappings":";;;AAAA,4CAAsE;AACtE,iEAA8D;AAC9D,qEAAkE;AAElE,SAAgB,uBAAuB,CACrC,OAAyB,EACzB,SAAS,GAAG,IAAI;;IAEhB,IAAI,OAAO,CAAC,IAAI,KAAK,gCAAoB,CAAC,QAAQ,EAAE,CAAC;QACnD,OAAO;YACL,GAAI,CAAC,CAAA,MAAA,OAAO,CAAC,IAAI,CAAC,QAAQ,0CAAE,SAAS,CAClC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,KAAI,EAAE,CAAc;YACrD,GAAI,CAAC,CAAA,MAAA,OAAO,CAAC,IAAI,CAAC,KAAK,0CAAE,SAAS,CAC/B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,KAAI,EAAE,CAAc;SACtD,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,gCAAoB,CAAC,KAAK,EAAE,CAAC;QAChD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,2CAAoB,EAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,mBAAmB,GAAG,IAAA,+CAAsB,EAAC,MAAM,EAAE,SAAS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