Moonbase Alpha Testnet

Contract

0x05da49FB21D4C5f419fb4E037E78cdb5C33be298

Overview

DEV Balance

Moonbase Alpha LogoMoonbase Alpha LogoMoonbase Alpha Logo0 DEV

Multichain Info

N/A
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
35609192023-01-16 14:40:42697 days ago1673880042
0x05da49FB...5C33be298
0 DEV
35609192023-01-16 14:40:42697 days ago1673880042
0x05da49FB...5C33be298
0 DEV
35609192023-01-16 14:40:42697 days ago1673880042
0x05da49FB...5C33be298
0 DEV
35609192023-01-16 14:40:42697 days ago1673880042
0x05da49FB...5C33be298
0 DEV
35609192023-01-16 14:40:42697 days ago1673880042
0x05da49FB...5C33be298
0 DEV
35609192023-01-16 14:40:42697 days ago1673880042
0x05da49FB...5C33be298
0 DEV
35609132023-01-16 14:39:18697 days ago1673879958
0x05da49FB...5C33be298
0 DEV
35609132023-01-16 14:39:18697 days ago1673879958
0x05da49FB...5C33be298
0 DEV
35609132023-01-16 14:39:18697 days ago1673879958
0x05da49FB...5C33be298
0 DEV
35609132023-01-16 14:39:18697 days ago1673879958
0x05da49FB...5C33be298
0 DEV
35609132023-01-16 14:39:18697 days ago1673879958
0x05da49FB...5C33be298
0 DEV
35609132023-01-16 14:39:18697 days ago1673879958
0x05da49FB...5C33be298
0 DEV
35608332023-01-16 14:22:06697 days ago1673878926
0x05da49FB...5C33be298
0 DEV
35608332023-01-16 14:22:06697 days ago1673878926
0x05da49FB...5C33be298
0 DEV
35608332023-01-16 14:22:06697 days ago1673878926
0x05da49FB...5C33be298
0 DEV
35608332023-01-16 14:22:06697 days ago1673878926
0x05da49FB...5C33be298
0 DEV
35608332023-01-16 14:22:06697 days ago1673878926
0x05da49FB...5C33be298
0 DEV
35608332023-01-16 14:22:06697 days ago1673878926
0x05da49FB...5C33be298
0 DEV
35608292023-01-16 14:21:18697 days ago1673878878
0x05da49FB...5C33be298
0 DEV
35608292023-01-16 14:21:18697 days ago1673878878
0x05da49FB...5C33be298
0 DEV
35608292023-01-16 14:21:18697 days ago1673878878
0x05da49FB...5C33be298
0 DEV
35608292023-01-16 14:21:18697 days ago1673878878
0x05da49FB...5C33be298
0 DEV
35608292023-01-16 14:21:18697 days ago1673878878
0x05da49FB...5C33be298
0 DEV
35608292023-01-16 14:21:18697 days ago1673878878
0x05da49FB...5C33be298
0 DEV
35607982023-01-16 14:14:24697 days ago1673878464
0x05da49FB...5C33be298
0 DEV
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StakingEmissionsQontroller

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 13 : StakingEmissionsQontroller.sol
// SPDX-License-Identifier: NONE
pragma solidity ^0.8.9;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IQAdmin.sol";
import "./interfaces/IQodaERC20.sol";
import "./interfaces/IStakingEmissionsQontroller.sol";

