# Oracle

Oracle Contract Address: [inj1u6cclz0qh5tep9m2qayry9k97dm46pnlqf8nre](https://injscan.com/contract/inj1u6cclz0qh5tep9m2qayry9k97dm46pnlqf8nre/)

The **Oracle Contract** is service developed to provide accurate and timely asset pricing data. It aggregates pricing information from multiple sources (e.g., Pyth, Ojo, and on-chain feeds) and supplies these data to other protocol modules such as the market and querier contracts. This ensures that collateral values and debt positions are evaluated based on current market prices.

***

## Price Feeds

Multiple price feeds can be utilised in the oracle contract to retrieve a source of truth for asset price data, including external sources like Pyth that push price updates to chain or utilising on-chain markets to aggregate asset price.

***

## Query Messages

### 1. Get Single Asset Price

The Oracle contract retrieves the current price information for a specified asset.

Query: `get_price`

**Purpose:**\
Retrieves the latest price data for a given asset.

**Query Input:**

```json
{
  "get_price": {
    "asset": {
      "native_token": {
        "denom": "inj"
      }
    }
  }
}
```

<table><thead><tr><th width="177">Parameter</th><th width="130">Type</th><th width="331">Description</th><th>Required</th></tr></thead><tbody><tr><td><code>asset</code></td><td><code>AssetInfo</code></td><td>Object specifying the asset to retrieve price data for. Must be either <code>native_token</code> or <code>token</code> object</td><td>Yes</td></tr><tr><td><code>native_token</code></td><td><code>object</code></td><td>Object containing native token information</td><td>Yes</td></tr><tr><td><code>denom</code></td><td><code>string</code></td><td>Token denomination (if using <code>native_token</code>) or contract address (if using <code>token</code>)</td><td>Yes</td></tr></tbody></table>

**Query Response:**

```json
{
  "price": "15.57740357",
  "decimals": 18,
  "time_last_updated": "1740100674000000000",
  "confidence": "0.01633254"
}
```

<table><thead><tr><th width="225">Parameter</th><th width="139">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>price</code></td><td><code>Decimal256</code></td><td>The reported asset price</td></tr><tr><td><code>decimals</code></td><td><code>u8</code></td><td>The number of decimals the price uses</td></tr><tr><td><code>time_last_updated</code></td><td><code>Timestamp</code></td><td>The timestamp indicating when the price was last updated</td></tr><tr><td><code>confidence</code></td><td><code>Decimal256</code></td><td>A measure of uncertainty associated with the reported price, as provided by Pyth</td></tr></tbody></table>

***

### 2. Get Multiple Asset Prices

This query retrieves pricing data for a list of specified assets simultaneously.

Query: `get_prices`

**Purpose:**\
Retrieves the price information for multiple assets in a single query.

**Query Input:**

```json
{
  "get_prices": {
    "assets": [
      {
        "native_token": {
          "denom": "inj"
        }
      },
      {
        "token": {
          "contract_addr": "inj1zcwr03uqw57g88nqvgpwfkazwutpqz9kplny4s"
        }
      }
    ]
  }
}
```

<table><thead><tr><th width="190">Parameter</th><th width="197">Type</th><th width="260">Description</th><th>Required</th></tr></thead><tbody><tr><td><code>assets</code></td><td><code>Array&#x3C;AssetInfo></code></td><td>An array of asset information objects to query prices for</td><td>Yes</td></tr><tr><td><p><code>assets.</code></p><p><strong><code>native_token</code></strong></p></td><td><code>object</code></td><td>Object representing a native token asset</td><td>Yes</td></tr><tr><td><p><code>assets.</code></p><p><code>native_token.</code></p><p><strong><code>denom</code></strong></p></td><td><code>string</code></td><td>The denomination of the native token</td><td>Yes</td></tr><tr><td><p><code>assets.</code></p><p><strong><code>token</code></strong></p></td><td><code>object</code></td><td>Object representing a CW20 token asset</td><td>Yes</td></tr><tr><td><p><code>assets.token.</code></p><p><strong><code>contract_addr</code></strong></p></td><td><code>Addr</code></td><td>The contract address of the token</td><td>Yes</td></tr></tbody></table>

\*Note: For each asset in the `assets` array, you should use *either* the `native_token` object (with its `denom`) *or* the `token` object (with its `contract_addr`), depending on the asset type.

**Query Response:**

```json
[
  [
    {
      "native_token": {
        "denom": "inj"
      }
    },
    {
      "price": "15.53999517",
      "decimals": 18,
      "time_last_updated": "1740101464000000000",
      "confidence": "0.01621974"
    }
  ],
  [
    {
      "token": {
        "contract_addr": "inj1zcwr03uqw57g88nqvgpwfkazwutpqz9kplny4s"
      }
    },
    {
      "price": "175.038099535824850751",
      "decimals": 8,
      "time_last_updated": "1740101464000000000",
      "confidence": "0.082077403813169304"
    }
  ]
]
```

<table><thead><tr><th width="225">Parameter</th><th width="141">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>price</code></td><td><code>Decimal256</code></td><td>The reported asset price</td></tr><tr><td><code>decimals</code></td><td><code>u8</code></td><td>The number of decimals the price uses</td></tr><tr><td><code>time_last_updated</code></td><td><code>Timestamp</code></td><td>The timestamp indicating when the price was last updated</td></tr><tr><td><code>confidence</code></td><td><code>Decimal256</code></td><td>A measure of uncertainty associated with the reported price, as provided by Pyth</td></tr></tbody></table>

***

### 3. Get All Asset Prices

The query supports pagination to retrieve pricing data for all registered assets.

Query: `get_all_prices`

**Purpose:**\
Retrieves price information for all supported assets, with optional pagination.

**Query Input:**

```json
{
  "get_all_prices": {
    "start_after": {
      "native_token": {
        "denom": "inj"
      }
    },
    "limit": 2
  }
}
```

<table><thead><tr><th width="168">Parameter</th><th width="119">Type</th><th width="363">Description</th><th>Required</th></tr></thead><tbody><tr><td><code>start_after</code></td><td><code>AssetInfo</code></td><td>Object specifying which token to start after. If not used, returns all price data</td><td>No</td></tr><tr><td><code>limit</code></td><td><code>u32</code></td><td>How many records to fetch starting after target token</td><td>No</td></tr></tbody></table>

**Query Response:**

```json
[
  [
    {
      "native_token": {
        "denom": "peggy0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
      }
    },
    {
      "price": "2739.45",
      "decimals": 18,
      "time_last_updated": "1740101929000000000",
      "confidence": "1.52228659"
    }
  ],
  [
    {
      "native_token": {
        "denom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7"
      }
    },
    {
      "price": "1.0002227",
      "decimals": 6,
      "time_last_updated": "1740101929000000000",
      "confidence": "0.00124156"
    }
  ]
]
```

<table><thead><tr><th width="225">Parameter</th><th width="142">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>price</code></td><td><code>Decimal256</code></td><td>The reported asset price</td></tr><tr><td><code>decimals</code></td><td><code>u8</code></td><td>The number of decimals the price uses</td></tr><tr><td><code>time_last_updated</code></td><td><code>Timestamp</code></td><td>The timestamp indicating when the price was last updated</td></tr><tr><td><code>confidence</code></td><td><code>Decimal256</code></td><td>A measure of uncertainty associated with the reported price, as provided by Pyth</td></tr></tbody></table>

***

### 4. Get Asset Details

This query retrieves detailed oracle asset information, including metadata about the price source or asset type.

Query: `get_all_asset_details`

**Purpose:**\
Retrieves detailed configurations of all asset entries stored in the Oracle, such as the oracle type (e.g., Pyth, Ojo, Regular, or Receipt Token).

**Query Input:**

```json
{
  "get_all_asset_details": {
    "start_after": {
      "native_token": {
        "denom": "inj"
      }
    },
    "limit": 10
  }
}
```

<table><thead><tr><th width="185">Parameter</th><th width="102">Type</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td><code>start_after</code></td><td><code>object</code></td><td>Object specifying which token to start after. If not used, returns all asset details</td><td>No</td></tr><tr><td><p><code>start_after.</code></p><p><strong><code>native_token</code></strong></p></td><td><code>object</code></td><td>Token type.<br>Can be <code>native_token</code> or <code>token</code></td><td>Yes</td></tr><tr><td><p><code>start_after.</code></p><p><code>native_token.</code></p><p><strong><code>denom</code></strong></p></td><td><code>object</code></td><td>Token address.<br>Can be <code>denom</code> (IF <code>native_token</code>) or <code>contract_address</code> (IF <code>token</code>)</td><td>Yes</td></tr><tr><td><code>limit</code></td><td><code>object</code></td><td>How many records to fetch starting after target token</td><td>No</td></tr></tbody></table>

**Query Response:**

```json
[
  [
    {
      "native_token": {
        "denom": "factory/inj1n636d9gzrqggdk66n2f97th0x8yuhfrtx520e7/ausd"
      }
    },
    {
      "pyth": {
        "price_id": "0xd9912df360b5b7f21a122f15bdd5e27f62ce5e72bd316c291f7c86620e07fb2a",
        "decimals": 6
      }
    }
  ],
  [
    {
      "native_token": {
        "denom": "factory/inj1v3a4zznudwpukpr8y987pu5gnh4xuf7v36jhva/nept"
      }
    },
    {
      "regular": {
        "price_info": {
          "price": "0.373738907677827617",
          "decimals": 6,
          "time_last_updated": "1740102142889585199",
          "confidence": "0"
        }
      }
    }
  ],
  [
    {
      "token": {
        "contract_addr": "inj16jf4qkcarp3lan4wl2qkrelf4kduvvujwg0780"
      }
    },
    {
      "receipt_token": {
        "origin_info": {
          "native_token": {
            "denom": "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9"
          }
        }
      }
    }
  ]
]
```

*In this response, each asset is mapped to its detailed oracle configuration. For example, a "Regular" asset directly contains its current `price_info`, while tokens relying on an external feed (e.g., Pyth) include details like the symbol and decimal precision.*

***

## Execute Messages

### 1.1 Update Asset

Execute: `update_asset`

**Purpose:** Adds a new asset or updates the details of an existing asset in the Oracle. This message registers asset metadata—including the source of pricing data (e.g., Regular, Pyth, Ojo, or Receipt Token)—and, when applicable, its current price information.

**Execute Input:**

```json
{
  "update_asset": {
    "asset_details": {
      "pyth": {
        "decimals": 6,
        "price_id": "0xd9912df360b5b7f21a122f15bdd5e27f62ce5e72bd316c291f7c86620e07fb2a"
      }
    },
    "asset_info": {
      "native_token": {
        "denom": "factory/inj1n636d9gzrqggdk66n2f97th0x8yuhfrtx520e7/ausd"
      }
    }
  }
}
```

<table><thead><tr><th width="206">Parameter</th><th width="144">Type</th><th width="297">Description</th><th>Required</th></tr></thead><tbody><tr><td><code>asset_details</code></td><td><code>OracleAssetDetails</code></td><td>An object that contains the asset configuration</td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><strong><code>pyth</code></strong></p></td><td><code>object</code></td><td><p>Oracle source feed type.</p><p>Can be <code>Pyth</code>, <code>Ojo</code>, <code>Regular</code>, or <code>ReceiptToken</code></p></td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><code>pyth.</code></p><p><strong><code>decimals</code></strong></p></td><td><code>u8</code></td><td>Decimal precision of target token</td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><strong><code>price_id</code></strong></p></td><td><code>string</code></td><td>The price ID string provided by the oracle source</td><td>Yes</td></tr><tr><td><code>asset_info</code></td><td><code>AssetInfo</code></td><td>An object that uniquely identifies the asset. Use either the <code>native_token</code> field (with its <code>denom</code>) or the <code>token</code> field (with its <code>contract_addr</code>).</td><td>Yes</td></tr></tbody></table>

### 1.2 Update Asset (nToken)

Execute: <kbd>update\_asset</kbd>

**Purpose:** Adding a receipt token, nToken, to the oracle requires the origin path to its original token

**Execute Input:**

```json
{
  "update_asset": {
    "asset_details": {
      "receipt_token": {
        "origin_info": {
          "native_token": {
            "denom": "factory/inj1n636d9gzrqggdk66n2f97th0x8yuhfrtx520e7/ausd"
          }
        }
      }
    },
    "asset_info": {
      "token": {
        "contract_addr": "inj1tkuemghm734h9qy8fh2eu0qp9hyfdlws0llt8g"
      }
    }
  }
}
```

<table><thead><tr><th width="203">Parameter</th><th width="105">Type</th><th width="321">Description</th><th>Required</th></tr></thead><tbody><tr><td><code>asset_details</code></td><td><code>object</code></td><td>Contains details of the asset</td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><strong><code>receipt_token</code></strong></p></td><td><code>object</code></td><td>Specifies receipt token information</td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><code>receipt_token.</code></p><p><strong><code>origin_info</code></strong></p></td><td><code>object</code></td><td>Origin details of the receipt token</td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><code>receipt_token.</code></p><p><code>origin_info.</code></p><p><strong><code>native_token</code></strong></p></td><td><code>object</code></td><td>Native token details</td><td>Yes</td></tr><tr><td><p><code>asset_details.</code></p><p><code>receipt_token.</code></p><p><code>origin_info.</code></p><p><code>native_token.</code></p><p><strong><code>denom</code></strong></p></td><td><code>string</code></td><td>The denomination identifier for the native token</td><td>Yes</td></tr><tr><td><code>asset_info</code></td><td><code>object</code></td><td>Contains asset identification details</td><td>Yes</td></tr><tr><td><p><code>asset_info.</code></p><p><strong><code>token</code></strong></p></td><td><code>object</code></td><td>Token contract details</td><td>Yes</td></tr><tr><td><p><code>asset_info.</code></p><p><code>token.</code></p><p><strong><code>contract_addr</code></strong></p></td><td><code>string</code></td><td>The contract address of the token</td><td>Yes</td></tr></tbody></table>

### 2. Update Prices

Execute: `update_prices`

**Purpose:** Updates the prices of multiple assets in a single transaction. This message is useful for batch-updating price information for various assets. The block's timestamp is automatically used to update the `time_last_updated` field.

**Execute Input:**

```json
{
  "update_prices": {
    "assets": [
      [
        {
          "native_token": {
            "denom": "inj"
          }
        },
        {
          "price": "15.53999517",
          "confidence": "0.01621974"
        }
      ],
      [
        {
          "token": {
            "contract_addr": "inj1zcwr03uqw57g88nqvgpwfkazwutpqz9kplny4s"
          }
        },
        {
          "price": "175.038099535824850751",
          "confidence": "0.082077403813169304"
        }
      ]
    ]
  }
}
```

<table><thead><tr><th width="175">Parameter</th><th width="140">Type</th><th width="297">Description</th><th>Required</th></tr></thead><tbody><tr><td><code>assets</code></td><td><code>Array&#x3C;[AssetInfo, UpdatePrice]></code></td><td>An array of tuples containing asset info and price update information</td><td>Yes</td></tr><tr><td><p><code>assets[].</code></p><p><strong><code>price</code></strong></p></td><td><code>Decimal256</code></td><td>New price for target token</td><td>Yes</td></tr><tr><td><p><code>assets[].</code></p><p><strong><code>confidence</code></strong></p></td><td><code>Decimal256</code></td><td>New confidence value for target token</td><td>Yes</td></tr></tbody></table>

**Note:**

* For each asset entry in the `assets` array, the first element identifies the asset and the second element provides the new price data.
* The `time_last_updated` field is automatically set to the current block time.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nept.finance/develop/contracts/oracle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
