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