Skip to main content
1 of 2
    let cpi_program = ctx.accounts.token_program.to_account_info();
    let cpi_accounts = Transfer {
        from: ctx.accounts.vault_account.to_account_info(),
        to: ctx.accounts.to.to_account_info(),
        authority: ctx.accounts.vault_account.to_account_info(),
    };

    if amount > ctx.accounts.vault_access.amount {
        return Err(ErrorCode::InsufficientFundsInVault.into())
    }

    ctx.accounts.vault_access.amount -= amount;

    token::transfer(
        CpiContext::new_with_signer(
            cpi_program, 
            cpi_accounts,
            &[&[b"vault", ctx.accounts.to.mint.as_ref(), &[bump]]]), 
        amount)?;