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
use borsh::BorshDeserialize;
use colored::Colorize;
use solana_client::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use tabled::{Alignment, Modify, Panel, Rotate, Style, Table};
use tabled::object::Segment;
use tabled::style::Color;
use common::command::{ProcessResult};
use common::contract::state::clmmpools::Clmmpool;
pub fn process_pair_info(rpc_client: &RpcClient, pair_key: &Pubkey) -> ProcessResult {
let data = rpc_client.get_account_data(pair_key).unwrap();
let swap_account: Clmmpool = Clmmpool::try_from_slice(&data[8..]).unwrap();
let amount_a = rpc_client.get_token_account_balance(&swap_account.token_a_vault).unwrap().ui_amount.unwrap();
let amount_b = rpc_client.get_token_account_balance(&swap_account.token_b_vault).unwrap().ui_amount.unwrap();
let color = Color::try_from(" ".cyan().to_string()).unwrap();
Ok(Table::new(vec![swap_account])
.with(Rotate::Bottom)
.with(Rotate::Right)
.with(Style::modern())
.with(color)
.with(Panel("Swap Account Info", 0))
.with(Modify::new(Segment::all()).with(Alignment::center()))
.to_string()
+ "\n" +
&Table::builder(
&[
&["amount_a", amount_a.to_string().as_str()],
&["amount_b", amount_b.to_string().as_str()]
]).build()
.with(Style::modern())
.with(Color::try_from(" ".cyan().to_string()).unwrap())
.with(Modify::new(Segment::all()).with(Alignment::center()))
.with(Panel("Pool calculate", 0))
.to_string()
)
}