ETH Price: $3,405.86 (-0.96%)
Gas: 15 Gwei

Contract

0x642b994887Be211d76Bb3F87450B5Ebe3eE4caEd
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040134179522021-10-14 18:38:261007 days ago1634236706IN
 Contract Creation
0 ETH0.1023032200

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

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

Contract Name:
StakedaoPricer

Compiler Version
v0.6.10+commit.00c0fcaf

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 6 : StakedaoPricer.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.10;

import {ICurve} from "../interfaces/ICurve.sol";
import {IStakeDao} from "../interfaces/IStakeDao.sol";
import {OracleInterface} from "../interfaces/OracleInterface.sol";
import {SafeMath} from "../packages/oz/SafeMath.sol";

/**
 * Error Codes
 * P1: cannot deploy pricer, lpToken address cannot be 0
 * P2: cannot deploy pricer, underlying address cannot be 0
 * P3: cannot deploy pricer, oracle address cannot be 0
 * P4: cannot deploy pricer, curve address cannot be 0
 * P5: cannot retrieve price, underlying price is 0
 * P6: cannot set expiry price in oracle, underlying price is 0 and has not been set
 * P7: cannot retrieve historical prices, getHistoricalPrice has been deprecated
 */

/**
 * @title StakedaoPricer
 * @author Opyn Team
 * @notice A Pricer contract for a Stakedao lpToken
 */
contract StakedaoPricer {
    using SafeMath for uint256;

    /// @notice curve pool
    ICurve public curve;

    /// @notice lpToken that this pricer will a get price for
    IStakeDao public lpToken;

    /// @notice opyn oracle address
    OracleInterface public oracle;

    /// @notice underlying asset for this lpToken
    address public underlying;

    /**
     * @param _lpToken lpToken asset
     * @param _underlying underlying asset for this lpToken
     * @param _oracle Opyn Oracle contract address
     * @param _curve curve pool contract address
     */
    constructor(
        address _lpToken,
        address _underlying,
        address _oracle,
        address _curve
    ) public {
        require(_lpToken != address(0), "P1");
        require(_underlying != address(0), "P2");
        require(_oracle != address(0), "P3");
        require(_curve != address(0), "P4");

        lpToken = IStakeDao(_lpToken);
        underlying = _underlying;
        oracle = OracleInterface(_oracle);
        curve = ICurve(_curve);
    }

    /**
     * @notice get the live price for the asset
     * @dev overrides the getPrice function in OpynPricerInterface
     * @return price of 1 lpToken in USD, scaled by 1e8
     */
    function getPrice() external view returns (uint256) {
        uint256 underlyingPrice = oracle.getPrice(address(underlying));
        require(underlyingPrice > 0, "P5");
        return _underlyingPriceToYtokenPrice(underlyingPrice);
    }

    /**
     * @notice set the expiry price in the oracle
     * @dev requires that the underlying price has been set before setting a lpToken price
     * @param _expiryTimestamp expiry to set a price for
     */
    function setExpiryPriceInOracle(uint256 _expiryTimestamp) external {
        (uint256 underlyingPriceExpiry, ) = oracle.getExpiryPrice(underlying, _expiryTimestamp);
        require(underlyingPriceExpiry > 0, "P6");
        uint256 lpTokenPrice = _underlyingPriceToYtokenPrice(underlyingPriceExpiry);
        oracle.setExpiryPrice(address(lpToken), _expiryTimestamp, lpTokenPrice);
    }

    /**
     * @dev convert underlying price to lpToken price with the lpToken to underlying exchange rate
     * @param _underlyingPrice price of 1 underlying token (hardcoded 1e18 for WETH) in USD, scaled by 1e8
     * @return price of 1 lpToken in USD, scaled by 1e8
     */
    function _underlyingPriceToYtokenPrice(uint256 _underlyingPrice) private view returns (uint256) {
        uint256 pricePerShare = lpToken.getPricePerFullShare(); // 18 decimals
        uint256 curvePrice = curve.get_virtual_price(); // 18 decimals

        // scale by 1e36 to return price of 1 lpToken in USD, scaled by 1e8
        // assumes underlyingPrice is 1e8, curve price is 1e18, pricePerShare is 1e18
        return pricePerShare.mul(_underlyingPrice).mul(curvePrice).div(1e36);
    }

    function getHistoricalPrice(uint80) external pure returns (uint256, uint256) {
        revert("P7");
    }
}

