MockOffchainAggregator v0.2.3 API Reference
MockOffchainAggregator
A mock implementation of an offchain aggregator for testing purposes.
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
Parameter | Type | Description |
---|---|---|
_decimals | uint8 | The number of decimals for the aggregator |
_initialAnswer | int256 | The 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
Parameter | Type | Description |
---|---|---|
_roundId | uint80 | The round ID to get the data for |
Returns
Parameter | Type | Description |
---|---|---|
roundId | uint80 | The round ID |
answer | int256 | The answer for the round |
startedAt | uint256 | The timestamp when the round started |
updatedAt | uint256 | The timestamp when the round was updated |
answeredInRound | uint80 | 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
Parameter | Type | Description |
---|---|---|
roundId | uint80 | The latest round ID |
answer | int256 | The latest answer |
startedAt | uint256 | The timestamp when the latest round started |
updatedAt | uint256 | The timestamp when the latest round was updated |
answeredInRound | uint80 | The round ID in which the latest answer was computed |
updateAnswer
Updates the answer in the mock aggregator.
function updateAnswer(int256 _answer) public
Parameters
Parameter | Type | Description |
---|---|---|
_answer | int256 | 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
Parameter | Type | Description |
---|---|---|
_minAnswer | int192 | The new minimum answer |
_maxAnswer | int192 | The 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
Parameter | Type | Description |
---|---|---|
_roundId | uint80 | The round ID to be updated |
_answer | int256 | The new answer to be set |
_timestamp | uint256 | The timestamp to be set |
_startedAt | uint256 | The timestamp when the round started |