API Version: v0.2.3

MockOffchainAggregator v0.2.3 API Reference

MockOffchainAggregator

A mock implementation of an offchain aggregator for testing purposes.

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 the contract with decimals and initial answer.

constructor(uint8 _decimals, int256 _initialAnswer)

Parameters

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

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

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

Gets the latest round data.

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 answer in the mock aggregator.

function updateAnswer(int256 _answer) public

Parameters

ParameterTypeDescription
_answerint256The new answer to be set

updateMinAndMaxAnswers

Updates the minimum and maximum answers the aggregator can report.

function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external

Parameters

ParameterTypeDescription
_minAnswerint192The new minimum answer
_maxAnswerint192The new maximum answer

Possible Reverts

  • Reverts if minAnswer is not less than maxAnswer with "minAnswer must be less than maxAnswer"
  • Reverts if minAnswer is too low with "minAnswer is too low"
  • Reverts if maxAnswer is too high with "maxAnswer is too high"

updateRoundData

Updates the round data in the mock aggregator.

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.