@pythnetwork/price-pusher 6.3.1 → 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/index.js +2 -0
- package/lib/solana/command.d.ts +25 -0
- package/lib/solana/command.d.ts.map +1 -0
- package/lib/solana/command.js +133 -0
- package/lib/solana/solana.d.ts +33 -0
- package/lib/solana/solana.d.ts.map +1 -0
- package/lib/solana/solana.js +135 -0
- package/package.json +4 -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/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const command_2 = __importDefault(require("./evm/command"));
|
|
|
11
11
|
const command_3 = __importDefault(require("./aptos/command"));
|
|
12
12
|
const command_4 = __importDefault(require("./sui/command"));
|
|
13
13
|
const command_5 = __importDefault(require("./near/command"));
|
|
14
|
+
const command_6 = __importDefault(require("./solana/command"));
|
|
14
15
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
15
16
|
.config("config")
|
|
16
17
|
.global("config")
|
|
@@ -19,4 +20,5 @@ const command_5 = __importDefault(require("./near/command"));
|
|
|
19
20
|
.command(command_3.default)
|
|
20
21
|
.command(command_4.default)
|
|
21
22
|
.command(command_5.default)
|
|
23
|
+
.command(command_6.default)
|
|
22
24
|
.help().argv;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Options } from "yargs";
|
|
2
|
+
import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
|
|
3
|
+
declare const _default: {
|
|
4
|
+
command: string;
|
|
5
|
+
describe: string;
|
|
6
|
+
builder: {
|
|
7
|
+
"pushing-frequency": Options;
|
|
8
|
+
"polling-frequency": Options;
|
|
9
|
+
"pyth-contract-address": Options;
|
|
10
|
+
"price-service-endpoint": Options;
|
|
11
|
+
"price-config-file": Options;
|
|
12
|
+
endpoint: Options;
|
|
13
|
+
"keypair-file": Options;
|
|
14
|
+
"shard-id": Options;
|
|
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;
|
|
20
|
+
};
|
|
21
|
+
handler: (argv: any) => void;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
export declare const onBundleResult: (c: SearcherClient) => void;
|
|
25
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;oBAqDrB,GAAG;;AAnD9B,wBAkJE;AAEF,eAAO,MAAM,cAAc,MAAO,cAAc,SAO/C,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.onBundleResult = void 0;
|
|
30
|
+
const options = __importStar(require("../options"));
|
|
31
|
+
const price_config_1 = require("../price-config");
|
|
32
|
+
const price_service_client_1 = require("@pythnetwork/price-service-client");
|
|
33
|
+
const pyth_price_listener_1 = require("../pyth-price-listener");
|
|
34
|
+
const solana_1 = require("./solana");
|
|
35
|
+
const controller_1 = require("../controller");
|
|
36
|
+
const pyth_solana_receiver_1 = require("@pythnetwork/pyth-solana-receiver");
|
|
37
|
+
const nodewallet_1 = __importDefault(require("@coral-xyz/anchor/dist/cjs/nodewallet"));
|
|
38
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
39
|
+
const fs_1 = __importDefault(require("fs"));
|
|
40
|
+
const web3_js_2 = require("@solana/web3.js");
|
|
41
|
+
const searcher_1 = require("jito-ts/dist/sdk/block-engine/searcher");
|
|
42
|
+
exports.default = {
|
|
43
|
+
command: "solana",
|
|
44
|
+
describe: "run price pusher for solana",
|
|
45
|
+
builder: {
|
|
46
|
+
endpoint: {
|
|
47
|
+
description: "Solana RPC API endpoint",
|
|
48
|
+
type: "string",
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
"keypair-file": {
|
|
52
|
+
description: "Path to a keypair file",
|
|
53
|
+
type: "string",
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
56
|
+
"shard-id": {
|
|
57
|
+
description: "Shard ID",
|
|
58
|
+
type: "number",
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
61
|
+
"compute-unit-price-micro-lamports": {
|
|
62
|
+
description: "Priority fee per compute unit",
|
|
63
|
+
type: "number",
|
|
64
|
+
default: 50000,
|
|
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
|
+
},
|
|
86
|
+
...options.priceConfigFile,
|
|
87
|
+
...options.priceServiceEndpoint,
|
|
88
|
+
...options.pythContractAddress,
|
|
89
|
+
...options.pollingFrequency,
|
|
90
|
+
...options.pushingFrequency,
|
|
91
|
+
},
|
|
92
|
+
handler: function (argv) {
|
|
93
|
+
const { endpoint, keypairFile, shardId, computeUnitPriceMicroLamports, priceConfigFile, priceServiceEndpoint, pythContractAddress, pushingFrequency, pollingFrequency, jitoEndpoint, jitoKeypairFile, jitoTipLamports, jitoBundleSize, } = argv;
|
|
94
|
+
const priceConfigs = (0, price_config_1.readPriceConfigFile)(priceConfigFile);
|
|
95
|
+
const priceServiceConnection = new price_service_client_1.PriceServiceConnection(priceServiceEndpoint, {
|
|
96
|
+
logger: {
|
|
97
|
+
// Log only warnings and errors from the price service client
|
|
98
|
+
info: () => undefined,
|
|
99
|
+
warn: console.warn,
|
|
100
|
+
error: console.error,
|
|
101
|
+
debug: () => undefined,
|
|
102
|
+
trace: () => undefined,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
const priceItems = priceConfigs.map(({ id, alias }) => ({ id, alias }));
|
|
106
|
+
const pythListener = new pyth_price_listener_1.PythPriceListener(priceServiceConnection, priceItems);
|
|
107
|
+
const wallet = new nodewallet_1.default(web3_js_1.Keypair.fromSecretKey(Uint8Array.from(JSON.parse(fs_1.default.readFileSync(keypairFile, "ascii")))));
|
|
108
|
+
const pythSolanaReceiver = new pyth_solana_receiver_1.PythSolanaReceiver({
|
|
109
|
+
connection: new web3_js_1.Connection(endpoint),
|
|
110
|
+
wallet,
|
|
111
|
+
pushOracleProgramId: new web3_js_2.PublicKey(pythContractAddress),
|
|
112
|
+
});
|
|
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
|
+
}
|
|
123
|
+
const solanaPriceListener = new solana_1.SolanaPriceListener(pythSolanaReceiver, shardId, priceItems, { pollingFrequency });
|
|
124
|
+
const controller = new controller_1.Controller(priceConfigs, pythListener, solanaPriceListener, solanaPricePusher, { pushingFrequency });
|
|
125
|
+
controller.start();
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
const onBundleResult = (c) => {
|
|
129
|
+
c.onBundleResult(() => undefined, (e) => {
|
|
130
|
+
console.log("Error in bundle result: ", e);
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
exports.onBundleResult = onBundleResult;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
|
|
2
|
+
import { ChainPriceListener, IPricePusher, PriceInfo, PriceItem } from "../interface";
|
|
3
|
+
import { DurationInSeconds } from "../utils";
|
|
4
|
+
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
|
|
5
|
+
import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
|
|
6
|
+
export declare class SolanaPriceListener extends ChainPriceListener {
|
|
7
|
+
private pythSolanaReceiver;
|
|
8
|
+
private shardId;
|
|
9
|
+
constructor(pythSolanaReceiver: PythSolanaReceiver, shardId: number, priceItems: PriceItem[], config: {
|
|
10
|
+
pollingFrequency: DurationInSeconds;
|
|
11
|
+
});
|
|
12
|
+
getOnChainPriceInfo(priceId: string): Promise<PriceInfo | undefined>;
|
|
13
|
+
}
|
|
14
|
+
export declare class SolanaPricePusher implements IPricePusher {
|
|
15
|
+
private pythSolanaReceiver;
|
|
16
|
+
private priceServiceConnection;
|
|
17
|
+
private shardId;
|
|
18
|
+
private computeUnitPriceMicroLamports;
|
|
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);
|
|
31
|
+
updatePriceFeed(priceIds: string[], pubTimesToPush: number[]): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=solana.d.ts.map
|
|
@@ -0,0 +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,qBAAa,mBAAoB,SAAQ,kBAAkB;IAEvD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,OAAO;gBADP,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,EAAE,MAAM,EACvB,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC;KACrC;IAKG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;CA2B3E;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAElD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,6BAA6B;IACrC,OAAO,CAAC,cAAc;gBAJd,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,MAAM,EACf,6BAA6B,EAAE,MAAM,EACrC,cAAc,GAAE,OAAe;IAGnC,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;CA+CjB;AAED,qBAAa,qBAAsB,YAAW,YAAY;IAEtD,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;gBALd,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,MAAM;IAG1B,eAAe,CACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,IAAI,CAAC;CAwDjB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaPricePusherJito = exports.SolanaPricePusher = exports.SolanaPriceListener = void 0;
|
|
4
|
+
const interface_1 = require("../interface");
|
|
5
|
+
const solana_utils_1 = require("@pythnetwork/solana-utils");
|
|
6
|
+
class SolanaPriceListener extends interface_1.ChainPriceListener {
|
|
7
|
+
pythSolanaReceiver;
|
|
8
|
+
shardId;
|
|
9
|
+
constructor(pythSolanaReceiver, shardId, priceItems, config) {
|
|
10
|
+
super("solana", config.pollingFrequency, priceItems);
|
|
11
|
+
this.pythSolanaReceiver = pythSolanaReceiver;
|
|
12
|
+
this.shardId = shardId;
|
|
13
|
+
}
|
|
14
|
+
async getOnChainPriceInfo(priceId) {
|
|
15
|
+
try {
|
|
16
|
+
const priceFeedAccount = await this.pythSolanaReceiver.fetchPriceFeedAccount(this.shardId, Buffer.from(priceId, "hex"));
|
|
17
|
+
console.log(`Polled a Solana on chain price for feed ${this.priceIdToAlias.get(priceId)} (${priceId}).`);
|
|
18
|
+
if (priceFeedAccount) {
|
|
19
|
+
return {
|
|
20
|
+
conf: priceFeedAccount.priceMessage.conf.toString(),
|
|
21
|
+
price: priceFeedAccount.priceMessage.price.toString(),
|
|
22
|
+
publishTime: priceFeedAccount.priceMessage.publishTime.toNumber(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
console.error(`Polling on-chain price for ${priceId} failed. Error:`);
|
|
31
|
+
console.error(e);
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.SolanaPriceListener = SolanaPriceListener;
|
|
37
|
+
class SolanaPricePusher {
|
|
38
|
+
pythSolanaReceiver;
|
|
39
|
+
priceServiceConnection;
|
|
40
|
+
shardId;
|
|
41
|
+
computeUnitPriceMicroLamports;
|
|
42
|
+
alreadySending;
|
|
43
|
+
constructor(pythSolanaReceiver, priceServiceConnection, shardId, computeUnitPriceMicroLamports, alreadySending = false) {
|
|
44
|
+
this.pythSolanaReceiver = pythSolanaReceiver;
|
|
45
|
+
this.priceServiceConnection = priceServiceConnection;
|
|
46
|
+
this.shardId = shardId;
|
|
47
|
+
this.computeUnitPriceMicroLamports = computeUnitPriceMicroLamports;
|
|
48
|
+
this.alreadySending = alreadySending;
|
|
49
|
+
}
|
|
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;
|
|
56
|
+
if (priceIds.length === 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let priceFeedUpdateData;
|
|
60
|
+
try {
|
|
61
|
+
priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(priceIds);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
console.error(new Date(), "getPriceFeedsUpdateData failed:", e);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const transactionBuilder = this.pythSolanaReceiver.newTransactionBuilder({
|
|
68
|
+
closeUpdateAccounts: true,
|
|
69
|
+
});
|
|
70
|
+
await transactionBuilder.addUpdatePriceFeed(priceFeedUpdateData, this.shardId);
|
|
71
|
+
const transactions = await transactionBuilder.buildVersionedTransactions({
|
|
72
|
+
computeUnitPriceMicroLamports: this.computeUnitPriceMicroLamports,
|
|
73
|
+
tightComputeBudget: true,
|
|
74
|
+
});
|
|
75
|
+
try {
|
|
76
|
+
await (0, solana_utils_1.sendTransactions)(transactions, this.pythSolanaReceiver.connection, this.pythSolanaReceiver.wallet);
|
|
77
|
+
console.log(new Date(), "updatePriceFeed successful");
|
|
78
|
+
this.alreadySending = false;
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
console.error(new Date(), "updatePriceFeed failed", e);
|
|
82
|
+
this.alreadySending = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
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",
|
|
@@ -55,9 +55,11 @@
|
|
|
55
55
|
"@mysten/sui.js": "^0.49.1",
|
|
56
56
|
"@pythnetwork/price-service-client": "*",
|
|
57
57
|
"@pythnetwork/pyth-sdk-solidity": "*",
|
|
58
|
+
"@pythnetwork/pyth-solana-receiver": "*",
|
|
58
59
|
"@pythnetwork/pyth-sui-js": "*",
|
|
59
60
|
"@truffle/hdwallet-provider": "^2.1.3",
|
|
60
61
|
"aptos": "^1.8.5",
|
|
62
|
+
"jito-ts": "^3.0.1",
|
|
61
63
|
"joi": "^17.6.0",
|
|
62
64
|
"near-api-js": "^3.0.2",
|
|
63
65
|
"web3": "^1.8.1",
|
|
@@ -65,5 +67,5 @@
|
|
|
65
67
|
"yaml": "^2.1.1",
|
|
66
68
|
"yargs": "^17.5.1"
|
|
67
69
|
},
|
|
68
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "70c2c8ec4b5092729791f642493072565d953439"
|
|
69
71
|
}
|