Address Contract Partially Verified
Address
0x4c4bE5B8a551910C729F366AdD9A0C4c7304B169
Balance
0 ETH
Nonce
1
Code Size
1911 bytes
Creator
0xe068647C...5BD4 at tx 0x7679b1de...6316ef
Indexed Transactions
0
Contract Bytecode
1911 bytes
0x60806040526004361061009c5760003560e01c80637bc9f04a116100645780637bc9f04a14610177578063864905ba1461018c5780638dffe3f4146101a9578063a6f9dae1146101da578063b2bdfa7b1461020d578063de292789146102225761009c565b806336bdc026146100a15780634237a7ee146100c85780634ef7b428146100f45780637004128a1461011e578063760768db1461014e575b600080fd5b3480156100ad57600080fd5b506100b6610237565b60408051918252519081900360200190f35b3480156100d457600080fd5b506100f2600480360360208110156100eb57600080fd5b503561023d565b005b34801561010057600080fd5b506100f26004803603602081101561011757600080fd5b5035610287565b34801561012a57600080fd5b506100f26004803603604081101561014157600080fd5b50803590602001356103f9565b6100f26004803603606081101561016457600080fd5b5080359060208101359060400135610552565b34801561018357600080fd5b506100b6610585565b6100f2600480360360208110156101a257600080fd5b5035610552565b3480156101b557600080fd5b506101be61058a565b604080516001600160a01b039092168252519081900360200190f35b3480156101e657600080fd5b506100f2600480360360208110156101fd57600080fd5b50356001600160a01b0316610599565b34801561021957600080fd5b506101be610613565b34801561022e57600080fd5b506100b6610622565b60025481565b6001546001600160a01b03163314610282576040805162461bcd60e51b81526020600482015260036024820152624e2e4f60e81b604482015290519081900360640190fd5b600255565b6000546040805163c8384d2f60e01b81523060048201526024810184905290516001600160a01b039092169163c8384d2f91604480820192602092909190829003018186803b1580156102d957600080fd5b505afa1580156102ed573d6000803e3d6000fd5b505050506040513d602081101561030357600080fd5b505115801561031157504281105b610348576040805162461bcd60e51b81526020600482015260036024820152624e2e4160e81b604482015290519081900360640190fd5b6000610352610622565b6000805460408051633102e5ab60e01b8152600481018790526024810185905290519394506001600160a01b0390911692633102e5ab9260448084019391929182900301818387803b1580156103a757600080fd5b505af11580156103bb573d6000803e3d6000fd5b50506040805184815290518593507f03816c3f4e6debf1641698c8a95e240174914abf30d4155262df33d79744afad92509081900360200190a25050565b6001546001600160a01b0316331461043e576040805162461bcd60e51b81526020600482015260036024820152624e2e4f60e81b604482015290519081900360640190fd5b6000546040805163c8384d2f60e01b81523060048201526024810185905290516001600160a01b039092169163c8384d2f91604480820192602092909190829003018186803b15801561049057600080fd5b505afa1580156104a4573d6000803e3d6000fd5b505050506040513d60208110156104ba57600080fd5b50511580156104cc5750426002548301105b610503576040805162461bcd60e51b81526020600482015260036024820152624e2e4560e81b604482015290519081900360640190fd5b6000805460408051633102e5ab60e01b8152600481018690526024810185905290516001600160a01b0390921692633102e5ab9260448084019382900301818387803b1580156103a757600080fd5b6040805162461bcd60e51b81526020600482015260036024820152624e2e5360e81b604482015290519081900360640190fd5b600090565b6000546001600160a01b031681565b6001546001600160a01b031633146105de576040805162461bcd60e51b81526020600482015260036024820152624e2e4f60e81b604482015290519081900360640190fd5b6001600160a01b0381166105f157600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031681565b600080735f4ec3df9cbd43714fe2740f5e3616155c5b84196001600160a01b03166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561067257600080fd5b505afa158015610686573d6000803e3d6000fd5b505050506040513d602081101561069c57600080fd5b5051905060006106b7826402540be40063ffffffff6106be16565b9250505090565b6000826106cd5750600061071a565b828202828482816106da57fe5b04146107175760405162461bcd60e51b81526004018080602001828103825260218152602001806107216021913960400191505060405180910390fd5b90505b9291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212205ce24e9aead045db1d4049fb89e916fedf58a79af6520561d2d23c462882fab864736f6c63430006060033
Verified Source Code Partial Match
Compiler: v0.6.6+commit.6c089d02
EVM: petersburg
Optimization: Yes (200 runs)
EthUsdEthChainlinkOracleId.sol 307 lines
// File: @openzeppelin/contracts/math/SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: contracts/oracles/onchainSubIds/chainlink/EthUsdEthOracleSubId.sol
pragma solidity =0.6.6;
interface IShortAggregatorInterface {
function latestAnswer() external view returns (int256);
}
contract EthUsdEthOracleSubId {
using SafeMath for uint256;
function getResult() public view returns (uint256) {
// Instance of Chainlink ETH/USD price feed
uint256 ethUsdPrice = uint256(IShortAggregatorInterface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419).latestAnswer());
// Data are provided with 8 decimals, adjust to 18 decimals
uint256 result = ethUsdPrice.mul(1e10);
return result;
}
}
// File: contracts/oracles/chainlink/EthUsdEthChainlinkOracleId.sol
pragma solidity =0.6.6;
/// @title Opium.Interface.IOracleId contract is an interface that every oracleId should implement
interface IOracleId {
/// @notice Requests data from `oracleId` one time
/// @param timestamp uint256 Timestamp at which data are needed
function fetchData(uint256 timestamp) external payable;
/// @notice Requests data from `oracleId` multiple times
/// @param timestamp uint256 Timestamp at which data are needed for the first time
/// @param period uint256 Period in seconds between multiple timestamps
/// @param times uint256 How many timestamps are requested
function recursivelyFetchData(uint256 timestamp, uint256 period, uint256 times) external payable;
/// @notice Requests and returns price in ETH for one request. This function could be called as `view` function. Oraclize API for price calculations restricts making this function as view.
/// @return fetchPrice uint256 Price of one data request in ETH
function calculateFetchPrice() external returns (uint256 fetchPrice);
// Event with oracleId metadata JSON string (for DIB.ONE derivative explorer)
event MetadataSet(string metadata);
}
interface IOracleAggregator {
function __callback(uint256 timestamp, uint256 data) external;
function hasData(address oracleId, uint256 timestamp) external view returns(bool result);
}
contract EthUsdEthChainlinkOracleId is EthUsdEthOracleSubId, IOracleId {
event Provided(uint256 indexed timestamp, uint256 result);
// Opium
IOracleAggregator public oracleAggregator;
// Governance
address public _owner;
uint256 public EMERGENCY_PERIOD;
modifier onlyOwner() {
require(_owner == msg.sender, "N.O"); // N.O = not an owner
_;
}
constructor(IOracleAggregator _oracleAggregator, uint256 _emergencyPeriod) public {
// Opium
oracleAggregator = _oracleAggregator;
// Governance
_owner = msg.sender;
EMERGENCY_PERIOD = _emergencyPeriod;
/*
{
"author": "Opium.Team",
"description": "ETH/USD Oracle ID",
"asset": "ETH/USD",
"type": "onchain",
"source": "chainlink",
"logic": "none",
"path": "latestAnswer()"
}
*/
emit MetadataSet("{\"author\":\"Opium.Team\",\"description\":\"ETH/USD Oracle ID\",\"asset\":\"ETH/USD\",\"type\":\"onchain\",\"source\":\"chainlink\",\"logic\":\"none\",\"path\":\"latestAnswer()\"}");
}
/** OPIUM INTERFACE */
function fetchData(uint256 _timestamp) external payable override {
_timestamp;
revert("N.S"); // N.S = not supported
}
function recursivelyFetchData(uint256 _timestamp, uint256 _period, uint256 _times) external payable override {
_timestamp;
_period;
_times;
revert("N.S"); // N.S = not supported
}
function calculateFetchPrice() external override returns (uint256) {
return 0;
}
/** RESOLVER */
function _callback(uint256 _timestamp) public {
require(
!oracleAggregator.hasData(address(this), _timestamp) &&
_timestamp < now,
"N.A" // N.A = Only when no data and after timestamp allowed
);
uint256 result = getResult();
oracleAggregator.__callback(_timestamp, result);
emit Provided(_timestamp, result);
}
/** GOVERNANCE */
/**
Emergency callback allows to push data manually in case EMERGENCY_PERIOD elapsed and no data were provided
*/
function emergencyCallback(uint256 _timestamp, uint256 _result) public onlyOwner {
require(
!oracleAggregator.hasData(address(this), _timestamp) &&
_timestamp + EMERGENCY_PERIOD < now,
"N.E" // N.E = Only when no data and after emergency period allowed
);
oracleAggregator.__callback(_timestamp, _result);
emit Provided(_timestamp, _result);
}
function changeOwner(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
_owner = _newOwner;
}
function changeEmergencyPeriod(uint256 _newEmergencyPeriod) public onlyOwner {
EMERGENCY_PERIOD = _newEmergencyPeriod;
}
}
Read Contract
EMERGENCY_PERIOD 0x36bdc026 → uint256
_owner 0xb2bdfa7b → address
getResult 0xde292789 → uint256
oracleAggregator 0x8dffe3f4 → address
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
_callback 0x4ef7b428
uint256 _timestamp
calculateFetchPrice 0x7bc9f04a
No parameters
returns: uint256
changeEmergencyPeriod 0x4237a7ee
uint256 _newEmergencyPeriod
changeOwner 0xa6f9dae1
address _newOwner
emergencyCallback 0x7004128a
uint256 _timestamp
uint256 _result
fetchData 0x864905ba
uint256 _timestamp
recursivelyFetchData 0x760768db
uint256 _timestamp
uint256 _period
uint256 _times
Recent Transactions
No transactions found for this address