Skip to main content

satrush_client/generated/accounts/
satrush_config.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_address::Address;
9use borsh::BorshSerialize;
10use borsh::BorshDeserialize;
11
12
13#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
14pub struct SatrushConfig {
15pub discriminator: [u8; 8],
16/// Struct version.
17pub version: u16,
18/// Bump seed for the config account.
19pub bump: u8,
20/// Current update authority address for both Config and other PDAs - can be updated.
21pub admin_authority: Address,
22/// Owner of the program. Can change ownership and set the admin of the program.
23pub owner_authority: Address,
24/// Address of the authority controlling the round flow.
25pub round_authority: Address,
26/// Protocol fees recipient address.
27pub fee_recipient: Address,
28/// USD mint address, initially USDC
29pub usd_mint: Address,
30/// BTC mint address, initially cbBTC
31pub btc_mint: Address,
32/// Strike jackpot fee in basis points.
33pub strike_fee_bps: u32,
34/// Epoch Vault fee in basis points.
35pub epoch_fee_bps: u32,
36/// 1 BTC Vault fee in basis points.
37pub one_btc_fee_bps: u32,
38/// Sats Vault fee in basis points.
39pub sats_vault_round_fee_bps: u32,
40/// Sats Vault claim fee in basis points.
41pub sats_vault_claim_fee_bps: u32,
42/// Protocol fee in basis points.
43pub protocol_fee_bps: u32,
44/// Reserved
45pub reserved: [u8; 30],
46}
47
48
49pub const SATRUSH_CONFIG_DISCRIMINATOR: [u8; 8] = [113, 169, 164, 118, 148, 217, 160, 200];
50
51impl SatrushConfig {
52      pub const LEN: usize = 257;
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_account_info::AccountInfo<'a>> for SatrushConfig {
64  type Error = std::io::Error;
65
66  fn try_from(account_info: &solana_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_satrush_config(
74  rpc: &solana_rpc_client::rpc_client::RpcClient,
75  address: &solana_address::Address,
76) -> Result<crate::shared::DecodedAccount<SatrushConfig>, std::io::Error> {
77  let accounts = fetch_all_satrush_config(rpc, &[*address])?;
78  Ok(accounts[0].clone())
79}
80
81#[cfg(feature = "fetch")]
82pub fn fetch_all_satrush_config(
83  rpc: &solana_rpc_client::rpc_client::RpcClient,
84  addresses: &[solana_address::Address],
85) -> Result<Vec<crate::shared::DecodedAccount<SatrushConfig>>, std::io::Error> {
86    let accounts = rpc.get_multiple_accounts(addresses)
87      .map_err(|e| std::io::Error::other(e.to_string()))?;
88    let mut decoded_accounts: Vec<crate::shared::DecodedAccount<SatrushConfig>> = 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::other(format!("Account not found: {address}")))?;
93      let data = SatrushConfig::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_satrush_config(
101  rpc: &solana_rpc_client::rpc_client::RpcClient,
102  address: &solana_address::Address,
103) -> Result<crate::shared::MaybeAccount<SatrushConfig>, std::io::Error> {
104    let accounts = fetch_all_maybe_satrush_config(rpc, &[*address])?;
105    Ok(accounts[0].clone())
106}
107
108#[cfg(feature = "fetch")]
109pub fn fetch_all_maybe_satrush_config(
110  rpc: &solana_rpc_client::rpc_client::RpcClient,
111  addresses: &[solana_address::Address],
112) -> Result<Vec<crate::shared::MaybeAccount<SatrushConfig>>, std::io::Error> {
113    let accounts = rpc.get_multiple_accounts(addresses)
114      .map_err(|e| std::io::Error::other(e.to_string()))?;
115    let mut decoded_accounts: Vec<crate::shared::MaybeAccount<SatrushConfig>> = 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 = SatrushConfig::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 SatrushConfig {
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 SatrushConfig {}
137
138  #[cfg(feature = "anchor")]
139  impl anchor_lang::Owner for SatrushConfig {
140      fn owner() -> anchor_lang::solana_program::pubkey::Pubkey {
141        anchor_lang::solana_program::pubkey::Pubkey::from(
142          crate::SATRUSH_ID.to_bytes()
143        )
144      }
145  }
146
147  #[cfg(feature = "anchor-idl-build")]
148  impl anchor_lang::IdlBuild for SatrushConfig {}
149
150  
151  #[cfg(feature = "anchor-idl-build")]
152  impl anchor_lang::Discriminator for SatrushConfig {
153    const DISCRIMINATOR: &[u8] = &[0; 8];
154  }
155