@pythnetwork/price-pusher 8.3.3 → 9.0.1

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.
Files changed (63) hide show
  1. package/README.md +1 -2
  2. package/lib/aptos/aptos.d.ts +3 -3
  3. package/lib/aptos/aptos.d.ts.map +1 -1
  4. package/lib/aptos/aptos.js +8 -7
  5. package/lib/aptos/command.d.ts +1 -2
  6. package/lib/aptos/command.d.ts.map +1 -1
  7. package/lib/aptos/command.js +16 -10
  8. package/lib/evm/command.d.ts +0 -1
  9. package/lib/evm/command.d.ts.map +1 -1
  10. package/lib/evm/command.js +18 -10
  11. package/lib/evm/evm.d.ts +3 -3
  12. package/lib/evm/evm.d.ts.map +1 -1
  13. package/lib/evm/evm.js +13 -9
  14. package/lib/fuel/command.d.ts +0 -1
  15. package/lib/fuel/command.d.ts.map +1 -1
  16. package/lib/fuel/command.js +15 -9
  17. package/lib/fuel/fuel.d.ts +3 -3
  18. package/lib/fuel/fuel.d.ts.map +1 -1
  19. package/lib/fuel/fuel.js +8 -5
  20. package/lib/injective/command.d.ts +1 -2
  21. package/lib/injective/command.d.ts.map +1 -1
  22. package/lib/injective/command.js +16 -10
  23. package/lib/injective/injective.d.ts +3 -3
  24. package/lib/injective/injective.d.ts.map +1 -1
  25. package/lib/injective/injective.js +7 -4
  26. package/lib/interface.d.ts +1 -1
  27. package/lib/interface.d.ts.map +1 -1
  28. package/lib/near/command.d.ts +1 -2
  29. package/lib/near/command.d.ts.map +1 -1
  30. package/lib/near/command.js +16 -10
  31. package/lib/near/near.d.ts +3 -3
  32. package/lib/near/near.d.ts.map +1 -1
  33. package/lib/near/near.js +7 -5
  34. package/lib/options.d.ts +0 -3
  35. package/lib/options.d.ts.map +1 -1
  36. package/lib/options.js +2 -11
  37. package/lib/price-config.d.ts +1 -1
  38. package/lib/price-config.d.ts.map +1 -1
  39. package/lib/pyth-price-listener.d.ts +4 -5
  40. package/lib/pyth-price-listener.d.ts.map +1 -1
  41. package/lib/pyth-price-listener.js +30 -85
  42. package/lib/solana/command.d.ts +3 -2
  43. package/lib/solana/command.d.ts.map +1 -1
  44. package/lib/solana/command.js +39 -15
  45. package/lib/solana/solana.d.ts +8 -5
  46. package/lib/solana/solana.d.ts.map +1 -1
  47. package/lib/solana/solana.js +20 -10
  48. package/lib/sui/command.d.ts +0 -1
  49. package/lib/sui/command.d.ts.map +1 -1
  50. package/lib/sui/command.js +16 -13
  51. package/lib/sui/sui.d.ts +4 -4
  52. package/lib/sui/sui.d.ts.map +1 -1
  53. package/lib/sui/sui.js +11 -9
  54. package/lib/ton/command.d.ts +0 -1
  55. package/lib/ton/command.d.ts.map +1 -1
  56. package/lib/ton/command.js +15 -9
  57. package/lib/ton/ton.d.ts +3 -3
  58. package/lib/ton/ton.d.ts.map +1 -1
  59. package/lib/ton/ton.js +7 -4
  60. package/lib/utils.d.ts +6 -1
  61. package/lib/utils.d.ts.map +1 -1
  62. package/lib/utils.js +16 -0
  63. package/package.json +5 -6
