API Version: v0.2.1 Not using latest version (v0.2.3)

MockV3Aggregator v0.2.1 API Reference

MockV3Aggregator

MockV3Aggregator implements the AggregatorV2V3Interface for testing purposes. This contract acts as a proxy to a MockOffchainAggregator instance and supports aggregator upgrades.

Variables

aggregator

address public aggregator

The address of the current MockOffchainAggregator implementation.

proposedAggregator

address public proposedAggregator

The address of the proposed new aggregator implementation.

version

uint256 public constant override version = 0

The version number of this aggregator implementation.

Functions

confirmAggregator

function confirmAggregator(address _aggregator) external

Confirms a proposed aggregator upgrade.

Parameters:

ParameterTypeDescription
_aggregatoraddressThe proposed aggregator address to confirm

constructor

constructor(uint8 _decimals, int256 _initialAnswer)

Initializes the contract by deploying a new MockOffchainAggregator instance.

Parameters:

ParameterTypeDescription
_decimalsuint8The number of decimal places in answers
_initialAnswerint256The initial price answer

decimals

function decimals() external view returns (uint8)

Retrieves the number of decimal places in the answer values.

Returns:

TypeDescription
uint8The number of decimals in the response

description

function description() external pure returns (string memory)

Returns the source file path of this contract.

Returns:

TypeDescription
stringThe description of the price feed

getAnswer

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

Retrieves the answer for a specific round.

Parameters:

ParameterTypeDescription
roundIduint256The round ID to query

Returns:

TypeDescription
int256The price answer for the specified round

getRoundData

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

Retrieves the complete round data for a specific round ID.

Parameters:

ParameterTypeDescription
_roundIduint80The round ID to query

Returns:

ParameterTypeDescription
roundIduint80The round ID from the aggregator for this round
answerint256The price answer for this round
startedAtuint256Timestamp when the round started
updatedAtuint256Timestamp when the round was updated
answeredInRounduint80The round ID in which the answer was computed

getTimestamp

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

Retrieves the timestamp for a specific round.

Parameters:

ParameterTypeDescription
roundIduint256The round ID to query

Returns:

TypeDescription
uint256The timestamp when the round was updated

latestAnswer

function latestAnswer() external view returns (int256)

Retrieves the most recent answer.

Returns:

TypeDescription
int256The latest price feed answer

latestRound

function latestRound() external view returns (uint256)

Retrieves the most recent round ID.

Returns:

TypeDescription
uint256The latest round ID

latestRoundData

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

Retrieves the latest round data from the aggregator.

Returns:

ParameterTypeDescription
roundIduint80The round ID from the aggregator for this round
answerint256The latest price answer
startedAtuint256Timestamp when the round started
updatedAtuint256Timestamp when the round was updated
answeredInRounduint80The round ID in which the answer was computed

latestTimestamp

function latestTimestamp() external view returns (uint256)

Retrieves the timestamp of the latest answer.

Returns:

TypeDescription
uint256The timestamp when the latest answer was updated

proposeAggregator

function proposeAggregator(AggregatorV2V3Interface _aggregator) external

Proposes a new aggregator implementation.

Parameters:

ParameterTypeDescription
_aggregatorAggregatorV2V3InterfaceThe new aggregator implementation

updateAnswer

function updateAnswer(int256 _answer) public

Updates the latest answer and associated round data.

Parameters:

ParameterTypeDescription
_answerint256The new price answer

updateRoundData

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

Updates all data for a specific round.

Parameters:

ParameterTypeDescription
_roundIduint80The round ID to update
_answerint256The new price answer
_timestampuint256The new update timestamp
_startedAtuint256The new round start timestamp

Get the latest Chainlink content straight to your inbox.