Interface
MAOB depends on an oracle adapter implementing:
getPrice(address orderBook) -> (uint256 price, uint256 precision, uint48 updatedAt)
Where:
priceis the raw price value (midpoint)precisionis the scale factor such that:mid = price / precisionupdatedAtis the timestamp of the price update (0 if unavailable)
MAOB calls the adapter with its own address as orderBook.
Requirements enforced by MAOB
From MAOB.sol internal _getMidPrice():
price != 0andprecision != 0or the call reverts withMAOB__OraclePriceMissing()- If
maxStaleSeconds != 0:updatedAtmust be non-zeroblock.timestamp <= updatedAt + maxStaleSeconds- otherwise
MAOB__OracleStale()
- Overflow-safety checks ensure the price, precision, and token scales won’t overflow internal math; otherwise
MAOB__OracleOutOfRange()
Precision and decimals
MAOB supports tokens up to 18 decimals. Internally it computes:
baseScale = 10^baseDecimalsquoteScale = 10^quoteDecimals
The adapter can choose any precision, but it must be consistent and stable for the pair. Common patterns:
precision = 1e18andpriceexpressed as base token/quote token with 18 decimalsprecision = 1e8like many Chainlink feeds (ensure downstream scaling remains safe)
Operational guidance
- Prefer returning a midpoint price for the specific pair MAOB trades (base token/quote token).
- Ensure timestamps advance as the oracle updates; MAOB may be configured with a strict staleness window.
- If your oracle can be paused or degraded, decide whether to return
(0,0,0)to hard-fail trading, or a last-known price with a timestamp (which may still be rejected as stale depending onmaxStaleSeconds).