@pythnetwork/price-pusher 8.3.2 → 9.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.
Files changed (66) 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/custom-gas-station.js +2 -2
  12. package/lib/evm/evm.d.ts +3 -3
  13. package/lib/evm/evm.d.ts.map +1 -1
  14. package/lib/evm/evm.js +13 -9
  15. package/lib/evm/super-wallet.d.ts.map +1 -1
  16. package/lib/fuel/command.d.ts +0 -1
  17. package/lib/fuel/command.d.ts.map +1 -1
  18. package/lib/fuel/command.js +15 -9
  19. package/lib/fuel/fuel.d.ts +3 -3
  20. package/lib/fuel/fuel.d.ts.map +1 -1
  21. package/lib/fuel/fuel.js +8 -5
  22. package/lib/injective/command.d.ts +1 -2
  23. package/lib/injective/command.d.ts.map +1 -1
  24. package/lib/injective/command.js +16 -10
  25. package/lib/injective/injective.d.ts +3 -3
  26. package/lib/injective/injective.d.ts.map +1 -1
  27. package/lib/injective/injective.js +7 -4
  28. package/lib/interface.d.ts +1 -1
  29. package/lib/interface.d.ts.map +1 -1
  30. package/lib/near/command.d.ts +1 -2
  31. package/lib/near/command.d.ts.map +1 -1
  32. package/lib/near/command.js +16 -10
  33. package/lib/near/near.d.ts +3 -3
  34. package/lib/near/near.d.ts.map +1 -1
  35. package/lib/near/near.js +7 -5
  36. package/lib/options.d.ts +0 -3
  37. package/lib/options.d.ts.map +1 -1
  38. package/lib/options.js +2 -11
  39. package/lib/price-config.d.ts +1 -1
  40. package/lib/price-config.d.ts.map +1 -1
  41. package/lib/price-config.js +3 -3
  42. package/lib/pyth-price-listener.d.ts +6 -5
  43. package/lib/pyth-price-listener.d.ts.map +1 -1
  44. package/lib/pyth-price-listener.js +39 -32
  45. package/lib/solana/command.d.ts +1 -2
  46. package/lib/solana/command.d.ts.map +1 -1
  47. package/lib/solana/command.js +20 -14
  48. package/lib/solana/solana.d.ts +5 -5
  49. package/lib/solana/solana.d.ts.map +1 -1
  50. package/lib/solana/solana.js +14 -8
  51. package/lib/sui/command.d.ts +0 -1
  52. package/lib/sui/command.d.ts.map +1 -1
  53. package/lib/sui/command.js +16 -13
  54. package/lib/sui/sui.d.ts +4 -4
  55. package/lib/sui/sui.d.ts.map +1 -1
  56. package/lib/sui/sui.js +11 -9
  57. package/lib/ton/command.d.ts +0 -1
  58. package/lib/ton/command.d.ts.map +1 -1
  59. package/lib/ton/command.js +15 -9
  60. package/lib/ton/ton.d.ts +3 -3
  61. package/lib/ton/ton.d.ts.map +1 -1
  62. package/lib/ton/ton.js +7 -4
  63. package/lib/utils.d.ts +6 -1
  64. package/lib/utils.d.ts.map +1 -1
  65. package/lib/utils.js +21 -5
  66. package/package.json +4 -4
@@ -39,15 +39,15 @@ class InjectivePriceListener extends interface_1.ChainPriceListener {
39
39
  }
40
40
  exports.InjectivePriceListener = InjectivePriceListener;
