@pythnetwork/price-pusher 10.3.1 → 11.3.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 (58) hide show
  1. package/README.md +28 -7
  2. package/dist/aptos/aptos.cjs +7 -7
  3. package/dist/aptos/aptos.d.ts +1 -1
  4. package/dist/aptos/balance-tracker.cjs +7 -7
  5. package/dist/aptos/balance-tracker.d.ts +1 -1
  6. package/dist/aptos/command.cjs +20 -17
  7. package/dist/aptos/command.d.ts +3 -2
  8. package/dist/common.cjs +0 -3
  9. package/dist/common.d.ts +0 -4
  10. package/dist/controller.cjs +12 -7
  11. package/dist/controller.d.ts +1 -1
  12. package/dist/evm/balance-tracker.cjs +4 -4
  13. package/dist/evm/balance-tracker.d.ts +2 -2
  14. package/dist/evm/command.cjs +89 -40
  15. package/dist/evm/command.d.ts +12 -6
  16. package/dist/evm/evm.cjs +162 -58
  17. package/dist/evm/evm.d.ts +13 -8
  18. package/dist/evm/gas-price.cjs +114 -0
  19. package/dist/evm/gas-price.d.ts +33 -0
  20. package/dist/evm/pyth-contract.cjs +2 -2
  21. package/dist/evm/super-wallet.cjs +4 -4
  22. package/dist/evm/super-wallet.d.ts +1 -1
  23. package/dist/fuel/command.cjs +17 -14
  24. package/dist/fuel/command.d.ts +3 -2
  25. package/dist/fuel/fuel.d.ts +2 -2
  26. package/dist/injective/command.cjs +26 -23
  27. package/dist/injective/command.d.ts +5 -4
  28. package/dist/injective/injective.cjs +11 -11
  29. package/dist/injective/injective.d.ts +2 -3
  30. package/dist/interface.d.ts +1 -1
  31. package/dist/metrics.cjs +57 -35
  32. package/dist/metrics.d.ts +10 -5
  33. package/dist/near/command.cjs +22 -19
  34. package/dist/near/command.d.ts +5 -4
  35. package/dist/near/near.cjs +17 -16
  36. package/dist/near/near.d.ts +1 -1
  37. package/dist/options.cjs +36 -26
  38. package/dist/options.d.ts +3 -0
  39. package/dist/price-config.cjs +15 -15
  40. package/dist/pyth-price-listener.cjs +5 -3
  41. package/dist/pyth-price-listener.d.ts +2 -3
  42. package/dist/solana/balance-tracker.cjs +5 -5
  43. package/dist/solana/balance-tracker.d.ts +2 -2
  44. package/dist/solana/command.cjs +75 -60
  45. package/dist/solana/command.d.ts +13 -10
  46. package/dist/solana/solana.cjs +5 -5
  47. package/dist/solana/solana.d.ts +4 -4
  48. package/dist/sui/balance-tracker.cjs +6 -6
  49. package/dist/sui/balance-tracker.d.ts +5 -5
  50. package/dist/sui/command.cjs +84 -47
  51. package/dist/sui/command.d.ts +10 -6
  52. package/dist/sui/sui.cjs +159 -106
  53. package/dist/sui/sui.d.ts +31 -14
  54. package/dist/ton/command.cjs +17 -14
  55. package/dist/ton/command.d.ts +3 -2
  56. package/dist/ton/ton.d.ts +2 -3
  57. package/dist/utils.d.ts +1 -2
  58. package/package.json +127 -131
