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
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;

use common::command::{CliConfig, Parse, ProcessResult};
use common::contract::instructions::initialize_clmm_config::{new_init_clmm_config};
use common::math::fee::ui_fee_to_lamport_4;
use common::program::SWAP_PROGRAM_ID;
use common::utils::send::send_tx;

pub fn process_init_config(
    rpc_client: &RpcClient,
    config: &mut CliConfig,
) -> ProcessResult {
    let protocol_authority = Parse::new("protocol_authority address", true).to_pubkey()?;
    let protocol_fee_claim_authority = Parse::new("protocol_fee_claim_authority address", true).to_pubkey()?;
    let create_pool_authority = Parse::new("create_pool_authority address", true).to_pubkey()?;
    let protocol_fee_rate = Parse::new("protocol_fee_rate with float (0.01 = 1%)", true).to_f64()?;
    Parse::confirm()?;
    let (clmm_config_pubkey, _) = Pubkey::find_program_address(
        &[
            b"clmmconfig",
        ],
        &SWAP_PROGRAM_ID,
    );

    let ixs = [new_init_clmm_config(
        protocol_authority,
        protocol_fee_claim_authority,
        create_pool_authority,
        ui_fee_to_lamport_4(protocol_fee_rate) as u16,
        clmm_config_pubkey,
        config.pubkey().unwrap(),
    )];

    let res = send_tx(rpc_client, config, &ixs)?;

    println!("clmm config key: {}", clmm_config_pubkey.to_string());

    Ok("signers : ".to_owned() + res.to_string().as_str())
}