@@ -100,11 +100,7 @@ export class SolanaPricePusher implements IPricePusher {
100
100
private computeUnitPriceMicroLamports : number
101
101
) { }
102
102
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 > {
108
104
if ( priceIds . length === 0 ) {
109
105
return ;
110
106
}
@@ -189,11 +185,11 @@ export class SolanaPricePusherJito implements IPricePusher {
189
185
}
190
186
}
191
187
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 > {
197
193
const recentJitoTip = await this . getRecentJitoTipLamports ( ) ;
198
194
const jitoTip =
199
195
this . dynamicJitoTips && recentJitoTip !== undefined
@@ -234,11 +230,32 @@ export class SolanaPricePusherJito implements IPricePusher {
234
230
jitoBundleSize : this . jitoBundleSize ,
235
231
} ) ;
236
232
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 ) ;
242
259
}
243
260
}
244
261
}
0 commit comments