@pythnetwork/price-pusher 8.3.3 → 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 (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 +1 -2
  43. package/lib/solana/command.d.ts.map +1 -1
  44. package/lib/solana/command.js +20 -14
  45. package/lib/solana/solana.d.ts +5 -5
  46. package/lib/solana/solana.d.ts.map +1 -1
  47. package/lib/solana/solana.js +14 -8
  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 +4 -5
@@ -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,KAAK;YAMG,UAAU;IASxB,SAAS,CAAC,qBAAqB,CAC7B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,S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a,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;;;;;;;;;;;;;oBAavB,OAAO;iBAKP,OAAO;sBAKP,OAAO;4BAKP,OAAO;;oBAUW,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","sourceRoot":"","sources":["../../src/near/near.ts"],"names":[],"mappings":"AAIA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AAS,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;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,8BAA8B;0CAOpC,OAAO;CACb,CAAC;AAEF,eAAO,MAAM,kBAAkB;4BAOxB,OAAO;CACb,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,S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AEF,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,EACxC,MAAM,EAAE,MAAM,GACb,eAAe,CAkEjB"}
@@ -1,18 +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
11
  private healthCheckInterval?;
12
- constructor(connection: PriceServiceConnection, priceItems: PriceItem[], logger: Logger);
12
+ constructor(hermesClient: HermesClient, priceItems: PriceItem[], logger: Logger);
13
13
  start(): Promise<void>;
14
- private onNewPriceFeed;
15
- getLatestPriceInfo(priceId: string): PriceInfo | undefined;
14
+ getLatestPriceInfo(priceId: HexString): PriceInfo | undefined;
16
15
  cleanup(): void;
17
16
  }
18
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;IAC/C,OAAO,CAAC,mBAAmB,CAAC,CAAiB;gBAG3C,UAAU,EAAE,sBAAsB,EAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM;IAaV,KAAK;IAmHX,OAAO,CAAC,cAAc;IAuBtB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI1D,OAAO;CAKR"}
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,15 +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
11
  healthCheckInterval;
