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

MockV3Aggregator v0.3.0 API Reference

MockV3Aggregator

Mock implementation of V3 aggregator.

MockV3Aggregator

Variables

aggregator

The address of the current aggregator.

address public aggregator

proposedAggregator

The address of the proposed aggregator.

address public proposedAggregator

version

The version of the aggregator.

uint256 public constant override version = 0

Functions

confirmAggregator

Confirms the proposed aggregator.

function confirmAggregator(address _aggregator) external;

Parameters

NameTypeDescription
_aggregatoraddress- The address of the proposed aggregator.

constructor

Constructor to initialize the MockV3Aggregator contract with initial parameters.

constructor(uint8 _decimals, int256 _initialAnswer) ;

Parameters

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

decimals

Gets the number of decimals used by the aggregator.

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

Returns

NameTypeDescription
<none>uint8uint8 - The number of decimals.

description

Gets the description of the aggregator.

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

Returns

NameTypeDescription
<none>stringstring memory - The description of the aggregator.

getAnswer

Gets the answer for a specific round ID.

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

Parameters

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

Returns

NameTypeDescription
<none>int256int256 - 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.

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

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

Gets the timestamp for a specific round ID.

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

Parameters

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

Returns

NameTypeDescription
<none>uint256uint256 - The timestamp for the given round ID.

latestAnswer

Gets the latest answer from the aggregator.

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

Returns

NameTypeDescription
<none>int256int256 - The latest answer.

latestRound

Gets the latest round ID from the aggregator.

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

Returns

NameTypeDescription
<none>uint256uint256 - The latest round ID.

latestRoundData

Gets the latest round data.

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

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

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

Gets the timestamp of the latest answer from the aggregator.

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

Returns

NameTypeDescription
<none>uint256uint256 - The timestamp of the latest answer.

proposeAggregator

Proposes a new aggregator.

function proposeAggregator(AggregatorV2V3Interface _aggregator) external;

Parameters

NameTypeDescription
_aggregatorAggregatorV2V3Interface- The address of the proposed aggregator.

updateAnswer

Updates the answer in the mock aggregator.

function updateAnswer(int256 _answer) public;

Parameters

NameTypeDescription
_answerint256- The 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

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.