Skip to main content

orca_sol/instructions/
decrease_liquidity.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 borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11/// Accounts.
12#[derive(Debug)]
13pub struct DecreaseLiquidity {
14    pub whirlpool: solana_pubkey::Pubkey,
15
16    pub token_program: solana_pubkey::Pubkey,
17
18    pub position_authority: solana_pubkey::Pubkey,
19
20    pub position: solana_pubkey::Pubkey,
21
22    pub position_token_account: solana_pubkey::Pubkey,
23
24    pub token_owner_account_a: solana_pubkey::Pubkey,
25
26    pub token_owner_account_b: solana_pubkey::Pubkey,
27
28    pub token_vault_a: solana_pubkey::Pubkey,
29
30    pub token_vault_b: solana_pubkey::Pubkey,
31
32    pub tick_array_lower: solana_pubkey::Pubkey,
33
34    pub tick_array_upper: solana_pubkey::Pubkey,
35}
36
37impl DecreaseLiquidity {
38    pub fn instruction(
39        &self,
40        args: DecreaseLiquidityInstructionArgs,
41    ) -> solana_instruction::Instruction {
42        self.instruction_with_remaining_accounts(args, &[])
43    }
44    #[allow(clippy::arithmetic_side_effects)]
45    #[allow(clippy::vec_init_then_push)]
46    pub fn instruction_with_remaining_accounts(
47        &self,
48        args: DecreaseLiquidityInstructionArgs,
49        remaining_accounts: &[solana_instruction::AccountMeta],
50    ) -> solana_instruction::Instruction {
51        let mut accounts = Vec::with_capacity(11 + remaining_accounts.len());
52        accounts.push(solana_instruction::AccountMeta::new(self.whirlpool, false));
53        accounts.push(solana_instruction::AccountMeta::new_readonly(
54            self.token_program,
55            false,
56        ));
57        accounts.push(solana_instruction::AccountMeta::new_readonly(
58            self.position_authority,
59            true,
60        ));
61        accounts.push(solana_instruction::AccountMeta::new(self.position, false));
62        accounts.push(solana_instruction::AccountMeta::new_readonly(
63            self.position_token_account,
64            false,
65        ));
66        accounts.push(solana_instruction::AccountMeta::new(
67            self.token_owner_account_a,
68            false,
69        ));
70        accounts.push(solana_instruction::AccountMeta::new(
71            self.token_owner_account_b,
72            false,
73        ));
74        accounts.push(solana_instruction::AccountMeta::new(
75            self.token_vault_a,
76            false,
77        ));
78        accounts.push(solana_instruction::AccountMeta::new(
79            self.token_vault_b,
80            false,
81        ));
82        accounts.push(solana_instruction::AccountMeta::new(
83            self.tick_array_lower,
84            false,
85        ));
86        accounts.push(solana_instruction::AccountMeta::new(
87            self.tick_array_upper,
88            false,
89        ));
90        accounts.extend_from_slice(remaining_accounts);
91        let mut data = borsh::to_vec(&DecreaseLiquidityInstructionData::new()).unwrap();
92        let mut args = borsh::to_vec(&args).unwrap();
93        data.append(&mut args);
94
95        solana_instruction::Instruction {
96            program_id: crate::WHIRLPOOL_ID,
97            accounts,
98            data,
99        }
100    }
101}
102
103#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
104#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
105pub struct DecreaseLiquidityInstructionData {
106    discriminator: [u8; 8],
107}
108
109impl DecreaseLiquidityInstructionData {
110    pub fn new() -> Self {
111        Self {
112            discriminator: [160, 38, 208, 111, 104, 91, 44, 1],
113        }
114    }
115}
116
117impl Default for DecreaseLiquidityInstructionData {
118    fn default() -> Self {
119        Self::new()
120    }
121}
122
123#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
124#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
125pub struct DecreaseLiquidityInstructionArgs {
126    pub liquidity_amount: u128,
127    pub token_min_a: u64,
128    pub token_min_b: u64,
129}
130
131/// Instruction builder for `DecreaseLiquidity`.
132///
133/// ### Accounts:
134///
135///   0. `[writable]` whirlpool
136///   1. `[optional]` token_program (default to `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`)
137///   2. `[signer]` position_authority
138///   3. `[writable]` position
139///   4. `[]` position_token_account
140///   5. `[writable]` token_owner_account_a
141///   6. `[writable]` token_owner_account_b
142///   7. `[writable]` token_vault_a
143///   8. `[writable]` token_vault_b
144///   9. `[writable]` tick_array_lower
145///   10. `[writable]` tick_array_upper
146#[derive(Clone, Debug, Default)]
147pub struct DecreaseLiquidityBuilder {
148    whirlpool: Option<solana_pubkey::Pubkey>,
149    token_program: Option<solana_pubkey::Pubkey>,
150    position_authority: Option<solana_pubkey::Pubkey>,
151    position: Option<solana_pubkey::Pubkey>,
152    position_token_account: Option<solana_pubkey::Pubkey>,
153    token_owner_account_a: Option<solana_pubkey::Pubkey>,
154    token_owner_account_b: Option<solana_pubkey::Pubkey>,
155    token_vault_a: Option<solana_pubkey::Pubkey>,
156    token_vault_b: Option<solana_pubkey::Pubkey>,
157    tick_array_lower: Option<solana_pubkey::Pubkey>,
158    tick_array_upper: Option<solana_pubkey::Pubkey>,
159    liquidity_amount: Option<u128>,
160    token_min_a: Option<u64>,
161    token_min_b: Option<u64>,
162    __remaining_accounts: Vec<solana_instruction::AccountMeta>,
163}
164
165impl DecreaseLiquidityBuilder {
166    pub fn new() -> Self {
167        Self::default()
168    }
169    #[inline(always)]
170    pub fn whirlpool(&mut self, whirlpool: solana_pubkey::Pubkey) -> &mut Self {
171        self.whirlpool = Some(whirlpool);
172        self
173    }
174    /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']`
175    #[inline(always)]
176    pub fn token_program(&mut self, token_program: solana_pubkey::Pubkey) -> &mut Self {
177        self.token_program = Some(token_program);
178        self
179    }
180    #[inline(always)]
181    pub fn position_authority(&mut self, position_authority: solana_pubkey::Pubkey) -> &mut Self {
182        self.position_authority = Some(position_authority);
183        self
184    }
185    #[inline(always)]
186    pub fn position(&mut self, position: solana_pubkey::Pubkey) -> &mut Self {
187        self.position = Some(position);
188        self
189    }
190    #[inline(always)]
191    pub fn position_token_account(
192        &mut self,
193        position_token_account: solana_pubkey::Pubkey,
194    ) -> &mut Self {
195        self.position_token_account = Some(position_token_account);
196        self
197    }
198    #[inline(always)]
199    pub fn token_owner_account_a(
200        &mut self,
201        token_owner_account_a: solana_pubkey::Pubkey,
202    ) -> &mut Self {
203        self.token_owner_account_a = Some(token_owner_account_a);
204        self
205    }
206    #[inline(always)]
207    pub fn token_owner_account_b(
208        &mut self,
209        token_owner_account_b: solana_pubkey::Pubkey,
210    ) -> &mut Self {
211        self.token_owner_account_b = Some(token_owner_account_b);
212        self
213    }
214    #[inline(always)]
215    pub fn token_vault_a(&mut self, token_vault_a: solana_pubkey::Pubkey) -> &mut Self {
216        self.token_vault_a = Some(token_vault_a);
217        self
218    }
219    #[inline(always)]
220    pub fn token_vault_b(&mut self, token_vault_b: solana_pubkey::Pubkey) -> &mut Self {
221        self.token_vault_b = Some(token_vault_b);
222        self
223    }
224    #[inline(always)]
225    pub fn tick_array_lower(&mut self, tick_array_lower: solana_pubkey::Pubkey) -> &mut Self {
226        self.tick_array_lower = Some(tick_array_lower);
227        self
228    }
229    #[inline(always)]
230    pub fn tick_array_upper(&mut self, tick_array_upper: solana_pubkey::Pubkey) -> &mut Self {
231        self.tick_array_upper = Some(tick_array_upper);
232        self
233    }
234    #[inline(always)]
235    pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self {
236        self.liquidity_amount = Some(liquidity_amount);
237        self
238    }
239    #[inline(always)]
240    pub fn token_min_a(&mut self, token_min_a: u64) -> &mut Self {
241        self.token_min_a = Some(token_min_a);
242        self
243    }
244    #[inline(always)]
245    pub fn token_min_b(&mut self, token_min_b: u64) -> &mut Self {
246        self.token_min_b = Some(token_min_b);
247        self
248    }
249    /// Add an additional account to the instruction.
250    #[inline(always)]
251    pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
252        self.__remaining_accounts.push(account);
253        self
254    }
255    /// Add additional accounts to the instruction.
256    #[inline(always)]
257    pub fn add_remaining_accounts(
258        &mut self,
259        accounts: &[solana_instruction::AccountMeta],
260    ) -> &mut Self {
261        self.__remaining_accounts.extend_from_slice(accounts);
262        self
263    }
264    #[allow(clippy::clone_on_copy)]
265    pub fn instruction(&self) -> solana_instruction::Instruction {
266        let accounts = DecreaseLiquidity {
267            whirlpool: self.whirlpool.expect("whirlpool is not set"),
268            token_program: self.token_program.unwrap_or(solana_pubkey::pubkey!(
269                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
270            )),
271            position_authority: self
272                .position_authority
273                .expect("position_authority is not set"),
274            position: self.position.expect("position is not set"),
275            position_token_account: self
276                .position_token_account
277                .expect("position_token_account is not set"),
278            token_owner_account_a: self
279                .token_owner_account_a
280                .expect("token_owner_account_a is not set"),
281            token_owner_account_b: self
282                .token_owner_account_b
283                .expect("token_owner_account_b is not set"),
284            token_vault_a: self.token_vault_a.expect("token_vault_a is not set"),
285            token_vault_b: self.token_vault_b.expect("token_vault_b is not set"),
286            tick_array_lower: self.tick_array_lower.expect("tick_array_lower is not set"),
287            tick_array_upper: self.tick_array_upper.expect("tick_array_upper is not set"),
288        };
289        let args = DecreaseLiquidityInstructionArgs {
290            liquidity_amount: self
291                .liquidity_amount
292                .clone()
293                .expect("liquidity_amount is not set"),
294            token_min_a: self.token_min_a.clone().expect("token_min_a is not set"),
295            token_min_b: self.token_min_b.clone().expect("token_min_b is not set"),
296        };
297
298        accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
299    }
300}
301
302/// `decrease_liquidity` CPI accounts.
303pub struct DecreaseLiquidityCpiAccounts<'a, 'b> {
304    pub whirlpool: &'b solana_account_info::AccountInfo<'a>,
305
306    pub token_program: &'b solana_account_info::AccountInfo<'a>,
307
308    pub position_authority: &'b solana_account_info::AccountInfo<'a>,
309
310    pub position: &'b solana_account_info::AccountInfo<'a>,
311
312    pub position_token_account: &'b solana_account_info::AccountInfo<'a>,
313
314    pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>,
315
316    pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>,
317
318    pub token_vault_a: &'b solana_account_info::AccountInfo<'a>,
319
320    pub token_vault_b: &'b solana_account_info::AccountInfo<'a>,
321
322    pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>,
323
324    pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>,
325}
326
327/// `decrease_liquidity` CPI instruction.
328pub struct DecreaseLiquidityCpi<'a, 'b> {
329    /// The program to invoke.
330    pub __program: &'b solana_account_info::AccountInfo<'a>,
331
332    pub whirlpool: &'b solana_account_info::AccountInfo<'a>,
333
334    pub token_program: &'b solana_account_info::AccountInfo<'a>,
335
336    pub position_authority: &'b solana_account_info::AccountInfo<'a>,
337
338    pub position: &'b solana_account_info::AccountInfo<'a>,
339
340    pub position_token_account: &'b solana_account_info::AccountInfo<'a>,
341
342    pub token_owner_account_a: &'b solana_account_info::AccountInfo<'a>,
343
344    pub token_owner_account_b: &'b solana_account_info::AccountInfo<'a>,
345
346    pub token_vault_a: &'b solana_account_info::AccountInfo<'a>,
347
348    pub token_vault_b: &'b solana_account_info::AccountInfo<'a>,
349
350    pub tick_array_lower: &'b solana_account_info::AccountInfo<'a>,
351
352    pub tick_array_upper: &'b solana_account_info::AccountInfo<'a>,
353    /// The arguments for the instruction.
354    pub __args: DecreaseLiquidityInstructionArgs,
355}
356
357impl<'a, 'b> DecreaseLiquidityCpi<'a, 'b> {
358    pub fn new(
359        program: &'b solana_account_info::AccountInfo<'a>,
360        accounts: DecreaseLiquidityCpiAccounts<'a, 'b>,
361        args: DecreaseLiquidityInstructionArgs,
362    ) -> Self {
363        Self {
364            __program: program,
365            whirlpool: accounts.whirlpool,
366            token_program: accounts.token_program,
367            position_authority: accounts.position_authority,
368            position: accounts.position,
369            position_token_account: accounts.position_token_account,
370            token_owner_account_a: accounts.token_owner_account_a,
371            token_owner_account_b: accounts.token_owner_account_b,
372            token_vault_a: accounts.token_vault_a,
373            token_vault_b: accounts.token_vault_b,
374            tick_array_lower: accounts.tick_array_lower,
375            tick_array_upper: accounts.tick_array_upper,
376            __args: args,
377        }
378    }
379    #[inline(always)]
380    pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
381        self.invoke_signed_with_remaining_accounts(&[], &[])
382    }
383    #[inline(always)]
384    pub fn invoke_with_remaining_accounts(
385        &self,
386        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
387    ) -> solana_program_entrypoint::ProgramResult {
388        self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
389    }
390    #[inline(always)]
391    pub fn invoke_signed(
392        &self,
393        signers_seeds: &[&[&[u8]]],
394    ) -> solana_program_entrypoint::ProgramResult {
395        self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
396    }
397    #[allow(clippy::arithmetic_side_effects)]
398    #[allow(clippy::clone_on_copy)]
399    #[allow(clippy::vec_init_then_push)]
400    pub fn invoke_signed_with_remaining_accounts(
401        &self,
402        signers_seeds: &[&[&[u8]]],
403        remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
404    ) -> solana_program_entrypoint::ProgramResult {
405        let mut accounts = Vec::with_capacity(11 + remaining_accounts.len());
406        accounts.push(solana_instruction::AccountMeta::new(
407            *self.whirlpool.key,
408            false,
409        ));
410        accounts.push(solana_instruction::AccountMeta::new_readonly(
411            *self.token_program.key,
412            false,
413        ));
414        accounts.push(solana_instruction::AccountMeta::new_readonly(
415            *self.position_authority.key,
416            true,
417        ));
418        accounts.push(solana_instruction::AccountMeta::new(
419            *self.position.key,
420            false,
421        ));
422        accounts.push(solana_instruction::AccountMeta::new_readonly(
423            *self.position_token_account.key,
424            false,
425        ));
426        accounts.push(solana_instruction::AccountMeta::new(
427            *self.token_owner_account_a.key,
428            false,
429        ));
430        accounts.push(solana_instruction::AccountMeta::new(
431            *self.token_owner_account_b.key,
432            false,
433        ));
434        accounts.push(solana_instruction::AccountMeta::new(
435            *self.token_vault_a.key,
436            false,
437        ));
438        accounts.push(solana_instruction::AccountMeta::new(
439            *self.token_vault_b.key,
440            false,
441        ));
442        accounts.push(solana_instruction::AccountMeta::new(
443            *self.tick_array_lower.key,
444            false,
445        ));
446        accounts.push(solana_instruction::AccountMeta::new(
447            *self.tick_array_upper.key,
448            false,
449        ));
450        remaining_accounts.iter().for_each(|remaining_account| {
451            accounts.push(solana_instruction::AccountMeta {
452                pubkey: *remaining_account.0.key,
453                is_signer: remaining_account.1,
454                is_writable: remaining_account.2,
455            })
456        });
457        let mut data = borsh::to_vec(&DecreaseLiquidityInstructionData::new()).unwrap();
458        let mut args = borsh::to_vec(&self.__args).unwrap();
459        data.append(&mut args);
460
461        let instruction = solana_instruction::Instruction {
462            program_id: crate::WHIRLPOOL_ID,
463            accounts,
464            data,
465        };
466        let mut account_infos = Vec::with_capacity(12 + remaining_accounts.len());
467        account_infos.push(self.__program.clone());
468        account_infos.push(self.whirlpool.clone());
469        account_infos.push(self.token_program.clone());
470        account_infos.push(self.position_authority.clone());
471        account_infos.push(self.position.clone());
472        account_infos.push(self.position_token_account.clone());
473        account_infos.push(self.token_owner_account_a.clone());
474        account_infos.push(self.token_owner_account_b.clone());
475        account_infos.push(self.token_vault_a.clone());
476        account_infos.push(self.token_vault_b.clone());
477        account_infos.push(self.tick_array_lower.clone());
478        account_infos.push(self.tick_array_upper.clone());
479        remaining_accounts
480            .iter()
481            .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
482
483        if signers_seeds.is_empty() {
484            solana_cpi::invoke(&instruction, &account_infos)
485        } else {
486            solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
487        }
488    }
489}
490
491/// Instruction builder for `DecreaseLiquidity` via CPI.
492///
493/// ### Accounts:
494///
495///   0. `[writable]` whirlpool
496///   1. `[]` token_program
497///   2. `[signer]` position_authority
498///   3. `[writable]` position
499///   4. `[]` position_token_account
500///   5. `[writable]` token_owner_account_a
501///   6. `[writable]` token_owner_account_b
502///   7. `[writable]` token_vault_a
503///   8. `[writable]` token_vault_b
504///   9. `[writable]` tick_array_lower
505///   10. `[writable]` tick_array_upper
506#[derive(Clone, Debug)]
507pub struct DecreaseLiquidityCpiBuilder<'a, 'b> {
508    instruction: Box<DecreaseLiquidityCpiBuilderInstruction<'a, 'b>>,
509}
510
511impl<'a, 'b> DecreaseLiquidityCpiBuilder<'a, 'b> {
512    pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
513        let instruction = Box::new(DecreaseLiquidityCpiBuilderInstruction {
514            __program: program,
515            whirlpool: None,
516            token_program: None,
517            position_authority: None,
518            position: None,
519            position_token_account: None,
520            token_owner_account_a: None,
521            token_owner_account_b: None,
522            token_vault_a: None,
523            token_vault_b: None,
524            tick_array_lower: None,
525            tick_array_upper: None,
526            liquidity_amount: None,
527            token_min_a: None,
528            token_min_b: None,
529            __remaining_accounts: Vec::new(),
530        });
531        Self { instruction }
532    }
533    #[inline(always)]
534    pub fn whirlpool(&mut self, whirlpool: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
535        self.instruction.whirlpool = Some(whirlpool);
536        self
537    }
538    #[inline(always)]
539    pub fn token_program(
540        &mut self,
541        token_program: &'b solana_account_info::AccountInfo<'a>,
542    ) -> &mut Self {
543        self.instruction.token_program = Some(token_program);
544        self
545    }
546    #[inline(always)]
547    pub fn position_authority(
548        &mut self,
549        position_authority: &'b solana_account_info::AccountInfo<'a>,
550    ) -> &mut Self {
551        self.instruction.position_authority = Some(position_authority);
552        self
553    }
554    #[inline(always)]
555    pub fn position(&mut self, position: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
556        self.instruction.position = Some(position);
557        self
558    }
559    #[inline(always)]
560    pub fn position_token_account(
561        &mut self,
562        position_token_account: &'b solana_account_info::AccountInfo<'a>,
563    ) -> &mut Self {
564        self.instruction.position_token_account = Some(position_token_account);
565        self
566    }
567    #[inline(always)]
568    pub fn token_owner_account_a(
569        &mut self,
570        token_owner_account_a: &'b solana_account_info::AccountInfo<'a>,
571    ) -> &mut Self {
572        self.instruction.token_owner_account_a = Some(token_owner_account_a);
573        self
574    }
575    #[inline(always)]
576    pub fn token_owner_account_b(
577        &mut self,
578        token_owner_account_b: &'b solana_account_info::AccountInfo<'a>,
579    ) -> &mut Self {
580        self.instruction.token_owner_account_b = Some(token_owner_account_b);
581        self
582    }
583    #[inline(always)]
584    pub fn token_vault_a(
585        &mut self,
586        token_vault_a: &'b solana_account_info::AccountInfo<'a>,
587    ) -> &mut Self {
588        self.instruction.token_vault_a = Some(token_vault_a);
589        self
590    }
591    #[inline(always)]
592    pub fn token_vault_b(
593        &mut self,
594        token_vault_b: &'b solana_account_info::AccountInfo<'a>,
595    ) -> &mut Self {
596        self.instruction.token_vault_b = Some(token_vault_b);
597        self
598    }
599    #[inline(always)]
600    pub fn tick_array_lower(
601        &mut self,
602        tick_array_lower: &'b solana_account_info::AccountInfo<'a>,
603    ) -> &mut Self {
604        self.instruction.tick_array_lower = Some(tick_array_lower);
605        self
606    }
607    #[inline(always)]
608    pub fn tick_array_upper(
609        &mut self,
610        tick_array_upper: &'b solana_account_info::AccountInfo<'a>,
611    ) -> &mut Self {
612        self.instruction.tick_array_upper = Some(tick_array_upper);
613        self
614    }
615    #[inline(always)]
616    pub fn liquidity_amount(&mut self, liquidity_amount: u128) -> &mut Self {
617        self.instruction.liquidity_amount = Some(liquidity_amount);
618        self
619    }
620    #[inline(always)]
621    pub fn token_min_a(&mut self, token_min_a: u64) -> &mut Self {
622        self.instruction.token_min_a = Some(token_min_a);
623        self
624    }
625    #[inline(always)]
626    pub fn token_min_b(&mut self, token_min_b: u64) -> &mut Self {
627        self.instruction.token_min_b = Some(token_min_b);
628        self
629    }
630    /// Add an additional account to the instruction.
631    #[inline(always)]
632    pub fn add_remaining_account(
633        &mut self,
634        account: &'b solana_account_info::AccountInfo<'a>,
635        is_writable: bool,
636        is_signer: bool,
637    ) -> &mut Self {
638        self.instruction
639            .__remaining_accounts
640            .push((account, is_writable, is_signer));
641        self
642    }
643    /// Add additional accounts to the instruction.
644    ///
645    /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not,
646    /// and a `bool` indicating whether the account is a signer or not.
647    #[inline(always)]
648    pub fn add_remaining_accounts(
649        &mut self,
650        accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
651    ) -> &mut Self {
652        self.instruction
653            .__remaining_accounts
654            .extend_from_slice(accounts);
655        self
656    }
657    #[inline(always)]
658    pub fn invoke(&self) -> solana_program_entrypoint::ProgramResult {
659        self.invoke_signed(&[])
660    }
661    #[allow(clippy::clone_on_copy)]
662    #[allow(clippy::vec_init_then_push)]
663    pub fn invoke_signed(
664        &self,
665        signers_seeds: &[&[&[u8]]],
666    ) -> solana_program_entrypoint::ProgramResult {
667        let args = DecreaseLiquidityInstructionArgs {
668            liquidity_amount: self
669                .instruction
670                .liquidity_amount
671                .clone()
672                .expect("liquidity_amount is not set"),
673            token_min_a: self
674                .instruction
675                .token_min_a
676                .clone()
677                .expect("token_min_a is not set"),
678            token_min_b: self
679                .instruction
680                .token_min_b
681                .clone()
682                .expect("token_min_b is not set"),
683        };
684        let instruction = DecreaseLiquidityCpi {
685            __program: self.instruction.__program,
686
687            whirlpool: self.instruction.whirlpool.expect("whirlpool is not set"),
688
689            token_program: self
690                .instruction
691                .token_program
692                .expect("token_program is not set"),
693
694            position_authority: self
695                .instruction
696                .position_authority
697                .expect("position_authority is not set"),
698
699            position: self.instruction.position.expect("position is not set"),
700
701            position_token_account: self
702                .instruction
703                .position_token_account
704                .expect("position_token_account is not set"),
705
706            token_owner_account_a: self
707                .instruction
708                .token_owner_account_a
709                .expect("token_owner_account_a is not set"),
710
711            token_owner_account_b: self
712                .instruction
713                .token_owner_account_b
714                .expect("token_owner_account_b is not set"),
715
716            token_vault_a: self
717                .instruction
718                .token_vault_a
719                .expect("token_vault_a is not set"),
720
721            token_vault_b: self
722                .instruction
723                .token_vault_b
724                .expect("token_vault_b is not set"),
725
726            tick_array_lower: self
727                .instruction
728                .tick_array_lower
729                .expect("tick_array_lower is not set"),
730
731            tick_array_upper: self
732                .instruction
733                .tick_array_upper
734                .expect("tick_array_upper is not set"),
735            __args: args,
736        };
737        instruction.invoke_signed_with_remaining_accounts(
738            signers_seeds,
739            &self.instruction.__remaining_accounts,
740        )
741    }
742}
743
744#[derive(Clone, Debug)]
745struct DecreaseLiquidityCpiBuilderInstruction<'a, 'b> {
746    __program: &'b solana_account_info::AccountInfo<'a>,
747    whirlpool: Option<&'b solana_account_info::AccountInfo<'a>>,
748    token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
749    position_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
750    position: Option<&'b solana_account_info::AccountInfo<'a>>,
751    position_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
752    token_owner_account_a: Option<&'b solana_account_info::AccountInfo<'a>>,
753    token_owner_account_b: Option<&'b solana_account_info::AccountInfo<'a>>,
754    token_vault_a: Option<&'b solana_account_info::AccountInfo<'a>>,
755    token_vault_b: Option<&'b solana_account_info::AccountInfo<'a>>,
756    tick_array_lower: Option<&'b solana_account_info::AccountInfo<'a>>,
757    tick_array_upper: Option<&'b solana_account_info::AccountInfo<'a>>,
758    liquidity_amount: Option<u128>,
759    token_min_a: Option<u64>,
760    token_min_b: Option<u64>,
761    /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
762    __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
763}