Skip to main content

MonitorState

Struct MonitorState 

Source
pub struct MonitorState {
Show 56 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 order_book: Option<OrderBook>, pub recent_trades: VecDeque<Trade>, pub dex_pairs: Vec<DexPair>, pub websites: Vec<String>, pub socials: Vec<(String, String)>, pub earliest_pair_created_at: Option<i64>, pub dexscreener_url: Option<String>, 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, pub exchange_ohlc: Vec<OhlcCandle>, pub venue_pair: Option<String>,
}
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).

§order_book: Option<OrderBook>

Synthetic order book generated from DEX pair data.

§recent_trades: VecDeque<Trade>

Recent trades (synthetic from DEX pair data or real from exchange API).

§dex_pairs: Vec<DexPair>

Raw DEX pair data for the exchange view.

§websites: Vec<String>

Token metadata: website URLs.

§socials: Vec<(String, String)>

Token metadata: social links (name, url).

§earliest_pair_created_at: Option<i64>

Earliest pair creation timestamp (for “listed since”).

§dexscreener_url: Option<String>

DexScreener URL for this token.

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

§exchange_ohlc: Vec<OhlcCandle>

Real OHLC candles fetched from an exchange venue. When present, get_ohlc_candles uses these instead of synthetic candles.

§venue_pair: Option<String>

Venue-formatted pair symbol for OHLC queries (e.g., “BTCUSDT”).

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<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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