Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/price_pusher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/price-pusher",
"version": "8.1.0",
"version": "8.2.0",
"description": "Pyth Price Pusher",
"homepage": "https://pyth.network",
"main": "lib/index.js",
Expand Down
7 changes: 7 additions & 0 deletions apps/price_pusher/src/solana/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export default {
type: "number",
optional: true,
} as Options,
"dynamic-jito-tips": {
description: "Use dynamic jito tips",
type: "boolean",
default: false,
} as Options,
"jito-bundle-size": {
description: "Number of transactions in each bundle",
type: "number",
Expand Down Expand Up @@ -94,6 +99,7 @@ export default {
jitoEndpoint,
jitoKeypairFile,
jitoTipLamports,
dynamicJitoTips,
jitoBundleSize,
updatesPerJitoBundle,
logLevel,
Expand Down Expand Up @@ -148,6 +154,7 @@ export default {
logger.child({ module: "SolanaPricePusherJito" }),
shardId,
jitoTipLamports,
dynamicJitoTips,
jitoClient,
jitoBundleSize,
updatesPerJitoBundle
Expand Down
46 changes: 39 additions & 7 deletions apps/price_pusher/src/solana/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
import {
sendTransactions,
sendTransactionsJito,

Check failure on line 12 in apps/price_pusher/src/solana/solana.ts

View workflow job for this annotation

GitHub Actions / test

'sendTransactionsJito' is defined but never used
} from "@pythnetwork/solana-utils";
import { SearcherClient } from "jito-ts/dist/sdk/block-engine/searcher";
import { sliceAccumulatorUpdateData } from "@pythnetwork/price-service-sdk";
import { Logger } from "pino";
import { LAMPORTS_PER_SOL } from "@solana/web3.js";

const HEALTH_CHECK_TIMEOUT_SECONDS = 60;
const MAX_JITO_TIP_LAMPORTS = LAMPORTS_PER_SOL / 100;
Copy link
Contributor Author

@guibescos guibescos Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll make this configurable but didn't have time today


export class SolanaPriceListener extends ChainPriceListener {
constructor(
Expand Down Expand Up @@ -155,17 +157,47 @@
private priceServiceConnection: PriceServiceConnection,
private logger: Logger,
private shardId: number,
private jitoTipLamports: number,
private defaultJitoTipLamports: number,
private dynamicJitoTips: boolean,
private searcherClient: SearcherClient,
private jitoBundleSize: number,
private updatesPerJitoBundle: number
) {}

async getRecentJitoTipLamports(): Promise<number | undefined> {
try {
const response = await fetch(
"http://bundles-api-rest.jito.wtf/api/v1/bundles/tip_floor"
);
if (!response.ok) {
this.logger.error(
{ status: response.status, statusText: response.statusText },
"getRecentJitoTips http request failed"
);
return undefined;
}
const data = await response.json();
return Math.floor(
Number(data[0].landed_tips_25th_percentile) * LAMPORTS_PER_SOL
);
} catch (err: any) {
this.logger.error({ err }, "getRecentJitoTips failed");
return undefined;
}
}

async updatePriceFeed(
priceIds: string[],
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_pubTimesToPush: number[]
): Promise<void> {
const jitoTip = this.dynamicJitoTips
? (await this.getRecentJitoTipLamports()) ?? this.defaultJitoTipLamports
: this.defaultJitoTipLamports;

const cappedJitoTip = Math.min(jitoTip, MAX_JITO_TIP_LAMPORTS);
this.logger.info({ cappedJitoTip }, "using jito tip of");

let priceFeedUpdateData: string[];
try {
priceFeedUpdateData = await this.priceServiceConnection.getLatestVaas(
Expand All @@ -191,17 +223,17 @@
this.shardId
);

const transactions = await transactionBuilder.buildVersionedTransactions({

Check failure on line 226 in apps/price_pusher/src/solana/solana.ts

View workflow job for this annotation

GitHub Actions / test

'transactions' is assigned a value but never used
jitoTipLamports: this.jitoTipLamports,
jitoTipLamports: cappedJitoTip,
tightComputeBudget: true,
jitoBundleSize: this.jitoBundleSize,
});

await sendTransactionsJito(
transactions,
this.searcherClient,
this.pythSolanaReceiver.wallet
);
// await sendTransactionsJito(
// transactions,
// this.searcherClient,
// this.pythSolanaReceiver.wallet
// );
}
}
}
Loading