tensor_amm/generated/instructions/
tamm_noop.rs1use crate::generated::types::TAmmEvent;
9use borsh::BorshDeserialize;
10use borsh::BorshSerialize;
11
12pub struct TammNoop {
14 pub pool: solana_program::pubkey::Pubkey,
15}
16
17impl TammNoop {
18 pub fn instruction(
19 &self,
20 args: TammNoopInstructionArgs,
21 ) -> solana_program::instruction::Instruction {
22 self.instruction_with_remaining_accounts(args, &[])
23 }
24 #[allow(clippy::vec_init_then_push)]
25 pub fn instruction_with_remaining_accounts(
26 &self,
27 args: TammNoopInstructionArgs,
28 remaining_accounts: &[solana_program::instruction::AccountMeta],
29 ) -> solana_program::instruction::Instruction {
30 let mut accounts = Vec::with_capacity(1 + remaining_accounts.len());
31 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
32 self.pool, false,
33 ));
34 accounts.extend_from_slice(remaining_accounts);
35 let mut data = TammNoopInstructionData::new().try_to_vec().unwrap();
36 let mut args = args.try_to_vec().unwrap();
37 data.append(&mut args);
38
39 solana_program::instruction::Instruction {
40 program_id: crate::TENSOR_AMM_ID,
41 accounts,
42 data,
43 }
44 }
45}
46
47#[derive(BorshDeserialize, BorshSerialize)]
48pub struct TammNoopInstructionData {
49 discriminator: [u8; 8],
50}
51
52impl TammNoopInstructionData {
53 pub fn new() -> Self {
54 Self {
55 discriminator: [31, 162, 228, 158, 153, 160, 198, 182],
56 }
57 }
58}
59
60impl Default for TammNoopInstructionData {
61 fn default() -> Self {
62 Self::new()
63 }
64}
65
66#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
67#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
68pub struct TammNoopInstructionArgs {
69 pub event: TAmmEvent,
70}
71
72#[derive(Clone, Debug, Default)]
78pub struct TammNoopBuilder {
79 pool: Option<solana_program::pubkey::Pubkey>,
80 event: Option<TAmmEvent>,
81 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
82}
83
84impl TammNoopBuilder {
85 pub fn new() -> Self {
86 Self::default()
87 }
88 #[inline(always)]
89 pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
90 self.pool = Some(pool);
91 self
92 }
93 #[inline(always)]
94 pub fn event(&mut self, event: TAmmEvent) -> &mut Self {
95 self.event = Some(event);
96 self
97 }
98 #[inline(always)]
100 pub fn add_remaining_account(
101 &mut self,
102 account: solana_program::instruction::AccountMeta,
103 ) -> &mut Self {
104 self.__remaining_accounts.push(account);
105 self
106 }
107 #[inline(always)]
109 pub fn add_remaining_accounts(
110 &mut self,
111 accounts: &[solana_program::instruction::AccountMeta],
112 ) -> &mut Self {
113 self.__remaining_accounts.extend_from_slice(accounts);
114 self
115 }
116 #[allow(clippy::clone_on_copy)]
117 pub fn instruction(&self) -> solana_program::instruction::Instruction {
118 let accounts = TammNoop {
119 pool: self.pool.expect("pool is not set"),
120 };
121 let args = TammNoopInstructionArgs {
122 event: self.event.clone().expect("event is not set"),
123 };
124
125 accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
126 }
127}
128
129pub struct TammNoopCpiAccounts<'a, 'b> {
131 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
132}
133
134pub struct TammNoopCpi<'a, 'b> {
136 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
138
139 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
140 pub __args: TammNoopInstructionArgs,
142}
143
144impl<'a, 'b> TammNoopCpi<'a, 'b> {
145 pub fn new(
146 program: &'b solana_program::account_info::AccountInfo<'a>,
147 accounts: TammNoopCpiAccounts<'a, 'b>,
148 args: TammNoopInstructionArgs,
149 ) -> Self {
150 Self {
151 __program: program,
152 pool: accounts.pool,
153 __args: args,
154 }
155 }
156 #[inline(always)]
157 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
158 self.invoke_signed_with_remaining_accounts(&[], &[])
159 }
160 #[inline(always)]
161 pub fn invoke_with_remaining_accounts(
162 &self,
163 remaining_accounts: &[(
164 &'b solana_program::account_info::AccountInfo<'a>,
165 bool,
166 bool,
167 )],
168 ) -> solana_program::entrypoint::ProgramResult {
169 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
170 }
171 #[inline(always)]
172 pub fn invoke_signed(
173 &self,
174 signers_seeds: &[&[&[u8]]],
175 ) -> solana_program::entrypoint::ProgramResult {
176 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
177 }
178 #[allow(clippy::clone_on_copy)]
179 #[allow(clippy::vec_init_then_push)]
180 pub fn invoke_signed_with_remaining_accounts(
181 &self,
182 signers_seeds: &[&[&[u8]]],
183 remaining_accounts: &[(
184 &'b solana_program::account_info::AccountInfo<'a>,
185 bool,
186 bool,
187 )],
188 ) -> solana_program::entrypoint::ProgramResult {
189 let mut accounts = Vec::with_capacity(1 + remaining_accounts.len());
190 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
191 *self.pool.key,
192 false,
193 ));
194 remaining_accounts.iter().for_each(|remaining_account| {
195 accounts.push(solana_program::instruction::AccountMeta {
196 pubkey: *remaining_account.0.key,
197 is_signer: remaining_account.1,
198 is_writable: remaining_account.2,
199 })
200 });
201 let mut data = TammNoopInstructionData::new().try_to_vec().unwrap();
202 let mut args = self.__args.try_to_vec().unwrap();
203 data.append(&mut args);
204
205 let instruction = solana_program::instruction::Instruction {
206 program_id: crate::TENSOR_AMM_ID,
207 accounts,
208 data,
209 };
210 let mut account_infos = Vec::with_capacity(2 + remaining_accounts.len());
211 account_infos.push(self.__program.clone());
212 account_infos.push(self.pool.clone());
213 remaining_accounts
214 .iter()
215 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
216
217 if signers_seeds.is_empty() {
218 solana_program::program::invoke(&instruction, &account_infos)
219 } else {
220 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
221 }
222 }
223}
224
225#[derive(Clone, Debug)]
231pub struct TammNoopCpiBuilder<'a, 'b> {
232 instruction: Box<TammNoopCpiBuilderInstruction<'a, 'b>>,
233}
234
235impl<'a, 'b> TammNoopCpiBuilder<'a, 'b> {
236 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
237 let instruction = Box::new(TammNoopCpiBuilderInstruction {
238 __program: program,
239 pool: None,
240 event: None,
241 __remaining_accounts: Vec::new(),
242 });
243 Self { instruction }
244 }
245 #[inline(always)]
246 pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
247 self.instruction.pool = Some(pool);
248 self
249 }
250 #[inline(always)]
251 pub fn event(&mut self, event: TAmmEvent) -> &mut Self {
252 self.instruction.event = Some(event);
253 self
254 }
255 #[inline(always)]
257 pub fn add_remaining_account(
258 &mut self,
259 account: &'b solana_program::account_info::AccountInfo<'a>,
260 is_writable: bool,
261 is_signer: bool,
262 ) -> &mut Self {
263 self.instruction
264 .__remaining_accounts
265 .push((account, is_writable, is_signer));
266 self
267 }
268 #[inline(always)]
273 pub fn add_remaining_accounts(
274 &mut self,
275 accounts: &[(
276 &'b solana_program::account_info::AccountInfo<'a>,
277 bool,
278 bool,
279 )],
280 ) -> &mut Self {
281 self.instruction
282 .__remaining_accounts
283 .extend_from_slice(accounts);
284 self
285 }
286 #[inline(always)]
287 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
288 self.invoke_signed(&[])
289 }
290 #[allow(clippy::clone_on_copy)]
291 #[allow(clippy::vec_init_then_push)]
292 pub fn invoke_signed(
293 &self,
294 signers_seeds: &[&[&[u8]]],
295 ) -> solana_program::entrypoint::ProgramResult {
296 let args = TammNoopInstructionArgs {
297 event: self.instruction.event.clone().expect("event is not set"),
298 };
299 let instruction = TammNoopCpi {
300 __program: self.instruction.__program,
301
302 pool: self.instruction.pool.expect("pool is not set"),
303 __args: args,
304 };
305 instruction.invoke_signed_with_remaining_accounts(
306 signers_seeds,
307 &self.instruction.__remaining_accounts,
308 )
309 }
310}
311
312#[derive(Clone, Debug)]
313struct TammNoopCpiBuilderInstruction<'a, 'b> {
314 __program: &'b solana_program::account_info::AccountInfo<'a>,
315 pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
316 event: Option<TAmmEvent>,
317 __remaining_accounts: Vec<(
319 &'b solana_program::account_info::AccountInfo<'a>,
320 bool,
321 bool,
322 )>,
323}