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

use common::command::{CliConfig, Parse, ProcessResult};
use common::contract::instructions::create_tick_array::new_create_tick_array;
use common::contract::state::TickArray;
use common::utils::send::send_tx;

pub fn process(rpc_client: &RpcClient, config: &CliConfig) -> ProcessResult {
    let clmmpool = Parse::new("clmmpool address", true).to_pubkey()?;
    let array_index = Parse::new("array_index", true).to_u16()?;
    Parse::confirm()?;

    let (tick_array_pubkey, _) =
        TickArray::calculate_tick_array_key(clmmpool.as_ref(), array_index.to_le_bytes().as_ref());

    let ixs = [new_create_tick_array(
        clmmpool,
        array_index,
        tick_array_pubkey,
        config.pubkey().unwrap(),
    )];

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

    println!("tick array key: {}", tick_array_pubkey.to_string());

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