contract StakingEmissionsQontroller is Initializable, IStakingEmissionsQontroller {

  using SafeERC20 for IERC20;
  using SafeERC20 for IQodaERC20;
  
  struct StakingPeriod {

    /// @notice total emissions for the period
    uint emissions;

    /// @notice total length of the period in blocks
    uint numBlocks;
  }

  struct UserInfo {

    /// @notice Amount of veToken 
    uint amount;

    /// @notice Emissions debt
    uint debt;
    
    /// @notice Unclaimed reward from user
    uint pendingReward;
  }

  /// @notice Contract storing all global Qoda parameters
  IQAdmin private _qAdmin;
    
  /// @notice Address of underlying QODA token
  IQodaERC20 private _qodaERC20;
    
  /// @notice Address of veToken
  IERC20 private _veToken;

  /// @notice Precision factor for calculating emissions
  uint private constant _PRECISION_FACTOR = 10**20;
  
  /// @notice Number of emissions periods
  uint private _numPeriods;
  
  /// @notice Accumulated tokens per share
  uint private _accTokenPerShare;  
    
  /// @notice Current period for emissions
  uint private _currentPeriod;

  /// @notice Block number when current emissions regime end
  uint private _endBlock;

  /// @notice Block number of the last update
  uint private _lastEmissionsBlock;

  /// @notice QODA Tokens distributed
  uint private _emissions;

  /// @notice total length of current period in blocks
  uint private _numBlocks;

  /// @notice Map defining the staking period and associated emissions
  mapping(uint => StakingPeriod) private _stakingPeriod;

  /// @notice Mapping of user emissions debt
  /// account => UserInfo
  mapping(address => UserInfo) private _userInfo;

  /// @notice Constructor for upgradeable contracts
  /// @param qAdminAddress Address of qAdmin
  /// @param qodaERC20Address Address of QODA ERC20 token
  /// @param veTokenAddress Address of veToken
  /// @param emissions_ Array of emission rewards by staking period
  /// @param numBlocks_ Array of number of blocks of each staking period
  /// @param numPeriods_ Total number of staking periods
  function initialize(
                      address qAdminAddress,
                      address qodaERC20Address,
                      address veTokenAddress,
                      uint[] memory emissions_,
                      uint[] memory numBlocks_,
                      uint numPeriods_
                      ) public initializer {
    require(
            emissions_.length == numPeriods_ &&
            numBlocks_.length == numPeriods_,
            "SEQ5 length mismatch"
            );

    _qAdmin = IQAdmin(qAdminAddress);
    _qodaERC20 = IQodaERC20(qodaERC20Address);
    _veToken = IERC20(veTokenAddress);
    _numPeriods = numPeriods_;
    _currentPeriod = 0;

    // Initialize staking periods and rewards config
    for (uint i = 0; i < numPeriods_; i++) {
      _stakingPeriod[i] = StakingPeriod({
        emissions: emissions_[i],
        numBlocks: numBlocks_[i]
        });
    }
    
    // Initialize staking periods and rewards
    _emissions = _stakingPeriod[0].emissions;
    _numBlocks = _stakingPeriod[0].numBlocks;
  }

  /// @notice Modifier which checks that the caller has the `VETOKEN` role
  modifier onlyVeToken() {
    require(_qAdmin.hasRole(_qAdmin.VETOKEN_ROLE(), msg.sender), "SEQ1 only veToken");
    _;
  }

  /// @notice Modifier which checks that the caller has the `ADMIN` role
  modifier onlyAdmin() {
    require(_qAdmin.hasRole(_qAdmin.ADMIN_ROLE(), msg.sender), "SEQ2 only admin");
    _;
  }
  
  /** ACCESS CONTROLLED FUNCTIONS **/
  
  /// @notice Credits the account with the given amount in `StakingEmissionsQontroller`
  /// This function should only be called by the veToken contract when the user
  /// claims their accrued veTokens.
  /// @param account Address of the user
  /// @param amount Amount to credit the account
  function deposit(address account, uint amount) external onlyVeToken {
    _deposit(account, amount, block.number);
  }

  /// @notice Cancels account's full amount and debt from `StakingEmissionsQontroller`
  /// and claims any remaining emissions for that account. This should only
  /// be called by the veToken contract when the user unstakes the underlying
  /// @param account Address of the user.
  function withdraw(address account) external onlyVeToken {
    _withdraw(account, block.number);
  }
  
  /// @notice Function to start reward distribution, can only be invoked once.
  /// @param startBlock starting block for reward distribution, 0 for current block
  function _startStaking(uint startBlock) external onlyAdmin {
    require(_endBlock <= 0 && _lastEmissionsBlock <= 0, "SEQ3 startStaking can only be called once");
    uint blockNum = startBlock > 0? startBlock: block.number;
    _endBlock = blockNum + _stakingPeriod[0].numBlocks;
    _lastEmissionsBlock = blockNum;
  }
  
  /** USER INTERFACE **/
  
  /// @notice Transfer accrued emissions from `StakingEmissionsQontroller` to veToken holder
  /// This function can be called by the user anytime and as often as they wish.
  function claimEmissions() external {
    _claimEmissions(msg.sender, block.number);
  }

  /// @notice Update emissions variables of the pool
  function updatePool() external {
    _updatePool(block.number);
  }


  /** VIEW FUNCTIONS **/

  /// @notice Calculates the amount of emissions claimable by a user by updating
  /// the pool info in memory without writing to storage so that viewing the
  /// claimable amount does not incur gas costs.
  /// @param account Address of the user
  /// @return uint Amount claimable
  function claimableEmissions(address account) external view returns(uint) {
    return _claimableEmissions(account, block.number);
  }
  
  /// @notice Get the address of the `QAdmin` contract
  /// @return address Address of `QAdmin` contract
  function qAdmin() external view returns(address){
    return address(_qAdmin);
  }

  /// @notice Get the address of the `QodaERC20` contract
  /// @return address Address of `QodaERC20` contract
  function qodaERC20() external view returns(address) {
    return address(_qodaERC20);
  }

  /// @notice Get the address of the `veQoda` contract
  /// @return address Address of `veQoda` contract
  function veToken() external view returns(address) {
    return address(_veToken);
  }

  function numPeriods() external view returns(uint) {
    return _numPeriods;
  }
  
  function accTokenPerShare() external view returns(uint) {
    return _accTokenPerShare;
  }

  function currentPeriod() external view returns(uint) {
    return _currentPeriod;
  }

  function endBlock() external view returns(uint) {
    return _endBlock;
  }

  function lastEmissionsBlock() external view returns(uint) {
    return _lastEmissionsBlock;
  }

  function emissions() external view returns(uint) {
    return _emissions;
  }

  function numBlocks() external view returns(uint) {
    return _numBlocks;
  }

  // @return emissions per block, scaled by 1e18
  function emissionsPerBlock() external view returns(uint) {
    return _qodaERC20.decimals() * _emissions / _numBlocks;
  }

  function userInfo(address account) external view returns(uint, uint, uint) {
    return (_userInfo[account].amount, _userInfo[account].debt, _userInfo[account].pendingReward);
  }
  
  function stakingPeriod(uint i) external view returns(uint, uint){
    return (_stakingPeriod[i].emissions, _stakingPeriod[i].numBlocks);
  }
  
  /** INTERNAL FUNCTIONS **/
  
  /// @notice Transfer accrued emissions from `StakingEmissionsQontroller` to veToken holder
  /// @param account Address of the user
  /// @param blockNum current block number
  function _claimEmissions(address account, uint blockNum) internal {
    // update pool information
    _updatePool(blockNum);

    // Calculate the amount of emissions to transfer to user
    uint emission = _claimableEmissions(account, blockNum);

    // Update emissions debt
    _userInfo[account].debt += emission;
    
    // Fetch previously unclaimed reward 
    uint pendingReward = _userInfo[account].pendingReward;
    
    if (emission + pendingReward > 0) {
      // Reset unclaimed reward
      _userInfo[account].pendingReward = 0;
  
      // Transfer emissions to sender
      _qodaERC20.safeTransfer(account, emission + pendingReward);
  
      // Emit the event
      emit ClaimEmissions(account, emission);
    }
  }
  
  /// @notice Credits the account with the given amount in `StakingEmissionsQontroller`
  /// This function should only be called by the veToken contract when the user
  /// claims their accrued veTokens.
  /// @param account Address of the user
  /// @param amount Amount to credit the account
  /// @param blockNum current block number
  function _deposit(address account, uint amount, uint blockNum) internal {
    require(amount > 0, "SEQ4 Amount must be > 0");
    
    // Update pool information
    _updatePool(blockNum);
    
    // Calculate amount of emissions to be claimed by user later on
    _userInfo[account].pendingReward += _claimableEmissions(account, blockNum);

    // Amount just deposited should not have any claimable emission previously, so debt is updated to reflect that
    _userInfo[account].amount += amount;
    _userInfo[account].debt = _userInfo[account].amount * _accTokenPerShare / _PRECISION_FACTOR;

    // Emit the event
    emit Deposit(account, amount);
  }

  /// @notice Cancels account's full amount and debt from `StakingEmissionsQontroller`
  /// and claims any remaining emissions for that account. This should only
  /// be called by the veToken contract when the user unstakes the underlying
  /// @param account Address of the user
  /// @param blockNum current block number
  function _withdraw(address account, uint blockNum) internal {
    require(_userInfo[account].amount > 0, "SEQ6 Account must have deposit > 0");
    
    // Update pool information
    _updatePool(blockNum);
    
    // Calculate amount of emissions to be claimed by user later on
    _userInfo[account].pendingReward += _claimableEmissions(account, blockNum);
    
    // Emit the event
    emit Withdraw(account, _userInfo[account].amount);
    
    // Adjust user info
    _userInfo[account].amount = 0;
    _userInfo[account].debt = 0;
  }
  
  /// @notice Calculates the amount of emissions claimable by a user by updating
  /// the pool info in memory without writing to storage so that viewing the
  /// claimable amount does not incur gas costs.
  /// @param account Address of the user
  /// @param blockNum current block number
  /// @return uint Amount claimable
  function _claimableEmissions(address account, uint blockNum) internal view returns(uint){
    // if emission has not been started or no veToken has been accrued by anyone yet, there will not be any claimable emission
    if (_lastEmissionsBlock <= 0 || _endBlock <= 0 || _veToken.totalSupply() <= 0) {
      return 0;
    }
    uint tokenPerShare = _accTokenPerShare;
    if (blockNum > _lastEmissionsBlock) {

      // Calculate block multiplier
      uint blockMultiplier = _getBlockMultiplier(_lastEmissionsBlock, blockNum);

      // Calculate emissions for staking
      uint tokenEmissions = _emissions * blockMultiplier / _numBlocks;

      uint adjEndBlock = _endBlock;
      uint adjCurrentPeriod = _currentPeriod;

      while(blockNum > adjEndBlock && adjCurrentPeriod < _numPeriods - 1) {

        // update current period
        adjCurrentPeriod++;

        // Calculate adjusted emissions
        uint adjEmissions = _stakingPeriod[adjCurrentPeriod].emissions;

        // Calculate adjusted length of period in blocks
        uint adjNumBlocks = _stakingPeriod[adjCurrentPeriod].numBlocks;

        // Calculate adjusted block number
        uint previousEndBlock = adjEndBlock;

        // Update end block
        adjEndBlock = previousEndBlock + _stakingPeriod[adjCurrentPeriod].numBlocks;

        // Calculate adjusted block multiplier
        uint adjBlockMultiplier = (blockNum <= adjEndBlock)
          ? (blockNum - previousEndBlock)
          : _stakingPeriod[adjCurrentPeriod].numBlocks;

        // Calculate adjusted token emissions
        tokenEmissions += adjEmissions * adjBlockMultiplier / adjNumBlocks;
      }

      // Calculate adjusted tokens per share
      tokenPerShare += (tokenEmissions * _PRECISION_FACTOR) / _veToken.totalSupply();
    }
    return _userInfo[account].amount * tokenPerShare / _PRECISION_FACTOR - _userInfo[account].debt;
  }

  
  /// @notice Update emissions variables of the pool
  /// @param blockNum current block number
  function _updatePool(uint blockNum) internal {

    // blockNum should always be ahead of `_lastEmissionsBlock`. If they are
    // equal, that means someone must have called _updatePool() earlier this
    // block, so we do not need to update again
    if(blockNum <= _lastEmissionsBlock) {
      return;
    }
    
    // Nothing to do if reward distribution has not been started yet
    if (_lastEmissionsBlock <= 0 || _endBlock <= 0) {
      return;
    }

    // Nothing to do if there is no veToken supply
    if (_veToken.totalSupply() <= 0){
      _lastEmissionsBlock = blockNum;
      return;
    }
    
    // Calculate block multiplier
    uint blockMultiplier = _getBlockMultiplier(_lastEmissionsBlock, blockNum);

    // Calculate emissions for staking
    uint tokenEmissions = _emissions * blockMultiplier / _numBlocks;

    // Check whether to adjust multipliers, `_emissions` and `_numBlocks`
    // Here, syncing `_lastEmissionsBlock` to current blockNum would cross the
    // end of the current period into the new period. So we need to fast-forward
    // from the start block of the new block to blockNum
    while(blockNum > _endBlock && _currentPeriod < _numPeriods - 1) {

      // Update `_emissions` and `_numBlocks`
      _updateEmissions(_endBlock);

      uint previousEndBlock = _endBlock;

      // Set `_endBlock to be the end of the new period
      _endBlock += _stakingPeriod[_currentPeriod].numBlocks;

      // Get the number of blocks between `previousEndBlock` (i.e. the current
      // start block) and current blockNum
      uint newBlockMultiplier = _getBlockMultiplier(previousEndBlock, blockNum);

      // Adjust token emissions
      tokenEmissions += (_emissions * newBlockMultiplier / _numBlocks);
    }

    // Mint tokens only if token emissions for staking are not null
    if(tokenEmissions > 0) {
      _accTokenPerShare += tokenEmissions * _PRECISION_FACTOR / _veToken.totalSupply();
    }

    // Update `_lastEmissionsBlock` only if it wasn't updated after or at the end block
    if(_lastEmissionsBlock <= _endBlock) {
      _lastEmissionsBlock = blockNum;
    }
  }
  
  /// @notice Update emissions
  /// @param newStartBlock Pass the new start block (should be the last period's end block)
  function _updateEmissions(uint newStartBlock) internal {

    // Update current period
    _currentPeriod++;

    // Update emissions
    _emissions = _stakingPeriod[_currentPeriod].emissions;

    // Update length of period
    _numBlocks = _stakingPeriod[_currentPeriod].numBlocks;

    // Emit the event
    emit NewEmissionsPerBlock(_currentPeriod, newStartBlock, _emissions, _numBlocks);
  }
  
  /// @notice Return emissions multiplier over the given "from" to "to" block
  /// @param from Block to start calculating emissions
  /// @param to Block to finish calculating emissions
  /// @return uint Multiplier for the period
  function _getBlockMultiplier(uint from, uint to) internal view returns(uint) {
    if (to <= _endBlock) {
      return to - from;
    }
    if (from >= _endBlock) {
      return 0;
    }
    return _endBlock - from;
  }
  
}

