defituna_client/generated/accounts/
tuna_config.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 TunaConfig {
16pub discriminator: [u8; 8],
17pub version: u16,
19pub bump: u8,
21#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
23pub admin_authority: Pubkey,
24#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
26pub fee_recipient: Pubkey,
27#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
29pub owner_authority: Pubkey,
30pub unused1: u32,
32pub max_percentage_of_leftovers: u32,
34pub suspend_lending_deposits: bool,
36pub suspend_lending_withdrawals: bool,
38pub suspend_add_liquidity: bool,
40pub suspend_remove_liquidity: bool,
42#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
44pub liquidator_authority: Pubkey,
45pub oracle_price_deviation_threshold: u32,
47pub default_protocol_fee_rate: u16,
49pub default_liquidation_fee_rate: u32,
51pub default_rebalance_fee_rate: u32,
53#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::DisplayFromStr>"))]
55pub oracle_price_update_authority: Pubkey,
56#[cfg_attr(feature = "serde", serde(with = "serde_with::As::<serde_with::Bytes>"))]
58pub reserved: [u8; 134],
59}
60
61
62pub const TUNA_CONFIG_DISCRIMINATOR: [u8; 8] = [124, 149, 24, 7, 195, 168, 153, 58];
63
64impl TunaConfig {
65 pub const LEN: usize = 331;
66
67
68
69 #[inline(always)]
70 pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
71 let mut data = data;
72 Self::deserialize(&mut data)
73 }
74}
75
76impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for TunaConfig {
77 type Error = std::io::Error;
78
79 fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
80 let mut data: &[u8] = &(*account_info.data).borrow();
81 Self::deserialize(&mut data)
82 }
83}
84
85#[cfg(feature = "fetch")]
86pub fn fetch_tuna_config(
87 rpc: &solana_client::rpc_client::RpcClient,
88 address: &solana_pubkey::Pubkey,
89) -> Result<crate::shared::DecodedAccount<TunaConfig>, std::io::Error> {
90 let accounts = fetch_all_tuna_config(rpc, &[*address])?;
91 Ok(accounts[0].clone())
92}
93
94#[cfg(feature = "fetch")]
95pub fn fetch_all_tuna_config(
96 rpc: &solana_client::rpc_client::RpcClient,
97 addresses: &[solana_pubkey::Pubkey],
98) -> Result<Vec<crate::shared::DecodedAccount<TunaConfig>>, std::io::Error> {
99 let accounts = rpc.get_multiple_accounts(addresses)
100 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
101 let mut decoded_accounts: Vec<crate::shared::DecodedAccount<TunaConfig>> = Vec::new();
102 for i in 0..addresses.len() {
103 let address = addresses[i];
104 let account = accounts[i].as_ref()
105 .ok_or(std::io::Error::new(std::io::ErrorKind::Other, format!("Account not found: {}", address)))?;
106 let data = TunaConfig::from_bytes(&account.data)?;
107 decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
108 }
109 Ok(decoded_accounts)
110}
111
112#[cfg(feature = "fetch")]
113pub fn fetch_maybe_tuna_config(
114 rpc: &solana_client::rpc_client::RpcClient,
115 address: &solana_pubkey::Pubkey,
116) -> Result<crate::shared::MaybeAccount<TunaConfig>, std::io::Error> {
117 let accounts = fetch_all_maybe_tuna_config(rpc, &[*address])?;
118 Ok(accounts[0].clone())
119}
120
121#[cfg(feature = "fetch")]
122pub fn fetch_all_maybe_tuna_config(
123 rpc: &solana_client::rpc_client::RpcClient,
124 addresses: &[solana_pubkey::Pubkey],
125) -> Result<Vec<crate::shared::MaybeAccount<TunaConfig>>, std::io::Error> {
126 let accounts = rpc.get_multiple_accounts(addresses)
127 .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
128 let mut decoded_accounts: Vec<crate::shared::MaybeAccount<TunaConfig>> = Vec::new();
129 for i in 0..addresses.len() {
130 let address = addresses[i];
131 if let Some(account) = accounts[i].as_ref() {
132 let data = TunaConfig::from_bytes(&account.data)?;
133 decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
134 } else {
135 decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
136 }
137 }
138 Ok(decoded_accounts)
139}
140
141 #[cfg(feature = "anchor")]
142 impl anchor_lang::AccountDeserialize for TunaConfig {
143 fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
144 Ok(Self::deserialize(buf)?)
145 }
146 }
147
148 #[cfg(feature = "anchor")]
149 impl anchor_lang::AccountSerialize for TunaConfig {}
150
151 #[cfg(feature = "anchor")]
152 impl anchor_lang::Owner for TunaConfig {
153 fn owner() -> Pubkey {
154 crate::TUNA_ID
155 }
156 }
157
158 #[cfg(feature = "anchor-idl-build")]
159 impl anchor_lang::IdlBuild for TunaConfig {}
160
161
162 #[cfg(feature = "anchor-idl-build")]
163 impl anchor_lang::Discriminator for TunaConfig {
164 const DISCRIMINATOR: &[u8] = &[0; 8];
165 }
166