12
- constructor(connection, priceItems, logger) {
13
- this.connection = connection;
12
+ constructor(hermesClient, priceItems, logger) {
13
+ this.hermesClient = hermesClient;
14
14
  this.priceIds = priceItems.map((priceItem) => priceItem.id);
15
15
  this.priceIdToAlias = new Map(priceItems.map((priceItem) => [priceItem.id, priceItem.alias]));
16
16
  this.latestPriceInfo = new Map();
@@ -19,75 +19,35 @@ class PythPriceListener {
19
19
  // This method should be awaited on and once it finishes it has the latest value
20
20
  // for the given price feeds (if they exist).
21
21
  async start() {
22
- // Set custom error handler for websocket errors
23
- this.connection.onWsError = (error) => {
24
- if (error.message.includes("not found")) {
25
- // Extract invalid feed IDs from error message
26
- const match = error.message.match(/\[(.*?)\]/);
27
- if (match) {
28
- const invalidFeedIds = match[1].split(",").map((id) => {
29
- // Remove '0x' prefix if present to match our stored IDs
30
- return id.trim().replace(/^0x/, "");
31
- });
32
- // Log invalid feeds with their aliases
33
- invalidFeedIds.forEach((id) => {
34
- this.logger.error(`Price feed ${id} (${this.priceIdToAlias.get(id)}) not found for subscribePriceFeedUpdates`);
35
- });
36
- // Filter out invalid feeds and resubscribe with valid ones
37
- const validFeeds = this.priceIds.filter((id) => !invalidFeedIds.includes(id));
38
- this.priceIds = validFeeds;
39
- if (validFeeds.length > 0) {
40
- this.logger.info("Resubscribing with valid feeds only");
41
- this.connection.subscribePriceFeedUpdates(validFeeds, this.onNewPriceFeed.bind(this));
42
- }
22
+ const eventSource = await this.hermesClient.getPriceUpdatesStream(this.priceIds, {
23
+ parsed: true,
24
+ ignoreInvalidPriceIds: true,
25
+ });
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;
43
37
  }
44
- }
45
- else {
46
- this.logger.error("Websocket error occurred:", error);
47
- }
48
- };
49
- this.connection.subscribePriceFeedUpdates(this.priceIds, this.onNewPriceFeed.bind(this));
50
- try {
51
- const priceFeeds = await this.connection.getLatestPriceFeeds(this.priceIds);
52
- priceFeeds?.forEach((priceFeed) => {
53
- const latestAvailablePrice = priceFeed.getPriceUnchecked();
54
- this.latestPriceInfo.set(priceFeed.id, {
55
- price: latestAvailablePrice.price,
56
- conf: latestAvailablePrice.conf,
57
- publishTime: latestAvailablePrice.publishTime,
58
- });
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();
59
45
  });
60
- }
61
- catch (error) {
62
- // Always log the HTTP error first
63
- this.logger.error("Failed to get latest price feeds:", error);
64
- if (error.response.data.includes("Price ids not found:")) {
65
- // Extract invalid feed IDs from error message
66
- const invalidFeedIds = error.response.data
67
- .split("Price ids not found:")[1]
68
- .split(",")
69
- .map((id) => id.trim().replace(/^0x/, ""));
70
- // Log invalid feeds with their aliases
71
- invalidFeedIds.forEach((id) => {
72
- this.logger.error(`Price feed ${id} (${this.priceIdToAlias.get(id)}) not found for getLatestPriceFeeds`);
73
- });
74
- // Filter out invalid feeds and retry
75
- const validFeeds = this.priceIds.filter((id) => !invalidFeedIds.includes(id));
76
- this.priceIds = validFeeds;
77
- if (validFeeds.length > 0) {
78
- this.logger.info("Retrying getLatestPriceFeeds with valid feeds only");
79
- const validPriceFeeds = await this.connection.getLatestPriceFeeds(validFeeds);
80
- validPriceFeeds?.forEach((priceFeed) => {
81
- const latestAvailablePrice = priceFeed.getPriceUnchecked();
82
- this.latestPriceInfo.set(priceFeed.id, {
83
- price: latestAvailablePrice.price,
84
- conf: latestAvailablePrice.conf,
85
- publishTime: latestAvailablePrice.publishTime,
86
- });
87
- });
88
- }
89
- }
90
- }
46
+ };
47
+ eventSource.onerror = (error) => {
48
+ console.error("Error receiving updates from Hermes:", error);
49
+ eventSource.close();
50
+ };
91
51
  // Store health check interval reference
92
52
  this.healthCheckInterval = setInterval(() => {
93
53
  if (this.lastUpdated === undefined ||
@@ -96,21 +56,6 @@ class PythPriceListener {
96
56
  }
97
57
  }, 5000);
98
58
  }
99
- onNewPriceFeed(priceFeed) {
100
- this.logger.debug(`Received new price feed update from Pyth price service: ${this.priceIdToAlias.get(priceFeed.id)} ${priceFeed.id}`);
101
- // Consider price to be currently available if it is not older than 60s
102
- const currentPrice = priceFeed.getPriceNoOlderThan(60);
103
- if (currentPrice === undefined) {
104
- return;
105
- }
106
- const priceInfo = {
107
- conf: currentPrice.conf,
108
- price: currentPrice.price,
109
- publishTime: currentPrice.publishTime,
110
- };
111
- this.latestPriceInfo.set(priceFeed.id, priceInfo);
112
- this.lastUpdated = Date.now();
113
- }
114
59
  getLatestPriceInfo(priceId) {
115
60
  return this.latestPriceInfo.get(priceId);
116
61
  }
@@ -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;;;;;;;;;;;;;kBAUrB,OAAO;wBAKP,OAAO;oBAKP,OAAO;6CAKP,OAAO;yBAKP,OAAO;6BAMP,OAAO;6BAKP,OAAO;6BAKP,OAAO;iCAKP,OAAO;4BAKP,OAAO;mCAKP,OAAO;;oBAUW,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,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