carbon_meteora_pools_decoder/accounts/
mod.rs1use crate::{MeteoraPoolsDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod config;
11pub mod lock_escrow;
12pub mod pool;
13
14#[derive(Debug, Clone, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
17pub enum MeteoraPoolsAccount {
18 Config(Box<config::Config>),
19 LockEscrow(Box<lock_escrow::LockEscrow>),
20 Pool(Box<pool::Pool>),
21}
22
23impl<'a> carbon_core::account::AccountDecoder<'a> for MeteoraPoolsDecoder {
24 type AccountType = MeteoraPoolsAccount;
25
26 fn decode_account(
27 &self,
28 account: &'a solana_account::Account,
29 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
30 if account.owner != PROGRAM_ID {
31 return None;
32 }
33
34 let data = account.data.as_slice();
35
36 {
37 if let Some(decoded) = config::Config::decode(data) {
38 return Some(carbon_core::account::DecodedAccount {
39 lamports: account.lamports,
40 data: MeteoraPoolsAccount::Config(Box::new(decoded)),
41 owner: account.owner,
42 executable: account.executable,
43 rent_epoch: account.rent_epoch,
44 });
45 }
46 }
47 {
48 if let Some(decoded) = lock_escrow::LockEscrow::decode(data) {
49 return Some(carbon_core::account::DecodedAccount {
50 lamports: account.lamports,
51 data: MeteoraPoolsAccount::LockEscrow(Box::new(decoded)),
52 owner: account.owner,
53 executable: account.executable,
54 rent_epoch: account.rent_epoch,
55 });
56 }
57 }
58 {
59 if let Some(decoded) = pool::Pool::decode(data) {
60 return Some(carbon_core::account::DecodedAccount {
61 lamports: account.lamports,
62 data: MeteoraPoolsAccount::Pool(Box::new(decoded)),
63 owner: account.owner,
64 executable: account.executable,
65 rent_epoch: account.rent_epoch,
66 });
67 }
68 }
69
70 None
71 }
72}