Contract 0xd61f42Ab1e575feF17748BfcdD81767a04952f81 2

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x6bb2db44c05904159000fed24991e1b47314cdf4fa29af5b2a01c9d580a48465_set Asset Key F...7056392022-03-29 10:18:36181 days 6 hrs ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  0xd61f42ab1e575fef17748bfcdd81767a04952f810 GLMR0.0073271
0x7ea3fa552c0f71633a470a545f9eb66069fa97a02312b2d405f52d0e971d070c_set Asset Key F...6723462022-03-24 15:37:42186 days 58 mins ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  0xd61f42ab1e575fef17748bfcdd81767a04952f810 GLMR0.0076446
0x7a737788e9784c1daadb8a0b917ee3e7bf4cc83939a89cdb1cf0cd0f7d443df8_set Asset Key F...6723442022-03-24 15:37:19186 days 58 mins ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  0xd61f42ab1e575fef17748bfcdd81767a04952f810 GLMR0.007760487
0x8ee33d57cb68e57fd419dcf8146787b52992f1c4e9633397e5558d1ef3fbe018_set Asset Key F...6723422022-03-24 15:36:54186 days 59 mins ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  0xd61f42ab1e575fef17748bfcdd81767a04952f810 GLMR0.007722258
0x1888fb88112bd84e49fd9a993caee02f392c9d97ebbbe5b0a4363c808afb8631_set Asset Key F...6723392022-03-24 15:36:34186 days 59 mins ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  0xd61f42ab1e575fef17748bfcdd81767a04952f810 GLMR0.0076446
0xdbdb913da1ad90b1e5a63c7f13860cb54f2070f18215ffc701ff179f5e5b79fa0x608060406723202022-03-24 15:32:18186 days 1 hr ago0xc333a03e8040cad31993e02615fd1b3f88447d95 IN  Create: DiaV2PriceOracle0 GLMR0.1028983655
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DiaV2PriceOracle

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 8 : DiaV2PriceOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;

import "../interfaces/IPriceOracle.sol";
import "../BasePriceOracle/BasePriceOracle.sol";

/**
* Based on https://docs.diadata.org/documentation/oracle-documentation/access-the-oracle#dia-key-value-oracle-contract-v2
*/
interface DiaOracleV2ForOracle {
    // returns (value, timestamp)
    function getValue(string memory key) external view returns (uint128, uint128);
}

/**
 * @title Ola's Witnet router based price oracle.
 * @author Ola
 */
contract DiaV2PriceOracle is BasePriceOracle {

    // The BAND protocol price source
    DiaOracleV2ForOracle public diaOracleV2;

    // Asset address -> matching key for the DIA V2 key-value protocol
    mapping(address => string) public assetsOracleKeys;

    event NewKeyConfiguredForAsset(address indexed asset, string indexed diaV2Key);

    constructor(address _diaOracleV2) {
        diaOracleV2 = DiaOracleV2ForOracle(_diaOracleV2);
    }

    function _setAssetKeyForUnderlying(address _underlying, string calldata diaV2Key) onlyOwner external {
        _setPriceFeedForUnderlyingInternal(_underlying, diaV2Key);
    }

    function _setAssetKeysForUnderlyings(address[] calldata _underlyings, string[] calldata _diaV2Keys) onlyOwner external {
        require(_underlyings.length == _diaV2Keys.length, "underlyings and keys should be 1:1");

        for (uint i = 0; i < _underlyings.length; i++) {
            _setPriceFeedForUnderlyingInternal(_underlyings[i], _diaV2Keys[i]);
        }
    }

    function _setPriceFeedForUnderlyingInternal(address _underlying, string memory _diaV2Key) internal {
        require(!isAssetSupported(_underlying), "Cannot reassign symbol");

        // BasePriceOracle
        _setDecimalsForAsset(_underlying);

        // DiaV2
        assetsOracleKeys[_underlying] = _diaV2Key;
        emit NewKeyConfiguredForAsset(_underlying, _diaV2Key);
    }

    /**
      * @notice Get the underlying price of a cToken asset
      * @param asset The asset (Erc20 or native)
      * @return The asset price mantissa (scaled by 1e(36 - assetDecimals)).
      *  Zero means the price is unavailable.
      */
    function getPriceFromSourceInternal(address asset) internal view override returns (uint) {
        uint8 assetDecimals = assetsDecimals[asset];
        string memory oracleKey = assetsOracleKeys[asset];

        int feedPriceRaw = getDiaV2Price(oracleKey);
        uint oraclePrice = uint(feedPriceRaw);

        // Sanity
        require(feedPriceRaw == uint128(oraclePrice), "Price Conversion error");

        // Needs to be scaled to e36 and then divided by the asset's decimals
        return (mul(1e28, oraclePrice) / (10 ** assetDecimals));
    }

    function getPriceUpdateTimestampFromSourceInternal(address asset) internal view override returns (uint) {
        string memory oracleKey = assetsOracleKeys[asset];

        int timestampRaw = getDiaV2UpdateTimestamp(oracleKey);

        return uint(timestampRaw);
    }

    function getDiaV2Price(string memory key) internal view returns (uint128 value) {
        (value, ) = getDiaV2KeyValueOracleResponse(key);
    }

    function getDiaV2UpdateTimestamp(string memory key) internal view returns (uint128) {
        uint128 updateTimestamp;
        (, updateTimestamp) = getDiaV2KeyValueOracleResponse(key);
        return updateTimestamp;
    }

    function getDiaV2KeyValueOracleResponse(string memory key) internal view returns(uint128 value, uint128 timestamp) {
        (value, timestamp) = diaOracleV2.getValue(key);
    }

    /// @dev Overflow proof multiplication
    function mul(uint a, uint b) internal pure returns (uint) {
        if (a == 0) return 0;
        uint c = a * b;
        require(c / a == b, "multiplication overflow");
        return c;
    }
}

