API Version: v0.2.3

MockV3Aggregator v0.2.3 API Reference

MockV3Aggregator

A mock implementation of the AggregatorV2V3Interface for testing purposes.

MockV3Aggregator

Variables

aggregator

address public aggregator

proposedAggregator

address public proposedAggregator

version

uint256 public constant override version = 0

Functions

confirmAggregator

Confirms the proposed aggregator.

function confirmAggregator(address _aggregator) external

Parameters

ParameterTypeDescription
_aggregatoraddressThe address of the proposed aggregator

Possible Reverts

  • Reverts if the provided aggregator address does not match the proposed aggregator with "Invalid proposed aggregator"

constructor

Initializes the contract with decimals and initial answer.

constructor(uint8 _decimals, int256 _initialAnswer)

Parameters

ParameterTypeDescription
_decimalsuint8The number of decimals for the aggregator
_initialAnswerint256The initial answer to be set

decimals

Gets the number of decimals used by the aggregator.

function decimals() external view returns (uint8)

Returns

ParameterTypeDescription
(unnamed)uint8The number of decimals

description

Gets the description of the aggregator.

function description() external pure returns (string memory)

Returns

ParameterTypeDescription
(unnamed)stringThe contract path as the description

getAnswer

Gets the answer for a specific round ID.

function getAnswer(uint256 roundId) external view returns (int256)

Parameters

ParameterTypeDescription
roundIduint256The round ID to get answer for

Returns

ParameterTypeDescription
(unnamed)int256The answer for the given round ID

getRoundData

Gets the round data for a specific round ID.

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

Parameters

ParameterTypeDescription
_roundIduint80The round ID to get the data for

Returns

ParameterTypeDescription
roundIduint80The round ID
answerint256The answer for the round
startedAtuint256The timestamp when the round started
updatedAtuint256The timestamp when the round was updated
answeredInRounduint80The round ID in which the answer was computed

getTimestamp

Gets the timestamp for a specific round ID.

function getTimestamp(uint256 roundId) external view returns (uint256)

Parameters

ParameterTypeDescription
roundIduint256The round ID to get timestamp for

Returns

ParameterTypeDescription
(unnamed)uint256The timestamp for the given round ID

latestAnswer

Gets the latest answer from the aggregator.

function latestAnswer() external view returns (int256)

Returns

ParameterTypeDescription
(unnamed)int256The latest answer

latestRound

Gets the latest round ID from the aggregator.

function latestRound() external view returns (uint256)

Returns

ParameterTypeDescription
(unnamed)uint256The latest round ID

latestRoundData

Gets the latest round data.

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

Returns

ParameterTypeDescription
roundIduint80The latest round ID
answerint256The latest answer
startedAtuint256The timestamp when the latest round started
updatedAtuint256The timestamp when the latest round was updated
answeredInRounduint80The round ID in which the latest answer was computed

latestTimestamp

Gets the timestamp of the latest answer.

function latestTimestamp() external view returns (uint256)

Returns

ParameterTypeDescription
(unnamed)uint256The timestamp of the latest answer

proposeAggregator

Proposes a new aggregator.

function proposeAggregator(AggregatorV2V3Interface _aggregator) external

Parameters

ParameterTypeDescription
_aggregatorAggregatorV2V3InterfaceThe address of the proposed aggregator

Possible Reverts

  • Reverts if the proposed aggregator is the zero address with "Proposed aggregator cannot be zero address"
  • Reverts if the proposed aggregator is the current aggregator with "Proposed aggregator cannot be current aggregator"

updateAnswer

Updates the answer in the mock aggregator.

function updateAnswer(int256 _answer) public

Parameters

ParameterTypeDescription
_answerint256The new answer to be set

updateRoundData

Updates the round data in the mock aggregator.

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

Parameters

ParameterTypeDescription
_roundIduint80The round ID to be updated
_answerint256The new answer to be set
_timestampuint256The timestamp to be set
_startedAtuint256The timestamp when the round started

Get the latest Chainlink content straight to your inbox.