Skip to content

Commit

Permalink
feat: decimals
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
  • Loading branch information
md0x committed May 9, 2024
1 parent 16b71bf commit a632a58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/oracles/CoinbaseOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IAggregatorV3Source} from "../interfaces/chainlink/IAggregatorV3Source.s
contract CoinbaseOracle is IAggregatorV3Source {
address immutable reporter;

uint8 public constant decimals = 6;
uint8 public immutable decimals;

string public symbol;

Expand All @@ -15,8 +15,9 @@ contract CoinbaseOracle is IAggregatorV3Source {
mapping(uint80 => int256) public roundAnswers;
mapping(uint80 => uint256) public roundTimestamps;

constructor(string memory _symbol, address _reporter) {
constructor(string memory _symbol, uint8 _decimals, address _reporter) {
symbol = _symbol;
decimals = _decimals;
reporter = _reporter;
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/CoinbaseOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract CoinbaseSourceAdapterTest is CommonTest {
(address _reporter, uint256 _reporterPk) = makeAddrAndKey("reporter");
reporter = _reporter;
reporterPk = _reporterPk;
coinbaseOracle = new CoinbaseOracle("ETH", reporter);
coinbaseOracle = new CoinbaseOracle("ETH", 6, reporter);
}

function testPushPrice() public {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/CoinbaseOracleSourceAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract CoinbaseSourceAdapterTest is CommonTest {
(address _reporter, uint256 _reporterPk) = makeAddrAndKey("reporter");
reporter = _reporter;
reporterPk = _reporterPk;
coinbase = new CoinbaseOracle(ticker, reporter);
coinbase = new CoinbaseOracle(ticker, 6, reporter);
sourceAdapter = new TestedSourceAdapter(coinbase);

// Push some prices to the oracle
Expand Down Expand Up @@ -183,7 +183,7 @@ contract CoinbaseSourceAdapterTest is CommonTest {
}

function testNonHistoricalData() public {
coinbase = new CoinbaseOracle(ticker, reporter);
coinbase = new CoinbaseOracle(ticker, 6, reporter);
sourceAdapter = new TestedSourceAdapter(coinbase);

// Push only one price to the oracle
Expand Down

0 comments on commit a632a58

Please sign in to comment.