Pyth
Introduction
Pyth Network is an oracle that publishes financial market data to multiple blockchains. Our market data is contributed by over 90 first-party publishers(opens in a new tab), including some of the biggest exchanges and market making firms in the world. We offer price feeds for a number of different asset classes, including US equities, commodities, and cryptocurrencies(opens in a new tab). Each price feed publishes a robust aggregate of publisher prices that updates multiple times per second.
Pyth on Cosmwasm
Cosmwasm contracts can update and fetch the Pyth prices using the Pyth Cosmwasm Contract, deployed on their network. The documented source code can be found here. The Cosmwasm API reference lets you interactively explore the complete API of the Pyth contract.
Update Price Feeds
The mechanism by which price feeds are updated on Cosmwasm is explained in the Pyth documentation. The @pythnetwork/price-service-client
TypeScript package can be used to fetch the latest price feed data which then can be passed to the contract as the UpdatePriceFeeds
ExecuteMsg.
Pyth publishes prices for two kinds of feeds:
Stable price feeds consist of prices generated on the pythnet blockchain. These feeds are available on both mainnet and testnet blockchains. Use stable feeds if you would like your test environment to be identical to your production environment.
Edge price feeds consist of prices generated on the pythtest blockchain, which is Pyth's test environment for new features. Consequently, these feeds are not as reliable as the stable feeds, and there are other differences as well (e.g., different price feed ids). These feeds are only available on testnets.
Examples
- A minimal on-chain contract example which queries the Pyth contract.
Contract Address for Osmosis Test 5
- Stable:
osmo1hpdzqku55lmfmptpyj6wdlugqs5etr6teqf7r4yqjjrxjznjhtuqqu5kdh
- Beta:
osmo1lltupx02sj99suakmuk4sr4ppqf34ajedaxut3ukjwkv6469erwqtpg9t3
Price Feed IDs
The price feed IDs for stable and edge feeds are different and can be found at the following links: