Skip to content

Oracle Engine

The Oracle Engine provides secure, accurate real-world data feeds to smart contracts, enabling reliable price discovery and valuation of tokenized real-world assets.

Overview

Real-world assets (RWAs) require reliable price data from traditional financial markets to function properly in blockchain environments. The IOST 3.0 Oracle Engine bridges this gap by gathering, validating, and delivering trusted financial data to on-chain protocols.

Technical Architecture

Oracle Engine Architecture

System Components

  • Data Collection Layer: Interfaces with external price sources and APIs
  • Validation Layer: Processes and validates incoming data against manipulation
  • Consensus Layer: Aggregates validated data into final price determinations
  • Delivery Layer: Manages on-chain submission of verified price feeds
  • Monitoring Layer: Tracks system performance and detects anomalies

Deployment Model

  • Hybrid On-Chain/Off-Chain: Combines off-chain data collection with on-chain verification
  • Observer Node Network: Distributed network of nodes verifying oracle operations
  • Redundant Infrastructure: Multiple fallback systems ensuring continuous operation
  • Geographic Distribution: Servers strategically located for resilience and reduced latency

Multi-Source Aggregation

The Oracle Engine collects pricing data from multiple authoritative sources to ensure accuracy and resilience against single points of failure.

Data Sources Integration

  • Regulated Exchanges: Direct feeds from traditional securities exchanges with established regulatory oversight
  • Financial Information Providers: Integration with industry-standard data providers like Bloomberg, Refinitiv, and Morningstar
  • Institutional Market Makers: Price quotes from regulated banks and financial institutions with market-making authority
  • Specialized RWA Data Services: Custom integrations with specialized pricing services for non-traditional assets

Aggregation Methodology

  • Weighted Source Reliability: Assigns dynamic weights to data sources based on historical accuracy, recency, and market representation
  • Cross-Verification Protocol: Compares data between sources to identify and flag inconsistencies
  • Market Depth Analysis: Considers trading volumes and liquidity in source evaluations to favor more robust price points
  • Asset-Specific Aggregation Models: Customized aggregation methods for different asset classes (bonds, real estate, commodities)

Frequency & Timeliness

  • Asset-Dependent Update Cycles: Update frequency tailored to each asset class's natural market rhythm
  • Event-Triggered Updates: Special update mechanisms triggered by significant market events
  • Real-Time Feed Options: Subscription-based real-time updates for high-value or volatile assets
  • Historical Data Storage: Maintains comprehensive price history for trend analysis and audit purposes

Anti-Manipulation Safeguards

The Oracle Engine employs multi-layered defenses against price manipulation, ensuring data integrity for critical financial applications.

Statistical Models & Anomaly Detection

  • Outlier Detection Algorithms: Identifies and flags statistically improbable price movements
  • Volatility-Adjusted Boundaries: Dynamic price boundaries that adapt to each asset's natural volatility patterns
  • Time-Series Anomaly Detection: Machine learning models that detect unusual patterns in price movement over time
  • Volume-Price Correlation Analysis: Detects suspicious price movements not supported by corresponding trading volumes

Consensus Mechanisms

  • Weighted Median Calculation: Core aggregation method resistant to extreme outliers
  • Trimmed Mean Methodology: Removes highest and lowest percentiles before aggregation
  • Interquartile Range Filtering: Focuses on middle 50% of data points to eliminate extreme values
  • Confidence Scoring: Assigns reliability scores to each data point for weighted consideration

Governance & Oversight

  • Algorithmic Governance: Transparent rules for data inclusion and exclusion
  • Manual Review Triggers: Automatic escalation of suspicious patterns for human review
  • Observer Node Network: Decentralized network of validator nodes monitoring oracle operations
  • Public Audit Trail: Immutable record of all price submissions and final determinations

Real-Time Price Discovery

The Oracle Engine delivers verified price data on-chain with minimal delay, enabling dynamic asset valuation and DeFi functionality.

On-Chain Update Mechanism

  • Threshold Signature Cryptography: Secure method for aggregating multiple data source signatures before submission
  • Gas-Optimized Updates: Efficient update patterns to minimize blockchain transaction costs
  • Tiered Update Priority: Critical price feeds receive higher priority in congested network conditions
  • Batch Processing Option: Groups multiple asset updates to reduce overall gas costs when appropriate

Integration Example

