Oracles & Price Feeds
Oracles provide the real-world price data that enables Mento's stability mechanisms. They feed accurate exchange rates to the protocol, allowing stablecoins to maintain their pegs through arbitrage and fixed-price swaps.
How Mento Oracles Work
Mento uses a decentralized oracle system where multiple independent data providers report prices on-chain. The protocol aggregates these reports to determine reliable exchange rates while protecting against manipulation or faulty data.
The oracle system consists of three main components:
Data Providers: Independent entities that source exchange rates from various markets. Each provider monitors real-world FX rates and cryptocurrency prices.
Oracle Relayers: Services that collect reports from data providers and submit them on-chain. Relayers batch multiple reports together to save gas while ensuring timely price updates.
On-Chain Contracts: Smart contracts that verify reports, aggregate prices, and make them available to the protocol. These contracts maintain sorted lists of prices and timestamps from each oracle provider.
Price Aggregation
When oracle reports arrive on-chain, the protocol doesn't simply use individual prices. Instead, it employs multiple layers of aggregation and validation:
Sorted Lists: Each rate feed maintains sorted linked lists of reported values and their timestamps. This structure enables efficient median calculation and expired report removal.
Median Calculation: The protocol takes the median of all valid reports, reducing the impact of outliers or manipulated values. The median updates automatically as new reports arrive or old ones expire.
Report Expiry: Reports older than the configured expiry time (set per rate feed or using a global default) are considered stale and can be removed, ensuring only fresh data influences prices.
Oracle Providers
Mento integrates with established oracle networks to ensure reliable price feeds:
Chainlink: Industry-standard decentralized oracles with large node networks and proven reliability across DeFi protocols.
RedStone: Fast, gas-efficient oracle infrastructure that enables high-frequency updates with lower costs.
The protocol can integrate additional oracle providers through governance, ensuring no single point of failure in price discovery.
Rate Feed IDs
Rate feed identifiers are the report targets for oracles. They feature in governance proposals mainly for:
Whitelisting oracles to report for a rate feed
Setting reference rates for exchanges
Configuring circuit breakers in the BreakerBox
Quality Assurance
Multiple mechanisms ensure oracle data quality:
Oracle Authorization: Each oracle must be explicitly added to a rate feed's whitelist through governance. Only authorized oracles can submit reports.
Automatic Expiry: Old reports are automatically invalidated after the expiry period, preventing stale data from affecting current prices.
Median Filtering: Using the median rather than average prices provides natural resistance to manipulation, as an attacker would need to control multiple oracles to shift the median significantly.
Integration with Protocol
Oracle prices flow through the protocol to enable core functions:
Price Discovery: Exchange contracts query median rates to determine swap prices(ℹconsider footnote to clarify what exchange contract is(family of contrtacts vs V1 contract). The broad term makes sense)
Circuit Breaker Monitoring: The circuit breaker checks oracle updates for abnormal movements
Multi-Asset Support: Different rate feeds track various currency pairs and asset prices
Technical Architecture
The oracle system uses gas-optimized designs for efficiency:
Sorted Linked Lists: Enable O(1) median calculation while maintaining sorted order for efficient updates.
Batch Updates: Oracles can update prices in a single transaction, with automatic median recalculation.
Modular Design: Oracle management, price aggregation, and breaker integration are cleanly separated for maintainability.
Event Emission: All significant actions emit events for off-chain monitoring and indexing.
Oracle Governance
Oracle system parameters are managed through decentralized governance:
Adding or removing oracle providers
Setting report expiry times
Managing equivalent token mappings
Configuring rate feed parameters
This ensures the oracle system evolves with the protocol's needs while maintaining decentralization.
Next Steps
To understand how oracles enable Mento's operations:
Stability Mechanisms - How oracle prices enable arbitrage
Trading Limits & Circuit Breakers - Oracle monitoring for safety
The Broker & Virtual AMMs - Using oracle prices in swaps
GitHub: Oracle Relayer - Technical implementation details
Last updated