From f9bd9e8eb4ec05d6dbe7b1bd4f5a8b7340d01986 Mon Sep 17 00:00:00 2001 From: Brendan Graetz Date: Wed, 25 Mar 2026 22:29:34 +0800 Subject: [PATCH 1/3] docs: more detailed oracle docs Signed-off-by: Brendan Graetz --- .gitbook/developers-evm/oracle-precompile.mdx | 76 ++++++++++++++++--- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/.gitbook/developers-evm/oracle-precompile.mdx b/.gitbook/developers-evm/oracle-precompile.mdx index dcaecf43..bdbc5dcd 100644 --- a/.gitbook/developers-evm/oracle-precompile.mdx +++ b/.gitbook/developers-evm/oracle-precompile.mdx @@ -1,20 +1,61 @@ --- title: Oracle Precompile +description: Approaches for querying price data on Injective, including native oracle queries, off-chain Pyth, and on-chain Pyth via EVM. --- -import { Callout } from "@/components/ui"; + + The Oracle Precompile is not yet available. + In the meantime, you can query prices using one of the approaches described below. + - - The Oracle Precompile is not yet available. In the meantime, you can query - prices directly from the Pyth contract deployed on Injective's EVM. Note that - not all price feeds are available — see the supported feeds below. - +Injective offers multiple ways to access oracle price data depending on your architecture and requirements. +The following approaches range from querying Injective's native oracle module directly, to integrating with Pyth off-chain, +to reading Pyth prices on-chain through Injective's EVM. -## Querying Pyth Prices on Injective EVM +## Approach 1: Query the native oracle module -Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM. You can use it to query prices for the supported feeds listed below. +You can query price data directly from Injective's native [oracle module](/developers-native/injective/oracle/index), +which aggregates feeds from multiple providers including Band, Coinbase, and Pyth. -### Supported Feeds +The [injective-price-oracle](https://github.com/InjectiveLabs/injective-price-oracle) repository +provides a reference implementation for querying the native oracle module programmatically. +This approach is well-suited for applications that need access to Injective-native price feeds without relying on third-party EVM contracts. + +For full details on the oracle module's state, messages, and supported providers, +see the [oracle module documentation](/developers-native/injective/oracle/index). + +## Approach 2: Off-chain price feeds with Pyth + +If your application fetches prices off-chain (for example, in a backend service or bot), +you can query Pyth's HTTP API directly without any on-chain interaction. + +Refer to the Pyth documentation on [fetching price updates](https://docs.pyth.network/price-feeds/core/fetch-price-updates) +for details on available endpoints, request formats, and response schemas. + +This approach is ideal for off-chain trading systems, analytics dashboards, +or any service that requires price data without submitting transactions. + +## Approach 3: On-chain price feeds with Pyth (EVM) + +For smart contracts that need to read prices on-chain, you can interact with the Pyth contract deployed on Injective's EVM. +This uses Pyth's pull-based oracle model, where price updates are fetched off-chain and submitted on-chain before reading. + +### Contract addresses + +To obtain the Pyth contract address for Injective EVM, refer to the Pyth contract addresses page and locate the **Injective EVM** entry: + +- [Mainnet contract addresses](https://docs.pyth.network/price-feeds/core/contract-addresses/evm#mainnets) +- [Testnet contract addresses](https://docs.pyth.network/price-feeds/core/contract-addresses/evm#testnets) + +Currently, Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM mainnet. + +### Price feed IDs + +Each asset pair has a unique price feed ID. You can look up feed IDs on +the [Pyth price feed IDs](https://docs.pyth.network/price-feeds/core/price-feeds/price-feed-ids) page. +For example, search for `INJ/USD`. + +### Supported feeds | Asset | Price Feed ID | | -------- | -------------------------------------------------------------------- | @@ -25,6 +66,15 @@ Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's | USDT/USD | `0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b` | | USDC/USD | `0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a` | +### Integration guide + +For a complete walkthrough of integrating Pyth price feeds into your Solidity contracts using the pull model, +follow the [Pyth EVM pull integration tutorial](https://docs.pyth.network/price-feeds/core/use-real-time-data/pull-integration/evm). + +### Example + +The following example demonstrates how to read the INJ/USD price from the Pyth contract on Injective's EVM: + ```typescript import { ethers } from "ethers"; import { toHumanReadable } from "@injectivelabs/utils"; @@ -120,9 +170,11 @@ async function main() { main().catch(console.error); ``` - + `getPriceUnsafe` returns the last pushed price without a staleness check. For production use, prefer `getPriceNoOlderThan(priceFeedId, maxAge)` — but note this requires the price to have been pushed on-chain recently, otherwise the - call will revert. See the [Pyth documentation](https://docs.pyth.network/price-feeds/use-real-time-data/evm) for more details on the pull model. - + call will revert. + See the [Pyth documentation](https://docs.pyth.network/price-feeds/use-real-time-data/evm) + for more details on the pull model. + From 4561f55823d30e7046ac2a359b1362bb1762f7dc Mon Sep 17 00:00:00 2001 From: Brendan Graetz Date: Thu, 26 Mar 2026 15:34:20 +0800 Subject: [PATCH 2/3] docs: minor - fixes from gen ai code review Signed-off-by: Brendan Graetz --- .gitbook/developers-evm/oracle-precompile.mdx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitbook/developers-evm/oracle-precompile.mdx b/.gitbook/developers-evm/oracle-precompile.mdx index bdbc5dcd..b2ecf23b 100644 --- a/.gitbook/developers-evm/oracle-precompile.mdx +++ b/.gitbook/developers-evm/oracle-precompile.mdx @@ -49,6 +49,10 @@ To obtain the Pyth contract address for Injective EVM, refer to the Pyth contrac Currently, Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM mainnet. + + Always consult the official documentation to obtain up-to-date addresses. + + ### Price feed IDs Each asset pair has a unique price feed ID. You can look up feed IDs on @@ -66,6 +70,10 @@ For example, search for `INJ/USD`. | USDT/USD | `0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b` | | USDC/USD | `0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a` | + + Always consult the official documentation to obtain up-to-date addresses. + + ### Integration guide For a complete walkthrough of integrating Pyth price feeds into your Solidity contracts using the pull model, @@ -152,7 +160,9 @@ async function main() { const priceFeedId = "0x7a5bc1d2b56ad029048cd63964b3ad2776eadf812edc1a43a31406cb54bff592"; // INJ/USD - const price = await pyth.getPriceUnsafe(priceFeedId); + // const price = await pyth.getPriceUnsafe(priceFeedId); + const maxAge = 60; // 60s + const price = await pyth.getPriceNoOlderThan(priceFeedId, maxAge); console.log( "Human readable price:", From 5f41d33170a491736340b365e3ba39d4309501f4 Mon Sep 17 00:00:00 2001 From: Brendan Graetz Date: Thu, 26 Mar 2026 15:36:11 +0800 Subject: [PATCH 3/3] docs: remove 1 out of the 3 approach, as that was for setting rather than querying oracle data, and thus irrelevant Signed-off-by: Brendan Graetz --- .gitbook/developers-evm/oracle-precompile.mdx | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.gitbook/developers-evm/oracle-precompile.mdx b/.gitbook/developers-evm/oracle-precompile.mdx index b2ecf23b..764469af 100644 --- a/.gitbook/developers-evm/oracle-precompile.mdx +++ b/.gitbook/developers-evm/oracle-precompile.mdx @@ -9,22 +9,10 @@ description: Approaches for querying price data on Injective, including native o Injective offers multiple ways to access oracle price data depending on your architecture and requirements. -The following approaches range from querying Injective's native oracle module directly, to integrating with Pyth off-chain, +The following approaches range from integrating with Pyth off-chain, to reading Pyth prices on-chain through Injective's EVM. -## Approach 1: Query the native oracle module - -You can query price data directly from Injective's native [oracle module](/developers-native/injective/oracle/index), -which aggregates feeds from multiple providers including Band, Coinbase, and Pyth. - -The [injective-price-oracle](https://github.com/InjectiveLabs/injective-price-oracle) repository -provides a reference implementation for querying the native oracle module programmatically. -This approach is well-suited for applications that need access to Injective-native price feeds without relying on third-party EVM contracts. - -For full details on the oracle module's state, messages, and supported providers, -see the [oracle module documentation](/developers-native/injective/oracle/index). - -## Approach 2: Off-chain price feeds with Pyth +## Approach 1: Off-chain price feeds with Pyth If your application fetches prices off-chain (for example, in a backend service or bot), you can query Pyth's HTTP API directly without any on-chain interaction. @@ -35,7 +23,7 @@ for details on available endpoints, request formats, and response schemas. This approach is ideal for off-chain trading systems, analytics dashboards, or any service that requires price data without submitting transactions. -## Approach 3: On-chain price feeds with Pyth (EVM) +## Approach 2: On-chain price feeds with Pyth (EVM) For smart contracts that need to read prices on-chain, you can interact with the Pyth contract deployed on Injective's EVM. This uses Pyth's pull-based oracle model, where price updates are fetched off-chain and submitted on-chain before reading.