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

MockOffchainAggregator v0.3.0 API Reference

MockOffchainAggregator

Mock implementation of off-chain aggregator.

MockOffchainAggregator

Variables

decimals

The number of decimals used by the aggregator.

uint8 public decimals

getAnswer

Mapping to get the answer for a specific round ID.

mapping(uint256 => int256) public getAnswer

getStartedAt

Mapping to get the start time for a specific round ID.

mapping(uint256 => uint256) private getStartedAt

getTimestamp

Mapping to get the timestamp for a specific round ID.

mapping(uint256 => uint256) public getTimestamp

latestAnswer

The latest answer reported by the aggregator.

int256 public latestAnswer

latestRound

The latest round ID.

uint256 public latestRound

latestTimestamp

The timestamp of the latest answer.

uint256 public latestTimestamp

MAX_ANSWER_POSSIBLE

The maximum possible answer the aggregator can report.

int192 private constant MAX_ANSWER_POSSIBLE = 95780971304118053647396689196894323976171195136475135

maxAnswer

The maximum answer the aggregator is allowed to report.

int192 public maxAnswer

MIN_ANSWER_POSSIBLE

The minimum possible answer the aggregator can report.

int192 private constant MIN_ANSWER_POSSIBLE = 1

minAnswer

The minimum answer the aggregator is allowed to report.

int192 public minAnswer

Functions

constructor

Constructor to initialize the MockOffchainAggregator 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.

getRoundData

Gets the 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

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.

latestRoundData

Gets the latest round data.

function latestRoundData()
    external
    view
    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.

updateAnswer

Updates the answer in the mock aggregator.

function updateAnswer(int256 _answer) public;

Parameters

NameTypeDescription
_answerint256- The new answer to be set.

updateMinAndMaxAnswers

Updates the minimum and maximum answers the aggregator can report.

function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external;

Parameters

NameTypeDescription
_minAnswerint192- The new minimum answer.
_maxAnswerint192- The new maximum answer.

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.