Contract 0x9a77da5Ebf1bD78AbaAbf7bbD13B1aB8FD1D8EB7

Txn Hash Method
Block
From
To
Value [Txn Fee]
0xd44a4e64b40869ba4fef92c6d1787a8b366c49c81ddcbf53c096b02db9b917940x60a06040161553312022-11-14 16:50:5518 days 19 hrs ago0x4c828d2a58b747de3598c2ce18a0908b0e78dc3e IN  Create: VotableStakingRewards0 CELO0.0002775761
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
VotableStakingRewards

Compiler Version
v0.8.16+commit.07a7930e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 18 : VotableStakingRewards.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "./interfaces/IRomulusDelegate.sol";
import "./interfaces/IStakingRewards.sol";
import "./RewardsDistributionRecipient.sol";
import "./Voter.sol";
import "./interfaces/IPoolManager.sol";

// Base: https://github.com/Ubeswap/ubeswap-farming/blob/master/contracts/synthetix/contracts/StakingRewards.sol
contract VotableStakingRewards is
  IStakingRewards,
  RewardsDistributionRecipient,
  ReentrancyGuard
{
  using SafeMath for uint256;
  using SafeERC20 for IERC20;

  /* ========== STATE VARIABLES ========== */

  IRomulusDelegate public immutable romulusDelegate;

  IERC20 public rewardsToken;
  IERC20 public stakingToken;
  uint256 public periodFinish = 0;
  uint256 public rewardRate = 0;
  uint256 public rewardsDuration = 7 days;
  uint256 public lastUpdateTime;
  uint256 public rewardPerTokenStored;

  IPoolManager public poolManager;
  uint256 public lockDuration;
  uint256 public lockTime;
  mapping(address => uint256) public userLocked;
  mapping(address => mapping(uint256 => uint256)) public userWeights;
  mapping(uint256 => uint256) public poolWeights;

  mapping(address => uint256) public userRewardPerTokenPaid;
  mapping(address => uint256) public rewards;

  uint256 private _totalSupply;
  mapping(address => uint256) private _balances;
  mapping(address => Voter) public voters;

  /* ========== CONSTRUCTOR ========== */

  constructor(
    address _owner,
    address _rewardsDistribution,
    address _rewardsToken,
    address _stakingToken,
    IRomulusDelegate _romulusDelegate,
    IPoolManager _poolManager,
    uint256 _lockDuration
  ) Owned(_owner) {
    rewardsToken = IERC20(_rewardsToken);
    stakingToken = IERC20(_stakingToken);
    rewardsDistribution = _rewardsDistribution;
    romulusDelegate = _romulusDelegate;
    poolManager = _poolManager;
    lockDuration = _lockDuration;
  }

  /* ========== VIEWS ========== */

  function totalSupply() external view override returns (uint256) {
    return _totalSupply;
  }

  function balanceOf(address account) external view override returns (uint256) {
    return _balances[account];
  }

  function lastTimeRewardApplicable() public view override returns (uint256) {
    return Math.min(block.timestamp, periodFinish);
  }

  function rewardPerToken() public view override returns (uint256) {
    if (_totalSupply == 0) {
      return rewardPerTokenStored;
    }
    return
      rewardPerTokenStored.add(
        lastTimeRewardApplicable()
          .sub(lastUpdateTime)
          .mul(rewardRate)
          .mul(1e18)
          .div(_totalSupply)
      );
  }

  function earned(address account) public view override returns (uint256) {
    return
      _balances[account]
        .mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
        .div(1e18)
        .add(rewards[account]);
  }

  function getRewardForDuration() external view override returns (uint256) {
    return rewardRate.mul(rewardsDuration);
  }

  /* ========== MUTATIVE FUNCTIONS ========== */

  function stake(uint256 amount)
    external
    override
    nonReentrant
    updateReward(msg.sender)
  {
    require(amount > 0, "Cannot stake 0");
    _totalSupply = _totalSupply.add(amount);
    _balances[msg.sender] = _balances[msg.sender].add(amount);
    if (address(voters[msg.sender]) == address(0)) {
      voters[msg.sender] = new Voter(
        address(this), // controller
        msg.sender, // user
        IVotingDelegates(address(stakingToken)),
        romulusDelegate
      );
    }
    Voter v = voters[msg.sender];
    stakingToken.safeTransferFrom(msg.sender, address(v), amount);
    emit Staked(msg.sender, amount);
  }

  function withdraw(uint256 amount)
    public
    override
    nonReentrant
    updateReward(msg.sender)
  {
    require(address(voters[msg.sender]) != address(0), "Caller has no voter");
    require(amount > 0, "Cannot withdraw 0");
    uint256 withdrawable = _balances[msg.sender].sub(userLocked[msg.sender]);
    require(amount <= withdrawable, "Withdrawing more than available");
    _totalSupply = _totalSupply.sub(amount);
    _balances[msg.sender] = _balances[msg.sender].sub(amount);
    Voter v = voters[msg.sender];
    v.removeVotes(msg.sender, amount);
    emit Withdrawn(msg.sender, amount);
  }

  function getReward() public override nonReentrant updateReward(msg.sender) {
    uint256 reward = rewards[msg.sender];
    if (reward > 0) {
      rewards[msg.sender] = 0;
      rewardsToken.safeTransfer(msg.sender, reward);
      emit RewardPaid(msg.sender, reward);
    }
  }

  function exit() external override {
    withdraw(_balances[msg.sender].sub(userLocked[msg.sender]));
    getReward();
  }

  function allocatePoolWeight(uint256 poolId, uint256 amount) external {
    require(
      amount.add(userLocked[msg.sender]) <= _balances[msg.sender],
      "Allocating too much"
    );

    userLocked[msg.sender] = userLocked[msg.sender].add(amount);
    userWeights[msg.sender][poolId] = userWeights[msg.sender][poolId].add(amount);
    poolWeights[poolId] = poolWeights[poolId].add(amount);
  }

  function removePoolWeight(uint256 poolId, uint256 amount) external isUnlocked {
    require(userWeights[msg.sender][poolId] >= amount, "Removing too much");

    userLocked[msg.sender] = userLocked[msg.sender].sub(amount);
    userWeights[msg.sender][poolId] = userWeights[msg.sender][poolId].sub(amount);
    poolWeights[poolId] = poolWeights[poolId].sub(amount);
  }

  /* ========== RESTRICTED FUNCTIONS ========== */

  function notifyRewardAmount(uint256 reward)
    external
    override
    onlyRewardsDistribution
    updateReward(address(0))
  {
    if (block.timestamp >= periodFinish) {
      rewardRate = reward.div(rewardsDuration);
    } else {
      uint256 remaining = periodFinish.sub(block.timestamp);
      uint256 leftover = remaining.mul(rewardRate);
      rewardRate = reward.add(leftover).div(rewardsDuration);
    }

    // Ensure the provided reward amount is not more than the balance in the contract.
    // This keeps the reward rate in the right range, preventing overflows due to
    // very high values of rewardRate in the earned and rewardsPerToken functions;
    // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
    uint256 balance = rewardsToken.balanceOf(address(this));
    require(
      rewardRate <= balance.div(rewardsDuration),
      "Provided reward too high"
    );

    lastUpdateTime = block.timestamp;
    periodFinish = block.timestamp.add(rewardsDuration);
    emit RewardAdded(reward);
  }

  function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
    require(
      block.timestamp > periodFinish,
      "Rewards period must be end before changing the rewardsDuration"
    );
    rewardsDuration = _rewardsDuration;
    emit RewardsDurationUpdated(rewardsDuration);
  }

  function lock() external onlyOwner isUnlocked {
    emit Locked(block.timestamp, block.timestamp + lockDuration);
    lockTime = block.timestamp;
  }

  function syncWeights(uint256 start, uint256 end) external onlyOwner {
    uint256 poolsCount = poolManager.poolsCount();
    if (end > poolsCount) {
      end = poolsCount;
    }
    for (uint256 i = start; i < end; i++) {
      poolManager.setWeight(poolManager.poolsByIndex(i), poolWeights[i]);
    }
  }

  function setLockDuration(uint256 _lockDuration) external onlyOwner isUnlocked {
    emit LockDurationChanged(lockDuration, _lockDuration);
    lockDuration =  _lockDuration;
  }

  // Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
  function recoverERC20(address tokenAddress, uint256 tokenAmount)
    external
    onlyOwner
  {
    require(
      tokenAddress != address(stakingToken),
      "Cannot withdraw the staking token"
    );
    IERC20(tokenAddress).safeTransfer(owner, tokenAmount);
    emit Recovered(tokenAddress, tokenAmount);
  }

  function transferPoolManagerOwnership(address to) external onlyOwner {
    poolManager.transferOwnership(to);
  }

  /* ========== MODIFIERS ========== */

  modifier updateReward(address account) {
    rewardPerTokenStored = rewardPerToken();
    lastUpdateTime = lastTimeRewardApplicable();
    if (account != address(0)) {
      rewards[account] = earned(account);
      userRewardPerTokenPaid[account] = rewardPerTokenStored;
    }
    _;
  }

  modifier isUnlocked() {
    require(block.timestamp >= lockTime.add(lockDuration), "Weights are locked");
    _;
  }

  /* ========== EVENTS ========== */

  event RewardAdded(uint256 reward);
  event Staked(address indexed user, uint256 amount);
  event Withdrawn(address indexed user, uint256 amount);
  event RewardPaid(address indexed user, uint256 reward);
  event RewardsDurationUpdated(uint256 newDuration);
  event Recovered(address token, uint256 amount);
  event Locked(uint256 lockTime, uint256 lockEndTime);
  event LockDurationChanged(uint256 prevLockDuration, uint256 nextLockDuration);
}

