use solana_program::pubkey;
use solana_program::pubkey::Pubkey;
#[allow(unused)]
#[allow(clippy::identity_op)]
mod generated;

pub use generated::programs::STABLEBOND_ID;
pub use generated::programs::STABLEBOND_ID as ID;
pub use generated::*;

pub fn find_config_pda() -> (Pubkey, u8) {
    Pubkey::find_program_address(&["config".to_string().as_ref()], &crate::ID)
}

pub fn find_delegate_pda(delegate_wallet: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &["delegate".to_string().as_ref(), delegate_wallet.as_ref()],
        &crate::ID,
    )
}

pub fn find_bond_pda(mint: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&["bond".to_string().as_ref(), mint.as_ref()], &crate::ID)
}

pub fn find_issuance_pda(bond: Pubkey, issuance_number: u64) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            "issuance".to_string().as_ref(),
            bond.as_ref(),
            &issuance_number.to_le_bytes(),
        ],
        &crate::ID,
    )
}

pub fn find_payment_pda(issuance: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &["payment".to_string().as_ref(), issuance.as_ref()],
        &crate::ID,
    )
}

pub fn find_payout_pda(issuance: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &["payout".to_string().as_ref(), issuance.as_ref()],
        &crate::ID,
    )
}

cfg_if::cfg_if! {
    if #[cfg(feature = "mainnet-beta")] {
        pub const PYTH_PROGRAM: Pubkey = pubkey!("FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH");
    } else {
        pub const PYTH_PROGRAM: Pubkey = pubkey!("gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s");
    }
}

cfg_if::cfg_if! {
    if #[cfg(feature = "mainnet-beta")] {
        pub const PYTH_USDC: Pubkey = pubkey!("Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD");
    } else {
        pub const PYTH_USDC: Pubkey = pubkey!("5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7");
    }
}

cfg_if::cfg_if! {
    if #[cfg(feature = "mainnet-beta")] {
        pub const PROGRAM_OWNER: Pubkey = pubkey!("owNEred9E1jEEFsS2E3LRMNtAnUf6XBseqBnyKc33Pz");
    } else {
        pub const PROGRAM_OWNER: Pubkey = pubkey!("9Qx7RaqE56rHz4k1bM3Bta2dmqYGd8nLQxonde26MukW");
    }
}
