Skip to content

Commit b5f8a3a

Browse files
authored
get-market should also print current market authority (#20)
* get-market should also print current market authority * bump version correctly * print quote fees * remove extra print
1 parent beeea31 commit b5f8a3a

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "phoenix-cli"
3-
version = "0.1.1"
3+
version = "0.1.7"
44
description = "CLI and associated library for interacting with the Phoenix program from the command line"
55
edition = "2021"
66
license = "MIT"
@@ -36,4 +36,4 @@ spl-associated-token-account = { version = "1.1.1", features = [ "no-entrypoint"
3636
phoenix-v1 = "0.1.1"
3737
phoenix-sdk = { version = "0.1.0" }
3838
bytemuck = "1.13.0"
39-
reqwest = "0.11.14"
39+
reqwest = "0.11.14"

src/lib/helpers/print_helpers.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use std::collections::BTreeMap;
2+
use std::mem::size_of;
23

34
use colored::Colorize;
4-
use phoenix::program::get_vault_address;
55
use phoenix::program::status::MarketStatus;
66
use phoenix::program::MarketHeader;
7+
use phoenix::program::{get_vault_address, load_with_dispatch};
8+
use phoenix::quantities::WrapperU64;
79
use phoenix::state::{markets::Ladder, Side, TraderState};
810
use phoenix_sdk::sdk_client::*;
911
use solana_sdk::program_pack::Pack;
@@ -123,6 +125,16 @@ pub async fn print_market_details(
123125

124126
let quote_vault_acct =
125127
spl_token::state::Account::unpack(&sdk.client.get_account(&quote_vault).await?.data)?;
128+
129+
// Get market account
130+
let mut market_account_data = sdk.client.get_account_data(market_pubkey).await?;
131+
let (header_bytes, market_bytes) = market_account_data.split_at_mut(size_of::<MarketHeader>());
132+
let header: &MarketHeader = bytemuck::try_from_bytes(header_bytes)
133+
.map_err(|e| anyhow::anyhow!("Error getting market header. Error: {:?}", e))?;
134+
135+
// Derserialize data and load into correct type
136+
let market = load_with_dispatch(&header.market_size_params, market_bytes)?.inner;
137+
126138
println!("--------------------------------------------");
127139
println!("Market: {}", market_pubkey);
128140
println!("Status: {}", MarketStatus::from(market_header.status));
@@ -171,6 +183,22 @@ pub async fn print_market_details(
171183
);
172184
println!("Market Size Params: {:?}", market_header.market_size_params);
173185
println!("Successor pubkey: {:?}", market_header.successor);
186+
187+
println!(
188+
"Uncollected fees, in quote units: {}",
189+
get_decimal_string(
190+
sdk.quote_lots_to_quote_atoms(market.get_uncollected_fee_amount().as_u64()),
191+
market_metadata.quote_decimals
192+
)
193+
);
194+
println!(
195+
"Collected fees, in quote units: {}",
196+
get_decimal_string(
197+
sdk.quote_lots_to_quote_atoms(market.get_collected_fee_amount().as_u64()),
198+
market_metadata.quote_decimals
199+
)
200+
);
201+
174202
Ok(())
175203
}
176204

0 commit comments

Comments
 (0)