3
3
#![ allow( clippy:: too_many_arguments) ]
4
4
5
5
use {
6
+ crate :: stake,
6
7
borsh:: { BorshDeserialize , BorshSchema , BorshSerialize } ,
7
8
solana_program:: {
8
9
instruction:: { AccountMeta , Instruction } ,
9
10
program_error:: ProgramError ,
10
11
pubkey:: Pubkey ,
11
- sysvar,
12
+ system_program , sysvar,
12
13
} ,
13
14
} ;
14
15
@@ -48,17 +49,17 @@ pub enum StakePoolInstruction {
48
49
/// Creates new program account for accumulating stakes for a particular validator
49
50
///
50
51
/// 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
59
59
CreateValidatorStakeAccount ,
60
60
61
- /// Adds validator stake account to the pool
61
+ /// Adds stake account delegated to validator to the pool's list of
62
+ /// managed validators
62
63
///
63
64
/// 0. `[w]` Stake pool
64
65
/// 1. `[s]` Owner
@@ -185,24 +186,23 @@ pub fn initialize(
185
186
pub fn create_validator_stake_account (
186
187
program_id : & Pubkey ,
187
188
stake_pool : & Pubkey ,
189
+ owner : & Pubkey ,
188
190
funder : & Pubkey ,
189
191
stake_account : & Pubkey ,
190
192
validator : & Pubkey ,
191
- stake_authority : & Pubkey ,
192
- withdraw_authority : & Pubkey ,
193
- system_program_id : & Pubkey ,
194
- stake_program_id : & Pubkey ,
195
193
) -> Result < Instruction , ProgramError > {
196
194
let accounts = vec ! [
197
195
AccountMeta :: new_readonly( * stake_pool, false ) ,
196
+ AccountMeta :: new_readonly( * owner, true ) ,
198
197
AccountMeta :: new( * funder, true ) ,
199
198
AccountMeta :: new( * stake_account, false ) ,
200
199
AccountMeta :: new_readonly( * validator, false ) ,
201
- AccountMeta :: new_readonly( * stake_authority, false ) ,
202
- AccountMeta :: new_readonly( * withdraw_authority, false ) ,
203
200
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 ) ,
206
206
] ;
207
207
Ok ( Instruction {
208
208
program_id : * program_id,
@@ -220,10 +220,9 @@ pub fn add_validator_to_pool(
220
220
stake_pool_withdraw : & Pubkey ,
221
221
validator_list : & Pubkey ,
222
222
stake_account : & Pubkey ,
223
- pool_tokens_to : & Pubkey ,
223
+ pool_token_receiver : & Pubkey ,
224
224
pool_mint : & Pubkey ,
225
225
token_program_id : & Pubkey ,
226
- stake_program_id : & Pubkey ,
227
226
) -> Result < Instruction , ProgramError > {
228
227
let accounts = vec ! [
229
228
AccountMeta :: new( * stake_pool, false ) ,
@@ -232,12 +231,12 @@ pub fn add_validator_to_pool(
232
231
AccountMeta :: new_readonly( * stake_pool_withdraw, false ) ,
233
232
AccountMeta :: new( * validator_list, false ) ,
234
233
AccountMeta :: new( * stake_account, false ) ,
235
- AccountMeta :: new( * pool_tokens_to , false ) ,
234
+ AccountMeta :: new( * pool_token_receiver , false ) ,
236
235
AccountMeta :: new( * pool_mint, false ) ,
237
236
AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
238
237
AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
239
238
AccountMeta :: new_readonly( * token_program_id, false ) ,
240
- AccountMeta :: new_readonly( * stake_program_id , false ) ,
239
+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
241
240
] ;
242
241
Ok ( Instruction {
243
242
program_id : * program_id,
@@ -258,7 +257,6 @@ pub fn remove_validator_from_pool(
258
257
burn_from : & Pubkey ,
259
258
pool_mint : & Pubkey ,
260
259
token_program_id : & Pubkey ,
261
- stake_program_id : & Pubkey ,
262
260
) -> Result < Instruction , ProgramError > {
263
261
let accounts = vec ! [
264
262
AccountMeta :: new( * stake_pool, false ) ,
@@ -271,7 +269,7 @@ pub fn remove_validator_from_pool(
271
269
AccountMeta :: new( * pool_mint, false ) ,
272
270
AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
273
271
AccountMeta :: new_readonly( * token_program_id, false ) ,
274
- AccountMeta :: new_readonly( * stake_program_id , false ) ,
272
+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
275
273
] ;
276
274
Ok ( Instruction {
277
275
program_id : * program_id,
@@ -330,7 +328,6 @@ pub fn deposit(
330
328
pool_fee_to : & Pubkey ,
331
329
pool_mint : & Pubkey ,
332
330
token_program_id : & Pubkey ,
333
- stake_program_id : & Pubkey ,
334
331
) -> Result < Instruction , ProgramError > {
335
332
let accounts = vec ! [
336
333
AccountMeta :: new( * stake_pool, false ) ,
@@ -345,7 +342,7 @@ pub fn deposit(
345
342
AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
346
343
AccountMeta :: new_readonly( sysvar:: stake_history:: id( ) , false ) ,
347
344
AccountMeta :: new_readonly( * token_program_id, false ) ,
348
- AccountMeta :: new_readonly( * stake_program_id , false ) ,
345
+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
349
346
] ;
350
347
Ok ( Instruction {
351
348
program_id : * program_id,
@@ -366,7 +363,6 @@ pub fn withdraw(
366
363
burn_from : & Pubkey ,
367
364
pool_mint : & Pubkey ,
368
365
token_program_id : & Pubkey ,
369
- stake_program_id : & Pubkey ,
370
366
amount : u64 ,
371
367
) -> Result < Instruction , ProgramError > {
372
368
let accounts = vec ! [
@@ -380,7 +376,7 @@ pub fn withdraw(
380
376
AccountMeta :: new( * pool_mint, false ) ,
381
377
AccountMeta :: new_readonly( sysvar:: clock:: id( ) , false ) ,
382
378
AccountMeta :: new_readonly( * token_program_id, false ) ,
383
- AccountMeta :: new_readonly( * stake_program_id , false ) ,
379
+ AccountMeta :: new_readonly( stake :: id ( ) , false ) ,
384
380
] ;
385
381
Ok ( Instruction {
386
382
program_id : * program_id,
0 commit comments