use carbon_core::account::AccountDecoder;
use carbon_core::deserialize::CarbonDeserialize;
use crate::PROGRAM_ID;
use super::MeteoraPoolsDecoder;
pub mod config;
pub mod lock_escrow;
pub mod pool;
pub enum MeteoraPoolsProgramAccount {
Config(config::Config),
LockEscrow(lock_escrow::LockEscrow),
Pool(pool::Pool),
}
impl AccountDecoder<'_> for MeteoraPoolsDecoder {
type AccountType = MeteoraPoolsProgramAccount;
fn decode_account(
&self,
account: &solana_sdk::account::Account,
) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
if !account.owner.eq(&PROGRAM_ID) {
return None;
}
if let Some(decoded_account) = config::Config::deserialize(account.data.as_slice()) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: MeteoraPoolsProgramAccount::Config(decoded_account),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
if let Some(decoded_account) = lock_escrow::LockEscrow::deserialize(account.data.as_slice())
{
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: MeteoraPoolsProgramAccount::LockEscrow(decoded_account),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
if let Some(decoded_account) = pool::Pool::deserialize(account.data.as_slice()) {
return Some(carbon_core::account::DecodedAccount {
lamports: account.lamports,
data: MeteoraPoolsProgramAccount::Pool(decoded_account),
owner: account.owner,
executable: account.executable,
rent_epoch: account.rent_epoch,
});
}
None
}
}