File 2 of 8 : IPriceOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;

// Price oracle interface for solidity 0.7

interface ICTokenForPriceOracle {
    function underlying() external view returns (address);
}

/**
 * 0.7.6 Interface for "PriceOracle.sol"
 */
interface IPriceOracle {
    function isPriceOracle() external view returns (bool);
    function getAssetPrice(address asset) external view returns (uint);
    function getAssetPriceUpdateTimestamp(address asset) external view returns (uint);
    function getUnderlyingPrice(address cToken) external view returns (uint);
    function getUnderlyingPriceUpdateTimestamp(address cToken) external view returns (uint);
}

File 3 of 8 : BasePriceOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../interfaces/IPriceOracle.sol";

abstract contract BasePriceOracle is IPriceOracle, Ownable {

    event NewDecimalsConfiguredForAsset(address indexed asset, uint decimals);

    // Underlying -> assets decimals
    mapping(address => uint8) public assetsDecimals;

    // ******************
    // IPriceOracle Functions
    // ******************

    /**
     * @notice Get the price an asset
     * @param asset The asset to get the price of
     * @return The asset price mantissa (scaled by 1e(36 - assetDecimals)).
     *  Zero means the price is unavailable.
     */
    function getAssetPrice(address asset) external override view returns (uint) {
        return _getPriceForAssetInternalIfSupported(asset);
    }

    /**
     * @notice Get the price update timestamp for the asset
     * @param asset The asset address for price update timestamp retrieval.
     * @return Last price update timestamp for the asset
     */
    function getAssetPriceUpdateTimestamp(address asset) external override view returns (uint) {
        return _getPriceUpdateTimestampForAssetIfSupported(asset);
    }

    /**
      * @notice Get the underlying price of a cToken asset
      * @param cToken The cToken to get the underlying price of
      * @return The underlying asset price mantissa (scaled by 1e(36 - underlyingDecimals)).
      *  Zero means the price is unavailable.
      */
    function getUnderlyingPrice(address cToken) external override view returns (uint) {
        return _getPriceForAssetInternalIfSupported(ICTokenForPriceOracle(cToken).underlying());
    }

    /**
     * @notice Get the price update timestamp for the cToken underlying
     * @param cToken The cToken address for price update timestamp retrieval.
     * @return Last price update timestamp for the cToken underlying asset
     */
    function getUnderlyingPriceUpdateTimestamp(address cToken) external override view returns (uint) {
        return _getPriceUpdateTimestampForAssetIfSupported(ICTokenForPriceOracle(cToken).underlying());
    }

    function isPriceOracle() public override pure returns (bool) {
        return true;
    }

    // ******************
    // Public virtual Functions
    // ******************

    function isAssetSupported(address asset) public view virtual returns (bool) {
        uint8 decimals = assetsDecimals[asset];
        return decimals != 0;
    }

    // ******************
    // Internal Functions
    // ******************

    /**
     * @notice Get the underlying price of an asset
     * @param asset The asset (Erc20 or native)
     * @return The asset price mantissa (scaled by 1e(36 - assetDecimals)).
     *  Zero means the price is unavailable.
     */
    function _getPriceForAssetInternalIfSupported(address asset) internal view returns (uint) {
        if (isAssetSupported(asset)) {
            return getPriceFromSourceInternal(asset);
        } else {
            return 0;
        }
    }

    /**
     * @notice Get the underlying price update timestamp of an asset
     * @param asset The asset (Erc20 or native)
     * @return The asset update timestamp.
     *  Zero means the price update timestamp is unavailable.
     */
    function _getPriceUpdateTimestampForAssetIfSupported(address asset) internal view returns (uint) {
        if (isAssetSupported(asset)) {
            return getPriceUpdateTimestampFromSourceInternal(asset);
        } else {
            return 0;
        }
    }

    /**
     * @notice saves to storage the decimals for the given asset.
     * This is done to reduce future calls gas cost.
     */
    function _setDecimalsForAsset(address _asset) internal {
        uint8 decimalsForAsset;

        if (_asset == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) {
            decimalsForAsset = 18;
        } else {
            decimalsForAsset = ERC20(_asset).decimals();
        }

        assetsDecimals[_asset] = decimalsForAsset;

        emit NewDecimalsConfiguredForAsset(_asset, decimalsForAsset);
    }

    // ******************
    // Internal virtual Functions
    // ******************

//    /**
//     * @notice Should return true if the given asset is supported by the oracle.
//     * @param asset The asset.
//     */
//    function isAssetSupported(address asset) internal view virtual returns (bool);

    /**
     * @notice This function should be implemented to retrieve the price for the asset in question.
     * @param asset The asset in question.
     * @return The asset price mantissa (scaled by 1e(36 - assetDecimals)).
     *  Zero means the price is unavailable.
     */
    function getPriceFromSourceInternal(address asset) internal view virtual returns (uint);

    /**
     * @notice This function should be implemented to retrieve the price update timestamp for the asset in question.
     * @param asset The asset in question.
     */
    function getPriceUpdateTimestampFromSourceInternal(address asset) internal view virtual returns (uint);
}

