OracleId examples
mapping(address => mapping(uint256 => uint256)) private dataCache;interface IChainlinkOracle {
function getLatestPrice() external returns(int);
}
contract OracleIdar is IOracleId, Ownable {
IOracleAggregator oracleAggregator;
uint256 public result;
constructor(address _registry) public {
IRegistry registry = IRegistry(_registry);
oracleAggregator = IOracleAggregator(registry.getOracleAggregator());
}
/// @notice Wrapper around Opium oracleAggregator.__callback to push the data related to the underlying's market price
/// @param _oracleSubId address of the oracleSubId - the data source whose result is being pushed into the OracleAggregator
/// @param _timestamp uint256 unix timestamp of when the data is being pushed
function __callback(address _oracleSubId, uint256 _timestamp) external onlyOwner {
require(
!oracleAggregator.hasData(address(this), _timestamp) && _timestamp < now,
"Only when no data and after timestamp allowed"
);
uint256 data = uint256(IChainlinkOracle(_oracleSubId).getLatestPrice());
result = data;
oracleAggregator.__callback(_timestamp, result);
}
function fetchData(uint256 timestamp) external payable {}
function recursivelyFetchData(
uint256 timestamp,
uint256 period,
uint256 times
) external payable {}
function calculateFetchPrice() external returns (uint256 fetchPrice) {}
}Last updated