Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions FireHorseConsumer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract FireHorseConsumer {
AggregatorV3Interface internal oracle;
address public owner;

constructor(address _oracle) {
oracle = AggregatorV3Interface(_oracle);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

owner = msg.sender;
}

function getSignal() public view returns (string memory) {
(, int256 answer, , , ) = oracle.latestRoundData();
return answer == 1 ? "LONG" : "SHORT";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

}

function autoTrade() external {
require(msg.sender == owner, "Only owner");

string memory sig = getSignal();
sig;
// TODO: Integrate DEX execution logic based on signal.
}
}