pub mod buy {
use borsh::{BorshDeserialize, BorshSerialize};
use solana_sdk::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
};
pub const DISCRIMINATOR: [u8; 8] = [102, 6, 61, 18, 1, 218, 235, 234];
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
pub struct Args {
pub amount: u64,
pub max_sol_cost: u64,
}
#[derive(Debug, Clone, Copy)]
pub struct Accounts {
pub global: Pubkey,
pub fee_recipient: Pubkey,
pub mint: Pubkey,
pub bonding_curve: Pubkey,
pub associated_bonding_curve: Pubkey,
pub associated_user: Pubkey,
pub user: Pubkey,
pub system_program: Pubkey,
pub token_program: Pubkey,
pub rent: Pubkey,
pub event_authority: Pubkey,
pub program: Pubkey,
}
pub fn build_ix(program_id: Pubkey, a: Accounts, args: Args) -> Instruction {
let mut data = Vec::with_capacity(8 + 128);
data.extend_from_slice(&DISCRIMINATOR);
data.extend_from_slice(&borsh::to_vec(&args).expect("borsh serialize"));
let accounts = vec![
AccountMeta::new_readonly(a.global, false),
AccountMeta::new(a.fee_recipient, false),
AccountMeta::new_readonly(a.mint, false),
AccountMeta::new(a.bonding_curve, false),
AccountMeta::new(a.associated_bonding_curve, false),
AccountMeta::new(a.associated_user, false),
AccountMeta::new(a.user, true),
AccountMeta::new_readonly(a.system_program, false),
AccountMeta::new_readonly(a.token_program, false),
AccountMeta::new_readonly(a.rent, false),
AccountMeta::new_readonly(a.event_authority, false),
AccountMeta::new_readonly(a.program, false),
];
Instruction {
program_id,
accounts,
data,
}
}
}
pub mod sell {
use borsh::{BorshDeserialize, BorshSerialize};
use solana_sdk::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
};
pub const DISCRIMINATOR: [u8; 8] = [51, 230, 133, 164, 1, 127, 131, 173];
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
pub struct Args {
pub amount: u64,
pub min_sol_output: u64,
}
#[derive(Debug, Clone, Copy)]
pub struct Accounts {
pub global: Pubkey,
pub fee_recipient: Pubkey,
pub mint: Pubkey,
pub bonding_curve: Pubkey,
pub associated_bonding_curve: Pubkey,
pub associated_user: Pubkey,
pub user: Pubkey,
pub system_program: Pubkey,
pub associated_token_program: Pubkey,
pub token_program: Pubkey,
pub event_authority: Pubkey,
pub program: Pubkey,
}
pub fn build_ix(program_id: Pubkey, a: Accounts, args: Args) -> Instruction {
let mut data = Vec::with_capacity(8 + 128);
data.extend_from_slice(&DISCRIMINATOR);
data.extend_from_slice(&borsh::to_vec(&args).expect("borsh serialize"));
let accounts = vec![
AccountMeta::new_readonly(a.global, false),
AccountMeta::new(a.fee_recipient, false),
AccountMeta::new_readonly(a.mint, false),
AccountMeta::new(a.bonding_curve, false),
AccountMeta::new(a.associated_bonding_curve, false),
AccountMeta::new(a.associated_user, false),
AccountMeta::new(a.user, true),
AccountMeta::new_readonly(a.system_program, false),
AccountMeta::new_readonly(a.associated_token_program, false),
AccountMeta::new_readonly(a.token_program, false),
AccountMeta::new_readonly(a.event_authority, false),
AccountMeta::new_readonly(a.program, false),
];
Instruction {
program_id,
accounts,
data,
}
}
}