> For the complete documentation index, see [llms.txt](https://docs-v4.venus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-v4.venus.io/technical-reference/reference-oracle/oracles/chainlink-oracle.md).

# ChainlinkOracle

## ChainlinkOracle

This oracle fetches prices of assets from the Chainlink oracle.

## Solidity API

```solidity
struct TokenConfig {
  address asset;
  address feed;
  uint256 maxStalePeriod;
}
```

#### NATIVE\_TOKEN\_ADDR

Set this as asset address for native token on each chain. This is the underlying address for vBNB on BNB chain or an underlying asset for a native market on any chain.

```solidity
address NATIVE_TOKEN_ADDR
```

***

#### prices

Manually set an override price, useful under extenuating conditions such as price feed failure

```solidity
mapping(address => uint256) prices
```

***

#### tokenConfigs

Token config by assets

```solidity
mapping(address => struct ChainlinkOracle.TokenConfig) tokenConfigs
```

***

#### constructor

Constructor for the implementation contract.

```solidity
constructor() public
```

***

#### initialize

Initializes the owner of the contract

```solidity
function initialize(address accessControlManager_) external
```

**Parameters**

| Name                   | Type    | Description                                    |
| ---------------------- | ------- | ---------------------------------------------- |
| accessControlManager\_ | address | Address of the access control manager contract |

***

#### setDirectPrice

Manually set the price of a given asset

```solidity
function setDirectPrice(address asset, uint256 price) external
```

**Parameters**

| Name  | Type    | Description                |
| ----- | ------- | -------------------------- |
| asset | address | Asset address              |
| price | uint256 | Asset price in 18 decimals |

**📅 Events**

* Emits PricePosted event on succesfully setup of asset price

**⛔️ Access Requirements**

* Only Governance

***

#### setTokenConfigs

Add multiple token configs at the same time

```solidity
function setTokenConfigs(struct ChainlinkOracle.TokenConfig[] tokenConfigs_) external
```

**Parameters**

| Name           | Type                                  | Description  |
| -------------- | ------------------------------------- | ------------ |
| tokenConfigs\_ | struct ChainlinkOracle.TokenConfig\[] | config array |

**⛔️ Access Requirements**

* Only Governance

**❌ Errors**

* Zero length error thrown, if length of the array in parameter is 0

***

#### setTokenConfig

Add single token config. asset & feed cannot be null addresses and maxStalePeriod must be positive

```solidity
function setTokenConfig(struct ChainlinkOracle.TokenConfig tokenConfig) public
```

**Parameters**

| Name        | Type                               | Description         |
| ----------- | ---------------------------------- | ------------------- |
| tokenConfig | struct ChainlinkOracle.TokenConfig | Token config struct |

**📅 Events**

* Emits TokenConfigAdded event on succesfully setting of the token config

**⛔️ Access Requirements**

* Only Governance

**❌ Errors**

* NotNullAddress error is thrown if asset address is null
* NotNullAddress error is thrown if token feed address is null
* Range error is thrown if maxStale period of token is not greater than zero

***

#### getPrice

Gets the price of a asset from the chainlink oracle

```solidity
function getPrice(address asset) public view virtual returns (uint256)
```

**Parameters**

| Name  | Type    | Description          |
| ----- | ------- | -------------------- |
| asset | address | Address of the asset |

**Return Values**

| Name | Type    | Description                                                       |
| ---- | ------- | ----------------------------------------------------------------- |
| \[0] | uint256 | Price in USD from Chainlink or a manually set price for the asset |

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs-v4.venus.io/technical-reference/reference-oracle/oracles/chainlink-oracle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
