1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;

use crate::program::PROGRAM_ID;
use crate::utils::sighash;

#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct UpdateConfigProtocolFeeRateArgs {
    pub new_protocol_fee_rate: u16,
}

pub fn new_update_config_protocol_fee_rate(
    clmm_config: &Pubkey,
    new_protocol_fee_rate: &u16,
    payer: Pubkey,
) -> Instruction {
    let data = &UpdateConfigProtocolFeeRateArgs {
        new_protocol_fee_rate: *new_protocol_fee_rate,
    };
    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "update_config_protocol_fee_rate").to_vec();
    distor.append(&mut dsa);

    Instruction {
        program_id: PROGRAM_ID,
        accounts: vec![
            AccountMeta::new(*clmm_config, false),
            AccountMeta::new_readonly(payer, true),
        ],
        data: distor,
    }
}