> For the complete documentation index, see [llms.txt](https://docs.kryptonite.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kryptonite.finance/developer/oracle.md).

# Oracle

Encapsulated the call to PythOracle.

## Config

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct Config {
    pub owner: CanonicalAddr,
    pub pyth_contract: CanonicalAddr,
    pub new_owner: Option<CanonicalAddr>,
}
```

<table><thead><tr><th width="184">Key</th><th width="199">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>CanonicalAddr</td><td>The address of the contract's owner</td></tr><tr><td>pyth_contract</td><td>CanonicalAddr</td><td>The address of pyth oracle contract</td></tr><tr><td>new_owner*</td><td>CanonicalAddr</td><td>The address of the contract's new owner</td></tr></tbody></table>

\* = optional

## InitMsg

```rust
#[cw_serde]
pub struct InstantiateMsg {
    pub pyth_contract: String,
    pub owner: Addr,
}
```

```json
{
  "owner": "sei...address...",
  "pyth_contract": "sei...address..."
}
```

<table><thead><tr><th width="193">Key</th><th width="203">Type</th><th>Description</th></tr></thead><tbody><tr><td>owner</td><td>string</td><td>The address of the contract's owner</td></tr><tr><td>pyth_contract</td><td>string</td><td>The address of pyth oracle contract</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

## ExecuteMsg

### ConfigFeedInfo&#x20;

Set the relevant information for updating oracle.

```rust
#[cw_serde]
pub enum ExecuteMsg {
    ConfigFeedInfo {
        asset: String,
        price_feed_id: String,
        price_feed_symbol: String,
        price_feed_decimal: u32,
        check_feed_age: bool,
        price_feed_age: u64,
    },
}
```

```
{
  "config_feed_info": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
    "price_feed_id": "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
    "price_feed_symbol": "Crypto.ETH/USD",
    "price_feed_decimal": 8,
    "price_feed_age": 360,
    "check_feed_age": true
  }
}
```

<table><thead><tr><th width="231">Key</th><th width="113">Type</th><th>Description</th></tr></thead><tbody><tr><td>asset</td><td>string</td><td>The address of the asset</td></tr><tr><td>price_feed_id</td><td>string</td><td>The pyth price feed id</td></tr><tr><td>price_feed_symbol</td><td>string</td><td>The pyth price feed symbol</td></tr><tr><td>price_feed_decimal</td><td>u32</td><td>The pyth price feed decimal</td></tr><tr><td>check_feed_age</td><td>bool</td><td>Whether to check the age of the price feed</td></tr><tr><td>price_feed_age</td><td>u64</td><td>The maximum age of the price feed in seconds</td></tr></tbody></table>

### ChangeOwner

Change the contract owner, only can issued by current owner.

```rust
#[cw_serde]
pub enum ExecuteMsg {
    ChangeOwner {
        new_owner: String,
    },
}
```

```json
{
  "change_owner": {
    "new_owner": "sei...addr..."
  }
}
```

<table><thead><tr><th width="176">Key</th><th width="217">Type</th><th>Description</th></tr></thead><tbody><tr><td>new_owner</td><td>string</td><td>The address of the new contract owner.</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### SetConfigFeedValid&#x20;

Set whether the oracle is available, the default is available, the type is bool.

```rust
#[cw_serde]
pub enum ExecuteMsg {
    SetConfigFeedValid {
        asset: String,
        valid: bool,
    },
}
```

```
{
  "set_config_feed_valid": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
    "valid": true
  }
}
```

<table><thead><tr><th width="151">Key</th><th width="169">Type</th><th>Description</th></tr></thead><tbody><tr><td>asset</td><td>string</td><td>The address of the asset</td></tr><tr><td>valid</td><td>bool</td><td>Whether the oracle is available</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### ChangePythContract&#x20;

Change the pyth contract address, only can issued by current owner.

```rust
#[cw_serde]
pub enum ExecuteMsg {
    ChangePythContract {
        pyth_contract: String,
    },
}
```

```
{
  "change_pyth_contract": {
    "pyth_contract": "sei...addr..."
  }
}
```

<table><thead><tr><th width="159">Key</th><th width="186">Type</th><th>Description</th></tr></thead><tbody><tr><td>pyth_contract</td><td>String</td><td>The pyth contract address</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

## QueryMsg

All query messages are described below. A custom struct is defined for each query response.

### QueryPrice

Returns the price of the asset.

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(PriceResponse)]
    QueryPrice { asset: String },
}
```

```
{
  "query_price": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
  }
}
```

<table><thead><tr><th width="170">Key</th><th width="179">Type</th><th>Description</th></tr></thead><tbody><tr><td>asset</td><td>string</td><td>The address of the asset</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### PriceResponse&#x20;

```rust
#[cw_serde]
pub struct PriceResponse {
    pub asset: String,
    pub emv_price: Decimal256,
    pub emv_price_raw: i64,
    pub price: Decimal256,
    pub price_raw: i64,
    pub last_updated_base: u64,
    pub last_updated_quote: u64,
}
```

