@@ -77,42 +77,24 @@ pub enum StakePoolInstruction {
77
77
max_validators : u32 ,
78
78
} ,
79
79
80
- /// (Staker only) Creates new program account for accumulating stakes for
81
- /// a particular validator
82
- ///
83
- /// 0. `[]` Stake pool account this stake will belong to
84
- /// 1. `[s]` Staker
85
- /// 2. `[ws]` Funding account (must be a system account)
86
- /// 3. `[w]` Stake account to be created
87
- /// 4. `[]` Validator this stake account will vote for
88
- /// 5. `[]` Rent sysvar
89
- /// 6. `[]` Stake History sysvar
90
- /// 7. `[]` Stake Config sysvar
91
- /// 8. `[]` System program
92
- /// 9. `[]` Stake program
93
- CreateValidatorStakeAccount ,
94
-
95
80
/// (Staker only) Adds stake account delegated to validator to the pool's
96
81
/// list of managed validators.
97
82
///
98
- /// The stake account must have the rent-exempt amount plus at least 1 SOL,
99
- /// and at most 1.001 SOL.
100
- ///
101
- /// Once we delegate even 1 SOL, it will accrue rewards one epoch later,
102
- /// so we'll have more than 1 active SOL at this point.
103
- /// At 10% annualized rewards, 1 epoch of 2 days will accrue
104
- /// 0.000547945 SOL, so we check that it is at least 1 SOL, and at most
105
- /// 1.001 SOL.
83
+ /// The stake account will have the rent-exempt amount plus 1 SOL.
106
84
///
107
85
/// 0. `[w]` Stake pool
108
86
/// 1. `[s]` Staker
109
- /// 2. `[]` Stake pool withdraw authority
110
- /// 3. `[w]` Validator stake list storage account
111
- /// 4. `[w]` Stake account to add to the pool, its withdraw authority must
112
- /// be set to the staker
113
- /// 5. `[]` Clock sysvar
114
- /// 6. '[]' Sysvar stake history account
115
- /// 7. `[]` Stake program
87
+ /// 2. `[ws]` Funding account (must be a system account)
88
+ /// 3. `[]` Stake pool withdraw authority
89
+ /// 4. `[w]` Validator stake list storage account
90
+ /// 5. `[w]` Stake account to add to the pool
91
+ /// 6. `[]` Validator this stake account will be delegated to
92
+ /// 7. `[]` Rent sysvar
93
+ /// 8. `[]` Clock sysvar
94
+ /// 9. '[]' Stake history sysvar
95
+ /// 10. '[]' Stake config sysvar
96
+ /// 11. `[]` System program
97
+ /// 12. `[]` Stake program
116
98
AddValidatorToPool ,
117
99
118
100
/// (Staker only) Removes validator from the pool
@@ -415,54 +397,30 @@ pub fn initialize(
415
397
}
416
398
}
417
399
418
- /// Creates `CreateValidatorStakeAccount` instruction (create new stake account for the validator)
419
- pub fn create_validator_stake_account (
420
- program_id : & Pubkey ,
421
- stake_pool : & Pubkey ,
422
- staker : & Pubkey ,
423
- funder : & Pubkey ,
424
- stake_account : & Pubkey ,
425
- validator : & Pubkey ,
426
- ) -> Instruction {
427
- let accounts = vec ! [
428
- AccountMeta :: new_readonly( * stake_pool, false ) ,
429
- AccountMeta :: new_readonly( * staker, true ) ,
430
- AccountMeta :: new( * funder, true ) ,
431
- AccountMeta :: new( * stake_account, false ) ,
432
- AccountMeta :: new_readonly( * validator, false ) ,
433
- AccountMeta :: new_readonly( sysvar:: rent:: id( ) , false ) ,
434
- AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
435
- AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
436
- AccountMeta :: new_readonly( stake_program:: config_id( ) , false ) ,
437
- AccountMeta :: new_readonly( system_program:: id( ) , false ) ,
438
- AccountMeta :: new_readonly( stake_program:: id( ) , false ) ,
439
- ] ;
440
- Instruction {
441
- program_id : * program_id,
442
- accounts,
443
- data : StakePoolInstruction :: CreateValidatorStakeAccount
444
- . try_to_vec ( )
445
- . unwrap ( ) ,
446
- }
447
- }
448
-
449
400
/// Creates `AddValidatorToPool` instruction (add new validator stake account to the pool)
450
401
pub fn add_validator_to_pool (
451
402
program_id : & Pubkey ,
452
403
stake_pool : & Pubkey ,
453
404
staker : & Pubkey ,
405
+ funder : & Pubkey ,
454
406
stake_pool_withdraw : & Pubkey ,
455
407
validator_list : & Pubkey ,
456
- stake_account : & Pubkey ,
408
+ stake : & Pubkey ,
409
+ validator : & Pubkey ,
457
410
) -> Instruction {
458
411
let accounts = vec ! [
459
412
AccountMeta :: new( * stake_pool, false ) ,
460
413
AccountMeta :: new_readonly( * staker, true ) ,
414
+ AccountMeta :: new( * funder, true ) ,
461
415
AccountMeta :: new_readonly( * stake_pool_withdraw, false ) ,
462
416
AccountMeta :: new( * validator_list, false ) ,
463
- AccountMeta :: new( * stake_account, false ) ,
417
+ AccountMeta :: new( * stake, false ) ,
418
+ AccountMeta :: new_readonly( * validator, false ) ,
419
+ AccountMeta :: new_readonly( sysvar:: rent:: id( ) , false ) ,
464
420
AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
465
421
AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
422
+ AccountMeta :: new_readonly( stake_program:: config_id( ) , false ) ,
423
+ AccountMeta :: new_readonly( system_program:: id( ) , false ) ,
466
424
AccountMeta :: new_readonly( stake_program:: id( ) , false ) ,
467
425
] ;
468
426
Instruction {
@@ -610,32 +568,13 @@ pub fn set_preferred_validator(
610
568
}
611
569
}
612
570
613
- /// Creates `CreateValidatorStakeAccount` instruction with a vote account
614
- pub fn create_validator_stake_account_with_vote (
615
- program_id : & Pubkey ,
616
- stake_pool_address : & Pubkey ,
617
- staker : & Pubkey ,
618
- funder : & Pubkey ,
619
- vote_account_address : & Pubkey ,
620
- ) -> Instruction {
621
- let ( stake_account, _) =
622
- find_stake_program_address ( program_id, vote_account_address, stake_pool_address) ;
623
- create_validator_stake_account (
624
- program_id,
625
- stake_pool_address,
626
- staker,
627
- funder,
628
- & stake_account,
629
- vote_account_address,
630
- )
631
- }
632
-
633
571
/// Create an `AddValidatorToPool` instruction given an existing stake pool and
634
572
/// vote account
635
573
pub fn add_validator_to_pool_with_vote (
636
574
program_id : & Pubkey ,
637
575
stake_pool : & StakePool ,
638
576
stake_pool_address : & Pubkey ,
577
+ funder : & Pubkey ,
639
578
vote_account_address : & Pubkey ,
640
579
) -> Instruction {
641
580
let pool_withdraw_authority =
@@ -646,9 +585,11 @@ pub fn add_validator_to_pool_with_vote(
646
585
program_id,
647
586
stake_pool_address,
648
587
& stake_pool. staker ,
588
+ funder,
649
589
& pool_withdraw_authority,
650
590
& stake_pool. validator_list ,
651
591
& stake_account_address,
592
+ vote_account_address,
652
593
)
653
594
}
654
595
0 commit comments