@pythnetwork/price-pusher 5.7.1 → 6.0.0

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/README.md CHANGED
@@ -37,6 +37,7 @@ The parameters above are configured per price feed in a price configuration YAML
37
37
  time_difference: 60 # Time difference threshold (in seconds) to push a newer price feed.
38
38
  price_deviation: 0.5 # The price deviation (%) threshold to push a newer price feed.
39
39
  confidence_ratio: 1 # The confidence/price (%) threshold to push a newer price feed.
40
+
40
41
  # Optional block to configure whether this feed can be early updated. If at least one feed meets the
41
42
  # triggering conditions above, all other feeds who meet the early update conditions will be included in
42
43
  # the submitted batch of prices. This logic takes advantage of the fact that adding a feed to a larger
@@ -49,6 +50,24 @@ The parameters above are configured per price feed in a price configuration YAML
49
50
  - ...
50
51
  ```
51
52
 
53
+ By default, the price pusher will automatically update the price of all listed price feeds whenever the
54
+ triggering condition for a single feed is met. This behavior takes advantage of the reduced cost of batch price updates
55
+ provided by the [Perseus upgrade](https://medium.com/@antonia.vanna.delgado/pyth-network-perseus-first-party-data-matters-e3379bf0d019),
56
+ and is typically the lowest cost way to schedule price updates for multiple feeds.
57
+
58
+ However, if you would like to customize this behavior, you can add an `early_update` section to the YAML configuration file for
59
+ the feed.
60
+
61
+ ```yaml
62
+ - alias: A/USD # Arbitrary alias for the price feed. It is used in enhance logging.
63
+ ...
64
+ # If provided, only early update this price feed if at least one of the listed triggering conditions is met.
65
+ early_update:
66
+ time_difference: 30
67
+ price_deviation: 0.1
68
+ confidence_ratio: 0.5
69
+ ```
70
+
52
71
  Two sample YAML configuration files are available in the root of this repo.
53
72
 
54
73
  You can get the list of available price feeds from
@@ -7,6 +7,7 @@ export type PriceConfig = {
7
7
  timeDifference: DurationInSeconds;
8
8
  priceDeviation: PctNumber;
9
9
  confidenceRatio: PctNumber;
10
+ customEarlyUpdate: boolean | undefined;
10
11
  earlyUpdateTimeDifference: DurationInSeconds | undefined;
11
12
  earlyUpdatePriceDeviation: PctNumber | undefined;
12
13
  earlyUpdateConfidenceRatio: PctNumber | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"price-config.d.ts","sourceRoot":"","sources":["../src/price-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAI9D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAuBxC,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,SAAS,CAAC;IACd,cAAc,EAAE,iBAAiB,CAAC;IAClC,cAAc,EAAE,SAAS,CAAC;IAC1B,eAAe,EAAE,SAAS,CAAC;IAI3B,yBAAyB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACzD,yBAAyB,EAAE,SAAS,GAAG,SAAS,CAAC;IACjD,0BAA0B,EAAE,SAAS,GAAG,SAAS,CAAC;CACnD,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAsB/D;AAED,oBAAY,eAAe;IAEzB,GAAG,IAAA;IAEH,KAAK,IAAA;IAEL,EAAE,IAAA;CACH;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,SAAS,GAAG,SAAS,EACxC,iBAAiB,EAAE,SAAS,GAAG,SAAS,GACvC,eAAe,CAmEjB"}
1
+ {"version":3,"file":"price-config.d.ts","sourceRoot":"","sources":["../src/price-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAI9D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAuBxC,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,SAAS,CAAC;IACd,cAAc,EAAE,iBAAiB,CAAC;IAClC,cAAc,EAAE,SAAS,CAAC;IAC1B,eAAe,EAAE,SAAS,CAAC;IAU3B,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,yBAAyB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACzD,yBAAyB,EAAE,SAAS,GAAG,SAAS,CAAC;IACjD,0BAA0B,EAAE,SAAS,GAAG,SAAS,CAAC;CACnD,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAuB/D;AAED,oBAAY,eAAe;IAEzB,GAAG,IAAA;IAEH,KAAK,IAAA;IAEL,EAAE,IAAA;CACH;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,SAAS,GAAG,SAAS,EACxC,iBAAiB,EAAE,SAAS,GAAG,SAAS,GACvC,eAAe,CAqEjB"}
@@ -39,6 +39,7 @@ function readPriceConfigFile(path) {
39
39
  timeDifference: priceConfigRaw.time_difference,
40
40
  priceDeviation: priceConfigRaw.price_deviation,
41
41
  confidenceRatio: priceConfigRaw.confidence_ratio,
42
+ customEarlyUpdate: priceConfigRaw.early_update !== undefined,
42
43
  earlyUpdateTimeDifference: priceConfigRaw.early_update?.time_difference,
43
44
  earlyUpdatePriceDeviation: priceConfigRaw.early_update?.price_deviation,
44
45
  earlyUpdateConfidenceRatio: priceConfigRaw.early_update?.confidence_ratio,
@@ -93,8 +94,10 @@ function shouldUpdate(priceConfig, sourceLatestPrice, targetLatestPrice) {
93
94
  confidenceRatioPct >= priceConfig.confidenceRatio) {
94
95
  return UpdateCondition.YES;
95
96
  }
96
- else if ((priceConfig.earlyUpdateTimeDifference !== undefined &&
97
- timeDifference >= priceConfig.earlyUpdateTimeDifference) ||
97
+ else if (priceConfig.customEarlyUpdate === undefined ||
98
+ !priceConfig.customEarlyUpdate ||
99
+ (priceConfig.earlyUpdateTimeDifference !== undefined &&
100
+ timeDifference >= priceConfig.earlyUpdateTimeDifference) ||
98
101
  (priceConfig.earlyUpdatePriceDeviation !== undefined &&
99
102
  priceDeviationPct >= priceConfig.earlyUpdatePriceDeviation) ||
100
103
  (priceConfig.earlyUpdateConfidenceRatio !== undefined &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/price-pusher",
3
- "version": "5.7.1",
3
+ "version": "6.0.0",
4
4
  "description": "Pyth Price Pusher",
5
5
  "homepage": "https://pyth.network",
6
6
  "main": "lib/index.js",
@@ -64,5 +64,5 @@
64
64
  "yaml": "^2.1.1",
65
65
  "yargs": "^17.5.1"
66
66
  },
67
- "gitHead": "44ebfbaf5512acd96a12b3cdf361b47e64802dbf"
67
+ "gitHead": "cc7054b6f35e5d6dd3875b91d348303c78773d5d"
68
68
  }