Expand description
Market module for peg and order book health analysis.
Fetches level-2 order book data from exchange APIs and runs configurable health checks for stablecoin markets.
§Market Module
Provides peg and order book health analysis for stablecoin markets.
Uses a data-driven architecture: exchange behaviour is described by YAML
venue descriptors (see venues/ directory). A VenueRegistry loads all
descriptors and creates generic ExchangeClient instances at runtime, so
new venues can be added without code changes.
§Supported Venues
Built-in CEX descriptors: Binance, MEXC, Bitget, Gate.io, Bybit, OKX, Coinbase, Kraken, HTX, Crypto.com, and Biconomy. DEX data (Ethereum, Solana) is synthesized from DexScreener liquidity.
§Usage
use scope::market::{VenueRegistry, HealthThresholds, MarketSummary, Pair};
#[tokio::main]
async fn main() -> scope::Result<()> {
let registry = VenueRegistry::load()?; // the synced catalog and the user's venues
let http = scope::http::build(&scope::Config::default())?.client;
let exchange = registry.create_exchange_client_with_http("binance", http)?;
let pair = exchange.venue_symbol(&Pair::parse("USDC"));
let book = exchange.fetch_order_book(&pair).await?;
let summary = MarketSummary::from_order_book(&book, &HealthThresholds::default(), None);
print!("{}", summary.format_text(Some("binance")));
Ok(())
}Re-exports§
pub use crate::metrics as series;pub use configurable_client::ConfigurableExchangeClient;pub use descriptor::VenueDescriptor;pub use exchange::ExchangeClient;pub use fetch::DexAnalyticsSource;pub use fetch::fetch_book_and_volume;pub use fetch::fetch_pattern_trades;pub use fetch::fetch_summary;pub use fetch::fetch_summary_with_trades;pub use fetch::fetch_token_summary;pub use fetch::fetch_token_summary_by_name;Deprecated pub use fetch::fetch_token_summary_by_name_with_http;pub use fetch::most_liquid;pub use orderbook::BookSide;pub use orderbook::BookSource;pub use orderbook::Candle;pub use orderbook::ExecutionEstimate;pub use orderbook::ExecutionSide;pub use orderbook::HealthCheck;pub use orderbook::HealthOverrides;pub use orderbook::HealthThresholds;pub use orderbook::MarketSnapshot;pub use orderbook::MarketSummary;pub use orderbook::OhlcClient;pub use orderbook::OrderBook;pub use orderbook::OrderBookClient;pub use orderbook::OrderBookLevel;pub use orderbook::Ticker;pub use orderbook::TickerClient;pub use orderbook::Trade;pub use orderbook::TradeHistoryClient;pub use orderbook::TradeSide;pub use orderbook::order_book_from_analytics;pub use pair::DEFAULT_PAIR;pub use pair::Pair;pub use registry::VenueRegistry;pub use venue::DexVenue;pub use venue::MarketVenue;pub use venue::VENUE_HELP;pub use venue::VenueKind;pub use venue::VenueListing;
Modules§
- analytics
- DEX analytics utilities.
- assets
- Which token a venue’s symbol is: the asset’s networks and contracts,
from the venue’s coin list (the
assetscapability). - catalog
- The venue catalog: the venue descriptors kept in the repo
(
crates/scope-core/venues/), synced into the scope home byscope venues update. Nothing is compiled in, so a new or fixed venue reaches users without a release. - configurable_
client - Generic exchange client that interprets a
VenueDescriptorat runtime. - descriptor
- Venue descriptor schema for data-driven exchange integration.
- exchange
- ExchangeClient facade: composes OrderBook, Ticker, and TradeHistory capabilities behind a unified interface with capability discovery.
- fetch
- The market summary use case: venue + pair -> order book, 24h volume and
MarketSummary.scope market summary,token-health --with-market,insightsand the web endpoints all call it, so the same input gives the same request everywhere. - health
- Order book health analysis and market summary.
- pair
- Trading pairs: one parser and one display format for every surface.
- patterns
- Bot-pattern signals in a venue’s recent trades and order book, for the market summary’s health advisory.
- registry
- Venue registry: loads and manages venue descriptors.
- traits
- Market client traits for fetching exchange data.
- types
- Core market data types.
- venue
- Market venues: the DEX venues (books built from DexScreener pools) and
the CEX venues of the
VenueRegistry. One parser decides which is which, and one list holds every venue id.
Constants§
- DEFAULT_
VENUE - The default exchange venue: CLI
--venuedefaults, web market requests, insights, and the fallback lookup for a symbol DexScreener does not know.