@@ -48,8 +48,10 @@ pub enum StakePoolInstruction {
48
48
/// 3. `[w]` Stake account to be created
49
49
/// 4. `[]` Validator this stake account will vote for
50
50
/// 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
53
55
CreateValidatorStakeAccount ,
54
56
55
57
/// (Staker only) Adds stake account delegated to validator to the pool's
@@ -98,29 +100,23 @@ pub enum StakePoolInstruction {
98
100
/// In order to rebalance the pool without taking custody, the staker needs
99
101
/// a way of reducing the stake on a stake account. This instruction splits
100
102
/// 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.
108
104
///
109
105
/// The instruction only succeeds if the transient stake account does not
110
106
/// exist. The amount of lamports to move must be at least rent-exemption
111
107
/// plus 1 lamport.
112
108
///
113
109
/// 0. `[]` Stake pool
114
110
/// 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
117
113
/// 5. `[w]` Canonical stake account to split from
118
114
/// 5. `[w]` Transient stake account to receive split
119
115
/// 6. `[]` Clock sysvar
120
116
/// 7. `[]` Rent sysvar
121
117
/// 8. `[]` System program
122
118
/// 9. `[]` Stake program
123
- /// userdata: amount of lamports to split
119
+ /// userdata: amount of lamports to split into the transient stake account
124
120
DecreaseValidatorStake ( u64 ) ,
125
121
126
122
/// (Staker only) Increase stake on a validator from the reserve account
@@ -135,13 +131,18 @@ pub enum StakePoolInstruction {
135
131
///
136
132
/// 0. `[]` Stake pool
137
133
/// 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
140
136
/// 4. `[w]` Stake pool reserve stake
141
137
/// 5. `[w]` Transient stake account
142
- /// 6. `[]` Canonical stake account
138
+ /// 6. `[]` Validator vote account to delegate to
143
139
/// 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
145
146
IncreaseValidatorStake ( u64 ) ,
146
147
147
148
/// Updates balances of validator and transient stake accounts in the pool
@@ -249,6 +250,7 @@ pub fn initialize(
249
250
manager : & Pubkey ,
250
251
staker : & Pubkey ,
251
252
validator_list : & Pubkey ,
253
+ reserve_stake : & Pubkey ,
252
254
pool_mint : & Pubkey ,
253
255
manager_pool_account : & Pubkey ,
254
256
token_program_id : & Pubkey ,
@@ -265,6 +267,7 @@ pub fn initialize(
265
267
AccountMeta :: new_readonly( * manager, true ) ,
266
268
AccountMeta :: new_readonly( * staker, false ) ,
267
269
AccountMeta :: new( * validator_list, false ) ,
270
+ AccountMeta :: new_readonly( * reserve_stake, false ) ,
268
271
AccountMeta :: new_readonly( * pool_mint, false ) ,
269
272
AccountMeta :: new_readonly( * manager_pool_account, false ) ,
270
273
AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
@@ -364,14 +367,68 @@ pub fn remove_validator_from_pool(
364
367
365
368
/// Creates `DecreaseValidatorStake` instruction (rebalance from validator account to
366
369
/// 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
+ } )
369
397
}
370
398
371
399
/// Creates `IncreaseValidatorStake` instruction (rebalance from reserve account to
372
400
/// 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
+ } )
375
432
}
376
433
377
434
/// Creates `UpdateValidatorListBalance` instruction (update validator stake account balances)
0 commit comments