File 2 of 6 : 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 3 of 6 : 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);

    // 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 6 : IStakeDao.sol
// SPDX-License-Identifier: MIT

import {ERC20Interface} from "./ERC20Interface.sol";

pragma solidity 0.6.10;
pragma experimental ABIEncoderV2;

interface IStakeDao {
    function getPricePerFullShare() external view returns (uint256);
}

File 5 of 6 : ICurve.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.10;

interface ICurve {
    function get_virtual_price() external view returns (uint256);
}

File 6 of 6 : ERC20Interface.sol
/**
 * SPDX-License-Identifier: UNLICENSED
 */
pragma solidity 0.6.10;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface ERC20Interface {
    /**
     * @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);

    function decimals() external view returns (uint8);

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_lpToken","type":"address"},{"internalType":"address","name":"_underlying","type":"address"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"address","name":"_curve","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"curve","outputs":[{"internalType":"contract ICurve","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"","type":"uint80"}],"name":"getHistoricalPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken","outputs":[{"internalType":"contract IStakeDao","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract OracleInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"setExpiryPriceInOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061007d5760003560e01c80637dc0d1d01161005b5780637dc0d1d0146100b657806396367290146100be57806398d5fdca146100dd578063eec377c0146100f75761007d565b80635fcbd285146100825780636f307dc3146100a65780637165485d146100ae575b600080fd5b61008a610139565b604080516001600160a01b039092168252519081900360200190f35b61008a610148565b61008a610157565b61008a610166565b6100db600480360360208110156100d457600080fd5b5035610175565b005b6100e56102bb565b60408051918252519081900360200190f35b6101206004803603602081101561010d57600080fd5b503569ffffffffffffffffffff16610381565b6040805192835260208301919091528051918290030190f35b6001546001600160a01b031681565b6003546001600160a01b031681565b6000546001600160a01b031681565b6002546001600160a01b031681565b600254600354604080516301957f8160e01b81526001600160a01b03928316600482015260248101859052815160009493909316926301957f8192604480840193919291829003018186803b1580156101cd57600080fd5b505afa1580156101e1573d6000803e3d6000fd5b505050506040513d60408110156101f757600080fd5b5051905080610232576040805162461bcd60e51b8152602060048201526002602482015261281b60f11b604482015290519081900360640190fd5b600061023d826103b8565b6002546001546040805163ee53140960e01b81526001600160a01b0392831660048201526024810188905260448101859052905193945091169163ee5314099160648082019260009290919082900301818387803b15801561029e57600080fd5b505af11580156102b2573d6000803e3d6000fd5b50505050505050565b600254600354604080516341976e0960e01b81526001600160a01b0392831660048201529051600093849316916341976e09916024808301926020929190829003018186803b15801561030d57600080fd5b505afa158015610321573d6000803e3d6000fd5b505050506040513d602081101561033757600080fd5b5051905080610372576040805162461bcd60e51b8152602060048201526002602482015261503560f01b604482015290519081900360640190fd5b61037b816103b8565b91505090565b6040805162461bcd60e51b8152602060048201526002602482015261503760f01b6044820152905160009182919081900360640190fd5b600080600160009054906101000a90046001600160a01b03166001600160a01b03166377c7b8fc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561040957600080fd5b505afa15801561041d573d6000803e3d6000fd5b505050506040513d602081101561043357600080fd5b50516000805460408051630176f71760e71b8152905193945091926001600160a01b039091169163bb7b8b80916004808301926020929190829003018186803b15801561047f57600080fd5b505afa158015610493573d6000803e3d6000fd5b505050506040513d60208110156104a957600080fd5b505190506104ec6ec097ce7bc90715b34b9f10000000006104e0836104d4868963ffffffff6104f416565b9063ffffffff6104f416565b9063ffffffff61055616565b949350505050565b60008261050357506000610550565b8282028284828161051057fe5b041461054d5760405162461bcd60e51b81526004018080602001828103825260218152602001806106366021913960400191505060405180910390fd5b90505b92915050565b600061054d83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506000818361061f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156105e45781810151838201526020016105cc565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161062b57fe5b049594505050505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220dff57b0f793616697d2fd317bebbb6d7ed8cdc47fee943fd6f691f1148a8a7d164736f6c634300060a0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.