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. Fetches level-2 order book data from exchange APIs (e.g., Biconomy) and runs configurable health checks: peg deviation, spread, bid/ask balance, and minimum depth thresholds.
§Supported Exchanges
- Binance: Spot REST depth API (public, no auth)
- Biconomy: CEX-style REST depth API
- Ethereum DEX: Synthesized from DexScreener liquidity
- Solana DEX: Synthesized from DexScreener liquidity
§Usage
use scope::market::{OrderBookClient, MarketSummary, HealthThresholds};
#[tokio::main]
async fn main() -> scope::Result<()> {
let client = scope::market::BiconomyClient::new("https://api.biconomy.com");
let book = client.fetch_order_book("PUSD_USDT").await?;
let summary = MarketSummary::from_order_book(&book, 1.0, &HealthThresholds::default(), None);
print!("{}", summary.format_text(Some("biconomy")));
Ok(())
}Structs§
- Biconomy
Client - Biconomy exchange order book client.
- Binance
Client - Binance Spot order book client.
- Execution
Estimate - Result of execution simulation for a given notional size.
- Health
Thresholds - Health check thresholds for order book validation.
- Market
Summary - Aggregated market summary with order book snapshot and health results.
- Order
Book - Full order book snapshot with bids and asks.
- Order
Book Level - A single price level in the order book.
Enums§
- Execution
Side - Side of execution (buy = hit asks, sell = hit bids).
- Health
Check - Outcome of a single health check.
- Market
Venue - Supported market venues for order book data.
Traits§
- Order
Book Client - Trait for fetching order book data from exchange APIs.
Functions§
- order_
book_ from_ analytics - Builds a synthetic order book from DEX analytics (used for Ethereum/Solana venues).