# Tiered Oracle

Moar Market uses a robust on-chain **Tiered Oracle** system to fetch secure and up-to-date prices for all supported assets. These prices are central to maintaining solvency, enforcing LTVs, and executing liquidations.

The system prioritizes safety and uptime through **tiered resolution**, timestamp-based freshness validation, and fallback logic.

***

### 🧱 Oracle Sources and Tiers

Moar’s Tiered Oracle architecture supports multiple providers, ordered by trust and reliability. Each asset is assigned two tiers:

* **Tier 1 (Primary)** — `Pyth`
* **Tier 2 (Fallback)** — `Switchboard`

Prices are fetched from the primary source first. If the price is stale or unavailable, the fallback is used — but only if it's valid and fresh.

If both tiers are invalid or stale, the asset's price is marked **broken**, and any operation that depends on that price is **blocked**.

***

### 🕒 Price Freshness & Enforcement

Each asset has two timing thresholds:

* `staleness_seconds` — the price is still usable but flagged as stale
* `broken_seconds` — the price is rejected entirely and marked broken

These ensure that only **fresh and secure prices** are used during:

* Health checks
* Borrowing
* Liquidations
* Strategy valuation

Price freshness is validated on-chain using timestamps provided by the oracle feeds. If a price exceeds its thresholds, the protocol either falls back to the secondary source or blocks the operation.

***

### ⚙️ How Price Resolution Works

When fetching the price of an asset, the Tiered Oracle resolves it using the following logic:

1. **Query Tier 1**&#x20;
   * If the price is fresh → use it
   * If the price is stale or invalid → move to Tier 2
2. **Query Tier 2**&#x20;
   * If the price is fresh → use it
   * If also stale or invalid → the oracle is marked **broken**, and price resolution fails

> There is **no fallback to stale data** — either Tier 1 or Tier 2 must return a valid, fresh price for the asset to be considered priced.

This strict design ensures all health checks, liquidations, and borrowing operations are executed using **only up-to-date oracle data**, reducing risk from manipulation or downtime.

***

### 🧠 Role in Protocol Operations

Prices returned by the Tiered Oracle are used throughout the Moar protocol:

* **Health checks** — to evaluate whether Credit Accounts remain solvent
* **Liquidations** — to determine asset and debt valuations
* **Strategy valuation** — to calculate the real-time value of LP tokens or staked assets
* **Borrow caps** — to ensure LTV enforcement across all pools

All pricing is enforced on-chain — ensuring transparency, verifiability, and resistance to manipulation.
