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

MockOffchainAggregator v0.2.2 API Reference

MockOffchainAggregator

A mock implementation of an offchain aggregator contract used for testing purposes, simulating price feed behavior with configurable parameters.

MockOffchainAggregator

Variables

decimals

uint8 public decimals

getAnswer

mapping(uint256 => int256) public getAnswer

getTimestamp

mapping(uint256 => uint256) public getTimestamp

latestAnswer

int256 public latestAnswer

latestRound

uint256 public latestRound

latestTimestamp

uint256 public latestTimestamp

maxAnswer

int192 public maxAnswer

minAnswer

int192 public minAnswer

Functions

constructor

Initializes a new mock aggregator with the specified decimal precision and starting price.

constructor(uint8 _decimals, int256 _initialAnswer)

Parameters

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

getRoundData

Retrieves the complete round data for a specific round ID.

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

Parameters

ParameterTypeDescription
_roundIduint80The round ID to get the data for

Returns

ParameterTypeDescription
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

Retrieves the complete round data for the most recent round.

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

Returns

ParameterTypeDescription
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

updateAnswer

Updates the latest answer and associated data.

function updateAnswer(int256 _answer) public

Parameters

ParameterTypeDescription
_answerint256The new answer to be set

updateMinAndMaxAnswers

Updates the minimum and maximum allowed answers for the aggregator.

function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external

Parameters

ParameterTypeDescription
_minAnswerint192The new minimum answer
_maxAnswerint192The new maximum answer

updateRoundData

Updates all data for a specific round.

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

Parameters

ParameterTypeDescription
_roundIduint80The round ID to be updated
_answerint256The new answer to be set
_timestampuint256The timestamp to be set
_startedAtuint256The timestamp when the round started

Get the latest Chainlink content straight to your inbox.