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.
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
Parameter | Type | Description |
---|---|---|
_decimals | uint8 | The number of decimals for the aggregator |
_initialAnswer | int256 | The 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
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
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
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 latest answer and associated data.
function updateAnswer(int256 _answer) public
Parameters
Parameter | Type | Description |
---|---|---|
_answer | int256 | The new answer to be set |
updateMinAndMaxAnswers
Updates the minimum and maximum allowed answers for the aggregator.
function updateMinAndMaxAnswers(int192 _minAnswer, int192 _maxAnswer) external
Parameters
Parameter | Type | Description |
---|---|---|
_minAnswer | int192 | The new minimum answer |
_maxAnswer | int192 | The new maximum answer |
updateRoundData
Updates all data for a specific round.
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 |