File 2 of 18 : IStakingRewards.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.4.24;

interface IStakingRewards {
  // Views
  function lastTimeRewardApplicable() external view returns (uint256);

  function rewardPerToken() external view returns (uint256);

  function earned(address account) external view returns (uint256);

  function getRewardForDuration() external view returns (uint256);

  function totalSupply() external view returns (uint256);

  function balanceOf(address account) external view returns (uint256);

  // Mutative

  function stake(uint256 amount) external;

  function withdraw(uint256 amount) external;

  function getReward() external;

  function exit() external;
}

File 3 of 18 : IRomulusDelegate.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

interface IRomulusDelegate {
  function castVote(uint256 proposalId, uint8 support) external;

  function propose(
    address[] memory targets,
    uint256[] memory values,
    string[] memory signatures,
    bytes[] memory calldatas,
    string memory description
  ) external;
}

File 4 of 18 : IPoolManager.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract IPoolManager is Ownable {
  function poolsCount() external view virtual returns (uint256);

  function poolsByIndex(uint256 index)
    external
    view
    virtual
    returns (address);

  function setWeight(address _stakingToken, uint256 _weight) external virtual;
}

File 5 of 18 : Voter.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.3;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@ubeswap/governance/contracts/interfaces/IVotingDelegates.sol";

