Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
36 changes: 34 additions & 2 deletions apps/price_pusher/src/solana/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
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 @@ export class SolanaPricePusherJito implements IPricePusher {
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 @@ -192,7 +224,7 @@ export class SolanaPricePusherJito implements IPricePusher {
);

const transactions = await transactionBuilder.buildVersionedTransactions({
jitoTipLamports: this.jitoTipLamports,
jitoTipLamports: cappedJitoTip,
tightComputeBudget: true,
jitoBundleSize: this.jitoBundleSize,
});
Expand Down
Loading