Contract 0x37d8543673fE8038dce4964fc9A8B99693042d18 6

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xb2d1f113079f18b74f87322e152792fc3ea97b4771763a9dbf7008c24a297dc30x608060401074385692023-07-03 11:23:37239 days 9 hrs ago0xa67d0c1180e0e183f482304a9b5436a3478f0674 IN  Contract Creation0 ETH0.00041383 0.1
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x7a71f218003d2DbF25337d072FA096099B50E0F0
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
L2ChainLinkPricer

Compiler Version
v0.6.10+commit.00c0fcaf

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 5 : AggregatorInterface.sol
/**
 * SPDX-License-Identifier: UNLICENSED
 */
pragma solidity 0.6.10;

/**
 * @dev Interface of the Chainlink aggregator
 */
interface AggregatorInterface {
	function latestAnswer() external view returns (int256);

	function latestTimestamp() external view returns (uint256);

	function latestRound() external view returns (uint256);

	function getAnswer(uint256 roundId) external view returns (int256);

	function getTimestamp(uint256 roundId) external view returns (uint256);

	event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);
	event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);

	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 2 of 5 : OpynPricerInterface.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.10;

interface OpynPricerInterface {
    function getPrice() external view returns (uint256);

    function getHistoricalPrice(uint80 _roundId) external view returns (uint256, uint256);
}

File 3 of 5 : OracleInterface.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.10;

interface OracleInterface {
    function isLockingPeriodOver(address _asset, uint256 _expiryTimestamp) external view returns (bool);

    function isDisputePeriodOver(address _asset, uint256 _expiryTimestamp) external view returns (bool);

    function getExpiryPrice(address _asset, uint256 _expiryTimestamp) external view returns (uint256, bool);

    function getDisputer() external view returns (address);

    function getPricer(address _asset) external view returns (address);

    function getPrice(address _asset) external view returns (uint256);

    function getPricerLockingPeriod(address _pricer) external view returns (uint256);

    function getPricerDisputePeriod(address _pricer) external view returns (uint256);

    function getChainlinkRoundData(address _asset, uint80 _roundId) external view returns (uint256, uint256);

    function setStablePrice(address _asset, uint256 _price) external;
    // Non-view function

    function setAssetPricer(address _asset, address _pricer) external;

    function setLockingPeriod(address _pricer, uint256 _lockingPeriod) external;

    function setDisputePeriod(address _pricer, uint256 _disputePeriod) external;

    function setExpiryPrice(
        address _asset,
        uint256 _expiryTimestamp,
        uint256 _price
    ) external;

    function disputeExpiryPrice(
        address _asset,
        uint256 _expiryTimestamp,
        uint256 _price
    ) external;

    function setDisputer(address _disputer) external;
}

File 4 of 5 : SafeMath.sol
// SPDX-License-Identifier: MIT
// openzeppelin-contracts v3.1.0

/* solhint-disable */
pragma solidity ^0.6.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, 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) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * 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);
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // 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 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts 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) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

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

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 5 of 5 : L2ChainlinkPricer.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.6.10;

import {AggregatorInterface} from "../interfaces/AggregatorInterface.sol";
import {OracleInterface} from "../interfaces/OracleInterface.sol";
import {OpynPricerInterface} from "../interfaces/OpynPricerInterface.sol";
import {SafeMath} from "../packages/oz/SafeMath.sol";

/**
 * @notice A Pricer contract for one asset as reported by Chainlink
 */