File 2 of 13 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

File 3 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 4 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 5 of 13 : IQAdmin.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../libraries/QTypes.sol";

interface IQAdmin is IAccessControlUpgradeable {

  /// @notice Emitted when a new FixedRateMarket is deployed
  event CreateFixedRateMarket(address indexed marketAddress, address indexed tokenAddress, uint maturity);
  
  /// @notice Emitted when a new `Asset` is added
  event AddAsset(
                 address indexed tokenAddress,
                 bool isYieldBearing,
                 address oracleFeed,
                 uint collateralFactor,
                 uint marketFactor);

  /// @notice Emitted when setting `_qollateralManager`
  event SetQollateralManager(address qollateralManagerAddress);

  /// @notice Emitted when setting `_stakingEmissionsQontroller`
  event SetStakingEmissionsQontroller(address stakingEmissionsQontrollerAddress);

  /// @notice Emitted when setting `_tradingEmissionsQontroller`
  event SetTradingEmissionsQontroller(address tradingEmissionsQontrollerAddress);

  /// @notice Emitted when setting `_feeEmissionsQontroller`
  event SetFeeEmissionsQontroller(address feeEmissionsQontrollerAddress);

  /// @notice Emitted when setting `_veQoda`
  event SetVeQoda(address veQodaAddress);
  
  /// @notice Emitted when setting `collateralFactor`
  event SetCollateralFactor(address indexed tokenAddress, uint oldValue, uint newValue);

  /// @notice Emitted when setting `marketFactor`
  event SetMarketFactor(address indexed tokenAddress, uint oldValue, uint newValue);

  /// @notice Emitted when setting `minQuoteSize`
  event SetMinQuoteSize(address indexed tokenAddress, uint oldValue, uint newValue);
  
  /// @notice Emitted when `_minCollateralRatioDefault` and `_initCollateralRatioDefault` get updated
  event SetCollateralRatio(uint oldMinValue, uint oldInitValue, uint newMinValue, uint newInitValue);
  
  /// @notice Emitted when `CreditFacility` gets updated
  event SetCreditFacility(address account, bool oldEnabled, uint oldMinValue, uint oldInitValue, uint oldCreditValue, bool newEnabled, uint newMinValue, uint newInitValue, uint newCreditValue);
  
  /// @notice Emitted when `_closeFactor` gets updated
  event SetCloseFactor(uint oldValue, uint newValue);

  /// @notice Emitted when `_repaymentGracePeriod` gets updated
  event SetRepaymentGracePeriod(uint oldValue, uint newValue);
  
  /// @notice Emitted when `_maturityGracePeriod` gets updated
  event SetMaturityGracePeriod(uint oldValue, uint newValue);
  
  /// @notice Emitted when `_liquidationIncentive` gets updated
  event SetLiquidationIncentive(uint oldValue, uint newValue);

  /// @notice Emitted when `_protocolFee` gets updated
  event SetProtocolFee(uint oldValue, uint newValue);
  
  /** ADMIN FUNCTIONS **/

  /// @notice Call upon initialization after deploying `QollateralManager` contract
  /// @param qollateralManagerAddress Address of `QollateralManager` deployment
  function _setQollateralManager(address qollateralManagerAddress) external;

  /// @notice Call upon initialization after deploying `StakingEmissionsQontroller` contract
  /// @param stakingEmissionsQontrollerAddress Address of `StakingEmissionsQontroller` deployment
  function _setStakingEmissionsQontroller(address stakingEmissionsQontrollerAddress) external;

