@@ -48,8 +48,10 @@ pub enum StakePoolInstruction {
4848 /// 3. `[w]` Stake account to be created
4949 /// 4. `[]` Validator this stake account will vote for
5050 /// 5. `[]` Rent sysvar
51- /// 6. `[]` System program
52- /// 7. `[]` Stake program
51+ /// 6. `[]` Stake History sysvar
52+ /// 7. `[]` Stake Config sysvar
53+ /// 8. `[]` System program
54+ /// 9. `[]` Stake program
5355 CreateValidatorStakeAccount ,
5456
5557 /// (Staker only) Adds stake account delegated to validator to the pool's
@@ -98,29 +100,23 @@ pub enum StakePoolInstruction {
98100 /// In order to rebalance the pool without taking custody, the staker needs
99101 /// a way of reducing the stake on a stake account. This instruction splits
100102 /// some amount of stake, up to the total activated stake, from the canonical
101- /// validator stake account, into its "transient" stake account, defined by:
102- ///
103- /// ```ignore
104- /// Pubkey::find_program_address(
105- /// &[&stake_account_address.to_bytes()[..32],], program_id,
106- /// )
107- /// ```
103+ /// validator stake account, into its "transient" stake account.
108104 ///
109105 /// The instruction only succeeds if the transient stake account does not
110106 /// exist. The amount of lamports to move must be at least rent-exemption
111107 /// plus 1 lamport.
112108 ///
113109 /// 0. `[]` Stake pool
114110 /// 1. `[s]` Stake pool staker
115- /// 2. `[]` Validator list
116- /// 3. `[]` Stake pool withdraw authority
111+ /// 2. `[]` Stake pool withdraw authority
112+ /// 3. `[]` Validator list
117113 /// 5. `[w]` Canonical stake account to split from
118114 /// 5. `[w]` Transient stake account to receive split
119115 /// 6. `[]` Clock sysvar
120116 /// 7. `[]` Rent sysvar
121117 /// 8. `[]` System program
122118 /// 9. `[]` Stake program
123- /// userdata: amount of lamports to split
119+ /// userdata: amount of lamports to split into the transient stake account
124120 DecreaseValidatorStake ( u64 ) ,
125121
126122 /// (Staker only) Increase stake on a validator from the reserve account
@@ -135,13 +131,18 @@ pub enum StakePoolInstruction {
135131 ///
136132 /// 0. `[]` Stake pool
137133 /// 1. `[s]` Stake pool staker
138- /// 2. `[]` Validator list
139- /// 3. `[]` Stake pool withdraw authority
134+ /// 2. `[]` Stake pool withdraw authority
135+ /// 3. `[]` Validator list
140136 /// 4. `[w]` Stake pool reserve stake
141137 /// 5. `[w]` Transient stake account
142- /// 6. `[]` Canonical stake account
138+ /// 6. `[]` Validator vote account to delegate to
143139 /// 7. '[]' Clock sysvar
144- /// 8. `[]` Stake program
140+ /// 8. '[]' Rent sysvar
141+ /// 9. `[]` Stake History sysvar
142+ /// 10. `[]` Stake Config sysvar
143+ /// 11. `[]` System program
144+ /// 12. `[]` Stake program
145+ /// userdata: amount of lamports to split into the transient stake account
145146 IncreaseValidatorStake ( u64 ) ,
146147
147148 /// Updates balances of validator and transient stake accounts in the pool
@@ -249,6 +250,7 @@ pub fn initialize(
249250 manager : & Pubkey ,
250251 staker : & Pubkey ,
251252 validator_list : & Pubkey ,
253+ reserve_stake : & Pubkey ,
252254 pool_mint : & Pubkey ,
253255 manager_pool_account : & Pubkey ,
254256 token_program_id : & Pubkey ,
@@ -265,6 +267,7 @@ pub fn initialize(
265267 AccountMeta :: new_readonly( * manager, true ) ,
266268 AccountMeta :: new_readonly( * staker, false ) ,
267269 AccountMeta :: new( * validator_list, false ) ,
270+ AccountMeta :: new_readonly( * reserve_stake, false ) ,
268271 AccountMeta :: new_readonly( * pool_mint, false ) ,
269272 AccountMeta :: new_readonly( * manager_pool_account, false ) ,
270273 AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
@@ -364,14 +367,68 @@ pub fn remove_validator_from_pool(
364367
365368/// Creates `DecreaseValidatorStake` instruction (rebalance from validator account to
366369/// transient account)
367- pub fn decrease_validator_stake ( ) -> Result < Instruction , ProgramError > {
368- Err ( ProgramError :: IncorrectProgramId )
370+ pub fn decrease_validator_stake (
371+ program_id : & Pubkey ,
372+ stake_pool : & Pubkey ,
373+ staker : & Pubkey ,
374+ stake_pool_withdraw_authority : & Pubkey ,
375+ validator_list : & Pubkey ,
376+ validator_stake : & Pubkey ,
377+ transient_stake : & Pubkey ,
378+ lamports : u64 ,
379+ ) -> Result < Instruction , ProgramError > {
380+ let accounts = vec ! [
381+ AccountMeta :: new_readonly( * stake_pool, false ) ,
382+ AccountMeta :: new_readonly( * staker, true ) ,
383+ AccountMeta :: new_readonly( * stake_pool_withdraw_authority, false ) ,
384+ AccountMeta :: new_readonly( * validator_list, false ) ,
385+ AccountMeta :: new( * validator_stake, false ) ,
386+ AccountMeta :: new( * transient_stake, false ) ,
387+ AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
388+ AccountMeta :: new_readonly( sysvar:: rent:: id( ) , false ) ,
389+ AccountMeta :: new_readonly( system_program:: id( ) , false ) ,
390+ AccountMeta :: new_readonly( stake_program:: id( ) , false ) ,
391+ ] ;
392+ Ok ( Instruction {
393+ program_id : * program_id,
394+ accounts,
395+ data : StakePoolInstruction :: DecreaseValidatorStake ( lamports) . try_to_vec ( ) ?,
396+ } )
369397}
370398
371399/// Creates `IncreaseValidatorStake` instruction (rebalance from reserve account to
372400/// transient account)
373- pub fn increase_validator_stake ( ) -> Result < Instruction , ProgramError > {
374- Err ( ProgramError :: IncorrectProgramId )
401+ pub fn increase_validator_stake (
402+ program_id : & Pubkey ,
403+ stake_pool : & Pubkey ,
404+ staker : & Pubkey ,
405+ stake_pool_withdraw_authority : & Pubkey ,
406+ validator_list : & Pubkey ,
407+ reserve_stake : & Pubkey ,
408+ transient_stake : & Pubkey ,
409+ validator : & Pubkey ,
410+ lamports : u64 ,
411+ ) -> Result < Instruction , ProgramError > {
412+ let accounts = vec ! [
413+ AccountMeta :: new_readonly( * stake_pool, false ) ,
414+ AccountMeta :: new_readonly( * staker, true ) ,
415+ AccountMeta :: new_readonly( * stake_pool_withdraw_authority, false ) ,
416+ AccountMeta :: new_readonly( * validator_list, false ) ,
417+ AccountMeta :: new( * reserve_stake, false ) ,
418+ AccountMeta :: new( * transient_stake, false ) ,
419+ AccountMeta :: new_readonly( * validator, false ) ,
420+ AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
421+ AccountMeta :: new_readonly( sysvar:: rent:: id( ) , false ) ,
422+ AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
423+ AccountMeta :: new_readonly( stake_program:: config_id( ) , false ) ,
424+ AccountMeta :: new_readonly( system_program:: id( ) , false ) ,
425+ AccountMeta :: new_readonly( stake_program:: id( ) , false ) ,
426+ ] ;
427+ Ok ( Instruction {
428+ program_id : * program_id,
429+ accounts,
430+ data : StakePoolInstruction :: IncreaseValidatorStake ( lamports) . try_to_vec ( ) ?,
431+ } )
375432}
376433
377434/// Creates `UpdateValidatorListBalance` instruction (update validator stake account balances)
0 commit comments