@@ -85,7 +85,8 @@ class NearPricePusher {
85
85
  const outcome = await this.account.updatePriceFeeds(data, updateFee);
86
86
  const failureMessages = [];
87
87
  const is_success = Object.values(outcome.receipts_outcome).reduce((is_success, receipt)=>{
88
- if (Object.prototype.hasOwnProperty.call(receipt.outcome.status, "Failure")) {
88
+ if (// biome-ignore lint/suspicious/noPrototypeBuiltins: receipt.outcome.status is ExecutionStatus | ExecutionStatusBasic (string union), which Object.hasOwn rejects at the type level
89
+ Object.prototype.hasOwnProperty.call(receipt.outcome.status, "Failure")) {
89
90
  failureMessages.push(receipt.outcome.status);
90
91
  return false;
91
92
  }
@@ -123,31 +124,31 @@ class NearAccount {
123
124
  }
124
125
  async getPriceUnsafe(priceId) {
125
126
  return await this.account.viewFunction({
126
- contractId: this.pythAccountId,
127
- methodName: "get_price_unsafe",
128
127
  args: {
129
128
  price_identifier: priceId
130
- }
129
+ },
130
+ contractId: this.pythAccountId,
131
+ methodName: "get_price_unsafe"
131
132
  });
132
133
  }
133
134
  async getUpdateFeeEstimate(data) {
134
135
  return await this.account.viewFunction({
135
- contractId: this.pythAccountId,
136
- methodName: "get_update_fee_estimate",
137
136
  args: {
138
137
  data
139
- }
138
+ },
139
+ contractId: this.pythAccountId,
140
+ methodName: "get_update_fee_estimate"
140
141
  });
141
142
  }
142
143
  async updatePriceFeeds(data, updateFee) {
143
144
  return await this.account.functionCall({
144
- contractId: this.pythAccountId,
145
- methodName: "update_price_feeds",
146
145
  args: {
147
146
  data
148
147
  },
148
+ attachedDeposit: updateFee,
149
+ contractId: this.pythAccountId,
149
150
  gas: "300000000000000",
150
- attachedDeposit: updateFee
151
+ methodName: "update_price_feeds"
151
152
  });
152
153
  }
153
154
  getConnection(network, accountId, nodeUrl, privateKeyPath) {
@@ -163,18 +164,18 @@ class NearAccount {
163
164
  const keyStore = new _key_stores.InMemoryKeyStore();
164
165
  void keyStore.setKey(network, accountInfo.account_id, keyPair);
165
166
  return _nearapijs.Connection.fromConfig({
167
+ jsvmAccountId: `jsvm.${network}`,
166
168
  networkId: network,
167
169
  provider: {
168
- type: "JsonRpcProvider",
169
170
  args: {
170
171
  url: nodeUrl
171
- }
172
+ },
173
+ type: "JsonRpcProvider"
172
174
  },
173
175
  signer: {
174
- type: "InMemorySigner",
175
- keyStore
176
- },
177
- jsvmAccountId: `jsvm.${network}`
176
+ keyStore,
177
+ type: "InMemorySigner"
178
+ }
178
179
  });
179
180
  } else {
180
181
  throw new Error("Invalid key file!");
@@ -1,4 +1,4 @@
1
- import { HermesClient } from "@pythnetwork/hermes-client";
1
+ import type { HermesClient } from "@pythnetwork/hermes-client";
2
2
  import type { FinalExecutionOutcome } from "near-api-js/lib/providers/provider";
3
3
  import type { Logger } from "pino";
4
4
  import type { IPricePusher, PriceInfo, PriceItem } from "../interface.js";
package/dist/options.cjs CHANGED
@@ -15,6 +15,9 @@ _export(exports, {
15
15
  get enableMetrics () {
16
16
  return enableMetrics;
17
17
  },
18
+ get hermesAccessToken () {
19
+ return hermesAccessToken;
20
+ },
18
21
  get logLevel () {
19
22
  return logLevel;
20
23
  },
@@ -43,90 +46,97 @@ _export(exports, {
43
46
  const priceServiceEndpoint = {
44
47
  "price-service-endpoint": {
45
48
  description: "Endpoint URL for the hermes client. e.g: https://endpoint/example",
46
- type: "string",
47
- required: true
49
+ required: true,
50
+ type: "string"
51
+ }
52
+ };
53
+ const hermesAccessToken = {
54
+ "hermes-access-token": {
55
+ description: "Access token to authenticate with Hermes. Sent as a Bearer token in the Authorization header.",
56
+ required: false,
57
+ type: "string"
48
58
  }
49
59
  };
50
60
  const pythContractAddress = {
51
61
  "pyth-contract-address": {
52
62
  description: "Pyth contract address. Provide the network name on which Pyth is deployed " + "or the Pyth contract address if you use a local network.",
53
- type: "string",
54
- required: true
63
+ required: true,
64
+ type: "string"
55
65
  }
56
66
  };
57
67
  const priceConfigFile = {
58
68
  "price-config-file": {
59
69
  description: "Path to price configuration YAML file.",
60
- type: "string",
61
- required: true
70
+ required: true,
71
+ type: "string"
62
72
  }
63
73
  };
64
74
  const pollingFrequency = {
65
75
  "polling-frequency": {
76
+ default: 5,
66
77
  description: "The frequency to poll price info data from the network if the RPC is not a websocket.",
67
- type: "number",
68
78
  required: false,
69
- default: 5
79
+ type: "number"
70
80
  }
71
81
  };
72
82
  const pushingFrequency = {
73
83
  "pushing-frequency": {
84
+ default: 10,
74
85
  description: "The frequency to push prices to the RPC. " + "It is better that the value be greater than the block time of the network, so this program confirms " + "it is updated and does not push it twice.",
75
- type: "number",
76
86
  required: false,
77
- default: 10
87
+ type: "number"
78
88
  }
79
89
  };
80
90
  const mnemonicFile = {
81
91
  "mnemonic-file": {
82
92
  description: "Path to payer mnemonic (private key) file.",
83
- type: "string",
84
- required: true
93
+ required: true,
94
+ type: "string"
85
95
  }
86
96
  };
87
97
  const logLevel = {
88
98
  "log-level": {
89
- description: "Log level",
90
- type: "string",
91
- required: false,
92
- default: "info",
93
99
  choices: [
94
100
  "trace",
95
101
  "debug",
96
102
  "info",
97
103
  "warn",
98
104
  "error"
99
- ]
105
+ ],
106
+ default: "info",
107
+ description: "Log level",
108
+ required: false,
109
+ type: "string"
100
110
  }
101
111
  };
102
112
  const controllerLogLevel = {
103
113
  "controller-log-level": {
104
- description: "Log level for the controller.",
105
- type: "string",
106
- required: false,
107
- default: "info",
108
114
  choices: [
109
115
  "trace",
110
116
  "debug",
111
117
  "info",
112
118
  "warn",
113
119
  "error"
114
- ]
120
+ ],
121
+ default: "info",
122
+ description: "Log level for the controller.",
123
+ required: false,
124
+ type: "string"
115
125
  }
116
126
  };
117
127
  const enableMetrics = {
118
128
  "enable-metrics": {
129
+ default: true,
119
130
  description: "Enable Prometheus metrics server",
120
- type: "boolean",
121
131
  required: false,
122
- default: true
132
+ type: "boolean"
123
133
  }
124
134
  };
125
135
  const metricsPort = {
126
136
  "metrics-port": {
137
+ default: 9090,
127
138
  description: "Port for the Prometheus metrics server",
128
- type: "number",
129
139
  required: false,
130
- default: 9090
140
+ type: "number"
131
141
  }
132
142
  };
package/dist/options.d.ts CHANGED
@@ -2,6 +2,9 @@ import type { Options } from "yargs";
2
2
  export declare const priceServiceEndpoint: {
3
3
  "price-service-endpoint": Options;
4
4
  };
5
+ export declare const hermesAccessToken: {
6
+ "hermes-access-token": Options;
7
+ };
5
8
  export declare const pythContractAddress: {
6
9
  "pyth-contract-address": Options;
7
10
  };
@@ -30,15 +30,15 @@ function _interop_require_default(obj) {
30
30
  }
31
31
  const PriceConfigFileSchema = _joi.default.array().items(_joi.default.object({
32
32
  alias: _joi.default.string().required(),
33
- id: _joi.default.string().regex(/^(0x)?[a-f0-9]{64}$/).required(),
34
- time_difference: _joi.default.number().required(),
35
- price_deviation: _joi.default.number().required(),
36
33
  confidence_ratio: _joi.default.number().required(),
37
34
  early_update: _joi.default.object({
38
- time_difference: _joi.default.number().optional(),
35
+ confidence_ratio: _joi.default.number().optional(),
39
36
  price_deviation: _joi.default.number().optional(),
40
- confidence_ratio: _joi.default.number().optional()
41
- }).optional()
37
+ time_difference: _joi.default.number().optional()
38
+ }).optional(),
39
+ id: _joi.default.string().regex(/^(0x)?[a-f0-9]{64}$/).required(),
40
+ price_deviation: _joi.default.number().required(),
41
+ time_difference: _joi.default.number().required()
42
42
  })).unique("id").unique("alias").required();
43
43
  function readPriceConfigFile(path) {
44
44
  const priceConfigs = _yaml.default.parse(_nodefs.default.readFileSync(path, "utf8"));
@@ -49,14 +49,14 @@ function readPriceConfigFile(path) {
49
49
  return priceConfigs.map((priceConfigRaw)=>{
50
50
  const priceConfig = {
51
51
  alias: priceConfigRaw.alias,
52
- id: (0, _utils.removeLeading0x)(priceConfigRaw.id),
53
- timeDifference: priceConfigRaw.time_difference,
54
- priceDeviation: priceConfigRaw.price_deviation,
55
52
  confidenceRatio: priceConfigRaw.confidence_ratio,
56
53
  customEarlyUpdate: priceConfigRaw.early_update !== undefined,
57
- earlyUpdateTimeDifference: priceConfigRaw.early_update?.time_difference,
54
+ earlyUpdateConfidenceRatio: priceConfigRaw.early_update?.confidence_ratio,
58
55
  earlyUpdatePriceDeviation: priceConfigRaw.early_update?.price_deviation,
59
- earlyUpdateConfidenceRatio: priceConfigRaw.early_update?.confidence_ratio
56
+ earlyUpdateTimeDifference: priceConfigRaw.early_update?.time_difference,
57
+ id: (0, _utils.removeLeading0x)(priceConfigRaw.id),
58
+ priceDeviation: priceConfigRaw.price_deviation,
59
+ timeDifference: priceConfigRaw.time_difference
60
60
  };
61
61
  return priceConfig;
62
62
  });
@@ -74,12 +74,12 @@ function shouldUpdate(priceConfig, sourceLatestPrice, targetLatestPrice, logger)
74
74
  const priceId = priceConfig.id;
75
75
  // There is no price to update the target with. So we should not update it.
76
76
  if (sourceLatestPrice === undefined) {
77
- logger.info(`${priceConfig.alias} (${priceId}) is not available on the source network. Ignoring it.`);
77
+ logger.warn(`${priceConfig.alias} (${priceId}) is not available on the source network. Ignoring it.`);
78
78
  return 2;
79
79
  }
80
80
  // It means that price never existed there. So we should push the latest price feed.
81
81
  if (targetLatestPrice === undefined) {
82
- logger.info(`${priceConfig.alias} (${priceId}) is not available on the target network. Pushing the price.`);
82
+ logger.debug(`${priceConfig.alias} (${priceId}) is not available on the target network. Pushing the price.`);
83
83
  return 0;
84
84
  }
85
85
  // The current price is not newer than the price onchain
@@ -91,8 +91,8 @@ function shouldUpdate(priceConfig, sourceLatestPrice, targetLatestPrice, logger)
91
91
  const confidenceRatioPct = Math.abs(Number(sourceLatestPrice.conf) / Number(sourceLatestPrice.price) * 100);
92
92
  logger.info({
93
93
  sourcePrice: sourceLatestPrice,
94
- targetPrice: targetLatestPrice,
95
- symbol: priceConfig.alias
94
+ symbol: priceConfig.alias,
95
+ targetPrice: targetLatestPrice
96
96
  }, `Analyzing price ${priceConfig.alias} (${priceId}). ` + `Time difference: ${timeDifference} (< ${priceConfig.timeDifference}? / early: < ${priceConfig.earlyUpdateTimeDifference}) OR ` + `Price deviation: ${priceDeviationPct.toFixed(5)}% (< ${priceConfig.priceDeviation}%? / early: < ${priceConfig.earlyUpdatePriceDeviation}%?) OR ` + `Confidence ratio: ${confidenceRatioPct.toFixed(5)}% (< ${priceConfig.confidenceRatio}%? / early: < ${priceConfig.earlyUpdateConfidenceRatio}%?)`);
97
97
  if (timeDifference >= priceConfig.timeDifference || priceDeviationPct >= priceConfig.priceDeviation || confidenceRatioPct >= priceConfig.confidenceRatio) {
98
98
  return 0;
@@ -41,8 +41,8 @@ class PythPriceListener {
41
41
  async startListening() {
42
42
  this.logger.info(`Starting to listen for price updates from Hermes for ${this.priceIds.length} price feeds.`);
43
43
  const eventSource = await this.hermesClient.getPriceUpdatesStream(this.priceIds, {
44
- parsed: true,
45
- ignoreInvalidPriceIds: true
44
+ ignoreInvalidPriceIds: true,
45
+ parsed: true
46
46
  });
47
47
  eventSource.onmessage = (event)=>{
48
48
  const priceUpdates = JSON.parse(event.data);
@@ -64,7 +64,9 @@ class PythPriceListener {
64
64
  }
65
65
  };
66
66
  eventSource.onerror = async (error)=>{
67
- console.error("Error receiving updates from Hermes:", error);
67
+ this.logger.error({
68
+ err: error
69
+ }, "Error receiving updates from Hermes");
68
70
  eventSource.close();
69
71
  await (0, _utils.sleep)(5000); // Wait a bit before trying to reconnect
70
72
  void this.startListening(); // Attempt to restart the listener
@@ -1,7 +1,6 @@
1
- import type { HexString } from "@pythnetwork/hermes-client";
2
- import { HermesClient } from "@pythnetwork/hermes-client";
1
+ import type { HermesClient, HexString } from "@pythnetwork/hermes-client";
3
2
  import type { Logger } from "pino";
4
- import type { PriceInfo, IPriceListener, PriceItem } from "./interface.js";
3
+ import type { IPriceListener, PriceInfo, PriceItem } from "./interface.js";
5
4
  export declare class PythPriceListener implements IPriceListener {
6
5
  private hermesClient;
7
6
  private priceIds;
@@ -49,12 +49,12 @@ class SolanaBalanceTracker extends _interface.BaseBalanceTracker {
49
49
  }
50
50
  function createSolanaBalanceTracker(params) {
51
51
  return new SolanaBalanceTracker({
52
- connection: params.connection,
53
- publicKey: params.publicKey,
54
52
  address: params.publicKey.toString(),
55
- network: params.network,
56
- updateInterval: params.updateInterval,
53
+ connection: params.connection,
54
+ logger: params.logger,
57
55
  metrics: params.metrics,
58
- logger: params.logger
56
+ network: params.network,
57
+ publicKey: params.publicKey,
58
+ updateInterval: params.updateInterval
59
59
  });
60
60
  }
@@ -1,8 +1,8 @@
1
- import { Connection, PublicKey } from "@solana/web3.js";
1
+ import type { Connection, PublicKey } from "@solana/web3.js";
2
2
  import type { Logger } from "pino";
3
3
  import type { BaseBalanceTrackerConfig, IBalanceTracker } from "../interface.js";
4
4
  import { BaseBalanceTracker } from "../interface.js";
5
- import { PricePusherMetrics } from "../metrics.js";
5
+ import type { PricePusherMetrics } from "../metrics.js";
6
6
  import type { DurationInSeconds } from "../utils.js";
7
7
  /**
8
8
  * Solana-specific configuration for balance tracker
@@ -23,14 +23,14 @@ const _pythsolanareceiver = require("@pythnetwork/pyth-solana-receiver");
23
23
  const _web3 = require("@solana/web3.js");
24
24
  const _searcher = require("jito-ts/dist/sdk/block-engine/searcher");
25
25
  const _pino = require("pino");
26
+ const _controller = require("../controller.cjs");
27
+ const _metrics = require("../metrics.cjs");
26
28
  const _options = /*#__PURE__*/ _interop_require_wildcard(require("../options.cjs"));
27
29
  const _priceconfig = require("../price-config.cjs");
28
30
  const _pythpricelistener = require("../pyth-price-listener.cjs");
29
- const _solana = require("./solana.cjs");
30
- const _controller = require("../controller.cjs");
31
- const _metrics = require("../metrics.cjs");
32
31
  const _utils = require("../utils.cjs");
33
32
  const _balancetracker = require("./balance-tracker.cjs");
33
+ const _solana = require("./solana.cjs");
34
34
  function _interop_require_default(obj) {
35
35
  return obj && obj.__esModule ? obj : {
36
36
  default: obj
@@ -78,76 +78,85 @@ function _interop_require_wildcard(obj, nodeInterop) {
78
78
  return newObj;
79
79
  }
80
80
  const _default = {
81
- command: "solana",
82
- describe: "run price pusher for solana",
83
81
  builder: {
84
- endpoint: {
85
- description: "Solana RPC API endpoint",
86
- type: "string",
87
- required: true
88
- },
89
- "keypair-file": {
90
- description: "Path to a keypair file",
91
- type: "string",
92
- required: true
93
- },
94
- "shard-id": {
95
- description: "Shard ID",
96
- type: "number",
97
- required: true
82
+ "address-lookup-table-account": {
83
+ description: "The pubkey of the ALT to use when updating price feeds",
84
+ optional: true,
85
+ type: "string"
98
86
  },
99
87
  "compute-unit-price-micro-lamports": {
88
+ default: 50_000,
100
89
  description: "Priority fee per compute unit",
101
- type: "number",
102
- default: 50_000
90
+ type: "number"
91
+ },
92
+ "dynamic-jito-tips": {
93
+ default: false,
94
+ description: "Use dynamic jito tips",
95
+ type: "boolean"
96
+ },
97
+ endpoint: {
98
+ description: "Solana RPC API endpoint",
99
+ required: true,
100
+ type: "string"
101
+ },
102
+ "jito-bundle-size": {
103
+ default: 5,
104
+ description: "Number of transactions in each Jito bundle",
105
+ type: "number"
103
106
  },
104
107
  "jito-endpoints": {
105
108
  description: "Jito endpoint(s) - comma-separated list of endpoints",
106
- type: "string",
107
- optional: true
109
+ optional: true,
110
+ type: "string"
108
111
  },
109
112
  "jito-keypair-file": {
110
113
  description: "Path to the jito keypair file (need for grpc authentication)",
111
- type: "string",
112
- optional: true
114
+ optional: true,
115
+ type: "string"
113
116
  },
114
117
  "jito-tip-lamports": {
115
118
  description: "Lamports to tip the jito builder",
116
- type: "number",
117
- optional: true
119
+ optional: true,
120
+ type: "number"
118
121
  },
119
- "dynamic-jito-tips": {
120
- description: "Use dynamic jito tips",
121
- type: "boolean",
122
- default: false
122
+ "keypair-file": {
123
+ description: "Path to a keypair file",
124
+ required: true,
125
+ type: "string"
123
126
  },
124
127
  "max-jito-tip-lamports": {
128
+ default: _web3.LAMPORTS_PER_SOL / 100,
125
129
  description: "Maximum jito tip lamports",
126
- type: "number",
127
- default: _web3.LAMPORTS_PER_SOL / 100
130
+ type: "number"
128
131
  },
129
- "jito-bundle-size": {
130
- description: "Number of transactions in each Jito bundle",
131
- type: "number",
132
- default: 5
132
+ "pyth-receiver-program-id": {
133
+ description: "The Pyth receiver program ID to use",
134
+ optional: true,
135
+ type: "string"
133
136
  },
134
- "updates-per-jito-bundle": {
135
- description: "Number of price updates in each Jito bundle",
136
- type: "number",
137
- default: 6
138
- },
139
- "address-lookup-table-account": {
140
- description: "The pubkey of the ALT to use when updating price feeds",
141
- type: "string",
142
- optional: true
137
+ "shard-id": {
138
+ description: "Shard ID",
139
+ required: true,
140
+ type: "number"
143
141
  },
144
142
  "treasury-id": {
145
143
  description: "The treasuryId to use. Useful when the corresponding treasury account is indexed in the ALT passed to --address-lookup-table-account. This is a tx size optimization and is optional; if not set, a random treasury account will be used.",
146
- type: "number",
147
- optional: true
144
+ optional: true,
145
+ type: "number"
146
+ },
147
+ "updates-per-jito-bundle": {
148
+ default: 6,
149
+ description: "Number of price updates in each Jito bundle",
150
+ type: "number"
151
+ },
152
+ "wormhole-program-id": {
153
+ description: "The Wormhole program ID to use",
154
+ optional: true,
155
+ type: "string"
148
156
  },
149
157
  ..._options.priceConfigFile,
150
158
  ..._options.priceServiceEndpoint,
159
+ ..._options.hermesAccessToken,
151
160
  ..._options.pythContractAddress,
152
161
  ..._options.pollingFrequency,
153
162
  ..._options.pushingFrequency,
@@ -156,13 +165,17 @@ const _default = {
156
165
  ..._options.enableMetrics,
157
166
  ..._options.metricsPort
158
167
  },
168
+ command: "solana",
169
+ describe: "run price pusher for solana",
159
170
  handler: async function(argv) {
160
- const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoints, jitoKeypairFile, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, updatesPerJitoBundle, addressLookupTableAccount, treasuryId, logLevel, controllerLogLevel, enableMetrics, metricsPort } = argv;
171
+ const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, hermesAccessToken, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoints, jitoKeypairFile, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, updatesPerJitoBundle, addressLookupTableAccount, treasuryId, logLevel, controllerLogLevel, enableMetrics, metricsPort, pythReceiverProgramId, wormholeProgramId } = argv;
161
172
  const logger = (0, _pino.pino)({
162
173
  level: logLevel
163
174
  });
164
175
  const priceConfigs = (0, _priceconfig.readPriceConfigFile)(priceConfigFile);
165
- const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint);
176
+ const hermesClient = new _hermesclient.HermesClient(priceServiceEndpoint, {
177
+ accessToken: hermesAccessToken
178
+ });
166
179
  // Initialize metrics if enabled
167
180
  let metrics;
168
181
  if (enableMetrics) {
@@ -173,8 +186,8 @@ const _default = {
173
186
  logger.info(`Metrics server started on port ${metricsPort}`);
174
187
  }
175
188
  let priceItems = priceConfigs.map(({ id, alias })=>({
176
- id,
177
- alias
189
+ alias,
190
+ id
178
191
  }));
179
192
  // Better to filter out invalid price items before creating the pyth listener
180
193
  const { existingPriceItems, invalidPriceItems } = await (0, _utils.filterInvalidPriceItems)(hermesClient, priceItems);
@@ -190,19 +203,21 @@ const _default = {
190
203
  const connection = new _web3.Connection(endpoint, "processed");
191
204
  const pythSolanaReceiver = new _pythsolanareceiver.PythSolanaReceiver({
192
205
  connection,
193
- wallet,
194
206
  pushOracleProgramId: new _web3.PublicKey(pythContractAddress),
195
- treasuryId: treasuryId
207
+ receiverProgramId: pythReceiverProgramId ? new _web3.PublicKey(pythReceiverProgramId) : undefined,
208
+ treasuryId: treasuryId,
209
+ wallet,
210
+ wormholeProgramId: wormholeProgramId ? new _web3.PublicKey(wormholeProgramId) : undefined
196
211
  });
197
212
  // Create and start the balance tracker if metrics are enabled
198
213
  if (metrics) {
199
214
  const balanceTracker = (0, _balancetracker.createSolanaBalanceTracker)({
200
215
  connection,
201
- publicKey: keypair.publicKey,
202
- network: "solana",
203
- updateInterval: 60,
216
+ logger,
204
217
  metrics,
205
- logger
218
+ network: "solana",
219
+ publicKey: keypair.publicKey,
220
+ updateInterval: 60
206
221
  });
207
222
  // Start the balance tracker
208
223
  await balanceTracker.start();
@@ -241,8 +256,8 @@ const _default = {
241
256
  }, {
242
257
  level: controllerLogLevel
243
258
  }), {
244
- pushingFrequency,
245
- metrics: metrics
259
+ metrics: metrics,
260
+ pushingFrequency
246
261
  });
247
262
  void controller.start();
248
263
  }
@@ -1,9 +1,7 @@
1
- import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
1
+ import type { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
2
2
  import type { Logger } from "pino";
3
3
  import type { Options } from "yargs";
4
4
  declare const _default: {
5
- command: string;
6
- describe: string;
7
5
  builder: {
8
6
  "metrics-port": Options;
9
7
  "enable-metrics": Options;
@@ -12,22 +10,27 @@ declare const _default: {
12
10
  "pushing-frequency": Options;
13
11
  "polling-frequency": Options;
14
12
  "pyth-contract-address": Options;
13
+ "hermes-access-token": Options;
15
14
  "price-service-endpoint": Options;
16
15
  "price-config-file": Options;
17
- endpoint: Options;
18
- "keypair-file": Options;
19
- "shard-id": Options;
16
+ "address-lookup-table-account": Options;
20
17
  "compute-unit-price-micro-lamports": Options;
18
+ "dynamic-jito-tips": Options;
19
+ endpoint: Options;
20
+ "jito-bundle-size": Options;
21
21
  "jito-endpoints": Options;
22
22
  "jito-keypair-file": Options;
23
23
  "jito-tip-lamports": Options;
24
- "dynamic-jito-tips": Options;
24
+ "keypair-file": Options;
25
25
  "max-jito-tip-lamports": Options;
26
- "jito-bundle-size": Options;
27
- "updates-per-jito-bundle": Options;
28
- "address-lookup-table-account": Options;
26
+ "pyth-receiver-program-id": Options;
27
+ "shard-id": Options;
29
28
  "treasury-id": Options;
29
+ "updates-per-jito-bundle": Options;
30
+ "wormhole-program-id": Options;
30
31
  };
32
+ command: string;
33
+ describe: string;
31
34
  handler: (argv: any) => Promise<void>;
32
35
  };
33
36
  export default _default;