  /// @notice Call upon initialization after deploying `TradingEmissionsQontroller` contract
  /// @param tradingEmissionsQontrollerAddress Address of `TradingEmissionsQontroller` deployment
  function _setTradingEmissionsQontroller(address tradingEmissionsQontrollerAddress) external;

  /// @notice Call upon initialization after deploying `FeeEmissionsQontroller` contract
  /// @param feeEmissionsQontrollerAddress Address of `FeeEmissionsQontroller` deployment
  function _setFeeEmissionsQontroller(address feeEmissionsQontrollerAddress) external;

  /// @notice Call upon initialization after deploying `veQoda` contract
  /// @param veQodaAddress Address of `veQoda` deployment
  function _setVeQoda(address veQodaAddress) external;
  
  /// @notice Set credit facility for specified account
  /// @param account_ account for credit facility adjustment
  /// @param enabled_ If credit facility should be enabled
  /// @param minCollateralRatio_ New minimum collateral ratio value
  /// @param initCollateralRatio_ New initial collateral ratio value
  /// @param creditLimit_ new credit limit in USD, scaled by 1e18
  function _setCreditFacility(address account_, bool enabled_, uint minCollateralRatio_, uint initCollateralRatio_, uint creditLimit_) external;
  
  /// @notice Admin function for adding new Assets. An Asset must be added before it
  /// can be used as collateral or borrowed. Note: We can create functionality for
  /// allowing borrows of a token but not using it as collateral by setting
  /// `collateralFactor` to zero.
  /// @param token ERC20 token corresponding to the Asset
  /// @param isYieldBearing True if token bears interest (eg aToken, cToken, mToken, etc)
  /// @param underlying Address of the underlying token
  /// @param oracleFeed Chainlink price feed address
  /// @param collateralFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets
  /// @param marketFactor 0.0 to 1.0 (scaled to 1e8) for premium on risky borrows
  function _addAsset(
                     IERC20 token,
                     bool isYieldBearing,
                     address underlying,
                     address oracleFeed,
                     uint collateralFactor,
                     uint marketFactor
                     ) external;

  /// @notice Adds a new `FixedRateMarket` contract into the internal mapping of
  /// whitelisted market addresses
  /// @param marketAddress New `FixedRateMarket` contract address
  /// @param protocolFee_ Corresponding protocol fee in basis points
  /// @param minQuoteSize_ Size in PV terms, local currency
  function _addFixedRateMarket(
                               address marketAddress,
                               uint protocolFee_,
                               uint minQuoteSize_
                               ) external;
  
  /// @notice Update the `collateralFactor` for a given `Asset`
  /// @param token ERC20 token corresponding to the Asset
  /// @param collateralFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets
  function _setCollateralFactor(IERC20 token, uint collateralFactor) external;

  /// @notice Update the `marketFactor` for a given `Asset`
  /// @param token Address of the token corresponding to the Asset
  /// @param marketFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets
  function _setMarketFactor(IERC20 token, uint marketFactor) external;

  /// @notice Set the minimum quote size for a particular `FixedRateMarket`
  /// @param marketAddress Address of the `FixedRateMarket` contract
  /// @param minQuoteSize_ Size in PV terms, local currency
  function _setMinQuoteSize(address marketAddress, uint minQuoteSize_) external;
  
  /// @notice Set the global minimum and initial collateral ratio
  /// @param minCollateralRatio_ New global minimum collateral ratio value
  /// @param initCollateralRatio_ New global initial collateral ratio value
  function _setCollateralRatio(uint minCollateralRatio_, uint initCollateralRatio_) external;
  
  /// @notice Set the global close factor
  /// @param closeFactor_ New close factor value
  function _setCloseFactor(uint closeFactor_) external;

  /// @notice Set the global repayment grace period
  /// @param repaymentGracePeriod_ New repayment grace period
  function _setRepaymentGracePeriod(uint repaymentGracePeriod_) external;

  /// @notice Set the global maturity grace period
  /// @param maturityGracePeriod_ New maturity grace period
  function _setMaturityGracePeriod(uint maturityGracePeriod_) external;
  
  /// @notice Set the global liquidation incetive
  /// @param liquidationIncentive_ New liquidation incentive value
  function _setLiquidationIncentive(uint liquidationIncentive_) external;

  /// @notice Set the global annualized protocol fees for each market in basis points
  /// @param marketAddress Address of the `FixedRateMarket` contract
  /// @param protocolFee_ New protocol fee value (scaled to 1e4)
  function _setProtocolFee(address marketAddress, uint protocolFee_) external;
  
  /// @notice Set the global threshold in USD for protocol fee transfer
  /// @param thresholdUSD_ New threshold USD value (scaled by 1e6)
  function _setThresholdUSD(uint thresholdUSD_) external;
  
  /** VIEW FUNCTIONS **/

  function ADMIN_ROLE() external view returns(bytes32);

  function MARKET_ROLE() external view returns(bytes32);

  function MINTER_ROLE() external view returns(bytes32);

  function VETOKEN_ROLE() external view returns(bytes32);
  
  /// @notice Get the address of the `QollateralManager` contract
  function qollateralManager() external view returns(address);

  /// @notice Get the address of the `QPriceOracle` contract
  function qPriceOracle() external view returns(address);

  /// @notice Get the address of the `StakingEmissionsQontroller` contract
  function stakingEmissionsQontroller() external view returns(address);

  /// @notice Get the address of the `TradingEmissionsQontroller` contract
  function tradingEmissionsQontroller() external view returns(address);

  /// @notice Get the address of the `FeeEmissionsQontroller` contract
  function feeEmissionsQontroller() external view returns(address);

  /// @notice Get the address of the `veQoda` contract
  function veQoda() external view returns(address);

  /// @notice Get the credit limit with associated address, scaled by 1e18
  function creditLimit(address account_) external view returns(uint);
  
  /// @notice Gets the `Asset` mapped to the address of a ERC20 token
  /// @param token ERC20 token
  /// @return QTypes.Asset Associated `Asset`
  function assets(IERC20 token) external view returns(QTypes.Asset memory);

  /// @notice Get all enabled `Asset`s
  /// @return address[] iterable list of enabled `Asset`s
  function allAssets() external view returns(address[] memory);

  /// @notice Gets the `oracleFeed` associated with a ERC20 token
  /// @param token ERC20 token
  /// @return address Address of the oracle feed
  function oracleFeed(IERC20 token) external view returns(address);
  
  /// @notice Gets the `CollateralFactor` associated with a ERC20 token
  /// @param token ERC20 token
  /// @return uint Collateral Factor, scaled by 1e8
  function collateralFactor(IERC20 token) external view returns(uint);

  /// @notice Gets the `MarketFactor` associated with a ERC20 token
  /// @param token ERC20 token
  /// @return uint Market Factor, scaled by 1e8
  function marketFactor(IERC20 token) external view returns(uint);

  /// @notice Gets the `maturities` associated with a ERC20 token
  /// @param token ERC20 token
  /// @return uint[] array of UNIX timestamps (in seconds) of the maturity dates
  function maturities(IERC20 token) external view returns(uint[] memory);
  
  /// @notice Get the MToken market corresponding to any underlying ERC20
  /// tokenAddress => mTokenAddress
  function underlyingToMToken(IERC20 token) external view returns(address);
  
  /// @notice Gets the address of the `FixedRateMarket` contract
  /// @param token ERC20 token
  /// @param maturity UNIX timestamp of the maturity date
  /// @return address Address of `FixedRateMarket` contract
  function fixedRateMarkets(IERC20 token, uint maturity) external view returns(address);

