@pythnetwork/price-pusher 5.6.3 → 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
@@ -85,7 +104,7 @@ npm run start -- injective --grpc-endpoint https://grpc-endpoint.com \
85
104
 
86
105
  # For Aptos
87
106
  npm run start -- aptos --endpoint https://fullnode.testnet.aptoslabs.com/v1 \
88
- --pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 --price-service-endpoint "https://xc-testnet.pyth.network" \
107
+ --pyth-contract-address 0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387 --price-service-endpoint "https://hermes-beta.pyth.network" \
89
108
  --price-config-file "./price-config.testnet.sample.yaml" \
90
109
  --mnemonic-file "path/to/mnemonic.txt" \
91
110
  [--pushing-frequency 10] \
@@ -99,7 +118,7 @@ npm run start -- sui \
99
118
  --wormhole-package-id 0xcc029e2810f17f9f43f52262f40026a71fbdca40ed3803ad2884994361910b7e \
100
119
  --wormhole-state-id 0xebba4cc4d614f7a7cdbe883acc76d1cc767922bc96778e7b68be0d15fce27c02 \
101
120
  --price-feed-to-price-info-object-table-id 0xf8929174008c662266a1adde78e1e8e33016eb7ad37d379481e860b911e40ed5 \
102
- --price-service-endpoint https://xc-testnet.pyth.network \
121
+ --price-service-endpoint https://hermes-beta.pyth.network \
103
122
  --mnemonic-file ./mnemonic \
104
123
  --price-config-file ./price-config.testnet.sample.yaml \
105
124
  [--pushing-frequency 10] \
@@ -128,7 +147,7 @@ For example, to push `BTC/USD` and `BNB/USD` prices on Fantom testnet, run the f
128
147
 
129
148
  ```sh
130
149
  npm run dev -- evm --endpoint https://endpoints.omniatech.io/v1/fantom/testnet/public \
131
- --pyth-contract-address 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C --price-service-endpoint https://xc-testnet.pyth.network \
150
+ --pyth-contract-address 0xff1a0f4744e8582DF1aE09D5611b887B6a12925C --price-service-endpoint https://hermes-beta.pyth.network \
132
151
  --mnemonic-file "./mnemonic" --price-config-file "./price-config.testnet.sample.yaml"
133
152
  ```
134
153
 
@@ -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 &&
@@ -13,6 +13,7 @@ declare const _default: {
13
13
  "wormhole-state-id": Options;
14
14
  "num-gas-objects": Options;
15
15
  "gas-budget": Options;
16
+ "account-index": Options;
16
17
  };
17
18
  handler: (argv: any) => Promise<void>;
18
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;oBAoDC,GAAG;;AAhDpC,wBA0HE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;oBA0DC,GAAG;;AAtDpC,wBAmIE"}
@@ -72,6 +72,12 @@ exports.default = {
72
72
  required: true,
73
73
  default: 500_000_000,
74
74
  },
75
+ "account-index": {
76
+ description: "Index of the account to use derived by the mnemonic",
77
+ type: "number",
78
+ required: true,
79
+ default: 0,
80
+ },
75
81
  ...options.priceConfigFile,
76
82
  ...options.priceServiceEndpoint,
77
83
  ...options.mnemonicFile,
@@ -79,7 +85,7 @@ exports.default = {
79
85
  ...options.pushingFrequency,
80
86
  },
81
87
  handler: async function (argv) {
82
- const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, gasBudget, } = argv;
88
+ const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, gasBudget, accountIndex, } = argv;
83
89
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
84
90
  const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
85
91
  logger: {
@@ -95,13 +101,14 @@ exports.default = {
95
101
  },
96
102
  });
97
103
  const mnemonic = fs_1.default.readFileSync(mnemonicFile, "utf-8").trim();
98
- console.log(`Pushing updates from wallet address: ${sui_js_1.Ed25519Keypair.deriveKeypair(mnemonic)
104
+ const keypair = sui_js_1.Ed25519Keypair.deriveKeypair(mnemonic, `m/44'/784'/${accountIndex}'/0'/0'`);
105
+ console.log(`Pushing updates from wallet address: ${keypair
99
106
  .getPublicKey()
100
107
  .toSuiAddress()}`);
101
108
  const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
102
109
  const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems);
103
110
  const suiListener = new sui_1.SuiPriceListener(pythStateId, wormholeStateId, endpoint, priceItems, { pollingFrequency });
104
- const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, mnemonic, gasBudget, numGasObjects);
111
+ const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects);
105
112
  const controller = new controller_1.Controller(priceConfigs, pythListener, suiListener, suiPusher, { pushingFrequency });
106
113
  controller.start();
107
114
  },
package/lib/sui/sui.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
2
2
  import { DurationInSeconds } from "../utils";
3
3
  import { PriceServiceConnection } from "@pythnetwork/price-service-client";
4
- import { JsonRpcProvider, RawSigner, SuiObjectRef, ObjectId } from "@mysten/sui.js";
4
+ import { JsonRpcProvider, Ed25519Keypair, RawSigner, SuiObjectRef, ObjectId } from "@mysten/sui.js";
5
5
  import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
