clmm-common 0.1.39

Blockchain, Clmm for Solana
Documentation
use borsh::{BorshSerialize, BorshDeserialize};
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 UpdateFeeRateArgs {
    pub new_fee_rate: u16,
}

pub fn new_update_fee_rate(
    clmm_config: &Pubkey,
    new_fee_rate: u16,
    clmmpool: &Pubkey,
    payer: Pubkey,
) -> Instruction {
    let data = &UpdateFeeRateArgs {
        new_fee_rate
    };
    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "update_fee_rate").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(*clmmpool, false),
        ],
        data: distor,
    }
}