import "./interfaces/IRomulusDelegate.sol";

contract Voter {
  using SafeERC20 for IERC20;

  address public immutable controller;
  address public immutable user;
  IVotingDelegates public immutable votingToken;
  IRomulusDelegate public immutable romulusDelegate;

  modifier onlyController() {
    require(msg.sender == controller, "Voter: only controller");
    _;
  }

  modifier onlyUser() {
    require(msg.sender == user, "Voter: only user");
    _;
  }

  constructor(
    address _controller,
    address _user,
    IVotingDelegates _votingToken,
    IRomulusDelegate _romulusDelegate
  ) {
    controller = _controller;
    user = _user;
    votingToken = _votingToken;
    romulusDelegate = _romulusDelegate;
    _votingToken.delegate(address(this));
  }

  function removeVotes(address to, uint256 amount) external onlyController {
    IERC20(address(votingToken)).safeTransfer(to, amount);
  }

  /**
   * @notice Casts vote for/against/abstain a Proposal
   * @param proposalId id of the proposal to vote for/against/abstain
   * @param support AGAINST=0 ; 1=FOR ; 2=ABSTAIN
   */
  function castVote(uint256 proposalId, uint8 support) external onlyUser {
    romulusDelegate.castVote(proposalId, support);
  }

  /// @notice Creates a proposal from this Voter. Only callable by the Voter's user.
  function propose(
    address[] memory targets,
    uint256[] memory values,
    string[] memory signatures,
    bytes[] memory calldatas,
    string memory description
  ) external onlyUser {
      romulusDelegate.propose(
      targets,
      values,
      signatures,
      calldatas,
      description
    );
  }

  /**
   * @notice Delegate votes of Voter to `delegatee`. Only callable by the Voter's user.
   * @param delegatee The address to delegate votes to
   */
  function delegate(address delegatee) external onlyUser {
    votingToken.delegate(delegatee);
  }
}

File 6 of 18 : RewardsDistributionRecipient.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

// Inheritance
import "./Owned.sol";

// https://docs.synthetix.io/contracts/source/contracts/rewardsdistributionrecipient
abstract contract RewardsDistributionRecipient is Owned {
  address public rewardsDistribution;

  event RewardsDistributionChanged(
    address indexed previousRewardsDistribution,
    address indexed nextRewardsDistribution
  );

  function notifyRewardAmount(uint256 reward) external virtual;

  modifier onlyRewardsDistribution() {
    require(
      msg.sender == rewardsDistribution,
      "Caller is not RewardsDistribution contract"
    );
    _;
  }

  function setRewardsDistribution(address _rewardsDistribution)
    external
    onlyOwner
  {
    address previousRewardsDistribution = rewardsDistribution;
    rewardsDistribution = _rewardsDistribution;
    emit RewardsDistributionChanged(
      previousRewardsDistribution,
      rewardsDistribution
    );
  }
}

File 7 of 18 : Owned.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

// https://docs.synthetix.io/contracts/source/contracts/owned
contract Owned {
  address public owner;
  address public nominatedOwner;

  constructor(address _owner) {
    require(_owner != address(0), "Owner address cannot be 0");
    owner = _owner;
    emit OwnerChanged(address(0), _owner);
  }

  function nominateNewOwner(address _owner) external onlyOwner {
    nominatedOwner = _owner;
    emit OwnerNominated(_owner);
  }

  function acceptOwnership() external {
    require(
      msg.sender == nominatedOwner,
      "You must be nominated before you can accept ownership"
    );
    emit OwnerChanged(owner, nominatedOwner);
    owner = nominatedOwner;
    nominatedOwner = address(0);
  }

  modifier onlyOwner() {
    _onlyOwner();
    _;
  }

  function _onlyOwner() private view {
    require(
      msg.sender == owner,
      "Only the contract owner may perform this action"
    );
  }

  event OwnerNominated(address newOwner);
  event OwnerChanged(address oldOwner, address newOwner);
}

File 8 of 18 : IVotingDelegates.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.3;

/**
 * Interface for a contract that keeps track of voting delegates.
 */
interface IVotingDelegates {
    /// @notice An event thats emitted when an account changes its delegate
    event DelegateChanged(
        address indexed delegator,
        address indexed fromDelegate,
        address indexed toDelegate
    );

    /// @notice An event thats emitted when a delegate account's vote balance changes
    event DelegateVotesChanged(
        address indexed delegate,
        uint256 previousBalance,
        uint256 newBalance
    );

    /// @notice An event emitted when an account's voting power is transferred.
    // - If `from` is `address(0)`, power was minted.
    // - If `to` is `address(0)`, power was burned.
    event Transfer(address indexed from, address indexed to, uint256 amount);

    /// @notice Name of the contract.
    // Required for signing.
    function name() external view returns (string memory);

