Skip to main content

Module market

Module market 

Source
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§

BiconomyClient
Biconomy exchange order book client.
BinanceClient
Binance Spot order book client.
ExecutionEstimate
Result of execution simulation for a given notional size.
HealthThresholds
Health check thresholds for order book validation.
MarketSummary
Aggregated market summary with order book snapshot and health results.
OrderBook
Full order book snapshot with bids and asks.
OrderBookLevel
A single price level in the order book.

Enums§

ExecutionSide
Side of execution (buy = hit asks, sell = hit bids).
HealthCheck
Outcome of a single health check.
MarketVenue
Supported market venues for order book data.

Traits§

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