Skip to content

xpriment626/agent-oracle-program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

seda-agents

A verifiable on-chain index value for 18 DeFi perpetual assets, powered by an AI research agent and the SEDA oracle network.

An AI research agent (quinndex) produces portfolio weighting functions via tournament-style optimisation. A human approves or rejects candidates. Developer-built infrastructure converts the active weights into a SEDA oracle data request. The oracle program fetches live Pyth prices, applies the weights, and returns a consensus-backed index value on-chain.

The agent never touches SEDA directly. It produces compute_weights() functions. Everything downstream is deterministic plumbing.

Architecture

research/          AI strategy code (copied from quinndex)
  strategy.py      Active compute_weights() function (Tail-Reactor, vol=1.0748)
  harness.py       Backtest engine with constraint validation
  config.py        18-asset universe, weight constraints
  data.py          Hyperliquid OHLCV fetcher + Parquet cache

state/             Version tracking + human approval
  models.py        WeightingFunction, WeightVector, IndexFeed, StagedCandidate
  store.py         JSON-file persistence

engine/            Weight engine + SEDA adapter
  weight_engine.py Runs active compute_weights() on cached prices
  seda_adapter.py  Converts weights, posts data requests, polls results
  seda_bridge.ts   TypeScript bridge to @seda-protocol/dev-tools

oracle-program/    Rust -> WASM, deployed to SEDA testnet
  src/lib.rs       execute() fetches 18 Pyth prices, tally() computes weighted index

frontend/          Flask admin console
  app.py           Server-rendered HTML with HTMX polling
  templates/       Index ticker, weight breakdown, staging panel

scripts/           Operational scripts
  seed_state.py    Initialize state with active strategy + feed config
  run_pipeline.py  Full loop: weights -> SEDA data request -> on-chain result

Prerequisites

  • Python 3.10+ with uv
  • Bun (for SEDA TypeScript bridge)
  • Rust with wasm32-wasip1 target (only if rebuilding the oracle program)
  • A .env file at the project root with SEDA testnet credentials:
SEDA_MNEMONIC=your twelve word mnemonic phrase here
SEDA_RPC_ENDPOINT=https://rpc.testnet.seda.xyz

Get testnet SEDA tokens from the faucet.

Setup

# Install Python dependencies
uv sync --all-extras

# Install SEDA bridge dependencies
cd engine && bun install && cd ..

# Populate the price cache (~1-2 min, fetches from Hyperliquid)
uv run python -c "from research.data import prepare; prepare()"

# Seed state with active strategy and index feed
uv run python scripts/seed_state.py

Usage

Run the pipeline

Computes weights from the active strategy, posts a data request to SEDA testnet, waits for consensus, and stores the verified index value:

uv run python scripts/run_pipeline.py

Takes 30-90 seconds per run (SEDA consensus). Each run costs a small amount of testnet SEDA.

Start the admin console

uv run python -m frontend.app

Open http://127.0.0.1:5000. Three panels auto-refresh every 30 seconds:

  • Index Ticker -- current verified index value, oracle program ID, data request ID
  • Weight Breakdown -- sorted table of all 18 assets with allocation percentages
  • Staging Panel -- approve/reject interface for candidate strategies (populated when tournaments run)

Refresh the index

Re-run the pipeline to compute fresh weights and post a new data request. The frontend picks up the latest result automatically:

uv run python scripts/run_pipeline.py

Tests

uv run pytest tests/ -v

70 tests covering state models, persistence, research module (backtest engine, metrics, data pipeline, strategy), weight engine, and SEDA adapter.

Oracle Program

The oracle program is already deployed to SEDA testnet. To rebuild and redeploy:

# Build
cd oracle-program && cargo build --target wasm32-wasip1 --release && cd ..

# Deploy (returns a new Oracle Program ID)
# Update ORACLE_PROGRAM_ID in scripts/seed_state.py, then re-seed

Current Oracle Program ID: b3d54b3c2cd2b06db5353bf7e5eafd31e8d211aaa24146d62ffe2d3ecf0f0511

Asset Universe

PUMP, LINK, AAVE, JUP, ENA, CRV, UNI, LDO, MORPHO, DYDX, PENDLE, INJ, JTO, ETHFI, PYTH, EIGEN, COMP, RUNE

All 18 assets have live Pyth price feeds fetched by the oracle program during execution.

About

An example of a research loop agent working in a Seda oracle program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors