> For the complete documentation index, see [llms.txt](https://developers.term.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.term.finance/latest/protocol-class/termpriceconsumerv3.md).

# TermPriceConsumerV3.sol

## TermPriceConsumerV3

This contract is a centralized price oracle contract that feeds pricing data to all Term Repos

*This contract operates at the protocol level and governs all instances of a Term Repo*

### DEVOPS\_ROLE

```solidity
bytes32 DEVOPS_ROLE
```

### DEFAULT\_MAX\_DATA\_TIMESTAMP\_AHEAD\_SECONDS

```solidity
uint256 DEFAULT_MAX_DATA_TIMESTAMP_AHEAD_SECONDS
```

### priceFeeds

```solidity
mapping(address => struct TermPriceFeedConfig) priceFeeds
```

### fallbackPriceFeeds

```solidity
mapping(address => struct TermPriceFeedConfig) fallbackPriceFeeds
```

### constructor

```solidity
constructor() public
```

### initialize

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

Intializes with an array of token addresses, followed with an array of Chainlink aggregator addresses <https://docs.chain.link/docs/ethereum-addresses/>

### usdValueOfTokens

```solidity
function usdValueOfTokens(address token, uint256 amount) external view returns (struct ExponentialNoError.Exp)
```

A function to return current market value given a token address and an amount

#### Parameters

| Name   | Type    | Description                       |
| ------ | ------- | --------------------------------- |
| token  | address | The address of the token to query |
| amount | uint256 | The amount tokens to value        |

#### Return Values

| Name | Type                          | Description                                                        |
| ---- | ----------------------------- | ------------------------------------------------------------------ |
| \[0] | struct ExponentialNoError.Exp | The current market value of tokens at the specified amount, in USD |

### addNewTokenPriceFeedAndFallbackPriceFeed

```solidity
function addNewTokenPriceFeedAndFallbackPriceFeed(address token, address tokenPriceAggregator, uint256 tokenPriceAggregatorRefreshRateThreshold, address fallbackPriceAggregator, uint256 fallbackPriceAggregatorRefreshRateThreshold) external
```

#### Parameters

| Name                                        | Type    | Description                                                                             |
| ------------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
| token                                       | address | The address of the token to add a price feed for                                        |
| tokenPriceAggregator                        | address | The price aggregator address for token to be added                                      |
| tokenPriceAggregatorRefreshRateThreshold    | uint256 | Refresh threshold in seconds for primary price feed updates beyond which price is stale |
| fallbackPriceAggregator                     | address | The fallback price aggregator address for token to be added                             |
| fallbackPriceAggregatorRefreshRateThreshold | uint256 | Refresh threshold for fallback price feed updates beyond which price is stale           |

### addNewTokenPriceFeed

```solidity
function addNewTokenPriceFeed(address token, address tokenPriceAggregator, uint256 refreshRateThreshold) external
```

#### Parameters

| Name                 | Type    | Description                                                                             |
| -------------------- | ------- | --------------------------------------------------------------------------------------- |
| token                | address | The address of the token to add a price feed for                                        |
| tokenPriceAggregator | address | The proxy price aggregator address for token to be added                                |
| refreshRateThreshold | uint256 | Refresh threshold in seconds for primary price feed updates beyond which price is stale |

### addNewTokenFallbackPriceFeed

```solidity
function addNewTokenFallbackPriceFeed(address token, address tokenPriceAggregator, uint256 refreshRateThreshold) external
```

#### Parameters

| Name                 | Type    | Description                                                                              |
| -------------------- | ------- | ---------------------------------------------------------------------------------------- |
| token                | address | The address of the token to add a price feed for                                         |
| tokenPriceAggregator | address | The proxy price aggregator address for token to be added                                 |
| refreshRateThreshold | uint256 | Refresh threshold in seconds for fallback price feed updates beyond which price is stale |

### removeTokenPriceFeed

```solidity
function removeTokenPriceFeed(address token) external
```

#### Parameters

| Name  | Type    | Description                                                   |
| ----- | ------- | ------------------------------------------------------------- |
| token | address | The address of the token whose price feed needs to be removed |

### removeFallbackTokenPriceFeed

```solidity
function removeFallbackTokenPriceFeed(address token) external
```

#### Parameters

| Name  | Type    | Description                                                   |
| ----- | ------- | ------------------------------------------------------------- |
| token | address | The address of the token whose price feed needs to be removed |

### getPriceFeedConfig

```solidity
function getPriceFeedConfig(address token) external view returns (address priceFeed, uint256 refreshRateThreshold)
```

Get the primary price feed configuration for a token

#### Parameters

| Name  | Type    | Description                       |
| ----- | ------- | --------------------------------- |
| token | address | The address of the token to query |

#### Return Values

| Name                 | Type    | Description                                      |
| -------------------- | ------- | ------------------------------------------------ |
| priceFeed            | address | The address of the primary price feed aggregator |
| refreshRateThreshold | uint256 | The refresh rate threshold in seconds            |

### getFallbackPriceFeedConfig

```solidity
function getFallbackPriceFeedConfig(address token) external view returns (address fallbackPriceFeed, uint256 refreshRateThreshold)
```

Get the fallback price feed configuration for a token

#### Parameters

| Name  | Type    | Description                       |
| ----- | ------- | --------------------------------- |
| token | address | The address of the token to query |

#### Return Values

| Name                 | Type    | Description                                       |
| -------------------- | ------- | ------------------------------------------------- |
| fallbackPriceFeed    | address | The address of the fallback price feed aggregator |
| refreshRateThreshold | uint256 | The refresh rate threshold in seconds             |

### \_addNewTokenPriceFeed

```solidity
function _addNewTokenPriceFeed(address token, address tokenPriceAggregator, uint256 refreshRateThreshold) internal
```

#### Parameters

| Name                 | Type    | Description                                                                             |
| -------------------- | ------- | --------------------------------------------------------------------------------------- |
| token                | address | The address of the token to add a price feed for                                        |
| tokenPriceAggregator | address | The proxy price aggregator address for token to be added                                |
| refreshRateThreshold | uint256 | Refresh threshold in seconds for primary price feed updates beyond which price is stale |

### \_addNewTokenFallbackPriceFeed

```solidity
function _addNewTokenFallbackPriceFeed(address token, address tokenPriceAggregator, uint256 refreshRateThreshold) internal
```

#### Parameters

| Name                 | Type    | Description                                                                              |
| -------------------- | ------- | ---------------------------------------------------------------------------------------- |
| token                | address | The address of the token to add a price feed for                                         |
| tokenPriceAggregator | address | The proxy price aggregator address for token to be added                                 |
| refreshRateThreshold | uint256 | Refresh threshold in seconds for fallback price feed updates beyond which price is stale |

### \_getLatestPrice

```solidity
function _getLatestPrice(address token) internal view returns (int256 latestPrice, uint8 decimals)
```

#### Return Values

| Name        | Type   | Description                            |
| ----------- | ------ | -------------------------------------- |
| latestPrice | int256 | The latest price from price aggregator |
| decimals    | uint8  | The decimals in the price              |

### \_authorizeUpgrade

```solidity
function _authorizeUpgrade(address) internal view
```

*required override by the OpenZeppelin UUPS module*


---

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

```
GET https://developers.term.finance/latest/protocol-class/termpriceconsumerv3.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.
