perpl_cli/args.rs
1use alloy::primitives::{Address, TxHash};
2use clap::{Parser, Subcommand};
3use perpl_sdk::types;
4
5pub(crate) const DEFAULT_MAINNET_RPC_PROVIDER: &str = "https://rpc.monad.xyz";
6pub(crate) const DEFAULT_TESTNET_RPC_PROVIDER: &str = "https://testnet-rpc.monad.xyz";
7pub(crate) const DEFAULT_RPC_THROTTLING: u32 = 15;
8
9#[derive(Parser, Debug)]
10#[command(name = "perpl-cli", version, about, long_about = None)]
11pub struct Cli {
12 #[command(subcommand)]
13 pub command: Commands,
14
15 /// RPC endpoint to connect to [default: https://rpc.monad.xyz for mainnet, https://testnet-rpc.monad.xyz for testnet]
16 #[arg(long, global = true)]
17 pub rpc: Option<String>,
18
19 /// Use testnet provider and contract addresses [default: false = mainnet]
20 #[arg(long, global = true)]
21 pub testnet: bool,
22
23 /// RPC throttling (req/sec) [default: 15 for default RPC providers and
24 /// none for custom]
25 #[arg(long, global = true)]
26 pub rpc_throttle: Option<u32>,
27
28 /// Exchange smart contract address [default: mainnet/testnet smart
29 /// contracts]
30 #[arg(long, global = true)]
31 pub exchange: Option<Address>,
32
33 /// Block number to fetch state at or start tracing from [default: latest
34 /// block]
35 #[arg(long, global = true)]
36 pub block: Option<u64>,
37
38 /// Number of blocks to trace or show [default: unlimited, until terminated
39 /// by (Ctrl+C)]
40 #[arg(long, global = true)]
41 pub num_blocks: Option<u64>,
42
43 /// Account addresses or ID to snaphot/trace/show [default: all accounts for
44 /// `snapshot`/`trace`, required for `show account`]
45 #[arg(long, global = true)]
46 pub account: Vec<types::AccountAddressOrID>,
47
48 /// Perpetual ID to show state/trace for [default: all perpetuals
49 /// for `snapshot`/`trace`/`show trades`, required for `show book`]
50 #[arg(long, global = true)]
51 pub perp: Vec<types::PerpetualId>,
52}
53
54#[derive(Subcommand, Debug)]
55pub enum Commands {
56 /// Trace raw events from a particular block
57 Block {
58 /// Block number to trace
59 block_number: u64,
60 },
61 /// Show live state of account, perpetual order book or recent trades
62 Show {
63 #[command(subcommand)]
64 command: ShowCommands,
65 },
66 /// Take a snapshot of exchange state at a particular block height
67 Snapshot,
68 /// Take an initial snapshot, then trace all events, then print the final
69 /// state
70 Trace,
71 /// Trace raw events from a particular transaction
72 Tx {
73 /// Transaction hash to trace
74 tx_hash: TxHash,
75 },
76}
77
78#[derive(Subcommand, Debug)]
79pub enum ShowCommands {
80 /// Show account state
81 Account {
82 /// Number of most recent trades to show (0 = don't show trades)
83 #[arg(long, default_value_t = 10)]
84 num_trades: usize,
85 },
86 /// Show state of perpetual order book
87 Book {
88 /// Number of price levels to display (0 = all)
89 #[arg(short, long, default_value_t = 10)]
90 depth: usize,
91
92 /// Maximum orders to show per level (0 = all)
93 #[arg(long, default_value_t = 10)]
94 orders_per_level: usize,
95
96 /// Whether to show expired orders
97 #[arg(long, default_value_t = false)]
98 show_expired: bool,
99 },
100 /// Show recent trades
101 Trades,
102}