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

MockOffchainAggregator v0.2.1 API Reference

MockOffchainAggregator

MockOffchainAggregator simulates a Chainlink Data Feed aggregator for testing purposes. This contract maintains price feed data and allows manual updates of answers and round data.

Variables

decimals

uint8 public decimals

The number of decimal places in the answer values.

getAnswer

mapping(uint256 => int256) public getAnswer

Maps round IDs to their corresponding price answers.

getTimestamp

mapping(uint256 => uint256) public getTimestamp

Maps round IDs to their update timestamps.

latestAnswer

int256 public latestAnswer

The most recent price answer.

latestRound

uint256 public latestRound

The most recent round ID.

latestTimestamp

uint256 public latestTimestamp

The timestamp of the most recent update.

maxAnswer

int192 public maxAnswer

The highest answer the system can report. Not exposed from the Proxy contract.

minAnswer

int192 public minAnswer

The lowest answer the system can report. Not exposed from the Proxy contract.

Functions

constructor

constructor(uint8 _decimals, int256 _initialAnswer)

Initializes the aggregator with decimal precision and an initial answer.

Parameters:

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

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

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

updateAnswer

function updateAnswer(int256 _answer) public

Updates the latest answer and associated round data.

Parameters:

ParameterTypeDescription
_answerint256The new price answer

updateMinAndMaxAnswers

function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external

Updates the minimum and maximum allowed answer values.

Parameters:

ParameterTypeDescription
_minAnswerint192The new minimum allowed answer
_maxAnswerint192The new maximum allowed 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.