defituna_staking/generated/accounts/
fusion_pool.rs1use solana_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 unused0: u32,
32pub liquidity: u128,
33pub sqrt_price: u128,
34pub tick_current_index: i32,
35pub protocol_fee_owed_a: u64,
36pub protocol_fee_owed_b: u64,
37pub fee_growth_global_a: u128,
38pub fee_growth_global_b: u128,
39pub orders_total_amount_a: u64,
40pub orders_total_amount_b: u64,
41pub orders_filled_amount_a: u64,
42pub orders_filled_amount_b: u64,
43pub olp_fee_owed_a: u64,
44pub olp_fee_owed_b: u64,
45pub ma_sqrt_price: u128,
46pub last_swap_timestamp: u64,
47#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::Bytes>"))]
48pub reserved: [u8; 116],
49}
50
51
52impl FusionPool {
53 pub const LEN: usize = 423;
54
55
56
57 #[inline(always)]
58 pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
59 let mut data = data;
60 Self::deserialize(&mut data)
61 }
62}
63
64impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for FusionPool {
65 type Error = std::io::Error;
66
67 fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
68 let mut data: &[u8] = &(*account_info.data).borrow();
69 Self::deserialize(&mut data)
70 }
71}
72
73#[cfg(feature = "fetch")]
74pub fn fetch_fusion_pool(
75 rpc: &solana_client::rpc_client::RpcClient,
76 address: &solana_pubkey::Pubkey,
77) -> Result<crate::shared::DecodedAccount<FusionPool>, std::io::Error> {
78 let accounts = fetch_all_fusion_pool(rpc, &[*address])?;
79 Ok(accounts[0].clone())
80}
81
82#[cfg(feature = "fetch")]
83pub fn fetch_all_fusion_pool(
84 rpc: &solana_client::rpc_client::RpcClient,
85 addresses: &[solana_pubkey::Pubkey],
86) -> Result<Vec<crate::shared::DecodedAccount<FusionPool>>, std::io::Error> {
87 let accounts = rpc.get_multiple_accounts(addresses)
88 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
89 let mut decoded_accounts: Vec<crate::shared::DecodedAccount<FusionPool>> = Vec::new();
90 for i in 0..addresses.len() {
91 let address = addresses[i];
92 let account = accounts[i].as_ref()
93 .ok_or(std::io::Error::new(std::io::ErrorKind::Other, format!("Account not found: {}", address)))?;
94 let data = FusionPool::from_bytes(&account.data)?;
95 decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
96 }
97 Ok(decoded_accounts)
98}
99
100#[cfg(feature = "fetch")]
101pub fn fetch_maybe_fusion_pool(
102 rpc: &solana_client::rpc_client::RpcClient,
103 address: &solana_pubkey::Pubkey,
104) -> Result<crate::shared::MaybeAccount<FusionPool>, std::io::Error> {
105 let accounts = fetch_all_maybe_fusion_pool(rpc, &[*address])?;
106 Ok(accounts[0].clone())
107}
108
109#[cfg(feature = "fetch")]
110pub fn fetch_all_maybe_fusion_pool(
111 rpc: &solana_client::rpc_client::RpcClient,
112 addresses: &[solana_pubkey::Pubkey],
113) -> Result<Vec<crate::shared::MaybeAccount<FusionPool>>, std::io::Error> {
114 let accounts = rpc.get_multiple_accounts(addresses)
115 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
116 let mut decoded_accounts: Vec<crate::shared::MaybeAccount<FusionPool>> = Vec::new();
117 for i in 0..addresses.len() {
118 let address = addresses[i];
119 if let Some(account) = accounts[i].as_ref() {
120 let data = FusionPool::from_bytes(&account.data)?;
121 decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
122 } else {
123 decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
124 }
125 }
126 Ok(decoded_accounts)
127}
128
129 #[cfg(feature = "anchor")]
130 impl anchor_lang::AccountDeserialize for FusionPool {
131 fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
132 Ok(Self::deserialize(buf)?)
133 }
134 }
135
136 #[cfg(feature = "anchor")]
137 impl anchor_lang::AccountSerialize for FusionPool {}
138
139 #[cfg(feature = "anchor")]
140 impl anchor_lang::Owner for FusionPool {
141 fn owner() -> Pubkey {
142 crate::TUNA_STAKING_ID
143 }
144 }
145
146 #[cfg(feature = "anchor-idl-build")]
147 impl anchor_lang::IdlBuild for FusionPool {}
148
149
150 #[cfg(feature = "anchor-idl-build")]
151 impl anchor_lang::Discriminator for FusionPool {
152 const DISCRIMINATOR: [u8; 8] = [0; 8];
153 }
154