@@ -264,12 +264,7 @@ fn command_vsa_create(
264
264
Ok ( ( ) )
265
265
}
266
266
267
- fn command_vsa_add (
268
- config : & Config ,
269
- stake_pool_address : & Pubkey ,
270
- stake : & Pubkey ,
271
- token_receiver : & Option < Pubkey > ,
272
- ) -> CommandResult {
267
+ fn command_vsa_add ( config : & Config , stake_pool_address : & Pubkey , stake : & Pubkey ) -> CommandResult {
273
268
if config. rpc_client . get_stake_activation ( * stake, None ) ?. state != StakeActivationState :: Active {
274
269
return Err ( "Stake account is not active." . into ( ) ) ;
275
270
}
@@ -280,26 +275,9 @@ fn command_vsa_add(
280
275
281
276
let stake_pool = get_stake_pool ( & config. rpc_client , stake_pool_address) ?;
282
277
283
- let mut total_rent_free_balances: u64 = 0 ;
284
-
285
- let token_receiver_account = Keypair :: new ( ) ;
286
-
287
278
let mut instructions: Vec < Instruction > = vec ! [ ] ;
288
279
let mut signers = vec ! [ config. fee_payer. as_ref( ) , config. staker. as_ref( ) ] ;
289
280
290
- // Create token account if not specified
291
- let token_receiver = unwrap_create_token_account (
292
- & config,
293
- & token_receiver,
294
- & token_receiver_account,
295
- & stake_pool. pool_mint ,
296
- & mut instructions,
297
- |balance| {
298
- signers. push ( & token_receiver_account) ;
299
- total_rent_free_balances += balance;
300
- } ,
301
- ) ?;
302
-
303
281
// Calculate Deposit and Withdraw stake pool authorities
304
282
let pool_deposit_authority =
305
283
find_deposit_authority_program_address ( & spl_stake_pool:: id ( ) , stake_pool_address) . 0 ;
@@ -331,20 +309,14 @@ fn command_vsa_add(
331
309
& pool_withdraw_authority,
332
310
& stake_pool. validator_list,
333
311
& stake,
334
- & token_receiver,
335
- & stake_pool. pool_mint,
336
- & spl_token:: id( ) ,
337
312
) ?,
338
313
] ) ;
339
314
340
315
let mut transaction =
341
316
Transaction :: new_with_payer ( & instructions, Some ( & config. fee_payer . pubkey ( ) ) ) ;
342
317
343
318
let ( recent_blockhash, fee_calculator) = config. rpc_client . get_recent_blockhash ( ) ?;
344
- check_fee_payer_balance (
345
- config,
346
- total_rent_free_balances + fee_calculator. calculate_fee ( & transaction. message ( ) ) ,
347
- ) ?;
319
+ check_fee_payer_balance ( config, fee_calculator. calculate_fee ( & transaction. message ( ) ) ) ?;
348
320
unique_signers ! ( signers) ;
349
321
transaction. sign ( & signers, recent_blockhash) ;
350
322
send_transaction ( & config, transaction) ?;
@@ -355,7 +327,6 @@ fn command_vsa_remove(
355
327
config : & Config ,
356
328
stake_pool_address : & Pubkey ,
357
329
stake : & Pubkey ,
358
- withdraw_from : & Pubkey ,
359
330
new_authority : & Option < Pubkey > ,
360
331
) -> CommandResult {
361
332
if !config. no_update {
@@ -369,35 +340,8 @@ fn command_vsa_remove(
369
340
let staker_pubkey = config. staker . pubkey ( ) ;
370
341
let new_authority = new_authority. as_ref ( ) . unwrap_or ( & staker_pubkey) ;
371
342
372
- // Calculate amount of tokens to withdraw
373
- let stake_account = config. rpc_client . get_account ( & stake) ?;
374
- let tokens_to_withdraw = stake_pool
375
- . calc_pool_tokens_for_withdraw ( stake_account. lamports )
376
- . unwrap ( ) ;
377
-
378
- // Check balance and mint
379
- let token_account =
380
- get_token_account ( & config. rpc_client , & withdraw_from, & stake_pool. pool_mint ) ?;
381
-
382
- if token_account. amount < tokens_to_withdraw {
383
- let pool_mint = get_token_mint ( & config. rpc_client , & stake_pool. pool_mint ) ?;
384
- return Err ( format ! (
385
- "Not enough balance to burn to remove validator stake account from the pool. {} pool tokens needed." ,
386
- spl_token:: amount_to_ui_amount( tokens_to_withdraw, pool_mint. decimals)
387
- ) . into ( ) ) ;
388
- }
389
-
390
343
let mut transaction = Transaction :: new_with_payer (
391
344
& [
392
- // Approve spending token
393
- spl_token:: instruction:: approve (
394
- & spl_token:: id ( ) ,
395
- & withdraw_from,
396
- & pool_withdraw_authority,
397
- & config. token_owner . pubkey ( ) ,
398
- & [ ] ,
399
- tokens_to_withdraw,
400
- ) ?,
401
345
// Create new validator stake account address
402
346
spl_stake_pool:: instruction:: remove_validator_from_pool (
403
347
& spl_stake_pool:: id ( ) ,
@@ -407,9 +351,6 @@ fn command_vsa_remove(
407
351
& new_authority,
408
352
& stake_pool. validator_list ,
409
353
& stake,
410
- & withdraw_from,
411
- & stake_pool. pool_mint ,
412
- & spl_token:: id ( ) ,
413
354
) ?,
414
355
] ,
415
356
Some ( & config. fee_payer . pubkey ( ) ) ,
@@ -589,7 +530,7 @@ fn command_list(config: &Config, stake_pool_address: &Pubkey) -> CommandResult {
589
530
for validator in validator_list. validators {
590
531
println ! (
591
532
"Validator Vote Account: {}\t Balance: {}\t Last Update Epoch: {}{}" ,
592
- validator. vote_account ,
533
+ validator. vote_account_address ,
593
534
Sol ( validator. stake_lamports) ,
594
535
validator. last_update_epoch,
595
536
if validator. last_update_epoch != epoch_info. epoch {
@@ -669,7 +610,7 @@ fn command_update(config: &Config, stake_pool_address: &Pubkey) -> CommandResult
669
610
} else {
670
611
let ( stake_account, _) = find_stake_program_address (
671
612
& spl_stake_pool:: id ( ) ,
672
- & item. vote_account ,
613
+ & item. vote_account_address ,
673
614
& stake_pool_address,
674
615
) ;
675
616
Some ( stake_account)
@@ -1439,26 +1380,13 @@ fn main() {
1439
1380
( "add-validator" , Some ( arg_matches) ) => {
1440
1381
let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
1441
1382
let stake_account = pubkey_of ( arg_matches, "stake_account" ) . unwrap ( ) ;
1442
- let token_receiver: Option < Pubkey > = pubkey_of ( arg_matches, "token_receiver" ) ;
1443
- command_vsa_add (
1444
- & config,
1445
- & stake_pool_address,
1446
- & stake_account,
1447
- & token_receiver,
1448
- )
1383
+ command_vsa_add ( & config, & stake_pool_address, & stake_account)
1449
1384
}
1450
1385
( "remove-validator" , Some ( arg_matches) ) => {
1451
1386
let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
1452
1387
let stake_account = pubkey_of ( arg_matches, "stake_account" ) . unwrap ( ) ;
1453
- let withdraw_from = pubkey_of ( arg_matches, "withdraw_from" ) . unwrap ( ) ;
1454
1388
let new_authority: Option < Pubkey > = pubkey_of ( arg_matches, "new_authority" ) ;
1455
- command_vsa_remove (
1456
- & config,
1457
- & stake_pool_address,
1458
- & stake_account,
1459
- & withdraw_from,
1460
- & new_authority,
1461
- )
1389
+ command_vsa_remove ( & config, & stake_pool_address, & stake_account, & new_authority)
1462
1390
}
1463
1391
( "deposit" , Some ( arg_matches) ) => {
1464
1392
let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
0 commit comments