33#![ allow( clippy:: too_many_arguments) ]
44
55use {
6+ crate :: stake,
67 borsh:: { BorshDeserialize , BorshSchema , BorshSerialize } ,
78 solana_program:: {
89 instruction:: { AccountMeta , Instruction } ,
910 program_error:: ProgramError ,
1011 pubkey:: Pubkey ,
11- sysvar,
12+ system_program , sysvar,
1213 } ,
1314} ;
1415
@@ -48,17 +49,17 @@ pub enum StakePoolInstruction {
4849 /// Creates new program account for accumulating stakes for a particular validator
4950 ///
5051 /// 0. `[]` Stake pool account this stake will belong to
51- /// 1. `[ws]` Funding account (must be a system account)
52- /// 2. `[w]` Stake account to be created
53- /// 3. `[]` Validator this stake account will vote for
54- /// 4. `[]` Stake authority for the new stake account
55- /// 5. `[]` Withdraw authority for the new stake account
56- /// 6. `[]` Rent sysvar
57- /// 7. `[]` System program
58- /// 8. `[]` Stake program
52+ /// 1. `[s]` Owner
53+ /// 2. `[ws]` Funding account (must be a system account)
54+ /// 3. `[w]` Stake account to be created
55+ /// 4. `[]` Validator this stake account will vote for
56+ /// 5. `[]` Rent sysvar
57+ /// 6. `[]` System program
58+ /// 7. `[]` Stake program
5959 CreateValidatorStakeAccount ,
6060
61- /// Adds validator stake account to the pool
61+ /// Adds stake account delegated to validator to the pool's list of
62+ /// managed validators
6263 ///
6364 /// 0. `[w]` Stake pool
6465 /// 1. `[s]` Owner
@@ -185,24 +186,23 @@ pub fn initialize(
185186pub fn create_validator_stake_account (
186187 program_id : & Pubkey ,
187188 stake_pool : & Pubkey ,
189+ owner : & Pubkey ,
188190 funder : & Pubkey ,
189191 stake_account : & Pubkey ,
190192 validator : & Pubkey ,
191- stake_authority : & Pubkey ,
192- withdraw_authority : & Pubkey ,
193- system_program_id : & Pubkey ,
194- stake_program_id : & Pubkey ,
195193) -> Result < Instruction , ProgramError > {
196194 let accounts = vec ! [
197195 AccountMeta :: new_readonly( * stake_pool, false ) ,
196+ AccountMeta :: new_readonly( * owner, true ) ,
198197 AccountMeta :: new( * funder, true ) ,
199198 AccountMeta :: new( * stake_account, false ) ,
200199 AccountMeta :: new_readonly( * validator, false ) ,
201- AccountMeta :: new_readonly( * stake_authority, false ) ,
202- AccountMeta :: new_readonly( * withdraw_authority, false ) ,
203200 AccountMeta :: new_readonly( sysvar:: rent:: id( ) , false ) ,
204- AccountMeta :: new_readonly( * system_program_id, false ) ,
205- AccountMeta :: new_readonly( * stake_program_id, false ) ,
201+ AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
202+ AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
203+ AccountMeta :: new_readonly( stake:: config_id( ) , false ) ,
204+ AccountMeta :: new_readonly( system_program:: id( ) , false ) ,
205+ AccountMeta :: new_readonly( stake:: id( ) , false ) ,
206206 ] ;
207207 Ok ( Instruction {
208208 program_id : * program_id,
@@ -220,10 +220,9 @@ pub fn add_validator_to_pool(
220220 stake_pool_withdraw : & Pubkey ,
221221 validator_list : & Pubkey ,
222222 stake_account : & Pubkey ,
223- pool_tokens_to : & Pubkey ,
223+ pool_token_receiver : & Pubkey ,
224224 pool_mint : & Pubkey ,
225225 token_program_id : & Pubkey ,
226- stake_program_id : & Pubkey ,
227226) -> Result < Instruction , ProgramError > {
228227 let accounts = vec ! [
229228 AccountMeta :: new( * stake_pool, false ) ,
@@ -232,12 +231,12 @@ pub fn add_validator_to_pool(
232231 AccountMeta :: new_readonly( * stake_pool_withdraw, false ) ,
233232 AccountMeta :: new( * validator_list, false ) ,
234233 AccountMeta :: new( * stake_account, false ) ,
235- AccountMeta :: new( * pool_tokens_to , false ) ,
234+ AccountMeta :: new( * pool_token_receiver , false ) ,
236235 AccountMeta :: new( * pool_mint, false ) ,
237236 AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
238237 AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
239238 AccountMeta :: new_readonly( * token_program_id, false ) ,
240- AccountMeta :: new_readonly( * stake_program_id , false ) ,
239+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
241240 ] ;
242241 Ok ( Instruction {
243242 program_id : * program_id,
@@ -258,7 +257,6 @@ pub fn remove_validator_from_pool(
258257 burn_from : & Pubkey ,
259258 pool_mint : & Pubkey ,
260259 token_program_id : & Pubkey ,
261- stake_program_id : & Pubkey ,
262260) -> Result < Instruction , ProgramError > {
263261 let accounts = vec ! [
264262 AccountMeta :: new( * stake_pool, false ) ,
@@ -271,7 +269,7 @@ pub fn remove_validator_from_pool(
271269 AccountMeta :: new( * pool_mint, false ) ,
272270 AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
273271 AccountMeta :: new_readonly( * token_program_id, false ) ,
274- AccountMeta :: new_readonly( * stake_program_id , false ) ,
272+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
275273 ] ;
276274 Ok ( Instruction {
277275 program_id : * program_id,
@@ -330,7 +328,6 @@ pub fn deposit(
330328 pool_fee_to : & Pubkey ,
331329 pool_mint : & Pubkey ,
332330 token_program_id : & Pubkey ,
333- stake_program_id : & Pubkey ,
334331) -> Result < Instruction , ProgramError > {
335332 let accounts = vec ! [
336333 AccountMeta :: new( * stake_pool, false ) ,
@@ -345,7 +342,7 @@ pub fn deposit(
345342 AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
346343 AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
347344 AccountMeta :: new_readonly( * token_program_id, false ) ,
348- AccountMeta :: new_readonly( * stake_program_id , false ) ,
345+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
349346 ] ;
350347 Ok ( Instruction {
351348 program_id : * program_id,
@@ -366,7 +363,6 @@ pub fn withdraw(
366363 burn_from : & Pubkey ,
367364 pool_mint : & Pubkey ,
368365 token_program_id : & Pubkey ,
369- stake_program_id : & Pubkey ,
370366 amount : u64 ,
371367) -> Result < Instruction , ProgramError > {
372368 let accounts = vec ! [
@@ -380,7 +376,7 @@ pub fn withdraw(
380376 AccountMeta :: new( * pool_mint, false ) ,
381377 AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
382378 AccountMeta :: new_readonly( * token_program_id, false ) ,
383- AccountMeta :: new_readonly( * stake_program_id , false ) ,
379+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
384380 ] ;
385381 Ok ( Instruction {
386382 program_id : * program_id,
0 commit comments