1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::str::FromStr;
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::instruction::{AccountMeta, Instruction};
use solana_program::pubkey::Pubkey;
use crate::math::fee::ui_fee_to_lamport_4;
use crate::clmmpool::pair::create_partner::PartnerTemplate;
use crate::program::PROGRAM_ID;
use crate::utils::sighash;
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)]
pub struct CreatePartnerArgs {
pub authority: Pubkey,
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(template: &PartnerTemplate, partner_pubkey: Pubkey, base_pubkey: Pubkey, payer: Pubkey) -> Instruction {
let data = &CreatePartnerArgs {
authority: Pubkey::from_str(template.authority.as_str()).unwrap(),
partner_fee_claim_authority: Pubkey::from_str(template.partner_fee_claim_authority.as_str()).unwrap(),
fee_rate: ui_fee_to_lamport_4(template.fee_rate) as u16,
start_time: template.start_time,
end_time: template.end_time,
name: (*template.name).parse().unwrap(),
};
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: PROGRAM_ID,
accounts: vec![
AccountMeta::new(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,
}
}