@@ -100,11 +100,7 @@ export class SolanaPricePusher implements IPricePusher {
100100 private computeUnitPriceMicroLamports : number
101101 ) { }
102102
103- async updatePriceFeed (
104- priceIds : string [ ] ,
105- // eslint-disable-next-line @typescript-eslint/no-unused-vars
106- _pubTimesToPush : number [ ]
107- ) : Promise < void > {
103+ async updatePriceFeed ( priceIds : string [ ] ) : Promise < void > {
108104 if ( priceIds . length === 0 ) {
109105 return ;
110106 }
@@ -189,11 +185,11 @@ export class SolanaPricePusherJito implements IPricePusher {
189185 }
190186 }
191187
192- async updatePriceFeed (
193- priceIds : string [ ] ,
194- // eslint-disable-next-line @typescript-eslint/no-unused-vars
195- _pubTimesToPush : number [ ]
196- ) : Promise < void > {
188+ private async sleep ( ms : number ) : Promise < void > {
189+ return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
190+ }
191+
192+ async updatePriceFeed ( priceIds : string [ ] ) : Promise < void > {
197193 const recentJitoTip = await this . getRecentJitoTipLamports ( ) ;
198194 const jitoTip =
199195 this . dynamicJitoTips && recentJitoTip !== undefined
@@ -234,11 +230,32 @@ export class SolanaPricePusherJito implements IPricePusher {
234230 jitoBundleSize : this . jitoBundleSize ,
235231 } ) ;
236232
237- await sendTransactionsJito (
238- transactions ,
239- this . searcherClient ,
240- this . pythSolanaReceiver . wallet
241- ) ;
233+ let retries = 60 ;
234+ while ( retries > 0 ) {
235+ try {
236+ await sendTransactionsJito (
237+ transactions ,
238+ this . searcherClient ,
239+ this . pythSolanaReceiver . wallet
240+ ) ;
241+ break ;
242+ } catch ( err : any ) {
243+ if ( err . code === 8 && err . details ?. includes ( "Rate limit exceeded" ) ) {
244+ this . logger . warn ( "Rate limit hit, waiting before retry..." ) ;
245+ await this . sleep ( 1100 ) ; // Wait slightly more than 1 second
246+ retries -- ;
247+ if ( retries === 0 ) {
248+ this . logger . error ( "Max retries reached for rate limit" ) ;
249+ throw err ;
250+ }
251+ } else {
252+ throw err ;
253+ }
254+ }
255+ }
256+
257+ // Add a delay between bundles to avoid rate limiting
258+ await this . sleep ( 1100 ) ;
242259 }
243260 }
244261}
0 commit comments