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 InitializeRewarderArgs {
    pub rewarder_index: u8,
    pub mint_wrapper: Pubkey,
    pub minter: Pubkey,
}

pub fn new_initialize_rewarder(
    clmm_config: Pubkey,
    clmmpool: Pubkey,
    rewarder_authority: Pubkey,
    rewarder_token_mint: Pubkey,
    rewarder_index: u8,
    mint_wrapper: Pubkey,
    minter: Pubkey,
    payer: Pubkey,
) -> Instruction {
    let data = &InitializeRewarderArgs {
        rewarder_index,
        mint_wrapper,
        minter,
    };

    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "initialize_rewarder").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),
            AccountMeta::new_readonly(rewarder_authority, true),
            AccountMeta::new_readonly(rewarder_token_mint, false),
            AccountMeta::new_readonly(spl_token::id(), false),
            AccountMeta::new_readonly(solana_program::system_program::id(), false),
            AccountMeta::new_readonly(solana_program::sysvar::rent::id(), false),
        ],
        data: distor,
    }
}