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
use common::command::ProcessResult;
use common::math::get_sqrt_price_at_tick;

use colored::Colorize;

use solana_client::rpc_client::RpcClient;

use tabled::object::Segment;
use tabled::style::Color;
use tabled::{Alignment, Modify, Panel, Rotate, Style, Table, Tabled};

#[derive(Debug, Tabled)]
pub struct TickPrice {
    tick: i32,
    price: u128,
}

pub fn process(_rpc_client: &RpcClient, tick: i32) -> ProcessResult {
    let price = get_sqrt_price_at_tick(tick);
    let map = TickPrice { tick, price };
    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 Price Info", 0))
        .with(Modify::new(Segment::all()).with(Alignment::center()))
        .to_string())
}