@pythnetwork/price-pusher 7.0.0 → 7.0.2

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 Pyth Contributors.
1
+ Copyright 2024 Pyth Data Association.
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ declare const _default: {
21
21
  "jito-keypair-file": Options;
22
22
  "jito-tip-lamports": Options;
23
23
  "jito-bundle-size": Options;
24
+ "updates-per-jito-bundle": Options;
24
25
  };
25
26
  handler: (argv: any) => void;
26
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/solana/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAgBhC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;oBAwDH,GAAG;;AAtD9B,wBA2JE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/solana/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAgBhC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;oBA6DH,GAAG;;AA3D9B,wBAkKE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
@@ -84,6 +84,11 @@ exports.default = {
84
84
  type: "number",
85
85
  default: 2,
86
86
  },
87
+ "updates-per-jito-bundle": {
88
+ description: "Number of transactions in each bundle",
89
+ type: "number",
90
+ default: 6,
91
+ },
87
92
  ...options.priceConfigFile,
88
93
  ...options.priceServiceEndpoint,
89
94
  ...options.pythContractAddress,
@@ -94,7 +99,7 @@ exports.default = {
94
99
  ...options.controllerLogLevel,
95
100
  },
96
101
  handler: function (argv) {
97
- const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, jitoBundleSize, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
102
+ const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, jitoBundleSize, updatesPerJitoBundle, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
98
103
  const logger = (0, pino_1.default)({ level: logLevel });
99
104
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
100
105
  const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
@@ -112,7 +117,7 @@ exports.default = {
112
117
  if (jitoTipLamports) {
113
118
  const jitoKeypair = web3_js_1.Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs_1.default.readFileSync(jitoKeypairFile, "ascii"))));
114
119
  const jitoClient = (0, searcher_1.searcherClient)(jitoEndpoint, jitoKeypair);
115
- solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, priceServiceConnection, logger.child({ module: "SolanaPricePusherJito" }), shardId, jitoTipLamports, jitoClient, jitoBundleSize);
120
+ solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, priceServiceConnection, logger.child({ module: "SolanaPricePusherJito" }), shardId, jitoTipLamports, jitoClient, jitoBundleSize, updatesPerJitoBundle);
116
121
  (0, exports.onBundleResult)(jitoClient, logger.child({ module: "JitoClient" }));
117
122
  }
118
123
  else {
@@ -32,7 +32,8 @@ export declare class SolanaPricePusherJito implements IPricePusher {
32
32
  private jitoTipLamports;
33
33
  private searcherClient;
34
34
  private jitoBundleSize;
35
- constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, logger: Logger, shardId: number, jitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number);
35
+ private updatesPerJitoBundle;
36
+ constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, logger: Logger, shardId: number, jitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number, updatesPerJitoBundle: number);
36
37
  updatePriceFeed(priceIds: string[], _pubTimesToPush: number[]): Promise<void>;
37
38
  }
38
39
  //# sourceMappingURL=solana.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAK3E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,qBAAa,mBAAoB,SAAQ,kBAAkB;IAEvD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,OAAO;IAEf,OAAO,CAAC,MAAM;gBAHN,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,EAAE,MAAM,EACvB,UAAU,EAAE,SAAS,EAAE,EACf,MAAM,EAAE,MAAM,EACtB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC;KACrC;YAOW,WAAW;IAUnB,KAAK;IAOL,mBAAmB,CAAC,OAAO,EA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AAE,sBAAsB,EAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,MAAM;IAGhC,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAElB,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC;CAuCjB"}
