From d158bb150ce2f0b947bf4eb80c067029f6880796 Mon Sep 17 00:00:00 2001 From: Alexander Ray Date: Tue, 15 Feb 2022 21:45:32 +0100 Subject: [PATCH] stake_pool: fix wrong available_for_withdrawal_wo_fee calculation (#2900) * - fix wrong available_for_withdrawal_wo_fee calculation by prepare_withdraw_accounts * - fix formatting * - refactor * - fix sub issue --- stake-pool/cli/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stake-pool/cli/src/main.rs b/stake-pool/cli/src/main.rs index 5457325c..aca6d19c 100644 --- a/stake-pool/cli/src/main.rs +++ b/stake-pool/cli/src/main.rs @@ -1257,7 +1257,9 @@ fn prepare_withdraw_accounts( ( transient_stake_account_address, - validator.transient_stake_lamports, + validator + .transient_stake_lamports + .saturating_sub(min_balance), Some(validator.vote_account_address), ) }, @@ -1265,7 +1267,13 @@ fn prepare_withdraw_accounts( let reserve_stake = rpc_client.get_account(&stake_pool.reserve_stake)?; - accounts.push((stake_pool.reserve_stake, reserve_stake.lamports, None)); + accounts.push(( + stake_pool.reserve_stake, + reserve_stake.lamports + - rpc_client.get_minimum_balance_for_rent_exemption(STAKE_STATE_LEN)? + - 1, + None, + )); // Prepare the list of accounts to withdraw from let mut withdraw_from: Vec = vec![];