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/// Owner of the program. Can change ownership and set the admin of the program.
21pub owner_authority: Address,
22/// Current update authority address for both Config and other PDAs - can be updated.
23pub admin_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 of the gross deployed amount. Charged
39/// at swap time against the pending pile (gross net of the deploy-time
40/// legs), so `Round::swap_amount` rescales it by `deploy_fees_bps`.
41pub sats_vault_round_fee_bps: u32,
42/// Sats Vault claim fee in basis points.
43pub sats_vault_claim_fee_bps: u32,
44/// Protocol fee in basis points.
45pub protocol_fee_bps: u32,
46/// Share of each settled play's hashrate reward deferred until the sats claim in basis points.
47pub unclaimed_hashrate_bps: u32,
48/// Minimum gross deploy size per round, manual or automated, in USD mint (6 decimals).
49pub min_deploy_usd_amount: u64,
50/// Epoch Vault iteration length in slots.
51pub epoch_vault_iteration_duration: u64,
52/// Grace window, in slots after `Round::settled_at_slot`, during which
53/// only the normal settle path applies; afterward stale deployments
54/// become eligible for third-party cleanup
55pub deployment_settle_grace_duration: u64,
56/// Sat Strike odds: the jackpot fires when `rng % strike_trigger_modulus == 0`
57/// (seeded at 1_440 for ~1/1440 odds; 1 = every round triggers).
58pub strike_trigger_modulus: u16,
59/// Reserved
60pub reserved: [u8; 30],
61}
62
63
64pub const SATRUSH_CONFIG_DISCRIMINATOR: [u8; 8] = [113, 169, 164, 118, 148, 217, 160, 200];
65
66impl SatrushConfig {
67      pub const LEN: usize = 287;
68  
69  
70  
71  #[inline(always)]
72  pub fn from_bytes(data: &[u8]) -> Result<Self, std::io::Error> {
73    let mut data = data;
74    Self::deserialize(&mut data)
75  }
76}
77
78impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for SatrushConfig {
79  type Error = std::io::Error;
80
81  fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
82      let mut data: &[u8] = &(*account_info.data).borrow();
83      Self::deserialize(&mut data)
84  }
85}
86
87#[cfg(feature = "fetch")]
88pub fn fetch_satrush_config(
89  rpc: &solana_rpc_client::rpc_client::RpcClient,
90  address: &solana_address::Address,
91) -> Result<crate::shared::DecodedAccount<SatrushConfig>, std::io::Error> {
92  let accounts = fetch_all_satrush_config(rpc, &[*address])?;
93  Ok(accounts[0].clone())
94}
95
96#[cfg(feature = "fetch")]
97pub fn fetch_all_satrush_config(
98  rpc: &solana_rpc_client::rpc_client::RpcClient,
99  addresses: &[solana_address::Address],
100) -> Result<Vec<crate::shared::DecodedAccount<SatrushConfig>>, std::io::Error> {
101    let accounts = rpc.get_multiple_accounts(addresses)
102      .map_err(|e| std::io::Error::other(e.to_string()))?;
103    let mut decoded_accounts: Vec<crate::shared::DecodedAccount<SatrushConfig>> = Vec::new();
104    for i in 0..addresses.len() {
105      let address = addresses[i];
106      let account = accounts[i].as_ref()
107        .ok_or(std::io::Error::other(format!("Account not found: {address}")))?;
108      let data = SatrushConfig::from_bytes(&account.data)?;
109      decoded_accounts.push(crate::shared::DecodedAccount { address, account: account.clone(), data });
110    }
111    Ok(decoded_accounts)
112}
113
114#[cfg(feature = "fetch")]
115pub fn fetch_maybe_satrush_config(
116  rpc: &solana_rpc_client::rpc_client::RpcClient,
117  address: &solana_address::Address,
118) -> Result<crate::shared::MaybeAccount<SatrushConfig>, std::io::Error> {
119    let accounts = fetch_all_maybe_satrush_config(rpc, &[*address])?;
120    Ok(accounts[0].clone())
121}
122
123#[cfg(feature = "fetch")]
124pub fn fetch_all_maybe_satrush_config(
125  rpc: &solana_rpc_client::rpc_client::RpcClient,
126  addresses: &[solana_address::Address],
127) -> Result<Vec<crate::shared::MaybeAccount<SatrushConfig>>, std::io::Error> {
128    let accounts = rpc.get_multiple_accounts(addresses)
129      .map_err(|e| std::io::Error::other(e.to_string()))?;
130    let mut decoded_accounts: Vec<crate::shared::MaybeAccount<SatrushConfig>> = Vec::new();
131    for i in 0..addresses.len() {
132      let address = addresses[i];
133      if let Some(account) = accounts[i].as_ref() {
134        let data = SatrushConfig::from_bytes(&account.data)?;
135        decoded_accounts.push(crate::shared::MaybeAccount::Exists(crate::shared::DecodedAccount { address, account: account.clone(), data }));
136      } else {
137        decoded_accounts.push(crate::shared::MaybeAccount::NotFound(address));
138      }
139    }
140  Ok(decoded_accounts)
141}
142
143  #[cfg(feature = "anchor")]
144  impl anchor_lang::AccountDeserialize for SatrushConfig {
145      fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
146        Ok(Self::deserialize(buf)?)
147      }
148  }
149
150  #[cfg(feature = "anchor")]
151  impl anchor_lang::AccountSerialize for SatrushConfig {}
152
153  #[cfg(feature = "anchor")]
154  impl anchor_lang::Owner for SatrushConfig {
155      fn owner() -> anchor_lang::solana_program::pubkey::Pubkey {
156        anchor_lang::solana_program::pubkey::Pubkey::from(
157          crate::SATRUSH_ID.to_bytes()
158        )
159      }
160  }
161
162  #[cfg(feature = "anchor-idl-build")]
163  impl anchor_lang::IdlBuild for SatrushConfig {}
164
165  
166  #[cfg(feature = "anchor-idl-build")]
167  impl anchor_lang::Discriminator for SatrushConfig {
168    const DISCRIMINATOR: &[u8] = &[0; 8];
169  }
170