crema-cli 0.1.0

Blockchain, Crema for Solana
Documentation
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;

use crate::program::FARMING_MINT_WRAPPER_PROGRAM_ID;
use crate::utils::sighash;

#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct NewRewarder {
    pub annual_rate: u64,
}

pub fn new_rewarder(
    base: Pubkey,
    initial_authority: Pubkey,
    rewarder: Pubkey,
    payer: Pubkey,
    mint_wrapper: Pubkey,
    rewards_token_mint: Pubkey,
    claim_fee_token_account: Pubkey,
    annual_rate: u64
) -> Instruction {
    let data = &NewRewarder {
        annual_rate
    };
    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "new_rewarder_v2").to_vec();

    distor.append(&mut dsa);

    Instruction {
        program_id: FARMING_MINT_WRAPPER_PROGRAM_ID,
        accounts: vec![
            AccountMeta::new_readonly(base, true),
            AccountMeta::new(rewarder, false),
            AccountMeta::new_readonly(initial_authority, false),
            AccountMeta::new(payer, true),
            AccountMeta::new_readonly(solana_program::system_program::id(), false),
            AccountMeta::new_readonly(mint_wrapper, false),
            AccountMeta::new_readonly(rewards_token_mint, false),
            AccountMeta::new_readonly(claim_fee_token_account, false),
        ],
        data: distor,
    }
}