Skip to main content

MonitorState

Struct MonitorState 

Source
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: String

Token contract address.

§symbol: String

Token symbol.

§name: String

Token name.

§chain: String

Blockchain 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: usize

Count of real (non-synthetic) data points.

§current_price: f64

Current price in USD.

§price_change_24h: f64

24-hour price change percentage.

§price_change_6h: f64

6-hour price change percentage.

§price_change_1h: f64

1-hour price change percentage.

§price_change_5m: f64

5-minute price change percentage.

§last_price_change_at: f64

Timestamp when the price last changed (Unix timestamp).

§previous_price: f64

Previous price for change detection.

§buys_24h: u64

Total buy transactions in 24 hours.

§sells_24h: u64

Total sell transactions in 24 hours.

§liquidity_usd: f64

Total liquidity in USD.

§volume_24h: f64

24-hour volume in USD.

§market_cap: Option<f64>

Market capitalization.

§fdv: Option<f64>

Fully diluted valuation.

§last_update: Instant

Last update timestamp.

§refresh_rate: Duration

Refresh rate.

§paused: bool

Whether monitoring is paused.

§log_messages: VecDeque<String>

Recent log messages.

§log_list_state: ListState

Scroll state for the activity log list widget.

§error_message: Option<String>

Error message to display (if any).

§time_period: TimePeriod

Selected time period for chart display.

§chart_mode: ChartMode

Chart display mode (line or candlestick).

§scale_mode: ScaleMode

Y-axis scale mode for price charts (Linear or Log).

§color_scheme: ColorScheme

Active 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: u32

Counter to throttle holder count fetches.

§start_timestamp: i64

Unix timestamp when monitoring started.

§layout: LayoutPreset

Current layout preset.

§widgets: WidgetVisibility

Widget visibility toggles.

§auto_layout: bool

Whether responsive auto-layout is active (disabled by manual layout switch).

§widget_toggle_mode: bool

Whether the widget-toggle input mode is active (waiting for digit 1-5).

§alerts: AlertConfig

Alert configuration thresholds.

§active_alerts: Vec<ActiveAlert>

Currently firing alerts.

§alert_flash_until: Option<Instant>

Visual flash timer for alert overlay.

§export_active: bool

Whether CSV export is currently active.

§export_path: Option<PathBuf>

Path to the current export file.

§volume_avg: f64

Rolling volume average for spike detection (simple moving average).

§auto_pause_on_input: bool

Whether auto-pause on user input is enabled.

§last_input_at: Instant

Timestamp of the last user key input.

§auto_pause_timeout: Duration

Duration after last input before auto-pause lifts (default 3s).

Implementations§

Source§

impl MonitorState

Source

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.

Source

pub fn apply_config(&mut self, config: &MonitorConfig)

Applies monitor config settings to this state.

Source

pub fn palette(&self) -> ColorPalette

Toggles between line and candlestick chart modes. Returns the current color palette based on the active color scheme.

Source

pub fn toggle_chart_mode(&mut self)

Source

pub fn save_cache(&self)

Saves monitor data to cache file.

Source

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).

Source

pub fn start_export(&mut self)

Starts CSV export: creates the file and writes the header.

Source

pub fn stop_export(&mut self)

Stops CSV export and closes the file.

Source

pub fn toggle_export(&mut self)

Toggles CSV export on/off.

Source

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.

Source

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.

Source

pub fn data_stats(&self) -> (usize, usize)

Returns count of synthetic vs real data points in the current view.

Source

pub fn memory_usage(&self) -> usize

Estimates memory usage of stored data in bytes.

Source

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
Source

pub fn cycle_time_period(&mut self)

Cycles to the next time period.

Source

pub fn set_time_period(&mut self, period: TimePeriod)

Sets a specific time period.

Source

pub fn should_refresh(&self) -> bool

Returns whether a refresh is needed. Respects manual pause, auto-pause on input, and the refresh interval.

Source

pub fn is_auto_paused(&self) -> bool

Returns true if auto-pause is currently suppressing refreshes.

Source

pub fn toggle_pause(&mut self)

Toggles pause state.

Source

pub fn force_refresh(&mut self)

Forces an immediate refresh.

Source

pub fn slower_refresh(&mut self)

Increases refresh interval (slower updates).

Source

pub fn faster_refresh(&mut self)

Decreases refresh interval (faster updates).

Source

pub fn scroll_log_down(&mut self)

Scrolls the activity log down (newer messages).

Source

pub fn scroll_log_up(&mut self)

Scrolls the activity log up (older messages).

Source

pub fn refresh_rate_secs(&self) -> u64

Returns the current refresh rate in seconds.

Source

pub fn buy_ratio(&self) -> f64

Returns the buy/sell ratio as a percentage (0.0 to 1.0).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more