Oracle

Overview

The Oracle in our system acts as a single endpoint responsible for fetching and aggregating two key types of data:

  1. Real-time Price Feeds of Assets

  2. User Position Data Across Multiple Protocols

This Oracle is a core piece of infrastructure that ensures the protocol can remain solvent, execute accurate risk calculations, and verify the health of all positions. It provides the necessary truth source for pricing, margin calls, liquidations, and portfolio tracking.

User Position Aggregator

One of the most critical responsibilities of the Oracle is tracking all active user positions across different external protocols. These include:

Market Type
Integrated Protocols

Perpetuals

MUX, Avantisfi, Perp

Options

Derive Protocol

Spot

Uniswap

Key roles of the Oracle:

  • Collateral Valuation: Determines how much USD value is backed by user’s assets

  • Health Checks: Ensures protocol remains overcollateralized and healthy

  • Liquidation Logic: Triggers liquidation if user’s position health falls below the safe threshold

  • Unified View: Aggregates fragmented positions from external protocols to provide a single view of user risk

Core Functions

The Oracle contract acts as a central interface for fetching the price of any supported token in terms of ETH. Instead of directly interacting with multiple oracle contracts, users and contracts can use this facade as a unified access point.

This contract is a proxy pattern over multiple asset-specific oracles and forwards the getPrice() call to the correct underlying oracle based on the asset address and the positon.

getPrice

Fetches the current ETH-denominated price of the given token for a specific account.

function getPrice(address token, address account) external returns (uint)
  • token: The address of the token whose price you want, for the positon we use track token

  • account: The account whose context might be used

setOracle

function setOracle(address token, IOracle _oracle) external adminOnly
  • Description: Assigns a new oracle for a specific token.

  • Access: Restricted to adminOnly (defined in the Ownable contract).

Last updated