solidity
// Example of threshold signature verification for oracle updates

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract OracleUpdateMechanism {
    // Authorized oracle updaters with their weights
    mapping(address => uint256) public updaters;
    
    // Threshold required for price updates (e.g., 7000 = 70%)
    uint256 public threshold = 7000;
    
    // Latest prices and timestamps
    mapping(string => uint256) public prices;
    mapping(string => uint256) public updateTimes;
    
    // Signatures collected for pending updates
    struct PendingUpdate {
        uint256 proposedPrice;
        uint256 totalWeight;
        mapping(address => bool) hasConfirmed;
        bool executed;
    }
    
    mapping(string => PendingUpdate) public pendingUpdates;
    
    event PriceUpdateProposed(string assetId, uint256 proposedPrice, address proposer);
    event PriceUpdateConfirmed(string assetId, address confirmer, uint256 currentWeight);
    event PriceUpdated(string assetId, uint256 newPrice);
    
    // Propose a new price update
    function proposeUpdate(string memory assetId, uint256 newPrice) external {
        require(updaters[msg.sender] > 0, "Not authorized");
        
        PendingUpdate storage update = pendingUpdates[assetId];
        
        // Reset if this is a new proposal
        if (update.totalWeight == 0 || update.executed) {
            update.proposedPrice = newPrice;
            update.totalWeight = 0;
            update.executed = false;
        }
        
        // Add weight if not already confirmed
        if (!update.hasConfirmed[msg.sender]) {
            update.hasConfirmed[msg.sender] = true;
            update.totalWeight += updaters[msg.sender];
        }
        
        emit PriceUpdateProposed(assetId, newPrice, msg.sender);
        
        // If threshold reached, execute the update
        if (update.totalWeight >= threshold) {
            prices[assetId] = newPrice;
            updateTimes[assetId] = block.timestamp;
            update.executed = true;
            
            emit PriceUpdated(assetId, newPrice);
        } else {
            emit PriceUpdateConfirmed(assetId, msg.sender, update.totalWeight);
        }
    }
    
    // Get the latest price with timestamp
    function getLatestPrice(string memory assetId) external view returns (uint256, uint256) {
        return (prices[assetId], updateTimes[assetId]);
    }
}

Smart Contract Integration

  • Standardized Interface: Common API for smart contracts to query current and historical price data
  • Push vs. Pull Mechanisms: Both active updates and on-demand query capabilities
  • Callback Functionality: Allows contracts to register for automated notifications on significant price changes
  • Confidence Interval Reporting: Provides uncertainty metrics alongside price points for risk-aware applications

Integration Example

solidity
// Example of a smart contract integrating with IOST Oracle Engine

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOracleEngine {
    // Get the latest price of an asset
    function getLatestPrice(string memory assetId) external view returns (uint256 price, uint256 timestamp);
    
    // Get price with confidence interval
    function getPriceWithConfidence(string memory assetId) external view returns (
        uint256 price, 
        uint256 lowerBound, 
        uint256 upperBound, 
        uint256 timestamp
    );
    
    // Register for price update notifications
    function registerCallback(string memory assetId, uint256 threshold, address callback) external;
}

contract RWAValuationExample {
    IOracleEngine public oracle;
    
    // Asset prices and last update timestamps
    mapping(string => uint256) public assetPrices;
    mapping(string => uint256) public lastUpdated;
    
    // Price change threshold (in basis points) that triggers actions
    uint256 public constant PRICE_CHANGE_THRESHOLD = 200; // 2%
    
    event PriceUpdated(string assetId, uint256 oldPrice, uint256 newPrice);
    
    constructor(address _oracleAddress) {
        oracle = IOracleEngine(_oracleAddress);
    }
    
    // Update asset price from oracle
    function updateAssetPrice(string memory assetId) public {
        (uint256 price, uint256 timestamp) = oracle.getLatestPrice(assetId);
        
        // Ensure price is fresh
        require(timestamp > block.timestamp - 1 hours, "Oracle data too old");
        
        uint256 oldPrice = assetPrices[assetId];
        assetPrices[assetId] = price;
        lastUpdated[assetId] = timestamp;
        
        emit PriceUpdated(assetId, oldPrice, price);
    }
    
    // Calculate portfolio value
    function calculatePortfolioValue(string[] memory assetIds, uint256[] memory amounts) 
        public view returns (uint256 totalValue) 
    {
        require(assetIds.length == amounts.length, "Arrays length mismatch");
        
        for (uint i = 0; i < assetIds.length; i++) {
            (uint256 price, ) = oracle.getLatestPrice(assetIds[i]);
            totalValue += (price * amounts[i]) / 1e18;
        }
        
        return totalValue;
    }
}

