@pythnetwork/price-pusher 6.4.2 → 6.5.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 +1 -1
- package/lib/solana/command.d.ts +6 -0
- package/lib/solana/command.d.ts.map +1 -1
- package/lib/solana/command.js +39 -2
- package/lib/solana/solana.d.ts +13 -1
- package/lib/solana/solana.d.ts.map +1 -1
- package/lib/solana/solana.js +65 -5
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ npm run start -- near \
|
|
|
150
150
|
docker run public.ecr.aws/pyth-network/xc-price-pusher:v<version> -- <above-arguments>
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
[hermes]: https://github.com/pyth-network/pyth-crosschain/tree/main/hermes
|
|
153
|
+
[hermes]: https://github.com/pyth-network/pyth-crosschain/tree/main/apps/hermes
|
|
154
154
|
|
|
155
155
|
### Command Line Arguments
|
|
156
156
|
|
package/lib/solana/command.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Options } from "yargs";
|
|
2
|
+
import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
|
|
2
3
|
declare const _default: {
|
|
3
4
|
command: string;
|
|
4
5
|
describe: string;
|
|
@@ -12,8 +13,13 @@ declare const _default: {
|
|
|
12
13
|
"keypair-file": Options;
|
|
13
14
|
"shard-id": Options;
|
|
14
15
|
"compute-unit-price-micro-lamports": Options;
|
|
16
|
+
"jito-endpoint": Options;
|
|
17
|
+
"jito-keypair-file": Options;
|
|
18
|
+
"jito-tip-lamports": Options;
|
|
19
|
+
"jito-bundle-size": Options;
|
|
15
20
|
};
|
|
16
21
|
handler: (argv: any) => void;
|
|
17
22
|
};
|
|
18
23
|
export default _default;
|
|
24
|
+
export declare const onBundleResult: (c: SearcherClient) => void;
|
|
19
25
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;oBAqDrB,GAAG;;AAnD9B,wBAkJE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,SAO/C,CAAC"}
|
package/lib/solana/command.js
CHANGED
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.onBundleResult = void 0;
|
|
29
30
|
const options = __importStar(require("../options"));
|
|
30
31
|
const price_config_1 = require("../price-config");
|
|
31
32
|
const price_service_client_1 = require("@pythnetwork/price-service-client");
|
|
@@ -37,6 +38,7 @@ const nodewallet_1 = __importDefault(require("@coral-xyz/anchor/dist/cjs/nodewal
|
|
|
37
38
|
const web3_js_1 = require("@solana/web3.js");
|
|
38
39
|
const fs_1 = __importDefault(require("fs"));
|
|
39
40
|
const web3_js_2 = require("@solana/web3.js");
|
|
41
|
+
const searcher_1 = require("jito-ts/dist/sdk/block-engine/searcher");
|
|
40
42
|
exports.default = {
|
|
41
43
|
command: "solana",
|
|
42
44
|
describe: "run price pusher for solana",
|
|
@@ -61,6 +63,26 @@ exports.default = {
|
|
|
61
63
|
type: "number",
|
|
62
64
|
default: 50000,
|
|
63
65
|
},
|
|
66
|
+
"jito-endpoint": {
|
|
67
|
+
description: "Jito endpoint",
|
|
68
|
+
type: "string",
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
"jito-keypair-file": {
|
|
72
|
+
description: "Path to the jito keypair file (need for grpc authentication)",
|
|
73
|
+
type: "string",
|
|
74
|
+
optional: true,
|
|
75
|
+
},
|
|
76
|
+
"jito-tip-lamports": {
|
|
77
|
+
description: "Lamports to tip the jito builder",
|
|
78
|
+
type: "number",
|
|
79
|
+
optional: true,
|
|
80
|
+
},
|
|
81
|
+
"jito-bundle-size": {
|
|
82
|
+
description: "Number of transactions in each bundle",
|
|
83
|
+
type: "number",
|
|
84
|
+
default: 2,
|
|
85
|
+
},
|
|
64
86
|
...options.priceConfigFile,
|
|
65
87
|
...options.priceServiceEndpoint,
|
|
66
88
|
...options.pythContractAddress,
|
|
@@ -68,7 +90,7 @@ exports.default = {
|
|
|
68
90
|
...options.pushingFrequency,
|
|
69
91
|
},
|
|
70
92
|
handler: function (argv) {
|
|
71
|
-
const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, } = argv;
|
|
93
|
+
const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, jitoBundleSize, } = argv;
|
|
72
94
|
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
73
95
|
const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
|
|
74
96
|
logger: {
|
|
@@ -88,9 +110,24 @@ exports.default = {
|
|
|
88
110
|
wallet,
|
|
89
111
|
pushOracleProgramId: new web3_js_2.PublicKey(pythContractAddress),
|
|
90
112
|
});
|
|
91
|
-
|
|
113
|
+
let solanaPricePusher;
|
|
114
|
+
if (jitoTipLamports) {
|
|
115
|
+
const jitoKeypair = web3_js_1.Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs_1.default.readFileSync(jitoKeypairFile, "ascii"))));
|
|
116
|
+
const jitoClient = (0, searcher_1.searcherClient)(jitoEndpoint, jitoKeypair);
|
|
117
|
+
solanaPricePusher = new solana_1.SolanaPricePusherJito(pythSolanaReceiver, priceServiceConnection, shardId, jitoTipLamports, jitoClient, jitoBundleSize);
|
|
118
|
+
(0, exports.onBundleResult)(jitoClient);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
solanaPricePusher = new solana_1.SolanaPricePusher(pythSolanaReceiver, priceServiceConnection, shardId, computeUnitPriceMicroLamports);
|
|
122
|
+
}
|
|
92
123
|
const solanaPriceListener = new solana_1.SolanaPriceListener(pythSolanaReceiver, shardId, priceItems, { pollingFrequency });
|
|
93
124
|
const controller = new controller_1.Controller(priceConfigs, pythListener, solanaPriceListener, solanaPricePusher, { pushingFrequency });
|
|
94
125
|
controller.start();
|
|
95
126
|
},
|
|
96
127
|
};
|
|
128
|
+
const onBundleResult = (c) => {
|
|
129
|
+
c.onBundleResult(() => undefined, (e) => {
|
|
130
|
+
console.log("Error in bundle result: ", e);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
exports.onBundleResult = onBundleResult;
|
package/lib/solana/solana.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
|
|
|
2
2
|
import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
|
|
3
3
|
import { DurationInSeconds } from "../utils";
|
|
4
4
|
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
|
|
5
|
+
import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
|
|
5
6
|
export declare class SolanaPriceListener extends ChainPriceListener {
|
|
6
7
|
private pythSolanaReceiver;
|
|
7
8
|
private shardId;
|
|
@@ -15,7 +16,18 @@ export declare class SolanaPricePusher implements IPricePusher {
|
|
|
15
16
|
private priceServiceConnection;
|
|
16
17
|
private shardId;
|
|
17
18
|
private computeUnitPriceMicroLamports;
|
|
18
|
-
|
|
19
|
+
private alreadySending;
|
|
20
|
+
constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, shardId: number, computeUnitPriceMicroLamports: number, alreadySending?: boolean);
|
|
21
|
+
updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare class SolanaPricePusherJito implements IPricePusher {
|
|
24
|
+
private pythSolanaReceiver;
|
|
25
|
+
private priceServiceConnection;
|
|
26
|
+
private shardId;
|
|
27
|
+
private jitoTipLamports;
|
|
28
|
+
private searcherClient;
|
|
29
|
+
private jitoBundleSize;
|
|
30
|
+
constructor(pythSolanaReceiver: PythSolanaReceiver, priceServiceConnection: PriceServiceConnection, shardId: number, jitoTipLamports: number, searcherClient: SearcherClient, jitoBundleSize: number);
|
|
19
31
|
updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
|
|
20
32
|
}
|
|
21
33
|
//# 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;
|
|
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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js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolanaPricePusher = exports.SolanaPriceListener = void 0;
|
|
3
|
+
exports.SolanaPricePusherJito = exports.SolanaPricePusher = exports.SolanaPriceListener = void 0;
|
|
4
4
|
const interface_1 = require("../interface");
|
|
5
|
+
const solana_utils_1 = require("@pythnetwork/solana-utils");
|
|
5
6
|
class SolanaPriceListener extends interface_1.ChainPriceListener {
|
|
6
7
|
pythSolanaReceiver;
|
|
7
8
|
shardId;
|
|
@@ -38,13 +39,20 @@ class SolanaPricePusher {
|
|
|
38
39
|
priceServiceConnection;
|
|
39
40
|
shardId;
|
|
40
41
|
computeUnitPriceMicroLamports;
|
|
41
|
-
|
|
42
|
+
alreadySending;
|
|
43
|
+
constructor(pythSolanaReceiver, priceServiceConnection, shardId, computeUnitPriceMicroLamports, alreadySending = false) {
|
|
42
44
|
this.pythSolanaReceiver = pythSolanaReceiver;
|
|
43
45
|
this.priceServiceConnection = priceServiceConnection;
|
|
44
46
|
this.shardId = shardId;
|
|
45
47
|
this.computeUnitPriceMicroLamports = computeUnitPriceMicroLamports;
|
|
48
|
+
this.alreadySending = alreadySending;
|
|
46
49
|
}
|
|
47
50
|
async updatePriceFeed(priceIds, pubTimesToPush) {
|
|
51
|
+
if (this.alreadySending) {
|
|
52
|
+
console.log(new Date(), "updatePriceFeed already in progress");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.alreadySending = true;
|
|
48
56
|
if (priceIds.length === 0) {
|
|
49
57
|
return;
|
|
50
58
|
}
|
|
@@ -60,16 +68,68 @@ class SolanaPricePusher {
|
|
|
60
68
|
closeUpdateAccounts: true,
|
|
61
69
|
});
|
|
62
70
|
await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData, this.shardId);
|
|
71
|
+
const transactions = await transactionBuilder.buildVersionedTransactions({
|
|
72
|
+
computeUnitPriceMicroLamports: this.computeUnitPriceMicroLamports,
|
|
73
|
+
tightComputeBudget: true,
|
|
74
|
+
});
|
|
63
75
|
try {
|
|
64
|
-
await this.pythSolanaReceiver.
|
|
65
|
-
computeUnitPriceMicroLamports: this.computeUnitPriceMicroLamports,
|
|
66
|
-
}), { skipPreflight: true });
|
|
76
|
+
await (0, solana_utils_1.sendTransactions)(transactions, this.pythSolanaReceiver.connection, this.pythSolanaReceiver.wallet);
|
|
67
77
|
console.log(new Date(), "updatePriceFeed successful");
|
|
78
|
+
this.alreadySending = false;
|
|
68
79
|
}
|
|
69
80
|
catch (e) {
|
|
70
81
|
console.error(new Date(), "updatePriceFeed failed", e);
|
|
82
|
+
this.alreadySending = false;
|
|
71
83
|
return;
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
exports.SolanaPricePusher = SolanaPricePusher;
|
|
88
|
+
class SolanaPricePusherJito {
|
|
89
|
+
pythSolanaReceiver;
|
|
90
|
+
priceServiceConnection;
|
|
91
|
+
shardId;
|
|
92
|
+
jitoTipLamports;
|
|
93
|
+
searcherClient;
|
|
94
|
+
jitoBundleSize;
|
|
95
|
+
constructor(pythSolanaReceiver, priceServiceConnection, shardId, jitoTipLamports, searcherClient, jitoBundleSize) {
|
|
96
|
+
this.pythSolanaReceiver = pythSolanaReceiver;
|
|
97
|
+
this.priceServiceConnection = priceServiceConnection;
|
|
98
|
+
this.shardId = shardId;
|
|
99
|
+
this.jitoTipLamports = jitoTipLamports;
|
|
100
|
+
this.searcherClient = searcherClient;
|
|
101
|
+
this.jitoBundleSize = jitoBundleSize;
|
|
102
|
+
}
|
|
103
|
+
async updatePriceFeed(priceIds, pubTimesToPush) {
|
|
104
|
+
let priceFeedUpdateData;
|
|
105
|
+
try {
|
|
106
|
+
priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
console.error(new Date(), "getPriceFeedsUpdateData failed:", e);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const transactionBuilder = this.pythSolanaReceiver.newTransactionBuilder({
|
|
113
|
+
closeUpdateAccounts: false,
|
|
114
|
+
});
|
|
115
|
+
await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData, this.shardId);
|
|
116
|
+
const transactions = await transactionBuilder.buildVersionedTransactions({
|
|
117
|
+
jitoTipLamports: this.jitoTipLamports,
|
|
118
|
+
tightComputeBudget: true,
|
|
119
|
+
jitoBundleSize: this.jitoBundleSize,
|
|
120
|
+
});
|
|
121
|
+
const firstSignature = await (0, solana_utils_1.sendTransactionsJito)(transactions.slice(0, this.jitoBundleSize), this.searcherClient, this.pythSolanaReceiver.wallet);
|
|
122
|
+
const blockhashResult = await this.pythSolanaReceiver.connection.getLatestBlockhashAndContext({
|
|
123
|
+
commitment: "confirmed",
|
|
124
|
+
});
|
|
125
|
+
await this.pythSolanaReceiver.connection.confirmTransaction({
|
|
126
|
+
signature: firstSignature,
|
|
127
|
+
blockhash: blockhashResult.value.blockhash,
|
|
128
|
+
lastValidBlockHeight: blockhashResult.value.lastValidBlockHeight,
|
|
129
|
+
}, "confirmed");
|
|
130
|
+
for (let i = this.jitoBundleSize; i < transactions.length; i += this.jitoBundleSize) {
|
|
131
|
+
await (0, solana_utils_1.sendTransactionsJito)(transactions.slice(i, i + this.jitoBundleSize), this.searcherClient, this.pythSolanaReceiver.wallet);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.SolanaPricePusherJito = SolanaPricePusherJito;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pythnetwork/price-pusher",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "Pyth Price Pusher",
|
|
5
5
|
"homepage": "https://pyth.network",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@pythnetwork/pyth-sui-js": "*",
|
|
60
60
|
"@truffle/hdwallet-provider": "^2.1.3",
|
|
61
61
|
"aptos": "^1.8.5",
|
|
62
|
+
"jito-ts": "^3.0.1",
|
|
62
63
|
"joi": "^17.6.0",
|
|
63
64
|
"near-api-js": "^3.0.2",
|
|
64
65
|
"web3": "^1.8.1",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"yaml": "^2.1.1",
|
|
67
68
|
"yargs": "^17.5.1"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "70c2c8ec4b5092729791f642493072565d953439"
|
|
70
71
|
}
|