MockV3Aggregator.sol API

API Methods

[MockV3Aggregator].decimals()

function decimals() external view returns(uint8);

Return the number of digits of precision for the stored answer. Answers are stored in fixed-point format.

Return values:

  • decimalPlaces (uint8): The number of digits of precision for the stored answer.


[MockV3Aggregator].description()

function description() external pure returns(string memory);

Return a description for this data feed. Usually this is an asset pair for a price feed. In mocks it is hard-coded to: "src/data-feeds/MockV3Aggregator.sol".

Return values:

  • description (string): The description for this data feed.


[MockV3Aggregator].version()

function version() public pure returns(uint256);

Returns the contract version. This is different from the typeAndVersion for the aggregator. In mocks it is hard-coded to 0.

Return values:

  • version (uint256): The contract version.


[MockV3Aggregator].getRoundData(uint80 _roundId)

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

Get the full information for a specific aggregator round including the answer and update timestamps. Use this to get the full historical data for a round.

Parameters:

  • _roundId (uint80): The round ID.

Return values:

  • roundId (uint80): The round ID.

  • answer (iint256): The answer for this round.

  • startedAt (uint256): Timestamp of when the round started.

  • updatedAt (uint256): Timestamp of when the round was updated.

  • answeredInRound(uint80): ⚠️ Deprecated - Previously used when answers could take multiple rounds to be computed.


[MockV3Aggregator].latestRoundData()

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

Get the full information for the most recent round including the answer and update timestamps.

Return values:

  • roundId (uint80): The round ID.

  • answer (iint256): The answer for this round.

  • startedAt (uint256): Timestamp of when the round started.

  • updatedAt (uint256): Timestamp of when the round was updated.

  • answeredInRound(uint80): ⚠️ Deprecated - Previously used when answers could take multiple rounds to be computed.


[MockV3Aggregator].updateAnswer(int256 _answer)

function updateAnswer(int256 _answer) public;

Sets the new answer that the mock contract will return. Starts the new round automatically. Bumps the roundId by one. Sets the startedAt, updatedAt and answeredInRound values to block.timestamp. To update all of these values, use the updateRoundData function.

Parameters:

  • _answer (int256): The new answer for the next round.


[MockV3Aggregator].updateRoundData(uint80 _roundId, int256 _answer, uint256 _timestamp, uint256 _startedAt)

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

Sets new details of the specific round that the mock contract will return.

Parameters:

  • roundId (uint80): The round ID.

  • answer (iint256): The answer for this round.

  • startedAt (uint256): Timestamp of when the round started.

  • updatedAt (uint256): Timestamp of when the round was updated.

  • answeredInRound(uint80): ⚠️ Deprecated - Previously used when answers could take multiple rounds to be computed.


[MockV3Aggregator].aggregator()

function aggregator() public view returns(address);

Returns the address of the current MockOffchainAggregator.sol contract.

Return values:

  • aggregator (address): The address of the current MockOffchainAggregator.sol contract.


[MockV3Aggregator].proposedAggregator()

function proposedAggregator() public view returns(address);

Returns the address of the proposed MockOffchainAggregator.sol contract. It is address(0) by default.

Return values:

  • proposedAggregator (address): The address of the proposed MockOffchainAggregator.sol contract.


[MockV3Aggregator].proposeAggregator(AggregatorV2V3Interface _aggregator)

function proposedAggregator(AggregatorV2V3Interface _aggregator) public;

Proposes the new MockOffchainAggregator.sol contract. Used as a first step in changing the underlying MockOffchainAggregator.sol contract. The second step is to call the confirmAggregator() function.

Parameters:

  • _aggregator (address): The address of the MockOffchainAggregator.sol contract to propose.


[MockV3Aggregator].confirmAggregator(address _aggregator)

function confirmAggregator(address _aggregator) public;

Sets the proposed MockOffchainAggregator.sol contract as the current aggregator. The proposedAggregator becomes address(0). Reverts if _aggregator is not equal to proposedAggregator.

Parameters:

  • _aggregator (address): The address of the new MockOffchainAggregator.sol contract.


[MockV3Aggregator].latestAnswer() - ⚠️ Deprecated

function latestAnswer() external view returns(int256);

⚠️ Deprecated - Do not use this function.


[MockV3Aggregator].latestTimestamp() - ⚠️ Deprecated

function latestTimestamp() external view returns(uint256);

⚠️ Deprecated - Do not use this function.


[MockV3Aggregator].latestRound() - ⚠️ Deprecated

function latestRound() external view returns(uint256);

⚠️ Deprecated - Do not use this function.


[MockV3Aggregator].getAnswer(uint256 roundId) - ⚠️ Deprecated

function getAnswer(uint256 roundId) external view returns(int256);

⚠️ Deprecated - Do not use this function.


[MockV3Aggregator].getTimestamp(uint256 roundId) - ⚠️ Deprecated

function getTimestamp(uint256 roundId) external view returns(uint256);

⚠️ Deprecated - Do not use this function.

Last updated