Contract 0xEA376E7BFd071061B200921229990C98D232129C

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x97b3f3b86380bfa4f9eedf4a3cd48e80d8823490dd1f5bef79d798e5bffdf7830x60806040161728662022-11-15 17:12:1317 days 18 hrs ago0x7b125320a3ceb1c9f7ed93d76c6009a2e77f2603 IN  Create: PriceFeed0 CELO0.000357721
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PriceFeed

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

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

pragma solidity ^0.8.0;

import "./interfaces/IPriceFeed.sol";
import "./interfaces/IStdReference.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title A standard interface for asking for prices from an Oracle
 */
contract PriceFeed is Ownable, IPriceFeed {
    
    enum PriceFeedType { CHAINLINK, BAND }

    address public priceFeedAddress;

    PriceFeedType public priceFeedType;
    string public bandBase;
    string public bandQuote;

    constructor(address _priceFeedAddress, PriceFeedType _priceFeedType, string memory _bandBase, string memory _bandQuote) {
        require(_priceFeedType == PriceFeedType.CHAINLINK || _priceFeedType == PriceFeedType.BAND, "Invalid price feed type");
        priceFeedType = _priceFeedType;
        priceFeedAddress = _priceFeedAddress;
        bandBase = _bandBase;
        bandQuote = _bandQuote;
    }

    /// @dev Get the latest price for this price feed
    /// @return price The last price
    /// @return decimals The number of decimals in the price
    function lastPrice() external view returns (uint price, uint8 decimals) {
        if (priceFeedType == PriceFeedType.CHAINLINK) {
            AggregatorV3Interface chainlinkPriceFeed = AggregatorV3Interface(priceFeedAddress);
            (, int256 aggPrice, , , ) = chainlinkPriceFeed.latestRoundData();
            price = uint(aggPrice);
            decimals = chainlinkPriceFeed.decimals();
        } else if (priceFeedType == PriceFeedType.BAND) {
            IStdReference bandPriceFeed = IStdReference(priceFeedAddress);
            price = bandPriceFeed.getReferenceData(bandBase, bandQuote).rate;
            decimals = 18;
        }
    }

    function setPriceFeedChainlink(address _priceFeedAddress) public onlyOwner {
        priceFeedType = PriceFeedType.CHAINLINK;
        priceFeedAddress = _priceFeedAddress;
    }

    function setPriceFeedBand(address _priceFeedAddress, string calldata _bandBase, string calldata _bandQuote) public onlyOwner {
        priceFeedType = PriceFeedType.BAND;
        priceFeedAddress = _priceFeedAddress;
        bandBase = _bandBase;
        bandQuote = _bandQuote;
    }    
}

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

pragma solidity ^0.8.0;

/**
 * @title A standard interface for asking for prices from an Oracle
 */
interface IPriceFeed {

    /// @dev Get the latest price for this price feed
    /// @return price The last price
    /// @return decimals The number of decimals in the price
    function lastPrice() external view returns (uint price, uint8 decimals);
}

File 3 of 6 : IStdReference.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IStdReference {
    /// A structure returned whenever someone requests for standard reference data.
    struct ReferenceData {
        uint256 rate; // base/quote exchange rate, multiplied by 1e18.
        uint256 lastUpdatedBase; // UNIX epoch of the last time when base price gets updated.
        uint256 lastUpdatedQuote; // UNIX epoch of the last time when quote price gets updated.
    }

    /// Returns the price data for the given base/quote pair. Revert if not available.
    function getReferenceData(string memory _base, string memory _quote)
        external
        view
        returns (ReferenceData memory);

    /// Similar to getReferenceData, but with multiple base/quote pairs at once.
    function getReferenceDataBulk(string[] memory _bases, string[] memory _quotes)
        external
        view
        returns (ReferenceData[] memory);
}

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

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

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

  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