contract L2ChainLinkPricer is OpynPricerInterface {
    using SafeMath for uint256;

    /// @dev base decimals
    uint256 internal constant BASE = 8;

    /// @notice chainlink response decimals
    uint256 public aggregatorDecimals;

    /// @notice the opyn oracle address
    OracleInterface public oracle;
    /// @notice the aggregator for an asset
    AggregatorInterface public aggregator;
    /// @notice the sequencer uptime feed for the L2 protocol
    address public sequencerUptimeFeedAddress;
    /// @notice asset that this pricer will a get price for
    address public asset;
    /// @notice bot address that is allowed to call setExpiryPriceInOracle
    address public bot;
    // seconds after arbitrum sequencer comes back online that we start accepting price feed data
    uint32 private constant GRACE_PERIOD_TIME = 1800; // 30 minutes

    /**
     * @param _bot priveleged address that can call setExpiryPriceInOracle
     * @param _asset asset that this pricer will get a price for
     * @param _aggregator Chainlink aggregator contract for the asset
     * @param _oracle Opyn Oracle address
     * @param _sequencerUptimeFeedAddress the uptime feed for the L2 sequencer
     */
    constructor(
        address _bot,
        address _asset,
        address _aggregator,
        address _oracle,
        address _sequencerUptimeFeedAddress
    ) public {
        require(_bot != address(0), "ChainLinkPricer: Cannot set 0 address as bot");
        require(_oracle != address(0), "ChainLinkPricer: Cannot set 0 address as oracle");
        require(_aggregator != address(0), "ChainLinkPricer: Cannot set 0 address as aggregator");
        require(_sequencerUptimeFeedAddress != address(0), "ChainLinkPricer: Cannot set 0 address as uptime feed");

        bot = _bot;
        oracle = OracleInterface(_oracle);
        aggregator = AggregatorInterface(_aggregator);
        sequencerUptimeFeedAddress = _sequencerUptimeFeedAddress;
        asset = _asset;

        aggregatorDecimals = uint256(aggregator.decimals());
    }

    /**
     * @notice modifier to check if sender address is equal to bot address
     */
    modifier onlyBot() {
        require(msg.sender == bot, "ChainLinkPricer: unauthorized sender");

        _;
    }

    /**
     * @notice set the expiry price in the oracle, can only be called by Bot address
     * @dev a roundId must be provided to confirm price validity, which is the first Chainlink price provided after the expiryTimestamp
     * @param _expiryTimestamp expiry to set a price for
     * @param _roundId the first roundId after expiryTimestamp
     */
    function setExpiryPriceInOracle(uint256 _expiryTimestamp, uint80 _roundId) external onlyBot {
        (, int256 price, , uint256 roundTimestamp, ) = aggregator.getRoundData(_roundId);

        require(_expiryTimestamp <= roundTimestamp, "ChainLinkPricer: invalid roundId");

        oracle.setExpiryPrice(asset, _expiryTimestamp, uint256(price));
    }

    /**
     * @notice get the live price for the asset, also check the l2 sequencer status
     * @dev overides the getPrice function in OpynPricerInterface
     * @return price of the asset in USD, scaled by 1e8
     */
    function getPrice() external view override returns (uint256) {
        _checkSequencerUp();
        (, int256 answer, , , ) = aggregator.latestRoundData();
        require(answer > 0, "ChainLinkPricer: price is lower than 0");
        // chainlink's answer is already 1e8
        return _scaleToBase(uint256(answer));
    }

    /**
     * @notice get historical chainlink price
     * @param _roundId chainlink round id
     * @return round price and timestamp
     */
    function getHistoricalPrice(uint80 _roundId) external view override returns (uint256, uint256) {
        (, int256 price, , uint256 roundTimestamp, ) = aggregator.getRoundData(_roundId);
        return (_scaleToBase(uint256(price)), roundTimestamp);
    }

    /**
     * @notice scale aggregator response to base decimals (1e8)
     * @param _price aggregator price
     * @return price scaled to 1e8
     */
    function _scaleToBase(uint256 _price) internal view returns (uint256) {
        if (aggregatorDecimals > BASE) {
            uint256 exp = aggregatorDecimals.sub(BASE);
            _price = _price.div(10**exp);
        } else if (aggregatorDecimals < BASE) {
            uint256 exp = BASE.sub(aggregatorDecimals);
            _price = _price.mul(10**exp);
        }

        return _price;
    }

    /// @dev check arbitrum sequencer status and time since it last came back online
    function _checkSequencerUp() internal view {
        AggregatorInterface sequencerUptimeFeed = AggregatorInterface(sequencerUptimeFeedAddress);
        (, int256 answer, uint256 startedAt, , ) = sequencerUptimeFeed.latestRoundData();
        require(answer == 0, "ChainlinkPricer: sequencer down");
        uint256 timeSinceUp = block.timestamp.sub(startedAt);
        require(timeSinceUp > GRACE_PERIOD_TIME, "ChainlinkPricer: grace period not over");
    }
}

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":"_bot","type":"address"},{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"address","name":"_sequencerUptimeFeedAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"contract AggregatorInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aggregatorDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bot","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getHistoricalPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract OracleInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sequencerUptimeFeedAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"setExpiryPriceInOracle","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100935760003560e01c80633a8c0fc3116100665780633a8c0fc3146100e65780637dc0d1d0146100ee57806398d5fdca146100f6578063b2b63d9f146100fe578063eec377c01461012f57610093565b806310814c3714610098578063245a7bfc146100bc57806331b46c8b146100c457806338d52e0f146100de575b600080fd5b6100a0610171565b604080516001600160a01b039092168252519081900360200190f35b6100a0610180565b6100cc61018f565b60408051918252519081900360200190f35b6100a0610195565b6100a06101a4565b6100a06101b3565b6100cc6101c2565b61012d6004803603604081101561011457600080fd5b508035906020013569ffffffffffffffffffff16610290565b005b6101586004803603602081101561014557600080fd5b503569ffffffffffffffffffff16610443565b6040805192835260208301919091528051918290030190f35b6005546001600160a01b031681565b6002546001600160a01b031681565b60005481565b6004546001600160a01b031681565b6003546001600160a01b031681565b6001546001600160a01b031681565b60006101cc6104ee565b60025460408051633fabe5a360e21b815290516000926001600160a01b03169163feaf968c9160048083019260a0929190829003018186803b15801561021157600080fd5b505afa158015610225573d6000803e3d6000fd5b505050506040513d60a081101561023b57600080fd5b50602001519050600081136102815760405162461bcd60e51b81526004018080602001828103825260268152602001806108cd6026913960400191505060405180910390fd5b61028a81610621565b91505090565b6005546001600160a01b031633146102d95760405162461bcd60e51b81526004018080602001828103825260248152602001806108a96024913960400191505060405180910390fd5b60025460408051639a6fc8f560e01b815269ffffffffffffffffffff84166004820152905160009283926001600160a01b0390911691639a6fc8f59160248082019260a092909190829003018186803b15801561033557600080fd5b505afa158015610349573d6000803e3d6000fd5b505050506040513d60a081101561035f57600080fd5b5060208101516060909101519092509050808411156103c5576040805162461bcd60e51b815260206004820181905260248201527f436861696e4c696e6b5072696365723a20696e76616c696420726f756e644964604482015290519081900360640190fd5b600154600480546040805163ee53140960e01b81526001600160a01b039283169381019390935260248301889052604483018690525192169163ee5314099160648082019260009290919082900301818387803b15801561042557600080fd5b505af1158015610439573d6000803e3d6000fd5b5050505050505050565b60025460408051639a6fc8f560e01b815269ffffffffffffffffffff8416600482015290516000928392839283926001600160a01b031691639a6fc8f59160248083019260a0929190829003018186803b1580156104a057600080fd5b505afa1580156104b4573d6000803e3d6000fd5b505050506040513d60a08110156104ca57600080fd5b50602081015160609091015190925090506104e482610621565b9350915050915091565b60035460408051633fabe5a360e21b815290516001600160a01b03909216916000918291849163feaf968c9160048083019260a0929190829003018186803b15801561053957600080fd5b505afa15801561054d573d6000803e3d6000fd5b505050506040513d60a081101561056357600080fd5b506020810151604090910151909250905081156105c7576040805162461bcd60e51b815260206004820152601f60248201527f436861696e6c696e6b5072696365723a2073657175656e63657220646f776e00604482015290519081900360640190fd5b60006105d9428363ffffffff6106a016565b9050610708811161061b5760405162461bcd60e51b81526004018080602001828103825260268152602001806108836026913960400191505060405180910390fd5b50505050565b600060086000541115610661576000805461064390600863ffffffff6106a016565b905061065983600a83900a63ffffffff6106eb16565b92505061069c565b6008600054101561069c57600080546106829060089063ffffffff6106a016565b905061069883600a83900a63ffffffff61072d16565b9250505b5090565b60006106e283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610786565b90505b92915050565b60006106e283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061081d565b60008261073c575060006106e5565b8282028284828161074957fe5b04146106e25760405162461bcd60e51b81526004018080602001828103825260218152602001806108f36021913960400191505060405180910390fd5b600081848411156108155760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156107da5781810151838201526020016107c2565b50505050905090810190601f1680156108075780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000818361086c5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156107da5781810151838201526020016107c2565b50600083858161087857fe5b049594505050505056fe436861696e6c696e6b5072696365723a20677261636520706572696f64206e6f74206f766572436861696e4c696e6b5072696365723a20756e617574686f72697a65642073656e646572436861696e4c696e6b5072696365723a207072696365206973206c6f776572207468616e2030536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220fa31bdba26cd9d957c54c9dee5e8a988fe44de6486db244c68e880aec54a322b64736f6c634300060a0033

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.