MockOffchainAggregator API reference

MockOffchainAggregator

This contract is a mock implementation of an offchain aggregator for testing purposes.

This contract simulates the behavior of an offchain aggregator and allows for updating answers and round data.

decimals

uint8 decimals

The number of decimals used by the aggregator.

latestAnswer

int256 latestAnswer

The latest answer reported by the aggregator.

latestTimestamp

uint256 latestTimestamp

The timestamp of the latest answer.

latestRound

uint256 latestRound

The latest round ID.

minAnswer

int192 minAnswer

The minimum answer the aggregator is allowed to report.

maxAnswer

int192 maxAnswer

The maximum answer the aggregator is allowed to report.

getAnswer

mapping(uint256 => int256) getAnswer

Mapping to get the answer for a specific round ID.

getTimestamp

mapping(uint256 => uint256) getTimestamp

Mapping to get the timestamp for a specific round ID.

constructor

constructor(uint8 _decimals, int256 _initialAnswer) public

Constructor to initialize the MockOffchainAggregator contract with initial parameters.

Parameters

NameTypeDescription
_decimalsuint8The number of decimals for the aggregator.
_initialAnswerint256The initial answer to be set in the mock aggregator.

updateAnswer

function updateAnswer(int256 _answer) public

Updates the answer in the mock aggregator.

Parameters

NameTypeDescription
_answerint256The 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
_roundIduint80The round ID to be updated.
_answerint256The new answer to be set.
_timestampuint256The timestamp to be set.
_startedAtuint256The timestamp when the round started.

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.

Parameters

NameTypeDescription
_roundIduint80The round ID to get the data for.

Return Values

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

latestRoundData

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

Gets the latest round data.

Return Values

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

updateMinAndMaxAnswers

function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external

Updates the minimum and maximum answers the aggregator can report.

Parameters

NameTypeDescription
_minAnswerint192The new minimum answer.
_maxAnswerint192The new maximum answer.

Get the latest Chainlink content straight to your inbox.