File 4 of 8 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 () internal {
        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 5 of 8 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
        _decimals = 18;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Sets {decimals} to a value other than the default one of 18.
     *
     * WARNING: This function should only be called from the constructor. Most
     * applications that interact with token contracts will not expect
     * {decimals} to ever change, and may work incorrectly if it does.
     */
    function _setupDecimals(uint8 decimals_) internal virtual {
        _decimals = decimals_;
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

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

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

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

File 7 of 8 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 8 of 8 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @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) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * 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);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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;
    }
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_diaOracleV2","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"decimals","type":"uint256"}],"name":"NewDecimalsConfiguredForAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"string","name":"diaV2Key","type":"string"}],"name":"NewKeyConfiguredForAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"_underlying","type":"address"},{"internalType":"string","name":"diaV2Key","type":"string"}],"name":"_setAssetKeyForUnderlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_underlyings","type":"address[]"},{"internalType":"string[]","name":"_diaV2Keys","type":"string[]"}],"name":"_setAssetKeysForUnderlyings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetsDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetsOracleKeys","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"diaOracleV2","outputs":[{"internalType":"contract DiaOracleV2ForOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getAssetPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getAssetPriceUpdateTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"cToken","type":"address"}],"name":"getUnderlyingPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"cToken","type":"address"}],"name":"getUnderlyingPriceUpdateTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isAssetSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPriceOracle","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","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"}]

