use crate::{PumpSwapDecoder, PROGRAM_ID};
#[cfg(feature = "postgres")]
pub mod postgres;
#[cfg(feature = "graphql")]
pub mod graphql;
pub mod bonding_curve;
pub mod fee_config;
pub mod global_config;
pub mod global_volume_accumulator;
pub mod pool;
pub mod sharing_config;
pub mod user_volume_accumulator;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum PumpSwapAccount {
BondingCurve(Box<bonding_curve::BondingCurve>),
FeeConfig(Box<fee_config::FeeConfig>),
GlobalConfig(Box<global_config::GlobalConfig>),
GlobalVolumeAccumulator(Box<global_volume_accumulator::GlobalVolumeAccumulator>),
Pool(Box<pool::Pool>),
SharingConfig(Box<sharing_config::SharingConfig>),
UserVolumeAccumulator(Box<user_volume_accumulator::UserVolumeAccumulator>),
}
impl<'a> carbon_core::account::AccountDecoder<'a> for PumpSwapDecoder {
type AccountType = PumpSwapAccount;
fn decode_account(
&self,
account: &'a solana_account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if account.owner != PROGRAM_ID {
return None;
}
let data = account.data.as_slice();
{
if let Some(decoded) = bonding_curve::BondingCurve::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::BondingCurve(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = fee_config::FeeConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::FeeConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = global_config::GlobalConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::GlobalConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = global_volume_accumulator::GlobalVolumeAccumulator::decode(data)
{
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::GlobalVolumeAccumulator(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = pool::Pool::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::Pool(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = sharing_config::SharingConfig::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::SharingConfig(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
{
if let Some(decoded) = user_volume_accumulator::UserVolumeAccumulator::decode(data) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: PumpSwapAccount::UserVolumeAccumulator(Box::new(decoded)),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
}
None
}
}