41
41
  class InjectivePricePusher {
42
- priceServiceConnection;
42
+ hermesClient;
43
43
  pythContractAddress;
44
44
  grpcEndpoint;
45
45
  logger;
46
46
  wallet;
47
47
  chainConfig;
48
48
  account = null;
49
- constructor(priceServiceConnection, pythContractAddress, grpcEndpoint, logger, mnemonic, chainConfig) {
50
- this.priceServiceConnection = priceServiceConnection;
49
+ constructor(hermesClient, pythContractAddress, grpcEndpoint, logger, mnemonic, chainConfig) {
50
+ this.hermesClient = hermesClient;
51
51
  this.pythContractAddress = pythContractAddress;
52
52
  this.grpcEndpoint = grpcEndpoint;
53
53
  this.logger = logger;
@@ -116,7 +116,10 @@ class InjectivePricePusher {
116
116
  }
117
117
  }
118
118
  async getPriceFeedUpdateObject(priceIds) {
119
- const vaas = await this.priceServiceConnection.getLatestVaas(priceIds);
119
+ const response = await this.hermesClient.getLatestPriceUpdates(priceIds, {
120
+ encoding: "base64",
121
+ });
122
+ const vaas = response.binary.data;
120
123
  return {
121
124
  update_price_feeds: {
122
125
  data: vaas,
@@ -1,4 +1,4 @@
1
- import { HexString, UnixTimestamp } from "@pythnetwork/price-service-client";
1
+ import { HexString, UnixTimestamp } from "@pythnetwork/hermes-client";
2
2
  import { DurationInSeconds } from "./utils";
3
3
  export type PriceItem = {
4
4
  id: HexString;
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,SAAS,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,cAAc;IAE7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CAC5D;AAED,8BAAsB,kBAAmB,YAAW,cAAc;IAK9D,OAAO,CAAC,gBAAgB;IACxB,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE;IALnC,OAAO,CAAC,eAAe,CAA4B;IACnD,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBAGvC,gBAAgB,EAAE,iBAAiB,EACjC,UAAU,EAAE,SAAS,EAAE;IAQ7B,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;IAQ7B,KAAK;YAMG,UAAU;IASxB,SAAS,CAAC,qBAAqB,CAC7B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,SAAS;IAkB1B,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI1D,QAAQ,CAAC,mBAAmB,CAC1B,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,eAAe,CACb,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,aAAa,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB"}
@@ -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;
@@ -16,7 +15,7 @@ declare const _default: {
16
15
  "account-id": Options;
17
16
  "private-key-path": Options;
18
17
  };
19
- handler: (argv: any) => void;
18
+ handler: (argv: any) => Promise<void>;
20
19
  };
21
20
  export default _default;
22
21
  //# sourceMappingURL=command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/near/command.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;oBAsCL,GAAG;;AAlC9B,wBA0GE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/near/command.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;oBAcvB,OAAO;iBAKP,OAAO;sBAKP,OAAO;4BAKP,OAAO;;oBASiB,GAAG;;AAjCpC,wBA8GE"}
@@ -26,13 +26,14 @@ 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 pyth_price_listener_1 = require("../pyth-price-listener");
33
33
  const controller_1 = require("../controller");
34
34
  const near_1 = require("./near");
35
35
  const pino_1 = __importDefault(require("pino"));
36
+ const utils_1 = require("../utils");
36
37
  exports.default = {
37
38
  command: "near",
38
39
  describe: "run price pusher for near",
@@ -63,24 +64,29 @@ exports.default = {
63
64
  ...options.pollingFrequency,
64
65
  ...options.pushingFrequency,
65
66
  ...options.logLevel,
66
- ...options.priceServiceConnectionLogLevel,
67
67
  ...options.controllerLogLevel,
68
68
  },
69
- handler: function (argv) {
69
+ handler: async function (argv) {
70
70
  // FIXME: type checks for this
71
- const { nodeUrl, network, accountId, privateKeyPath, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
71
+ const { nodeUrl, network, accountId, privateKeyPath, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, logLevel, controllerLogLevel, } = argv;
72
72
  const logger = (0, pino_1.default)({ level: logLevel });
73
73
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
74
- const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
75
- logger: logger.child({ module: "PriceServiceConnection" }, { level: priceServiceConnectionLogLevel }),
76
- });
77
- const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
78
- const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems, logger);
74
+ const hermesClient = new hermes_client_1.HermesClient(priceServiceEndpoint);
75
+ let priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
76
+ // Better to filter out invalid price items before creating the pyth listener
77
+ const { existingPriceItems, invalidPriceItems } = await (0, utils_1.filterInvalidPriceItems)(hermesClient, priceItems);
78
+ if (invalidPriceItems.length > 0) {
79
+ logger.error(`Invalid price id submitted for: ${invalidPriceItems
80
+ .map(({ alias }) => alias)
81
+ .join(", ")}`);
82
+ }
83
+ priceItems = existingPriceItems;
84
+ const pythListener = new pyth_price_listener_1.PythPriceListener(hermesClient, priceItems, logger);
79
85
  const nearAccount = new near_1.NearAccount(network, accountId, nodeUrl, privateKeyPath, pythContractAddress);
80
86
  const nearListener = new near_1.NearPriceListener(nearAccount, priceItems, logger.child({ module: "NearPriceListener" }), {
81
87
  pollingFrequency,
82
88
  });
83
- const nearPusher = new near_1.NearPricePusher(nearAccount, priceServiceConnection, logger.child({ module: "NearPricePusher" }));
89
+ const nearPusher = new near_1.NearPricePusher(nearAccount, hermesClient, logger.child({ module: "NearPricePusher" }));
84
90
  const controller = new controller_1.Controller(priceConfigs, pythListener, nearListener, nearPusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), { pushingFrequency });
85
91
  controller.start();
86
92
  },
@@ -1,5 +1,5 @@
1
1
  import { IPricePusher, PriceInfo, ChainPriceListener, PriceItem } from "../interface";
2
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
2
+ import { HermesClient } from "@pythnetwork/hermes-client";
3
3
  import { DurationInSeconds } from "../utils";
4
4
  import { FinalExecutionOutcome } from "near-api-js/lib/providers/provider";
5
5
  import { Logger } from "pino";
@@ -13,9 +13,9 @@ export declare class NearPriceListener extends ChainPriceListener {
13
13
  }
14
14
  export declare class NearPricePusher implements IPricePusher {
15
15
  private account;
16
- private connection;
16
+ private hermesClient;
17
17
  private logger;
18
- constructor(account: NearAccount, connection: PriceServiceConnection, logger: Logger);
18
+ constructor(account: NearAccount, hermesClient: HermesClient, logger: Logger);
19
19
  updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
20
20
  private getPriceFeedsUpdateData;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"near.d.ts","sourceRo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AO,CAAU;gBAGvB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM;IAWzB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAU7C,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAUhD,gBAAgB,CACpB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,qBAAqB,CAAC;IAYjC,OAAO,CAAC,aAAa;CAkCtB"}
package/lib/near/near.js CHANGED
@@ -42,11 +42,11 @@ class NearPriceListener extends interface_1.ChainPriceListener {
42
42
  exports.NearPriceListener = NearPriceListener;
43
43
  class NearPricePusher {
44
44
  account;
45
- connection;
45
+ hermesClient;
46
46
  logger;
47
- constructor(account, connection, logger) {
47
+ constructor(account, hermesClient, logger) {
48
48
  this.account = account;
49
- this.connection = connection;
49
+ this.hermesClient = hermesClient;
50
50
  this.logger = logger;
51
51
  }
52
52
  async updatePriceFeed(priceIds, pubTimesToPush) {
@@ -96,8 +96,10 @@ class NearPricePusher {
96
96
  }
97
97
  }
98
98
  async getPriceFeedsUpdateData(priceIds) {
99
- const latestVaas = await this.connection.getLatestVaas(priceIds);
100
- return latestVaas.map((vaa) => Buffer.from(vaa, "base64").toString("hex"));
99
+ const response = await this.hermesClient.getLatestPriceUpdates(priceIds, {
100
+ encoding: "base64",
101
+ });
102
+ return response.binary.data;
101
103
  }
102
104
  }
103
105
  exports.NearPricePusher = NearPricePusher;
package/lib/options.d.ts CHANGED
@@ -20,9 +20,6 @@ export declare const mnemonicFile: {
20
20
  export declare const logLevel: {
21
21
  "log-level": Options;
22
22
  };
23
- export declare const priceServiceConnectionLogLevel: {
24
- "price-service-connection-log-level": Options;
25
- };
26
23
  export declare const controllerLogLevel: {
27
24
  "controller-log-level": Options;
28
25
  };
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,eAAO,MAAM,oBAAoB;;CAOhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAQ/B,CAAC;AAEF,eAAO,MAAM,eAAe;;CAM3B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;CAQ5B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;CAU5B,CAAC;AAEF,eAAO,MAAM,YAAY;;CAMxB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAQpB,CAAC;AAEF,eAAO,MAAM,8BAA8B;;CAQ1C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAQ9B,CAAC"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,eAAO,MAAM,oBAAoB;8BAM1B,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,mBAAmB;6BAOzB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,eAAe;yBAKrB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,gBAAgB;yBAOtB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,gBAAgB;yBAStB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,YAAY;qBAKlB,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,QAAQ;iBAOd,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,kBAAkB;4BAOxB,OAAO;CACb,CAAC"}
package/lib/options.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.controllerLogLevel = exports.priceServiceConnectionLogLevel = exports.logLevel = exports.mnemonicFile = exports.pushingFrequency = exports.pollingFrequency = exports.priceConfigFile = exports.pythContractAddress = exports.priceServiceEndpoint = void 0;
3
+ exports.controllerLogLevel = exports.logLevel = exports.mnemonicFile = exports.pushingFrequency = exports.pollingFrequency = exports.priceConfigFile = exports.pythContractAddress = exports.priceServiceEndpoint = void 0;
4
4
  exports.priceServiceEndpoint = {
5
5
  "price-service-endpoint": {
6
- description: "Endpoint URL for the price service. e.g: https://endpoint/example",
6
+ description: "Endpoint URL for the hermes client. e.g: https://endpoint/example",
7
7
  type: "string",
8
8
  required: true,
9
9
  },
@@ -57,15 +57,6 @@ exports.logLevel = {
57
57
  choices: ["trace", "debug", "info", "warn", "error"],
58
58
  },
59
59
  };
60
- exports.priceServiceConnectionLogLevel = {
61
- "price-service-connection-log-level": {
62
- description: "Log level for the price service connection.",
63
- type: "string",
64
- required: false,
65
- default: "warn",
66
- choices: ["trace", "debug", "info", "warn", "error"],
67
- },
68
- };
69
60
  exports.controllerLogLevel = {
70
61
  "controller-log-level": {
71
62
  description: "Log level for the controller.",
@@ -1,4 +1,4 @@
1
- import { HexString } from "@pythnetwork/price-service-client";
1
+ import { HexString } from "@pythnetwork/hermes-client";
2
2
  import { Logger } from "pino";
3
3
  import { DurationInSeconds, PctNumber } from "./utils";
4
4
  import { PriceInfo } from "./interface";
@@ -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,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,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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AG,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,EACxC,MAAM,EAAE,MAAM,GACb,eAAe,CAkEjB"}
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.shouldUpdate = exports.UpdateCondition = exports.readPriceConfigFile = void 0;
6
+ exports.UpdateCondition = void 0;
7
+ exports.readPriceConfigFile = readPriceConfigFile;
8
+ exports.shouldUpdate = shouldUpdate;
7
9
  const joi_1 = __importDefault(require("joi"));
8
10
  const yaml_1 = __importDefault(require("yaml"));
9
11
  const fs_1 = __importDefault(require("fs"));
@@ -47,7 +49,6 @@ function readPriceConfigFile(path) {
47
49
  return priceConfig;
48
50
  });
49
51
  }
50
- exports.readPriceConfigFile = readPriceConfigFile;
51
52
  var UpdateCondition;
52
53
  (function (UpdateCondition) {
53
54
  // This price feed must be updated
@@ -106,4 +107,3 @@ function shouldUpdate(priceConfig, sourceLatestPrice, targetLatestPrice, logger)
106
107
  return UpdateCondition.NO;
107
108
  }
108
109
  }
109
- exports.shouldUpdate = shouldUpdate;
@@ -1,16 +1,17 @@
1
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
1
+ import { HexString, HermesClient } from "@pythnetwork/hermes-client";
2
2
  import { PriceInfo, IPriceListener, PriceItem } from "./interface";
3
3
  import { Logger } from "pino";
4
4
  export declare class PythPriceListener implements IPriceListener {
5
- private connection;
5
+ private hermesClient;
6
6
  private priceIds;
7
7
  private priceIdToAlias;
8
8
  private latestPriceInfo;
9
9
  private logger;
10
10
  private lastUpdated;
11
- constructor(connection: PriceServiceConnection, priceItems: PriceItem[], logger: Logger);
11
+ private healthCheckInterval?;
12
+ constructor(hermesClient: HermesClient, priceItems: PriceItem[], logger: Logger);
12
13
  start(): Promise<void>;
13
- private onNewPriceFeed;
14
- getLatestPriceInfo(priceId: string): PriceInfo | undefined;
14
+ getLatestPriceInfo(priceId: HexString): PriceInfo | undefined;
15
+ cleanup(): void;
15
16
  }
16
17
  //# sourceMappingURL=pyth-price-listener.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pyth-price-listener.d.ts","sourceRoot":"","sources":["../src/pyth-price-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAI9B,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAA4B;gBAG7C,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM;IAaV,KAAK;IA8BX,OAAO,CAAC,cAAc;IAuBtB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAG3D"}
1
+ {"version":3,"file":"pyth-price-listener.d.ts","sourceRoot":"","sources":["../src/pyth-price-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EAEb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAI9B,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,mBAAmB,CAAC,CAAiB;gBAG3C,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM;IAaV,KAAK;IAsDX,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS;IAI7D,OAAO;CAKR"}
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PythPriceListener = void 0;
4
4
  class PythPriceListener {
5
- connection;
5
+ hermesClient;
6
6
  priceIds;
7
7
  priceIdToAlias;
8
8
  latestPriceInfo;
9
9
  logger;
10
10
  lastUpdated;
11
- constructor(connection, priceItems, logger) {
12
- this.connection = connection;
11
+ healthCheckInterval;
12
+ constructor(hermesClient, priceItems, logger) {
13
+ this.hermesClient = hermesClient;
13
14
  this.priceIds = priceItems.map((priceItem) => priceItem.id);
14
15
  this.priceIdToAlias = new Map(priceItems.map((priceItem) => [priceItem.id, priceItem.alias]));
15
16
  this.latestPriceInfo = new Map();
@@ -18,44 +19,50 @@ class PythPriceListener {
18
19
  // This method should be awaited on and once it finishes it has the latest value
19
20
  // for the given price feeds (if they exist).
20
21
  async start() {
21
- this.connection.subscribePriceFeedUpdates(this.priceIds, this.onNewPriceFeed.bind(this));
22
- const priceFeeds = await this.connection.getLatestPriceFeeds(this.priceIds);
23
- priceFeeds?.forEach((priceFeed) => {
24
- // Getting unchecked because although it might be old
25
- // but might not be there on the target chain.
26
- const latestAvailablePrice = priceFeed.getPriceUnchecked();
27
- this.latestPriceInfo.set(priceFeed.id, {
28
- price: latestAvailablePrice.price,
29
- conf: latestAvailablePrice.conf,
30
- publishTime: latestAvailablePrice.publishTime,
31
- });
22
+ const eventSource = await this.hermesClient.getPriceUpdatesStream(this.priceIds, {
23
+ parsed: true,
24
+ ignoreInvalidPriceIds: true,
32
25
  });
33
- // Check health of the price feeds 5 second. If the price feeds are not updating
34
- // for more than 30s, throw an error.
35
- setInterval(() => {
26
+ eventSource.onmessage = (event) => {
27
+ const priceUpdates = JSON.parse(event.data);
28
+ priceUpdates.parsed?.forEach((priceUpdate) => {
29
+ this.logger.debug(`Received new price feed update from Pyth price service: ${this.priceIdToAlias.get(priceUpdate.id)} ${priceUpdate.id}`);
30
+ // Consider price to be currently available if it is not older than 60s
31
+ const currentPrice = Date.now() / 1000 - priceUpdate.price.publish_time > 60
32
+ ? undefined
33
+ : priceUpdate.price;
34
+ if (currentPrice === undefined) {
35
+ this.logger.debug("Price is older than 60s, skipping");
36
+ return;
37
+ }
38
+ const priceInfo = {
39
+ conf: currentPrice.conf,
40
+ price: currentPrice.price,
41
+ publishTime: currentPrice.publish_time,
42
+ };
43
+ this.latestPriceInfo.set(priceUpdate.id, priceInfo);
44
+ this.lastUpdated = Date.now();
45
+ });
46
+ };
47
+ eventSource.onerror = (error) => {
48
+ console.error("Error receiving updates from Hermes:", error);
49
+ eventSource.close();
50
+ };
51
+ // Store health check interval reference
52
+ this.healthCheckInterval = setInterval(() => {
36
53
  if (this.lastUpdated === undefined ||
37
54
  this.lastUpdated < Date.now() - 30 * 1000) {
38
55
  throw new Error("Hermes Price feeds are not updating.");
39
56
  }
40
57
  }, 5000);
41
58
  }
42
- onNewPriceFeed(priceFeed) {
43
- this.logger.debug(`Received new price feed update from Pyth price service: ${this.priceIdToAlias.get(priceFeed.id)} ${priceFeed.id}`);
44
- // Consider price to be currently available if it is not older than 60s
45
- const currentPrice = priceFeed.getPriceNoOlderThan(60);
46
- if (currentPrice === undefined) {
47
- return;
48
- }
49
- const priceInfo = {
50
- conf: currentPrice.conf,
51
- price: currentPrice.price,
52
- publishTime: currentPrice.publishTime,
53
- };
54
- this.latestPriceInfo.set(priceFeed.id, priceInfo);
55
- this.lastUpdated = Date.now();
56
- }
57
59
  getLatestPriceInfo(priceId) {
58
60
  return this.latestPriceInfo.get(priceId);
59
61
  }
62
+ cleanup() {
63
+ if (this.healthCheckInterval) {
64
+ clearInterval(this.healthCheckInterval);
65
+ }
66
+ }
60
67
  }
61
68
  exports.PythPriceListener = PythPriceListener;
@@ -6,7 +6,6 @@ declare const _default: {
6
6
  describe: string;
7
7
  builder: {
8
8
  "controller-log-level": Options;
9
- "price-service-connection-log-level": Options;
10
9
  "log-level": Options;
11
10
  "pushing-frequency": Options;
12
11
  "polling-frequency": Options;
@@ -25,7 +24,7 @@ declare const _default: {
25
24
  "jito-bundle-size": Options;
26
25
  "updates-per-jito-bundle": Options;
27
26
  };
28
- handler: (argv: any) => void;
27
+ handler: (argv: any) => Promise<void>;
29
28
  };
30
29
  export default _default;
31
30
  export declare const onBundleResult: (c: SearcherClient, logger: Logger) => void;
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;oBAuEH,GAAG;;AArE9B,wBAgLE;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;AAehC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;kBAWrB,OAAO;wBAKP,OAAO;oBAKP,OAAO;6CAKP,OAAO;yBAKP,OAAO;6BAMP,OAAO;6BAKP,OAAO;6BAKP,OAAO;iCAKP,OAAO;4BAKP,OAAO;mCAKP,OAAO;;oBASiB,GAAG;;AApEpC,wBAoLE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
@@ -29,7 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.onBundleResult = void 0;
30
30
  const options = __importStar(require("../options"));
31
31
  const price_config_1 = require("../price-config");
32
- const price_service_client_1 = require("@pythnetwork/price-service-client");
33
32
  const pyth_price_listener_1 = require("../pyth-price-listener");
34
33
  const solana_1 = require("./solana");
35
34
  const controller_1 = require("../controller");
@@ -40,6 +39,8 @@ const fs_1 = __importDefault(require("fs"));
40
39
  const web3_js_2 = require("@solana/web3.js");
41
40
  const searcher_1 = require("jito-ts/dist/sdk/block-engine/searcher");
42
41
  const pino_1 = __importDefault(require("pino"));
42
+ const hermes_client_1 = require("@pythnetwork/hermes-client");
43
+ const utils_1 = require("../utils");
43
44
  exports.default = {
44
45
  command: "solana",
45
46
  describe: "run price pusher for solana",
@@ -90,12 +91,12 @@ exports.default = {
90
91
  default: web3_js_1.LAMPORTS_PER_SOL / 100,
91
92
  },
92
93
  "jito-bundle-size": {
93
- description: "Number of transactions in each bundle",
94
+ description: "Number of transactions in each Jito bundle",
94
95
  type: "number",
95
- default: 2,
96
+ default: 5,
96
97
  },
97
98
  "updates-per-jito-bundle": {
98
- description: "Number of transactions in each bundle",
99
+ description: "Number of price updates in each Jito bundle",
99
100
  type: "number",
100
101
  default: 6,
101
102
  },
@@ -105,18 +106,23 @@ exports.default = {
105
106
  ...options.pollingFrequency,
106
107
  ...options.pushingFrequency,
107
108
  ...options.logLevel,
108
- ...options.priceServiceConnectionLogLevel,
109
109
  ...options.controllerLogLevel,
110
110
  },
111
- handler: function (argv) {
112
- const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, jitoBundleSize, updatesPerJitoBundle, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
111
+ handler: async function (argv) {
112
+ const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, jitoBundleSize, updatesPerJitoBundle, logLevel, controllerLogLevel, } = argv;
113
113
  const logger = (0, pino_1.default)({ level: logLevel });
114
114
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
115
- const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
116
- logger: logger.child({ module: "PriceServiceConnection" }, { level: priceServiceConnectionLogLevel }),
117
- });
118
- const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
119
- const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems, logger.child({ module: "PythPriceListener" }));
115
+ const hermesClient = new hermes_client_1.HermesClient(priceServiceEndpoint);
116
+ let priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
117
+ // Better to filter out invalid price items before creating the pyth listener
118
+ const { existingPriceItems, invalidPriceItems } = await (0, utils_1.filterInvalidPriceItems)(hermesClient, priceItems);
119
+ if (invalidPriceItems.length > 0) {
120
+ logger.error(`Invalid price id submitted for: ${invalidPriceItems
121
+ .map(({ alias }) => alias)
122
+ .join(", ")}`);
123
+ }
124
+ priceItems = existingPriceItems;
125
+ const pythListener = new pyth_price_listener_1.PythPriceListener(hermesClient, priceItems, logger.child({ module: "PythPriceListener" }));
120
126
  const wallet = new nodewallet_1.default(web3_js_1.Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs_1.default.readFileSync(keypairFile, "ascii")))));
121
127
  const pythSolanaReceiver = new pyth_solana_receiver_1.PythSolanaReceiver({
122
128
  connection: new web3_js_1.Connection(endpoint, "processed"),
@@ -127,11 +133,11 @@ exports.default = {
127
133
  if (jitoTipLamports) {
128
134
  const jitoKeypair = web3_js_1.Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs_1.default.readFileSync(jitoKeypairFile, "ascii"))));
129
135
  const jitoClient = (0, searcher_1.searcherClient)(jitoEndpoint, jitoKeypair);
130
- solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, priceServiceConnection, logger.child({ module: "SolanaPricePusherJito" }), shardId, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, jitoClient, jitoBundleSize, updatesPerJitoBundle);
136
+ solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, hermesClient, logger.child({ module: "SolanaPricePusherJito" }), shardId, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, jitoClient, jitoBundleSize, updatesPerJitoBundle);
131
137
  (0, exports.onBundleResult)(jitoClient, logger.child({ module: "JitoClient" }));
132
138
  }
133
139
  else {
134
- solanaPricePusher = new solana_1.SolanaPricePusher(pythSolanaReceiver, priceServiceConnection, logger.child({ module: "SolanaPricePusher" }), shardId, computeUnitPriceMicroLamports);
140
+ solanaPricePusher = new solana_1.SolanaPricePusher(pythSolanaReceiver, hermesClient, logger.child({ module: "SolanaPricePusher" }), shardId, computeUnitPriceMicroLamports);
135
141
  }
136
142
  const solanaPriceListener = new solana_1.SolanaPriceListener(pythSolanaReceiver, shardId, priceItems, logger.child({ module: "SolanaPriceListener" }), { pollingFrequency });
137
143
  const controller = new controller_1.Controller(priceConfigs, pythListener, solanaPriceListener, solanaPricePusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), { pushingFrequency });
@@ -1,7 +1,7 @@
1
1
  import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
2
2
  import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
3
3
  import { DurationInSeconds } from "../utils";
4
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
4
+ import { HermesClient } from "@pythnetwork/hermes-client";
5
5
  import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
6
6
  import { Logger } from "pino";
7
7
  export declare class SolanaPriceListener extends ChainPriceListener {
@@ -17,16 +17,16 @@ export declare class SolanaPriceListener extends ChainPriceListener {
17
17
  }
18
18
  export declare class SolanaPricePusher implements IPricePusher {
19
19
  private pythSolanaReceiver;
20
- private priceServiceConnection;
20
+ private hermesClient;
21
21
  private logger;
22
22
  private shardId;
23
23
  private computeUnitPriceMicroLamports;
24
- constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, logger: Logger, shardId: number, computeUnitPriceMicroLamports: number);
24
+ constructor(pythSolanaReceiver: PythSolanaReceiver, hermesClient: HermesClient, logger: Logger, shardId: number, computeUnitPriceMicroLamports: number);
25
25
  updatePriceFeed(priceIds: string[]): Promise<void>;
26
26
  }
27
27
  export declare class SolanaPricePusherJito implements IPricePusher {
28
28
  private pythSolanaReceiver;
29
- private priceServiceConnection;
29
+ private hermesClient;
30
30
  private logger;
31
31
  private shardId;
32
32
  private defaultJitoTipLamports;
@@ -35,7 +35,7 @@ export declare class SolanaPricePusherJito implements IPricePusher {
35
35
  private searcherClient;
36
36
  private jitoBundleSize;
37
37
  private updatesPerJitoBundle;
38
- constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, logger: Logger, shardId: number, defaultJitoTipLamports: number, dynamicJitoTips: boolean, maxJitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number, updatesPerJitoBundle: number);
38
+ constructor(pythSolanaReceiver: PythSolanaReceiver, hermesClient: HermesClient, logger: Logger, shardId: number, defaultJitoTipLamports: number, dynamicJitoTips: boolean, maxJitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number, updatesPerJitoBundle: number);
39
39
  getRecentJitoTipLamports(): Promise<number | undefined>;
40
40
  private sleep;
41
41
  updatePriceFeed(priceIds: string[]): Promise<void>;
@@ -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;AAK9B,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;IAuBnB,KAAK;IAOL,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CA0B3E;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAElD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,6BAA6B;gBAJ7B,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,6BAA6B,EAAE,MAAM;IAGzC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAA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wB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;YAsB/C,KAAK;IAIb,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAsEzD"}
@@ -62,13 +62,13 @@ 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
+ constructor(pythSolanaReceiver, hermesClient, logger, shardId, computeUnitPriceMicroLamports) {
70
70
  this.pythSolanaReceiver = pythSolanaReceiver;
71
- this.priceServiceConnection = priceServiceConnection;
71
+ this.hermesClient = hermesClient;
72
72
  this.logger = logger;
73
73
  this.shardId = shardId;
74
74
  this.computeUnitPriceMicroLamports = computeUnitPriceMicroLamports;
@@ -85,7 +85,10 @@ class SolanaPricePusher {
85
85
  .map((x) => x.element);
86
86
  let priceFeedUpdateData;
87
87
  try {
88
- priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(shuffledPriceIds);
88
+ const response = await this.hermesClient.getLatestPriceUpdates(shuffledPriceIds, {
89
+ encoding: "base64",
90
+ });
91
+ priceFeedUpdateData = response.binary.data;
89
92
  }
90
93
  catch (err) {
91
94
  this.logger.error(err, "getPriceFeedsUpdateData failed:");
@@ -112,7 +115,7 @@ class SolanaPricePusher {
112
115
  exports.SolanaPricePusher = SolanaPricePusher;
113
116
  class SolanaPricePusherJito {
114
117
  pythSolanaReceiver;
115
- priceServiceConnection;
118
+ hermesClient;
116
119
  logger;
117
120
  shardId;
118
121
  defaultJitoTipLamports;
@@ -121,9 +124,9 @@ class SolanaPricePusherJito {
121
124
  searcherClient;
122
125
  jitoBundleSize;
123
126
  updatesPerJitoBundle;
124
- constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, defaultJitoTipLamports, dynamicJitoTips, maxJitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle) {
127
+ constructor(pythSolanaReceiver, hermesClient, logger, shardId, defaultJitoTipLamports, dynamicJitoTips, maxJitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle) {
125
128
  this.pythSolanaReceiver = pythSolanaReceiver;
126
- this.priceServiceConnection = priceServiceConnection;
129
+ this.hermesClient = hermesClient;
127
130
  this.logger = logger;
128
131
  this.shardId = shardId;
129
132
  this.defaultJitoTipLamports = defaultJitoTipLamports;
@@ -160,7 +163,10 @@ class SolanaPricePusherJito {
160
163
  this.logger.info({ cappedJitoTip }, "using jito tip of");
161
164
  let priceFeedUpdateData;
162
165
  try {
163
- priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
166
+ const response = await this.hermesClient.getLatestPriceUpdates(priceIds, {
167
+ encoding: "base64",
168
+ });
169
+ priceFeedUpdateData = response.binary.data;
164
170
  }
165
171
  catch (err) {
166
172
  this.logger.error(err, "getPriceFeedsUpdateData failed");
@@ -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;