@@ -69,9 +69,15 @@ class SolanaPricePusher {
69
69
  if (priceIds.length === 0) {
70
70
  return;
71
71
  }
72
+ const shuffledPriceIds = priceIds
73
+ .map((x) => {
74
+ return { element: x, key: Math.random() };
75
+ })
76
+ .sort((a, b) => a.key - b.key)
77
+ .map((x) => x.element);
72
78
  let priceFeedUpdateData;
73
79
  try {
74
- priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
80
+ priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(shuffledPriceIds);
75
81
  }
76
82
  catch (err) {
77
83
  this.logger.error(err, "getPriceFeedsUpdateData failed:");
@@ -96,7 +102,6 @@ class SolanaPricePusher {
96
102
  }
97
103
  }
98
104
  exports.SolanaPricePusher = SolanaPricePusher;
99
- const UPDATES_PER_JITO_BUNDLE = 7;
100
105
  class SolanaPricePusherJito {
101
106
  pythSolanaReceiver;
102
107
  priceServiceConnection;
@@ -105,7 +110,8 @@ class SolanaPricePusherJito {
105
110
  jitoTipLamports;
106
111
  searcherClient;
107
112
  jitoBundleSize;
108
- constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, jitoTipLamports, searcherClient, jitoBundleSize) {
113
+ updatesPerJitoBundle;
114
+ constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, jitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle) {
109
115
  this.pythSolanaReceiver = pythSolanaReceiver;
110
116
  this.priceServiceConnection = priceServiceConnection;
111
117
  this.logger = logger;
@@ -113,6 +119,7 @@ class SolanaPricePusherJito {
113
119
  this.jitoTipLamports = jitoTipLamports;
114
120
  this.searcherClient = searcherClient;
115
121
  this.jitoBundleSize = jitoBundleSize;
122
+ this.updatesPerJitoBundle = updatesPerJitoBundle;
116
123
  }
117
124
  async updatePriceFeed(priceIds,
118
125
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -125,12 +132,12 @@ class SolanaPricePusherJito {
125
132
  this.logger.error(err, "getPriceFeedsUpdateData failed");
126
133
  return;
127
134
  }
128
- for (let i = 0; i < priceIds.length; i += UPDATES_PER_JITO_BUNDLE) {
135
+ for (let i = 0; i < priceIds.length; i += this.updatesPerJitoBundle) {
129
136
  const transactionBuilder = this.pythSolanaReceiver.newTransactionBuilder({
130
137
  closeUpdateAccounts: true,
131
138
  });
132
139
  await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData.map((x) => {
133
- return (0, price_service_sdk_1.sliceAccumulatorUpdateData)(Buffer.from(x, "base64"), i, i + UPDATES_PER_JITO_BUNDLE).toString("base64");
140
+ return (0, price_service_sdk_1.sliceAccumulatorUpdateData)(Buffer.from(x, "base64"), i, i + this.updatesPerJitoBundle).toString("base64");
134
141
  }), this.shardId);
135
142
  const transactions = await transactionBuilder.buildVersionedTransactions({
136
143
  jitoTipLamports: this.jitoTipLamports,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/price-pusher",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Pyth Price Pusher",
5
5
  "homepage": "https://pyth.network",
6
6
  "main": "lib/index.js",
@@ -62,7 +62,7 @@
62
62
  "@pythnetwork/pyth-sdk-solidity": "3.1.0",
63
63
  "@pythnetwork/pyth-solana-receiver": "0.8.0",
64
64
  "@pythnetwork/pyth-sui-js": "2.0.0",
65
- "@pythnetwork/solana-utils": "0.4.1",
65
+ "@pythnetwork/solana-utils": "0.4.2",
66
66
  "@solana/web3.js": "^1.93.0",
67
67
  "@truffle/hdwallet-provider": "^2.1.3",
68
68
  "@types/pino": "^7.0.5",
@@ -77,5 +77,5 @@
77
77
  "yaml": "^2.1.1",
78
78
  "yargs": "^17.5.1"
79
79
  },
80
- "gitHead": "05dc9c8e06b9643bb365db494e67cac843d7b90a"
80
+ "gitHead": "0db40907504579f2d8b6520fcbfb2e952c3ab170"
81
81
  }