Skip to content

Commit f9bd9e8

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

1 file changed

Lines changed: 64 additions & 12 deletions

File tree

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

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,61 @@
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

5-
import { Callout } from "@/components/ui";
6+
<Info>
7+
The Oracle Precompile is not yet available.
8+
In the meantime, you can query prices using one of the approaches described below.
9+
</Info>
610

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>
11+
Injective offers multiple ways to access oracle price data depending on your architecture and requirements.
12+
The following approaches range from querying Injective's native oracle module directly, to integrating with Pyth off-chain,
13+
to reading Pyth prices on-chain through Injective's EVM.
1214

13-
## Querying Pyth Prices on Injective EVM
15+
## Approach 1: Query the native oracle module
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+
You can query price data directly from Injective's native [oracle module](/developers-native/injective/oracle/index),
18+
which aggregates feeds from multiple providers including Band, Coinbase, and Pyth.
1619

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

1960
| Asset | Price Feed ID |
2061
| -------- | -------------------------------------------------------------------- |
@@ -25,6 +66,15 @@ Pyth is deployed at `0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320` on Injective's
2566
| USDT/USD | `0x2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b` |
2667
| USDC/USD | `0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a` |
2768

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

123-
<Callout type="info">
173+
<Warning>
124174
`getPriceUnsafe` returns the last pushed price without a staleness check. For
125175
production use, prefer `getPriceNoOlderThan(priceFeedId, maxAge)` — but note
126176
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>
177+
call will revert.
178+
See the [Pyth documentation](https://docs.pyth.network/price-feeds/use-real-time-data/evm)
179+
for more details on the pull model.
180+
</Warning>

0 commit comments

Comments
 (0)