pub struct MonitorState {Show 47 fields
pub token_address: String,
pub symbol: String,
pub name: String,
pub chain: String,
pub price_history: VecDeque<DataPoint>,
pub volume_history: VecDeque<DataPoint>,
pub real_data_count: usize,
pub current_price: f64,
pub price_change_24h: f64,
pub price_change_6h: f64,
pub price_change_1h: f64,
pub price_change_5m: f64,
pub last_price_change_at: f64,
pub previous_price: f64,
pub buys_24h: u64,
pub sells_24h: u64,
pub liquidity_usd: f64,
pub volume_24h: f64,
pub market_cap: Option<f64>,
pub fdv: Option<f64>,
pub last_update: Instant,
pub refresh_rate: Duration,
pub paused: bool,
pub log_messages: VecDeque<String>,
pub log_list_state: ListState,
pub error_message: Option<String>,
pub time_period: TimePeriod,
pub chart_mode: ChartMode,
pub scale_mode: ScaleMode,
pub color_scheme: ColorScheme,
pub holder_count: Option<u64>,
pub liquidity_pairs: Vec<(String, f64)>,
pub holder_fetch_counter: u32,
pub start_timestamp: i64,
pub layout: LayoutPreset,
pub widgets: WidgetVisibility,
pub auto_layout: bool,
pub widget_toggle_mode: bool,
pub alerts: AlertConfig,
pub active_alerts: Vec<ActiveAlert>,
pub alert_flash_until: Option<Instant>,
pub export_active: bool,
pub export_path: Option<PathBuf>,
pub volume_avg: f64,
pub auto_pause_on_input: bool,
pub last_input_at: Instant,
pub auto_pause_timeout: Duration,
}Expand description
State for the live token monitor.
Fields§
§token_address: StringToken contract address.
symbol: StringToken symbol.
name: StringToken name.
chain: StringBlockchain network.
price_history: VecDeque<DataPoint>Historical price data points with real/synthetic indicator.
volume_history: VecDeque<DataPoint>Historical volume data points with real/synthetic indicator.
real_data_count: usizeCount of real (non-synthetic) data points.
current_price: f64Current price in USD.
price_change_24h: f6424-hour price change percentage.
price_change_6h: f646-hour price change percentage.
price_change_1h: f641-hour price change percentage.
price_change_5m: f645-minute price change percentage.
last_price_change_at: f64Timestamp when the price last changed (Unix timestamp).
previous_price: f64Previous price for change detection.
buys_24h: u64Total buy transactions in 24 hours.
sells_24h: u64Total sell transactions in 24 hours.
liquidity_usd: f64Total liquidity in USD.
volume_24h: f6424-hour volume in USD.
market_cap: Option<f64>Market capitalization.
fdv: Option<f64>Fully diluted valuation.
last_update: InstantLast update timestamp.
refresh_rate: DurationRefresh rate.
paused: boolWhether monitoring is paused.
log_messages: VecDeque<String>Recent log messages.
log_list_state: ListStateScroll state for the activity log list widget.
error_message: Option<String>Error message to display (if any).
time_period: TimePeriodSelected time period for chart display.
chart_mode: ChartModeChart display mode (line or candlestick).
scale_mode: ScaleModeY-axis scale mode for price charts (Linear or Log).
color_scheme: ColorSchemeActive color scheme.
holder_count: Option<u64>Holder count (fetched from chain client, if available).
liquidity_pairs: Vec<(String, f64)>Per-pair liquidity data: (pair_name, liquidity_usd).
holder_fetch_counter: u32Counter to throttle holder count fetches.
start_timestamp: i64Unix timestamp when monitoring started.
layout: LayoutPresetCurrent layout preset.
widgets: WidgetVisibilityWidget visibility toggles.
auto_layout: boolWhether responsive auto-layout is active (disabled by manual layout switch).
widget_toggle_mode: boolWhether the widget-toggle input mode is active (waiting for digit 1-5).
alerts: AlertConfigAlert configuration thresholds.
active_alerts: Vec<ActiveAlert>Currently firing alerts.
alert_flash_until: Option<Instant>Visual flash timer for alert overlay.
export_active: boolWhether CSV export is currently active.
export_path: Option<PathBuf>Path to the current export file.
volume_avg: f64Rolling volume average for spike detection (simple moving average).
auto_pause_on_input: boolWhether auto-pause on user input is enabled.
last_input_at: InstantTimestamp of the last user key input.
auto_pause_timeout: DurationDuration after last input before auto-pause lifts (default 3s).
Implementations§
Source§impl MonitorState
impl MonitorState
Sourcepub fn new(token_data: &DexTokenData, chain: &str) -> Self
pub fn new(token_data: &DexTokenData, chain: &str) -> Self
Creates a new monitor state from initial token data. Attempts to load cached data from disk first.
Sourcepub fn apply_config(&mut self, config: &MonitorConfig)
pub fn apply_config(&mut self, config: &MonitorConfig)
Applies monitor config settings to this state.
Sourcepub fn palette(&self) -> ColorPalette
pub fn palette(&self) -> ColorPalette
Toggles between line and candlestick chart modes. Returns the current color palette based on the active color scheme.
pub fn toggle_chart_mode(&mut self)
Sourcepub fn save_cache(&self)
pub fn save_cache(&self)
Saves monitor data to cache file.
Sourcepub fn update(&mut self, token_data: &DexTokenData)
pub fn update(&mut self, token_data: &DexTokenData)
Updates the state with new token data. New data points are marked as real (is_real = true).
Sourcepub fn start_export(&mut self)
pub fn start_export(&mut self)
Starts CSV export: creates the file and writes the header.
Sourcepub fn stop_export(&mut self)
pub fn stop_export(&mut self)
Stops CSV export and closes the file.
Sourcepub fn toggle_export(&mut self)
pub fn toggle_export(&mut self)
Toggles CSV export on/off.
Sourcepub fn get_price_data_for_period(&self) -> (Vec<(f64, f64)>, Vec<bool>)
pub fn get_price_data_for_period(&self) -> (Vec<(f64, f64)>, Vec<bool>)
Returns data points filtered by the current time period. Returns tuples for chart compatibility, plus a separate vector of is_real flags.
Sourcepub fn get_volume_data_for_period(&self) -> (Vec<(f64, f64)>, Vec<bool>)
pub fn get_volume_data_for_period(&self) -> (Vec<(f64, f64)>, Vec<bool>)
Returns volume data filtered by the current time period. Returns tuples for chart compatibility, plus a separate vector of is_real flags.
Sourcepub fn data_stats(&self) -> (usize, usize)
pub fn data_stats(&self) -> (usize, usize)
Returns count of synthetic vs real data points in the current view.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Estimates memory usage of stored data in bytes.
Sourcepub fn get_ohlc_candles(&self) -> Vec<OhlcCandle>
pub fn get_ohlc_candles(&self) -> Vec<OhlcCandle>
Generates OHLC candles from price history for the current time period.
The candle duration is automatically determined based on the selected time period:
- 1m view: 5-second candles
- 5m view: 15-second candles
- 15m view: 1-minute candles
- 1h view: 5-minute candles
- 4h view: 15-minute candles
- 1d view: 1-hour candles
Sourcepub fn cycle_time_period(&mut self)
pub fn cycle_time_period(&mut self)
Cycles to the next time period.
Sourcepub fn set_time_period(&mut self, period: TimePeriod)
pub fn set_time_period(&mut self, period: TimePeriod)
Sets a specific time period.
Sourcepub fn should_refresh(&self) -> bool
pub fn should_refresh(&self) -> bool
Returns whether a refresh is needed. Respects manual pause, auto-pause on input, and the refresh interval.
Sourcepub fn is_auto_paused(&self) -> bool
pub fn is_auto_paused(&self) -> bool
Returns true if auto-pause is currently suppressing refreshes.
Sourcepub fn toggle_pause(&mut self)
pub fn toggle_pause(&mut self)
Toggles pause state.
Sourcepub fn force_refresh(&mut self)
pub fn force_refresh(&mut self)
Forces an immediate refresh.
Sourcepub fn slower_refresh(&mut self)
pub fn slower_refresh(&mut self)
Increases refresh interval (slower updates).
Sourcepub fn faster_refresh(&mut self)
pub fn faster_refresh(&mut self)
Decreases refresh interval (faster updates).
Sourcepub fn scroll_log_down(&mut self)
pub fn scroll_log_down(&mut self)
Scrolls the activity log down (newer messages).
Sourcepub fn scroll_log_up(&mut self)
pub fn scroll_log_up(&mut self)
Scrolls the activity log up (older messages).
Sourcepub fn refresh_rate_secs(&self) -> u64
pub fn refresh_rate_secs(&self) -> u64
Returns the current refresh rate in seconds.
Auto Trait Implementations§
impl Freeze for MonitorState
impl RefUnwindSafe for MonitorState
impl Send for MonitorState
impl Sync for MonitorState
impl Unpin for MonitorState
impl UnwindSafe for MonitorState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more