Performance Metrics

  • Latency Monitoring: Continuous measurement of time from real-world price change to on-chain availability
  • Deviation Tracking: Measures oracle price accuracy against definitive settlement prices
  • Reliability Scoring: Tracks successful update percentage and system uptime
  • Cost Efficiency Analysis: Monitors and optimizes gas costs for data provision

Use Cases in RWA Framework

Asset Valuation

  • NAV Calculation: Provides current market values for calculating Net Asset Value of tokenized portfolios
  • Mark-to-Market: Enables real-time valuation of collateral assets backing tokenized securities
  • Yield Calculations: Powers accurate yield projections for interest-bearing RWA tokens
  • Redemption Pricing: Ensures fair valuation during token redemption events

Risk Management

  • Collateralization Ratio Monitoring: Tracks collateral values to maintain required security levels
  • Liquidation Triggers: Provides reliable price feeds for automatic liquidation mechanisms
  • Value-at-Risk Calculations: Supplies historical volatility data for risk modeling
  • Stress Testing: Supports scenario analysis with historical and simulated price movements

Integration Example

solidity
// Example of liquidation trigger using oracle price feeds

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOracleEngine {
    function getLatestPrice(string memory assetId) external view returns (uint256 price, uint256 timestamp);
}

contract CollateralizedLoan {
    IOracleEngine public oracle;
    
    struct Loan {
        uint256 loanAmount;
        uint256 collateralAmount;
        string collateralAssetId;
        uint256 liquidationThreshold; // in basis points (e.g., 8000 = 80%)
        bool active;
    }
    
    mapping(address => Loan) public loans;
    
    event LoanCreated(address borrower, uint256 loanAmount, uint256 collateralAmount);
    event Liquidated(address borrower, uint256 collateralValue, uint256 loanValue);
    
    constructor(address _oracleAddress) {
        oracle = IOracleEngine(_oracleAddress);
    }
    
    // Check if a loan needs liquidation based on current collateral value
    function checkLiquidation(address borrower) public view returns (bool) {
        Loan memory loan = loans[borrower];
        if (!loan.active) return false;
        
        (uint256 collateralPrice, uint256 timestamp) = oracle.getLatestPrice(loan.collateralAssetId);
        
        // Ensure oracle data is fresh
        require(timestamp > block.timestamp - 1 hours, "Oracle data too old");
        
        uint256 collateralValue = (loan.collateralAmount * collateralPrice) / 1e18;
        uint256 minCollateralRequired = (loan.loanAmount * 10000) / loan.liquidationThreshold;
        
        return collateralValue < minCollateralRequired;
    }
    
    // Liquidate an undercollateralized position
    function liquidate(address borrower) external {
        require(checkLiquidation(borrower), "Position is not liquidatable");
        
        Loan storage loan = loans[borrower];
        (uint256 collateralPrice, ) = oracle.getLatestPrice(loan.collateralAssetId);
        
        uint256 collateralValue = (loan.collateralAmount * collateralPrice) / 1e18;
        
        emit Liquidated(borrower, collateralValue, loan.loanAmount);
        
        // Liquidation logic would continue here...
        loan.active = false;
    }
}

Secondary Market Support

  • Fair Price Discovery: Provides reliable reference prices for thinly-traded RWA tokens
  • Arbitrage Detection: Identifies pricing inefficiencies between on-chain and off-chain markets
  • Market Making Support: Enables efficient market making with accurate price information
  • Settlement Price Determination: Provides trusted settlement prices for derivatives and options

Security & Compliance

Data Security

  • End-to-End Encryption: Secures data transmission from source to on-chain destination
  • Cryptographic Verification: Ensures data integrity throughout the oracle process
  • Access Control Framework: Restricts data access to authorized contracts and users
  • Key Management Protocol: Secure handling of cryptographic keys for signing operations

Compliance Framework

  • Audit Trails: Maintains complete, immutable records of all price submissions and uses
  • Data Provenance: Tracks and verifies the source of all pricing information
  • Regulatory Reporting: Supports automated generation of required regulatory reports
  • Privacy Controls: Ensures handling of sensitive financial data complies with relevant regulations

Released under the MIT License.