  /// @notice Check whether an address is a valid FixedRateMarket address.
  /// Can be used for checks for inter-contract admin/restricted function call.
  /// @param marketAddress Address of the `FixedRateMarket` contract
  /// @return bool True if valid false otherwise
  function isMarketEnabled(address marketAddress) external view returns(bool);

  function minQuoteSize(address marketAddress) external view returns(uint);
  
  function minCollateralRatio() external view returns(uint);
  
  function minCollateralRatio(address account) external view returns(uint);
  
  function initCollateralRatio() external view returns(uint);
  
  function initCollateralRatio(address account) external view returns(uint);
  
  function closeFactor() external view returns(uint);

  function repaymentGracePeriod() external view returns(uint);
  
  function maturityGracePeriod() external view returns(uint);
  
  function liquidationIncentive() external view returns(uint);

  /// @notice Annualized protocol fee in basis points, scaled by 1e4
  function protocolFee(address marketAddress) external view returns(uint);

  /// @notice threshold in USD where protocol fee from each market will be transferred into `FeeEmissionsQontroller`
  /// once this amount is reached, scaled by 1e6
  function thresholdUSD() external view returns(uint);
  
  /// @notice 2**256 - 1
  function UINT_MAX() external pure returns(uint);
  
  /// @notice Generic mantissa corresponding to ETH decimals
  function MANTISSA_DEFAULT() external pure returns(uint);

  /// @notice Mantissa for USD
  function MANTISSA_USD() external pure returns(uint);
  
  /// @notice Mantissa for collateral ratio
  function MANTISSA_COLLATERAL_RATIO() external pure returns(uint);

  /// @notice `assetFactor` and `marketFactor` have up to 8 decimal places precision
  function MANTISSA_FACTORS() external pure returns(uint);

  /// @notice Basis points have 4 decimal place precision
  function MANTISSA_BPS() external pure returns(uint);

  /// @notice Staked Qoda has 6 decimal place precision
  function MANTISSA_STAKING() external pure returns(uint);

  /// @notice `collateralFactor` cannot be above 1.0
  function MAX_COLLATERAL_FACTOR() external pure returns(uint);

  /// @notice `marketFactor` cannot be above 1.0
  function MAX_MARKET_FACTOR() external pure returns(uint);

  /// @notice version number of this contract, will be bumped upon contractual change
  function VERSION_NUMBER() external pure returns(string memory);
}

File 6 of 13 : IQodaERC20.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

interface IQodaERC20 is IERC20, IERC20Metadata {
  
  /// @notice Mints tokens to a recipient, as long as it is under the
  /// supply cap. Reverts if the caller does not have the minter role.
  /// @param recipient Account to mint tokens to
  /// @param amount Amount of tokens to mint
  function mint(address recipient, uint amount) external returns(bool);
  
  function supplyCap() external view returns(uint);
}

File 7 of 13 : IStakingEmissionsQontroller.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

interface IStakingEmissionsQontroller {

  /** EVENTS **/
  
  /// @notice Emitted when we move to a new emissions regime
  event NewEmissionsPerBlock(uint indexed currentPeriod, uint startBlock, uint emissions, uint numBlocks);

  /// @notice Emitted when user claims emissions
  event ClaimEmissions(address indexed account, uint emission);
  
  /// @notice Emitted when user deposits
  event Deposit(address indexed account, uint amount);

  /// @notice Emitted when user withdraws
  event Withdraw(address indexed account, uint amount);
  
  /** ACCESS CONTROLLED FUNCTIONS **/
  
  /// @notice Credits the account with the given amount in `StakingEmissionsQontroller`
  /// This function should only be called by the veToken contract when the user
  /// claims their accrued veTokens.
  /// @param account Address of the user
  /// @param amount Amount to credit the account
  function deposit(address account, uint amount) external;

  /// @notice Cancels account's full amount and debt from `StakingEmissionsQontroller`
  /// and claims any remaining emissions for that account. This should only
  /// be called by the veToken contract when the user unstakes the underlying
  /// @param account Address of the user.
  function withdraw(address account) external;
  
  /// @notice Function to start reward distribution, can only be invoked once.
  /// @param startBlock starting block for reward distribution, 0 for current block
  function _startStaking(uint startBlock) external;

  /** USER INTERFACE **/

  /// @notice Transfer accrued emissions from `StakingEmissionsQontroller` to veToken holder
  /// This function can be called by the user anytime and as often as they wish.
  function claimEmissions() external;

  /// @notice Update emissions variables of the pool
  function updatePool() external;

  /** VIEW FUNCTIONS **/

  /// @notice Calculates the amount of emissions claimable by a user by updating
  /// the pool info in memory without writing to storage so that viewing the
  /// claimable amount does not incur gas costs.
  /// @param account Address of the user
  /// @return uint Amount claimable
  function claimableEmissions(address account) external view returns(uint);

  /// @notice Get the address of the `QAdmin` contract
  /// @return address Address of `QAdmin` contract
  function qAdmin() external view returns(address);
  
  /// @notice Get the address of the `QodaERC20` contract
  /// @return address Address of `QodaERC20` contract
  function qodaERC20() external view returns(address);

  /// @notice Get the address of the `veQoda` contract
  /// @return address Address of `veQoda` contract
  function veToken() external view returns(address);

  function numPeriods() external view returns(uint);
  
  function accTokenPerShare() external view returns(uint);

  function currentPeriod() external view returns(uint);

  function endBlock() external view returns(uint);

  function lastEmissionsBlock() external view returns(uint);

  function emissions() external view returns(uint);

  function numBlocks() external view returns(uint);

  // @return emissions per block, scaled by 1e6
  function emissionsPerBlock() external view returns(uint);

  function userInfo(address account) external view returns(uint, uint, uint);
  
  function stakingPeriod(uint i) external view returns(uint, uint);
  
}

File 8 of 13 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 9 of 13 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 10 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 11 of 13 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 12 of 13 : QTypes.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

library QTypes {

  /// @notice Contains all the details of an Asset. Assets  must be defined
  /// before they can be used as collateral.
  /// @member isEnabled True if an asset is defined, false otherwise
  /// @member isYieldBearing True if token bears interest (eg aToken, cToken, mToken, etc)
  /// @member underlying Address of the underlying token
  /// @member oracleFeed Address of the corresponding chainlink oracle feed
  /// @member collateralFactor 0.0 to 1.0 (scaled to 1e8) for discounting risky assets
  /// @member marketFactor 0.0 1.0 for premium on risky borrows
  /// @member maturities Iterable storage for all enabled maturities
  struct Asset {
    bool isEnabled;
    bool isYieldBearing;
    address underlying;
    address oracleFeed;
    uint collateralFactor;
    uint marketFactor;
    uint[] maturities;
  }
  
  /// @notice Contains all the fields of a created Quote
  /// @param id ID of the quote
  /// @param next Next quote in the list
  /// @param prev Previous quote in the list
  /// @param quoter Account of the Quoter
  /// @param quoteType 0 for PV+APR, 1 for FV+APR
  /// @param APR In decimal form scaled by 1e4 (ex. 10.52% = 1052)
  /// @param cashflow Can be PV or FV depending on `quoteType`
  /// @param filled Amount quote has got filled partially 
  struct Quote {
    uint64 id;
    uint64 next;
    uint64 prev;
    address quoter;
    uint8 quoteType;
    uint64 APR;
    uint cashflow;
    uint filled;
  }
  
  /// @notice Contains all the configurations customizable to an address
  /// @member enabled If config for an address is enabled. When enabled is false, credit limit is infinite even if value is 0
  /// @member minCollateralRatio If collateral ratio falls below `_minCollateralRatio`, it is subject to liquidation. Scaled by 1e8
  /// @member initCollateralRatio When initially taking a loan, collateral ratio must be higher than this. `initCollateralRatio` should always be higher than `minCollateralRatio`. Scaled by 1e8
  /// @member creditLimit Allowed limit in virtual USD for each address to do uncollateralized borrow, scaled by 1e18
  struct CreditFacility {
    bool enabled;
    uint minCollateralRatio;
    uint initCollateralRatio;
    uint creditLimit;
  }
}

