Read precompiles provide on-chain, deterministic access to Polyester-derived market state.
They allow smart contracts running on Polyester Chain to synchronously query protocol-defined views of trading data produced by PolyEngine, without relying on external oracles or off-chain publishers.
Read precompiles are a developer-facing interface.
What Read Precompiles Are
A read precompile is a protocol-level function exposed by Polyester Chain that returns a specific, deterministic piece of market state.
These functions are read-only and derive their values from PolyEngine’s execution state.
Read precompiles do not stream data, push updates, or maintain independent state. They expose authoritative snapshots of market conditions that smart contracts can safely rely on.
Why Read Precompiles Exist
Polyester produces rich real-time market data streams for trading, analytics, and user interfaces. These streams are fast, expressive, and ideal for off-chain consumers.
However, smart contracts cannot safely consume off-chain streams.
Smart contracts require:
- Synchronous reads
- Deterministic results
- Consensus-level agreement
- Enforceable correctness
Read precompiles exist to bridge this gap. They make selected aspects of PolyEngine’s execution state available inside the execution environment of the chain, without introducing new trust assumptions.
What Can Be Read
Read precompiles expose protocol-defined, deterministic views of trading state derived from PolyEngine’s execution history.
Examples include:
- Market reference price The current protocol-defined reference price for a market (e.g. BTC/USDT).
- Last executed trade price The most recent finalized execution price for a market.
- Time-weighted average price (TWAP) A protocol-defined average price over a fixed time window.
- Market status flags Indicators such as whether a market is active, halted, or operating under restricted conditions.
These values correspond directly to state already tracked by PolyEngine and return a single, deterministic result during contract execution.
Read precompiles do not expose raw order books, individual orders, account balances, or real-time order-level activity.
For a complete list of available read functions and integration details, see the developer documentation.
Determinism and Trust Boundaries
A critical property of read precompiles is that they do not introduce new trusted actors.
Unlike oracle-style data publishing, read precompiles do not rely on third-party updaters. The data returned by a read precompile is defined by the protocol itself and evaluated consistently by all validators.
This preserves a single trust boundary: the Polyester protocol.
When to Use a Read Precompile
Read precompiles are useful when a decision must be made inside a smart contract, based on Polyester market state.
Examples include:
- Gating on-chain actions based on market conditions
- Coordinating risk logic across protocols
- Validating assumptions about prices or volatility
- Building controllers that reason about off-chain execution outcomes
If a use case does not require on-chain enforcement, market data streams are typically the better tool.
Relationship to PolyEngine
PolyEngine remains the source of truth for trading execution.
Read precompiles expose selected, derived views of PolyEngine’s state to the chain. They do not modify execution behavior, influence matching, or submit trading intent.
Execution flows off-chain. Verification and coordination flow on-chain.