clmm-common 0.1.39

Blockchain, Clmm for Solana
Documentation
use crate::contract::state::{config::ClmmConfig, poolmetadata::ClmmpoolMetadata};
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_sdk::pubkey::Pubkey;

use crate::{program::SWAP_PROGRAM_ID, utils::sighash::sighash};

#[derive(BorshDeserialize, BorshSerialize, PartialEq, Debug, Clone)]
pub struct CreateClmmpoolMetadataArgs {
    pub name: String,
    pub uri: String,
}

pub fn build_ix(clmmpool: Pubkey, payer: Pubkey, name: String, uri: String) -> Instruction {
    let data = &CreateClmmpoolMetadataArgs { name, uri };
    let mut dsa = data.try_to_vec().unwrap();
    let mut distor = sighash("global", "create_clmmpool_metadata").to_vec();

    distor.append(&mut dsa);

    Instruction {
        program_id: SWAP_PROGRAM_ID,
        accounts: vec![
            AccountMeta::new(payer, true),
            AccountMeta::new(ClmmConfig::find_address(), false),
            AccountMeta::new(clmmpool, false),
            AccountMeta::new(ClmmpoolMetadata::find_address(&clmmpool), false),
            AccountMeta::new(payer, true),
            AccountMeta::new_readonly(solana_program::sysvar::rent::id(), false),
            AccountMeta::new_readonly(solana_program::system_program::id(), false),
        ],
        data: distor,
    }
}