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