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 CreatePartnerArgs {
    pub partner_fee_claim_authority: Pubkey,
    pub fee_rate: u16,
    pub start_time: u64,
    pub end_time: u64,
    pub name: String,
}

pub fn new_create_partner(
    clmm_config: Pubkey,
    partner_fee_claim_authority: Pubkey,
    fee_rate: u16,
    start_time: u64,
    end_time: u64,
    name: String,
    partner_pubkey: Pubkey,
    base_pubkey: Pubkey,
    payer: Pubkey,
) -> Instruction {
    let data = &CreatePartnerArgs {
        partner_fee_claim_authority,
        fee_rate,
        start_time,
        end_time,
        name,
    };

    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash::sighash("global", "create_partner").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_readonly(payer, true),
            AccountMeta::new_readonly(base_pubkey, true),
            AccountMeta::new(partner_pubkey, false),
            AccountMeta::new_readonly(solana_program::sysvar::rent::id(), false),
            AccountMeta::new_readonly(solana_program::system_program::id(), false),
        ],
        data: distor,
    }
}