clmm-common 0.1.39

Blockchain, Clmm for Solana
Documentation
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 UpdateRewarderEmissionArgs {
    pub rewarder_index: u8,
    pub emissions_per_second: u128,
}

pub fn new_update_rewarder_emission(
    clmm_config: Pubkey,
    clmmpool: Pubkey,
    rewarder_authority: Pubkey,
    rewarder_index: u8,
    emissions_per_second: u128,
) -> Instruction {
    let data = &UpdateRewarderEmissionArgs {
        rewarder_index,
        emissions_per_second,
    };

    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "update_rewarder_emission").to_vec();
    distor.append(&mut dsa);

    Instruction {
        program_id: SWAP_PROGRAM_ID,
        accounts: vec![
            AccountMeta::new_readonly(rewarder_authority, true),
            AccountMeta::new_readonly(clmm_config, false),
            AccountMeta::new(clmmpool, false),
        ],

        data: distor,
    }
}