@@ -26,6 +26,11 @@ export const DEFAULT_COMPUTE_BUDGET_UNITS = 200000;
2626export const PACKET_DATA_SIZE_WITH_ROOM_FOR_COMPUTE_BUDGET =
2727 PACKET_DATA_SIZE - 52 ;
2828
29+ /**
30+ * The maximum number of transactions in a Jito bundle.
31+ */
32+ export const JITO_BUNDLE_SIZE = 5 ;
33+
2934/**
3035 * An instruction with some extra information that will be used to build transactions.
3136 */
@@ -46,7 +51,6 @@ export type PriorityFeeConfig = {
4651 computeUnitPriceMicroLamports ?: number ;
4752 tightComputeBudget ?: boolean ;
4853 jitoTipLamports ?: number ;
49- jitoBundleSize ?: number ;
5054} ;
5155
5256/**
@@ -188,7 +192,11 @@ export class TransactionBuilder {
188192 this . transactionInstructions . length - 1
189193 ] . instructions ,
190194 instruction ,
191- buildJitoTipInstruction ( this . payer , 1 ) ,
195+ this . transactionInstructions . length % JITO_BUNDLE_SIZE === 0
196+ ? buildJitoTipInstruction ( this . payer , 1 )
197+ : ComputeBudgetProgram . setComputeUnitPrice ( {
198+ microLamports : 1 ,
199+ } ) ,
192200 ComputeBudgetProgram . setComputeUnitLimit ( { units : 1 } ) ,
193201 ] ,
194202 true ,
@@ -232,9 +240,6 @@ export class TransactionBuilder {
232240 await this . connection . getLatestBlockhash ( { commitment : "confirmed" } )
233241 ) . blockhash ;
234242
235- const jitoBundleSize =
236- args . jitoBundleSize || this . transactionInstructions . length ;
237-
238243 return this . transactionInstructions . map (
239244 ( { instructions, signers, computeUnits } , index ) => {
240245 const instructionsWithComputeBudget : TransactionInstruction [ ] = [
@@ -255,7 +260,7 @@ export class TransactionBuilder {
255260 } ) ,
256261 ) ;
257262 }
258- if ( args . jitoTipLamports && index % jitoBundleSize === 0 ) {
263+ if ( args . jitoTipLamports && index % JITO_BUNDLE_SIZE === 0 ) {
259264 instructionsWithComputeBudget . push (
260265 buildJitoTipInstruction ( this . payer , args . jitoTipLamports ) ,
261266 ) ;
@@ -297,9 +302,6 @@ export class TransactionBuilder {
297302 buildLegacyTransactions (
298303 args : PriorityFeeConfig ,
299304 ) : { tx : Transaction ; signers : Signer [ ] } [ ] {
300- const jitoBundleSize =
301- args . jitoBundleSize || this . transactionInstructions . length ;
302-
303305 return this . transactionInstructions . map (
304306 ( { instructions, signers, computeUnits } , index ) => {
305307 const instructionsWithComputeBudget : TransactionInstruction [ ] = [
@@ -320,7 +322,7 @@ export class TransactionBuilder {
320322 } ) ,
321323 ) ;
322324 }
323- if ( args . jitoTipLamports && index % jitoBundleSize === 0 ) {
325+ if ( args . jitoTipLamports && index % JITO_BUNDLE_SIZE === 0 ) {
324326 instructionsWithComputeBudget . push (
325327 buildJitoTipInstruction ( this . payer , args . jitoTipLamports ) ,
326328 ) ;
0 commit comments