@@ -484,18 +484,16 @@ fn build_jito_stake(
484484 let mut instructions = Vec :: new ( ) ;
485485
486486 // Optionally create ATA for pool mint (JitoSOL) if requested
487+ // Use CreateIdempotent (&[1]) so the instruction is a no-op if the ATA already exists,
488+ // avoiding "Provided owner is not allowed" errors when trustedTokens DB is out of sync.
487489 if config. create_associated_token_account == Some ( true ) {
488- instructions. push ( Instruction :: new_with_bytes (
489- ata_program,
490- & [ ] ,
491- vec ! [
492- AccountMeta :: new( * fee_payer, true ) ,
493- AccountMeta :: new( destination_pool_account, false ) ,
494- AccountMeta :: new_readonly( * fee_payer, false ) ,
495- AccountMeta :: new_readonly( pool_mint, false ) ,
496- AccountMeta :: new_readonly( system_program, false ) ,
497- AccountMeta :: new_readonly( token_program, false ) ,
498- ] ,
490+ instructions. push ( create_ata_idempotent_ix (
491+ fee_payer,
492+ & destination_pool_account,
493+ fee_payer,
494+ & pool_mint,
495+ & system_program,
496+ & token_program,
499497 ) ) ;
500498 }
501499
@@ -967,26 +965,21 @@ fn build_enable_token(
967965 let ata_program: Pubkey = SPL_ATA_PROGRAM_ID . parse ( ) . unwrap ( ) ;
968966 let system_program: Pubkey = SYSTEM_PROGRAM_ID . parse ( ) . unwrap ( ) ;
969967
970- use solana_sdk:: instruction:: AccountMeta ;
971-
972968 // Build one instruction per token
969+ // Use CreateIdempotent so the instruction is a no-op if the ATA already exists.
973970 let instructions: Vec < Instruction > = token_pairs
974971 . iter ( )
975972 . map ( |( mint, token_program) | {
976973 let seeds = & [ owner. as_ref ( ) , token_program. as_ref ( ) , mint. as_ref ( ) ] ;
977974 let ( ata, _bump) = Pubkey :: find_program_address ( seeds, & ata_program) ;
978975
979- Instruction :: new_with_bytes (
980- ata_program,
981- & [ ] ,
982- vec ! [
983- AccountMeta :: new( fee_payer, true ) ,
984- AccountMeta :: new( ata, false ) ,
985- AccountMeta :: new_readonly( owner, false ) ,
986- AccountMeta :: new_readonly( * mint, false ) ,
987- AccountMeta :: new_readonly( system_program, false ) ,
988- AccountMeta :: new_readonly( * token_program, false ) ,
989- ] ,
976+ create_ata_idempotent_ix (
977+ & fee_payer,
978+ & ata,
979+ & owner,
980+ mint,
981+ & system_program,
982+ token_program,
990983 )
991984 } )
992985 . collect ( ) ;
0 commit comments