# MockV3Aggregator v0.3.0 API Reference
Source: https://docs.chain.link/chainlink-local/api-reference/v0.3.0/mock-v3-aggregator

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

> **NOTE: Integrate Chainlink Local into your project**
>
> ### npm
>
> If you use [NPM](https://www.npmjs.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> npm install @chainlink/local@0.3.0
> ```
>
> ### yarn
>
> If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> yarn add @chainlink/local@0.3.0
> ```
>
> ### foundry
>
> If you use [Foundry](https://book.getfoundry.sh/):
>
> ```shell
> forge install smartcontractkit/chainlink-local@v0.3.0
> ```
>
> and then set remappings to: `@chainlink/local/=lib/chainlink-local/` in either `remappings.txt` or `foundry.toml` file
>
> ### RemixIDE
>
> Import the `CCIPLocalSimulator` contract from the `@chainlink/local` package:
>
> ```solidity
> import {CCIPLocalSimulator} from "@chainlink/local@0.3.0/src/ccip/CCIPLocalSimulator.sol";
> ```

## MockV3Aggregator

Mock implementation of V3 aggregator.

[MockV3Aggregator](https://github.com/smartcontractkit/chainlink-local/blob/v0.3.0/src/data-feeds/MockV3Aggregator.sol)

## Variables

### aggregator

The address of the current aggregator.

```solidity
address public aggregator
```

### proposedAggregator

The address of the proposed aggregator.

```solidity
address public proposedAggregator
```

### version

The version of the aggregator.

```solidity
uint256 public constant override version = 0
```

## Functions

### confirmAggregator

Confirms the proposed aggregator.

```solidity
function confirmAggregator(address _aggregator) external;
```

**Parameters**

| Name          | Type      | Description                               |
| ------------- | --------- | ----------------------------------------- |
| `_aggregator` | `address` | - The address of the proposed aggregator. |

### constructor

Constructor to initialize the MockV3Aggregator contract with initial parameters.

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

**Parameters**

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

### decimals

Gets the number of decimals used by the aggregator.

```solidity
function decimals() external view override returns (uint8);
```

**Returns**

| Name     | Type    | Description                     |
| -------- | ------- | ------------------------------- |
| `<none>` | `uint8` | uint8 - The number of decimals. |

### description

Gets the description of the aggregator.

```solidity
function description() external pure override returns (string memory);
```

**Returns**

| Name     | Type     | Description                                        |
| -------- | -------- | -------------------------------------------------- |
| `<none>` | `string` | string memory - The description of the aggregator. |

### getAnswer

Gets the answer for a specific round ID.

```solidity
function getAnswer(uint256 roundId) external view override returns (int256);
```

**Parameters**

| Name      | Type      | Description                           |
| --------- | --------- | ------------------------------------- |
| `roundId` | `uint256` | - The round ID to get the answer for. |

**Returns**

| Name     | Type     | Description                                 |
| -------- | -------- | ------------------------------------------- |
| `<none>` | `int256` | int256 - The answer for the given round ID. |

### getRoundData

Gets the round data for a specific round ID.

This function should raise "No data present" if no data is available for the
given round ID.

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

**Parameters**

| Name       | Type     | Description                         |
| ---------- | -------- | ----------------------------------- |
| `_roundId` | `uint80` | - The round ID to get the data for. |

**Returns**

| Name              | 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. |

### getTimestamp

Gets the timestamp for a specific round ID.

```solidity
function getTimestamp(uint256 roundId) external view override returns (uint256);
```

**Parameters**

| Name      | Type      | Description                              |
| --------- | --------- | ---------------------------------------- |
| `roundId` | `uint256` | - The round ID to get the timestamp for. |

**Returns**

| Name     | Type      | Description                                     |
| -------- | --------- | ----------------------------------------------- |
| `<none>` | `uint256` | uint256 - The timestamp for the given round ID. |

### latestAnswer

Gets the latest answer from the aggregator.

```solidity
function latestAnswer() external view override returns (int256);
```

**Returns**

| Name     | Type     | Description                 |
| -------- | -------- | --------------------------- |
| `<none>` | `int256` | int256 - The latest answer. |

### latestRound

Gets the latest round ID from the aggregator.

```solidity
function latestRound() external view override returns (uint256);
```

**Returns**

| Name     | Type      | Description                    |
| -------- | --------- | ------------------------------ |
| `<none>` | `uint256` | uint256 - The latest round ID. |

### latestRoundData

Gets the latest round data.

This function should raise "No data present" if no data is available.

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

**Returns**

| Name              | 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. |

### latestTimestamp

Gets the timestamp of the latest answer from the aggregator.

```solidity
function latestTimestamp() external view override returns (uint256);
```

**Returns**

| Name     | Type      | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `<none>` | `uint256` | uint256 - The timestamp of the latest answer. |

### proposeAggregator

Proposes a new aggregator.

```solidity
function proposeAggregator(AggregatorV2V3Interface _aggregator) external;
```

**Parameters**

| Name          | Type                      | Description                               |
| ------------- | ------------------------- | ----------------------------------------- |
| `_aggregator` | `AggregatorV2V3Interface` | - The address of the proposed aggregator. |

### updateAnswer

Updates the answer in the mock aggregator.

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

**Parameters**

| Name      | Type     | Description                 |
| --------- | -------- | --------------------------- |
| `_answer` | `int256` | - The new answer to be set. |

### updateRoundData

Updates the round data in the mock aggregator.

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

**Parameters**

| Name         | 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. |