```json
{
  "price_response": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
    "emv_price": "1.00000000",
    "emv_price_raw": 100000000,
    "price": "1.00000000",
    "price_raw": 100000000,
    "last_updated_base": 1634160000,
    "last_updated_quote": 1634160000
  }
}
```

<table><thead><tr><th width="209">Key</th><th width="115">Type</th><th>Description</th></tr></thead><tbody><tr><td>asset</td><td>string</td><td>The address of the asset</td></tr><tr><td>emv_price</td><td>decimal</td><td>The emv price of the asset in the base currency</td></tr><tr><td>emv_price_raw</td><td>i64</td><td>The emv price of the asset in the base currency, multiplied by 10^8</td></tr><tr><td>price</td><td>decimal</td><td>The price of the asset in the quote currency</td></tr><tr><td>price_raw</td><td>i64</td><td>The price of the asset in the quote currency, multiplied by 10^8</td></tr><tr><td>last_updated_base</td><td>u64</td><td>The timestamp of the last update of the price of the asset in the base currency</td></tr><tr><td>last_updated_quote</td><td>u64</td><td>The timestamp of the last update of the price of the asset in the quote currency</td></tr></tbody></table>

### QueryPrices&#x20;

Returns the prices of the assets.

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(Vec < PriceResponse >)]
    QueryPrices { assets: Vec<String> },
}
```

```json
{
  "query_prices": {
    "assets": [
      "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt",
      "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/eth"
    ]
  }
}
```

<table><thead><tr><th width="165">Key</th><th width="165">Type</th><th>Description</th></tr></thead><tbody><tr><td>assets</td><td>Vec&#x3C;String></td><td>The list of asset addresses</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### QueryConfig&#x20;

Returns information about global config.

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(ConfigResponse)]
    QueryConfig {},
}
```

```json
{
  "query_config": {}
}
```

### ConfigResponse&#x20;

```rust
#[cw_serde]
pub struct PythFeederConfigResponse {
    pub price_feed_id: PriceIdentifier,
    pub price_feed_symbol: String,
    pub price_feed_decimal: u32,
    pub price_feed_age: u64,
    pub check_feed_age: bool,
    pub is_valid: bool,
}
```

```json
{
  "config_response": {
    "price_feed_id": "fff...",
    "price_feed_symbol": "USDT",
    "price_feed_decimal": 6,
    "price_feed_age": 1634160000,
    "check_feed_age": true,
    "is_valid": true
  }
}
```

### QueryPythFeederConfig

Returns the pyth feeder config.

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(PythFeederConfigResponse)]
    QueryPythFeederConfig { asset: String },
}
```

```
{
  "query_pyth_feeder_config": {
    "asset": "factory/sei1h3ukufh4lhacftdf6kyxzum4p86rcnel35v4jk/usdt"
  }
}
```

<table><thead><tr><th width="158">Key</th><th width="144">Type</th><th>Description</th></tr></thead><tbody><tr><td>asset</td><td>string</td><td>The address of the asset</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

### PythFeederConfigResponse&#x20;

```rust
#[cw_serde]
pub struct PythFeederConfigResponse {
    pub price_feed_id: PriceIdentifier,
    pub price_feed_symbol: String,
    pub price_feed_decimal: u32,
    pub price_feed_age: u64,
    pub check_feed_age: bool,
    pub is_valid: bool,
}
```

```json
{
  "pyth_feeder_config_response": {
    "price_feed_id": "fff...",
    "price_feed_symbol": "USDT",
    "price_feed_decimal": 6,
    "price_feed_age": 1634160000,
    "check_feed_age": true,
    "is_valid": true
  }
}
```

<table><thead><tr><th width="210">Key</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>price_feed_id</td><td>string</td><td>The price feed id</td></tr><tr><td>price_feed_symbol</td><td>string</td><td>The price feed symbol</td></tr><tr><td>price_feed_decimal</td><td>u32</td><td>The price feed decimal</td></tr><tr><td>price_feed_age</td><td>u64</td><td>The price feed age</td></tr><tr><td>check_feed_age</td><td>bool</td><td>Whether to check the price feed age</td></tr><tr><td>is_valid</td><td>bool</td><td>Whether the config is valid</td></tr></tbody></table>

### QueryExchangeRateByAssetLabel&#x20;

Returns the exchange rate of the asset label.

```rust
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
    #[returns(Decimal256)]
    QueryExchangeRateByAssetLabel { base_label: String, quote_label: String },
}
```

```
{
  "query_exchange_rate_by_asset_label": {
    "base_label": "USDT",
    "quote_label": "ETH"
  }
}
```

<table><thead><tr><th width="185">Key</th><th width="177">Type</th><th>Description</th></tr></thead><tbody><tr><td>base_label</td><td>String</td><td>The base label</td></tr><tr><td>quote_label</td><td>String</td><td>The quote label</td></tr><tr><td></td><td></td><td></td></tr></tbody></table>
