Antigravity [ Crypto ] Fix PriceOracle missing staleness check and fallback mechanism#5915
Antigravity [ Crypto ] Fix PriceOracle missing staleness check and fallback mechanism#5915KHHH2312 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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
PriceOracleto validate price, round completeness, and staleness, with fallback to a secondary feed. - Adds a
MockAggregatortest helper implementingAggregatorV3Interface. - 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) { |
| require(price > 0, "Invalid price"); | ||
| require(answeredInRound >= roundId, "Incomplete round"); | ||
|
|
||
| if (block.timestamp - updatedAt >= MAX_STALENESS) { |
| AggregatorV3Interface public primaryFeed; | ||
| AggregatorV3Interface public fallbackFeed; | ||
| address public owner; | ||
| uint256 public MAX_STALENESS = 3600; |
| require(price > 0, "Invalid price"); | ||
| require(answeredInRound >= roundId, "Incomplete round"); | ||
|
|
||
| if (block.timestamp - updatedAt >= MAX_STALENESS) { |
|
|
||
| require(fbPrice > 0, "Invalid price"); | ||
| require(fbAnsweredInRound >= fbRoundId, "Incomplete round"); | ||
| require(block.timestamp - fbUpdatedAt < MAX_STALENESS, "Stale price"); |
| const tx = await priceOracle.getLatestPrice(); | ||
| const price = await priceOracle.getLatestPrice.staticCall(); |
|
|
||
| import "./PriceOracle.sol"; | ||
|
|
||
| contract MockAggregator is AggregatorV3Interface { |
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" |
| { | ||
| "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" | ||
| } |
|
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. |
|
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. |
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.