Skip to content

How Sai's Oracle Works

Every Sai market has one reference price, the oracle price. Sai uses it to fill trades, calculate profit and loss, trigger orders, and liquidate positions. This page explains where that price comes from and what protects it.

Yes. Sai runs its own oracle, and it has two parts:

  • The Sai price feeder is an offchain service that Sai operates. It collects prices from exchanges and market data providers, combines them into one price per market, and writes the result to the chain.
  • The Sai oracle contract is a smart contract on Nibiru, the chain Sai runs on. It stores the latest price of each asset. Sai’s trading contract reads prices only from this contract.

Nibiru used to run a separate oracle in which validators voted on prices. Nibiru retired that oracle in v2.12, in April 2026. Sai’s markets don’t depend on it. Nibiru’s NAN 004 release note explains why.

    • Binance
    • OKX
    • Bybit
    • Bitfinex
    • Gate.io
    • Twelve Data
    • AllTick
    Price sources Exchanges and data providers
  1. Fetch
  2. Sai price feeder Drops a lone outlier, takes a weighted median
  3. Write onchain
  4. Sai oracle contract On Nibiru. Approved writers only
  5. Read
  6. Sai perps contract Refuses prices older than 5 min
  7. Update
  8. BTC $60,548.40 Market price Example values
  1. Collect. The feeder asks each source for its latest price. Crypto markets use several large exchanges. Stocks, ETFs, and commodities use a market data provider, which is called a custom feed.
  2. Drop a lone outlier. If exactly one source is far from the median of all sources and from the market’s recent average price, the feeder leaves it out of that round. A flash crash or spike on one exchange therefore doesn’t move Sai’s price. If several sources move the same way, the feeder treats it as a real market move.
  3. Take the weighted median. Each exchange carries a weight, and larger, more liquid exchanges weigh more. The feeder lines up the remaining prices from low to high and adds up their weights as it goes. The price where that running total first reaches half of all the weight is the weighted median. Unlike an average, it isn’t pulled around by one extreme value.
  4. Write it onchain. The feeder sends the new prices to the Sai oracle contract. The contract accepts prices only from addresses that Sai has approved, and it records when each price was written. When a block contains a price update, Nibiru puts it first, so later trades in the same block use the new price.

A market with a single source, such as a stock, uses that provider’s price.

  • Market orders. When you place a market order, Sai waits for the next oracle price written after your request and fills the order at that price, adjusted for price impact. If no new price arrives within 20 blocks, Sai cancels the order and refunds any margin it held.
  • Profit and loss. Your PnL compares your entry price with the current oracle price, before fees.
  • Limit, stop, take-profit, and stop-loss orders. Keepers watch oracle prices and trigger an order once the price reaches its level. A trigger fills only at a price written after you placed or last edited the order.
  • Liquidations. Sai liquidates a position when the oracle price reaches its liquidation price. See Leverage and Liquidations.
  • Collateral. The oracle also prices USDC collateral, which feeds into fees and liquidation math.
  • Stale prices are refused. Each group of markets has a maximum price age. For crypto, stock, ETF, and commodity markets, it is 5 minutes. If the latest price is older than that, Sai’s trading contract won’t open, close, or liquidate positions with it, and it won’t set a new take-profit or stop-loss level. Trading continues once a fresh price arrives.
  • The last good price stays, with an age limit. If the feeder pauses, the oracle keeps the last price it accepted. It never makes up a price. Once that price passes the age limit, the stale-price rule applies.
  • One exchange can’t set the price. The outlier filter and the weighted median keep a single exchange’s flash crash or spike out of Sai’s price.
  • Only approved writers. The oracle contract rejects price updates from any address that Sai hasn’t approved.
  • Triggers wait for a newer price. A limit, stop, take-profit, or stop-loss order can’t fill at a price that was already onchain when you placed or edited it.
MarketsPrice sourcesHow the price is made
Crypto, such as BTC, ETH, and SOLBinance, OKX, Bybit, Bitfinex, and Gate.io. Each market uses two to five of them, most use four or five.Weighted median after dropping a lone outlier
US stocks and ETFs, such as AAPL, NVDA, TSLA, and SPYTwelve Data, a market data providerCustom feed from one provider
Gold, silver, platinum, palladium, and natural gasTwelve DataCustom feed from one provider
Brent crude oil (XBR)AllTick, a market data providerCustom feed from one provider

Sources can change as Sai adds markets and venues. The Sai app always shows each market’s current oracle price.

Why is Sai’s price a little different from the exchange I’m watching?
Sai’s price blends several venues instead of copying one. It also updates in rounds rather than with every trade, and some sources quote prices in USDT, a dollar stablecoin that can trade slightly above or below $1. Your fill price can also include price impact.

What happens when a market is closed?
Stocks, ETFs, and commodities follow trading sessions. Outside a session, the feeder ignores the provider’s updates, so the oracle price stays at its last value. You can’t open or voluntarily close positions on a closed market. Positions held through a close can have their leverage reduced. See After-Hours Leverage.

Is this Nibiru’s validator oracle?
No. Nibiru’s validator oracle, in which validators committed and then revealed their price votes, was retired in v2.12. Sai’s markets read prices only from the Sai oracle contract.

Who runs the price feeder?
Sai does. The oracle contract accepts prices only from addresses that Sai has approved, and every price it stores records which address wrote it and when.

Can I check the price myself?
Yes. The Sai oracle contract is public on Nibiru. Its address is on the Contract Addresses page, and the Oracle API serves the same prices through Sai Keeper.