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