    /// @notice A record of each accounts delegate
    function delegates(address delegatee) external view returns (address);

    /**
     * @notice Delegate votes from `msg.sender` to `delegatee`
     * @param delegatee The address to delegate votes to
     */
    function delegate(address delegatee) external;

    /**
     * @notice Delegates votes from signatory to `delegatee`
     * @param delegatee The address to delegate votes to
     * @param nonce The contract state required to match the signature
     * @param expiry The time at which to expire the signature
     * @param v The recovery byte of the signature
     * @param r Half of the ECDSA signature pair
     * @param s Half of the ECDSA signature pair
     */
    function delegateBySig(
        address delegatee,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @notice Get the amount of voting power of an account
     * @param account The address of the account to get the balance of
     * @return The amount of voting power held
     */
    function votingPower(address account) external view returns (uint96);

    /// @notice Total voting power in existence.
    function totalVotingPower() external view returns (uint96);
}

File 9 of 18 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        uint256 result = sqrt(a);
        if (rounding == Rounding.Up && result * result < a) {
            result += 1;
        }
        return result;
    }
}

File 11 of 18 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 12 of 18 : 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 13 of 18 : 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 14 of 18 : 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 15 of 18 : 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 16 of 18 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 17 of 18 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

File 18 of 18 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_rewardsDistribution","type":"address"},{"internalType":"address","name":"_rewardsToken","type":"address"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"contract IRomulusDelegate","name":"_romulusDelegate","type":"address"},{"internalType":"contract IPoolManager","name":"_poolManager","type":"address"},{"internalType":"uint256","name":"_lockDuration","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevLockDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nextLockDuration","type":"uint256"}],"name":"LockDurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockEndTime","type":"uint256"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousRewardsDistribution","type":"address"},{"indexed":true,"internalType":"address","name":"nextRewardsDistribution","type":"address"}],"name":"RewardsDistributionChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"allocatePoolWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolManager","outputs":[{"internalType":"contract IPoolManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolWeights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removePoolWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDistribution","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"romulusDelegate","outputs":[{"internalType":"contract IRomulusDelegate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockDuration","type":"uint256"}],"name":"setLockDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardsDistribution","type":"address"}],"name":"setRewardsDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardsDuration","type":"uint256"}],"name":"setRewardsDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"syncWeights","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"transferPoolManagerOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userLocked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userWeights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"voters","outputs":[{"internalType":"contract Voter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040526000600655600060075562093a806008553480156200002257600080fd5b506040516200306038038062003060833981016040819052620000459162000175565b866001600160a01b038116620000a15760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015260640160405180910390fd5b600080546001600160a01b0319166001600160a01b03831690811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1506001600355600480546001600160a01b039687166001600160a01b03199182161790915560058054958716958216959095179094556002805496861696851696909617909555908316608052600b8054919093169116179055600c555062000214565b6001600160a01b03811681146200017257600080fd5b50565b600080600080600080600060e0888a0312156200019157600080fd5b87516200019e816200015c565b6020890151909750620001b1816200015c565b6040890151909650620001c4816200015c565b6060890151909550620001d7816200015c565b6080890151909450620001ea816200015c565b60a0890151909350620001fd816200015c565b8092505060c0880151905092959891949750929550565b608051612e29620002376000396000818161035601526114740152612e296000f3fe60806040523480156200001157600080fd5b5060043610620002905760003560e01c806379ba50971162000161578063c8f33c9111620000d3578063dc4c90d31162000092578063dc4c90d314620005cb578063df136d6514620005df578063e97adb8514620005e9578063e9fad8ee1462000617578063ebe2b12b1462000621578063f83d08ba146200062b57600080fd5b8063c8f33c911462000575578063cc1a378f146200057f578063cd3daf9d1462000596578063d1af0c7d14620005a0578063d72ca48d14620005b457600080fd5b80638b87634711620001205780638b87634714620004d85780638da5cb5b14620004fb578063a3ec138d146200050f578063a694fc3a146200053b578063bba05384146200055257600080fd5b806379ba5097146200048c5780637b0a47ee146200049657806380e4e1ec14620004a057806380faa57d14620004b75780638980f11f14620004c157600080fd5b806333f4103111620002075780634eb665af11620001c65780634eb665af14620003e75780634fede52414620003fe57806353a47bb71462000421578063645505c4146200043557806370a08231146200044c57806372f702f3146200047857600080fd5b806333f410311462000391578063386a952514620003a85780633c6b16ab14620003b25780633d18b91214620003c95780633fc6df6e14620003d357600080fd5b806318160ddd116200025457806318160ddd146200030f5780631976214314620003185780631c1f78eb146200032f5780632e1a7d4d14620003395780633310c7df146200035057600080fd5b80628cc26214620002955780630455444314620002bf5780630700037d14620002c95780630d66808714620002ec5780631627540c14620002f6575b600080fd5b620002ac620002a636600462001c42565b62000635565b6040519081526020015b60405180910390f35b620002ac600c5481565b620002ac620002da36600462001c42565b60126020526000908152604090205481565b620002ac600d5481565b6200030d6200030736600462001c42565b620006bd565b005b601354620002ac565b6200030d6200032936600462001c42565b6200071c565b620002ac62000778565b6200030d6200034a36600462001c62565b62000798565b620003787f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001620002b6565b6200030d620003a236600462001c7c565b62000a3c565b620002ac60085481565b6200030d620003c336600462001c62565b62000bd5565b6200030d62000e45565b60025462000378906001600160a01b031681565b6200030d620003f836600462001c62565b62000f52565b620002ac6200040f36600462001c62565b60106020526000908152604090205481565b60015462000378906001600160a01b031681565b6200030d6200044636600462001c7c565b62000fd0565b620002ac6200045d36600462001c42565b6001600160a01b031660009081526014602052604090205490565b60055462000378906001600160a01b031681565b6200030d620010f5565b620002ac60075481565b6200030d620004b136600462001c42565b620011e1565b620002ac6200124f565b6200030d620004d236600462001c9f565b6200125f565b620002ac620004e936600462001c42565b60116020526000908152604090205481565b60005462000378906001600160a01b031681565b620003786200052036600462001c42565b6015602052600090815260409020546001600160a01b031681565b6200030d6200054c36600462001c62565b62001335565b620002ac6200056336600462001c42565b600e6020526000908152604090205481565b620002ac60095481565b6200030d6200059036600462001c62565b62001582565b620002ac6200163b565b60045462000378906001600160a01b031681565b6200030d620005c536600462001c7c565b62001690565b600b5462000378906001600160a01b031681565b620002ac600a5481565b620002ac620005fa36600462001c9f565b600f60209081526000928352604080842090915290825290205481565b6200030d6200177b565b620002ac60065481565b6200030d620017b4565b6001600160a01b0381166000908152601260209081526040808320546011909252822054620006b79190620006b090670de0b6b3a764000090620006a9906200068990620006826200163b565b9062001841565b6001600160a01b0388166000908152601460205260409020549062001856565b9062001864565b9062001872565b92915050565b620006c762001880565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020015b60405180910390a150565b6200072662001880565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f7cd0eff38c2bfa946cee93bb97833afb376387f4d6c0df35a7fb8b20b3f3ece190600090a35050565b6000620007936008546007546200185690919063ffffffff16565b905090565b600260035403620007c65760405162461bcd60e51b8152600401620007bd9062001cce565b60405180910390fd5b600260035533620007d66200163b565b600a55620007e36200124f565b6009556001600160a01b038116156200082d57620008018162000635565b6001600160a01b038216600090815260126020908152604080832093909355600a546011909152919020555b336000908152601560205260409020546001600160a01b03166200088a5760405162461bcd60e51b815260206004820152601360248201527221b0b63632b9103430b9903737903b37ba32b960691b6044820152606401620007bd565b60008211620008d05760405162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b6044820152606401620007bd565b336000908152600e60209081526040808320546014909252822054620008f69162001841565b9050808311156200094a5760405162461bcd60e51b815260206004820152601f60248201527f5769746864726177696e67206d6f7265207468616e20617661696c61626c65006044820152606401620007bd565b60135462000959908462001841565b6013553360009081526014602052604090205462000978908462001841565b336000818152601460209081526040808320949094556015905282902054915163019cd41160e71b81526004810191909152602481018590526001600160a01b0390911690819063ce6a088090604401600060405180830381600087803b158015620009e357600080fd5b505af1158015620009f8573d6000803e3d6000fd5b50506040518681523392507f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5915060200160405180910390a2505060016003555050565b62000a4662001880565b600b5460408051630463c46f60e51b815290516000926001600160a01b031691638c788de09160048083019260209291908290030181865afa15801562000a91573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ab7919062001d05565b90508082111562000ac6578091505b825b8281101562000bcf57600b54604051634a4ca36960e01b8152600481018390526001600160a01b03909116906305ba0cf1908290634a4ca36990602401602060405180830381865afa15801562000b23573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b49919062001d1f565b6000848152601060205260409081902054905160e084901b6001600160e01b03191681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801562000ba057600080fd5b505af115801562000bb5573d6000803e3d6000fd5b50505050808062000bc69062001d55565b91505062000ac8565b50505050565b6002546001600160a01b0316331462000c445760405162461bcd60e51b815260206004820152602a60248201527f43616c6c6572206973206e6f742052657761726473446973747269627574696f6044820152691b8818dbdb9d1c9858dd60b21b6064820152608401620007bd565b600062000c506200163b565b600a5562000c5d6200124f565b6009556001600160a01b0381161562000ca75762000c7b8162000635565b6001600160a01b038216600090815260126020908152604080832093909355600a546011909152919020555b600654421062000cca5760085462000cc190839062001864565b60075562000d14565b60065460009062000cdc904262001841565b9050600062000cf7600754836200185690919063ffffffff16565b60085490915062000d0e90620006a9868462001872565b60075550505b600480546040516370a0823160e01b815230928101929092526000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801562000d63573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000d89919062001d05565b905062000da2600854826200186490919063ffffffff16565b600754111562000df55760405162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f206869676800000000000000006044820152606401620007bd565b42600981905560085462000e0a919062001872565b6006556040518381527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a1505050565b60026003540362000e6a5760405162461bcd60e51b8152600401620007bd9062001cce565b60026003553362000e7a6200163b565b600a5562000e876200124f565b6009556001600160a01b0381161562000ed15762000ea58162000635565b6001600160a01b038216600090815260126020908152604080832093909355600a546011909152919020555b33600090815260126020526040902054801562000f49573360008181526012602052604081205560045462000f13916001600160a01b039091169083620018f4565b60405181815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a25b50506001600355565b62000f5c62001880565b600c54600d5462000f6d9162001872565b42101562000f8f5760405162461bcd60e51b8152600401620007bd9062001d71565b600c5460408051918252602082018390527fe7099ed5aec5fe57f5f4250a1ffd9a47e245c9eb28f596a832e18fffcb3c3498910160405180910390a1600c55565b600c54600d5462000fe19162001872565b421015620010035760405162461bcd60e51b8152600401620007bd9062001d71565b336000908152600f60209081526040808320858452909152902054811115620010635760405162461bcd60e51b81526020600482015260116024820152700a4cadadeecd2dcce40e8dede40daeac6d607b1b6044820152606401620007bd565b336000908152600e60205260409020546200107f908262001841565b336000908152600e6020908152604080832093909355600f815282822085835290522054620010af908262001841565b336000908152600f60209081526040808320868452825280832093909355601090522054620010df908262001841565b6000928352601060205260409092209190915550565b6001546001600160a01b031633146200116f5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401620007bd565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b620011eb62001880565b600b5460405163f2fde38b60e01b81526001600160a01b0383811660048301529091169063f2fde38b90602401600060405180830381600087803b1580156200123357600080fd5b505af115801562001248573d6000803e3d6000fd5b5050505050565b600062000793426006546200195e565b6200126962001880565b6005546001600160a01b0390811690831603620012d35760405162461bcd60e51b815260206004820152602160248201527f43616e6e6f7420776974686472617720746865207374616b696e6720746f6b656044820152603760f91b6064820152608401620007bd565b600054620012ef906001600160a01b03848116911683620018f4565b604080516001600160a01b0384168152602081018390527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a15050565b6002600354036200135a5760405162461bcd60e51b8152600401620007bd9062001cce565b6002600355336200136a6200163b565b600a55620013776200124f565b6009556001600160a01b03811615620013c157620013958162000635565b6001600160a01b038216600090815260126020908152604080832093909355600a546011909152919020555b60008211620014045760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b6044820152606401620007bd565b60135462001413908362001872565b6013553360009081526014602052604090205462001432908362001872565b336000908152601460209081526040808320939093556015905220546001600160a01b03166200151357600554604051309133916001600160a01b03909116907f0000000000000000000000000000000000000000000000000000000000000000906200149f9062001c1b565b6001600160a01b039485168152928416602084015290831660408301529091166060820152608001604051809103906000f080158015620014e4573d6000803e3d6000fd5b5033600090815260156020526040902080546001600160a01b0319166001600160a01b03929092169190911790555b336000818152601560205260409020546005546001600160a01b0391821692620015439290911690838662001976565b60405183815233907f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d9060200160405180910390a25050600160035550565b6200158c62001880565b6006544211620016055760405162461bcd60e51b815260206004820152603e60248201527f5265776172647320706572696f64206d75737420626520656e64206265666f7260448201527f65206368616e67696e672074686520726577617264734475726174696f6e00006064820152608401620007bd565b60088190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d39060200162000711565b60006013546000036200164f5750600a5490565b6200079362001686601354620006a9670de0b6b3a76400006200167f6007546200167f600954620006826200124f565b9062001856565b600a549062001872565b33600090815260146020908152604080832054600e90925290912054620016b990839062001872565b1115620016ff5760405162461bcd60e51b8152602060048201526013602482015272082d8d8dec6c2e8d2dcce40e8dede40daeac6d606b1b6044820152606401620007bd565b336000908152600e60205260409020546200171b908262001872565b336000908152600e6020908152604080832093909355600f8152828220858352905220546200174b908262001872565b336000908152600f60209081526040808320868452825280832093909355601090522054620010df908262001872565b336000908152600e6020908152604080832054601490925290912054620017a8916200034a919062001841565b620017b262000e45565b565b620017be62001880565b600c54600d54620017cf9162001872565b421015620017f15760405162461bcd60e51b8152600401620007bd9062001d71565b7f907fece23ce39fbcbceb71e515043fe29408353fbb393b25b35eb8a70a4bad0b42600c544262001823919062001d9d565b6040805192835260208301919091520160405180910390a142600d55565b60006200184f828462001db3565b9392505050565b60006200184f828462001dc9565b60006200184f828462001deb565b60006200184f828462001d9d565b6000546001600160a01b03163314620017b25760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401620007bd565b6040516001600160a01b0383166024820152604481018290526200195990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152620019b0565b505050565b60008183106200196f57816200184f565b5090919050565b6040516001600160a01b038085166024830152831660448201526064810182905262000bcf9085906323b872dd60e01b9060840162001921565b600062001a07826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662001a899092919063ffffffff16565b80519091501562001959578080602001905181019062001a28919062001e0e565b620019595760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620007bd565b606062001a9a848460008562001aa2565b949350505050565b60608247101562001b055760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620007bd565b6001600160a01b0385163b62001b5e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620007bd565b600080866001600160a01b0316858760405162001b7c919062001e58565b60006040518083038185875af1925050503d806000811462001bbb576040519150601f19603f3d011682016040523d82523d6000602084013e62001bc0565b606091505b509150915062001bd282828662001bdd565b979650505050505050565b6060831562001bee5750816200184f565b82511562001bff5782518084602001fd5b8160405162461bcd60e51b8152600401620007bd919062001e76565b610f488062001eac83390190565b6001600160a01b038116811462001c3f57600080fd5b50565b60006020828403121562001c5557600080fd5b81356200184f8162001c29565b60006020828403121562001c7557600080fd5b5035919050565b6000806040838503121562001c9057600080fd5b50508035926020909101359150565b6000806040838503121562001cb357600080fd5b823562001cc08162001c29565b946020939093013593505050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006020828403121562001d1857600080fd5b5051919050565b60006020828403121562001d3257600080fd5b81516200184f8162001c29565b634e487b7160e01b600052601160045260246000fd5b60006001820162001d6a5762001d6a62001d3f565b5060010190565b60208082526012908201527115d95a59da1d1cc8185c99481b1bd8dad95960721b604082015260600190565b80820180821115620006b757620006b762001d3f565b81810381811115620006b757620006b762001d3f565b600081600019048311821515161562001de65762001de662001d3f565b500290565b60008262001e0957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121562001e2157600080fd5b815180151581146200184f57600080fd5b60005b8381101562001e4f57818101518382015260200162001e35565b50506000910152565b6000825162001e6c81846020870162001e32565b9190910192915050565b602081526000825180602084015262001e9781604085016020870162001e32565b601f01601f1916919091016040019291505056fe61010060405234801561001157600080fd5b50604051610f48380380610f48833981016040819052610030916100c1565b6001600160a01b0384811660805283811660a05282811660c081905290821660e0526040516317066a5760e21b8152306004820152635c19a95c90602401600060405180830381600087803b15801561008857600080fd5b505af115801561009c573d6000803e3d6000fd5b5050505050505050610120565b6001600160a01b03811681146100be57600080fd5b50565b600080600080608085870312156100d757600080fd5b84516100e2816100a9565b60208601519094506100f3816100a9565b6040860151909350610104816100a9565b6060860151909250610115816100a9565b939692955090935050565b60805160a05160c05160e051610db961018f600039600081816092015281816102030152610439015260008181610124015281816102d201526103af01526000818160d50152818161019e0152818161027601526103e5015260008181610171015261033c0152610db96000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b03401231161005b578063b03401231461011f578063ce6a088014610146578063da95691a14610159578063f77c47911461016c57600080fd5b80633310c7df1461008d5780634f8632ba146100d057806356781388146100f75780635c19a95c1461010c575b600080fd5b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b61010a61010536600461075b565b610193565b005b61010a61011a3660046107ad565b61026b565b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b61010a6101543660046107c8565b610331565b61010a610167366004610ab7565b6103da565b6100b47f000000000000000000000000000000000000000000000000000000000000000081565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146101e45760405162461bcd60e51b81526004016101db90610b89565b60405180910390fd5b604051630acf027160e31b81526004810183905260ff821660248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690635678138890604401600060405180830381600087803b15801561024f57600080fd5b505af1158015610263573d6000803e3d6000fd5b505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146102b35760405162461bcd60e51b81526004016101db90610b89565b6040516317066a5760e21b81526001600160a01b0382811660048301527f00000000000000000000000000000000000000000000000000000000000000001690635c19a95c90602401600060405180830381600087803b15801561031657600080fd5b505af115801561032a573d6000803e3d6000fd5b5050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103a25760405162461bcd60e51b81526020600482015260166024820152752b37ba32b91d1037b7363c9031b7b73a3937b63632b960511b60448201526064016101db565b6103d66001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683836104af565b5050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104225760405162461bcd60e51b81526004016101db90610b89565b604051636d4ab48d60e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063da95691a906104769088908890889088908890600401610c93565b600060405180830381600087803b15801561049057600080fd5b505af11580156104a4573d6000803e3d6000fd5b505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610501908490610506565b505050565b600061055b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166105d89092919063ffffffff16565b80519091501561050157808060200190518101906105799190610d32565b6105015760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101db565b60606105e784846000856105f1565b90505b9392505050565b6060824710156106525760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101db565b6001600160a01b0385163b6106a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101db565b600080866001600160a01b031685876040516106c59190610d54565b60006040518083038185875af1925050503d8060008114610702576040519150601f19603f3d011682016040523d82523d6000602084013e610707565b606091505b5091509150610717828286610722565b979650505050505050565b606083156107315750816105ea565b8251156107415782518084602001fd5b8160405162461bcd60e51b81526004016101db9190610d70565b6000806040838503121561076e57600080fd5b82359150602083013560ff8116811461078657600080fd5b809150509250929050565b80356001600160a01b03811681146107a857600080fd5b919050565b6000602082840312156107bf57600080fd5b6105ea82610791565b600080604083850312156107db57600080fd5b6107e483610791565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610831576108316107f2565b604052919050565b600067ffffffffffffffff821115610853576108536107f2565b5060051b60200190565b600082601f83011261086e57600080fd5b8135602061088361087e83610839565b610808565b82815260059290921b840181019181810190868411156108a257600080fd5b8286015b848110156108c4576108b781610791565b83529183019183016108a6565b509695505050505050565b600082601f8301126108e057600080fd5b813560206108f061087e83610839565b82815260059290921b8401810191818101908684111561090f57600080fd5b8286015b848110156108c45780358352918301918301610913565b600067ffffffffffffffff831115610944576109446107f2565b610957601f8401601f1916602001610808565b905082815283838301111561096b57600080fd5b828260208301376000602084830101529392505050565b600082601f83011261099357600080fd5b6105ea8383356020850161092a565b600082601f8301126109b357600080fd5b813560206109c361087e83610839565b82815260059290921b840181019181810190868411156109e257600080fd5b8286015b848110156108c457803567ffffffffffffffff811115610a065760008081fd5b610a148986838b0101610982565b8452509183019183016109e6565b600082601f830112610a3357600080fd5b81356020610a4361087e83610839565b82815260059290921b84018101918181019086841115610a6257600080fd5b8286015b848110156108c457803567ffffffffffffffff811115610a865760008081fd5b8701603f81018913610a985760008081fd5b610aa989868301356040840161092a565b845250918301918301610a66565b600080600080600060a08688031215610acf57600080fd5b853567ffffffffffffffff80821115610ae757600080fd5b610af389838a0161085d565b96506020880135915080821115610b0957600080fd5b610b1589838a016108cf565b95506040880135915080821115610b2b57600080fd5b610b3789838a016109a2565b94506060880135915080821115610b4d57600080fd5b610b5989838a01610a22565b93506080880135915080821115610b6f57600080fd5b50610b7c88828901610982565b9150509295509295909350565b60208082526010908201526f2b37ba32b91d1037b7363c903ab9b2b960811b604082015260600190565b600081518084526020808501945080840160005b83811015610be357815187529582019590820190600101610bc7565b509495945050505050565b60005b83811015610c09578181015183820152602001610bf1565b50506000910152565b60008151808452610c2a816020860160208601610bee565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b85811015610c86578284038952610c74848351610c12565b98850198935090840190600101610c5c565b5091979650505050505050565b60a0808252865190820181905260009060209060c0840190828a01845b82811015610cd55781516001600160a01b031684529284019290840190600101610cb0565b50505083810382850152610ce98189610bb3565b9150508281036040840152610cfe8187610c3e565b90508281036060840152610d128186610c3e565b90508281036080840152610d268185610c12565b98975050505050505050565b600060208284031215610d4457600080fd5b815180151581146105ea57600080fd5b60008251610d66818460208701610bee565b9190910192915050565b6020815260006105ea6020830184610c1256fea26469706673582212200d001ea62fc2d74aa7e353b598da7f2182b8f16b9fb3bbef0b93992bdc87039764736f6c63430008100033a2646970667358221220e381465000c0aa4082c183b81ad3e174aec1970e73d275a09dfa3c2acc0e283964736f6c634300081000330000000000000000000000000ce41dbcea62580ae2c894a7d93e97da0c3dac3a0000000000000000000000000ce41dbcea62580ae2c894a7d93e97da0c3dac3a00000000000000000000000000be915b9dcf56a3cbe739d9b9c202ca692409ec00000000000000000000000000be915b9dcf56a3cbe739d9b9c202ca692409ec000000000000000000000000a7581d8e26007f4d2374507736327f5b46dd6ba80000000000000000000000009ee3600543eccc85020d6bc77eb553d1747a65d20000000000000000000000000000000000000000000000000000000000069780

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000ce41dbcea62580ae2c894a7d93e97da0c3dac3a0000000000000000000000000ce41dbcea62580ae2c894a7d93e97da0c3dac3a00000000000000000000000000be915b9dcf56a3cbe739d9b9c202ca692409ec00000000000000000000000000be915b9dcf56a3cbe739d9b9c202ca692409ec000000000000000000000000a7581d8e26007f4d2374507736327f5b46dd6ba80000000000000000000000009ee3600543eccc85020d6bc77eb553d1747a65d20000000000000000000000000000000000000000000000000000000000069780

