carbon_meteora_pools_decoder/accounts/
mod.rs1use carbon_core::account::AccountDecoder;
2use carbon_core::deserialize::CarbonDeserialize;
3
4use crate::PROGRAM_ID;
5
6use super::MeteoraPoolsDecoder;
7pub mod config;
8pub mod lock_escrow;
9pub mod pool;
10
11pub enum MeteoraPoolsProgramAccount {
12 Config(Box<config::Config>),
13 LockEscrow(lock_escrow::LockEscrow),
14 Pool(Box<pool::Pool>),
15}
16
17impl AccountDecoder<'_> for MeteoraPoolsDecoder {
18 type AccountType = MeteoraPoolsProgramAccount;
19 fn decode_account(
20 &self,
21 account: &solana_account::Account,
22 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
23 if !account.owner.eq(&PROGRAM_ID) {
24 return None;
25 }
26
27 if let Some(decoded_account) = config::Config::deserialize(account.data.as_slice()) {
28 return Some(carbon_core::account::DecodedAccount {
29 lamports: account.lamports,
30 data: MeteoraPoolsProgramAccount::Config(Box::new(decoded_account)),
31 owner: account.owner,
32 executable: account.executable,
33 rent_epoch: account.rent_epoch,
34 });
35 }
36
37 if let Some(decoded_account) = lock_escrow::LockEscrow::deserialize(account.data.as_slice())
38 {
39 return Some(carbon_core::account::DecodedAccount {
40 lamports: account.lamports,
41 data: MeteoraPoolsProgramAccount::LockEscrow(decoded_account),
42 owner: account.owner,
43 executable: account.executable,
44 rent_epoch: account.rent_epoch,
45 });
46 }
47
48 if let Some(decoded_account) = pool::Pool::deserialize(account.data.as_slice()) {
49 return Some(carbon_core::account::DecodedAccount {
50 lamports: account.lamports,
51 data: MeteoraPoolsProgramAccount::Pool(Box::new(decoded_account)),
52 owner: account.owner,
53 executable: account.executable,
54 rent_epoch: account.rent_epoch,
55 });
56 }
57
58 None
59 }
60}