Oracle

The oracle is MegaTAO's pricing engine. It provides real-time Alpha token prices to the protocol by reading directly from on-chain data, with no reliance on off-chain price feeds.

How pricing works

Each Bittensor subnet has an Alpha token that trades in an on-chain liquidity pool against TAO. These pools hold reserves of both TAO and the Alpha token. The ratio of these reserves determines the token's price.

MegaTAO's price oracle reads these reserves through the Alpha precompile contract on Bittensor EVM. The precompile is a native contract built into the chain itself, giving the oracle a direct source of truth for pricing from the Alpha pools.

The price derivation:

  1. The oracle calls get_alpha_price(netUid) for a given subnet

  2. The precompile returns the current pool reserves (TAO and Alpha token amounts)

  3. The price is calculated from the TAO/Alpha ratio in the pool

  4. This price is used for position entry, exit, P&L calculation, and liquidation checks

Because the precompile is part of the Bittensor EVM itself, the oracle accesses pool state at the block level. There is no delay, no relay, and no intermediary. The price you see is the price on-chain at that moment.

Why on-chain pricing matters

Most derivatives protocols rely on external oracle networks (like Chainlink) to relay off-chain exchange prices on-chain. This introduces latency, trust assumptions, and potential manipulation vectors.

MegaTAO takes a different approach:

  • No off-chain feeds. Prices come directly from on-chain pool reserves via the precompile. There is no external data provider to trust or wait for.

  • No relay delay. The oracle reads pool state in the same block as the trade. Prices are always current.

  • Transparent and verifiable. Anyone can independently verify prices by reading the same pool reserves on-chain.

  • Manipulation resistant. Manipulating prices would require moving actual liquidity in the Alpha token pools, which has a real capital cost.

Price validation

The oracle includes safeguards to reject invalid price data:

  • Zero or negative prices are rejected

  • Price impact is calculated dynamically based on position size relative to pool liquidity

  • The protocol enforces a maximum slippage parameter on each trade, reverting the transaction if actual execution price deviates too far from the oracle price

Role in the protocol

Oracle prices feed into every part of the trading system:

Function
How oracle price is used

Opening a position

Determines entry price and notional value

Closing a position

Determines exit price and realized P&L

Margin ratio

Calculates unrealized P&L against current price

Liquidation

Triggers when margin ratio falls below maintenance threshold

Funding rates

Combined with open interest to determine funding payments

Last updated