Add FireHorsePriceConsumer Chainlink ETH/USD feed consumer (Sepolia)#3
Add FireHorsePriceConsumer Chainlink ETH/USD feed consumer (Sepolia)#3jpbpari-sys wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cecb0a73b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| function getLatestPrice() public view returns (int) { | ||
| (, int price,,,) = priceFeed.latestRoundData(); // Returns price * 10^8 |
There was a problem hiding this comment.
Validate round freshness before using Chainlink answer
getLatestPrice() ignores the metadata returned by latestRoundData(), so checkSignal() can make LONG/SHORT decisions from stale or incomplete rounds when the feed is delayed or recovering. In those scenarios the contract returns a seemingly valid signal from outdated data, which can corrupt downstream strategy logic; add round-validity checks (for example updatedAt != 0 and answeredInRound >= roundId, plus an optional staleness window) before accepting price.
Useful? React with 👍 / 👎.
Motivation
checkSignal()helper that maps price into a simple LONG/SHORT decision for downstream logic.Description
FireHorsePriceConsumer.solwhich importsAggregatorV3Interfaceand initializes the Sepolia ETH/USD feed at0x694AA1769357215DE4FAC081bf1f309aDC325306in the constructor.getLatestPrice()to return the latestanswerfromlatestRoundData()(price is returned scaled by 10^8).checkSignal()which returns"LONG"ifprice > 3000 * 10**8and"SHORT"otherwise.Testing
solc --versionto attempt compilation, but this failed becausesolcis not installed in the environment (failed).git status --shortwhich listed the new file (succeeded).nl -ba FireHorsePriceConsumer.solto confirm the source (succeeded).Codex Task