Skip to content

Commit b787e4e

Browse files
committed
docs: more detailed oracle docs
Signed-off-by: Brendan Graetz <bguiz@users.noreply.github.com>
1 parent 44289a4 commit b787e4e

1 file changed

Lines changed: 65 additions & 11 deletions

File tree

.gitbook/developers-evm/oracle-precompile.mdx

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,63 @@
11
---
22
title: Oracle Precompile
3+
description: Approaches for querying price data on Injective, including native oracle queries, off-chain Pyth, and on-chain Pyth via EVM.
34
---
45

56
import { Callout } from "@/components/ui";
67

7-
<Callout type="warning">
8-
The Oracle Precompile is not yet available. In the meantime, you can query
9-
prices directly from the Pyth contract deployed on Injective's EVM. Note that
10-
not all price feeds are available — see the supported feeds below.
11-
</Callout>
8+
<Info>
9+
The Oracle Precompile is not yet available.
10+
In the meantime, you can query prices using one of the approaches described below.
11+
</Info>
1212

13-
## Querying Pyth Prices on Injective EVM
13+
Injective offers multiple ways to access oracle price data depending on your architecture and requirements.
14+
The following approaches range from querying Injective's native oracle module directly, to integrating with Pyth off-chain,
15+
to reading Pyth prices on-chain through Injective's EVM.
1416

15-
Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM. You can use it to query prices for the supported feeds listed below.
17+
## Approach 1: Query the native oracle module
1618

17-
### Supported Feeds
19+
You can query price data directly from Injective's native [oracle module](/developers-native/injective/oracle/index),
20+
which aggregates feeds from multiple providers including Band, Coinbase, and Pyth.
21+
22+
The [injective-price-oracle](https://github.com/InjectiveLabs/injective-price-oracle) repository
23+
provides a reference implementation for querying the native oracle module programmatically.
24+
This approach is well-suited for applications that need access to Injective-native price feeds without relying on third-party EVM contracts.
25+
26+
For full details on the oracle module's state, messages, and supported providers,
27+
see the [oracle module documentation](/developers-native/injective/oracle/index).
28+
29+
## Approach 2: Off-chain price feeds with Pyth
30+
31+
If your application fetches prices off-chain (for example, in a backend service or bot),
32+
you can query Pyth's HTTP API directly without any on-chain interaction.
33+
34+
Refer to the Pyth documentation on [fetching price updates](https://docs.pyth.network/price-feeds/core/fetch-price-updates)
35+
for details on available endpoints, request formats, and response schemas.
36+
37+
This approach is ideal for off-chain trading systems, analytics dashboards,
38+
or any service that requires price data without submitting transactions.
39+
40+
## Approach 3: On-chain price feeds with Pyth (EVM)
41+
42+
For smart contracts that need to read prices on-chain, you can interact with the Pyth contract deployed on Injective's EVM.
43+
This uses Pyth's pull-based oracle model, where price updates are fetched off-chain and submitted on-chain before reading.
44+
45+
### Contract addresses
46+
47+
To obtain the Pyth contract address for Injective EVM, refer to the Pyth contract addresses page and locate the **Injective EVM** entry:
48+
49+
- [Mainnet contract addresses](https://docs.pyth.network/price-feeds/core/contract-addresses/evm#mainnets)
50+
- [Testnet contract addresses](https://docs.pyth.network/price-feeds/core/contract-addresses/evm#testnets)
51+
52+
Currently, Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's EVM mainnet.
53+
54+
### Price feed IDs
55+
56+
Each asset pair has a unique price feed ID. You can look up feed IDs on
57+
the [Pyth price feed IDs](https://docs.pyth.network/price-feeds/core/price-feeds/price-feed-ids) page.
58+
For example, search for `INJ/USD`.
59+
60+
### Supported feeds
1861

1962
| Asset | Price Feed ID |
2063
| -------- | -------------------------------------------------------------------- |
@@ -25,6 +68,15 @@ Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's
2568
| USDT/USD | `0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b` |
2669
| USDC/USD | `0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a` |
2770

71+
### Integration guide
72+
73+
For a complete walkthrough of integrating Pyth price feeds into your Solidity contracts using the pull model,
74+
follow the [Pyth EVM pull integration tutorial](https://docs.pyth.network/price-feeds/core/use-real-time-data/pull-integration/evm).
75+
76+
### Example
77+
78+
The following example demonstrates how to read the INJ/USD price from the Pyth contract on Injective's EVM:
79+
2880
```typescript
2981
import { ethers } from "ethers";
3082
import { toHumanReadable } from "@injectivelabs/utils";
@@ -120,9 +172,11 @@ async function main() {
120172
main().catch(console.error);
121173
```
122174

123-
<Callout type="info">
175+
<Warning>
124176
`getPriceUnsafe` returns the last pushed price without a staleness check. For
125177
production use, prefer `getPriceNoOlderThan(priceFeedId, maxAge)` — but note
126178
this requires the price to have been pushed on-chain recently, otherwise the
127-
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.
128-
</Callout>
179+
call will revert.
180+
See the [Pyth documentation](https://docs.pyth.network/price-feeds/use-real-time-data/evm)
181+
for more details on the pull model.
182+
</Warning>

0 commit comments

Comments
 (0)