use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;
use crate::program::SWAP_PROGRAM_ID;
use crate::utils::sighash;
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct CreateFeeTierArgs {
pub tick_spacing: u16,
pub fee_rate: u16,
}
pub fn new_create_fee_tier(
clmm_config: Pubkey,
fee_authority: Pubkey,
tick_spacing: u16,
fee_rate: u16,
fee_tier_pubkey: Pubkey,
payer: Pubkey,
) -> Instruction {
let data = &CreateFeeTierArgs {
tick_spacing,
fee_rate,
};
let mut dsa = data.try_to_vec().unwrap();
let mut distor = sighash::sighash("global", "create_fee_tier").to_vec();
distor.append(&mut dsa);
Instruction {
program_id: SWAP_PROGRAM_ID,
accounts: vec![
AccountMeta::new(payer, true),
AccountMeta::new_readonly(clmm_config, false),
AccountMeta::new(fee_tier_pubkey, false),
AccountMeta::new_readonly(fee_authority, true),
AccountMeta::new_readonly(solana_program::sysvar::rent::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
],
data: distor,
}
}