Price Oracle Middleware

Purpose and scope

The Price Oracle Middleware system provides standardized asset valuation and conversion for the PlasmaVault ecosystem. It is centered around the PriceOracleMiddlewareWithRoles contract, which acts as a centralized price hub, and the PriceOracleMiddlewareManager, which provides a vault-specific interface for price queries and validation.

The system is responsible for:

System architecture

The architecture separates global price discovery from vault-specific price management and validation.

Logic flow and code entities

Architecture description:

  1. PlasmaVault and its Balance Fuses interact with the PriceOracleMiddlewareManager assigned to the vault contracts/vaults/PlasmaVault.sol75arrow-up-right

  2. The PriceOracleMiddlewareManager handles vault-specific configuration, such as custom asset sources and price validation logic stored via PriceOracleMiddlewareManagerLib contracts/managers/price/PriceOracleMiddlewareManagerLib.sol64-75arrow-up-right

  3. PriceOracleMiddlewareWithRoles serves as the protocol-wide price aggregator, managing specialized feeds like PtPriceFeed for Pendle tokens contracts/price_oracle/PriceOracleMiddlewareWithRoles.sol140-150arrow-up-right

Core components

1. PriceOracleMiddlewareWithRoles

This contract provides the "Source of Truth" for asset prices. It normalizes all outputs to 18 decimals (WAD) contracts/price_oracle/PriceOracleMiddlewareWithRoles.sol76-77arrow-up-right

2. PriceOracleMiddlewareManager

A per-vault manager that wraps the global middleware with validation and vault-specific overrides.

Specialized price feeds

The system supports various specialized feeds to handle complex DeFi assets.

Pendle PT Price Feed (PtPriceFeed)

Calculates the price of Pendle Principal Tokens using Pendle's TWAP oracle and the price of the underlying asset from the middleware contracts/price_oracle/price_feed/PtPriceFeed.sol12-18arrow-up-right

Feature
Implementation Detail

TWAP Window

Calculation

(PtToAssetRate * UnderlyingAssetPrice) / scalingFactor contracts/price_oracle/price_feed/PtPriceFeed.sol128arrow-up-right

Metadata

Feed factory pattern

Factories like PtPriceFeedFactory and CurveStableSwapNGPriceFeedFactory are used to deploy standardized feed instances that the middleware can then consume contracts/factory/price_feed/PtPriceFeedFactory.sol6-10arrow-up-right

Price validation mechanism

The validation system prevents the vault from transacting at "stale" or manipulated prices by enforcing a maximum allowed deviation.

Access control and roles

The system utilizes a hierarchy of roles defined in Roles.sol to secure configuration.

Role
Entity
Permission

ADMIN_ROLE

AccessManager

Highest level; manages all roles contracts/libraries/Roles.sol11-13arrow-up-right

ATOMIST_ROLE

PlasmaVault

Can update the priceOracleMiddleware address contracts/libraries/Roles.sol44-45arrow-up-right

PRICE_ORACLE_MIDDLEWARE_MANAGER_ROLE

PriceOracleMiddlewareManager

Manages asset price sources and validation deltas contracts/libraries/Roles.sol102-105arrow-up-right

SET_ASSETS_PRICES_SOURCES

PriceOracleMiddlewareWithRoles

ADD_PT_TOKEN_PRICE

PriceOracleMiddlewareWithRoles

Data normalization

All prices returned by the middleware system are normalized to 18 decimals (WAD) to ensure consistency across the IPOR Fusion protocol.

Last updated

Was this helpful?