Skip to main content
← Back to blog
TUTORIAL What Is a Blockchain Oracle? Pyth, Price Feeds, and Why They… MoonHydra · moonhydra.com/blog
Tutorial Oracles Fundamentals Solana

What Is a Blockchain Oracle? Pyth, Price Feeds, and Why They Matter

· 9 min read · MoonHydra Research

A smart contract on Solana is powerful and completely blind. It can move tokens, run math, and enforce rules with perfect reliability — but it cannot look up the price of SOL, the dollar value of Bitcoin, or anything else that happens outside the chain. That blindness is a deliberate design choice, and it creates a problem the whole of DeFi has to solve: how does on-chain code learn what a real-world asset is worth? The answer is a blockchain oracle. If you trade on Solana, you have probably leaned on oracles without ever seeing one, and the few minutes it takes to understand them will make perps, lending, and stablecoins a lot less mysterious — and a lot less surprising when something breaks.

The core problem: contracts can't see off-chain

Blockchains are closed systems on purpose. Every node has to reach the exact same result when it runs a contract, otherwise the network can't agree on what happened. If a contract could reach out to the open internet and ask "what's the price of SOL right now?", two nodes running it a half-second apart might get two different answers — and consensus would fall apart. So contracts are sealed off from external data entirely. They can only see what is already written on-chain.

That's fine for some things. A simple AMM swap doesn't need to know the "real" price of anything, because it prices a token purely from the balances sitting in its own pool — the math is entirely on-chain, so no outside data is required. But the moment a protocol needs to know the actual market price of an asset, it hits a wall. A lending market has to know what your collateral is worth before it lets you borrow against it. A perpetuals exchange has to know the mark price to settle your position. A stablecoin that claims to track the dollar has to know whether it's actually trading at one dollar. None of that information lives on-chain by default. Something has to carry it in.

What an oracle actually does

An oracle is the bridge that brings external data onto the chain in a form contracts can read. In the narrow sense most traders care about, that data is a price feed: a continuously updated, on-chain record of what an asset is worth, sourced from the wider market. A contract that needs a price doesn't reach off-chain itself — it reads the oracle's on-chain value, which an oracle network has already gathered, aggregated, and posted.

The hard part isn't fetching a number — anyone can read a price from an exchange. The hard part is doing it in a way that's trust-minimized. If a single company simply typed a price into a contract, every protocol relying on it would be one bad actor (or one hacked server) away from disaster. So a serious oracle network spreads the work across many independent data sources, aggregates them into a single figure, and exposes that figure on-chain with a timestamp and often a confidence range. The goal is for the on-chain price to be hard for any one party to fake, and to fail loudly rather than silently when something is wrong. An oracle is less a "data feed" and more a small piece of market infrastructure whose entire job is making off-chain reality trustworthy enough for code to act on.

The main Solana oracles: Pyth and Switchboard

On Solana, two oracle networks come up over and over, and they take noticeably different approaches.

Pyth Network is built around first-party data. Instead of paying third parties to scrape prices, Pyth has the actual market participants — exchanges, trading firms, and market makers — publish their own price data directly. Those first-party submissions are aggregated into a single feed per asset, and Pyth provides hundreds of price feeds covering crypto, equities, FX, and more. The pitch is that the data comes straight from the venues that set the prices, rather than from an intermediary reading a screen.

Switchboard takes a more open, permissionless route. Rather than a curated set of approved publishers, Switchboard lets anyone create a data feed and define where its data comes from, run by a network of independent operators. That flexibility means it can serve a long tail of assets and even non-price data, and it's multichain rather than Solana-only. The trade-off between the two is roughly first-party curation and depth on common assets (Pyth) versus open, customizable coverage of almost anything (Switchboard) — and many protocols read from more than one source so they aren't betting everything on a single oracle.

Pull vs push, at a high level

You'll see oracle feeds described as either push or pull, and the distinction matters mostly for cost and freshness rather than anything you click. In the older push model, the oracle network continuously writes new prices on-chain on a schedule — every few seconds, say — whether or not anyone is using them. Reliable, but someone pays for a constant stream of updates, and during network congestion those updates can lag.

The pull model flips that. The freshest price is kept ready off-chain, and it only gets written on-chain at the exact moment a contract actually needs it — the transaction that uses the price also carries a recent signed update and posts it in the same breath. The protocol "pulls" the price on demand instead of paying to have it constantly "pushed." On a high-throughput chain like Solana, where update costs and congestion both matter, the pull design has become the norm — Pyth's Solana feeds work this way. The practical upshot for you as a trader: a price was usually fetched and verified as part of the same action that relied on it, which is good for freshness, but it also means the freshness depends on that update actually being recent and correct.

Where oracles actually matter to you

