pub struct MonitorState {Show 28 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 error_message: Option<String>,
pub time_period: TimePeriod,
pub chart_mode: ChartMode,
pub start_timestamp: i64,
}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.
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).
start_timestamp: i64Unix timestamp when monitoring started.
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 toggle_chart_mode(&mut self)
pub fn toggle_chart_mode(&mut self)
Toggles between line and candlestick chart modes.
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 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:
- 15m view: 1-minute candles
- 1h view: 5-minute candles
- 6h view: 15-minute candles
- 24h 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.
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 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