@@ -120,7 +120,7 @@ fn command_create_pool(
120
120
let pool_account_balance = config
121
121
. rpc_client
122
122
. get_minimum_balance_for_rent_exemption ( get_packed_len :: < StakePool > ( ) ) ?;
123
- let empty_validator_list = ValidatorList :: new_with_max_validators ( max_validators) ;
123
+ let empty_validator_list = ValidatorList :: new ( max_validators) ;
124
124
let validator_list_size = get_instance_packed_len ( & empty_validator_list) ?;
125
125
let validator_list_balance = config
126
126
. rpc_client
@@ -272,7 +272,7 @@ fn command_vsa_add(
272
272
command_update ( config, pool) ?;
273
273
}
274
274
275
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
275
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
276
276
277
277
let mut total_rent_free_balances: u64 = 0 ;
278
278
@@ -286,7 +286,7 @@ fn command_vsa_add(
286
286
& config,
287
287
& token_receiver,
288
288
& token_receiver_account,
289
- & pool_data . pool_mint ,
289
+ & stake_pool . pool_mint ,
290
290
& mut instructions,
291
291
|balance| {
292
292
signers. push ( & token_receiver_account) ;
@@ -299,14 +299,14 @@ fn command_vsa_add(
299
299
& spl_stake_pool:: id ( ) ,
300
300
pool,
301
301
AUTHORITY_DEPOSIT ,
302
- pool_data . deposit_bump_seed ,
302
+ stake_pool . deposit_bump_seed ,
303
303
)
304
304
. unwrap ( ) ;
305
305
let pool_withdraw_authority: Pubkey = create_pool_authority_address (
306
306
& spl_stake_pool:: id ( ) ,
307
307
pool,
308
308
AUTHORITY_WITHDRAW ,
309
- pool_data . withdraw_bump_seed ,
309
+ stake_pool . withdraw_bump_seed ,
310
310
)
311
311
. unwrap ( ) ;
312
312
@@ -332,10 +332,10 @@ fn command_vsa_add(
332
332
& config. owner. pubkey( ) ,
333
333
& pool_deposit_authority,
334
334
& pool_withdraw_authority,
335
- & pool_data . validator_list,
335
+ & stake_pool . validator_list,
336
336
& stake,
337
337
& token_receiver,
338
- & pool_data . pool_mint,
338
+ & stake_pool . pool_mint,
339
339
& spl_token:: id( ) ,
340
340
) ?,
341
341
] ) ;
@@ -365,12 +365,12 @@ fn command_vsa_remove(
365
365
command_update ( config, pool) ?;
366
366
}
367
367
368
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
368
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
369
369
let pool_withdraw_authority: Pubkey = create_pool_authority_address (
370
370
& spl_stake_pool:: id ( ) ,
371
371
pool,
372
372
AUTHORITY_WITHDRAW ,
373
- pool_data . withdraw_bump_seed ,
373
+ stake_pool . withdraw_bump_seed ,
374
374
)
375
375
. unwrap ( ) ;
376
376
@@ -379,16 +379,16 @@ fn command_vsa_remove(
379
379
380
380
// Calculate amount of tokens to withdraw
381
381
let stake_account = config. rpc_client . get_account ( & stake) ?;
382
- let tokens_to_withdraw = pool_data
382
+ let tokens_to_withdraw = stake_pool
383
383
. calc_pool_withdraw_amount ( stake_account. lamports )
384
384
. unwrap ( ) ;
385
385
386
386
// Check balance and mint
387
387
let token_account =
388
- get_token_account ( & config. rpc_client , & withdraw_from, & pool_data . pool_mint ) ?;
388
+ get_token_account ( & config. rpc_client , & withdraw_from, & stake_pool . pool_mint ) ?;
389
389
390
390
if token_account. amount < tokens_to_withdraw {
391
- let pool_mint = get_token_mint ( & config. rpc_client , & pool_data . pool_mint ) ?;
391
+ let pool_mint = get_token_mint ( & config. rpc_client , & stake_pool . pool_mint ) ?;
392
392
return Err ( format ! (
393
393
"Not enough balance to burn to remove validator stake account from the pool. {} pool tokens needed." ,
394
394
spl_token:: amount_to_ui_amount( tokens_to_withdraw, pool_mint. decimals)
@@ -413,10 +413,10 @@ fn command_vsa_remove(
413
413
& config. owner . pubkey ( ) ,
414
414
& pool_withdraw_authority,
415
415
& new_authority,
416
- & pool_data . validator_list ,
416
+ & stake_pool . validator_list ,
417
417
& stake,
418
418
& withdraw_from,
419
- & pool_data . pool_mint ,
419
+ & stake_pool . pool_mint ,
420
420
& spl_token:: id ( ) ,
421
421
) ?,
422
422
] ,
@@ -490,7 +490,7 @@ fn command_deposit(
490
490
command_update ( config, pool) ?;
491
491
}
492
492
493
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
493
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
494
494
let stake_state = get_stake_state ( & config. rpc_client , & stake) ?;
495
495
496
496
if config. verbose {
@@ -502,7 +502,7 @@ fn command_deposit(
502
502
} ?;
503
503
504
504
// Check if this vote account has staking account in the pool
505
- let validator_list = get_validator_list ( & config. rpc_client , & pool_data . validator_list ) ?;
505
+ let validator_list = get_validator_list ( & config. rpc_client , & stake_pool . validator_list ) ?;
506
506
if !validator_list. contains ( & vote_account) {
507
507
return Err ( "Stake account for this validator does not exist in the pool." . into ( ) ) ;
508
508
}
@@ -529,7 +529,7 @@ fn command_deposit(
529
529
& config,
530
530
& token_receiver,
531
531
& token_receiver_account,
532
- & pool_data . pool_mint ,
532
+ & stake_pool . pool_mint ,
533
533
& mut instructions,
534
534
|balance| {
535
535
signers. push ( & token_receiver_account) ;
@@ -542,14 +542,14 @@ fn command_deposit(
542
542
& spl_stake_pool:: id ( ) ,
543
543
pool,
544
544
AUTHORITY_DEPOSIT ,
545
- pool_data . deposit_bump_seed ,
545
+ stake_pool . deposit_bump_seed ,
546
546
)
547
547
. unwrap ( ) ;
548
548
let pool_withdraw_authority: Pubkey = create_pool_authority_address (
549
549
& spl_stake_pool:: id ( ) ,
550
550
pool,
551
551
AUTHORITY_WITHDRAW ,
552
- pool_data . withdraw_bump_seed ,
552
+ stake_pool . withdraw_bump_seed ,
553
553
)
554
554
. unwrap ( ) ;
555
555
@@ -572,14 +572,14 @@ fn command_deposit(
572
572
spl_stake_pool:: instruction:: deposit(
573
573
& spl_stake_pool:: id( ) ,
574
574
& pool,
575
- & pool_data . validator_list,
575
+ & stake_pool . validator_list,
576
576
& pool_deposit_authority,
577
577
& pool_withdraw_authority,
578
578
& stake,
579
579
& validator_stake_account,
580
580
& token_receiver,
581
- & pool_data . owner_fee_account,
582
- & pool_data . pool_mint,
581
+ & stake_pool . owner_fee_account,
582
+ & stake_pool . pool_mint,
583
583
& spl_token:: id( ) ,
584
584
) ?,
585
585
] ) ;
@@ -599,11 +599,11 @@ fn command_deposit(
599
599
}
600
600
601
601
fn command_list ( config : & Config , pool : & Pubkey ) -> CommandResult {
602
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
602
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
603
603
604
604
if config. verbose {
605
605
println ! ( "Current validator list" ) ;
606
- let validator_list = get_validator_list ( & config. rpc_client , & pool_data . validator_list ) ?;
606
+ let validator_list = get_validator_list ( & config. rpc_client , & stake_pool . validator_list ) ?;
607
607
for validator in validator_list. validators {
608
608
println ! (
609
609
"Vote Account: {}\t Balance: {}\t Epoch: {}" ,
@@ -616,7 +616,7 @@ fn command_list(config: &Config, pool: &Pubkey) -> CommandResult {
616
616
& spl_stake_pool:: id ( ) ,
617
617
pool,
618
618
AUTHORITY_WITHDRAW ,
619
- pool_data . withdraw_bump_seed ,
619
+ stake_pool . withdraw_bump_seed ,
620
620
)
621
621
. unwrap ( ) ;
622
622
@@ -641,8 +641,8 @@ fn command_list(config: &Config, pool: &Pubkey) -> CommandResult {
641
641
}
642
642
643
643
fn command_update ( config : & Config , pool : & Pubkey ) -> CommandResult {
644
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
645
- let validator_list = get_validator_list ( & config. rpc_client , & pool_data . validator_list ) ?;
644
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
645
+ let validator_list = get_validator_list ( & config. rpc_client , & stake_pool . validator_list ) ?;
646
646
let epoch_info = config. rpc_client . get_epoch_info ( ) ?;
647
647
648
648
let accounts_to_update: Vec < Pubkey > = validator_list
@@ -667,20 +667,20 @@ fn command_update(config: &Config, pool: &Pubkey) -> CommandResult {
667
667
for chunk in accounts_to_update. chunks ( MAX_ACCOUNTS_TO_UPDATE ) {
668
668
instructions. push ( spl_stake_pool:: instruction:: update_validator_list_balance (
669
669
& spl_stake_pool:: id ( ) ,
670
- & pool_data . validator_list ,
670
+ & stake_pool . validator_list ,
671
671
& chunk,
672
672
) ?) ;
673
673
}
674
674
675
- if instructions. is_empty ( ) && pool_data . last_update_epoch == epoch_info. epoch {
675
+ if instructions. is_empty ( ) && stake_pool . last_update_epoch == epoch_info. epoch {
676
676
println ! ( "Stake pool balances are up to date, no update required." ) ;
677
677
Ok ( ( ) )
678
678
} else {
679
679
println ! ( "Updating stake pool..." ) ;
680
680
instructions. push ( spl_stake_pool:: instruction:: update_stake_pool_balance (
681
681
& spl_stake_pool:: id ( ) ,
682
682
pool,
683
- & pool_data . validator_list ,
683
+ & stake_pool . validator_list ,
684
684
) ?) ;
685
685
686
686
let mut transaction =
@@ -765,21 +765,21 @@ fn command_withdraw(
765
765
command_update ( config, pool) ?;
766
766
}
767
767
768
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
769
- let pool_mint = get_token_mint ( & config. rpc_client , & pool_data . pool_mint ) ?;
768
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
769
+ let pool_mint = get_token_mint ( & config. rpc_client , & stake_pool . pool_mint ) ?;
770
770
let pool_amount = spl_token:: ui_amount_to_amount ( pool_amount, pool_mint. decimals ) ;
771
771
772
772
let pool_withdraw_authority: Pubkey = create_pool_authority_address (
773
773
& spl_stake_pool:: id ( ) ,
774
774
pool,
775
775
AUTHORITY_WITHDRAW ,
776
- pool_data . withdraw_bump_seed ,
776
+ stake_pool . withdraw_bump_seed ,
777
777
)
778
778
. unwrap ( ) ;
779
779
780
780
// Check withdraw_from account type
781
781
let token_account =
782
- get_token_account ( & config. rpc_client , & withdraw_from, & pool_data . pool_mint ) ?;
782
+ get_token_account ( & config. rpc_client , & withdraw_from, & stake_pool . pool_mint ) ?;
783
783
784
784
// Check withdraw_from balance
785
785
if token_account. amount < pool_amount {
@@ -794,7 +794,7 @@ fn command_withdraw(
794
794
// Get the list of accounts to withdraw from
795
795
let withdraw_accounts = prepare_withdraw_accounts (
796
796
& config. rpc_client ,
797
- & pool_data ,
797
+ & stake_pool ,
798
798
& pool_withdraw_authority,
799
799
pool_amount,
800
800
) ?;
@@ -824,7 +824,7 @@ fn command_withdraw(
824
824
// Go through prepared accounts and withdraw/claim them
825
825
for withdraw_account in withdraw_accounts {
826
826
// Convert pool tokens amount to lamports
827
- let sol_withdraw_amount = pool_data
827
+ let sol_withdraw_amount = stake_pool
828
828
. calc_lamports_withdraw_amount ( withdraw_account. pool_amount )
829
829
. unwrap ( ) ;
830
830
@@ -867,13 +867,13 @@ fn command_withdraw(
867
867
instructions. push ( spl_stake_pool:: instruction:: withdraw (
868
868
& spl_stake_pool:: id ( ) ,
869
869
& pool,
870
- & pool_data . validator_list ,
870
+ & stake_pool . validator_list ,
871
871
& pool_withdraw_authority,
872
872
& withdraw_account. address ,
873
873
& stake_receiver. unwrap ( ) , // Cannot be none at this point
874
874
& config. owner . pubkey ( ) ,
875
875
& withdraw_from,
876
- & pool_data . pool_mint ,
876
+ & stake_pool . pool_mint ,
877
877
& spl_token:: id ( ) ,
878
878
withdraw_account. pool_amount ,
879
879
) ?) ;
@@ -899,19 +899,20 @@ fn command_set_owner(
899
899
new_owner : & Option < Pubkey > ,
900
900
new_fee_receiver : & Option < Pubkey > ,
901
901
) -> CommandResult {
902
- let pool_data = get_stake_pool ( & config. rpc_client , pool) ?;
902
+ let stake_pool = get_stake_pool ( & config. rpc_client , pool) ?;
903
903
904
904
// If new accounts are missing in the arguments use the old ones
905
905
let new_owner = match new_owner {
906
- None => pool_data . owner ,
906
+ None => stake_pool . owner ,
907
907
Some ( value) => * value,
908
908
} ;
909
909
let new_fee_receiver = match new_fee_receiver {
910
- None => pool_data . owner_fee_account ,
910
+ None => stake_pool . owner_fee_account ,
911
911
Some ( value) => {
912
912
// Check for fee receiver being a valid token account and have to same mint as the stake pool
913
- let token_account = get_token_account ( & config. rpc_client , value, & pool_data. pool_mint ) ?;
914
- if token_account. mint != pool_data. pool_mint {
913
+ let token_account =
914
+ get_token_account ( & config. rpc_client , value, & stake_pool. pool_mint ) ?;
915
+ if token_account. mint != stake_pool. pool_mint {
915
916
return Err ( "Fee receiver account belongs to a different mint"
916
917
. to_string ( )
917
918
. into ( ) ) ;
0 commit comments