defituna_client/generated/accounts/
fusion_pool.rs

1//! This code was AUTOGENERATED using the codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7
8use solana_program::pubkey::Pubkey;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12
13#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15pub struct FusionPool {
16pub discriminator: [u8; 8],
17pub bump: [u8; 1],
18pub version: u16,
19#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
20pub token_mint_a: Pubkey,
21#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
22pub token_mint_b: Pubkey,
23#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
24pub token_vault_a: Pubkey,
25#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
26pub token_vault_b: Pubkey,
27pub tick_spacing: u16,
28pub tick_spacing_seed: [u8; 2],
29pub fee_rate: u16,
30pub protocol_fee_rate: u16,
31pub clp_to_olp_reward_ratio: u16,
32pub order_protocol_fee_rate: u16,
33pub liquidity: u128,
34pub sqrt_price: u128,
35pub tick_current_index: i32,
36pub protocol_fee_owed_a: u64,
37pub protocol_fee_owed_b: u64,
38pub fee_growth_global_a: u128,
39pub fee_growth_global_b: u128,
40pub orders_total_amount_a: u64,
41pub orders_total_amount_b: u64,
42pub orders_filled_amount_a: u64,
43pub orders_filled_amount_b: u64,
44pub olp_fee_owed_a: u64,
45pub olp_fee_owed_b: u64,
46#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::Bytes>"))]
47pub reserved: [u8; 140],
48}
49
50
51impl FusionPool {
52      pub const LEN: usize = 423;
53  
54  
55  
56  #[inline(always)]
57  pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
58    let mut data = data;
59    Self::deserialize(&mut data)
60  }
61}
62
63impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for FusionPool {
64  type Error = std::io::Error;
65
66  fn try_from(account_info: &solana_program::account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
67      let mut data: &[u8] = &(*account_info.data).borrow();
68      Self::deserialize(&mut data)
69  }
70}
71
72#[cfg(feature = "fetch")]
73pub fn fetch_fusion_pool(
74  rpc: &solana_client::rpc_client::RpcClient,
75  address: &solana_program::pubkey::Pubkey,
76) -> Result<crate::shared::DecodedAccount<FusionPool>, std::io::Error> {
77  let accounts = fetch_all_fusion_pool(rpc, &[*address])?;
78  Ok(accounts[0].clone())
79}
80
81#[cfg(feature = "fetch")]
82pub fn fetch_all_fusion_pool(
83  rpc: &solana_client::rpc_client::RpcClient,
84  addresses: &[solana_program::pubkey::Pubkey],
85) -> Result<Vec<crate::shared::DecodedAccount<FusionPool>>, std::io::Error> {
86    let accounts = rpc.get_multiple_accounts(addresses)
87      .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
88    let mut decoded_accounts: Vec<crate::shared::DecodedAccount<FusionPool>> = Vec::new();
89    for i in 0..addresses.len() {
90      let address = addresses[i];
91      let account = accounts[i].as_ref()
92        .ok_or(std::io::Error::new(std::io::ErrorKind::Other, format!("Account not found: {}", address)))?;
93      let data = FusionPool::from_bytes(&account.data)?;
94      decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
95    }
96    Ok(decoded_accounts)
97}
98
99#[cfg(feature = "fetch")]
100pub fn fetch_maybe_fusion_pool(
101  rpc: &solana_client::rpc_client::RpcClient,
102  address: &solana_program::pubkey::Pubkey,
103) -> Result<crate::shared::MaybeAccount<FusionPool>, std::io::Error> {
104    let accounts = fetch_all_maybe_fusion_pool(rpc, &[*address])?;
105    Ok(accounts[0].clone())
106}
107
108#[cfg(feature = "fetch")]
109pub fn fetch_all_maybe_fusion_pool(
110  rpc: &solana_client::rpc_client::RpcClient,
111  addresses: &[solana_program::pubkey::Pubkey],
112) -> Result<Vec<crate::shared::MaybeAccount<FusionPool>>, std::io::Error> {
113    let accounts = rpc.get_multiple_accounts(addresses)
114      .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
115    let mut decoded_accounts: Vec<crate::shared::MaybeAccount<FusionPool>> = Vec::new();
116    for i in 0..addresses.len() {
117      let address = addresses[i];
118      if let Some(account) = accounts[i].as_ref() {
119        let data = FusionPool::from_bytes(&account.data)?;
120        decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
121      } else {
122        decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
123      }
124    }
125  Ok(decoded_accounts)
126}
127
128  #[cfg(feature = "anchor")]
129  impl anchor_lang::AccountDeserialize for FusionPool {
130      fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
131        Ok(Self::deserialize(buf)?)
132      }
133  }
134
135  #[cfg(feature = "anchor")]
136  impl anchor_lang::AccountSerialize for FusionPool {}
137
138  #[cfg(feature = "anchor")]
139  impl anchor_lang::Owner for FusionPool {
140      fn owner() -> Pubkey {
141        crate::TUNA_ID
142      }
143  }
144
145  #[cfg(feature = "anchor-idl-build")]
146  impl anchor_lang::IdlBuild for FusionPool {}
147
148  
149  #[cfg(feature = "anchor-idl-build")]
150  impl anchor_lang::Discriminator for FusionPool {
151    const DISCRIMINATOR: [u8; 8] = [0; 8];
152  }
153