-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclose_vesting_balance.rs
44 lines (42 loc) · 1.59 KB
/
close_vesting_balance.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::context::{VESTING_BALANCE_SEED, VESTING_CONFIG_SEED};
use crate::error::VestingError;
use crate::state::{VestingBalance, VestingConfig};
use anchor_lang::prelude::*;
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};
#[derive(Accounts)]
#[instruction()]
pub struct CloseVestingBalance<'info> {
#[account(mut)]
/// CHECK: This account is the original rent_payer for the vesting_balance account
rent_payer: Signer<'info>,
mint: InterfaceAccount<'info, Mint>,
#[account(
seeds = [VESTING_CONFIG_SEED.as_bytes(), mint.key().as_ref(), config.seed.to_le_bytes().as_ref()],
bump = config.bump
)]
config: Account<'info, VestingConfig>,
#[account(
mut,
has_one = rent_payer,
constraint = vesting_balance.total_vesting_balance == 0 @ VestingError::NotFullyVested,
seeds = [VESTING_BALANCE_SEED.as_bytes(), config.key().as_ref(), vester_ta.owner.key().as_ref()],
bump,
close = rent_payer,
)]
vesting_balance: Account<'info, VestingBalance>,
#[account(
associated_token::mint = mint,
associated_token::authority = vester_ta.owner,
associated_token::token_program = token_program
)]
vester_ta: InterfaceAccount<'info, TokenAccount>,
associated_token_program: Program<'info, AssociatedToken>,
token_program: Interface<'info, TokenInterface>,
system_program: Program<'info, System>,
}
impl<'info> CloseVestingBalance<'info> {
pub fn close_vesting_balance(&mut self) -> Result<()> {
Ok(())
}
}