Skip to content

Antigravity [ Crypto ] Fix PriceOracle missing staleness check and fallback mechanism#5915

Closed
KHHH2312 wants to merge 2 commits into
UnsafeLabs:mainfrom
KHHH2312:fix-priceoracle2
Closed

Antigravity [ Crypto ] Fix PriceOracle missing staleness check and fallback mechanism#5915
KHHH2312 wants to merge 2 commits into
UnsafeLabs:mainfrom
KHHH2312:fix-priceoracle2

Conversation

@KHHH2312
Copy link
Copy Markdown

@KHHH2312 KHHH2312 commented Jun 1, 2026

Fixes #915 by adding staleness checking and a fallback oracle mechanism to the PriceOracle contract. Also includes Hardhat tests mocking Chainlink responses to verify behavior.

Copilot AI review requested due to automatic review settings June 1, 2026 16:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a PriceOracle Solidity contract with fallback oracle support, along with a mock aggregator, Hardhat configuration, and tests.

Changes:

  • Updates PriceOracle to validate price, round completeness, and staleness, with fallback to a secondary feed.
  • Adds a MockAggregator test helper implementing AggregatorV3Interface.
  • Adds Hardhat configuration, package manifest, and a Mocha/Chai test suite.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
solidity/contracts/PriceOracle.sol Adds fallback feed, price/round/staleness validation, and StalePrice event.
solidity/contracts/MockAggregator.sol New mock aggregator for tests.
solidity/contracts/.generation_meta.json Generation metadata file.
solidity/hardhat.config.js Hardhat config using toolbox and Solidity 0.8.20.
solidity/package.json NPM manifest with Hardhat/OpenZeppelin deps.
solidity/test/PriceOracle.test.js Tests for primary/fallback price retrieval and revert paths.

// BUG: No round completeness validation
// BUG: No fallback oracle
function getLatestPrice() external view returns (int256) {
function getLatestPrice() external returns (int256) {
Comment thread solidity/contracts/PriceOracle.sol Outdated
require(price > 0, "Invalid price");
require(answeredInRound >= roundId, "Incomplete round");

if (block.timestamp - updatedAt >= MAX_STALENESS) {
Comment thread solidity/contracts/PriceOracle.sol Outdated
AggregatorV3Interface public primaryFeed;
AggregatorV3Interface public fallbackFeed;
address public owner;
uint256 public MAX_STALENESS = 3600;
Comment thread solidity/contracts/PriceOracle.sol Outdated
require(price > 0, "Invalid price");
require(answeredInRound >= roundId, "Incomplete round");

if (block.timestamp - updatedAt >= MAX_STALENESS) {
Comment thread solidity/contracts/PriceOracle.sol Outdated

require(fbPrice > 0, "Invalid price");
require(fbAnsweredInRound >= fbRoundId, "Incomplete round");
require(block.timestamp - fbUpdatedAt < MAX_STALENESS, "Stale price");
Comment thread solidity/test/PriceOracle.test.js Outdated
Comment on lines +31 to +32
const tx = await priceOracle.getLatestPrice();
const price = await priceOracle.getLatestPrice.staticCall();

import "./PriceOracle.sol";

contract MockAggregator is AggregatorV3Interface {
Comment thread solidity/package.json Outdated
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Comment on lines +1 to +5
{
"agent": "Antigravity",
"initial_directives": "You are Antigravity, a powerful agentic AI coding assistant designed by the Google DeepMind team working on Advanced Agentic Coding. You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question.",
"date": "2026-06-01T16:08:34Z"
}
@KHHH2312
Copy link
Copy Markdown
Author

KHHH2312 commented Jun 1, 2026

I have addressed the Copilot review comments. I fixed the dimensional inconsistency with staleness boundaries, explicitly rejected updatedAt == 0 for both the primary and fallback feeds, renamed MAX_STALENESS to maxStaleness, fixed the unused variable in the test, and expanded MockAggregator to fully implement AggregatorV3Interface. Note: I left the generation_meta.json file alongside the contract code as strictly requested by the bounty issue, and getLatestPrice remains non-view because the StalePrice event is a required acceptance criteria.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Unfortunately the changes in this PR didn't fully resolve the issue. Please rework your solution and submit a new pull request.

Make sure to review the acceptance criteria in the linked issue and verify all conditions are met before resubmitting. See CONTRIBUTING.md for guidelines.

@github-actions github-actions Bot closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ Crypto ] Fix PriceOracle missing staleness check and fallback mechanism

2 participants