Expand description
Semioscan: Blockchain analytics library for EVM chains
Semioscan provides production-grade tools for:
- Gas cost calculation (L1 and L2 chains)
- Price extraction from DEX events
- Block window calculations
- Token event processing
§Domain Organization
types- Strong types for type safetyconfig- Configuration systemgas- Gas calculation domainprice- Price extraction domainblocks- Block window calculationsevents- Event processingprovider- Dynamic provider utilities for runtime chain selectiontransport- Transport layer utilities (rate limiting, etc.)cache- Caching infrastructure (internal)retrieval- Data orchestration (internal)tracing- Observability (internal)
§Preferred imports
The most commonly used types are re-exported at the crate root, so
use semioscan::{GasCostCalculator, PriceCalculator, BlockWindowCalculator};
covers typical usage. Domain-specific items that aren’t part of that facade
live under their public modules — for example a custom price source pulls
PriceSource and PriceSourceError from semioscan::price, and transport
layers come from semioscan::transport.
§Feature flags
Every domain is a Cargo feature, and the default feature enables all of
them — so a default semioscan dependency behaves exactly as before.
Downstream crates that only need part of the library can opt out and pull
in just the domains they use:
# Just block-window calculations, nothing else:
semioscan = { version = "0.14", default-features = false, features = ["blocks"] }Feature dependencies follow the real module dependencies:
blocks,events,transport— standalone domainsgasenablesevents(it decodesTransfer/Approvallogs)price— DEX price extraction (reads on-chain token decimals)providerenablestransportretrievalenableseventsandgas(combined gas/price/balance lookups)wsenablesproviderand adds WebSocket transport (create_ws_provider)
A --no-default-features build with no domains selected compiles the core
configuration, error, and type machinery only.
Re-exports§
pub use config::constants;pub use config::policy::LookupConfig;pub use config::policy::LookupPolicy;pub use config::policy::RpcConfig;pub use config::policy::RpcPolicy;pub use config::policy::ScanConfig;pub use config::policy::ScanPolicy;pub use config::ChainConfig;pub use config::SemioscanConfig;pub use config::SemioscanConfigBuilder;pub use errors::BlockWindowError;pub use errors::EventProcessingError;pub use errors::GasCalculationError;pub use errors::PriceCalculationError;pub use errors::RetrievalError;pub use errors::RpcError;pub use errors::SemioscanError;pub use price::PriceCalculator;pub use price::PriceSource;pub use price::PriceSourceError;pub use price::RawSwapResult;pub use price::SwapData;pub use price::TokenPriceResult;pub use transport::RateLimitLayer;pub use transport::RateLimitService;pub use transport::RetryConfig;pub use transport::RetryLayer;pub use transport::RetryLayerBuilder;pub use transport::RetryService;pub use provider::create_http_provider;pub use provider::create_typed_http_provider;pub use provider::network_type_for_chain;pub use provider::rate_limited_http_provider;pub use provider::simple_http_provider;pub use provider::AnyHttpProvider;pub use provider::ChainAwareProvider;pub use provider::ChainEndpoint;pub use provider::DynProviderBuilder;pub use provider::EthereumHttpProvider;pub use provider::NetworkType;pub use provider::OptimismHttpProvider;pub use provider::PooledProvider;pub use provider::ProviderConfig;pub use provider::ProviderPool;pub use provider::ProviderPoolBuilder;
Modules§
- blob
- EIP-4844 Blob Gas Utilities
- config
- Configuration for semioscan operations
- errors
- Error types for the semioscan library.
- price
- Price extraction from DEX swap events
- provider
- Dynamic provider utilities for runtime chain selection
- transport
- Transport layer utilities for Alloy providers.
Structs§
- Access
Sequence - Monotonic sequence number for deterministic LRU ordering
- Amount
Calculator - Calculator for ERC-20 token transfer amounts
- Amount
Result - Result of transfer amount calculation
- Approval
- ERC-20 Approval event
- Blob
Count - Represents the number of EIP-4844 blobs in a transaction
- Blob
GasAmount - Represents the amount of blob gas consumed by EIP-4844 transactions
- Blob
GasPrice - Blob gas price in wei per unit of blob gas (EIP-4844)
- Block
Count - Represents a count of blocks (not a block number)
- Block
Window Calculator - Calculates and caches daily block windows for blockchain queries
- Cache
Key - Key for caching daily block windows
- Cache
Stats - Statistics about cache performance
- Combined
Calculator - Combined
Data Lookup Attempt - Diagnostic details for one failed tx/receipt lookup attempt.
- Combined
Data Lookup Failure - Structured metadata describing a decoded transfer that could not be fully enriched.
- Combined
Data Result - Aggregated result for combined data retrieval over a block range.
- Combined
Data Retrieval Metadata - Retrieval metadata for combined data calculations.
- Daily
Block Window - Represents an inclusive block range for a specific UTC day on a blockchain
- Disk
Cache - Disk-based cache with file locking, versioning, and TTL support
- Ethereum
Receipt Adapter - Receipt adapter for Ethereum and Ethereum-like chains
- Event
Scanner - Event scanner that fetches logs over a block range with chunking and
rate limiting, skipping any chunk whose
eth_getLogscall fails. - GasAmount
- Amount of gas consumed by a transaction
- GasAnd
Amount ForTx - Data for a single transaction including gas and transferred amount.
- GasBreakdown
- Detailed breakdown of gas costs for a transaction
- GasBreakdown
Builder - Builder for constructing GasBreakdown instances
- GasCache
- In-memory cache for gas cost calculation results
- GasCost
Calculator - GasCost
Result - Result of gas cost calculation over a block range
- GasPrice
- Gas price in wei per unit of gas
- L1Data
Fee - L1 data fee for L2 transactions
- MaxBlock
Range - Maximum block range for RPC queries
- Memory
Cache - In-memory cache with optional TTL and size limits
- NoOp
Cache - A no-operation cache that disables caching entirely
- Normalized
Amount - Token amount normalized by decimals (human-readable)
- Optimism
Receipt Adapter - Receipt adapter for Optimism Stack chains
- Percentage
- Represents a percentage value in the range [0.0, 1.0]
- Timestamp
Millis - Unix timestamp in milliseconds for high-precision cache ordering
- Token
Amount - Raw token amount (not normalized for decimals)
- Token
Decimals - ERC-20 token decimal precision
- Token
Price - Price of one token in USDC (or other stablecoin)
- Token
Set - Represents a set of unique token addresses
- Transaction
Count - Represents a count of blockchain transactions
- Transfer
- ERC-20 Transfer event
- Unix
Timestamp - Unix timestamp in seconds (always UTC)
- UsdValue
- Represents a USD-denominated value for amounts, balances, and prices
- WeiAmount
- Represents an amount of native currency (ETH, MATIC, etc.) in wei
Enums§
- Combined
Data Lookup Pass - Which pass produced a lookup error while enriching a decoded transfer log.
- Combined
Data Lookup Stage - Which follow-up RPC lookup failed while enriching a decoded transfer log.
- Decimal
Precision - Decimal precision for blockchain values
- Event
Type - Type of ERC-20 event for gas calculation
- GasFor
Tx - Gas data for a single transaction
- UsdValue
Error - Errors that can occur when creating a USD value
Constants§
- DEFAULT_
HEAD_ TTL - Default TTL for the memoized chain head shared by
BlockWindowCalculator::block_range_for_timestampsandBlockWindowCalculator::get_daily_window.
Traits§
- Block
Window Cache - Trait for block window cache backends
- Receipt
Adapter - Trait for network-specific receipt handling
Functions§
- batch_
fetch_ balances - Batch fetch token balances for multiple (token, holder) pairs.
- batch_
fetch_ eth_ balances - Batch fetch ETH balances for multiple addresses.
- extract_
transferred_ to_ tokens - Extract tokens transferred to a router contract using default configuration
- extract_
transferred_ to_ tokens_ with_ config - Extract tokens transferred to a router contract with custom configuration
- fetch_
logs_ chunked - Fetch logs in chunks to handle large block ranges.
- get_
token_ decimal_ precision - Get the decimal precision for a specific token on a specific chain. Native tokens (Address::ZERO) use 18 decimals. Most USDC tokens use 6 decimals, but BSC Binance-Peg USDC uses 18 decimals.
- u256_
to_ bigdecimal - Convert U256 to BigDecimal with decimal scaling for database storage. This function properly handles large decimal places (like 18 for ETH) without overflow.
Type Aliases§
- Balance
Error - Error from a failed balance fetch: (token_address, holder_address, error_message)
- Balance
Query - Query for a token balance: (token_address, holder_address)
- Balance
Result - Result of a successful balance fetch: (token_address, holder_address, balance)