|
1 | 1 | use std::collections::BTreeMap; |
| 2 | +use std::mem::size_of; |
2 | 3 |
|
3 | 4 | use colored::Colorize; |
4 | | -use phoenix::program::get_vault_address; |
5 | 5 | use phoenix::program::status::MarketStatus; |
6 | 6 | use phoenix::program::MarketHeader; |
| 7 | +use phoenix::program::{get_vault_address, load_with_dispatch}; |
| 8 | +use phoenix::quantities::WrapperU64; |
7 | 9 | use phoenix::state::{markets::Ladder, Side, TraderState}; |
8 | 10 | use phoenix_sdk::sdk_client::*; |
9 | 11 | use solana_sdk::program_pack::Pack; |
@@ -123,6 +125,16 @@ pub async fn print_market_details( |
123 | 125 |
|
124 | 126 | let quote_vault_acct = |
125 | 127 | spl_token::state::Account::unpack(&sdk.client.get_account("e_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 | + |
126 | 138 | println!("--------------------------------------------"); |
127 | 139 | println!("Market: {}", market_pubkey); |
128 | 140 | println!("Status: {}", MarketStatus::from(market_header.status)); |
@@ -171,6 +183,22 @@ pub async fn print_market_details( |
171 | 183 | ); |
172 | 184 | println!("Market Size Params: {:?}", market_header.market_size_params); |
173 | 185 | 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 | + |
174 | 202 | Ok(()) |
175 | 203 | } |
176 | 204 |
|
|
0 commit comments