-----Decoded View---------------
Arg [0] : _owner (address): 0x0ce41dbcea62580ae2c894a7d93e97da0c3dac3a
Arg [1] : _rewardsDistribution (address): 0x0ce41dbcea62580ae2c894a7d93e97da0c3dac3a
Arg [2] : _rewardsToken (address): 0x00be915b9dcf56a3cbe739d9b9c202ca692409ec
Arg [3] : _stakingToken (address): 0x00be915b9dcf56a3cbe739d9b9c202ca692409ec
Arg [4] : _romulusDelegate (address): 0xa7581d8e26007f4d2374507736327f5b46dd6ba8
Arg [5] : _poolManager (address): 0x9ee3600543eccc85020d6bc77eb553d1747a65d2
Arg [6] : _lockDuration (uint256): 432000

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000ce41dbcea62580ae2c894a7d93e97da0c3dac3a
Arg [1] : 0000000000000000000000000ce41dbcea62580ae2c894a7d93e97da0c3dac3a
Arg [2] : 00000000000000000000000000be915b9dcf56a3cbe739d9b9c202ca692409ec
Arg [3] : 00000000000000000000000000be915b9dcf56a3cbe739d9b9c202ca692409ec
Arg [4] : 000000000000000000000000a7581d8e26007f4d2374507736327f5b46dd6ba8
Arg [5] : 0000000000000000000000009ee3600543eccc85020d6bc77eb553d1747a65d2
Arg [6] : 0000000000000000000000000000000000000000000000000000000000069780


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.