6
6
  export declare class SuiPriceListener extends ChainPriceListener {
7
7
  private pythClient;
@@ -35,7 +35,7 @@ export declare class SuiPricePusher implements IPricePusher {
35
35
  private gasBudget;
36
36
  private gasPool;
37
37
  private pythClient;
38
- constructor(signer: RawSigner, priceServiceConnection: PriceServiceConnection, pythPackageId: string, pythStateId: string, wormholePackageId: string, wormholeStateId: string, endpoint: string, mnemonic: string, gasBudget: number, gasPool: SuiObjectRef[], pythClient: SuiPythClient);
38
+ constructor(signer: RawSigner, priceServiceConnection: PriceServiceConnection, pythPackageId: string, pythStateId: string, wormholePackageId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, gasPool: SuiObjectRef[], pythClient: SuiPythClient);
39
39
  /**
40
40
  * getPackageId returns the latest package id that the object belongs to. Use this to
41
41
  * fetch the latest package id for a given object id and handle package upgrades automatically.
@@ -46,9 +46,9 @@ export declare class SuiPricePusher implements IPricePusher {
46
46
  static getPackageId(provider: JsonRpcProvider, objectId: ObjectId): Promise<ObjectId>;
47
47
  /**
48
48
  * Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
49
- * The gas coins of the wallet for the provided mnemonic will be merged and then evenly split into `numGasObjects`.
49
+ * The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
50
50
  */
51
- static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, pythStateId: string, wormholeStateId: string, endpoint: string, mnemonic: string, gasBudget: number, numGasObjects: number): Promise<SuiPricePusher>;
51
+ static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, pythStateId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, numGasObjects: number): Promise<SuiPricePusher>;
52
52
  updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
53
53
  /** Send every transaction in txs in parallel, returning when all transactions have completed. */
54
54
  private sendTransactionBlocks;
@@ -1 +1 @@
1
- {"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/sui/sui.ts"],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iG;YACnF,qBAAqB;IAMnC,sEAAsE;YACxD,oBAAoB;mBAwDb,iBAAiB;mBAuCjB,yBAAyB;mBAoBzB,cAAc;mBAiCd,mBAAmB;mBAsCnB,oBAAoB;CA+D1C"}
package/lib/sui/sui.js CHANGED
@@ -76,7 +76,7 @@ class SuiPricePusher {
76
76
  gasBudget;
77
77
  gasPool;
78
78
  pythClient;
79
- constructor(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, mnemonic, gasBudget, gasPool, pythClient) {
79
+ constructor(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, keypair, gasBudget, gasPool, pythClient) {
80
80
  this.signer = signer;
81
81
  this.priceServiceConnection = priceServiceConnection;
82
82
  this.pythPackageId = pythPackageId;
@@ -115,19 +115,19 @@ class SuiPricePusher {
115
115
  }
116
116
  /**
117
117
  * Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
118
- * The gas coins of the wallet for the provided mnemonic will be merged and then evenly split into `numGasObjects`.
118
+ * The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
119
119
  */
120
- static async createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, mnemonic, gasBudget, numGasObjects) {
120
+ static async createWithAutomaticGasPool(priceServiceConnection, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects) {
121
121
  if (numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT) {
122
122
  throw new Error(`numGasObjects cannot be greater than ${MAX_NUM_OBJECTS_IN_ARGUMENT} until we implement split chunking`);
123
123
  }
124
124
  const provider = new sui_js_1.JsonRpcProvider(new sui_js_1.Connection({ fullnode: endpoint }));
125
- const signer = new sui_js_1.RawSigner(sui_js_1.Ed25519Keypair.deriveKeypair(mnemonic), provider);
125
+ const signer = new sui_js_1.RawSigner(keypair, provider);
126
126
  const pythPackageId = await SuiPricePusher.getPackageId(provider, pythStateId);
127
127
  const wormholePackageId = await SuiPricePusher.getPackageId(provider, wormholeStateId);
128
128
  const gasPool = await SuiPricePusher.initializeGasPool(signer, numGasObjects);
129
129
  const pythClient = new pyth_sui_js_1.SuiPythClient(provider, pythStateId, wormholeStateId);
130
- return new SuiPricePusher(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, mnemonic, gasBudget, gasPool, pythClient);
130
+ return new SuiPricePusher(signer, priceServiceConnection, pythPackageId, pythStateId, wormholePackageId, wormholeStateId, endpoint, keypair, gasBudget, gasPool, pythClient);
131
131
  }
132
132
  async updatePriceFeed(priceIds, pubTimesToPush) {
133
133
  if (priceIds.length === 0) {
@@ -182,8 +182,10 @@ class SuiPricePusher {
182
182
  }
183
183
  catch (e) {
184
184
  console.log("Error when signAndExecuteTransactionBlock");
185
- if (String(e).includes("GasBalanceTooLow")) {
186
- console.warn(`The balance of gas object ${gasObject.objectId} is too low. Removing from pool.`);
185
+ if (String(e).includes("Balance of gas object") ||
186
+ String(e).includes("GasBalanceTooLow")) {
187
+ // If the error is caused by insufficient gas, we should panic
188
+ throw e;
187
189
  }
188
190
  else {
189
191
  // Refresh the coin object here in case the error is caused by an object version mismatch.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/price-pusher",
3
- "version": "5.6.3",
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": "2b51cffdc7e782995e7c267d2fc3b0a8a24e1c60"
67
+ "gitHead": "cc7054b6f35e5d6dd3875b91d348303c78773d5d"
68
68
  }