LogoLogo
  • Overview
  • Learn
    • Lend
    • Borrow
    • Interest Rate
    • Liquidate
    • Flash Loans
    • NEPT Token
    • Risks
  • Develop
    • Contracts
      • Market
      • Interest Model
      • Token
      • Oracle
      • Querier
      • Flashloan Reciever
      • nToken
    • Token Addresses
  • User Guides
    • How to Lend on Neptune
    • How to Borrow on Neptune
    • How to Stake with the Neptune Validator
    • How to bridge TIA to Injective
  • Socials and Media
  • Audits
Powered by GitBook
On this page
  • Price Feeds
  • Query Messages
  • 1. Get Single Asset Price
  • 2. Get Multiple Asset Prices
  • 3. Get All Asset Prices
  • 4. Get Asset Details
  • Execute Messages
  • 1.1 Update Asset
  • 1.2 Update Asset (nToken)
  • 2. Update Prices
  1. Develop
  2. Contracts

Oracle

PreviousTokenNextQuerier

Last updated 2 months ago

Oracle Contract Address:

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:

{
  "get_price": {
    "asset": {
      "native_token": {
        "denom": "inj"
      }
    }
  }
}
Parameter
Type
Description
Required

asset

AssetInfo

Object specifying the asset to retrieve price data for. Must be either native_token or token object

Yes

native_token

object

Object containing native token information

Yes

denom

string

Token denomination (if using native_token) or contract address (if using token)

Yes

Query Response:

{
  "price": "15.57740357",
  "decimals": 18,
  "time_last_updated": "1740100674000000000",
  "confidence": "0.01633254"
}
Parameter
Type
Description

price

Decimal256

The reported asset price

decimals

u8

The number of decimals the price uses

time_last_updated

Timestamp

The timestamp indicating when the price was last updated

confidence

Decimal256

A measure of uncertainty associated with the reported price, as provided by Pyth


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:

{
  "get_prices": {
    "assets": [
      {
        "native_token": {
          "denom": "inj"
        }
      },
      {
        "token": {
          "contract_addr": "inj1zcwr03uqw57g88nqvgpwfkazwutpqz9kplny4s"
        }
      }
    ]
  }
}
Parameter
Type
Description
Required

assets

Array<AssetInfo>

An array of asset information objects to query prices for

Yes

assets.

native_token

object

Object representing a native token asset

Yes

assets.

native_token.

denom

string

The denomination of the native token

Yes

assets.

token

object

Object representing a CW20 token asset

Yes

assets.token.

contract_addr

Addr

The contract address of the token

Yes

*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:

[
  [
    {
      "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"
    }
  ]
]
Parameter
Type
Description

price

Decimal256

The reported asset price

decimals

u8

The number of decimals the price uses

time_last_updated

Timestamp

The timestamp indicating when the price was last updated

confidence

Decimal256

A measure of uncertainty associated with the reported price, as provided by Pyth


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:

{
  "get_all_prices": {
    "start_after": {
      "native_token": {
        "denom": "inj"
      }
    },
    "limit": 2
  }
}
Parameter
Type
Description
Required

start_after

AssetInfo

Object specifying which token to start after. If not used, returns all price data

No

limit

u32

How many records to fetch starting after target token

No

Query Response:

[
  [
    {
      "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"
    }
  ]
]
Parameter
Type
Description

price

Decimal256

The reported asset price

decimals

u8

The number of decimals the price uses

time_last_updated

Timestamp

The timestamp indicating when the price was last updated

confidence

Decimal256

A measure of uncertainty associated with the reported price, as provided by Pyth


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:

{
  "get_all_asset_details": {
    "start_after": {
      "native_token": {
        "denom": "inj"
      }
    },
    "limit": 10
  }
}
Parameter
Type
Description
Required

start_after

object

Object specifying which token to start after. If not used, returns all asset details

No

start_after.

native_token

object

Token type. Can be native_token or token

Yes

start_after.

native_token.

denom

object

Token address. Can be denom (IF native_token) or contract_address (IF token)

Yes

limit

object

How many records to fetch starting after target token

No

Query Response:

[
  [
    {
      "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:

{
  "update_asset": {
    "asset_details": {
      "pyth": {
        "decimals": 6,
        "price_id": "0xd9912df360b5b7f21a122f15bdd5e27f62ce5e72bd316c291f7c86620e07fb2a"
      }
    },
    "asset_info": {
      "native_token": {
        "denom": "factory/inj1n636d9gzrqggdk66n2f97th0x8yuhfrtx520e7/ausd"
      }
    }
  }
}
Parameter
Type
Description
Required

asset_details

OracleAssetDetails

An object that contains the asset configuration

Yes

asset_details.

pyth

object

Oracle source feed type.

Can be Pyth, Ojo, Regular, or ReceiptToken

Yes

asset_details.

pyth.

decimals

u8

Decimal precision of target token

Yes

asset_details.

price_id

string

The price ID string provided by the oracle source

Yes

asset_info

AssetInfo

An object that uniquely identifies the asset. Use either the native_token field (with its denom) or the token field (with its contract_addr).

Yes

1.2 Update Asset (nToken)

Execute: update_asset

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

Execute Input:

{
  "update_asset": {
    "asset_details": {
      "receipt_token": {
        "origin_info": {
          "native_token": {
            "denom": "factory/inj1n636d9gzrqggdk66n2f97th0x8yuhfrtx520e7/ausd"
          }
        }
      }
    },
    "asset_info": {
      "token": {
        "contract_addr": "inj1tkuemghm734h9qy8fh2eu0qp9hyfdlws0llt8g"
      }
    }
  }
}
Parameter
Type
Description
Required

asset_details

object

Contains details of the asset

Yes

asset_details.

receipt_token

object

Specifies receipt token information

Yes

asset_details.

receipt_token.

origin_info

object

Origin details of the receipt token

Yes

asset_details.

receipt_token.

origin_info.

native_token

object

Native token details

Yes

asset_details.

receipt_token.

origin_info.

native_token.

denom

string

The denomination identifier for the native token

Yes

asset_info

object

Contains asset identification details

Yes

asset_info.

token

object

Token contract details

Yes

asset_info.

token.

contract_addr

string

The contract address of the token

Yes

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:

{
  "update_prices": {
    "assets": [
      [
        {
          "native_token": {
            "denom": "inj"
          }
        },
        {
          "price": "15.53999517",
          "confidence": "0.01621974"
        }
      ],
      [
        {
          "token": {
            "contract_addr": "inj1zcwr03uqw57g88nqvgpwfkazwutpqz9kplny4s"
          }
        },
        {
          "price": "175.038099535824850751",
          "confidence": "0.082077403813169304"
        }
      ]
    ]
  }
}
Parameter
Type
Description
Required

assets

Array<[AssetInfo, UpdatePrice]>

An array of tuples containing asset info and price update information

Yes

assets[].

price

Decimal256

New price for target token

Yes

assets[].

confidence

Decimal256

New confidence value for target token

Yes

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.

inj1u6cclz0qh5tep9m2qayry9k97dm46pnlqf8nre