-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
M-02 [Oval] Attempts to Push Price to the CoinbaseOracle Will Always Fail #18
M-02 [Oval] Attempts to Push Price to the CoinbaseOracle Will Always Fail #18
Conversation
Signed-off-by: Pablo Maldonado <[email protected]>
@@ -7,10 +7,10 @@ interface IAggregatorV3SourceCoinbase { | |||
function latestRoundData(string memory ticker) | |||
external | |||
view | |||
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, we can simplify the return values, given that they don’t match the Chainlink Aggregator interface anymore with the ticker argument.
src/oracles/CoinbaseOracle.sol
Outdated
* @param _reporter The address of the reporter allowed to push price data. | ||
*/ | ||
constructor(uint8 _decimals, address _reporter) { | ||
constructor(uint8 _decimals, string memory _dataKind, address _reporter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now can pass a data kind in the constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's always prices
then we should not yet the deployer to define this, I think? if it should always be a hard-coded value then we should hard-code it.
Signed-off-by: Pablo Maldonado <[email protected]>
Signed-off-by: Pablo Maldonado <[email protected]>
src/oracles/CoinbaseOracle.sol
Outdated
uint256 timestamp, // e.g. 1629350000 | ||
string memory ticker, // e.g. "BTC" | ||
uint256 price // 6 decimals | ||
) = abi.decode(priceData, (string, uint256, string, uint256)); | ||
|
||
require(keccak256(abi.encodePacked(kind)) == keccak256(abi.encodePacked("price")), "Invalid kind."); | ||
require(keccak256(abi.encodePacked(kind)) == keccak256(abi.encodePacked("prices")), "Invalid kind."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be better to use constant for KIND
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or bytes32 public immutable KIND_HASH = keccak256(abi.encodePacked("prices"));
src/oracles/CoinbaseOracle.sol
Outdated
function reporter() public view virtual returns (address) { | ||
return 0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better leave as immutable. If mock needs override then can do that in mock constructor
src/oracles/CoinbaseOracle.sol
Outdated
@@ -8,48 +8,45 @@ 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 immutable reporter; | |||
uint8 public immutable decimals = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also if we make it immutable I think it should be all uppercase, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good so far but needs a bit of refinement to be more consistent. ever immutable should be uppercase, for example.
Signed-off-by: Pablo Maldonado <[email protected]>
src/oracles/CoinbaseOracle.sol
Outdated
@@ -8,48 +8,47 @@ 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 immutable reporter; | |||
address public reporter = 0xfCEAdAFab14d46e20144F48824d0C09B1a03F2BC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will have state reading overhead in production. better use the same approach as for decimals, like have upper case constant and lovercase getter function
Signed-off-by: Pablo Maldonado <[email protected]>
Fixes the following issue reported in the Oval Incremental Audit:
Changes:
string memory _dataKind
argument instead of having a hardcoded "price" value