Contract 0x74cadbdf7850abd4f9bd355e528a9b23a2d334b4

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xaecae3e57db10952c1bd4a2f1b2c6731934f2734a192558ca1c9eb5a7b53198bUpdate Oracle Fo...28958312021-11-08 0:35:0319 days 23 hrs ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  0x74cadbdf7850abd4f9bd355e528a9b23a2d334b40 ETH0.000939099327 ETH
0x24697fd6934d25eefa16a15c509623d8e0900cab486085d514cfec19249d7a5dUpdate Oracle Fo...26355122021-10-27 23:25:0431 days 33 mins ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  0x74cadbdf7850abd4f9bd355e528a9b23a2d334b40 ETH0.001226531746 ETH
0x60d54219909330af1e20ffd7fa061827989f1fd07a8fbeb7aa423e4f2b8679ec0x6080604026355092021-10-27 23:25:0431 days 33 mins ago0xde485812e28824e542b9c2270b6b8ed9232b7d0b IN  Contract Creation0 ETH0.019516178079 ETH
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PriceOracleAggregator

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, Unlicense license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 6 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 2 of 6 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 3 of 6 : IERC20.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 * NOTE: Modified to include symbols and decimals.
 */
interface IERC20 {
  function totalSupply() external view returns (uint256);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint8);

  function balanceOf(address account) external view returns (uint256);

  function transfer(address recipient, uint256 amount) external returns (bool);

  function allowance(address owner, address spender)
    external
    view
    returns (uint256);

  function approve(address spender, uint256 amount) external returns (bool);

  function transferFrom(
    address sender,
    address recipient,
    uint256 amount
  ) external returns (bool);

  event Transfer(address indexed from, address indexed to, uint256 value);
  event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 4 of 6 : IOracle.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IOracle {
  event PriceUpdated(address asset, uint256 newPrice);

  function getPriceInUSD() external returns (uint256);

  function viewPriceInUSD() external view returns (uint256);
}

File 5 of 6 : IPriceOracleAggregator.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import { IOracle } from "./IOracle.sol";

interface IPriceOracleAggregator {
  event UpdateOracle(address token, IOracle oracle);

  function getPriceInUSD(address _token) external returns (uint256);

  function updateOracleForAsset(address _asset, IOracle _oracle) external;

  function viewPriceInUSD(address _token) external view returns (uint256);
}

File 6 of 6 : PriceOracleAggregator.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

// Interfaces
import {IERC20} from '../external/interfaces/IERC20.sol';
import {IPriceOracleAggregator} from '../interfaces/IPriceOracleAggregator.sol';
import {IOracle} from '../interfaces/IOracle.sol';

// Contracts
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';

contract PriceOracleAggregator is IPriceOracleAggregator, Ownable {
    /// @notice token to the oracle address
    mapping(address => IOracle) public assetToOracle;

    /// @notice adds oracle for an asset e.g. ETH
    /// @param _asset the oracle for the asset
    /// @param _oracle the oracle address
    function updateOracleForAsset(address _asset, IOracle _oracle)
        external
        override
        onlyOwner
    {
        require(
            address(_oracle) != address(0),
            'PriceOracleAggregator: Oracle address cannot be zero address'
        );
        assetToOracle[_asset] = _oracle;
        emit UpdateOracle(_asset, _oracle);
    }

    /// @notice returns price of token in USD in 1e8 decimals
    /// @param _token token to fetch price
    function getPriceInUSD(address _token) external override returns (uint256) {
        require(
            address(assetToOracle[_token]) != address(0),
            'PriceOracleAggregator: Oracle address cannot be zero address'
        );

        uint256 price = assetToOracle[_token].getPriceInUSD();

        require(price > 0, 'PriceOracleAggregator: Price cannot be 0');

        return price;
    }

    /// @notice returns price of token in USD
    /// @param _token view price of token
    function viewPriceInUSD(address _token)
        external
        view
        override
        returns (uint256)
    {
        require(
            address(assetToOracle[_token]) != address(0),
            'PriceOracleAggregator: Oracle address cannot be zero address'
        );
        return assetToOracle[_token].viewPriceInUSD();
    }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"contract IOracle","name":"oracle","type":"address"}],"name":"UpdateOracle","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetToOracle","outputs":[{"internalType":"contract IOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getPriceInUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"contract IOracle","name":"_oracle","type":"address"}],"name":"updateOracleForAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"viewPriceInUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506106a1806100616000396000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063715018a61161005b578063715018a6146100fe5780638da5cb5b14610106578063eb9d14a914610117578063f2fde38b1461012a57600080fd5b806302266147146100825780632e00d245146100a85780635df52114146100e9575b600080fd5b61009561009036600461054e565b61013d565b6040519081526020015b60405180910390f35b6100d16100b636600461054e565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161009f565b6100fc6100f7366004610571565b610273565b005b6100fc61032e565b6000546001600160a01b03166100d1565b61009561012536600461054e565b6103a2565b6100fc61013836600461054e565b610464565b6001600160a01b0381811660009081526001602052604081205490911661017f5760405162461bcd60e51b8152600401610176906105f6565b60405180910390fd5b6001600160a01b0380831660009081526001602090815260408083205481516370d5301b60e11b815291519394169263e1aa60369260048084019391929182900301818787803b1580156101d257600080fd5b505af11580156101e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020a91906105a9565b90506000811161026d5760405162461bcd60e51b815260206004820152602860248201527f50726963654f7261636c6541676772656761746f723a2050726963652063616e60448201526706e6f7420626520360c41b6064820152608401610176565b92915050565b6000546001600160a01b0316331461029d5760405162461bcd60e51b8152600401610176906105c1565b6001600160a01b0381166102c35760405162461bcd60e51b8152600401610176906105f6565b6001600160a01b0382811660008181526001602090815260409182902080546001600160a01b031916948616948517905581519283528201929092527fb1d1442dba579887e297ac433e5716c847abf2dc052ee9de4869b7b1b8f6206d910160405180910390a15050565b6000546001600160a01b031633146103585760405162461bcd60e51b8152600401610176906105c1565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6001600160a01b038181166000908152600160205260408120549091166103db5760405162461bcd60e51b8152600401610176906105f6565b6001600160a01b0380831660009081526001602090815260409182902054825163f55fa17f60e01b8152925193169263f55fa17f926004808201939291829003018186803b15801561042c57600080fd5b505afa158015610440573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026d91906105a9565b6000546001600160a01b0316331461048e5760405162461bcd60e51b8152600401610176906105c1565b6001600160a01b0381166104f35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610176565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006020828403121561055f578081fd5b813561056a81610653565b9392505050565b60008060408385031215610583578081fd5b823561058e81610653565b9150602083013561059e81610653565b809150509250929050565b6000602082840312156105ba578081fd5b5051919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252603c908201527f50726963654f7261636c6541676772656761746f723a204f7261636c6520616460408201527f64726573732063616e6e6f74206265207a65726f206164647265737300000000606082015260800190565b6001600160a01b038116811461066857600080fd5b5056fea2646970667358221220dd41fdb66c0da23ef39027c6ef2accc5fe4a8f7ff110e557418fbfed2b583dd264736f6c63430008040033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.