diff --git a/src/oracles/CoinbaseOracle.sol b/src/oracles/CoinbaseOracle.sol index 6d2c8d3..38e65fe 100644 --- a/src/oracles/CoinbaseOracle.sol +++ b/src/oracles/CoinbaseOracle.sol @@ -8,7 +8,7 @@ import {IAggregatorV3SourceCoinbase} from "../interfaces/coinbase/IAggregatorV3S * @notice A smart contract that serves as an oracle for price data reported by a designated reporter. */ contract CoinbaseOracle is IAggregatorV3SourceCoinbase { - address public reporter = 0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC; + address public immutable REPORTER = 0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC; uint8 public immutable DECIMALS = 6; bytes32 public immutable KIND_HASH = keccak256(abi.encodePacked("prices")); @@ -34,6 +34,14 @@ contract CoinbaseOracle is IAggregatorV3SourceCoinbase { return DECIMALS; } + /** + * @notice Returns the address of the reporter. + * @return The address of the reporter. + */ + function reporter() public view virtual returns (address) { + return REPORTER; + } + /** * @notice Returns the latest round data for a given ticker. * @param ticker The ticker symbol to retrieve the data for. @@ -93,7 +101,7 @@ contract CoinbaseOracle is IAggregatorV3SourceCoinbase { uint256 latestTimestamp = priceDataStruct.rounds[priceDataStruct.lastRoundId].timestamp; require(timestamp > latestTimestamp, "Invalid timestamp."); - require(recoverSigner(priceData, signature) == reporter, "Invalid signature."); + require(recoverSigner(priceData, signature) == reporter(), "Invalid signature."); require(price <= uint256(type(int256).max), "Price exceeds max value."); priceDataStruct.lastRoundId++; diff --git a/test/mocks/MockCoinbaseOracle.sol b/test/mocks/MockCoinbaseOracle.sol index 8bf2222..d712d6a 100644 --- a/test/mocks/MockCoinbaseOracle.sol +++ b/test/mocks/MockCoinbaseOracle.sol @@ -4,7 +4,13 @@ pragma solidity 0.8.17; import {CoinbaseOracle} from "../../src/oracles/CoinbaseOracle.sol"; contract MockCoinbaseOracle is CoinbaseOracle { + address public customReporter; + constructor(address _customReporter) { - reporter = _customReporter; + customReporter = _customReporter; + } + + function reporter() public view override returns (address) { + return customReporter; } }