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
use colored::Colorize;
use solana_client::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use tabled::object::Segment;
use tabled::style::Color;
use tabled::{Alignment, Modify, Panel, Rotate, Style, Table, Tabled};
use common::command::ProcessResult;
use common::contract::state::clmmpools::Clmmpool;
use common::program::SWAP_PROGRAM_ID;
#[derive(Debug, Tabled)]
pub struct TickMap {
pre: String,
current: String,
post: String,
}
pub fn process(rpc_client: &RpcClient, array_index: u16, pool: &Pubkey) -> ProcessResult {
let tick_map_address = Clmmpool::get_tick_map_address(pool, SWAP_PROGRAM_ID);
let data = rpc_client.get_account_data(&tick_map_address).unwrap();
println!("address: {}", tick_map_address);
println!("{:?}", data);
let word: usize = array_index as usize / 8 + 8 as usize;
let map = TickMap {
pre: format!("{:08b}", data[word - 1]),
current: format!("{:08b}", data[word]),
post: format!("{:08b}", data[word + 1]),
};
println!("word_index: {}", array_index / 8);
println!("word_bit: {}", array_index % 8);
let color = Color::try_from(" ".cyan().to_string()).unwrap();
Ok(Table::new(vec![map])
.with(Rotate::Bottom)
.with(Rotate::Right)
.with(Style::modern())
.with(color)
.with(Panel("Tick Map Info", 0))
.with(Modify::new(Segment::all()).with(Alignment::center()))
.to_string())
}