mod error;
pub use error::*;
pub mod accounts;
pub use accounts::*;
pub mod instructions;
pub use instructions::*;
pub mod oracle_quote;
pub use oracle_quote::*;
pub mod types;
#[cfg(feature = "anchor")]
use anchor_lang::solana_program;
#[cfg(not(feature = "anchor"))]
use crate::solana_program;
use solana_program::pubkey::{pubkey, Pubkey};
pub use types::*;
pub const ADDRESS_LOOKUP_TABLE_PROGRAM_ID: Pubkey = pubkey!("AddressLookupTab1e1111111111111111111111111");
pub fn get_associated_token_address_and_bump_seed(
wallet_address: &Pubkey,
token_mint_address: &Pubkey,
program_id: &Pubkey,
token_program_id: &Pubkey,
) -> (Pubkey, u8) {
get_associated_token_address_and_bump_seed_internal(
wallet_address,
token_mint_address,
program_id,
token_program_id,
)
}
pub fn get_associated_token_address(
wallet_address: &Pubkey,
token_mint_address: &Pubkey,
) -> Pubkey {
get_associated_token_address_with_program_id(
wallet_address,
token_mint_address,
&spl_token::ID.to_bytes().into(),
)
}
pub fn get_associated_token_address_with_program_id(
wallet_address: &Pubkey,
token_mint_address: &Pubkey,
token_program_id: &Pubkey,
) -> Pubkey {
get_associated_token_address_and_bump_seed(
wallet_address,
token_mint_address,
&pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")
.to_bytes()
.into(),
token_program_id,
)
.0
}
fn get_associated_token_address_and_bump_seed_internal(
wallet_address: &Pubkey,
token_mint_address: &Pubkey,
program_id: &Pubkey,
token_program_id: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
&wallet_address.to_bytes(),
&token_program_id.to_bytes(),
&token_mint_address.to_bytes(),
],
program_id,
)
}