Oracle Integration
Overview
The ZEUR protocol relies on accurate and reliable price data for all critical operations including collateral valuation, borrowing capacity calculation, liquidation triggers, and health factor monitoring. The protocol integrates with Chainlink oracles to ensure secure, decentralized, and tamper-resistant price feeds.
Chainlink Oracle Manager
Architecture
The ChainlinkOracleManager serves as the central hub for all price data:
contract ChainlinkOracleManager is AccessManagedUpgradeable, UUPSUpgradeable {
// Mapping from asset address to Chainlink aggregator
mapping(address => AggregatorV3Interface) public priceFeeds;
// Price validation parameters
uint256 public maxPriceDeviation = 500; // 5% max deviation
uint256 public stalenessTolerance = 3600; // 1 hour staleness tolerance
function getAssetPrice(address asset) external view returns (uint256);
}Supported Price Feeds
ETH/USD Feed
Address: Chainlink ETH/USD aggregator
Decimals: 8
Update Frequency: ~1 minute
Deviation Threshold: 0.5%
LINK/USD Feed
Address: Chainlink LINK/USD aggregator
Decimals: 8
Update Frequency: ~1 minute
Deviation Threshold: 0.5%
EURC/USD Feed
Address: Chainlink EUR/USD aggregator (converted for EURC)
Decimals: 8
Update Frequency: ~1 minute
Deviation Threshold: 0.1%
Price Feed Integration
Getting Asset Prices
The oracle manager provides a unified interface for price queries:
Price Validation
Multiple validation checks ensure price reliability:
1. Staleness Check
2. Positive Price Check
3. Round Consistency Check
4. Deviation Check (Optional)
Price Calculations
Collateral Value Calculation
Converting token amounts to USD values:
Example:
Asset: 5 ETH (18 decimals)
Price: 300000000000 (8 decimals, $3,000.00)
Value: (5 × 10^18 × 3000 × 10^8) / 10^18 = $15,000 × 10^8
Debt Value Calculation
Converting debt amounts to USD values:
Health Factor Calculation
Using oracle prices for health factor:
Liquidation Price Calculations
Liquidation Threshold Prices
Calculate the price at which liquidation becomes possible:
Multi-Asset Price Management
Batch Price Updates
For gas efficiency, prices can be queried in batches:
Price Aggregation
For portfolio-level calculations:
Oracle Security Features
Circuit Breakers
Automatic protection against extreme price movements:
Fallback Oracles
Secondary price sources for redundancy:
Time-Weighted Average Price (TWAP)
Smooth price movements using TWAP:
Oracle Administration
Adding New Price Feeds
Updating Oracle Parameters
Emergency Price Override
For extreme situations:
Error Handling
Oracle-Related Errors
Graceful Degradation
When oracles fail:
Use Fallback Oracles: Secondary price sources
Use TWAP: Time-weighted average prices
Pause Operations: Temporarily halt sensitive operations
Emergency Prices: Manual price overrides
Gas Optimization
Efficient Price Queries
Batch Price Operations
Optimize gas when working with multiple assets:
Monitoring and Alerts
Price Deviation Monitoring
Oracle Health Monitoring
The oracle integration system provides the reliable and secure price data foundation that enables all ZEUR protocol operations while maintaining appropriate safeguards against oracle manipulation and failures.
Last updated