@@ -62,16 +62,18 @@ class SolanaPriceListener extends interface_1.ChainPriceListener {
62
62
  exports.SolanaPriceListener = SolanaPriceListener;
63
63
  class SolanaPricePusher {
64
64
  pythSolanaReceiver;
65
- priceServiceConnection;
65
+ hermesClient;
66
66
  logger;
67
67
  shardId;
68
68
  computeUnitPriceMicroLamports;
69
- constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, computeUnitPriceMicroLamports) {
69
+ addressLookupTableAccount;
70
+ constructor(pythSolanaReceiver, hermesClient, logger, shardId, computeUnitPriceMicroLamports, addressLookupTableAccount) {
70
71
  this.pythSolanaReceiver = pythSolanaReceiver;
71
- this.priceServiceConnection = priceServiceConnection;
72
+ this.hermesClient = hermesClient;
72
73
  this.logger = logger;
73
74
  this.shardId = shardId;
74
75
  this.computeUnitPriceMicroLamports = computeUnitPriceMicroLamports;
76
+ this.addressLookupTableAccount = addressLookupTableAccount;
75
77
  }
76
78
  async updatePriceFeed(priceIds) {
77
79
  if (priceIds.length === 0) {
@@ -85,7 +87,10 @@ class SolanaPricePusher {
85
87
  .map((x) => x.element);
86
88
  let priceFeedUpdateData;
87
89
  try {
88
- priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(shuffledPriceIds);
90
+ const response = await this.hermesClient.getLatestPriceUpdates(shuffledPriceIds, {
91
+ encoding: "base64",
92
+ });
93
+ priceFeedUpdateData = response.binary.data;
89
94
  }
90
95
  catch (err) {
91
96
  this.logger.error(err, "getPriceFeedsUpdateData failed:");
@@ -93,7 +98,7 @@ class SolanaPricePusher {
93
98
  }
94
99
  const transactionBuilder = this.pythSolanaReceiver.newTransactionBuilder({
95
100
  closeUpdateAccounts: true,
96
- });
101
+ }, this.addressLookupTableAccount);
97
102
  await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData, this.shardId);
98
103
  const transactions = await transactionBuilder.buildVersionedTransactions({
99
104
  computeUnitPriceMicroLamports: this.computeUnitPriceMicroLamports,
@@ -112,7 +117,7 @@ class SolanaPricePusher {
112
117
  exports.SolanaPricePusher = SolanaPricePusher;
113
118
  class SolanaPricePusherJito {
114
119
  pythSolanaReceiver;
115
- priceServiceConnection;
120
+ hermesClient;
116
121
  logger;
117
122
  shardId;
118
123
  defaultJitoTipLamports;
@@ -121,9 +126,10 @@ class SolanaPricePusherJito {
121
126
  searcherClient;
122
127
  jitoBundleSize;
123
128
  updatesPerJitoBundle;
124
- constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, defaultJitoTipLamports, dynamicJitoTips, maxJitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle) {
129
+ addressLookupTableAccount;
130
+ constructor(pythSolanaReceiver, hermesClient, logger, shardId, defaultJitoTipLamports, dynamicJitoTips, maxJitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle, addressLookupTableAccount) {
125
131
  this.pythSolanaReceiver = pythSolanaReceiver;
126
- this.priceServiceConnection = priceServiceConnection;
132
+ this.hermesClient = hermesClient;
127
133
  this.logger = logger;
128
134
  this.shardId = shardId;
129
135
  this.defaultJitoTipLamports = defaultJitoTipLamports;
@@ -132,6 +138,7 @@ class SolanaPricePusherJito {
132
138
  this.searcherClient = searcherClient;
133
139
  this.jitoBundleSize = jitoBundleSize;
134
140
  this.updatesPerJitoBundle = updatesPerJitoBundle;
141
+ this.addressLookupTableAccount = addressLookupTableAccount;
135
142
  }
136
143
  async getRecentJitoTipLamports() {
137
144
  try {
@@ -160,7 +167,10 @@ class SolanaPricePusherJito {
160
167
  this.logger.info({ cappedJitoTip }, "using jito tip of");
161
168
  let priceFeedUpdateData;
162
169
  try {
163
- priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
170
+ const response = await this.hermesClient.getLatestPriceUpdates(priceIds, {
171
+ encoding: "base64",
172
+ });
173
+ priceFeedUpdateData = response.binary.data;
164
174
  }
165
175
  catch (err) {
166
176
  this.logger.error(err, "getPriceFeedsUpdateData failed");
@@ -169,7 +179,7 @@ class SolanaPricePusherJito {
169
179
  for (let i = 0; i < priceIds.length; i += this.updatesPerJitoBundle) {
170
180
  const transactionBuilder = this.pythSolanaReceiver.newTransactionBuilder({
171
181
  closeUpdateAccounts: true,
172
- });
182
+ }, this.addressLookupTableAccount);
173
183
  await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData.map((x) => {
174
184
  return (0, price_service_sdk_1.sliceAccumulatorUpdateData)(Buffer.from(x, "base64"), i, i + this.updatesPerJitoBundle).toString("base64");
175
185
  }), this.shardId);
@@ -4,7 +4,6 @@ declare const _default: {
4
4
  describe: string;
5
5
  builder: {
6
6
  "controller-log-level": Options;
7
- "price-service-connection-log-level": Options;
8
7
  "log-level": Options;
9
8
  "pushing-frequency": Options;
10
9
  "polling-frequency": Options;
@@ -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;;;;;;;;;;;;;kBAoBvB,OAAO;yBAOP,OAAO;6BAOP,OAAO;2BAMP,OAAO;8BAOP,OAAO;sBAMP,OAAO;yBAMP,OAAO;;oBAUiB,GAAG;;AAhEpC,wBAoJE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sui/command.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;kBAqBvB,OAAO;yBAOP,OAAO;6BAOP,OAAO;2BAMP,OAAO;8BAOP,OAAO;sBAMP,OAAO;yBAMP,OAAO;;oBASiB,GAAG;;AA/DpC,wBAsJE"}
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const price_service_client_1 = require("@pythnetwork/price-service-client");
29
+ const hermes_client_1 = require("@pythnetwork/hermes-client");
30
30
  const options = __importStar(require("../options"));
31
31
  const price_config_1 = require("../price-config");
32
32
  const fs_1 = __importDefault(require("fs"));
@@ -35,11 +35,12 @@ const controller_1 = require("../controller");
35
35
  const sui_1 = require("./sui");
36
36
  const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
37
37
  const pino_1 = __importDefault(require("pino"));
38
+ const utils_1 = require("../utils");
38
39
  exports.default = {
39
40
  command: "sui",
40
41
  describe: "Run price pusher for sui. Most of the arguments below are" +
41
42
  "network specific, so there's one set of values for mainnet and" +
42
- "another for testnet. See config.sui..sample.json for the " +
43
+ " another for testnet. See config.sui.mainnet.sample.json for the " +
43
44
  "appropriate values for your network. ",
44
45
  builder: {
45
46
  endpoint: {
@@ -91,28 +92,30 @@ exports.default = {
91
92
  ...options.pollingFrequency,
92
93
  ...options.pushingFrequency,
93
94
  ...options.logLevel,
94
- ...options.priceServiceConnectionLogLevel,
95
95
  ...options.controllerLogLevel,
96
96
  },
97
97
  handler: async function (argv) {
98
- const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, ignoreGasObjects, gasBudget, accountIndex, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
98
+ const { endpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pushingFrequency, pollingFrequency, pythStateId, wormholeStateId, numGasObjects, ignoreGasObjects, gasBudget, accountIndex, logLevel, controllerLogLevel, } = argv;
99
99
  const logger = (0, pino_1.default)({ level: logLevel });
100
100
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
101
- const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
102
- logger: logger.child({ module: "PriceServiceConnection" }, { level: priceServiceConnectionLogLevel }),
103
- priceFeedRequestConfig: {
104
- binary: true,
105
- },
106
- });
101
+ const hermesClient = new hermes_client_1.HermesClient(priceServiceEndpoint);
107
102
  const mnemonic = fs_1.default.readFileSync(mnemonicFile, "utf-8").trim();
108
103
  const keypair = ed25519_1.Ed25519Keypair.deriveKeypair(mnemonic, `m/44'/784'/${accountIndex}'/0'/0'`);
109
104
  logger.info(`Pushing updates from wallet address: ${keypair
110
105
  .getPublicKey()
111
106
  .toSuiAddress()}`);
112
- const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
113
- const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems, logger.child({ module: "PythPriceListener" }));
107
+ let priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
108
+ // Better to filter out invalid price items before creating the pyth listener
109
+ const { existingPriceItems, invalidPriceItems } = await (0, utils_1.filterInvalidPriceItems)(hermesClient, priceItems);
110
+ if (invalidPriceItems.length > 0) {
111
+ logger.error(`Invalid price id submitted for: ${invalidPriceItems
112
+ .map(({ alias }) => alias)
113
+ .join(", ")}`);
114
+ }
115
+ priceItems = existingPriceItems;
116
+ const pythListener = new pyth_price_listener_1.PythPriceListener(hermesClient, priceItems, logger.child({ module: "PythPriceListener" }));
114
117
  const suiListener = new sui_1.SuiPriceListener(pythStateId, wormholeStateId, endpoint, priceItems, logger.child({ module: "SuiPriceListener" }), { pollingFrequency });
115
- const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(priceServiceConnection, logger.child({ module: "SuiPricePusher" }), pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects, ignoreGasObjects);
118
+ const suiPusher = await sui_1.SuiPricePusher.createWithAutomaticGasPool(hermesClient, logger.child({ module: "SuiPricePusher" }), pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects, ignoreGasObjects);
116
119
  const controller = new controller_1.Controller(priceConfigs, pythListener, suiListener, suiPusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), { pushingFrequency });
117
120
  controller.start();
118
121
  },
package/lib/sui/sui.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
2
2
  import { DurationInSeconds } from "../utils";
3
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
4
3
  import { SuiPythClient } from "@pythnetwork/pyth-sui-js";
5
4
  import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
6
5
  import { SuiClient, SuiObjectRef } from "@mysten/sui/client";
7
6
  import { Logger } from "pino";
7
+ import { HermesClient } from "@pythnetwork/hermes-client";
8
8
  type ObjectId = string;
9
9
  export declare class SuiPriceListener extends ChainPriceListener {
10
10
  private pythClient;
@@ -33,11 +33,11 @@ export declare class SuiPricePusher implements IPricePusher {
33
33
  private readonly signer;
34
34
  private readonly provider;
35
35
  private logger;
36
- private priceServiceConnection;
36
+ private hermesClient;
37
37
  private gasBudget;
38
38
  private gasPool;
39
39
  private pythClient;
40
- constructor(signer: Ed25519Keypair, provider: SuiClient, logger: Logger, priceServiceConnection: PriceServiceConnection, gasBudget: number, gasPool: SuiObjectRef[], pythClient: SuiPythClient);
40
+ constructor(signer: Ed25519Keypair, provider: SuiClient, logger: Logger, hermesClient: HermesClient, gasBudget: number, gasPool: SuiObjectRef[], pythClient: SuiPythClient);
41
41
  /**
42
42
  * getPackageId returns the latest package id that the object belongs to. Use this to
43
43
  * fetch the latest package id for a given object id and handle package upgrades automatically.
@@ -50,7 +50,7 @@ export declare class SuiPricePusher implements IPricePusher {
50
50
  * Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
51
51
  * The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
52
52
  */
53
- static createWithAutomaticGasPool(priceServiceConnection: PriceServiceConnection, logger: Logger, pythStateId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, numGasObjects: number, ignoreGasObjects: string[]): Promise<SuiPricePusher>;
53
+ static createWithAutomaticGasPool(hermesClient: HermesClient, logger: Logger, pythStateId: string, wormholeStateId: string, endpoint: string, keypair: Ed25519Keypair, gasBudget: number, numGasObjects: number, ignoreGasObjects: string[]): Promise<SuiPricePusher>;
54
54
  updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
55
55
  /** Send every transaction in txs in parallel, returning when all transactions have completed. */
56
56
  private sendTransactionBlocks;
@@ -1 +1 @@
1
- {"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/sui/sui.ts"],"names":[],"mappings":"AAAA,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;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAO9B,KAAK,QAAQ,GAAG,MAAM,CAAC;AA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BAAa,cAAe,YAAW,YAAY;IAE/C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;gBAND,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,EAAE,EACvB,UAAU,EAAE,aAAa;IAGnC;;;;;;OAMG;WACU,YAAY,CACvB,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,QAAQ,CAAC;IAyBpB;;;OAGG;WACU,0BAA0B,CACrC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,cAAc,CAAC;IAkCpB,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;IA6ChB,iGAAiG;YACnF,qBAAqB;IAInC,sEAAsE;YACxD,oBAAoB;mBAyDb,iBAAiB;mBAsDjB,yBAAyB;mBAgBzB,cAAc;mBAiCd,mBAAmB;mBAwCnB,oBAAoB;CAiE1C"}
package/lib/sui/sui.js CHANGED
@@ -73,15 +73,15 @@ class SuiPricePusher {
73
73
  signer;
74
74
  provider;
75
75
  logger;
76
- priceServiceConnection;
76
+ hermesClient;
77
77
  gasBudget;
78
78
  gasPool;
79
79
  pythClient;
80
- constructor(signer, provider, logger, priceServiceConnection, gasBudget, gasPool, pythClient) {
80
+ constructor(signer, provider, logger, hermesClient, gasBudget, gasPool, pythClient) {
81
81
  this.signer = signer;
82
82
  this.provider = provider;
83
83
  this.logger = logger;
84
- this.priceServiceConnection = priceServiceConnection;
84
+ this.hermesClient = hermesClient;
85
85
  this.gasBudget = gasBudget;
86
86
  this.gasPool = gasPool;
87
87
  this.pythClient = pythClient;
@@ -118,14 +118,14 @@ class SuiPricePusher {
118
118
  * Create a price pusher with a pool of `numGasObjects` gas coins that will be used to send transactions.
119
119
  * The gas coins of the wallet for the provided keypair will be merged and then evenly split into `numGasObjects`.
120
120
  */
121
- static async createWithAutomaticGasPool(priceServiceConnection, logger, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects, ignoreGasObjects) {
121
+ static async createWithAutomaticGasPool(hermesClient, logger, pythStateId, wormholeStateId, endpoint, keypair, gasBudget, numGasObjects, ignoreGasObjects) {
122
122
  if (numGasObjects > MAX_NUM_OBJECTS_IN_ARGUMENT) {
123
123
  throw new Error(`numGasObjects cannot be greater than ${MAX_NUM_OBJECTS_IN_ARGUMENT} until we implement split chunking`);
124
124
  }
125
125
  const provider = new client_1.SuiClient({ url: endpoint });
126
126
  const gasPool = await SuiPricePusher.initializeGasPool(keypair, provider, numGasObjects, ignoreGasObjects, logger);
127
127
  const pythClient = new pyth_sui_js_1.SuiPythClient(provider, pythStateId, wormholeStateId);
128
- return new SuiPricePusher(keypair, provider, logger, priceServiceConnection, gasBudget, gasPool, pythClient);
128
+ return new SuiPricePusher(keypair, provider, logger, hermesClient, gasBudget, gasPool, pythClient);
129
129
  }
130
130
  async updatePriceFeed(priceIds, pubTimesToPush) {
131
131
  if (priceIds.length === 0) {
@@ -141,11 +141,13 @@ class SuiPricePusher {
141
141
  const priceIdChunks = chunkArray(priceIds, 3);
142
142
  const txBlocks = [];
143
143
  await Promise.all(priceIdChunks.map(async (priceIdChunk) => {
144
- const vaas = await this.priceServiceConnection.getLatestVaas(priceIdChunk);
145
- if (vaas.length !== 1) {
146
- throw new Error(`Expected a single VAA for all priceIds ${priceIdChunk} but received ${vaas.length} VAAs: ${vaas}`);
144
+ const response = await this.hermesClient.getLatestPriceUpdates(priceIdChunk, {
145
+ encoding: "base64",
146
+ });
147
+ if (response.binary.data.length !== 1) {
148
+ throw new Error(`Expected a single VAA for all priceIds ${priceIdChunk} but received ${response.binary.data.length} VAAs: ${response.binary.data}`);
147
149
  }
148
- const vaa = vaas[0];
150
+ const vaa = response.binary.data[0];
149
151
  const tx = new transactions_1.Transaction();
150
152
  await this.pythClient.updatePriceFeeds(tx, [Buffer.from(vaa, "base64")], priceIdChunk);
151
153
  txBlocks.push(tx);
@@ -4,7 +4,6 @@ declare const _default: {
4
4
  describe: string;
5
5
  builder: {
6
6
  "controller-log-level": Options;
7
- "price-service-connection-log-level": Options;
8
7
  "log-level": Options;
9
8
  "polling-frequency": Options;
10
9
  "pushing-frequency": Options;
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/ton/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;kBAmBvB,OAAO;4BAKP,OAAO;iCAKP,OAAO;;oBASiB,GAAG;;AA3BpC,wBA+FE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/ton/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;kBAoBvB,OAAO;4BAKP,OAAO;iCAKP,OAAO;;oBAQiB,GAAG;;AA1BpC,wBAmGE"}
@@ -28,13 +28,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const options = __importStar(require("../options"));
30
30
  const price_config_1 = require("../price-config");
31
- const price_service_client_1 = require("@pythnetwork/price-service-client");
32
31
  const pyth_price_listener_1 = require("../pyth-price-listener");
33
32
  const ton_1 = require("./ton");
34
33
  const controller_1 = require("../controller");
35
34
  const ton_2 = require("@ton/ton");
36
35
  const fs_1 = __importDefault(require("fs"));
37
36
  const pino_1 = __importDefault(require("pino"));
37
+ const hermes_client_1 = require("@pythnetwork/hermes-client");
38
+ const utils_1 = require("../utils");
38
39
  exports.default = {
39
40
  command: "ton",
40
41
  describe: "run price pusher for TON",
@@ -59,24 +60,29 @@ exports.default = {
59
60
  ...options.pushingFrequency,
60
61
  ...options.pollingFrequency,
61
62
  ...options.logLevel,
62
- ...options.priceServiceConnectionLogLevel,
63
63
  ...options.controllerLogLevel,
64
64
  },
65
65
  handler: async function (argv) {
66
- const { endpoint, privateKeyFile, pythContractAddress, priceConfigFile, priceServiceEndpoint, pushingFrequency, pollingFrequency, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
66
+ const { endpoint, privateKeyFile, pythContractAddress, priceConfigFile, priceServiceEndpoint, pushingFrequency, pollingFrequency, logLevel, controllerLogLevel, } = argv;
67
67
  const logger = (0, pino_1.default)({ level: logLevel });
68
68
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
69
- const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
70
- logger: logger.child({ module: "PriceServiceConnection" }, { level: priceServiceConnectionLogLevel }),
71
- });
72
- const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
73
- const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems, logger.child({ module: "PythPriceListener" }));
69
+ const hermesClient = new hermes_client_1.HermesClient(priceServiceEndpoint);
70
+ let priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
71
+ // Better to filter out invalid price items before creating the pyth listener
72
+ const { existingPriceItems, invalidPriceItems } = await (0, utils_1.filterInvalidPriceItems)(hermesClient, priceItems);
73
+ if (invalidPriceItems.length > 0) {
74
+ logger.error(`Invalid price id submitted for: ${invalidPriceItems
75
+ .map(({ alias }) => alias)
76
+ .join(", ")}`);
77
+ }
78
+ priceItems = existingPriceItems;
79
+ const pythListener = new pyth_price_listener_1.PythPriceListener(hermesClient, priceItems, logger.child({ module: "PythPriceListener" }));
74
80
  const client = new ton_2.TonClient({ endpoint });
75
81
  const privateKey = fs_1.default.readFileSync(privateKeyFile, "utf8").trim();
76
82
  const contractAddress = ton_2.Address.parse(pythContractAddress);
77
83
  const provider = client.provider(contractAddress);
78
84
  const tonPriceListener = new ton_1.TonPriceListener(provider, contractAddress, priceItems, logger.child({ module: "TonPriceListener" }), { pollingFrequency });
79
- const tonPricePusher = new ton_1.TonPricePusher(client, privateKey, contractAddress, priceServiceConnection, logger.child({ module: "TonPricePusher" }));
85
+ const tonPricePusher = new ton_1.TonPricePusher(client, privateKey, contractAddress, hermesClient, logger.child({ module: "TonPricePusher" }));
80
86
  const controller = new controller_1.Controller(priceConfigs, pythListener, tonPriceListener, tonPricePusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), { pushingFrequency });
81
87
  await controller.start();
82
88
  },
package/lib/ton/ton.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
1
+ import { HermesClient } from "@pythnetwork/hermes-client";
2
2
  import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
3
3
  import { DurationInSeconds } from "../utils";
4
4
  import { Logger } from "pino";
@@ -17,11 +17,11 @@ export declare class TonPricePusher implements IPricePusher {
17
17
  private client;
18
18
  private privateKey;
19
19
  private contractAddress;
20
- private priceServiceConnection;
20
+ private hermesClient;
21
21
  private logger;
22
22
  private contract;
23
23
  private sender;
24
- constructor(client: TonClient, privateKey: string, contractAddress: Address, priceServiceConnection: PriceServiceConnection, logger: Logger);
24
+ constructor(client: TonClient, privateKey: string, contractAddress: Address, hermesClient: HermesClient, logger: Logger);
25
25
  updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
26
26
  }
27
27
  //# sourceMappingURL=ton.d.ts.map
@@ -1 +1 @@
1
- {"version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AoCjB"}
package/lib/ton/ton.js CHANGED
@@ -40,15 +40,15 @@ class TonPricePusher {
40
40
  client;
41
41
  privateKey;
42
42
  contractAddress;
43
- priceServiceConnection;
43
+ hermesClient;
44
44
  logger;
45
45
  contract;
46
46
  sender;
47
- constructor(client, privateKey, contractAddress, priceServiceConnection, logger) {
47
+ constructor(client, privateKey, contractAddress, hermesClient, logger) {
48
48
  this.client = client;
49
49
  this.privateKey = privateKey;
50
50
  this.contractAddress = contractAddress;
51
- this.priceServiceConnection = priceServiceConnection;
51
+ this.hermesClient = hermesClient;
52
52
  this.logger = logger;
53
53
  this.contract = this.client
54
54
  .provider(this.contractAddress)
@@ -69,7 +69,10 @@ class TonPricePusher {
69
69
  }
70
70
  let priceFeedUpdateData;
71
71
  try {
72
- priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
72
+ const response = await this.hermesClient.getLatestPriceUpdates(priceIds, {
73
+ encoding: "base64",
74
+ });
75
+ priceFeedUpdateData = response.binary.data;
73
76
  }
74
77
  catch (err) {
75
78
  this.logger.error(err, "getPriceFeedsUpdateData failed");
package/lib/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { HexString } from "@pythnetwork/price-service-client";
1
+ import { HermesClient, HexString } from "@pythnetwork/hermes-client";
2
+ import { PriceItem } from "./interface";
2
3
  export type PctNumber = number;
3
4
  export type DurationInSeconds = number;
4
5
  export declare const txSpeeds: readonly ["slow", "standard", "fast"];
@@ -11,4 +12,8 @@ export declare const addLeading0x: (id: HexString) => `0x${string}`;
11
12
  export declare function isWsEndpoint(endpoint: string): boolean;
12
13
  export declare function verifyValidOption<options extends Readonly<Array<any>>, validOption extends options[number]>(option: any, validOptions: options): validOption;
13
14
  export declare const assertDefined: <T>(value: T | undefined) => T;
15
+ export declare function filterInvalidPriceItems(hermesClient: HermesClient, priceItems: PriceItem[]): Promise<{
16
+ existingPriceItems: PriceItem[];
17
+ invalidPriceItems: PriceItem[];
18
+ }>;
14
19
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACvC,eAAO,MAAM,QAAQ,uCAAwC,CAAC;AAC9D,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC9C,eAAO,MAAM,iBAAiB,gBAAiB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAKxD;AAED,eAAO,MAAM,YAAY,OAAQ,SAAS,KAAG,KAAK,MAAM,EACrB,CAAC;AAKpC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAStD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACpC,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,EACnC,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,GAEf,WAAW,CAK/B;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,CAAC,GAAG,SAAS,KAAG,CAMvD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACvC,eAAO,MAAM,QAAQ,uCAAwC,CAAC;AAC9D,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC9C,eAAO,MAAM,iBAAiB,gBAAiB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,SAAS,CAKxD;AAED,eAAO,MAAM,YAAY,OAAQ,SAAS,KAAG,KAAK,MAAM,EACrB,CAAC;AAKpC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAStD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACpC,WAAW,SAAS,OAAO,CAAC,MAAM,CAAC,EACnC,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,GAEf,WAAW,CAK/B;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,CAAC,GAAG,SAAS,KAAG,CAMvD,CAAC;AAEF,wBAAsB,uBAAuB,CAC3C,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,SAAS,EAAE,GACtB,OAAO,CAAC;IACT,kBAAkB,EAAE,SAAS,EAAE,CAAC;IAChC,iBAAiB,EAAE,SAAS,EAAE,CAAC;CAChC,CAAC,CAqBD"}
package/lib/utils.js CHANGED
@@ -5,6 +5,7 @@ exports.sleep = sleep;
5
5
  exports.removeLeading0x = removeLeading0x;
6
6
  exports.isWsEndpoint = isWsEndpoint;
7
7
  exports.verifyValidOption = verifyValidOption;
8
+ exports.filterInvalidPriceItems = filterInvalidPriceItems;
8
9
  exports.txSpeeds = ["slow", "standard", "fast"];
9
10
  exports.customGasChainIds = [137];
10
11
  async function sleep(ms) {
@@ -43,3 +44,18 @@ const assertDefined = (value) => {
43
44
  }
44
45
  };
45
46
  exports.assertDefined = assertDefined;
47
+ async function filterInvalidPriceItems(hermesClient, priceItems) {
48
+ const priceMetadata = await hermesClient.getPriceFeeds();
49
+ const allPriceIds = priceMetadata.map((priceMetadata) => priceMetadata.id);
50
+ // Filter out invalid price ids
51
+ const { existingPriceItems, invalidPriceItems } = priceItems.reduce((acc, item) => {
52
+ if (allPriceIds.includes(item.id)) {
53
+ acc.existingPriceItems.push(item);
54
+ }
55
+ else {
56
+ acc.invalidPriceItems.push(item);
57
+ }
58
+ return acc;
59
+ }, { existingPriceItems: [], invalidPriceItems: [] });
60
+ return { existingPriceItems, invalidPriceItems };
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/price-pusher",
3
- "version": "8.3.3",
3
+ "version": "9.0.1",
4
4
  "description": "Pyth Price Pusher",
5
5
  "homepage": "https://pyth.network",
6
6
  "main": "lib/index.js",
@@ -24,7 +24,6 @@
24
24
  "format": "prettier --write \"src/**/*.ts\"",
25
25
  "test:lint": "eslint src/",
26
26
  "start": "node lib/index.js",
27
- "test": "jest",
28
27
  "dev": "ts-node src/index.ts",
29
28
  "prepublishOnly": "pnpm run build && pnpm run test:lint",
30
29
  "preversion": "pnpm run test:lint",
@@ -61,14 +60,14 @@
61
60
  "@injectivelabs/networks": "^1.14.6",
62
61
  "@injectivelabs/sdk-ts": "1.10.72",
63
62
  "@mysten/sui": "^1.3.0",
64
- "@pythnetwork/price-service-client": "1.9.0",
63
+ "@pythnetwork/hermes-client": "^1.3.1",
65
64
  "@pythnetwork/price-service-sdk": "^1.8.0",
66
65
  "@pythnetwork/pyth-fuel-js": "1.0.7",
67
66
  "@pythnetwork/pyth-sdk-solidity": "4.0.0",
68
- "@pythnetwork/pyth-solana-receiver": "0.9.1",
67
+ "@pythnetwork/pyth-solana-receiver": "0.10.0",
69
68
  "@pythnetwork/pyth-sui-js": "2.1.0",
70
69
  "@pythnetwork/pyth-ton-js": "0.1.2",
71
- "@pythnetwork/solana-utils": "0.4.3",
70
+ "@pythnetwork/solana-utils": "0.4.4",
72
71
  "@solana/web3.js": "^1.93.0",
73
72
  "@ton/crypto": "^3.3.0",
74
73
  "@ton/ton": "^15.1.0",
@@ -83,5 +82,5 @@
83
82
  "yaml": "^2.1.1",
84
83
  "yargs": "^17.5.1"
85
84
  },
86
- "gitHead": "707437af791b9b111f976eb45b958639f90a2e20"
85
+ "gitHead": "4bd2adacc4d30b0899492026c7071d5d5007bb3b"
87
86
  }