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 SetAnnualRewards {
    pub new_rate: u64,
}

pub fn new_set_annual_rewards(
    rewarder: Pubkey,
    payer: Pubkey,
    new_rate: u64,
) -> Instruction {
    let data = &SetAnnualRewards {
        new_rate
    };
    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "set_annual_rewards").to_vec();
    distor.append(&mut dsa);

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