contract OracleProxy is
    Authorizable
{

    /* ============ State Variables ============ */
    IOracle public oracleInstance;

    /* ============ Events ============ */

    event LogOracleUpdated(
        address indexed newOracleAddress
    );

    /* ============ Constructor ============ */
    /*
     * Set address of oracle being proxied
     *
     * @param  _oracleAddress    The address of oracle being proxied
     */
    constructor(
        IOracle _oracleAddress
    )
        public
    {
        oracleInstance = _oracleAddress;
    }

    /* ============ External ============ */

    /*
     * Reads value of external oracle and passed to Set system. Only authorized addresses are allowed
     * to call read().
     *
     * @returns         Oracle's uint256 output
     */
    function read()
        external
        view
        onlyAuthorized
        returns (uint256)
    {
        // Read value of oracle
        return oracleInstance.read();
    }

    /*
     * Sets address of new oracle to be proxied. Only owner has ability to update oracleAddress.
     *
     * @param _newOracleAddress         Address of new oracle being proxied
     */
    function changeOracleAddress(
        IOracle _newOracleAddress
    )
        external
        onlyOwner
        timeLockUpgrade
    {
        // Check to make sure new oracle address is passed
        require(
            address(_newOracleAddress) != address(oracleInstance),
            "OracleProxy.changeOracleAddress: Must give new oracle address."
        );

        // Set new Oracle instance
        oracleInstance = _newOracleAddress;

        emit LogOracleUpdated(address(_newOracleAddress));
    }
}
/**
 * @title OracleProxy
 * @author Set Protocol
 *
 * Permissioned contract that acts as a bridge between external Oracles and the whole Set system.
 * OracleProxies help enforce standardization of data types the Set system uses as well as allows
 * for Set to interact with external permissioned oracles through one contract instead of permiss-
 * ioning all contracts that need the external oracle's data. Because the OracleProxy is interacting
 * with permissioned oracles, the OracleProxy must also be permissioned so that only out contracts
 * use it and the oracle data isn't leaked on chain.
 */
function read()
    external
    view
    onlyAuthorized
    returns (uint256)
{
    // Read value of oracle
    return oracleInstance.read();
}

/*
 * Reads value of external oracle and passed to Set system. Only authorized addresses are allowed
 * to call read().
 *
 * @returns         Oracle's uint256 output
 */