tensor_amm/generated/instructions/
close_expired_pool.rs1use borsh::BorshDeserialize;
9use borsh::BorshSerialize;
10
11pub struct CloseExpiredPool {
13 pub rent_payer: solana_program::pubkey::Pubkey,
15 pub owner: solana_program::pubkey::Pubkey,
18 pub pool: solana_program::pubkey::Pubkey,
20 pub system_program: solana_program::pubkey::Pubkey,
22}
23
24impl CloseExpiredPool {
25 pub fn instruction(&self) -> solana_program::instruction::Instruction {
26 self.instruction_with_remaining_accounts(&[])
27 }
28 #[allow(clippy::vec_init_then_push)]
29 pub fn instruction_with_remaining_accounts(
30 &self,
31 remaining_accounts: &[solana_program::instruction::AccountMeta],
32 ) -> solana_program::instruction::Instruction {
33 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
34 accounts.push(solana_program::instruction::AccountMeta::new(
35 self.rent_payer,
36 false,
37 ));
38 accounts.push(solana_program::instruction::AccountMeta::new(
39 self.owner, false,
40 ));
41 accounts.push(solana_program::instruction::AccountMeta::new(
42 self.pool, false,
43 ));
44 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
45 self.system_program,
46 false,
47 ));
48 accounts.extend_from_slice(remaining_accounts);
49 let data = CloseExpiredPoolInstructionData::new().try_to_vec().unwrap();
50
51 solana_program::instruction::Instruction {
52 program_id: crate::TENSOR_AMM_ID,
53 accounts,
54 data,
55 }
56 }
57}
58
59#[derive(BorshDeserialize, BorshSerialize)]
60pub struct CloseExpiredPoolInstructionData {
61 discriminator: [u8; 8],
62}
63
64impl CloseExpiredPoolInstructionData {
65 pub fn new() -> Self {
66 Self {
67 discriminator: [108, 212, 233, 53, 132, 83, 63, 219],
68 }
69 }
70}
71
72impl Default for CloseExpiredPoolInstructionData {
73 fn default() -> Self {
74 Self::new()
75 }
76}
77
78#[derive(Clone, Debug, Default)]
87pub struct CloseExpiredPoolBuilder {
88 rent_payer: Option<solana_program::pubkey::Pubkey>,
89 owner: Option<solana_program::pubkey::Pubkey>,
90 pool: Option<solana_program::pubkey::Pubkey>,
91 system_program: Option<solana_program::pubkey::Pubkey>,
92 __remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
93}
94
95impl CloseExpiredPoolBuilder {
96 pub fn new() -> Self {
97 Self::default()
98 }
99 #[inline(always)]
101 pub fn rent_payer(&mut self, rent_payer: solana_program::pubkey::Pubkey) -> &mut Self {
102 self.rent_payer = Some(rent_payer);
103 self
104 }
105 #[inline(always)]
108 pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
109 self.owner = Some(owner);
110 self
111 }
112 #[inline(always)]
114 pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
115 self.pool = Some(pool);
116 self
117 }
118 #[inline(always)]
121 pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
122 self.system_program = Some(system_program);
123 self
124 }
125 #[inline(always)]
127 pub fn add_remaining_account(
128 &mut self,
129 account: solana_program::instruction::AccountMeta,
130 ) -> &mut Self {
131 self.__remaining_accounts.push(account);
132 self
133 }
134 #[inline(always)]
136 pub fn add_remaining_accounts(
137 &mut self,
138 accounts: &[solana_program::instruction::AccountMeta],
139 ) -> &mut Self {
140 self.__remaining_accounts.extend_from_slice(accounts);
141 self
142 }
143 #[allow(clippy::clone_on_copy)]
144 pub fn instruction(&self) -> solana_program::instruction::Instruction {
145 let accounts = CloseExpiredPool {
146 rent_payer: self.rent_payer.expect("rent_payer is not set"),
147 owner: self.owner.expect("owner is not set"),
148 pool: self.pool.expect("pool is not set"),
149 system_program: self
150 .system_program
151 .unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
152 };
153
154 accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
155 }
156}
157
158pub struct CloseExpiredPoolCpiAccounts<'a, 'b> {
160 pub rent_payer: &'b solana_program::account_info::AccountInfo<'a>,
162 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
165 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
167 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
169}
170
171pub struct CloseExpiredPoolCpi<'a, 'b> {
173 pub __program: &'b solana_program::account_info::AccountInfo<'a>,
175 pub rent_payer: &'b solana_program::account_info::AccountInfo<'a>,
177 pub owner: &'b solana_program::account_info::AccountInfo<'a>,
180 pub pool: &'b solana_program::account_info::AccountInfo<'a>,
182 pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
184}
185
186impl<'a, 'b> CloseExpiredPoolCpi<'a, 'b> {
187 pub fn new(
188 program: &'b solana_program::account_info::AccountInfo<'a>,
189 accounts: CloseExpiredPoolCpiAccounts<'a, 'b>,
190 ) -> Self {
191 Self {
192 __program: program,
193 rent_payer: accounts.rent_payer,
194 owner: accounts.owner,
195 pool: accounts.pool,
196 system_program: accounts.system_program,
197 }
198 }
199 #[inline(always)]
200 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
201 self.invoke_signed_with_remaining_accounts(&[], &[])
202 }
203 #[inline(always)]
204 pub fn invoke_with_remaining_accounts(
205 &self,
206 remaining_accounts: &[(
207 &'b solana_program::account_info::AccountInfo<'a>,
208 bool,
209 bool,
210 )],
211 ) -> solana_program::entrypoint::ProgramResult {
212 self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
213 }
214 #[inline(always)]
215 pub fn invoke_signed(
216 &self,
217 signers_seeds: &[&[&[u8]]],
218 ) -> solana_program::entrypoint::ProgramResult {
219 self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
220 }
221 #[allow(clippy::clone_on_copy)]
222 #[allow(clippy::vec_init_then_push)]
223 pub fn invoke_signed_with_remaining_accounts(
224 &self,
225 signers_seeds: &[&[&[u8]]],
226 remaining_accounts: &[(
227 &'b solana_program::account_info::AccountInfo<'a>,
228 bool,
229 bool,
230 )],
231 ) -> solana_program::entrypoint::ProgramResult {
232 let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
233 accounts.push(solana_program::instruction::AccountMeta::new(
234 *self.rent_payer.key,
235 false,
236 ));
237 accounts.push(solana_program::instruction::AccountMeta::new(
238 *self.owner.key,
239 false,
240 ));
241 accounts.push(solana_program::instruction::AccountMeta::new(
242 *self.pool.key,
243 false,
244 ));
245 accounts.push(solana_program::instruction::AccountMeta::new_readonly(
246 *self.system_program.key,
247 false,
248 ));
249 remaining_accounts.iter().for_each(|remaining_account| {
250 accounts.push(solana_program::instruction::AccountMeta {
251 pubkey: *remaining_account.0.key,
252 is_signer: remaining_account.1,
253 is_writable: remaining_account.2,
254 })
255 });
256 let data = CloseExpiredPoolInstructionData::new().try_to_vec().unwrap();
257
258 let instruction = solana_program::instruction::Instruction {
259 program_id: crate::TENSOR_AMM_ID,
260 accounts,
261 data,
262 };
263 let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
264 account_infos.push(self.__program.clone());
265 account_infos.push(self.rent_payer.clone());
266 account_infos.push(self.owner.clone());
267 account_infos.push(self.pool.clone());
268 account_infos.push(self.system_program.clone());
269 remaining_accounts
270 .iter()
271 .for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
272
273 if signers_seeds.is_empty() {
274 solana_program::program::invoke(&instruction, &account_infos)
275 } else {
276 solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
277 }
278 }
279}
280
281#[derive(Clone, Debug)]
290pub struct CloseExpiredPoolCpiBuilder<'a, 'b> {
291 instruction: Box<CloseExpiredPoolCpiBuilderInstruction<'a, 'b>>,
292}
293
294impl<'a, 'b> CloseExpiredPoolCpiBuilder<'a, 'b> {
295 pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
296 let instruction = Box::new(CloseExpiredPoolCpiBuilderInstruction {
297 __program: program,
298 rent_payer: None,
299 owner: None,
300 pool: None,
301 system_program: None,
302 __remaining_accounts: Vec::new(),
303 });
304 Self { instruction }
305 }
306 #[inline(always)]
308 pub fn rent_payer(
309 &mut self,
310 rent_payer: &'b solana_program::account_info::AccountInfo<'a>,
311 ) -> &mut Self {
312 self.instruction.rent_payer = Some(rent_payer);
313 self
314 }
315 #[inline(always)]
318 pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
319 self.instruction.owner = Some(owner);
320 self
321 }
322 #[inline(always)]
324 pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
325 self.instruction.pool = Some(pool);
326 self
327 }
328 #[inline(always)]
330 pub fn system_program(
331 &mut self,
332 system_program: &'b solana_program::account_info::AccountInfo<'a>,
333 ) -> &mut Self {
334 self.instruction.system_program = Some(system_program);
335 self
336 }
337 #[inline(always)]
339 pub fn add_remaining_account(
340 &mut self,
341 account: &'b solana_program::account_info::AccountInfo<'a>,
342 is_writable: bool,
343 is_signer: bool,
344 ) -> &mut Self {
345 self.instruction
346 .__remaining_accounts
347 .push((account, is_writable, is_signer));
348 self
349 }
350 #[inline(always)]
355 pub fn add_remaining_accounts(
356 &mut self,
357 accounts: &[(
358 &'b solana_program::account_info::AccountInfo<'a>,
359 bool,
360 bool,
361 )],
362 ) -> &mut Self {
363 self.instruction
364 .__remaining_accounts
365 .extend_from_slice(accounts);
366 self
367 }
368 #[inline(always)]
369 pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
370 self.invoke_signed(&[])
371 }
372 #[allow(clippy::clone_on_copy)]
373 #[allow(clippy::vec_init_then_push)]
374 pub fn invoke_signed(
375 &self,
376 signers_seeds: &[&[&[u8]]],
377 ) -> solana_program::entrypoint::ProgramResult {
378 let instruction = CloseExpiredPoolCpi {
379 __program: self.instruction.__program,
380
381 rent_payer: self.instruction.rent_payer.expect("rent_payer is not set"),
382
383 owner: self.instruction.owner.expect("owner is not set"),
384
385 pool: self.instruction.pool.expect("pool is not set"),
386
387 system_program: self
388 .instruction
389 .system_program
390 .expect("system_program is not set"),
391 };
392 instruction.invoke_signed_with_remaining_accounts(
393 signers_seeds,
394 &self.instruction.__remaining_accounts,
395 )
396 }
397}
398
399#[derive(Clone, Debug)]
400struct CloseExpiredPoolCpiBuilderInstruction<'a, 'b> {
401 __program: &'b solana_program::account_info::AccountInfo<'a>,
402 rent_payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
403 owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
404 pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
405 system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
406 __remaining_accounts: Vec<(
408 &'b solana_program::account_info::AccountInfo<'a>,
409 bool,
410 bool,
411 )>,
412}