Oracle Use: Pyth and SEDA

SEDA provides the aggregation logic that combines Pyth prices with other sources (like Hyperliquid mark prices) to create a composite rate. Pyth provides the relayer infrastructure that connects to SEDA FAST, and serves as the oracle updater. Importantly, Pyth will be operating the relayers in a decentralized manner.

Architecture & Actors

The following table depicts the different roles played by various actors in delivering price data to Nunchi:

Component

Role

Responsibility

Pyth

Data Source

Provides high-quality, real-time price feeds

HIP-3 Pusher (Pyth)

Relayer

Listens to SEDA and updates HIP-3 oracles

Oracle Updater (Pyth)

Executor

Calls ‘SetOracle’ with SEDA composite rate

SEDA

Aggregator

Combines Pyth + other sources into composite rate

Step-by-Step Flow

The flow of this architecture is depicted below:

Additional details on these steps are provided below:

Note: All code below is in Python.

Step 1: Pyth Provides Price Data

# Pyth network continuously updates on-chain PythFeeds contract
# Price Feed ID: ae2603642690e2eab388e4c91edbf4eb248012b878a177d0b2c9ec8c7d891487
# Price: 35.34 USDC per VXX
# Confidence: ±0.01
# Publish Time: 1234567890

Step 2: Hyperliquid Provides Mark Price

# Hyperliquid DEX provides mark price from orderbook
# DEX: "nunchi"
# Asset: "VXX"
# Mark Price: 35.33 USDC per VXX
# Source: median(best_bid, best_ask, last_trade) 

Step 3: SEDA Aggregates Prices

# SEDA program executes:
# 1. Fetches Pyth price from PythFeeds contract
# 2. Fetches Hyperliquid mark price from API
# 3. Applies weighting logic based on market conditions
# 4. Returns composite rate

seda_result = seda_client.execute_nunchi_program(
    exec_inputs="ae2603642690e2eab388e4c91edbf4eb248012b878a177d0b2c9ec8c7d891487,nunchi,2"
)

# Result:
{
    "composite_rate": "35.33656",  # Blended price
    "pyth_price": "35.34",         # From Pyth
    "hyperliquid_price": "35.33",  # From Hyperliquid
    "weights": {
        "session": 0.95,           # 95% weight to Hyperliquid (during market hours)
        "reference": 0.05           # 5% weight to Pyth (reference)
    },
    "active_session": "NORMAL",    # Market is open
    "sources_used": [...]
}

Step 4: Relayer (Pyth) Updates Oracle

# Relayer uses SEDA composite rate
# Calls SetOracle on Hyperliquid HIP-3

exchange.perp_deploy_set_oracle(
    dex="nunchi",
    oracle_pxs={"nunchi:VXX": "35.33656"},  # From SEDA
    mark_pxs=[{"nunchi:VXX": "35.33656"}],
    external_perp_pxs={"nunchi:VXX": "35.33656"}

Weighted Blending

SEDA uses weighted blending to combine Pyth and Hyperliquid prices:

composite_rate = (
    hyperliquid_price * session_weight +
    pyth_price * reference_weight
)

Last updated

Was this helpful?