File 5 of 6 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

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() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        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 {
        _transferOwnership(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");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 6 of 6 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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) {
        return msg.data;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"address","name":"_priceFeedAddress","type":"address"},{"internalType":"enum PriceFeed.PriceFeedType","name":"_priceFeedType","type":"uint8"},{"internalType":"string","name":"_bandBase","type":"string"},{"internalType":"string","name":"_bandQuote","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"bandBase","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bandQuote","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeedType","outputs":[{"internalType":"enum PriceFeed.PriceFeedType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedAddress","type":"address"},{"internalType":"string","name":"_bandBase","type":"string"},{"internalType":"string","name":"_bandQuote","type":"string"}],"name":"setPriceFeedBand","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeedAddress","type":"address"}],"name":"setPriceFeedChainlink","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162000e2938038062000e29833981016040819052620000349162000308565b6200003f3362000145565b6000836001811115620000565762000056620003ab565b14806200007757506001836001811115620000755762000075620003ab565b145b620000c85760405162461bcd60e51b815260206004820152601760248201527f496e76616c696420707269636520666565642074797065000000000000000000604482015260640160405180910390fd5b6001805484919060ff60a01b1916600160a01b8383811115620000ef57620000ef620003ab565b0217905550600180546001600160a01b0319166001600160a01b03861617905581516200012490600290602085019062000195565b5080516200013a90600390602084019062000195565b5050505050620003fe565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b828054620001a390620003c1565b90600052602060002090601f016020900481019282620001c7576000855562000212565b82601f10620001e257805160ff191683800117855562000212565b8280016001018555821562000212579182015b8281111562000212578251825591602001919060010190620001f5565b506200022092915062000224565b5090565b5b8082111562000220576000815560010162000225565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200026357600080fd5b81516001600160401b03808211156200028057620002806200023b565b604051601f8301601f19908116603f01168101908282118183101715620002ab57620002ab6200023b565b81604052838152602092508683858801011115620002c857600080fd5b600091505b83821015620002ec5785820183015181830184015290820190620002cd565b83821115620002fe5760008385830101525b9695505050505050565b600080600080608085870312156200031f57600080fd5b84516001600160a01b03811681146200033757600080fd5b6020860151909450600281106200034d57600080fd5b60408601519093506001600160401b03808211156200036b57600080fd5b620003798883890162000251565b935060608701519150808211156200039057600080fd5b506200039f8782880162000251565b91505092959194509250565b634e487b7160e01b600052602160045260246000fd5b600181811c90821680620003d657607f821691505b60208210811415620003f857634e487b7160e01b600052602260045260246000fd5b50919050565b610a1b806200040e6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639ab64c75116100665780639ab64c751461012c578063a400f3431461013f578063afa22d1f14610152578063e0abca0b1461015a578063f2fde38b1461016d57600080fd5b8063053f14da146100a357806326d182d5146100c75780633fd0875f146100dc578063715018a6146100fd5780638da5cb5b14610107575b600080fd5b6100ab610180565b6040805192835260ff9091166020830152015b60405180910390f35b6100cf610364565b6040516100be919061064a565b6001546100f090600160a01b900460ff1681565b6040516100be91906106b5565b6101056103f2565b005b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100be565b61010561013a3660046106f9565b610406565b61010561014d366004610764565b610430565b6100cf61047c565b600154610114906001600160a01b031681565b61010561017b3660046106f9565b610489565b6000808060018054600160a01b900460ff16908111156101a2576101a261069f565b14156102ac5760015460408051633fabe5a360e21b815290516001600160a01b0390921691600091839163feaf968c9160048082019260a092909190829003018186803b1580156101f257600080fd5b505afa158015610206573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061022a91906107ff565b505050915050809350816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561026c57600080fd5b505afa158015610280573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a4919061084f565b925050509091565b6001808054600160a01b900460ff16908111156102cb576102cb61069f565b14156103605760015460405163195556f360e21b81526001600160a01b039091169081906365555bcc906103079060029060039060040161094d565b60606040518083038186803b15801561031f57600080fd5b505afa158015610333573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610357919061097b565b51925060129150505b9091565b6002805461037190610872565b80601f016020809104026020016040519081016040528092919081815260200182805461039d90610872565b80156103ea5780601f106103bf576101008083540402835291602001916103ea565b820191906000526020600020905b8154815290600101906020018083116103cd57829003601f168201915b505050505081565b6103fa610507565b6104046000610561565b565b61040e610507565b600180546001600160a81b0319166001600160a01b0392909216919091179055565b610438610507565b600180546001600160a01b0387166001600160a81b031990911617600160a01b179055610467600285856105b1565b50610474600383836105b1565b505050505050565b6003805461037190610872565b610491610507565b6001600160a01b0381166104fb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61050481610561565b50565b6000546001600160a01b031633146104045760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104f2565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8280546105bd90610872565b90600052602060002090601f0160209004810192826105df5760008555610625565b82601f106105f85782800160ff19823516178555610625565b82800160010185558215610625579182015b8281111561062557823582559160200191906001019061060a565b50610631929150610635565b5090565b5b808211156106315760008155600101610636565b600060208083528351808285015260005b818110156106775785810183015185820160400152820161065b565b81811115610689576000604083870101525b50601f01601f1916929092016040019392505050565b634e487b7160e01b600052602160045260246000fd5b60208101600283106106d757634e487b7160e01b600052602160045260246000fd5b91905290565b80356001600160a01b03811681146106f457600080fd5b919050565b60006020828403121561070b57600080fd5b610714826106dd565b9392505050565b60008083601f84011261072d57600080fd5b50813567ffffffffffffffff81111561074557600080fd5b60208301915083602082850101111561075d57600080fd5b9250929050565b60008060008060006060868803121561077c57600080fd5b610785866106dd565b9450602086013567ffffffffffffffff808211156107a257600080fd5b6107ae89838a0161071b565b909650945060408801359150808211156107c757600080fd5b506107d48882890161071b565b969995985093965092949392505050565b805169ffffffffffffffffffff811681146106f457600080fd5b600080600080600060a0868803121561081757600080fd5b610820866107e5565b9450602086015193506040860151925060608601519150610843608087016107e5565b90509295509295909350565b60006020828403121561086157600080fd5b815160ff8116811461071457600080fd5b600181811c9082168061088657607f821691505b602082108114156108a757634e487b7160e01b600052602260045260246000fd5b50919050565b8054600090600181811c90808316806108c757607f831692505b60208084108214156108e957634e487b7160e01b600052602260045260246000fd5b83885260208801828015610904576001811461091557610940565b60ff19871682528282019750610940565b60008981526020902060005b8781101561093a57815484820152908601908401610921565b83019850505b5050505050505092915050565b60408152600061096060408301856108ad565b828103602084015261097281856108ad565b95945050505050565b60006060828403121561098d57600080fd5b6040516060810181811067ffffffffffffffff821117156109be57634e487b7160e01b600052604160045260246000fd5b8060405250825181526020830151602082015260408301516040820152809150509291505056fea264697066735822122021481976d04d59b9b2d3864ea514a8beed139b6b18b6526ac6c174e7c94ea7d064736f6c63430008090033000000000000000000000000da7a001b254cd22e46d3eab04d937489c93174c30000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000443454c4f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035553440000000000000000000000000000000000000000000000000000000000

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000da7a001b254cd22e46d3eab04d937489c93174c30000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000443454c4f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035553440000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _priceFeedAddress (address): 0xda7a001b254cd22e46d3eab04d937489c93174c3
Arg [1] : _priceFeedType (uint8): 1
Arg [2] : _bandBase (string): CELO
Arg [3] : _bandQuote (string): USD

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000da7a001b254cd22e46d3eab04d937489c93174c3
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [5] : 43454c4f00000000000000000000000000000000000000000000000000000000
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [7] : 5553440000000000000000000000000000000000000000000000000000000000


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