Skip to content

Commit

Permalink
feat: use osm in source adapter
Browse files Browse the repository at this point in the history
Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
  • Loading branch information
Reinis-FRP committed Aug 28, 2023
1 parent 8a06624 commit dc58950
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/adapters/makerdao/ChronicleSourceOracleAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
pragma solidity 0.8.17;

import "../../interfaces/IBaseOracleAdapter.sol";
import "../../interfaces/chronicle/IMedian.sol";
import "../../interfaces/chronicle/IOSM.sol";

contract ChronicleSourceOracleAdapter is IBaseOracleAdapter {
IMedian public source;
IOSM public source;

// MakerDAO performs decimal conversion in collateral adapter contracts, so all oracle prices are expected to have
// 18 decimals.
uint8 public constant decimals = 18;

constructor(IMedian _source) {
constructor(IOSM _source) {
source = _source;
}

function latestAnswer() public view override returns (int256) {
return int256((source.read() * (10 ** 18)) / (10 ** decimals));
return int256((uint(source.read()) * (10 ** 18)) / (10 ** decimals));
}

function latestTimestamp() public view override returns (uint256) {
return source.age();
return source.zzz();
}
}
4 changes: 2 additions & 2 deletions src/interfaces/chronicle/IOSM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IOSM {
// function src() external view returns (address); // Address of source oracle.

// function hop() external view returns (uint16); // Oracle delay in seconds.
// function zzz() external view returns (uint64); // Start of current period timestamp.
function zzz() external view returns (uint64); // Start of period timestamp when the price was last updated.

// function bud(address _addr) external view returns (uint256); // Whitelisted contracts, set by an auth

Expand All @@ -28,7 +28,7 @@ interface IOSM {

function peek() external view returns (bytes32, bool); // Return current price and if valid (whitelisted)
// function peep() external view returns (bytes32, bool); // Return the next price and if valid (whitelisted)
// function read() external view returns (bytes32); // Return current price, only if valid (whitelisted)
function read() external view returns (bytes32); // Return current price, only if valid (whitelisted)

// function kiss(address a) external; // Add address to whitelist (auth)
// function diss(address a) external; // Remove address from whitelist (auth)
Expand Down

0 comments on commit dc58950

Please sign in to comment.