use crate::types::Side;
use borsh::{BorshDeserialize, BorshSerialize};
pub const INSTANT_CREATE_LIMIT_ORDER_DISCRIMINATOR: [u8; 8] =
[194, 37, 195, 123, 40, 127, 126, 156];
#[derive(Debug)]
pub struct InstantCreateLimitOrder {
pub keeper: solana_program::pubkey::Pubkey,
pub api_keeper: solana_program::pubkey::Pubkey,
pub owner: solana_program::pubkey::Pubkey,
pub funding_account: solana_program::pubkey::Pubkey,
pub perpetuals: solana_program::pubkey::Pubkey,
pub pool: solana_program::pubkey::Pubkey,
pub position: solana_program::pubkey::Pubkey,
pub position_request: solana_program::pubkey::Pubkey,
pub position_request_ata: solana_program::pubkey::Pubkey,
pub custody: solana_program::pubkey::Pubkey,
pub custody_doves_price_account: solana_program::pubkey::Pubkey,
pub custody_pythnet_price_account: solana_program::pubkey::Pubkey,
pub collateral_custody: solana_program::pubkey::Pubkey,
pub input_mint: solana_program::pubkey::Pubkey,
pub referral: Option<solana_program::pubkey::Pubkey>,
pub token_program: solana_program::pubkey::Pubkey,
pub associated_token_program: solana_program::pubkey::Pubkey,
pub system_program: solana_program::pubkey::Pubkey,
pub event_authority: solana_program::pubkey::Pubkey,
pub program: solana_program::pubkey::Pubkey,
}
impl InstantCreateLimitOrder {
pub fn instruction(
&self,
args: InstantCreateLimitOrderInstructionArgs,
) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(
&self,
args: InstantCreateLimitOrderInstructionArgs,
remaining_accounts: &[solana_program::instruction::AccountMeta],
) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(20 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.keeper,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.api_keeper,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.owner, true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.funding_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.perpetuals,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.pool, false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.position,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.position_request,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.position_request_ata,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.custody,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.custody_doves_price_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.custody_pythnet_price_account,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.collateral_custody,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.input_mint,
false,
));
if let Some(referral) = self.referral {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
referral, false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::PERPETUALS_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.associated_token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.system_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.event_authority,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.program,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&InstantCreateLimitOrderInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_program::instruction::Instruction {
program_id: crate::PERPETUALS_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InstantCreateLimitOrderInstructionData {
discriminator: [u8; 8],
}
impl InstantCreateLimitOrderInstructionData {
pub fn new() -> Self {
Self {
discriminator: [194, 37, 195, 123, 40, 127, 126, 156],
}
}
}
impl Default for InstantCreateLimitOrderInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InstantCreateLimitOrderInstructionArgs {
pub size_usd_delta: u64,
pub collateral_token_delta: u64,
pub side: Side,
pub trigger_price: u64,
pub trigger_above_threshold: bool,
pub counter: u64,
pub request_time: i64,
}
#[derive(Clone, Debug, Default)]
pub struct InstantCreateLimitOrderBuilder {
keeper: Option<solana_program::pubkey::Pubkey>,
api_keeper: Option<solana_program::pubkey::Pubkey>,
owner: Option<solana_program::pubkey::Pubkey>,
funding_account: Option<solana_program::pubkey::Pubkey>,
perpetuals: Option<solana_program::pubkey::Pubkey>,
pool: Option<solana_program::pubkey::Pubkey>,
position: Option<solana_program::pubkey::Pubkey>,
position_request: Option<solana_program::pubkey::Pubkey>,
position_request_ata: Option<solana_program::pubkey::Pubkey>,
custody: Option<solana_program::pubkey::Pubkey>,
custody_doves_price_account: Option<solana_program::pubkey::Pubkey>,
custody_pythnet_price_account: Option<solana_program::pubkey::Pubkey>,
collateral_custody: Option<solana_program::pubkey::Pubkey>,
input_mint: Option<solana_program::pubkey::Pubkey>,
referral: Option<solana_program::pubkey::Pubkey>,
token_program: Option<solana_program::pubkey::Pubkey>,
associated_token_program: Option<solana_program::pubkey::Pubkey>,
system_program: Option<solana_program::pubkey::Pubkey>,
event_authority: Option<solana_program::pubkey::Pubkey>,
program: Option<solana_program::pubkey::Pubkey>,
size_usd_delta: Option<u64>,
collateral_token_delta: Option<u64>,
side: Option<Side>,
trigger_price: Option<u64>,
trigger_above_threshold: Option<bool>,
counter: Option<u64>,
request_time: Option<i64>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl InstantCreateLimitOrderBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn keeper(&mut self, keeper: solana_program::pubkey::Pubkey) -> &mut Self {
self.keeper = Some(keeper);
self
}
#[inline(always)]
pub fn api_keeper(&mut self, api_keeper: solana_program::pubkey::Pubkey) -> &mut Self {
self.api_keeper = Some(api_keeper);
self
}
#[inline(always)]
pub fn owner(&mut self, owner: solana_program::pubkey::Pubkey) -> &mut Self {
self.owner = Some(owner);
self
}
#[inline(always)]
pub fn funding_account(
&mut self,
funding_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.funding_account = Some(funding_account);
self
}
#[inline(always)]
pub fn perpetuals(&mut self, perpetuals: solana_program::pubkey::Pubkey) -> &mut Self {
self.perpetuals = Some(perpetuals);
self
}
#[inline(always)]
pub fn pool(&mut self, pool: solana_program::pubkey::Pubkey) -> &mut Self {
self.pool = Some(pool);
self
}
#[inline(always)]
pub fn position(&mut self, position: solana_program::pubkey::Pubkey) -> &mut Self {
self.position = Some(position);
self
}
#[inline(always)]
pub fn position_request(
&mut self,
position_request: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.position_request = Some(position_request);
self
}
#[inline(always)]
pub fn position_request_ata(
&mut self,
position_request_ata: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.position_request_ata = Some(position_request_ata);
self
}
#[inline(always)]
pub fn custody(&mut self, custody: solana_program::pubkey::Pubkey) -> &mut Self {
self.custody = Some(custody);
self
}
#[inline(always)]
pub fn custody_doves_price_account(
&mut self,
custody_doves_price_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.custody_doves_price_account = Some(custody_doves_price_account);
self
}
#[inline(always)]
pub fn custody_pythnet_price_account(
&mut self,
custody_pythnet_price_account: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.custody_pythnet_price_account = Some(custody_pythnet_price_account);
self
}
#[inline(always)]
pub fn collateral_custody(
&mut self,
collateral_custody: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.collateral_custody = Some(collateral_custody);
self
}
#[inline(always)]
pub fn input_mint(&mut self, input_mint: solana_program::pubkey::Pubkey) -> &mut Self {
self.input_mint = Some(input_mint);
self
}
#[inline(always)]
pub fn referral(&mut self, referral: Option<solana_program::pubkey::Pubkey>) -> &mut Self {
self.referral = referral;
self
}
#[inline(always)]
pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn event_authority(
&mut self,
event_authority: solana_program::pubkey::Pubkey,
) -> &mut Self {
self.event_authority = Some(event_authority);
self
}
#[inline(always)]
pub fn program(&mut self, program: solana_program::pubkey::Pubkey) -> &mut Self {
self.program = Some(program);
self
}
#[inline(always)]
pub fn size_usd_delta(&mut self, size_usd_delta: u64) -> &mut Self {
self.size_usd_delta = Some(size_usd_delta);
self
}
#[inline(always)]
pub fn collateral_token_delta(&mut self, collateral_token_delta: u64) -> &mut Self {
self.collateral_token_delta = Some(collateral_token_delta);
self
}
#[inline(always)]
pub fn side(&mut self, side: Side) -> &mut Self {
self.side = Some(side);
self
}
#[inline(always)]
pub fn trigger_price(&mut self, trigger_price: u64) -> &mut Self {
self.trigger_price = Some(trigger_price);
self
}
#[inline(always)]
pub fn trigger_above_threshold(&mut self, trigger_above_threshold: bool) -> &mut Self {
self.trigger_above_threshold = Some(trigger_above_threshold);
self
}
#[inline(always)]
pub fn counter(&mut self, counter: u64) -> &mut Self {
self.counter = Some(counter);
self
}
#[inline(always)]
pub fn request_time(&mut self, request_time: i64) -> &mut Self {
self.request_time = Some(request_time);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: solana_program::instruction::AccountMeta,
) -> &mut Self {
self.__remaining_accounts.push(account);
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[solana_program::instruction::AccountMeta],
) -> &mut Self {
self.__remaining_accounts.extend_from_slice(accounts);
self
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_program::instruction::Instruction {
let accounts = InstantCreateLimitOrder {
keeper: self.keeper.expect("keeper is not set"),
api_keeper: self.api_keeper.expect("api_keeper is not set"),
owner: self.owner.expect("owner is not set"),
funding_account: self.funding_account.expect("funding_account is not set"),
perpetuals: self.perpetuals.expect("perpetuals is not set"),
pool: self.pool.expect("pool is not set"),
position: self.position.expect("position is not set"),
position_request: self.position_request.expect("position_request is not set"),
position_request_ata: self
.position_request_ata
.expect("position_request_ata is not set"),
custody: self.custody.expect("custody is not set"),
custody_doves_price_account: self
.custody_doves_price_account
.expect("custody_doves_price_account is not set"),
custody_pythnet_price_account: self
.custody_pythnet_price_account
.expect("custody_pythnet_price_account is not set"),
collateral_custody: self
.collateral_custody
.expect("collateral_custody is not set"),
input_mint: self.input_mint.expect("input_mint is not set"),
referral: self.referral,
token_program: self.token_program.unwrap_or(solana_program::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
associated_token_program: self
.associated_token_program
.expect("associated_token_program is not set"),
system_program: self
.system_program
.unwrap_or(solana_program::pubkey!("11111111111111111111111111111111")),
event_authority: self.event_authority.expect("event_authority is not set"),
program: self.program.expect("program is not set"),
};
let args = InstantCreateLimitOrderInstructionArgs {
size_usd_delta: self
.size_usd_delta
.clone()
.expect("size_usd_delta is not set"),
collateral_token_delta: self
.collateral_token_delta
.clone()
.expect("collateral_token_delta is not set"),
side: self.side.clone().expect("side is not set"),
trigger_price: self
.trigger_price
.clone()
.expect("trigger_price is not set"),
trigger_above_threshold: self
.trigger_above_threshold
.clone()
.expect("trigger_above_threshold is not set"),
counter: self.counter.clone().expect("counter is not set"),
request_time: self.request_time.clone().expect("request_time is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct InstantCreateLimitOrderCpiAccounts<'a, 'b> {
pub keeper: &'b solana_program::account_info::AccountInfo<'a>,
pub api_keeper: &'b solana_program::account_info::AccountInfo<'a>,
pub owner: &'b solana_program::account_info::AccountInfo<'a>,
pub funding_account: &'b solana_program::account_info::AccountInfo<'a>,
pub perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub position: &'b solana_program::account_info::AccountInfo<'a>,
pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
pub custody: &'b solana_program::account_info::AccountInfo<'a>,
pub custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
pub custody_pythnet_price_account: &'b solana_program::account_info::AccountInfo<'a>,
pub collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
pub input_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub program: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct InstantCreateLimitOrderCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub keeper: &'b solana_program::account_info::AccountInfo<'a>,
pub api_keeper: &'b solana_program::account_info::AccountInfo<'a>,
pub owner: &'b solana_program::account_info::AccountInfo<'a>,
pub funding_account: &'b solana_program::account_info::AccountInfo<'a>,
pub perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
pub pool: &'b solana_program::account_info::AccountInfo<'a>,
pub position: &'b solana_program::account_info::AccountInfo<'a>,
pub position_request: &'b solana_program::account_info::AccountInfo<'a>,
pub position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
pub custody: &'b solana_program::account_info::AccountInfo<'a>,
pub custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
pub custody_pythnet_price_account: &'b solana_program::account_info::AccountInfo<'a>,
pub collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
pub input_mint: &'b solana_program::account_info::AccountInfo<'a>,
pub referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
pub event_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub program: &'b solana_program::account_info::AccountInfo<'a>,
pub __args: InstantCreateLimitOrderInstructionArgs,
}
impl<'a, 'b> InstantCreateLimitOrderCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: InstantCreateLimitOrderCpiAccounts<'a, 'b>,
args: InstantCreateLimitOrderInstructionArgs,
) -> Self {
Self {
__program: program,
keeper: accounts.keeper,
api_keeper: accounts.api_keeper,
owner: accounts.owner,
funding_account: accounts.funding_account,
perpetuals: accounts.perpetuals,
pool: accounts.pool,
position: accounts.position,
position_request: accounts.position_request,
position_request_ata: accounts.position_request_ata,
custody: accounts.custody,
custody_doves_price_account: accounts.custody_doves_price_account,
custody_pythnet_price_account: accounts.custody_pythnet_price_account,
collateral_custody: accounts.collateral_custody,
input_mint: accounts.input_mint,
referral: accounts.referral,
token_program: accounts.token_program,
associated_token_program: accounts.associated_token_program,
system_program: accounts.system_program,
event_authority: accounts.event_authority,
program: accounts.program,
__args: args,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(
&self,
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(20 + remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.keeper.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.api_keeper.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.owner.key,
true,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.funding_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.perpetuals.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.pool.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.position.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.position_request.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.position_request_ata.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.custody.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.custody_doves_price_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.custody_pythnet_price_account.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.collateral_custody.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.input_mint.key,
false,
));
if let Some(referral) = self.referral {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*referral.key,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::PERPETUALS_ID,
false,
));
}
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.associated_token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.system_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.event_authority.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.program.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_program::instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let mut data = borsh::to_vec(&InstantCreateLimitOrderInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
let instruction = solana_program::instruction::Instruction {
program_id: crate::PERPETUALS_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(21 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.keeper.clone());
account_infos.push(self.api_keeper.clone());
account_infos.push(self.owner.clone());
account_infos.push(self.funding_account.clone());
account_infos.push(self.perpetuals.clone());
account_infos.push(self.pool.clone());
account_infos.push(self.position.clone());
account_infos.push(self.position_request.clone());
account_infos.push(self.position_request_ata.clone());
account_infos.push(self.custody.clone());
account_infos.push(self.custody_doves_price_account.clone());
account_infos.push(self.custody_pythnet_price_account.clone());
account_infos.push(self.collateral_custody.clone());
account_infos.push(self.input_mint.clone());
if let Some(referral) = self.referral {
account_infos.push(referral.clone());
}
account_infos.push(self.token_program.clone());
account_infos.push(self.associated_token_program.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.event_authority.clone());
account_infos.push(self.program.clone());
remaining_accounts
.iter()
.for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
if signers_seeds.is_empty() {
solana_program::program::invoke(&instruction, &account_infos)
} else {
solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
#[derive(Clone, Debug)]
pub struct InstantCreateLimitOrderCpiBuilder<'a, 'b> {
instruction: Box<InstantCreateLimitOrderCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> InstantCreateLimitOrderCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(InstantCreateLimitOrderCpiBuilderInstruction {
__program: program,
keeper: None,
api_keeper: None,
owner: None,
funding_account: None,
perpetuals: None,
pool: None,
position: None,
position_request: None,
position_request_ata: None,
custody: None,
custody_doves_price_account: None,
custody_pythnet_price_account: None,
collateral_custody: None,
input_mint: None,
referral: None,
token_program: None,
associated_token_program: None,
system_program: None,
event_authority: None,
program: None,
size_usd_delta: None,
collateral_token_delta: None,
side: None,
trigger_price: None,
trigger_above_threshold: None,
counter: None,
request_time: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn keeper(
&mut self,
keeper: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.keeper = Some(keeper);
self
}
#[inline(always)]
pub fn api_keeper(
&mut self,
api_keeper: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.api_keeper = Some(api_keeper);
self
}
#[inline(always)]
pub fn owner(&mut self, owner: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.owner = Some(owner);
self
}
#[inline(always)]
pub fn funding_account(
&mut self,
funding_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.funding_account = Some(funding_account);
self
}
#[inline(always)]
pub fn perpetuals(
&mut self,
perpetuals: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.perpetuals = Some(perpetuals);
self
}
#[inline(always)]
pub fn pool(&mut self, pool: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.pool = Some(pool);
self
}
#[inline(always)]
pub fn position(
&mut self,
position: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.position = Some(position);
self
}
#[inline(always)]
pub fn position_request(
&mut self,
position_request: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.position_request = Some(position_request);
self
}
#[inline(always)]
pub fn position_request_ata(
&mut self,
position_request_ata: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.position_request_ata = Some(position_request_ata);
self
}
#[inline(always)]
pub fn custody(
&mut self,
custody: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.custody = Some(custody);
self
}
#[inline(always)]
pub fn custody_doves_price_account(
&mut self,
custody_doves_price_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.custody_doves_price_account = Some(custody_doves_price_account);
self
}
#[inline(always)]
pub fn custody_pythnet_price_account(
&mut self,
custody_pythnet_price_account: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.custody_pythnet_price_account = Some(custody_pythnet_price_account);
self
}
#[inline(always)]
pub fn collateral_custody(
&mut self,
collateral_custody: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.collateral_custody = Some(collateral_custody);
self
}
#[inline(always)]
pub fn input_mint(
&mut self,
input_mint: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.input_mint = Some(input_mint);
self
}
#[inline(always)]
pub fn referral(
&mut self,
referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.referral = referral;
self
}
#[inline(always)]
pub fn token_program(
&mut self,
token_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.token_program = Some(token_program);
self
}
#[inline(always)]
pub fn associated_token_program(
&mut self,
associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.associated_token_program = Some(associated_token_program);
self
}
#[inline(always)]
pub fn system_program(
&mut self,
system_program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn event_authority(
&mut self,
event_authority: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.event_authority = Some(event_authority);
self
}
#[inline(always)]
pub fn program(
&mut self,
program: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.program = Some(program);
self
}
#[inline(always)]
pub fn size_usd_delta(&mut self, size_usd_delta: u64) -> &mut Self {
self.instruction.size_usd_delta = Some(size_usd_delta);
self
}
#[inline(always)]
pub fn collateral_token_delta(&mut self, collateral_token_delta: u64) -> &mut Self {
self.instruction.collateral_token_delta = Some(collateral_token_delta);
self
}
#[inline(always)]
pub fn side(&mut self, side: Side) -> &mut Self {
self.instruction.side = Some(side);
self
}
#[inline(always)]
pub fn trigger_price(&mut self, trigger_price: u64) -> &mut Self {
self.instruction.trigger_price = Some(trigger_price);
self
}
#[inline(always)]
pub fn trigger_above_threshold(&mut self, trigger_above_threshold: bool) -> &mut Self {
self.instruction.trigger_above_threshold = Some(trigger_above_threshold);
self
}
#[inline(always)]
pub fn counter(&mut self, counter: u64) -> &mut Self {
self.instruction.counter = Some(counter);
self
}
#[inline(always)]
pub fn request_time(&mut self, request_time: i64) -> &mut Self {
self.instruction.request_time = Some(request_time);
self
}
#[inline(always)]
pub fn add_remaining_account(
&mut self,
account: &'b solana_program::account_info::AccountInfo<'a>,
is_writable: bool,
is_signer: bool,
) -> &mut Self {
self.instruction
.__remaining_accounts
.push((account, is_writable, is_signer));
self
}
#[inline(always)]
pub fn add_remaining_accounts(
&mut self,
accounts: &[(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)],
) -> &mut Self {
self.instruction
.__remaining_accounts
.extend_from_slice(accounts);
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(
&self,
signers_seeds: &[&[&[u8]]],
) -> solana_program::entrypoint::ProgramResult {
let args = InstantCreateLimitOrderInstructionArgs {
size_usd_delta: self
.instruction
.size_usd_delta
.clone()
.expect("size_usd_delta is not set"),
collateral_token_delta: self
.instruction
.collateral_token_delta
.clone()
.expect("collateral_token_delta is not set"),
side: self.instruction.side.clone().expect("side is not set"),
trigger_price: self
.instruction
.trigger_price
.clone()
.expect("trigger_price is not set"),
trigger_above_threshold: self
.instruction
.trigger_above_threshold
.clone()
.expect("trigger_above_threshold is not set"),
counter: self
.instruction
.counter
.clone()
.expect("counter is not set"),
request_time: self
.instruction
.request_time
.clone()
.expect("request_time is not set"),
};
let instruction = InstantCreateLimitOrderCpi {
__program: self.instruction.__program,
keeper: self.instruction.keeper.expect("keeper is not set"),
api_keeper: self.instruction.api_keeper.expect("api_keeper is not set"),
owner: self.instruction.owner.expect("owner is not set"),
funding_account: self
.instruction
.funding_account
.expect("funding_account is not set"),
perpetuals: self.instruction.perpetuals.expect("perpetuals is not set"),
pool: self.instruction.pool.expect("pool is not set"),
position: self.instruction.position.expect("position is not set"),
position_request: self
.instruction
.position_request
.expect("position_request is not set"),
position_request_ata: self
.instruction
.position_request_ata
.expect("position_request_ata is not set"),
custody: self.instruction.custody.expect("custody is not set"),
custody_doves_price_account: self
.instruction
.custody_doves_price_account
.expect("custody_doves_price_account is not set"),
custody_pythnet_price_account: self
.instruction
.custody_pythnet_price_account
.expect("custody_pythnet_price_account is not set"),
collateral_custody: self
.instruction
.collateral_custody
.expect("collateral_custody is not set"),
input_mint: self.instruction.input_mint.expect("input_mint is not set"),
referral: self.instruction.referral,
token_program: self
.instruction
.token_program
.expect("token_program is not set"),
associated_token_program: self
.instruction
.associated_token_program
.expect("associated_token_program is not set"),
system_program: self
.instruction
.system_program
.expect("system_program is not set"),
event_authority: self
.instruction
.event_authority
.expect("event_authority is not set"),
program: self.instruction.program.expect("program is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct InstantCreateLimitOrderCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
api_keeper: Option<&'b solana_program::account_info::AccountInfo<'a>>,
owner: Option<&'b solana_program::account_info::AccountInfo<'a>>,
funding_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
perpetuals: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pool: Option<&'b solana_program::account_info::AccountInfo<'a>>,
position: Option<&'b solana_program::account_info::AccountInfo<'a>>,
position_request: Option<&'b solana_program::account_info::AccountInfo<'a>>,
position_request_ata: Option<&'b solana_program::account_info::AccountInfo<'a>>,
custody: Option<&'b solana_program::account_info::AccountInfo<'a>>,
custody_doves_price_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
custody_pythnet_price_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
collateral_custody: Option<&'b solana_program::account_info::AccountInfo<'a>>,
input_mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
referral: Option<&'b solana_program::account_info::AccountInfo<'a>>,
token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
event_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
size_usd_delta: Option<u64>,
collateral_token_delta: Option<u64>,
side: Option<Side>,
trigger_price: Option<u64>,
trigger_above_threshold: Option<bool>,
counter: Option<u64>,
request_time: Option<i64>,
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
bool,
bool,
)>,
}