contract MedianOracleAdapter 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 IOracle and returns bytes32 result. Only authorized addresses are allowed
     * to call read().
     *
     * @returns         Oracle's bytes32 converted output
     */
    function read()
        external
        view
        onlyAuthorized
        returns (bytes32)
    {
        // Read value of oracle and coerces into bytes32
        return bytes32(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 // Must be placed after onlyOwner
    {
        // Check to make sure new oracle address is passed
        require(
            address(_newOracleAddress) != address(oracleInstance),
            "MedianOracleAdapter.changeOracleAddress: Must give new oracle address."
        );

        // Set new Oracle instance
        oracleInstance = _newOracleAddress;

        emit LogOracleUpdated(address(_newOracleAddress));
    }
}
/**
 * @title MedianOracleAdapter
 * @author Set Protocol
 *
 * Permissioned oracle proxy that is intended to replicate the interface of the MakerDAO Legacy IMedian
 * oracle that returns bytes32 values.
 */
function read()
    external
    view
    onlyAuthorized
    returns (bytes32)
{
    // Read value of oracle and coerces into bytes32
    return bytes32(oracleInstance.read());
}

/*
 * Reads value of IOracle and returns bytes32 result. Only authorized addresses are allowed
 * to call read().
 *
 * @returns         Oracle's bytes32 converted output
 */