@pythnetwork/price-pusher 8.0.1 → 8.2.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.
package/README.md CHANGED
@@ -84,7 +84,7 @@ To run the price pusher, please run the following commands, replacing the comman
84
84
  ```sh
85
85
  # Please run the two following commands once from the root of the repo to build the code.
86
86
  pnpm install
87
- pnpm exec lerna run build --scope @pythnetwork/price-pusher --include-dependencies
87
+ pnpm turbo build --filter @pythnetwork/price-pusher
88
88
 
89
89
  # Navigate to the price_pusher folder
90
90
  cd apps/price_pusher
@@ -105,7 +105,8 @@ pnpm run start injective --grpc-endpoint https://grpc-endpoint.com \
105
105
  --price-config-file "path/to/price-config.beta.sample.yaml" \
106
106
  --mnemonic-file "path/to/mnemonic.txt" \
107
107
  --network testnet \
108
- [--gas-price 500000000] \
108
+ [--gas-price 160000000] \
109
+ [--gas-multiplier 1.1] \
109
110
  [--pushing-frequency 10] \
110
111
  [--polling-frequency 5]
111
112
 
@@ -15,6 +15,7 @@ declare const _default: {
15
15
  "grpc-endpoint": Options;
16
16
  network: Options;
17
17
  "gas-price": Options;
18
+ "gas-multiplier": Options;
18
19
  };
19
20
  handler: (argv: any) => void;
20
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/injective/command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;oBAmCL,GAAG;;AA/B9B,wBA0GE"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/injective/command.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;;;;;;;;;;;;;;;;;;;oBAuCL,GAAG;;AAnC9B,wBAgHE"}
@@ -55,6 +55,10 @@ exports.default = {
55
55
  description: "Gas price to be used for each transasction",
56
56
  type: "number",
57
57
  },
58
+ "gas-multiplier": {
59
+ description: "Gas multiplier to be used for each transasction",
60
+ type: "number",
61
+ },
58
62
  ...options.priceConfigFile,
59
63
  ...options.priceServiceEndpoint,
60
64
  ...options.mnemonicFile,
@@ -67,7 +71,7 @@ exports.default = {
67
71
  },
68
72
  handler: function (argv) {
69
73
  // FIXME: type checks for this
70
- const { gasPrice, grpcEndpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, network, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
74
+ const { gasPrice, gasMultiplier, grpcEndpoint, priceConfigFile, priceServiceEndpoint, mnemonicFile, pythContractAddress, pushingFrequency, pollingFrequency, network, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
71
75
  const logger = (0, pino_1.default)({ level: logLevel });
72
76
  if (network !== "testnet" && network !== "mainnet") {
73
77
  throw new Error("Please specify network. One of [testnet, mainnet]");
@@ -85,6 +89,7 @@ exports.default = {
85
89
  const injectivePusher = new injective_1.InjectivePricePusher(priceServiceConnection, pythContractAddress, grpcEndpoint, logger.child({ module: "InjectivePricePusher" }), mnemonic, {
86
90
  chainId: (0, networks_1.getNetworkInfo)(network).chainId,
87
91
  gasPrice,
92
+ gasMultiplier,
88
93
  });
89
94
  const controller = new controller_1.Controller(priceConfigs, pythListener, injectiveListener, injectivePusher, logger.child({ module: "Controller" }, { level: controllerLogLevel }), { pushingFrequency });
90
95
  controller.start();
@@ -1 +1 @@
1
- {"version":3,"file":"injective.d.ts","sourceRoot":"","sources":["../../src/injective/injective.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAW7C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAuB9B,qBAAa,sBAAuB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AG,CAAC;IAU1D,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;CAiEjB"}
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InjectivePricePusher = exports.InjectivePriceListener = void 0;
4
4
  const interface_1 = require("../interface");
5
5
  const sdk_ts_1 = require("@injectivelabs/sdk-ts");
6
- const DEFAULT_GAS_PRICE = 500000000;
6
+ const DEFAULT_GAS_PRICE = 160000000;
7
+ const DEFAULT_GAS_MULTIPLIER = 1.05;
8
+ const INJECTIVE_TESTNET_CHAIN_ID = "injective-888";
7
9
  // this use price without leading 0x
8
10
  class InjectivePriceListener extends interface_1.ChainPriceListener {
9
11
  pythContractAddress;
@@ -51,8 +53,8 @@ class InjectivePricePusher {
51
53
  this.logger = logger;
52
54
  this.wallet = sdk_ts_1.PrivateKey.fromMnemonic(mnemonic);
53
55
  this.chainConfig = {
54
- chainId: chainConfig?.chainId ?? "injective-888",
55
- gasMultiplier: chainConfig?.gasMultiplier ?? 1.2,
56
+ chainId: chainConfig?.chainId ?? INJECTIVE_TESTNET_CHAIN_ID,
57
+ gasMultiplier: chainConfig?.gasMultiplier ?? DEFAULT_GAS_MULTIPLIER,
56
58
  gasPrice: chainConfig?.gasPrice ?? DEFAULT_GAS_PRICE,
57
59
  };
58
60
  }
@@ -20,6 +20,8 @@ declare const _default: {
20
20
  "jito-endpoint": Options;
21
21
  "jito-keypair-file": Options;
22
22
  "jito-tip-lamports": Options;
23
+ "dynamic-jito-tips": Options;
24
+ "max-jito-tip-lamports": Options;
23
25
  "jito-bundle-size": Options;
24
26
  "updates-per-jito-bundle": Options;
25
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/solana/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAgBhC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;oBA6DH,GAAG;;AA3D9B,wBAkKE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/solana/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAgBhC,OAAO,EACL,cAAc,EAEf,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;oBAuEH,GAAG;;AArE9B,wBAgLE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,UAAU,MAAM,SAO/D,CAAC"}
@@ -79,6 +79,16 @@ exports.default = {
79
79
  type: "number",
80
80
  optional: true,
81
81
  },
82
+ "dynamic-jito-tips": {
83
+ description: "Use dynamic jito tips",
84
+ type: "boolean",
85
+ default: false,
86
+ },
87
+ "max-jito-tip-lamports": {
88
+ description: "Maximum jito tip lamports",
89
+ type: "number",
90
+ default: web3_js_1.LAMPORTS_PER_SOL / 100,
91
+ },
82
92
  "jito-bundle-size": {
83
93
  description: "Number of transactions in each bundle",
84
94
  type: "number",
@@ -99,7 +109,7 @@ exports.default = {
99
109
  ...options.controllerLogLevel,
100
110
  },
101
111
  handler: function (argv) {
102
- const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, jitoBundleSize, updatesPerJitoBundle, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
112
+ const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, jitoBundleSize, updatesPerJitoBundle, logLevel, priceServiceConnectionLogLevel, controllerLogLevel, } = argv;
103
113
  const logger = (0, pino_1.default)({ level: logLevel });
104
114
  const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
105
115
  const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
@@ -117,7 +127,7 @@ exports.default = {
117
127
  if (jitoTipLamports) {
118
128
  const jitoKeypair = web3_js_1.Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs_1.default.readFileSync(jitoKeypairFile, "ascii"))));
119
129
  const jitoClient = (0, searcher_1.searcherClient)(jitoEndpoint, jitoKeypair);
120
- solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, priceServiceConnection, logger.child({ module: "SolanaPricePusherJito" }), shardId, jitoTipLamports, jitoClient, jitoBundleSize, updatesPerJitoBundle);
130
+ solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, priceServiceConnection, logger.child({ module: "SolanaPricePusherJito" }), shardId, jitoTipLamports, dynamicJitoTips, maxJitoTipLamports, jitoClient, jitoBundleSize, updatesPerJitoBundle);
121
131
  (0, exports.onBundleResult)(jitoClient, logger.child({ module: "JitoClient" }));
122
132
  }
123
133
  else {
@@ -29,11 +29,14 @@ export declare class SolanaPricePusherJito implements IPricePusher {
29
29
  private priceServiceConnection;
30
30
  private logger;
31
31
  private shardId;
32
- private jitoTipLamports;
32
+ private defaultJitoTipLamports;
33
+ private dynamicJitoTips;
34
+ private maxJitoTipLamports;
33
35
  private searcherClient;
34
36
  private jitoBundleSize;
35
37
  private updatesPerJitoBundle;
36
- constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, logger: Logger, shardId: number, jitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number, updatesPerJitoBundle: number);
38
+ constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, logger: Logger, shardId: number, defaultJitoTipLamports: number, dynamicJitoTips: boolean, maxJitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number, updatesPerJitoBundle: number);
39
+ getRecentJitoTipLamports(): Promise<number | undefined>;
37
40
  updatePriceFeed(priceIds: string[], _pubTimesToPush: number[]): Promise<void>;
38
41
  }
39
42
  //# sourceMappingURL=solana.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAK3E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,qBAAa,mBAAoB,SAAQ,kBAAkB;IAEvD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,OAAO;IAEf,OAAO,CAAC,MAAM;gBAHN,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,EAAE,MAAM,EACvB,UAAU,EAAE,SAAS,EAAE,EACf,MAAM,EAAE,MAAM,EACtB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC;KACrC;YAOW,WAAW;IAUnB,KAAK;IAOL,mBAAmB,CAAC,OAAO,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,6BAA6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AAO,EACxB,kBAAkB,EAAE,MAAM,EAC1B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,MAAM;IAGhC,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAsBvD,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAElB,eAAe,EAAE,MAAM,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC;CA8CjB"}
@@ -4,6 +4,8 @@ exports.SolanaPricePusherJito = exports.SolanaPricePusher = exports.SolanaPriceL
4
4
  const interface_1 = require("../interface");
5
5
  const solana_utils_1 = require("@pythnetwork/solana-utils");
6
6
  const price_service_sdk_1 = require("@pythnetwork/price-service-sdk");
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const HEALTH_CHECK_TIMEOUT_SECONDS = 60;
7
9
  class SolanaPriceListener extends interface_1.ChainPriceListener {
8
10
  pythSolanaReceiver;
9
11
  shardId;
@@ -17,10 +19,18 @@ class SolanaPriceListener extends interface_1.ChainPriceListener {
17
19
  // Checking the health of the Solana connection by checking the last block time
18
20
  // and ensuring it is not older than 30 seconds.
19
21
  async checkHealth() {
20
- const slot = await this.pythSolanaReceiver.connection.getSlot();
21
- const blockTime = await this.pythSolanaReceiver.connection.getBlockTime(slot);
22
- if (blockTime === null || blockTime < Date.now() / 1000 - 30) {
23
- throw new Error("Solana connection is unhealthy");
22
+ const slot = await this.pythSolanaReceiver.connection.getSlot("finalized");
23
+ try {
24
+ const blockTime = await this.pythSolanaReceiver.connection.getBlockTime(slot);
25
+ if (blockTime === null ||
26
+ blockTime < Date.now() / 1000 - HEALTH_CHECK_TIMEOUT_SECONDS) {
27
+ if (blockTime !== null) {
28
+ this.logger.info(`Solana connection is behind by ${Date.now() / 1000 - blockTime} seconds`);
29
+ }
30
+ }
31
+ }
32
+ catch (err) {
33
+ this.logger.error({ err }, "checkHealth failed");
24
34
  }
25
35
  }
26
36
  async start() {
@@ -107,23 +117,47 @@ class SolanaPricePusherJito {
107
117
  priceServiceConnection;
108
118
  logger;
109
119
  shardId;
110
- jitoTipLamports;
120
+ defaultJitoTipLamports;
121
+ dynamicJitoTips;
122
+ maxJitoTipLamports;
111
123
  searcherClient;
112
124
  jitoBundleSize;
113
125
  updatesPerJitoBundle;
114
- constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, jitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle) {
126
+ constructor(pythSolanaReceiver, priceServiceConnection, logger, shardId, defaultJitoTipLamports, dynamicJitoTips, maxJitoTipLamports, searcherClient, jitoBundleSize, updatesPerJitoBundle) {
115
127
  this.pythSolanaReceiver = pythSolanaReceiver;
116
128
  this.priceServiceConnection = priceServiceConnection;
117
129
  this.logger = logger;
118
130
  this.shardId = shardId;
119
- this.jitoTipLamports = jitoTipLamports;
131
+ this.defaultJitoTipLamports = defaultJitoTipLamports;
132
+ this.dynamicJitoTips = dynamicJitoTips;
133
+ this.maxJitoTipLamports = maxJitoTipLamports;
120
134
  this.searcherClient = searcherClient;
121
135
  this.jitoBundleSize = jitoBundleSize;
122
136
  this.updatesPerJitoBundle = updatesPerJitoBundle;
123
137
  }
138
+ async getRecentJitoTipLamports() {
139
+ try {
140
+ const response = await fetch("http://bundles-api-rest.jito.wtf/api/v1/bundles/tip_floor");
141
+ if (!response.ok) {
142
+ this.logger.error({ status: response.status, statusText: response.statusText }, "getRecentJitoTips http request failed");
143
+ return undefined;
144
+ }
145
+ const data = await response.json();
146
+ return Math.floor(Number(data[0].landed_tips_25th_percentile) * web3_js_1.LAMPORTS_PER_SOL);
147
+ }
148
+ catch (err) {
149
+ this.logger.error({ err }, "getRecentJitoTips failed");
150
+ return undefined;
151
+ }
152
+ }
124
153
  async updatePriceFeed(priceIds,
125
154
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
126
155
  _pubTimesToPush) {
156
+ const jitoTip = this.dynamicJitoTips
157
+ ? (await this.getRecentJitoTipLamports()) ?? this.defaultJitoTipLamports
158
+ : this.defaultJitoTipLamports;
159
+ const cappedJitoTip = Math.min(jitoTip, this.maxJitoTipLamports);
160
+ this.logger.info({ cappedJitoTip }, "using jito tip of");
127
161
  let priceFeedUpdateData;
128
162
  try {
129
163
  priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
@@ -140,7 +174,7 @@ class SolanaPricePusherJito {
140
174
  return (0, price_service_sdk_1.sliceAccumulatorUpdateData)(Buffer.from(x, "base64"), i, i + this.updatesPerJitoBundle).toString("base64");
141
175
  }), this.shardId);
142
176
  const transactions = await transactionBuilder.buildVersionedTransactions({
143
- jitoTipLamports: this.jitoTipLamports,
177
+ jitoTipLamports: cappedJitoTip,
144
178
  tightComputeBudget: true,
145
179
  jitoBundleSize: this.jitoBundleSize,
146
180
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/price-pusher",
3
- "version": "8.0.1",
3
+ "version": "8.2.0",
4
4
  "description": "Pyth Price Pusher",
5
5
  "homepage": "https://pyth.network",
6
6
  "main": "lib/index.js",
@@ -20,14 +20,13 @@
20
20
  "access": "public"
21
21
  },
22
22
  "scripts": {
23
- "test": "jest src/ --passWithNoTests",
24
23
  "build": "tsc",
25
24
  "format": "prettier --write \"src/**/*.ts\"",
26
- "lint": "eslint src/",
25
+ "test:lint": "eslint src/",
27
26
  "start": "node lib/index.js",
28
27
  "dev": "ts-node src/index.ts",
29
- "prepublishOnly": "pnpm run build && pnpm test && pnpm run lint",
30
- "preversion": "pnpm run lint",
28
+ "prepublishOnly": "pnpm run build && pnpm run test:lint",
29
+ "preversion": "pnpm run test:lint",
31
30
  "version": "pnpm run format && git add -A src"
32
31
  },
33
32
  "keywords": [
@@ -63,7 +62,7 @@
63
62
  "@mysten/sui": "^1.3.0",
64
63
  "@pythnetwork/price-service-client": "1.9.0",
65
64
  "@pythnetwork/price-service-sdk": "^1.7.1",
66
- "@pythnetwork/pyth-fuel-js": "1.0.6",
65
+ "@pythnetwork/pyth-fuel-js": "1.0.7",
67
66
  "@pythnetwork/pyth-sdk-solidity": "4.0.0",
68
67
  "@pythnetwork/pyth-solana-receiver": "0.8.2",
69
68
  "@pythnetwork/pyth-sui-js": "2.1.0",
@@ -80,5 +79,5 @@
80
79
  "yaml": "^2.1.1",
81
80
  "yargs": "^17.5.1"
82
81
  },
83
- "gitHead": "9109f5f49bf31e8ff4a915bbff2d5f6b1e4f96aa"
82
+ "gitHead": "733971809a4415c420922477a162aff3789a7774"
84
83
  }