use anchor_client::{
    solana_sdk::{commitment_config::CommitmentConfig, signer::Signer},
    Client, ClientError, Cluster, Program,
};
use anchor_lang::prelude::Pubkey;

use std::{ops::Deref, sync::Arc};

use crate::{programs::vaults::ID, ReadKeypair};

pub mod constants;
pub mod errors;
pub mod helpers;
pub mod instructions;
pub mod pda;
pub mod read;
pub mod simulations;
pub mod state;
pub mod tick_has_debt;
pub mod ticks;

pub const VAULTS_PROGRAM_ID: Pubkey = ID;

pub type VaultProgram = Program<Arc<ReadKeypair>>;

pub fn get_vault_program<C: Clone + Deref<Target = impl Signer>>(
    cluster: Cluster,
    payer: C,
    options: CommitmentConfig,
) -> Result<Program<C>, ClientError> {
    let provider = Client::new_with_options(cluster, payer, options);

    let program = provider.program(VAULTS_PROGRAM_ID);

    program
}
