# Price Oracle

> A Somnia Agents base agent that serves the median price of a token across several exchanges, from a cache it keeps up to date, to your contract.

Price Oracle is a base agent on [Somnia Agents](/agents/somnia-agents). It polls the price of a configured set of tokens on several exchanges, keeps each exchange's latest quote in memory, and answers a request with the median across exchanges. No network call happens while a request is served, and no LLM is involved, so it is fast and cheap.

Symbols are exchange-style pairs such as `BTC/USDC`, or `BTC/USDC:PERP` for a perpetual. Prices come back scaled by the decimals the caller asks for, with how many exchanges contributed and when the quote was last updated.

## Methods

| Method | Returns | For |
| --- | --- | --- |
| `getPrices` | median, source count and update time per symbol | Several symbols at once |
| `getPricesPacked` | the same medians, two symbols per word | Gas-efficient batches |
| `getPricesSlots` | the same medians, one 48-bit slot per symbol | Many symbols in one call |
| `getExchangePrice` | one exchange's latest quote and its time | A named exchange, with a freshness limit the caller sets |

## Price Oracle and Somnia Price Feeds

Price Oracle answers a contract's request on demand. [Somnia Price Feeds](/data/price-feeds) is built on the same agents but pushes a spot and a mark price for every tracked pair into contract storage about once a second, so any contract reads a price for free with no request. Use Price Oracle for a symbol the feeds don't track or for one exchange's quote; use Price Feeds for a price a market or a lending pool reads every block.

## Reference

Parameters, freshness rules, the minimum number of sources, receipts and the price per subcommittee member are in the agent's reference page, [Price Oracle](/agents/somnia-agents/base-agents/price-oracle). Calling any agent from Solidity is in [Invoking from Solidity](/agents/somnia-agents/invoking-agents/from-solidity).

Every registered agent, with its methods and price, is in the [Agents directory](https://new.explorer.somnia.network/agents?type=price-oracle) in the Somnia Explorer.

---

Every page is also Markdown: append `.md` to its URL, or ask for `text/markdown`. Found something wrong, missing or confusing in these docs? Tell us: `POST /api/feedback` on this site with JSON `{"message": "…", "context": "what you were doing and what happened", "page": "…"}`, or a plain-text body. `GET /api/feedback` gives the JSON Schema. The team reads every one.
