Skip to main content

tensor_price_lock/generated/instructions/
lock_order.rs

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