Add FireHorseConsumer Chainlink signal consumer contract#4
Add FireHorseConsumer Chainlink signal consumer contract#4jpbpari-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: 16daaa4d08
ℹ️ 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 getSignal() public view returns (string memory) { | ||
| (, int256 answer, , , ) = oracle.latestRoundData(); | ||
| return answer == 1 ? "LONG" : "SHORT"; |
There was a problem hiding this comment.
Validate oracle answers instead of defaulting to SHORT
getSignal() maps every non-1 response to "SHORT", so any unexpected oracle value (for example 0, 2, or a temporary bad payload) is treated as an active short signal. In contexts where autoTrade() will execute positions, this can flip strategy decisions on invalid data rather than failing safely; handle only explicitly supported encodings and revert/hold for anything else.
Useful? React with 👍 / 👎.
| address public owner; | ||
|
|
||
| constructor(address _oracle) { | ||
| oracle = AggregatorV3Interface(_oracle); |
There was a problem hiding this comment.
Reject invalid oracle address at deployment
The constructor accepts _oracle without validation, so a misconfigured deployment (e.g., address(0) or a non-aggregator address) will leave the contract unable to return a signal because latestRoundData() cannot be decoded as expected. Failing fast in the constructor with an address/code check prevents shipping a permanently broken consumer.
Useful? React with 👍 / 👎.
Motivation
LONG/SHORTand expose an owner-gated hook for future DEX execution.Description
FireHorseConsumer.solwhich includes SPDX andpragma, importsAggregatorV3Interface, storesoracleandowner, implementsgetSignal()mappinganswer == 1to"LONG"and otherwise"SHORT", and provides anautoTrade()owner-only stub for integrating DEX logic.Testing
Codex Task