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

> For the complete documentation index, see [llms.txt](/llms.txt).

<Common callout="importPackage023" />

## MockOffchainAggregator

A mock implementation of an offchain aggregator for testing purposes.

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

<Aside>Simulates the behavior of an offchain aggregator and allows for updating answers and round data.</Aside>

## Variables

### decimals

```solidity
uint8 public decimals
```

<Aside>The number of decimals used by the aggregator.</Aside>

### getAnswer

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

<Aside>Mapping to get the answer for a specific round ID.</Aside>

### getTimestamp

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

<Aside>Mapping to get the timestamp for a specific round ID.</Aside>

### latestAnswer

```solidity
int256 public latestAnswer
```

<Aside>The latest answer reported by the aggregator.</Aside>

### latestRound

```solidity
uint256 public latestRound
```

<Aside>The latest round ID.</Aside>

### latestTimestamp

```solidity
uint256 public latestTimestamp
```

<Aside>The timestamp of the latest answer.</Aside>

### maxAnswer

```solidity
int192 public maxAnswer
```

<Aside>The maximum answer the aggregator is allowed to report.</Aside>

### minAnswer

```solidity
int192 public minAnswer
```

<Aside>The minimum answer the aggregator is allowed to report.</Aside>

## Functions

### constructor

Initializes the contract with decimals and initial answer.

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

<Aside>Constructor to initialize the MockOffchainAggregator contract with initial parameters.</Aside>

#### Parameters

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

### getRoundData

Gets the 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
    )
```

<Aside>Gets the round data for a specific round ID.</Aside>

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

Gets the latest round data.

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

<Aside>Gets the latest round data.</Aside>

#### 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 answer in the mock aggregator.

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

<Aside>Updates the answer in the mock aggregator.</Aside>

#### Parameters

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

### updateMinAndMaxAnswers

Updates the minimum and maximum answers the aggregator can report.

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

<Aside>Updates the minimum and maximum answers the aggregator can report.</Aside>

#### Parameters

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

#### Possible Reverts

- Reverts if minAnswer is not less than maxAnswer with "minAnswer must be less than maxAnswer"
- Reverts if minAnswer is too low with "minAnswer is too low"
- Reverts if maxAnswer is too high with "maxAnswer is too high"

### updateRoundData

Updates the round data in the mock aggregator.

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

<Aside>Updates the round data in the mock aggregator.</Aside>

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