Skip to main content

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