608060405234801561001057600080fd5b5060405161116438038061116483398101604081905261002f916100ac565b60006100396100a8565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600280546001600160a01b0319166001600160a01b03929092169190911790556100da565b3390565b6000602082840312156100bd578081fd5b81516001600160a01b03811681146100d3578182fd5b9392505050565b61107b806100e96000396000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c806393329b521161008c578063d4cdd8d311610066578063d4cdd8d3146101c0578063f2fde38b146101d3578063fc57d4df146101e6578063feb1c000146101f9576100ea565b806393329b5214610187578063b3596f071461019a578063c5ba9c2b146101ad576100ea565b80635f349660116100c85780635f3496601461014d57806366331bba1461016d578063715018a6146101755780638da5cb5b1461017f576100ea565b806309f8110e146100ef578063464b41581461011857806357f6cf3514610138575b600080fd5b6101026100fd366004610d29565b610219565b60405161010f9190610f7c565b60405180910390f35b61012b610126366004610d29565b61022e565b60405161010f9190610e8c565b610140610252565b60405161010f9190610e78565b61016061015b366004610d29565b610261565b60405161010f9190610f73565b61012b6102d6565b61017d6102db565b005b610140610387565b610160610195366004610d29565b610396565b6101606101a8366004610d29565b6103a1565b61017d6101bb366004610dc1565b6103ac565b61017d6101ce366004610d43565b6104cc565b61017d6101e1366004610d29565b610573565b6101606101f4366004610d29565b610675565b61020c610207366004610d29565b6106e4565b60405161010f9190610e97565b60016020526000908152604090205460ff1681565b6001600160a01b03811660009081526001602052604090205460ff1615155b919050565b6002546001600160a01b031681565b60006102d0826001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561029f57600080fd5b505afa1580156102b3573d6000803e3d6000fd5b505050506040513d60208110156102c957600080fd5b505161077f565b92915050565b600190565b6102e36107a7565b6001600160a01b03166102f4610387565b6001600160a01b03161461033d576040805162461bcd60e51b81526020600482018190526024820152600080516020611026833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b60006102d08261077f565b60006102d0826107ab565b6103b46107a7565b6001600160a01b03166103c5610387565b6001600160a01b03161461040e576040805162461bcd60e51b81526020600482018190526024820152600080516020611026833981519152604482015290519081900360640190fd5b8281146104365760405162461bcd60e51b815260040161042d90610eca565b60405180910390fd5b60005b838110156104c5576104bd85858381811061045057fe5b90506020020160208101906104659190610d29565b84848481811061047157fe5b90506020028101906104839190610f8a565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506107c492505050565b600101610439565b5050505050565b6104d46107a7565b6001600160a01b03166104e5610387565b6001600160a01b03161461052e576040805162461bcd60e51b81526020600482018190526024820152600080516020611026833981519152604482015290519081900360640190fd5b61056e8383838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506107c492505050565b505050565b61057b6107a7565b6001600160a01b031661058c610387565b6001600160a01b0316146105d5576040805162461bcd60e51b81526020600482018190526024820152600080516020611026833981519152604482015290519081900360640190fd5b6001600160a01b03811661061a5760405162461bcd60e51b81526004018080602001828103825260268152602001806110006026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006102d0826001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156106b357600080fd5b505afa1580156106c7573d6000803e3d6000fd5b505050506040513d60208110156106dd57600080fd5b50516107ab565b60036020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156107775780601f1061074c57610100808354040283529160200191610777565b820191906000526020600020905b81548152906001019060200180831161075a57829003601f168201915b505050505081565b600061078a8261022e565b1561079f576107988261086a565b905061024d565b50600061024d565b3390565b60006107b68261022e565b1561079f5761079882610929565b6107cd8261022e565b156107ea5760405162461bcd60e51b815260040161042d90610f43565b6107f382610a24565b6001600160a01b0382166000908152600360209081526040909120825161081c92840190610c11565b508060405161082b9190610e5c565b604051908190038120906001600160a01b038416907fb9b535257f263114b880724be30bb966dff1956789ec97fa4c1e20ea0888d8de90600090a35050565b6001600160a01b038116600090815260036020908152604080832080548251601f6002600019610100600186161502019093169290920491820185900485028101850190935280835284938301828280156109065780601f106108db57610100808354040283529160200191610906565b820191906000526020600020905b8154815290600101906020018083116108e957829003601f168201915b50505050509050600061091882610b1c565b6001600160801b0316949350505050565b6001600160a01b0381166000908152600160208181526040808420546003835281852080548351600261010097831615979097026000190190911695909504601f810185900485028601850190935282855260ff9091169385939092908301828280156109d75780601f106109ac576101008083540402835291602001916109d7565b820191906000526020600020905b8154815290600101906020018083116109ba57829003601f168201915b5050505050905060006109e982610b30565b6001600160801b03169050808360ff16600a0a610a126b204fce5e3e2502611000000083610b42565b81610a1957fe5b049695505050505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610a5357506012610abb565b816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610a8c57600080fd5b505afa158015610aa0573d6000803e3d6000fd5b505050506040513d6020811015610ab657600080fd5b505190505b6001600160a01b038216600081815260016020908152604091829020805460ff191660ff8616908117909155825190815291517ffbb5ef0702f02bd91bbad461f4910e192d28851fec6139dd2448297175666f2b9281900390910190a25050565b600080610b2883610b83565b949350505050565b6000610b3b82610b83565b5092915050565b600082610b51575060006102d0565b82820282848281610b5e57fe5b0414610b7c5760405162461bcd60e51b815260040161042d90610f0c565b9392505050565b6002546040516304b01c2560e51b815260009182916001600160a01b039091169063960384a090610bb8908690600401610e97565b604080518083038186803b158015610bcf57600080fd5b505afa158015610be3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c079190610e2a565b9094909350915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282610c475760008555610c8d565b82601f10610c6057805160ff1916838001178555610c8d565b82800160010185558215610c8d579182015b82811115610c8d578251825591602001919060010190610c72565b50610c99929150610c9d565b5090565b5b80821115610c995760008155600101610c9e565b80356001600160a01b038116811461024d57600080fd5b60008083601f840112610cda578182fd5b50813567ffffffffffffffff811115610cf1578182fd5b6020830191508360208083028501011115610d0b57600080fd5b9250929050565b80516001600160801b038116811461024d57600080fd5b600060208284031215610d3a578081fd5b610b7c82610cb2565b600080600060408486031215610d57578182fd5b610d6084610cb2565b9250602084013567ffffffffffffffff80821115610d7c578384fd5b818601915086601f830112610d8f578384fd5b813581811115610d9d578485fd5b876020828501011115610dae578485fd5b6020830194508093505050509250925092565b60008060008060408587031215610dd6578081fd5b843567ffffffffffffffff80821115610ded578283fd5b610df988838901610cc9565b90965094506020870135915080821115610e11578283fd5b50610e1e87828801610cc9565b95989497509550505050565b60008060408385031215610e3c578182fd5b610e4583610d12565b9150610e5360208401610d12565b90509250929050565b60008251610e6e818460208701610fcf565b9190910192915050565b6001600160a01b0391909116815260200190565b901515815260200190565b6000602082528251806020840152610eb6816040850160208701610fcf565b601f01601f19169190910160400192915050565b60208082526022908201527f756e6465726c79696e677320616e64206b6579732073686f756c6420626520316040820152613a3160f01b606082015260800190565b60208082526017908201527f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000604082015260600190565b60208082526016908201527510d85b9b9bdd081c99585cdcda59db881cde5b589bdb60521b604082015260600190565b90815260200190565b60ff91909116815260200190565b6000808335601e19843603018112610fa0578283fd5b83018035915067ffffffffffffffff821115610fba578283fd5b602001915036819003821315610d0b57600080fd5b60005b83811015610fea578181015183820152602001610fd2565b83811115610ff9576000848401525b5050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220187b7b8d786f751b558ca23ec731dd0435629354616a6713cc2a01732aae9c8464736f6c634300070600330000000000000000000000009fe8befbba9ccc9c98b54f61aa99b772b9ded28b

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

0000000000000000000000009fe8befbba9ccc9c98b54f61aa99b772b9ded28b

-----Decoded View---------------
Arg [0] : _diaOracleV2 (address): 0x9fe8befbba9ccc9c98b54f61aa99b772b9ded28b

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000009fe8befbba9ccc9c98b54f61aa99b772b9ded28b


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.