3131 spl_stake_pool:: {
3232 self ,
3333 borsh:: get_instance_packed_len,
34- find_stake_program_address, find_transient_stake_program_address,
35- find_withdraw_authority_program_address,
34+ find_stake_program_address, find_withdraw_authority_program_address,
3635 stake_program:: { self , StakeState } ,
3736 state:: { Fee , StakePool , ValidatorList } ,
38- MAX_VALIDATORS_TO_UPDATE ,
3937 } ,
4038 std:: process:: exit,
4139} ;
@@ -243,7 +241,7 @@ fn command_create_pool(
243241 deposit_authority,
244242 fee,
245243 max_validators,
246- ) ? ,
244+ ) ,
247245 ] ,
248246 Some ( & config. fee_payer . pubkey ( ) ) ,
249247 ) ;
@@ -283,22 +281,17 @@ fn command_vsa_create(
283281 stake_pool_address : & Pubkey ,
284282 vote_account : & Pubkey ,
285283) -> CommandResult {
286- let ( stake_account, _) =
287- find_stake_program_address ( & spl_stake_pool:: id ( ) , & vote_account, & stake_pool_address) ;
288-
289- println ! ( "Creating stake account {}" , stake_account) ;
284+ println ! ( "Creating stake account on {}" , vote_account) ;
290285
291286 let mut transaction = Transaction :: new_with_payer (
292287 & [
293288 // Create new validator stake account address
294- spl_stake_pool:: instruction:: create_validator_stake_account (
295- & spl_stake_pool:: id ( ) ,
289+ spl_stake_pool:: instruction:: create_validator_stake_account_with_vote (
296290 & stake_pool_address,
297291 & config. staker . pubkey ( ) ,
298292 & config. fee_payer . pubkey ( ) ,
299- & stake_account,
300293 & vote_account,
301- ) ? ,
294+ ) ,
302295 ] ,
303296 Some ( & config. fee_payer . pubkey ( ) ) ,
304297 ) ;
@@ -348,30 +341,18 @@ fn command_vsa_add(
348341 command_update ( config, stake_pool_address, false , false ) ?;
349342 }
350343
351- let mut instructions: Vec < Instruction > = vec ! [ ] ;
352- let mut signers = vec ! [ config. fee_payer. as_ref( ) , config. staker. as_ref( ) ] ;
353-
354- // Calculate Withdraw stake pool authorities
355- let pool_withdraw_authority =
356- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
357-
358- instructions. extend ( vec ! [
359- // Add validator stake account to the pool
360- spl_stake_pool:: instruction:: add_validator_to_pool(
361- & spl_stake_pool:: id( ) ,
362- & stake_pool_address,
363- & config. staker. pubkey( ) ,
364- & pool_withdraw_authority,
365- & stake_pool. validator_list,
366- & stake_account_address,
367- ) ?,
368- ] ) ;
344+ let instruction = spl_stake_pool:: instruction:: add_validator_to_pool_with_vote (
345+ & stake_pool,
346+ & stake_pool_address,
347+ & vote_account,
348+ ) ;
369349
370350 let mut transaction =
371- Transaction :: new_with_payer ( & instructions , Some ( & config. fee_payer . pubkey ( ) ) ) ;
351+ Transaction :: new_with_payer ( & [ instruction ] , Some ( & config. fee_payer . pubkey ( ) ) ) ;
372352
373353 let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
374354 check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
355+ let mut signers = vec ! [ config. fee_payer. as_ref( ) , config. staker. as_ref( ) ] ;
375356 unique_signers ! ( signers) ;
376357 transaction. sign ( & signers, recent_blockhash) ;
377358 send_transaction ( & config, transaction) ?;
@@ -389,32 +370,19 @@ fn command_vsa_remove(
389370 }
390371
391372 let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
392- let pool_withdraw_authority =
393- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
394- let ( validator_stake_account, _) =
395- find_stake_program_address ( & spl_stake_pool:: id ( ) , & vote_account, stake_pool_address) ;
396- let ( transient_stake_account, _) = find_transient_stake_program_address (
397- & spl_stake_pool:: id ( ) ,
398- & vote_account,
399- stake_pool_address,
400- ) ;
401373
402374 let staker_pubkey = config. staker . pubkey ( ) ;
403375 let new_authority = new_authority. as_ref ( ) . unwrap_or ( & staker_pubkey) ;
404376
405377 let mut transaction = Transaction :: new_with_payer (
406378 & [
407379 // Create new validator stake account address
408- spl_stake_pool:: instruction:: remove_validator_from_pool (
409- & spl_stake_pool:: id ( ) ,
410- & stake_pool_address,
411- & config. staker . pubkey ( ) ,
412- & pool_withdraw_authority,
413- & new_authority,
414- & stake_pool. validator_list ,
415- & validator_stake_account,
416- & transient_stake_account,
417- ) ?,
380+ spl_stake_pool:: instruction:: remove_validator_from_pool_with_vote (
381+ & stake_pool,
382+ stake_pool_address,
383+ vote_account,
384+ new_authority,
385+ ) ,
418386 ] ,
419387 Some ( & config. fee_payer . pubkey ( ) ) ,
420388 ) ;
@@ -441,28 +409,15 @@ fn command_increase_validator_stake(
441409 }
442410
443411 let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
444- let pool_withdraw_authority =
445- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
446- let ( transient_stake_address, _) = find_transient_stake_program_address (
447- & spl_stake_pool:: id ( ) ,
448- & vote_account,
412+ let instruction = spl_stake_pool:: instruction:: increase_validator_stake_with_vote (
413+ & stake_pool,
449414 stake_pool_address,
415+ vote_account,
416+ lamports,
450417 ) ;
451418
452- let mut transaction = Transaction :: new_with_payer (
453- & [ spl_stake_pool:: instruction:: increase_validator_stake (
454- & spl_stake_pool:: id ( ) ,
455- & stake_pool_address,
456- & config. staker . pubkey ( ) ,
457- & pool_withdraw_authority,
458- & stake_pool. validator_list ,
459- & stake_pool. reserve_stake ,
460- & transient_stake_address,
461- & vote_account,
462- lamports,
463- ) ] ,
464- Some ( & config. fee_payer . pubkey ( ) ) ,
465- ) ;
419+ let mut transaction =
420+ Transaction :: new_with_payer ( & [ instruction] , Some ( & config. fee_payer . pubkey ( ) ) ) ;
466421
467422 let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
468423 check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
@@ -486,29 +441,15 @@ fn command_decrease_validator_stake(
486441 }
487442
488443 let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
489- let pool_withdraw_authority =
490- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
491- let ( validator_stake_address, _) =
492- find_stake_program_address ( & spl_stake_pool:: id ( ) , & vote_account, stake_pool_address) ;
493- let ( transient_stake_address, _) = find_transient_stake_program_address (
494- & spl_stake_pool:: id ( ) ,
495- & vote_account,
444+ let instruction = spl_stake_pool:: instruction:: decrease_validator_stake_with_vote (
445+ & stake_pool,
496446 stake_pool_address,
447+ vote_account,
448+ lamports,
497449 ) ;
498450
499- let mut transaction = Transaction :: new_with_payer (
500- & [ spl_stake_pool:: instruction:: decrease_validator_stake (
501- & spl_stake_pool:: id ( ) ,
502- & stake_pool_address,
503- & config. staker . pubkey ( ) ,
504- & pool_withdraw_authority,
505- & stake_pool. validator_list ,
506- & validator_stake_address,
507- & transient_stake_address,
508- lamports,
509- ) ] ,
510- Some ( & config. fee_payer . pubkey ( ) ) ,
511- ) ;
451+ let mut transaction =
452+ Transaction :: new_with_payer ( & [ instruction] , Some ( & config. fee_payer . pubkey ( ) ) ) ;
512453
513454 let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
514455 check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
@@ -745,41 +686,12 @@ fn command_update(
745686
746687 let validator_list = get_validator_list ( & config. rpc_client , & stake_pool. validator_list ) ?;
747688
748- let vote_accounts: Vec < Pubkey > = validator_list
749- . validators
750- . iter ( )
751- . map ( |item| item. vote_account_address )
752- . collect ( ) ;
753-
754- println ! ( "Updating stake pool..." ) ;
755- let ( withdraw_authority, _) =
756- find_withdraw_authority_program_address ( & spl_stake_pool:: id ( ) , & stake_pool_address) ;
757-
758- let mut instructions: Vec < Instruction > = vec ! [ ] ;
759- let mut start_index = 0 ;
760- for accounts_chunk in vote_accounts. chunks ( MAX_VALIDATORS_TO_UPDATE ) {
761- instructions. push ( spl_stake_pool:: instruction:: update_validator_list_balance (
762- & spl_stake_pool:: id ( ) ,
763- stake_pool_address,
764- & withdraw_authority,
765- & stake_pool. validator_list ,
766- & stake_pool. reserve_stake ,
767- & accounts_chunk,
768- start_index,
769- no_merge,
770- ) ) ;
771- start_index += MAX_VALIDATORS_TO_UPDATE as u32 ;
772- }
773-
774- instructions. push ( spl_stake_pool:: instruction:: update_stake_pool_balance (
775- & spl_stake_pool:: id ( ) ,
689+ let instructions = spl_stake_pool:: instruction:: update_stake_pool (
690+ & stake_pool,
691+ & validator_list,
776692 stake_pool_address,
777- & withdraw_authority,
778- & stake_pool. validator_list ,
779- & stake_pool. reserve_stake ,
780- & stake_pool. manager_fee_account ,
781- & stake_pool. pool_mint ,
782- ) ) ;
693+ no_merge,
694+ ) ;
783695
784696 // TODO: A faster solution would be to send all the `update_validator_list_balance` instructions concurrently
785697 for instruction in instructions {
@@ -1014,7 +926,7 @@ fn command_withdraw(
1014926 & stake_pool. pool_mint ,
1015927 & spl_token:: id ( ) ,
1016928 withdraw_account. pool_amount ,
1017- ) ? ) ;
929+ ) ) ;
1018930 }
1019931
1020932 let mut transaction =
@@ -1066,7 +978,7 @@ fn command_set_manager(
1066978 & config. manager . pubkey ( ) ,
1067979 & new_manager,
1068980 & new_fee_receiver,
1069- ) ? ] ,
981+ ) ] ,
1070982 Some ( & config. fee_payer . pubkey ( ) ) ,
1071983 ) ;
1072984
@@ -1090,7 +1002,7 @@ fn command_set_staker(
10901002 & stake_pool_address,
10911003 & config. manager . pubkey ( ) ,
10921004 & new_staker,
1093- ) ? ] ,
1005+ ) ] ,
10941006 Some ( & config. fee_payer . pubkey ( ) ) ,
10951007 ) ;
10961008
0 commit comments