Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solana] Add close_vesting_balance instruction #242

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add rent_payer to VestingBalance for rent reclaim on close
  • Loading branch information
nvsriram committed Feb 21, 2025
commit 60b5b434cb3d873904c26217e73a80e23ef2429a
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@ pub struct CloseVestingBalance<'info> {
@ VestingError::InvalidVestingAdmin
)]
admin: Signer<'info>,
#[account(mut)]
/// CHECK: This account is the original rent_payer for the vesting_balance account
rent_payer: UncheckedAccount<'info>,
mint: InterfaceAccount<'info, Mint>,
#[account(
mut,
@@ -24,9 +27,10 @@ pub struct CloseVestingBalance<'info> {
config: Account<'info, VestingConfig>,
#[account(
mut,
has_one = rent_payer,
seeds = [VESTING_BALANCE_SEED.as_bytes(), config.key().as_ref(), vester_ta.owner.key().as_ref()],
bump,
close = admin,
close = rent_payer,
)]
vesting_balance: Account<'info, VestingBalance>,
#[account(
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ impl<'info> CreateVestingBalance<'info> {
stake_account_metadata: Pubkey::default(),
total_vesting_balance: 0,
bump,
rent_payer: self.admin.key(),
});

Ok(())
1 change: 1 addition & 0 deletions solana/programs/staking/src/contexts/transfer_vesting.rs
Original file line number Diff line number Diff line change
@@ -319,6 +319,7 @@ impl<'info> crate::contexts::TransferVesting<'info> {
.checked_add(self.vest.amount)
.ok_or(VestingError::Overflow)?,
bump: new_vesting_balance_bump,
rent_payer: self.vester.key(),
});

self.vesting_balance.total_vesting_balance = self
3 changes: 2 additions & 1 deletion solana/programs/staking/src/state/vesting_balance.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ pub struct VestingBalance {
pub total_vesting_balance: u64,
pub bump: u8,
pub stake_account_metadata: Pubkey,
pub rent_payer: Pubkey,
}

impl VestingBalance {
@@ -21,6 +22,6 @@ pub mod tests {

#[test]
fn check_size() {
assert!(VestingBalance::LEN == 8 + 32 + 8 + 1 + 32); // 81
assert!(VestingBalance::LEN == 8 + 32 + 8 + 1 + 32 + 32); // 113
}
}