File 13 of 13 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"emission","type":"uint256"}],"name":"ClaimEmissions","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"currentPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"emissions","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numBlocks","type":"uint256"}],"name":"NewEmissionsPerBlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"startBlock","type":"uint256"}],"name":"_startStaking","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accTokenPerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimEmissions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimableEmissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emissions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emissionsPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"qAdminAddress","type":"address"},{"internalType":"address","name":"qodaERC20Address","type":"address"},{"internalType":"address","name":"veTokenAddress","type":"address"},{"internalType":"uint256[]","name":"emissions_","type":"uint256[]"},{"internalType":"uint256[]","name":"numBlocks_","type":"uint256[]"},{"internalType":"uint256","name":"numPeriods_","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastEmissionsBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numBlocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numPeriods","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"qAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"qodaERC20","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"}],"name":"stakingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"veToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506118f6806100206000396000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c80638f662915116100ad578063c0cb9acf11610071578063c0cb9acf14610255578063c1027c9814610268578063ce401308146102a5578063dcd65479146102bc578063e3161ddd146102c457600080fd5b80638f66291514610219578063930fc2161461022157806394d91bea14610229578063a591a6f41461023c578063bf5d43321461024457600080fd5b806347e7ef24116100f457806347e7ef24146101ce5780634e2d851f146101e357806351cff8d9146101f6578063541aad1b14610209578063861537a51461021157600080fd5b80630604061814610131578063083c6323146101485780631959a002146101505780632267716c146101a15780633b92eb23146101a9575b600080fd5b6005545b6040519081526020015b60405180910390f35b600654610135565b61018661015e36600461158e565b6001600160a01b03166000908152600b60205260409020805460018201546002909201549092565b6040805193845260208401929092529082015260600161013f565b600854610135565b6002546001600160a01b03165b6040516001600160a01b03909116815260200161013f565b6101e16101dc3660046115a9565b6102cc565b005b6101e16101f13660046115d3565b610401565b6101e161020436600461158e565b6105e0565b600754610135565b61013561070e565b600454610135565b600954610135565b6101e1610237366004611692565b6107a9565b6101e1610a39565b6001546001600160a01b03166101b6565b61013561026336600461158e565b610a45565b6102906102763660046115d3565b6000908152600a6020526040902080546001909101549091565b6040805192835260208301919091520161013f565b6000546201000090046001600160a01b03166101b6565b600354610135565b6101e1610a57565b60005460408051630753d0a960e41b81529051620100009092046001600160a01b0316916391d1485491839163753d0a90916004808201926020929091908290030181865afa158015610323573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103479190611730565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa158015610389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ad9190611749565b6103f25760405162461bcd60e51b815260206004820152601160248201527029a2a8989037b7363c903b32aa37b5b2b760791b60448201526064015b60405180910390fd5b6103fd828243610a60565b5050565b60005460408051631d6c8e3f60e21b81529051620100009092046001600160a01b0316916391d148549183916375b238fc916004808201926020929091908290030181865afa158015610458573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047c9190611730565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa1580156104be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e29190611749565b6105205760405162461bcd60e51b815260206004820152600f60248201526e29a2a8991037b7363c9030b236b4b760891b60448201526064016103e9565b6006541580156105305750600754155b61058e5760405162461bcd60e51b815260206004820152602960248201527f534551332073746172745374616b696e672063616e206f6e6c792062652063616044820152686c6c6564206f6e636560b81b60648201526084016103e9565b600080821161059d574361059f565b815b60008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e4549091506105d79082611781565b60065560075550565b60005460408051630753d0a960e41b81529051620100009092046001600160a01b0316916391d1485491839163753d0a90916004808201926020929091908290030181865afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b9190611730565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa15801561069d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c19190611749565b6107015760405162461bcd60e51b815260206004820152601160248201527029a2a8989037b7363c903b32aa37b5b2b760791b60448201526064016103e9565b61070b8143610bb9565b50565b6000600954600854600160009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078d9190611799565b60ff1661079a91906117bc565b6107a491906117db565b905090565b600054610100900460ff16158080156107c95750600054600160ff909116105b806107e35750303b1580156107e3575060005460ff166001145b6108465760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103e9565b6000805460ff191660011790558015610869576000805461ff0019166101001790555b8184511480156108795750818351145b6108bc5760405162461bcd60e51b81526020600482015260146024820152730a68aa26a40d8cadccee8d040dad2e6dac2e8c6d60631b60448201526064016103e9565b600080546001600160a01b03808a16620100000262010000600160b01b0319909216919091178255600180548983166001600160a01b0319918216179091556002805492891692909116919091179055600383905560058190555b8281101561099657604051806040016040528086838151811061093c5761093c6117fd565b6020026020010151815260200185838151811061095b5761095b6117fd565b6020908102919091018101519091526000838152600a825260409020825181559101516001909101558061098e81611813565b915050610917565b5060008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e3546008557f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e4546009558015610a30576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b610a433343610cda565b565b6000610a518243610dd8565b92915050565b610a4343611053565b60008211610ab05760405162461bcd60e51b815260206004820152601760248201527f5345513420416d6f756e74206d757374206265203e203000000000000000000060448201526064016103e9565b610ab981611053565b610ac38382610dd8565b6001600160a01b0384166000908152600b602052604081206002018054909190610aee908490611781565b90915550506001600160a01b0383166000908152600b602052604081208054849290610b1b908490611781565b90915550506004546001600160a01b0384166000908152600b602052604090205468056bc75e2d6310000091610b50916117bc565b610b5a91906117db565b6001600160a01b0384166000818152600b6020526040908190206001019290925590517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c90610bac9085815260200190565b60405180910390a2505050565b6001600160a01b0382166000908152600b6020526040902054610c295760405162461bcd60e51b815260206004820152602260248201527f53455136204163636f756e74206d7573742068617665206465706f736974203e604482015261020360f41b60648201526084016103e9565b610c3281611053565b610c3c8282610dd8565b6001600160a01b0383166000908152600b602052604081206002018054909190610c67908490611781565b90915550506001600160a01b0382166000818152600b60209081526040918290205491519182527f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364910160405180910390a2506001600160a01b03166000908152600b6020526040812081815560010155565b610ce381611053565b6000610cef8383610dd8565b6001600160a01b0384166000908152600b6020526040812060010180549293508392909190610d1f908490611781565b90915550506001600160a01b0383166000908152600b602052604081206002015490610d4b8284611781565b1115610dd2576001600160a01b0384166000908152600b6020526040812060020155610d8e84610d7b8385611781565b6001546001600160a01b0316919061127d565b836001600160a01b03167f0d962b580b08e94b6cd0d0ed9da8371103adfad40f998c68bda1f58c7a97ffa483604051610dc991815260200190565b60405180910390a25b50505050565b6007546000901580610dea5750600654155b80610e615750600254604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015610e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5e9190611730565b11155b15610e6e57506000610a51565b600454600754831115611002576000610e89600754856112cf565b9050600060095482600854610e9e91906117bc565b610ea891906117db565b600654600554919250905b8187118015610ecf57506001600354610ecc919061182e565b81105b15610f5d5780610ede81611813565b6000818152600a602052604090208054600190910154919350915083610f048282611781565b94506000858b1115610f27576000858152600a6020526040902060010154610f31565b610f31828c61182e565b905082610f3e82866117bc565b610f4891906117db565b610f529088611781565b965050505050610eb3565b600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd49190611730565b610fe768056bc75e2d63100000856117bc565b610ff191906117db565b610ffb9086611781565b9450505050505b6001600160a01b0384166000908152600b602052604090206001810154905468056bc75e2d63100000906110379084906117bc565b61104191906117db565b61104b919061182e565b949350505050565b600754811161105f5750565b600754158061106e5750600654155b156110765750565b600254604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa1580156110c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e49190611730565b116110ee57600755565b60006110fc600754836112cf565b905060006009548260085461111191906117bc565b61111b91906117db565b90505b6006548311801561113e57506001600354611139919061182e565b600554105b156111b65761114e600654611311565b600680546005546000908152600a60205260408120600101549192906111748385611781565b909155506000905061118682866112cf565b90506009548160085461119991906117bc565b6111a391906117db565b6111ad9084611781565b9250505061111e565b801561126757600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112339190611730565b61124668056bc75e2d63100000836117bc565b61125091906117db565b600460008282546112619190611781565b90915550505b600654600754116112785760078390555b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261127890849061138c565b600060065482116112eb576112e4838361182e565b9050610a51565b60065483106112fc57506000610a51565b8260065461130a919061182e565b9392505050565b6005805490600061132183611813565b90915550506005546000818152600a60209081526040918290208054600881905560019091015460098190558351868152928301919091528183015290517fcad4809cb4d3c2b90e4ef13634a2c80b1596674930154ddaba52d0db65d3a38c9181900360600190a250565b60006113e1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661145e9092919063ffffffff16565b80519091501561127857808060200190518101906113ff9190611749565b6112785760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103e9565b606061104b8484600085856001600160a01b0385163b6114c05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103e9565b600080866001600160a01b031685876040516114dc9190611871565b60006040518083038185875af1925050503d8060008114611519576040519150601f19603f3d011682016040523d82523d6000602084013e61151e565b606091505b509150915061152e828286611539565b979650505050505050565b6060831561154857508161130a565b8251156115585782518084602001fd5b8160405162461bcd60e51b81526004016103e9919061188d565b80356001600160a01b038116811461158957600080fd5b919050565b6000602082840312156115a057600080fd5b61130a82611572565b600080604083850312156115bc57600080fd5b6115c583611572565b946020939093013593505050565b6000602082840312156115e557600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261161357600080fd5b8135602067ffffffffffffffff80831115611630576116306115ec565b8260051b604051601f19603f83011681018181108482111715611655576116556115ec565b60405293845285810183019383810192508785111561167357600080fd5b83870191505b8482101561152e57813583529183019190830190611679565b60008060008060008060c087890312156116ab57600080fd5b6116b487611572565b95506116c260208801611572565b94506116d060408801611572565b9350606087013567ffffffffffffffff808211156116ed57600080fd5b6116f98a838b01611602565b9450608089013591508082111561170f57600080fd5b5061171c89828a01611602565b92505060a087013590509295509295509295565b60006020828403121561174257600080fd5b5051919050565b60006020828403121561175b57600080fd5b8151801515811461130a57600080fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156117945761179461176b565b500190565b6000602082840312156117ab57600080fd5b815160ff8116811461130a57600080fd5b60008160001904831182151516156117d6576117d661176b565b500290565b6000826117f857634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006000198214156118275761182761176b565b5060010190565b6000828210156118405761184061176b565b500390565b60005b83811015611860578181015183820152602001611848565b83811115610dd25750506000910152565b60008251611883818460208701611845565b9190910192915050565b60208152600082518060208401526118ac816040850160208701611845565b601f01601f1916919091016040019291505056fea26469706673582212208b12e1425b0bfa3ff08a60136551758e2a24a6d9248e559ed2278967b105593664736f6c634300080a0033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061012c5760003560e01c80638f662915116100ad578063c0cb9acf11610071578063c0cb9acf14610255578063c1027c9814610268578063ce401308146102a5578063dcd65479146102bc578063e3161ddd146102c457600080fd5b80638f66291514610219578063930fc2161461022157806394d91bea14610229578063a591a6f41461023c578063bf5d43321461024457600080fd5b806347e7ef24116100f457806347e7ef24146101ce5780634e2d851f146101e357806351cff8d9146101f6578063541aad1b14610209578063861537a51461021157600080fd5b80630604061814610131578063083c6323146101485780631959a002146101505780632267716c146101a15780633b92eb23146101a9575b600080fd5b6005545b6040519081526020015b60405180910390f35b600654610135565b61018661015e36600461158e565b6001600160a01b03166000908152600b60205260409020805460018201546002909201549092565b6040805193845260208401929092529082015260600161013f565b600854610135565b6002546001600160a01b03165b6040516001600160a01b03909116815260200161013f565b6101e16101dc3660046115a9565b6102cc565b005b6101e16101f13660046115d3565b610401565b6101e161020436600461158e565b6105e0565b600754610135565b61013561070e565b600454610135565b600954610135565b6101e1610237366004611692565b6107a9565b6101e1610a39565b6001546001600160a01b03166101b6565b61013561026336600461158e565b610a45565b6102906102763660046115d3565b6000908152600a6020526040902080546001909101549091565b6040805192835260208301919091520161013f565b6000546201000090046001600160a01b03166101b6565b600354610135565b6101e1610a57565b60005460408051630753d0a960e41b81529051620100009092046001600160a01b0316916391d1485491839163753d0a90916004808201926020929091908290030181865afa158015610323573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103479190611730565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa158015610389573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ad9190611749565b6103f25760405162461bcd60e51b815260206004820152601160248201527029a2a8989037b7363c903b32aa37b5b2b760791b60448201526064015b60405180910390fd5b6103fd828243610a60565b5050565b60005460408051631d6c8e3f60e21b81529051620100009092046001600160a01b0316916391d148549183916375b238fc916004808201926020929091908290030181865afa158015610458573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047c9190611730565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa1580156104be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e29190611749565b6105205760405162461bcd60e51b815260206004820152600f60248201526e29a2a8991037b7363c9030b236b4b760891b60448201526064016103e9565b6006541580156105305750600754155b61058e5760405162461bcd60e51b815260206004820152602960248201527f534551332073746172745374616b696e672063616e206f6e6c792062652063616044820152686c6c6564206f6e636560b81b60648201526084016103e9565b600080821161059d574361059f565b815b60008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e4549091506105d79082611781565b60065560075550565b60005460408051630753d0a960e41b81529051620100009092046001600160a01b0316916391d1485491839163753d0a90916004808201926020929091908290030181865afa158015610637573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065b9190611730565b6040516001600160e01b031960e084901b1681526004810191909152336024820152604401602060405180830381865afa15801561069d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c19190611749565b6107015760405162461bcd60e51b815260206004820152601160248201527029a2a8989037b7363c903b32aa37b5b2b760791b60448201526064016103e9565b61070b8143610bb9565b50565b6000600954600854600160009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078d9190611799565b60ff1661079a91906117bc565b6107a491906117db565b905090565b600054610100900460ff16158080156107c95750600054600160ff909116105b806107e35750303b1580156107e3575060005460ff166001145b6108465760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103e9565b6000805460ff191660011790558015610869576000805461ff0019166101001790555b8184511480156108795750818351145b6108bc5760405162461bcd60e51b81526020600482015260146024820152730a68aa26a40d8cadccee8d040dad2e6dac2e8c6d60631b60448201526064016103e9565b600080546001600160a01b03808a16620100000262010000600160b01b0319909216919091178255600180548983166001600160a01b0319918216179091556002805492891692909116919091179055600383905560058190555b8281101561099657604051806040016040528086838151811061093c5761093c6117fd565b6020026020010151815260200185838151811061095b5761095b6117fd565b6020908102919091018101519091526000838152600a825260409020825181559101516001909101558061098e81611813565b915050610917565b5060008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e3546008557f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e4546009558015610a30576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b610a433343610cda565b565b6000610a518243610dd8565b92915050565b610a4343611053565b60008211610ab05760405162461bcd60e51b815260206004820152601760248201527f5345513420416d6f756e74206d757374206265203e203000000000000000000060448201526064016103e9565b610ab981611053565b610ac38382610dd8565b6001600160a01b0384166000908152600b602052604081206002018054909190610aee908490611781565b90915550506001600160a01b0383166000908152600b602052604081208054849290610b1b908490611781565b90915550506004546001600160a01b0384166000908152600b602052604090205468056bc75e2d6310000091610b50916117bc565b610b5a91906117db565b6001600160a01b0384166000818152600b6020526040908190206001019290925590517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c90610bac9085815260200190565b60405180910390a2505050565b6001600160a01b0382166000908152600b6020526040902054610c295760405162461bcd60e51b815260206004820152602260248201527f53455136204163636f756e74206d7573742068617665206465706f736974203e604482015261020360f41b60648201526084016103e9565b610c3281611053565b610c3c8282610dd8565b6001600160a01b0383166000908152600b602052604081206002018054909190610c67908490611781565b90915550506001600160a01b0382166000818152600b60209081526040918290205491519182527f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364910160405180910390a2506001600160a01b03166000908152600b6020526040812081815560010155565b610ce381611053565b6000610cef8383610dd8565b6001600160a01b0384166000908152600b6020526040812060010180549293508392909190610d1f908490611781565b90915550506001600160a01b0383166000908152600b602052604081206002015490610d4b8284611781565b1115610dd2576001600160a01b0384166000908152600b6020526040812060020155610d8e84610d7b8385611781565b6001546001600160a01b0316919061127d565b836001600160a01b03167f0d962b580b08e94b6cd0d0ed9da8371103adfad40f998c68bda1f58c7a97ffa483604051610dc991815260200190565b60405180910390a25b50505050565b6007546000901580610dea5750600654155b80610e615750600254604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015610e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5e9190611730565b11155b15610e6e57506000610a51565b600454600754831115611002576000610e89600754856112cf565b9050600060095482600854610e9e91906117bc565b610ea891906117db565b600654600554919250905b8187118015610ecf57506001600354610ecc919061182e565b81105b15610f5d5780610ede81611813565b6000818152600a602052604090208054600190910154919350915083610f048282611781565b94506000858b1115610f27576000858152600a6020526040902060010154610f31565b610f31828c61182e565b905082610f3e82866117bc565b610f4891906117db565b610f529088611781565b965050505050610eb3565b600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd49190611730565b610fe768056bc75e2d63100000856117bc565b610ff191906117db565b610ffb9086611781565b9450505050505b6001600160a01b0384166000908152600b602052604090206001810154905468056bc75e2d63100000906110379084906117bc565b61104191906117db565b61104b919061182e565b949350505050565b600754811161105f5750565b600754158061106e5750600654155b156110765750565b600254604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa1580156110c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e49190611730565b116110ee57600755565b60006110fc600754836112cf565b905060006009548260085461111191906117bc565b61111b91906117db565b90505b6006548311801561113e57506001600354611139919061182e565b600554105b156111b65761114e600654611311565b600680546005546000908152600a60205260408120600101549192906111748385611781565b909155506000905061118682866112cf565b90506009548160085461119991906117bc565b6111a391906117db565b6111ad9084611781565b9250505061111e565b801561126757600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112339190611730565b61124668056bc75e2d63100000836117bc565b61125091906117db565b600460008282546112619190611781565b90915550505b600654600754116112785760078390555b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261127890849061138c565b600060065482116112eb576112e4838361182e565b9050610a51565b60065483106112fc57506000610a51565b8260065461130a919061182e565b9392505050565b6005805490600061132183611813565b90915550506005546000818152600a60209081526040918290208054600881905560019091015460098190558351868152928301919091528183015290517fcad4809cb4d3c2b90e4ef13634a2c80b1596674930154ddaba52d0db65d3a38c9181900360600190a250565b60006113e1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661145e9092919063ffffffff16565b80519091501561127857808060200190518101906113ff9190611749565b6112785760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103e9565b606061104b8484600085856001600160a01b0385163b6114c05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103e9565b600080866001600160a01b031685876040516114dc9190611871565b60006040518083038185875af1925050503d8060008114611519576040519150601f19603f3d011682016040523d82523d6000602084013e61151e565b606091505b509150915061152e828286611539565b979650505050505050565b6060831561154857508161130a565b8251156115585782518084602001fd5b8160405162461bcd60e51b81526004016103e9919061188d565b80356001600160a01b038116811461158957600080fd5b919050565b6000602082840312156115a057600080fd5b61130a82611572565b600080604083850312156115bc57600080fd5b6115c583611572565b946020939093013593505050565b6000602082840312156115e557600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261161357600080fd5b8135602067ffffffffffffffff80831115611630576116306115ec565b8260051b604051601f19603f83011681018181108482111715611655576116556115ec565b60405293845285810183019383810192508785111561167357600080fd5b83870191505b8482101561152e57813583529183019190830190611679565b60008060008060008060c087890312156116ab57600080fd5b6116b487611572565b95506116c260208801611572565b94506116d060408801611572565b9350606087013567ffffffffffffffff808211156116ed57600080fd5b6116f98a838b01611602565b9450608089013591508082111561170f57600080fd5b5061171c89828a01611602565b92505060a087013590509295509295509295565b60006020828403121561174257600080fd5b5051919050565b60006020828403121561175b57600080fd5b8151801515811461130a57600080fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156117945761179461176b565b500190565b6000602082840312156117ab57600080fd5b815160ff8116811461130a57600080fd5b60008160001904831182151516156117d6576117d661176b565b500290565b6000826117f857634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60006000198214156118275761182761176b565b5060010190565b6000828210156118405761184061176b565b500390565b60005b83811015611860578181015183820152602001611848565b83811115610dd25750506000910152565b60008251611883818460208701611845565b9190910192915050565b60208152600082518060208401526118ac816040850160208701611845565b601f01601f1916919091016040019291505056fea26469706673582212208b12e1425b0bfa3ff08a60136551758e2a24a6d9248e559ed2278967b105593664736f6c634300080a0033

Block Transaction Gas Used Reward
view all blocks collator

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
[ 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.