Skip to content

Commit b3772f1

Browse files
feat(oracle): Introduce robust and secure IPriceFeed infrastructure
This commit finalizes the core components of the Baobab Protocol's decentralized oracle infrastructure, migrating to a unified interface across all data sources (Chainlink, Pyth, Computed Feeds, and TWAP). The central goal is to enhance manipulation resistance, data consistency, and security through a multi-layered validation approach enforced by the new contract. ### Key Features and Changes: 1. **BaobabOracleSecurity Integration:** * Implements a central security gateway () enforcing sequential checks: Circuit Breakers, Global Pause, Global Staleness (), and contextual risk-based Confidence checks (). * **Refinement:** Streamlined price fetching to rely solely on the output, eliminating redundant internal calls and improving gas efficiency. 2. **OracleRegistry (Assumed Role):** * Acknowledges the reliance on the core to manage asset configuration (Primary/Fallback feeds) and enforce internal heartbeat/staleness logic before data is passed to the Security layer. The Registry acts as the sole source of data for the layer. 3. **ComputedOracle (Derived Prices):** * Introduced a system for deriving secondary asset prices (e.g., ETH/BTC) via multiplication or division of two base feeds. * **Security Fix:** Updated logic to return the **oldest** component timestamp, preventing the computed price from falsely appearing fresh when an underlying feed is stale. * **Refinement:** Optimized fixed-point division math for gas efficiency while preserving 8-decimal output precision. 4. **Oracle Adapters (Chainlink & Pyth):** * Created and to strictly conform to the interface. * **Consistency:** Standardized output to 8 decimals for Pyth by implementing a robust helper that handles variable exponents. * **Efficiency:** Refactored all adapters to ensure only a single external call is made per price query, drastically reducing transaction gas costs. * **Fail Safe:** Ensured adapters return the sentinel value () on any failure (call revert, stale data, non-positive price). 5. **TWAPAdapter (Manipulation Resistance):** * Implemented a Time-Weighted Average Price (TWAP) adapter used for sensitive actions, sourcing only validated prices from . * **Security Principle:** The price pushing mechanism is permissionless to decentralize maintenance cost and increase data freshness. * **Note on Pruning:** Identified and noted the gas-inefficiency of the current array pruning method, which is marked for a future refactor to a Ring/Circular Buffer structure for superior scalability.
1 parent 2a3e484 commit b3772f1

4,983 files changed

Lines changed: 1701 additions & 1016828 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/chainlink/.changeset/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/chainlink/.changeset/changelog-generator.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

lib/chainlink/.changeset/config.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/chainlink/.dockerignore

Lines changed: 0 additions & 38 deletions
This file was deleted.

lib/chainlink/.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/chainlink/.github/CODEOWNERS

Lines changed: 0 additions & 127 deletions
This file was deleted.

lib/chainlink/.github/E2E_TESTS_ON_GITHUB_CI.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)