Read Precompiles
Custom REVM precompiles for reading aggregate market data from the core engine
Read Precompiles
Custom precompiles at addresses 0x0800--0x0807 provide lock-free reads of aggregate market data from the core engine's EngineSnapshot.
Address Map
| Address | Name | Input | Output |
|---|---|---|---|
0x0800 | GetBBO | string instrumentId | (uint256 bidPrice, uint256 bidSize, uint256 askPrice, uint256 askSize) |
0x0801 | GetDepthSnapshot | (string instrumentId, uint256 levels) | (uint256[] bidPrices, uint256[] bidSizes, uint256[] askPrices, uint256[] askSizes) |
0x0802 | GetMidPrice | string instrumentId | uint256 midPrice |
0x0803 | GetLastTrade | string instrumentId | (uint256 price, uint256 size, uint256 timestamp) |
0x0804 | GetOHLCV | (string instrumentId, uint256 interval) | (uint256 open, uint256 high, uint256 low, uint256 close, uint256 volume, uint256 timestamp) |
0x0805 | GetInstrumentConfig | string instrumentId | (uint256 tickSize, uint256 lotSize, string baseAsset, string quoteAsset, uint256 status) |
0x0806 | GetActiveInstruments | (none) | string[] instrumentIds |
0x0807 | GetBridgeStatus | (none) | bool isActive |
Gas Costs
All precompiles cost 1 gas (nominal). The chain runs single-validator with no gas market -- gas exists only to satisfy EVM mechanical requirements.
OlympusReader Contract
The OlympusReader contract is deployed at genesis at address 0x0C00. It provides typed Solidity wrappers around all 8 read precompiles, giving you autocomplete, compile-time types, and direct calls without library linking.
| Address | Contract |
|---|---|
0x0C00 | OlympusReader (deployed at genesis) |
Solidity Usage
Import the OlympusReader interface and call it at 0x0C00:
import {OlympusReader} from "./IOlympusReader.sol";
contract MyStrategy {
OlympusReader constant reader = OlympusReader(address(0x0C00));
function checkSpread(string calldata instrumentId) external view returns (uint256) {
OlympusReader.BBO memory bbo = reader.getBBO(instrumentId);
return bbo.askPrice - bbo.bidPrice;
}
function getMid(string calldata instrumentId) external view returns (uint256) {
return reader.getMidPrice(instrumentId);
}
function lastTradePrice(string calldata instrumentId) external view returns (uint256) {
(uint256 price,,) = reader.getLastTrade(instrumentId);
return price;
}
}Or call precompiles directly via staticcall:
(bool success, bytes memory data) = address(0x0800).staticcall(
abi.encode("AAPL-USD")
);
require(success);
(uint256 bidPrice, uint256 bidSize, uint256 askPrice, uint256 askSize) =
abi.decode(data, (uint256, uint256, uint256, uint256));Data Encoding
All prices and quantities are encoded as uint256 with 18 decimal places (like wei). For example:
- Price
150.50atprice_scale=2(raw15050) becomes150500000000000000000 - Quantity
100shares atqty_scale=0(raw100) becomes100000000000000000000
The GetOHLCV precompile currently returns zeros -- kline snapshot integration is pending.