API Version: v0.2.9 Not using latest version (v0.3.1)

MockV3Aggregator v0.2.9 API Reference

MockV3Aggregator

Mock implementation of V3 aggregator.

MockV3Aggregator

Variables

aggregator

address aggregator

The address of the current aggregator.

proposedAggregator

address proposedAggregator

The address of the proposed aggregator.

version

uint256 version

The version of the aggregator.

Functions

confirmAggregator

function confirmAggregator(address _aggregator) external

Confirms the proposed aggregator.

Parameters

NameTypeDescription
_aggregatoraddress- The address of the proposed aggregator.

constructor

constructor(uint8 _decimals, int256 _initialAnswer) public

Constructor to initialize the MockV3Aggregator contract with initial parameters.

Parameters

NameTypeDescription
_decimalsuint8- The number of decimals for the aggregator.
_initialAnswerint256- The initial answer to be set in the mock aggregator.

decimals

function decimals() external view returns (uint8)

Gets the number of decimals used by the aggregator.

Returns

NameTypeDescription
[0]uint8uint8 - The number of decimals.

description

function description() external pure returns (string)

Gets the description of the aggregator.

Returns

NameTypeDescription
[0]stringstring memory - The description of the aggregator.

getAnswer

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

Gets the answer for a specific round ID.

Parameters

NameTypeDescription
roundIduint256- The round ID to get the answer for.

Returns

NameTypeDescription
[0]int256int256 - The answer for the given round ID.

getRoundData

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

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.

Parameters

NameTypeDescription
_roundIduint80- The round ID to get the data for.

Returns

NameTypeDescription
roundIduint80- The round ID.
answerint256- The answer for the round.
startedAtuint256- The timestamp when the round started.
updatedAtuint256- The timestamp when the round was updated.
answeredInRounduint80- The round ID in which the answer was computed.

getTimestamp

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

Gets the timestamp for a specific round ID.

Parameters

NameTypeDescription
roundIduint256- The round ID to get the timestamp for.

Returns

NameTypeDescription
[0]uint256uint256 - The timestamp for the given round ID.

latestAnswer

function latestAnswer() external view returns (int256)

Gets the latest answer from the aggregator.

Returns

NameTypeDescription
[0]int256int256 - The latest answer.

latestRound

function latestRound() external view returns (uint256)

Gets the latest round ID from the aggregator.

Returns

NameTypeDescription
[0]uint256uint256 - The latest round ID.

latestRoundData

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

Gets the latest round data.

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

Returns

NameTypeDescription
roundIduint80- The latest round ID.
answerint256- The latest answer.
startedAtuint256- The timestamp when the latest round started.
updatedAtuint256- The timestamp when the latest round was updated.
answeredInRounduint80- The round ID in which the latest answer was computed.

latestTimestamp

function latestTimestamp() external view returns (uint256)

Gets the timestamp of the latest answer from the aggregator.

Returns

NameTypeDescription
[0]uint256uint256 - The timestamp of the latest answer.

proposeAggregator

function proposeAggregator(contract AggregatorV2V3Interface _aggregator) external

Proposes a new aggregator.

Parameters

NameTypeDescription
_aggregatorcontract AggregatorV2V3Interface- The address of the proposed aggregator.

updateAnswer

function updateAnswer(int256 _answer) public

Updates the answer in the mock aggregator.

Parameters

NameTypeDescription
_answerint256- The new answer to be set.

updateRoundData

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

Updates the round data in the mock aggregator.

Parameters

NameTypeDescription
_roundIduint80- The round ID to be updated.
_answerint256- The new answer to be set.
_timestampuint256- The timestamp to be set.
_startedAtuint256- The timestamp when the round started.

Get the latest Chainlink content straight to your inbox.