Here's the part worth internalizing: for a plain spot memecoin swap, you mostly don't touch an oracle at all. When you buy a token through a DEX, the price comes from the liquidity pool itself — the AMM math on the pool's reserves sets your execution price, and an aggregator like Jupiter just routes you to the best pools. No external price feed is consulted to fill that trade. So if all you ever do is swap one Solana token for another, oracles are largely happening somewhere off to the side.

But the wider DeFi you may step into leans on oracles heavily, and that's where they quietly govern your money:

  • Perpetuals. A perps venue like Drift needs a mark price to value open positions, calculate funding, and decide when a position is underwater. That mark price comes from an oracle, not from a single pool — so the oracle is effectively the referee for your leveraged trade.
  • Lending and borrowing. A lending market has to price your collateral to know how much you can borrow and when you should be liquidated. If the oracle says your collateral is worth less, you can get liquidated; the feed is the trigger.
  • Liquidations. The moment that closes an over-leveraged position is driven by an oracle reading. A liquidation fires because a price feed crossed a threshold — which means the timing of your liquidation is the timing of the oracle update.
  • Stablecoin pegs. Protocols that mint or manage a stablecoin use oracles to check whether it's holding its peg and to value the collateral backing it. A misreported peg can cascade into bad mints or unfair liquidations.

The rule of thumb: if you're trading spot on an AMM, the pool is your price. The instant you touch leverage, lending, or anything that liquidates, an oracle is in the loop — and you should care how good it is.

The risks: manipulation, latency, and failure

Oracles are a point of trust, and points of trust are points of attack. The most notorious failure mode is oracle manipulation, and the classic version is brutal in its simplicity. If a protocol naively derives its price from a single DEX pool, an attacker can take out a flash loan, dump an enormous trade into that thin pool to wrench the price far away from reality, and exploit a lending market that trusts the distorted number — borrowing against inflated collateral or triggering liquidations that shouldn't happen — then unwind the trade in the same transaction. The whole thing can cost little more than gas. A long, expensive history of DeFi hacks traces back to exactly this: a protocol reading a price that was too easy to push. It's a major reason robust, aggregated feeds from networks like Pyth and Switchboard exist instead of "just read the pool" — and a reason to be wary of leverage protocols that source prices from a single shallow venue.

The quieter risks are latency and failure. If a price feed lags during a violent move — say the market gaps down hard and the on-chain price updates a beat late — you can be liquidated on a stale number, or a position can settle at a price that no longer reflects the market. And if an oracle goes fully down or starts reporting something wrong, every protocol downstream of it inherits the problem at once: lending markets freeze or misprice, perps can't settle correctly, and a stablecoin can wobble. You don't control any of this, but you can account for it — favor protocols that use reputable, well-aggregated feeds, understand that liquidation prices are oracle-driven and not always perfectly in sync with the chart you're watching, and treat extreme volatility as a moment when oracle risk is highest.

How MoonHydra fits

MoonHydra is a non-custodial Solana trading bot for spot swaps, which is exactly the corner of the market where oracles mostly stay out of your way. When you paste a contract address and buy or sell, the bot routes your order through Jupiter, and your price comes from the AMM pools it routes across — not from a price-feed oracle. There's no oracle in the loop deciding your fill, and because MoonHydra runs no custom on-chain contracts of its own, there's no oracle dependency to break either; it relies on Jupiter's audited routing. Your keys stay encrypted with AES-256-GCM and the design is fully non-custodial, so your funds never leave your control. The only fee is a flat 1% per trade, on buys and sells alike, with no subscription, on top of the network and DEX fees you'd pay anyway. Where oracles do start to matter is the wider DeFi you might explore beyond the bot — perps, lending, anything with liquidations — and that's where the understanding above pays off: those venues live and die on the quality of their feeds.

Bottom line

A blockchain oracle exists to solve one stubborn problem: smart contracts can't see off-chain data on their own, so something has to carry real-world prices onto the chain in a trust-minimized way. On Solana, Pyth (first-party publisher feeds) and Switchboard (open, permissionless feeds) are the names you'll meet, and the pull model — fetching a fresh, signed price exactly when a contract needs it — is how modern feeds keep costs and lag down. For a simple spot swap you mostly rely on live pool and AMM pricing plus an aggregator, so oracles stay in the background; but the moment you touch perps, lending, liquidations, or stablecoin pegs, an oracle is quietly in charge, and its manipulation, latency, and failure risks become your risks. Know which side of that line you're on, and you'll read the rest of DeFi a lot more clearly.

Next: read what an AMM is to see why a spot swap prices off the pool and not a feed, what Drift is for a perps venue where oracle prices run the show, and what a stablecoin is for an asset whose whole job depends on a trustworthy peg. Start trading at t.me/moonhydrabot.


Ready to put this into practice?

MoonHydra is a multi-wallet Solana memecoin trading bot on Telegram. 1% per trade. AES-256-GCM encrypted. Non-custodial.

Open MoonHydra