Skip to main content

Module block_time

Module block_time 

Source
Expand description

Block time monitoring for dYdX short-term order expiration estimation.

This module provides BlockTimeMonitor, a component that tracks rolling average block times from WebSocket data to enable accurate estimation of short-term order expiration in wall-clock time.

§Overview

dYdX short-term orders expire by block height (typically 20 blocks). Without knowing the actual block time, it’s impossible to estimate when an order will expire in wall-clock time. This monitor captures block timestamps from WebSocket updates and

Structs§

BlockTimeMonitor
Monitors block times and provides estimation utilities for order expiration.

Constants§

DEFAULT_BLOCK_TIME_MS
Default block time in milliseconds (dYdX mainnet ~500ms).
DEFAULT_BLOCK_TIME_WINDOW_SIZE
Default rolling window size for block time averaging.
MIN_SAMPLES_FOR_ESTIMATE
Minimum number of samples required before trusting the rolling average.
MIN_VALID_BLOCK_TIME_MS
Minimum valid block time in milliseconds.