1use borsh::BorshSerialize;
9use borsh::BorshDeserialize;
10
11pub const UPDATE_DEPLOY_FEES_DISCRIMINATOR: [u8; 8] = [0, 170, 26, 215, 156, 171, 22, 68];
12
13#[derive(Debug)]
15pub struct UpdateDeployFees {
16
17
18 pub authority: solana_address::Address,
19
20
21 pub satrush_config: solana_address::Address,
22 }
23
24impl UpdateDeployFees {
25 pub fn instruction(&self, args: UpdateDeployFeesInstructionArgs) -> solana_instruction::Instruction {
26 self.instruction_with_remaining_accounts(args, &[])
27 }
28 #[allow(clippy::arithmetic_side_effects)]
29 #[allow(clippy::vec_init_then_push)]
30 pub fn instruction_with_remaining_accounts(&self, args: UpdateDeployFeesInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
31 let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
32 accounts.push(solana_instruction::AccountMeta::new_readonly(
33 self.authority,
34 true
35 ));
36 accounts.push(solana_instruction::AccountMeta::new(
37 self.satrush_config,
38 false
39 ));
40 accounts.extend_from_slice(remaining_accounts);
41 let mut data = UpdateDeployFeesInstructionData::new().try_to_vec().unwrap();
42 let mut args = args.try_to_vec().unwrap();
43 data.append(&mut args);
44
45 solana_instruction::Instruction {
46 program_id: crate::SATRUSH_ID,
47 accounts,
48 data,
49 }
50 }
51}
52
53#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
54 pub struct UpdateDeployFeesInstructionData {
55 discriminator: [u8; 8],
56 }
57
58impl UpdateDeployFeesInstructionData {
59 pub fn new() -> Self {
60 Self {
61 discriminator: [0, 170, 26, 215, 156, 171, 22, 68],
62 }
63 }
64
65 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
66 borsh::to_vec(self)
67 }
68 }
69
70impl Default for UpdateDeployFeesInstructionData {
71 fn default() -> Self {
72 Self::new()
73 }
74}
75
76#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
77 pub struct UpdateDeployFeesInstructionArgs {
78 pub new_strike_fee_bps: u32,
79 pub new_epoch_fee_bps: u32,
80 pub new_one_btc_fee_bps: u32,
81 pub new_protocol_fee_bps: u32,
82 pub new_buybacks_fee_bps: u32,
83 }
84
85impl UpdateDeployFeesInstructionArgs {
86 pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
87 borsh::to_vec(self)
88 }
89}
90
91
92#[derive(Clone, Debug, Default)]
99pub struct UpdateDeployFeesBuilder {
100 authority: Option<solana_address::Address>,
101 satrush_config: Option<solana_address::Address>,
102 new_strike_fee_bps: Option<u32>,
103 new_epoch_fee_bps: Option<u32>,
104 new_one_btc_fee_bps: Option<u32>,
105 new_protocol_fee_bps: Option<u32>,
106 new_buybacks_fee_bps: Option<u32>,
107 __remaining_accounts: Vec<solana_instruction::AccountMeta>,
108}
109
110impl UpdateDeployFeesBuilder {
111 pub fn new() -> Self {
112 Self::default()
113 }
114 #[inline(always)]
115 pub fn authority(&mut self, authority: solana_address::Address) -> &mut Self {
116 self.authority = Some(authority);
117 self
118 }
119 #[inline(always)]
120 pub fn satrush_config(&mut self, satrush_config: solana_address::Address) -> &mut Self {
121 self.satrush_config = Some(satrush_config);
122 self
123 }
124 #[inline(always)]
125 pub fn new_strike_fee_bps(&mut self, new_strike_fee_bps: u32) -> &mut Self {
126 self.new_strike_fee_bps = Some(new_strike_fee_bps);
127 self
128 }
129 #[inline(always)]
130 pub fn new_epoch_fee_bps(&mut self, new_epoch_fee_bps: u32) -> &mut Self {
131 self.new_epoch_fee_bps = Some(new_epoch_fee_bps);
132 self
133 }
134 #[inline(always)]
135 pub fn new_one_btc_fee_bps(&mut self, new_one_btc_fee_bps: u32) -> &mut Self {
136 self.new_one_btc_fee_bps = Some(new_one_btc_fee_bps);
137 self
138 }
139 #[inline(always)]
140 pub fn new_protocol_fee_bps(&mut self, new_protocol_fee_bps: u32) -> &mut Self {
141 self.new_protocol_fee_bps = Some(new_protocol_fee_bps);
142 self
143 }
144 #[inline(always)]
145 pub fn new_buybacks_fee_bps(&mut self, new_buybacks_fee_bps: u32) -> &mut Self {
146 self.new_buybacks_fee_bps = Some(new_buybacks_fee_bps);
147 self
148 }
149 #[inline(always)]
151 pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
152 self.__remaining_accounts.push(account);
153 self
154 }
155 #[inline(always)]
157 pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
158 self.__remaining_accounts.extend_from_slice(accounts);
159 self
160 }
161 #[allow(clippy::clone_on_copy)]
162 pub fn instruction(&self) -> solana_instruction::Instruction {
163 let accounts = UpdateDeployFees {
164 authority: self.authority.expect("authority is not set"),
165 satrush_config: self.satrush_config.expect("satrush_config is not set"),
166 };
167 let args = UpdateDeployFeesInstructionArgs {
168 new_strike_fee_bps: self.new_strike_fee_bps.clone().expect("new_strike_fee_bps is not set"),
169 new_epoch_fee_bps: self.new_epoch_fee_bps.clone().expect("new_epoch_fee_bps is not set"),
170 new_one_btc_fee_bps: self.new_one_btc_fee_bps.clone().expect("new_one_btc_fee_bps is not set"),
171 new_protocol_fee_bps: self.new_protocol_fee_bps.clone().expect("new_protocol_fee_bps is not set"),
172 new_buybacks_fee_bps: self.new_buybacks_fee_bps.clone().expect("new_buybacks_fee_bps is not set"),
173 };
174
175 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
176 }
177}
178
179 pub struct UpdateDeployFeesCpiAccounts<'a, 'b> {
181
182
183 pub authority: &'b solana_account_info::AccountInfo<'a>,
184
185
186 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
187 }
188
189pub struct UpdateDeployFeesCpi<'a, 'b> {
191 pub __program: &'b solana_account_info::AccountInfo<'a>,
193
194
195 pub authority: &'b solana_account_info::AccountInfo<'a>,
196
197
198 pub satrush_config: &'b solana_account_info::AccountInfo<'a>,
199 pub __args: UpdateDeployFeesInstructionArgs,
201 }
202
203impl<'a, 'b> UpdateDeployFeesCpi<'a, 'b> {
204 pub fn new(
205 program: &'b solana_account_info::AccountInfo<'a>,
206 accounts: UpdateDeployFeesCpiAccounts<'a, 'b>,
207 args: UpdateDeployFeesInstructionArgs,
208 ) -> Self {
209 Self {
210 __program: program,
211 authority: accounts.authority,
212 satrush_config: accounts.satrush_config,
213 __args: args,
214 }
215 }
216 #[inline(always)]
217 pub fn invoke(&self) -> solana_program_error::ProgramResult {
218 self.invoke_signed_with_remaining_accounts(&[], &[])
219 }
220 #[inline(always)]
221 pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
222 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
223 }
224 #[inline(always)]
225 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
226 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
227 }
228 #[allow(clippy::arithmetic_side_effects)]
229 #[allow(clippy::clone_on_copy)]
230 #[allow(clippy::vec_init_then_push)]
231 pub fn invoke_signed_with_remaining_accounts(
232 &self,
233 signers_seeds: &[&[&[u8]]],
234 remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]
235 ) -> solana_program_error::ProgramResult {
236 let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
237 accounts.push(solana_instruction::AccountMeta::new_readonly(
238 *self.authority.key,
239 true
240 ));
241 accounts.push(solana_instruction::AccountMeta::new(
242 *self.satrush_config.key,
243 false
244 ));
245 remaining_accounts.iter().for_each(|remaining_account| {
246 accounts.push(solana_instruction::AccountMeta {
247 pubkey: *remaining_account.0.key,
248 is_signer: remaining_account.1,
249 is_writable: remaining_account.2,
250 })
251 });
252 let mut data = UpdateDeployFeesInstructionData::new().try_to_vec().unwrap();
253 let mut args = self.__args.try_to_vec().unwrap();
254 data.append(&mut args);
255
256 let instruction = solana_instruction::Instruction {
257 program_id: crate::SATRUSH_ID,
258 accounts,
259 data,
260 };
261 let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len());
262 account_infos.push(self.__program.clone());
263 account_infos.push(self.authority.clone());
264 account_infos.push(self.satrush_config.clone());
265 remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
266
267 if signers_seeds.is_empty() {
268 solana_cpi::invoke(&instruction, &account_infos)
269 } else {
270 solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
271 }
272 }
273}
274
275#[derive(Clone, Debug)]
282pub struct UpdateDeployFeesCpiBuilder<'a, 'b> {
283 instruction: Box<UpdateDeployFeesCpiBuilderInstruction<'a, 'b>>,
284}
285
286impl<'a, 'b> UpdateDeployFeesCpiBuilder<'a, 'b> {
287 pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
288 let instruction = Box::new(UpdateDeployFeesCpiBuilderInstruction {
289 __program: program,
290 authority: None,
291 satrush_config: None,
292 new_strike_fee_bps: None,
293 new_epoch_fee_bps: None,
294 new_one_btc_fee_bps: None,
295 new_protocol_fee_bps: None,
296 new_buybacks_fee_bps: None,
297 __remaining_accounts: Vec::new(),
298 });
299 Self { instruction }
300 }
301 #[inline(always)]
302 pub fn authority(&mut self, authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
303 self.instruction.authority = Some(authority);
304 self
305 }
306 #[inline(always)]
307 pub fn satrush_config(&mut self, satrush_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
308 self.instruction.satrush_config = Some(satrush_config);
309 self
310 }
311 #[inline(always)]
312 pub fn new_strike_fee_bps(&mut self, new_strike_fee_bps: u32) -> &mut Self {
313 self.instruction.new_strike_fee_bps = Some(new_strike_fee_bps);
314 self
315 }
316 #[inline(always)]
317 pub fn new_epoch_fee_bps(&mut self, new_epoch_fee_bps: u32) -> &mut Self {
318 self.instruction.new_epoch_fee_bps = Some(new_epoch_fee_bps);
319 self
320 }
321 #[inline(always)]
322 pub fn new_one_btc_fee_bps(&mut self, new_one_btc_fee_bps: u32) -> &mut Self {
323 self.instruction.new_one_btc_fee_bps = Some(new_one_btc_fee_bps);
324 self
325 }
326 #[inline(always)]
327 pub fn new_protocol_fee_bps(&mut self, new_protocol_fee_bps: u32) -> &mut Self {
328 self.instruction.new_protocol_fee_bps = Some(new_protocol_fee_bps);
329 self
330 }
331 #[inline(always)]
332 pub fn new_buybacks_fee_bps(&mut self, new_buybacks_fee_bps: u32) -> &mut Self {
333 self.instruction.new_buybacks_fee_bps = Some(new_buybacks_fee_bps);
334 self
335 }
336 #[inline(always)]
338 pub fn add_remaining_account(&mut self, account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
339 self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
340 self
341 }
342 #[inline(always)]
347 pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
348 self.instruction.__remaining_accounts.extend_from_slice(accounts);
349 self
350 }
351 #[inline(always)]
352 pub fn invoke(&self) -> solana_program_error::ProgramResult {
353 self.invoke_signed(&[])
354 }
355 #[allow(clippy::clone_on_copy)]
356 #[allow(clippy::vec_init_then_push)]
357 pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult {
358 let args = UpdateDeployFeesInstructionArgs {
359 new_strike_fee_bps: self.instruction.new_strike_fee_bps.clone().expect("new_strike_fee_bps is not set"),
360 new_epoch_fee_bps: self.instruction.new_epoch_fee_bps.clone().expect("new_epoch_fee_bps is not set"),
361 new_one_btc_fee_bps: self.instruction.new_one_btc_fee_bps.clone().expect("new_one_btc_fee_bps is not set"),
362 new_protocol_fee_bps: self.instruction.new_protocol_fee_bps.clone().expect("new_protocol_fee_bps is not set"),
363 new_buybacks_fee_bps: self.instruction.new_buybacks_fee_bps.clone().expect("new_buybacks_fee_bps is not set"),
364 };
365 let instruction = UpdateDeployFeesCpi {
366 __program: self.instruction.__program,
367
368 authority: self.instruction.authority.expect("authority is not set"),
369
370 satrush_config: self.instruction.satrush_config.expect("satrush_config is not set"),
371 __args: args,
372 };
373 instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
374 }
375}
376
377#[derive(Clone, Debug)]
378struct UpdateDeployFeesCpiBuilderInstruction<'a, 'b> {
379 __program: &'b solana_account_info::AccountInfo<'a>,
380 authority: Option<&'b solana_account_info::AccountInfo<'a>>,
381 satrush_config: Option<&'b solana_account_info::AccountInfo<'a>>,
382 new_strike_fee_bps: Option<u32>,
383 new_epoch_fee_bps: Option<u32>,
384 new_one_btc_fee_bps: Option<u32>,
385 new_protocol_fee_bps: Option<u32>,
386 new_buybacks_fee_bps: Option<u32>,
387 __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
389}
390