# MockOffchainAggregator v0.2.2 API Reference
Source: https://docs.chain.link/chainlink-local/api-reference/v0.2.2/mock-offchain-aggregator


<Common callout="importPackage022" />

## MockOffchainAggregator

A mock implementation of an offchain aggregator contract used for testing purposes, simulating price feed behavior with configurable parameters.

[`MockOffchainAggregator`](https://github.com/smartcontractkit/chainlink-local/blob/cd3bfb8c42716cfb791174314eba2c0d178551b9/src/data-feeds/MockOffchainAggregator.sol)

## Variables

### decimals

```solidity
uint8 public decimals
```

> \*\*NOTE\*\*
>
>
>
> The number of decimals used by the aggregator.

### getAnswer

```solidity
mapping(uint256 => int256) public getAnswer
```

> \*\*NOTE\*\*
>
>
>
> Mapping to get the answer for a specific round ID.

### getTimestamp

```solidity
mapping(uint256 => uint256) public getTimestamp
```

> \*\*NOTE\*\*
>
>
>
> Mapping to get the timestamp for a specific round ID.

### latestAnswer

```solidity
int256 public latestAnswer
```

> \*\*NOTE\*\*
>
>
>
> The latest answer reported by the aggregator.

### latestRound

```solidity
uint256 public latestRound
```

> \*\*NOTE\*\*
>
>
>
> The latest round ID.

### latestTimestamp

```solidity
uint256 public latestTimestamp
```

> \*\*NOTE\*\*
>
>
>
> The timestamp of the latest answer.

### maxAnswer

```solidity
int192 public maxAnswer
```

> \*\*NOTE\*\*
>
>
>
> The maximum answer the aggregator is allowed to report.

### minAnswer

```solidity
int192 public minAnswer
```

> \*\*NOTE\*\*
>
>
>
> The minimum answer the aggregator is allowed to report.

## Functions

### constructor

Initializes a new mock aggregator with the specified decimal precision and starting price.

```solidity
constructor(uint8 _decimals, int256 _initialAnswer)
```

> \*\*NOTE\*\*
>
>
>
> Constructor to initialize the MockOffchainAggregator contract with initial parameters.

#### Parameters

| Parameter       | Type   | Description                                         |
| --------------- | ------ | --------------------------------------------------- |
| \_decimals      | uint8  | The number of decimals for the aggregator           |
| \_initialAnswer | int256 | The initial answer to be set in the mock aggregator |

### getRoundData

Retrieves the complete round data for a specific round ID.

```solidity
function getRoundData(uint80 _roundId) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
```

> \*\*NOTE\*\*
>
>
>
> Gets the round data for a specific round ID.

#### Parameters

| Parameter | Type   | Description                      |
| --------- | ------ | -------------------------------- |
| \_roundId | uint80 | The round ID to get the data for |

#### Returns

| Parameter       | Type    | Description                                   |
| --------------- | ------- | --------------------------------------------- |
| roundId         | uint80  | The round ID                                  |
| answer          | int256  | The answer for the round                      |
| startedAt       | uint256 | The timestamp when the round started          |
| updatedAt       | uint256 | The timestamp when the round was updated      |
| answeredInRound | uint80  | The round ID in which the answer was computed |

### latestRoundData

Retrieves the complete round data for the most recent round.

```solidity
function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
```

> \*\*NOTE\*\*
>
>
>
> Gets the latest round data.

#### Returns

| Parameter       | Type    | Description                                          |
| --------------- | ------- | ---------------------------------------------------- |
| roundId         | uint80  | The latest round ID                                  |
| answer          | int256  | The latest answer                                    |
| startedAt       | uint256 | The timestamp when the latest round started          |
| updatedAt       | uint256 | The timestamp when the latest round was updated      |
| answeredInRound | uint80  | The round ID in which the latest answer was computed |

### updateAnswer

Updates the latest answer and associated data.

```solidity
function updateAnswer(int256 _answer) public
```

> \*\*NOTE\*\*
>
>
>
> Updates the answer in the mock aggregator.

#### Parameters

| Parameter | Type   | Description              |
| --------- | ------ | ------------------------ |
| \_answer  | int256 | The new answer to be set |

### updateMinAndMaxAnswers

Updates the minimum and maximum allowed answers for the aggregator.

```solidity
function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external
```

> \*\*NOTE\*\*
>
>
>
> Updates the minimum and maximum answers the aggregator can report.

#### Parameters

| Parameter   | Type   | Description            |
| ----------- | ------ | ---------------------- |
| \_minAnswer | int192 | The new minimum answer |
| \_maxAnswer | int192 | The new maximum answer |

> **CAUTION**
>
> **Possible Reverts**

- Reverts with "minAnswer must be less than maxAnswer" if `_minAnswer >= _maxAnswer`
- Reverts with "minAnswer is too low" if `_minAnswer < MIN_ANSWER_POSSIBLE`
- Reverts with "maxAnswer is too high" if `_maxAnswer > MAX_ANSWER_POSSIBLE`

### updateRoundData

Updates all data for a specific round.

```solidity
function updateRoundData(uint80 _roundId, int256 _answer, uint256 _timestamp, uint256 _startedAt) public
```

> \*\*NOTE\*\*
>
>
>
> Updates the round data in the mock aggregator.

#### Parameters

| Parameter   | Type    | Description                          |
| ----------- | ------- | ------------------------------------ |
| \_roundId   | uint80  | The round ID to be updated           |
| \_answer    | int256  | The new answer to be set             |
| \_timestamp | uint256 | The timestamp to be set              |
| \_startedAt | uint256 | The timestamp when the round started |