Oracle Integration
Overview
Architecture Diagram
┌─────────────────────────────────────────────────────────────────┐
│ Vault Operations │
│ (borrow, deposit, callback) │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Asset Wrappers │
│ (ERC20, ERC4626, LP Positions) │
│ │
│ getValue(vault, manager, positionId) │
│ └── registry.getValueUSD(asset, balance) │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Oracle Registry │
│ │
│ getValueUSD(asset, amount) → USD value (18 decimals) │
│ getPriceUSD(asset) → price per unit (18 decimals) │
│ getOracle(asset) → IPriceOracle adapter │
└──────────────────────────┬──────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Oracle Adapters │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │
│ │ Chainlink│ │ Uniswap │ │ Fixed │ │ Exchange Rate │ │
│ │ Adapter │ │ V3 TWAP │ │ Price │ │ Adapter │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────────────┘ │
└─────────────────────────────────────────────────────────────────┘Core Interfaces
IOracleRegistry
IPriceOracle
Oracle Adapter Types
1. Chainlink Oracle Adapter
2. Uniswap V3 TWAP Oracle
3. Fixed Price Oracle
4. Exchange Rate Oracle
5. Composite Oracle with Fallback
Integrating Oracles with Asset Wrappers
Decimal Handling
Asset
Balance
Price
Calculation
USD Value
Health Ratio Calculation Flow
Deploying the Oracle System
Step 1: Deploy Oracle Registry
Step 2: Deploy Oracle Adapters
Step 3: Register Oracles in Registry
Step 4: Connect Registry to Factory
Security Best Practices
1. Staleness Checks
2. Price Deviation Monitoring
3. Multi-Oracle Validation
4. Circuit Breakers
Oracle Selection Guidelines
Asset Type
Recommended Oracle
Rationale
Testing Oracle Integrations
Last updated