ETH Price: $3,153.34 (+0.44%)
Gas: 0.06 GWei

Contract

0xec9453d72613c2c9d6a639784F9dB4A230cc0F5A
Transaction Hash
Method
Block
From
To
Value
Get Reward66868402024-07-12 9:34:5631 hrs ago1720776896IN
0xec9453d7...230cc0F5A
0 ETH0.000016470.0582
Get Reward66602322024-07-11 18:47:5846 hrs ago1720723678IN
0xec9453d7...230cc0F5A
0 ETH0.000048260.067
Get Reward66596262024-07-11 18:27:4646 hrs ago1720722466IN
0xec9453d7...230cc0F5A
0 ETH0.000047550.067
Get Reward66497482024-07-11 12:58:302 days ago1720702710IN
0xec9453d7...230cc0F5A
0 ETH0.000017860.0582
Get Reward66464742024-07-11 11:09:222 days ago1720696162IN
0xec9453d7...230cc0F5A
0 ETH0.000022330.063
Get Reward66429252024-07-11 9:11:042 days ago1720689064IN
0xec9453d7...230cc0F5A
0 ETH0.000014360.061
Get Reward66383022024-07-11 6:36:582 days ago1720679818IN
0xec9453d7...230cc0F5A
0 ETH0.000014670.063
Get Reward66375642024-07-11 6:12:222 days ago1720678342IN
0xec9453d7...230cc0F5A
0 ETH0.000003920.061
Get Reward66375612024-07-11 6:12:162 days ago1720678336IN
0xec9453d7...230cc0F5A
0 ETH0.000014360.061
Get Reward66327232024-07-11 3:30:582 days ago1720668658IN
0xec9453d7...230cc0F5A
0 ETH0.000012770.0582
Get Reward66324322024-07-11 3:21:162 days ago1720668076IN
0xec9453d7...230cc0F5A
0 ETH0.000017010.0582
Get Reward66323712024-07-11 3:19:142 days ago1720667954IN
0xec9453d7...230cc0F5A
0 ETH0.000015250.063
Get Reward66299442024-07-11 1:58:202 days ago1720663100IN
0xec9453d7...230cc0F5A
0 ETH0.000014770.061
Get Reward66281442024-07-11 0:58:202 days ago1720659500IN
0xec9453d7...230cc0F5A
0 ETH0.000032020.061
Get Reward66272982024-07-11 0:30:082 days ago1720657808IN
0xec9453d7...230cc0F5A
0 ETH0.000017260.061
Get Reward66265332024-07-11 0:04:382 days ago1720656278IN
0xec9453d7...230cc0F5A
0 ETH0.000016030.062
Get Reward66233472024-07-10 22:18:262 days ago1720649906IN
0xec9453d7...230cc0F5A
0 ETH0.000033050.062
Get Reward66098332024-07-10 14:47:583 days ago1720622878IN
0xec9453d7...230cc0F5A
0 ETH0.000011550.05931178
Get Reward66055112024-07-10 12:23:543 days ago1720614234IN
0xec9453d7...230cc0F5A
0 ETH0.000013510.0582
Notify Reward Am...65734172024-07-09 18:34:003 days ago1720550040IN
0xec9453d7...230cc0F5A
0 ETH0.000008520.064
Get Reward65003882024-07-08 1:59:345 days ago1720403974IN
0xec9453d7...230cc0F5A
0 ETH0.000041740.0582
Get Reward64614632024-07-07 4:21:596 days ago1720326119IN
0xec9453d7...230cc0F5A
0 ETH0.000050940.0582
Get Reward64437242024-07-06 18:29:016 days ago1720290541IN
0xec9453d7...230cc0F5A
0 ETH0.000039850.0588
Get Reward64172262024-07-06 3:45:397 days ago1720237539IN
0xec9453d7...230cc0F5A
0 ETH0.000021550.061
Get Reward63485722024-07-04 13:37:099 days ago1720100229IN
0xec9453d7...230cc0F5A
0 ETH0.000032770.06668529
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To Value
67430692024-07-13 16:49:147 mins ago1720889354
0xec9453d7...230cc0F5A
0 ETH
67430692024-07-13 16:49:147 mins ago1720889354
0xec9453d7...230cc0F5A
0 ETH
67348342024-07-13 12:14:444 hrs ago1720872884
0xec9453d7...230cc0F5A
0 ETH
67348342024-07-13 12:14:444 hrs ago1720872884
0xec9453d7...230cc0F5A
0 ETH
67348342024-07-13 12:14:444 hrs ago1720872884
0xec9453d7...230cc0F5A
0 ETH
67348342024-07-13 12:14:444 hrs ago1720872884
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
67323142024-07-13 10:50:446 hrs ago1720867844
0xec9453d7...230cc0F5A
0 ETH
View All Internal Transactions
Loading...
Loading

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

Contract Name:
BribeV2

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 19 : BribeV2.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import "../interfaces/IMinter.sol";
import "../interfaces/IVoter.sol";
import "./VotingEscrow/interfaces/IVotingEscrowV2.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../Constants.sol";
import "./IBribe.sol";

contract BribeV2 is IBribe, ReentrancyGuard {
    using SafeERC20 for IERC20;

    uint256 public WEEK = Constants.EPOCH; // rewards are released over 7 days
    uint256 public firstBribeTimestamp;

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

    struct Reward {
        uint256 periodFinish;
        uint256 rewardsPerEpoch;
        uint256 lastUpdateTime;
    }

    mapping(address => mapping(uint256 => Reward)) public rewardData; // token -> startTimestamp -> Reward
    mapping(address => bool) public isRewardToken;
    address[] public rewardTokens;
    address public voter;
    address public immutable bribeFactory;
    address public minter;
    address public immutable ve;
    address public owner;

    string public TYPE;

    // owner -> reward token -> lastTime
    mapping(uint256 => mapping(address => uint256)) public tokenTimestamp;

    //uint256 private _totalSupply;
    mapping(uint256 => uint256) private _totalSupply;
    mapping(address => mapping(uint256 => uint256)) private _balances; //owner -> timestamp -> amount

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

    constructor(address _owner, address _voter, address _bribeFactory, string memory _type) {
        require(_bribeFactory != address(0) && _voter != address(0) && _owner != address(0));
        voter = _voter;
        bribeFactory = _bribeFactory;
        firstBribeTimestamp = 0;
        ve = IVoter(_voter).ve();
        minter = IVoter(_voter).minter();
        require(minter != address(0));
        owner = _owner;
        TYPE = _type;
    }

    /// @notice get the current epoch
    function getEpochStart() public view returns (uint256) {
        return IMinter(minter).active_period();
    }

    /// @notice get next epoch (where bribes are saved)
    function getNextEpochStart() public view returns (uint256) {
        return getEpochStart() + WEEK;
    }

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

    /// @notice get the length of the reward tokens
    function rewardsListLength() external view returns (uint256) {
        return rewardTokens.length;
    }

    /// @notice get the last totalSupply (total votes for a pool)
    function totalSupply() external view returns (uint256) {
        uint256 _currentEpochStart = IMinter(minter).active_period(); // claim until current epoch
        return _totalSupply[_currentEpochStart];
    }

    /// @notice get a totalSupply given a timestamp
    function totalSupplyAt(uint256 _timestamp) external view returns (uint256) {
        return _totalSupply[_timestamp];
    }

    /// @notice read the balanceOf the tokenId at a given timestamp
    function balanceOfAt(uint256 tokenId, uint256 _timestamp) public view returns (uint256) {
        address _owner = IVotingEscrowV2(ve).ownerOf(tokenId);
        return _balances[_owner][_timestamp];
    }

    /// @notice get last deposit available given a tokenID
    function balanceOf(uint256 tokenId) public view returns (uint256) {
        uint256 _timestamp = getNextEpochStart();
        address _owner = IVotingEscrowV2(ve).ownerOf(tokenId);
        return _balances[_owner][_timestamp];
    }

    /// @notice get the balance of an owner in the current epoch
    function balanceOfOwner(address _owner) public view returns (uint256) {
        uint256 _timestamp = getNextEpochStart();
        return _balances[_owner][_timestamp];
    }

    /// @notice get the balance of an owner given a timestamp
    function balanceOfOwnerAt(address _owner, uint256 _timestamp) public view returns (uint256) {
        return _balances[_owner][_timestamp];
    }

    /// @notice Read earned amount given a tokenID and _rewardToken
    function earned(uint256 tokenId, address _rewardToken) public view returns (uint256) {
        uint256 k = 0;
        uint256 reward = 0;
        uint256 _endTimestamp = IMinter(minter).active_period(); // claim until current epoch
        uint256 _tokenLastTime = tokenTimestamp[tokenId][_rewardToken];

        if (_endTimestamp == _tokenLastTime) {
            return 0;
        }

        // if user first time then set it to first bribe - week to avoid any timestamp problem
        if (_tokenLastTime < firstBribeTimestamp) {
            (, uint48 ts) = IVotingEscrowV2(ve).getFirstEscrowPoint(tokenId);
            uint256 start = (ts / WEEK) * WEEK;
            _tokenLastTime = start > firstBribeTimestamp ? start : firstBribeTimestamp - WEEK;
        }

        for (k; k < 50; k++) {
            if (_tokenLastTime >= _endTimestamp) {
                // if we pass the current epoch, exit
                break;
            }
            reward += _earnedTokenId(tokenId, _rewardToken, uint48(_tokenLastTime));
            _tokenLastTime += WEEK;
        }
        return reward;
    }

    /// @notice Read earned amount given address and reward token, returns the rewards and the last user timestamp (used in case user do not claim since 50+epochs)
    function earnedWithTimestampTokenId(uint256 _tokenId, address _rewardToken) private view returns (uint256, uint256) {
        uint256 k = 0;
        uint256 reward = 0;
        uint256 _endTimestamp = IMinter(minter).active_period(); // claim until current epoch
        uint256 _tokenLastTime = tokenTimestamp[_tokenId][_rewardToken];


        // if user first time then set it to first bribe - week to avoid any timestamp problem
        if (_tokenLastTime < firstBribeTimestamp) {
            (, uint48 ts) = IVotingEscrowV2(ve).getFirstEscrowPoint(_tokenId);
            uint256 start = (ts / WEEK) * WEEK;
            _tokenLastTime = start > firstBribeTimestamp ? start : firstBribeTimestamp - WEEK;
        }

        for (k; k < 50; k++) {
            if (_tokenLastTime >= _endTimestamp) {
                // if we pass the current epoch, exit
                break;
            }
            reward += _earnedTokenId(_tokenId, _rewardToken, uint48(_tokenLastTime));
            _tokenLastTime += WEEK;
        }
        return (reward, _tokenLastTime);

    }

    /// @notice get the earned rewards
    function earnedOwner(address _owner, address _rewardToken, uint256 _timestamp) public view returns (uint256) {
        uint256 _balance = balanceOfOwnerAt(_owner, _timestamp);
        if (_balance == 0) {
            return 0;
        } else {
            uint256 _rewardPerToken = rewardPerToken(_rewardToken, _timestamp);
            uint256 _rewards = (_rewardPerToken * _balance) / 1e32;
            return _rewards;
        }
    }

    /// @notice get the earned rewards rounded to closest previous active period
    function earnedTokenId(uint256 _tokenId, address _rewardToken, uint48 _timestamp) external view returns (uint256) {
        uint48 onClockTimestamp = uint48((_timestamp / WEEK) * WEEK);
        return _earnedTokenId(_tokenId, _rewardToken, onClockTimestamp);
    }

    /// @notice get the earned rewards
    function _earnedTokenId(uint256 _tokenId, address _rewardToken, uint48 _weightTimestamp) internal view returns (uint256) {
        address _delegatee = IVotingEscrowV2(ve).delegates(_tokenId, _weightTimestamp);
        if (_delegatee == address(0)) return 0;
        uint256 _power = IVotingEscrowV2(ve).balanceOfNFTAt(_tokenId, _weightTimestamp);
        if (_power == 0) return 0;
        
        uint256 _balance = balanceOfOwnerAt(_delegatee, _weightTimestamp);
        if (_balance == 0) return 0;

        uint256 _delegateePower = IVotingEscrowV2(ve).getPastVotes(_delegatee, _weightTimestamp);
        if (_delegateePower == 0) return 0;

        uint256 _weight = (_power * 1e18) / _delegateePower;
        
        if (_balance == 0 || _weight == 0) {
            return 0;
        } else {
            uint256 _rewardPerToken = rewardPerToken(_rewardToken, _weightTimestamp);
            uint256 _rewards = ((_rewardPerToken * _balance * _weight) / 1e18) / 1e32;
            return _rewards;
        }
    }

    /// @notice get the rewards for token
    function rewardPerToken(address _rewardsToken, uint256 _timestamp) public view returns (uint256) {
        if (_totalSupply[_timestamp] == 0) {
            return rewardData[_rewardsToken][_timestamp].rewardsPerEpoch;
        }
        return (rewardData[_rewardsToken][_timestamp].rewardsPerEpoch * 1e32) / _totalSupply[_timestamp];
    }

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

    /// @notice User votes deposit
    /// @dev    called on voter.vote() or voter.poke()
    ///         we save into owner "address" and not "tokenID".
    ///         Owner must reset before transferring token
    function deposit(uint256 amount, address user) external nonReentrant {
        require(amount > 0, "Cannot stake 0");
        require(msg.sender == voter);
        uint256 _startTimestamp = IMinter(minter).active_period();
        uint256 _oldSupply = _totalSupply[_startTimestamp];
        uint256 _lastBalance = _balances[user][_startTimestamp];

        _totalSupply[_startTimestamp] = _oldSupply + amount;
        _balances[user][_startTimestamp] = _lastBalance + amount;

        emit Staked(user, amount);
    }

    /// @notice User votes withdrawal
    /// @dev    called on voter.reset()
    function withdraw(uint256 amount, address user) external nonReentrant {
        require(amount > 0, "Cannot withdraw 0");
        require(msg.sender == voter);
        uint256 _startTimestamp = IMinter(minter).active_period();

        // incase of bribe contract reset in gauge proxy
        if (amount <= _balances[user][_startTimestamp]) {
            uint256 _oldSupply = _totalSupply[_startTimestamp];
            uint256 _oldBalance = _balances[user][_startTimestamp];
            _totalSupply[_startTimestamp] = _oldSupply - amount;
            _balances[user][_startTimestamp] = _oldBalance - amount;
            emit Withdrawn(user, amount);
        }
    }

    /// @notice Claim the TOKENID rewards
    function _getReward(uint256 tokenId, address _owner, address[] memory tokens) internal {
        uint256 _tokenLastTime;
        uint256 reward = 0;

        for (uint256 i = 0; i < tokens.length; i++) {
            address _rewardToken = tokens[i];
            (reward, _tokenLastTime) = earnedWithTimestampTokenId(tokenId, _rewardToken);
            if (reward > 0) {
                IERC20(_rewardToken).safeTransfer(_owner, reward);
                emit RewardPaid(_owner, _rewardToken, reward);
            }
            tokenTimestamp[tokenId][_rewardToken] = _tokenLastTime;
        }
    }

    // @notice Claim the TOKENID rewards
    function getReward(uint256 tokenId, address[] memory tokens) external nonReentrant {
        require(IVotingEscrowV2(ve).isApprovedOrOwner(msg.sender, tokenId));
        address _owner = IVotingEscrowV2(ve).ownerOf(tokenId);
        return _getReward(tokenId, _owner, tokens);
    }

    /// @notice Claim the rewards given msg.sender
    function getReward(address[] memory tokens) external nonReentrant {
        address _owner = msg.sender;
        uint256 balance = IVotingEscrowV2(ve).balanceOf(_owner);
        for (uint256 i = 0; i < balance; i++) {
            uint256 tokenId = IVotingEscrowV2(ve).tokenOfOwnerByIndex(_owner, i);
            _getReward(tokenId, _owner, tokens);
        }
    }

    /// @notice Claim rewards from voter
    function getRewardForOwner(uint256 tokenId, address[] memory tokens) public nonReentrant {
        require(msg.sender == voter);
        address _owner = IVotingEscrowV2(ve).ownerOf(tokenId);
        return _getReward(tokenId, _owner, tokens);
    }

    /// @notice Claim rewards from voter
    function getRewardForAddress(address _owner, address[] memory tokens) public nonReentrant {
        require(msg.sender == voter);
        uint256 balance = IVotingEscrowV2(ve).balanceOf(_owner);
        for (uint256 i = 0; i < balance; i++) {
            uint256 tokenId = IVotingEscrowV2(ve).tokenOfOwnerByIndex(_owner, i);
            _getReward(tokenId, _owner, tokens);
        }
    }

    /// @notice Notify a bribe amount
    /// @dev    Rewards are saved into NEXT EPOCH mapping.
    function notifyRewardAmount(address _rewardsToken, uint256 reward) external nonReentrant {
        require(isRewardToken[_rewardsToken], "reward token not verified");
        /// @dev Account for tax on transfer tokens
        uint256 balanceBefore = IERC20(_rewardsToken).balanceOf(address(this));
        IERC20(_rewardsToken).safeTransferFrom(msg.sender, address(this), reward);
        uint256 balanceAfter = IERC20(_rewardsToken).balanceOf(address(this));
        uint256 effectiveTransfer = balanceAfter - balanceBefore;

        uint256 _startTimestamp = IMinter(minter).active_period(); //period points to the current thursday. Bribes are distributed from next epoch (thursday)
        if (firstBribeTimestamp == 0) {
            firstBribeTimestamp = _startTimestamp;
        }

        uint256 _lastReward = rewardData[_rewardsToken][_startTimestamp].rewardsPerEpoch;

        rewardData[_rewardsToken][_startTimestamp].rewardsPerEpoch = _lastReward + effectiveTransfer;
        rewardData[_rewardsToken][_startTimestamp].lastUpdateTime = block.timestamp;
        rewardData[_rewardsToken][_startTimestamp].periodFinish = _startTimestamp;

        emit RewardAdded(_rewardsToken, effectiveTransfer, _startTimestamp);
    }

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

    /// @notice add rewards tokens
    function addRewardTokens(address[] memory _rewardsToken) public onlyAllowed {
        uint256 i = 0;
        for (i; i < _rewardsToken.length; i++) {
            _addRewardToken(_rewardsToken[i]);
        }
    }

    /// @notice add a single reward token
    function addRewardToken(address _rewardsToken) public onlyAllowed {
        _addRewardToken(_rewardsToken);
    }

    function _addRewardToken(address _rewardsToken) internal {
        if (!isRewardToken[_rewardsToken]) {
            isRewardToken[_rewardsToken] = true;
            rewardTokens.push(_rewardsToken);
        }
    }

    /// @notice Recover some ERC20 from the contract and updated given bribe
    function recoverERC20AndUpdateData(address tokenAddress, uint256 tokenAmount) external onlyAllowed {
        require(tokenAmount <= IERC20(tokenAddress).balanceOf(address(this)));

        uint256 _startTimestamp = IMinter(minter).active_period();
        uint256 _lastReward = rewardData[tokenAddress][_startTimestamp].rewardsPerEpoch;
        rewardData[tokenAddress][_startTimestamp].rewardsPerEpoch = _lastReward - tokenAmount;
        rewardData[tokenAddress][_startTimestamp].lastUpdateTime = block.timestamp;

        IERC20(tokenAddress).safeTransfer(owner, tokenAmount);
        emit Recovered(tokenAddress, tokenAmount);
    }

    /// @notice Recover some ERC20 from the contract.
    /// @dev    Be careful --> if called then getReward() at last epoch will fail because some reward are missing!
    ///         Think about calling recoverERC20AndUpdateData()
    function emergencyRecoverERC20(address tokenAddress, uint256 tokenAmount) external onlyAllowed {
        require(tokenAmount <= IERC20(tokenAddress).balanceOf(address(this)));
        IERC20(tokenAddress).safeTransfer(owner, tokenAmount);
        emit Recovered(tokenAddress, tokenAmount);
    }

    /// @notice Set a new voter
    function setVoter(address _Voter) external onlyAllowed {
        require(_Voter != address(0));
        voter = _Voter;
    }

    /// @notice Set a new minter
    function setMinter(address _minter) external onlyAllowed {
        require(_minter != address(0));
        minter = _minter;
    }

    /// @notice Set a new Owner
    event SetOwner(address indexed _owner);

    function setOwner(address _owner) external onlyAllowed {
        require(_owner != address(0));
        owner = _owner;
        emit SetOwner(_owner);
    }

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

    modifier onlyAllowed() {
        require((msg.sender == owner || msg.sender == bribeFactory), "permission is denied!");
        _;
    }

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

    event RewardAdded(address indexed rewardToken, uint256 reward, uint256 startTimestamp);
    event Staked(address indexed user, uint256 amount);
    event Withdrawn(address indexed user, uint256 amount);
    event RewardPaid(address indexed user, address indexed rewardsToken, uint256 reward);
    event Recovered(address indexed token, uint256 amount);
}

File 2 of 19 : IVotes.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (governance/utils/IVotes.sol)
pragma solidity ^0.8.0;

/**
 * @dev Common interface for {ERC20Votes}, {ERC721Votes}, and other {Votes}-enabled contracts.
 *
 * _Available since v4.5._
 */
interface IVotes {
    /**
     * @dev Emitted when an account changes their delegate.
     */
    event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);

    /**
     * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
     */
    event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);

    /**
     * @dev Returns the current amount of votes that `account` has.
     */
    function getVotes(address account) external view returns (uint256);

    /**
     * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is
     * configured to use block numbers, this will return the value at the end of the corresponding block.
     */
    function getPastVotes(address account, uint256 timepoint) external view returns (uint256);

    /**
     * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is
     * configured to use block numbers, this will return the value at the end of the corresponding block.
     *
     * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
     * Votes that have not been delegated are still part of total supply, even though they would not participate in a
     * vote.
     */
    function getPastTotalSupply(uint256 timepoint) external view returns (uint256);

    /**
     * @dev Returns the delegate that `account` has chosen.
     */
    function delegates(address account) external view returns (address);

    /**
     * @dev Delegates votes from the sender to `delegatee`.
     */
    function delegate(address delegatee) external;

    /**
     * @dev Delegates votes from signer to `delegatee`.
     */
    function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external;
}

File 3 of 19 : IERC5805.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5805.sol)

pragma solidity ^0.8.0;

import "../governance/utils/IVotes.sol";
import "./IERC6372.sol";

interface IERC5805 is IERC6372, IVotes {}

File 4 of 19 : IERC6372.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC6372.sol)

pragma solidity ^0.8.0;

interface IERC6372 {
    /**
     * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
     */
    function clock() external view returns (uint48);

    /**
     * @dev Description of the clock
     */
    // solhint-disable-next-line func-name-mixedcase
    function CLOCK_MODE() external view returns (string memory);
}

File 5 of 19 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

File 6 of 19 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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 7 of 19 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 8 of 19 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/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;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 9 of 19 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 10 of 19 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 11 of 19 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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 12 of 19 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 13 of 19 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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. If 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)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 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) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 14 of 19 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

library Constants {
    uint48 constant EPOCH = 1 weeks;
}

File 15 of 19 : IMinter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IMinter {
    function update_period() external returns (uint);
    function check() external view returns(bool);
    function period() external view returns(uint);
    function active_period() external view returns(uint);
}

File 16 of 19 : IVoter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IVoter {
    function ve() external view returns (address);
    function gauges(address _pair) external view returns (address);
    function isGauge(address _gauge) external view returns (bool);
    function poolForGauge(address _gauge) external view returns (address);
    function factory() external view returns (address);
    function minter() external view returns(address);
    function isWhitelisted(address token) external view returns (bool);
    function notifyRewardAmount(uint amount) external;
    function distributeAll() external;
    function distributeFees(address[] memory _gauges) external;

    function internal_bribes(address _gauge) external view returns (address);
    function external_bribes(address _gauge) external view returns (address);

    function usedWeights(uint id) external view returns(uint);
    function lastVoted(uint id) external view returns(uint);
    function poolVote(uint id, uint _index) external view returns(address _pair);
    function votes(uint id, address _pool) external view returns(uint votes);
    function poolVoteLength(uint tokenId) external view returns(uint);
    
    function attachTokenToGauge(uint _tokenId, address account) external;
    function detachTokenFromGauge(uint _tokenId, address account) external;
}

File 17 of 19 : IBribe.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IBribe {
    function deposit(uint amount, address account) external;

    function withdraw(uint amount, address account) external;

    function getRewardForOwner(uint tokenId, address[] memory tokens) external;

    function getRewardForAddress(address _owner, address[] memory tokens) external;

    function notifyRewardAmount(address token, uint amount) external;

    function addRewardToken(address _rewardsToken) external;

    function addRewardTokens(address[] memory _rewardsToken) external;

    function setVoter(address _Voter) external;

    function setMinter(address _Voter) external;

    function setOwner(address _Voter) external;

    function emergencyRecoverERC20(address tokenAddress, uint256 tokenAmount) external;

    function recoverERC20AndUpdateData(address tokenAddress, uint256 tokenAmount) external;
}

File 18 of 19 : IVotingEscrowV2.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import {IERC5805} from "@openzeppelin/contracts/interfaces/IERC5805.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

interface IVotingEscrowV2 is IERC5805, IERC721Enumerable {
    struct LockDetails {
        uint256 amount; /// @dev amount of tokens locked
        uint256 startTime; /// @dev when locking started
        uint256 endTime; /// @dev when locking ends
        bool isPermanent; /// @dev if its a permanent lock
    }

    /// -----------------------------------------------------------------------
    /// Events
    /// -----------------------------------------------------------------------

    event SupplyUpdated(uint256 oldSupply, uint256 newSupply);
    /// @notice Lock events
    event LockCreated(uint256 indexed tokenId, address indexed to, uint256 value, uint256 unlockTime, bool isPermanent);
    event LockUpdated(uint256 indexed tokenId, uint256 value, uint256 unlockTime, bool isPermanent);
    event LockMerged(
        uint256 indexed fromTokenId,
        uint256 indexed toTokenId,
        uint256 totalValue,
        uint256 unlockTime,
        bool isPermanent
    );
    event LockSplit(uint256[] splitWeights, uint256 indexed _tokenId);
    event LockDurationExtended(uint256 indexed tokenId, uint256 newUnlockTime, bool isPermanent);
    event LockAmountIncreased(uint256 indexed tokenId, uint256 value);
    event UnlockPermanent(uint256 indexed tokenId, address indexed sender, uint256 unlockTime);
    /// @notice Delegate events
    event LockDelegateChanged(
        uint256 indexed tokenId,
        address indexed delegator,
        address fromDelegate,
        address indexed toDelegate
    );

    /// -----------------------------------------------------------------------
    /// Errors
    /// -----------------------------------------------------------------------

    error AlreadyVoted();
    error InvalidNonce();
    error InvalidDelegatee();
    error InvalidSignature();
    error InvalidSignatureS();
    error LockDurationNotInFuture();
    error LockDurationTooLong();
    error LockExpired();
    error LockNotExpired();
    error NoLockFound();
    error NotPermanentLock();
    error PermanentLock();
    error SameNFT();
    error SignatureExpired();
    error ZeroAmount();

    function supply() external view returns (uint);

    function token() external view returns (IERC20);

    function balanceOfNFT(uint256 _tokenId) external view returns (uint256);
    function balanceOfNFTAt(uint256 _tokenId, uint256 _timestamp) external view returns (uint256);

    function delegates(uint256 tokenId, uint48 timestamp) external view returns (address);

    function lockDetails(uint256 tokenId) external view returns (LockDetails calldata);

    function isApprovedOrOwner(address user, uint tokenId) external view returns (bool);

    function getPastEscrowPoint(
        uint256 _tokenId,
        uint256 _timePoint
    ) external view returns (Checkpoints.Point memory, uint48);

    function getFirstEscrowPoint(uint256 _tokenId) external view returns (Checkpoints.Point memory, uint48);

    function checkpoint() external;

    function increaseAmount(uint256 _tokenId, uint256 _value) external;

    function createLockFor(uint256 _value, uint256 _lockDuration, address _to, bool _permanent) external returns (uint256);
    function decimals() external view returns(uint8);
}

File 19 of 19 : Checkpoints.sol
// SPDX-License-Identifier: MIT
// This file was derived from OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol)

pragma solidity 0.8.13;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

/**
 * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
 * time, and later looking up past values by block number. See {Votes} as an example.
 *
 * To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new
 * checkpoint for the current transaction block using the {push} function.
 */
library Checkpoints {
    struct Trace {
        Checkpoint[] _checkpoints;
    }

    /**
     * @dev Struct to keep track of the voting power over time.
     */
    struct Point {
        /// @dev The voting power at a specific time
        /// - MUST never be negative.
        int128 bias;
        /// @dev The rate at which the voting power decreases over time.
        int128 slope;
        /// @dev The value of tokens which do not decrease over time, representing permanent voting power
        /// - MUST never be negative.
        int128 permanent;
    }

    struct Checkpoint {
        uint48 _key;
        Point _value;
    }

    /**
     * @dev A value was attempted to be inserted on a past checkpoint.
     */
    error CheckpointUnorderedInsertions();

    /**
     * @dev Pushes a (`key`, `value`) pair into a Trace so that it is stored as the checkpoint.
     *
     * Returns previous value and new value.
     *
     * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
     * library.
     */
    function push(Trace storage self, uint48 key, Point memory value) internal returns (Point memory, Point memory) {
        return _insert(self._checkpoints, key, value);
    }

    /**
     * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
     * there is none.
     */
    function lowerLookup(Trace storage self, uint48 key) internal view returns (Point memory) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
        return pos == len ? blankPoint() : _unsafeAccess(self._checkpoints, pos)._value;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     */
    function upperLookup(
        Trace storage self,
        uint48 key
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);

        exists = pos != 0;
        _value = exists ? _unsafeAccess(self._checkpoints, pos - 1)._value : blankPoint();
        _key = exists ? _unsafeAccess(self._checkpoints, pos - 1)._key : 0;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     *
     * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
     * keys).
     */
    function upperLookupRecent(
        Trace storage self,
        uint48 key
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 len = self._checkpoints.length;

        uint256 low = 0;
        uint256 high = len;

        if (len > 5) {
            uint256 mid = len - Math.sqrt(len);
            if (key < _unsafeAccess(self._checkpoints, mid)._key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);

        exists = pos != 0;
        _value = exists ? _unsafeAccess(self._checkpoints, pos - 1)._value : blankPoint();
        _key = exists ? _unsafeAccess(self._checkpoints, pos - 1)._key : 0;
    }

    /**
     * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
     */
    function latest(Trace storage self) internal view returns (Point memory) {
        uint256 pos = self._checkpoints.length;
        return pos == 0 ? blankPoint() : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
     * in the most recent checkpoint.
     */
    function latestCheckpoint(
        Trace storage self
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 pos = self._checkpoints.length;
        if (pos == 0) {
            return (false, 0, blankPoint());
        } else {
            Checkpoint memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
            return (true, ckpt._key, ckpt._value);
        }
    }

    /**
     * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
     * in the most recent checkpoint.
     */
    function firstCheckpoint(
        Trace storage self
    ) internal view returns (bool exists, uint48 _key, Point memory _value) {
        uint256 pos = self._checkpoints.length;
        if (pos == 0) {
            return (false, 0, blankPoint());
        } else {
            Checkpoint memory ckpt = _unsafeAccess(self._checkpoints, 0);
            return (true, ckpt._key, ckpt._value);
        }
    }

    /**
     * @dev Returns the number of checkpoint.
     */
    function length(Trace storage self) internal view returns (uint256) {
        return self._checkpoints.length;
    }

    /**
     * @dev Returns checkpoint at given position.
     */
    function at(Trace storage self, uint48 pos) internal view returns (Checkpoint memory) {
        return self._checkpoints[pos];
    }

    /**
     * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
     * or by updating the last one.
     */
    function _insert(
        Checkpoint[] storage self,
        uint48 key,
        Point memory value
    ) private returns (Point memory, Point memory) {
        uint256 pos = self.length;

        if (pos > 0) {
            // Copying to memory is important here.
            Checkpoint memory last = _unsafeAccess(self, pos - 1);

            // Checkpoint keys must be non-decreasing.
            if (last._key > key) {
                revert CheckpointUnorderedInsertions();
            }

            // Update or push new checkpoint
            if (last._key == key) {
                _unsafeAccess(self, pos - 1)._value = value;
            } else {
                self.push(Checkpoint({_key: key, _value: value}));
            }
            return (last._value, value);
        } else {
            self.push(Checkpoint({_key: key, _value: value}));
            return (blankPoint(), value);
        }
    }

    /**
     * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
     * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
     * `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _upperBinaryLookup(
        Checkpoint[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key > key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return high;
    }

    /**
     * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
     * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
     * exclusive `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _lowerBinaryLookup(
        Checkpoint[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key < key) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return high;
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _unsafeAccess(Checkpoint[] storage self, uint256 pos) private view returns (Checkpoint storage result) {
        return self[pos];
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _realUnsafeAccess(
        Checkpoint[] storage self,
        uint256 pos
    ) private pure returns (Checkpoint storage result) {
        assembly {
            mstore(0, self.slot)
            result.slot := add(keccak256(0, 0x20), pos)
        }
    }

    function blankPoint() internal pure returns (Point memory) {
        return Point({bias: 0, slope: 0, permanent: 0});
    }

    struct TraceAddress {
        CheckpointAddress[] _checkpoints;
    }

    struct CheckpointAddress {
        uint48 _key;
        address _value;
    }

    /**
     * @dev Pushes a (`key`, `value`) pair into a TraceAddress so that it is stored as the checkpoint.
     *
     * Returns previous value and new value.
     *
     * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
     * library.
     */
    function push(TraceAddress storage self, uint48 key, address value) internal returns (address, address) {
        return _insert(self._checkpoints, key, value);
    }

    /**
     * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
     * there is none.
     */
    function lowerLookup(TraceAddress storage self, uint48 key) internal view returns (address) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
        return pos == len ? address(0) : _unsafeAccess(self._checkpoints, pos)._value;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     */
    function upperLookup(TraceAddress storage self, uint48 key) internal view returns (address) {
        uint256 len = self._checkpoints.length;
        uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
        return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
     * if there is none.
     *
     * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
     * keys).
     */
    function upperLookupRecent(TraceAddress storage self, uint48 key) internal view returns (address) {
        uint256 len = self._checkpoints.length;

        uint256 low = 0;
        uint256 high = len;

        if (len > 5) {
            uint256 mid = len - Math.sqrt(len);
            if (key < _unsafeAccess(self._checkpoints, mid)._key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);

        return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
     */
    function latest(TraceAddress storage self) internal view returns (address) {
        uint256 pos = self._checkpoints.length;
        return pos == 0 ? address(0) : _unsafeAccess(self._checkpoints, pos - 1)._value;
    }

    /**
     * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
     * in the most recent checkpoint.
     */
    function latestCheckpoint(
        TraceAddress storage self
    ) internal view returns (bool exists, uint48 _key, address _value) {
        uint256 pos = self._checkpoints.length;
        if (pos == 0) {
            return (false, 0, address(0));
        } else {
            CheckpointAddress memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
            return (true, ckpt._key, ckpt._value);
        }
    }

    /**
     * @dev Returns the number of checkpoint.
     */
    function length(TraceAddress storage self) internal view returns (uint256) {
        return self._checkpoints.length;
    }

    /**
     * @dev Returns checkpoint at given position.
     */
    function at(TraceAddress storage self, uint48 pos) internal view returns (CheckpointAddress memory) {
        return self._checkpoints[pos];
    }

    /**
     * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
     * or by updating the last one.
     */
    function _insert(CheckpointAddress[] storage self, uint48 key, address value) private returns (address, address) {
        uint256 pos = self.length;

        if (pos > 0) {
            // Copying to memory is important here.
            CheckpointAddress memory last = _unsafeAccess(self, pos - 1);

            // Checkpoint keys must be non-decreasing.
            if (last._key > key) {
                revert CheckpointUnorderedInsertions();
            }

            // Update or push new checkpoint
            if (last._key == key) {
                _unsafeAccess(self, pos - 1)._value = value;
            } else {
                self.push(CheckpointAddress({_key: key, _value: value}));
            }
            return (last._value, value);
        } else {
            self.push(CheckpointAddress({_key: key, _value: value}));
            return (address(0), value);
        }
    }

    /**
     * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
     * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
     * `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _upperBinaryLookup(
        CheckpointAddress[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key > key) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return high;
    }

    /**
     * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
     * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
     * exclusive `high`.
     *
     * WARNING: `high` should not be greater than the array's length.
     */
    function _lowerBinaryLookup(
        CheckpointAddress[] storage self,
        uint48 key,
        uint256 low,
        uint256 high
    ) private view returns (uint256) {
        while (low < high) {
            uint256 mid = Math.average(low, high);
            if (_unsafeAccess(self, mid)._key < key) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return high;
    }

    /**
     * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
     */
    function _unsafeAccess(
        CheckpointAddress[] storage self,
        uint256 pos
    ) private pure returns (CheckpointAddress storage result) {
        assembly {
            mstore(0, self.slot)
            result.slot := add(keccak256(0, 0x20), pos)
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_voter","type":"address"},{"internalType":"address","name":"_bribeFactory","type":"address"},{"internalType":"string","name":"_type","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTimestamp","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"rewardsToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"}],"name":"SetOwner","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":"TYPE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WEEK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardsToken","type":"address"}],"name":"addRewardToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_rewardsToken","type":"address[]"}],"name":"addRewardTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"balanceOfAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOfOwner","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"balanceOfOwnerAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bribeFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"_rewardToken","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"earnedOwner","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"uint48","name":"_timestamp","type":"uint48"}],"name":"earnedTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"emergencyRecoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"firstBribeTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEpochStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextEpochStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getRewardForAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getRewardForOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isRewardToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardsToken","type":"address"},{"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":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20AndUpdateData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardData","outputs":[{"internalType":"uint256","name":"periodFinish","type":"uint256"},{"internalType":"uint256","name":"rewardsPerEpoch","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardsToken","type":"address"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsListLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"setMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_Voter","type":"address"}],"name":"setVoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tokenTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ve","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102ac5760003560e01c8063981b24d01161017b578063c66130d7116100d8578063eb4a78e01161008c578063f5f8d36511610071578063f5f8d36514610606578063f808a77414610619578063fca3b5aa1461064457600080fd5b8063eb4a78e0146105d6578063f4359ce5146105fd57600080fd5b8063db0ea984116100bd578063db0ea984146105a8578063e39c08fc146105bb578063e6886396146105ce57600080fd5b8063c66130d714610582578063c95bda701461059557600080fd5b8063a7852afa1161012f578063b5fd73f811610114578063b5fd73f814610527578063b66503cf1461055a578063bb24fe8a1461056d57600080fd5b8063a7852afa146104de578063ae205536146104f157600080fd5b8063a147ab0311610160578063a147ab03146104b0578063a1f87809146104c3578063a4a3e035146104d657600080fd5b8063981b24d01461047d5780639cc7f7081461049d57600080fd5b806346c96aac116102295780636e553f65116101dd5780637fd7d062116101c25780637fd7d06214610444578063853c8aeb146104575780638da5cb5b1461046a57600080fd5b80636e553f651461041e5780637bb7bed11461043157600080fd5b806355288eea1161020e57806355288eea146103fa57806357bc56141461040357806365c5f94a1461041657600080fd5b806346c96aac146103d45780634bc2a657146103e757600080fd5b806313af4035116102805780631c03e6cc116102655780631c03e6cc146103455780631f85071614610358578063381748621461037f57600080fd5b806313af40351461032a57806318160ddd1461033d57600080fd5b8062f714ce146102b15780630125bb32146102c657806303efc66c146102d957806307546172146102ff575b600080fd5b6102c46102bf36600461295d565b610657565b005b6102c46102d436600461298d565b610824565b6102ec6102e73660046129cd565b61097e565b6040519081526020015b60405180910390f35b600754610312906001600160a01b031681565b6040516001600160a01b0390911681526020016102f6565b6102c4610338366004612a0f565b6109ba565b6102ec610aa9565b6102c4610353366004612a0f565b610b38565b6103127f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c81565b6103b961038d36600461298d565b600360209081526000928352604080842090915290825290208054600182015460029092015490919083565b604080519384526020840192909252908201526060016102f6565b600654610312906001600160a01b031681565b6102c46103f5366004612a0f565b610bc9565b6102ec60025481565b6102ec61041136600461298d565b610c90565b6102ec610d2f565b6102c461042c36600461295d565b610d4b565b61031261043f366004612a2c565b610ed4565b6102c4610452366004612af4565b610efe565b6102ec610465366004612b29565b611064565b600854610312906001600160a01b031681565b6102ec61048b366004612a2c565b6000908152600b602052604090205490565b6102ec6104ab366004612a2c565b61111e565b6102ec6104be366004612b4b565b6111e4565b6102c46104d1366004612af4565b611258565b6102ec61131d565b6102c46104ec366004612b8c565b61138b565b6102ec6104ff36600461298d565b6001600160a01b03919091166000908152600c60209081526040808320938352929052205490565b61054a610535366004612a0f565b60046020526000908152604090205460ff1681565b60405190151581526020016102f6565b6102c461056836600461298d565b611443565b6105756116e9565b6040516102f69190612bff565b6102ec610590366004612a0f565b611777565b6102c46105a336600461298d565b6117af565b6102c46105b6366004612c32565b6119d8565b6102ec6105c936600461295d565b611b55565b6005546102ec565b6103127f000000000000000000000000ca79b73d967c948864058642eb736de541b325b081565b6102ec60015481565b6102c4610614366004612b8c565b611d3b565b6102ec61062736600461295d565b600a60209081526000928352604080842090915290825290205481565b6102c4610652366004612a0f565b611df4565b61065f611ebb565b600082116106b45760405162461bcd60e51b815260206004820152601160248201527f43616e6e6f74207769746864726177203000000000000000000000000000000060448201526064015b60405180910390fd5b6006546001600160a01b031633146106cb57600080fd5b60075460408051631a2732c160e31b815290516000926001600160a01b03169163d13996089160048083019260209291908290030181865afa158015610715573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107399190612c6c565b6001600160a01b0383166000908152600c602090815260408083208484529091529020549091508311610815576000818152600b60209081526040808320546001600160a01b0386168452600c83528184208585529092529091205461079f8583612c9b565b6000848152600b60205260409020556107b88582612c9b565b6001600160a01b0385166000818152600c60209081526040808320888452825291829020939093555187815290917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d591015b60405180910390a250505b506108206001600055565b5050565b6008546001600160a01b03163314806108655750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b6108a95760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156108ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109119190612c6c565b81111561091d57600080fd5b600854610937906001600160a01b03848116911683611f14565b816001600160a01b03167f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa288260405161097291815260200190565b60405180910390a25050565b60015460009081906109988165ffffffffffff8616612cb2565b6109a29190612cd4565b90506109af858583611fc2565b9150505b9392505050565b6008546001600160a01b03163314806109fb5750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b610a3f5760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b6001600160a01b038116610a5257600080fd5b6008805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f167d3e9c1016ab80e58802ca9da10ce5c6a0f4debc46a2e7a2cd9e56899a4fb590600090a250565b600080600760009054906101000a90046001600160a01b03166001600160a01b031663d13996086040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190612c6c565b6000908152600b602052604090205492915050565b6008546001600160a01b0316331480610b795750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b610bbd5760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b610bc68161230d565b50565b6008546001600160a01b0316331480610c0a5750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b610c4e5760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b6001600160a01b038116610c6157600080fd5b6006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000818152600b60205260408120548103610cd257506001600160a01b0382166000908152600360209081526040808320848452909152902060010154610d29565b6000828152600b60209081526040808320546001600160a01b03871684526003835281842086855290925290912060010154610d1c906d04ee2d6d415b85acef8100000000612cd4565b610d269190612cb2565b90505b92915050565b6000600154610d3c61131d565b610d469190612cf3565b905090565b610d53611ebb565b60008211610da35760405162461bcd60e51b815260206004820152600e60248201527f43616e6e6f74207374616b65203000000000000000000000000000000000000060448201526064016106ab565b6006546001600160a01b03163314610dba57600080fd5b60075460408051631a2732c160e31b815290516000926001600160a01b03169163d13996089160048083019260209291908290030181865afa158015610e04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e289190612c6c565b6000818152600b60209081526040808320546001600160a01b0387168452600c83528184208585529092529091205491925090610e658583612cf3565b6000848152600b6020526040902055610e7e8582612cf3565b6001600160a01b0385166000818152600c60209081526040808320888452825291829020939093555187815290917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d910161080a565b60058181548110610ee457600080fd5b6000918252602090912001546001600160a01b0316905081565b610f06611ebb565b6040516370a0823160e01b81523360048201819052906000907f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c6001600160a01b0316906370a0823190602401602060405180830381865afa158015610f70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f949190612c6c565b905060005b8181101561105757604051632f745c5960e01b81526001600160a01b038481166004830152602482018390526000917f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c90911690632f745c5990604401602060405180830381865afa158015611013573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110379190612c6c565b90506110448185876123a0565b508061104f81612d0b565b915050610f99565b505050610bc66001600055565b6040516331a9108f60e11b81526004810183905260009081906001600160a01b037f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c1690636352211e90602401602060405180830381865afa1580156110ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f29190612d24565b6001600160a01b03166000908152600c6020908152604080832086845290915290205491505092915050565b600080611129610d2f565b6040516331a9108f60e11b8152600481018590529091506000906001600160a01b037f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c1690636352211e90602401602060405180830381865afa158015611194573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b89190612d24565b6001600160a01b03166000908152600c6020908152604080832094835293905291909120549392505050565b6001600160a01b0383166000908152600c602090815260408083208484529091528120548060000361121a5760009150506109b3565b60006112268585610c90565b905060006d04ee2d6d415b85acef81000000006112438484612cd4565b61124d9190612cb2565b93506109b392505050565b6008546001600160a01b03163314806112995750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b6112dd5760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b60005b81518110156108205761130b8282815181106112fe576112fe612d41565b602002602001015161230d565b8061131581612d0b565b9150506112e0565b60075460408051631a2732c160e31b815290516000926001600160a01b03169163d13996089160048083019260209291908290030181865afa158015611367573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d469190612c6c565b611393611ebb565b6006546001600160a01b031633146113aa57600080fd5b6040516331a9108f60e11b8152600481018390526000907f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c6001600160a01b031690636352211e90602401602060405180830381865afa158015611412573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114369190612d24565b90506108158382846123a0565b61144b611ebb565b6001600160a01b03821660009081526004602052604090205460ff166114b35760405162461bcd60e51b815260206004820152601960248201527f72657761726420746f6b656e206e6f742076657269666965640000000000000060448201526064016106ab565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156114fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151e9190612c6c565b90506115356001600160a01b038416333085612481565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a09190612c6c565b905060006115ae8383612c9b565b90506000600760009054906101000a90046001600160a01b03166001600160a01b031663d13996086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611605573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116299190612c6c565b905060025460000361163b5760028190555b6001600160a01b038616600090815260036020908152604080832084845290915290206001015461166c8382612cf3565b6001600160a01b0388166000818152600360209081526040808320878452825291829020600181019490945542600285015592859055805186815292830185905290917f6a6f77044107a33658235d41bedbbaf2fe9ccdceb313143c947a5e76e1ec8474910160405180910390a250505050506108206001600055565b600980546116f690612d57565b80601f016020809104026020016040519081016040528092919081815260200182805461172290612d57565b801561176f5780601f106117445761010080835404028352916020019161176f565b820191906000526020600020905b81548152906001019060200180831161175257829003601f168201915b505050505081565b600080611782610d2f565b6001600160a01b039093166000908152600c60209081526040808320958352949052929092205492915050565b6008546001600160a01b03163314806117f05750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b6118345760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189c9190612c6c565b8111156118a857600080fd5b60075460408051631a2732c160e31b815290516000926001600160a01b03169163d13996089160048083019260209291908290030181865afa1580156118f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119169190612c6c565b6001600160a01b038416600090815260036020908152604080832084845290915290206001015490915061194a8382612c9b565b6001600160a01b038581166000818152600360209081526040808320888452909152902060018101939093554260029093019290925560085461198f92911685611f14565b836001600160a01b03167f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28846040516119ca91815260200190565b60405180910390a250505050565b6119e0611ebb565b6006546001600160a01b031633146119f757600080fd5b6040516370a0823160e01b81526001600160a01b0383811660048301526000917f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c909116906370a0823190602401602060405180830381865afa158015611a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a869190612c6c565b905060005b81811015611b4957604051632f745c5960e01b81526001600160a01b038581166004830152602482018390526000917f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c90911690632f745c5990604401602060405180830381865afa158015611b05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b299190612c6c565b9050611b368186866123a0565b5080611b4181612d0b565b915050611a8b565b50506108206001600055565b60075460408051631a2732c160e31b815290516000928392839283926001600160a01b03169163d13996089160048083019260209291908290030181865afa158015611ba5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc99190612c6c565b6000878152600a602090815260408083206001600160a01b038a168452909152902054909150808203611c03576000945050505050610d29565b600254811015611ce65760405163f778e0a360e01b8152600481018890526000907f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c6001600160a01b03169063f778e0a390602401608060405180830381865afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c999190612da8565b60015490925060009150611cb58165ffffffffffff8516612cb2565b611cbf9190612cd4565b90506002548111611cdf57600154600254611cda9190612c9b565b611ce1565b805b925050505b6032841015611d305781811015611d3057611d02878783611fc2565b611d0c9084612cf3565b925060015481611d1c9190612cf3565b905083611d2881612d0b565b945050611ce6565b509095945050505050565b611d43611ebb565b6040517f430c2081000000000000000000000000000000000000000000000000000000008152336004820152602481018390527f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c6001600160a01b03169063430c208190604401602060405180830381865afa158015611dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611deb9190612e2f565b6113aa57600080fd5b6008546001600160a01b0316331480611e355750336001600160a01b037f000000000000000000000000ca79b73d967c948864058642eb736de541b325b016145b611e795760405162461bcd60e51b81526020600482015260156024820152747065726d697373696f6e2069732064656e6965642160581b60448201526064016106ab565b6001600160a01b038116611e8c57600080fd5b6007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600260005403611f0d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106ab565b6002600055565b6040516001600160a01b038316602482015260448101829052611fbd9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526124d8565b505050565b6040517f2b3b09ec0000000000000000000000000000000000000000000000000000000081526004810184905265ffffffffffff8216602482015260009081906001600160a01b037f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c1690632b3b09ec90604401602060405180830381865afa158015612053573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120779190612d24565b90506001600160a01b0381166120915760009150506109b3565b6040517fe0514aba0000000000000000000000000000000000000000000000000000000081526004810186905265ffffffffffff841660248201526000907f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c6001600160a01b03169063e0514aba90604401602060405180830381865afa158015612120573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121449190612c6c565b905080600003612159576000925050506109b3565b6001600160a01b0382166000908152600c6020908152604080832065ffffffffffff881684529091528120549081900361219957600093505050506109b3565b6040517f3a46b1a80000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015265ffffffffffff871660248301526000917f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c90911690633a46b1a890604401602060405180830381865afa15801561222b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061224f9190612c6c565b9050806000036122665760009450505050506109b3565b60008161227b85670de0b6b3a7640000612cd4565b6122859190612cb2565b9050821580612292575080155b156122a5576000955050505050506109b3565b60006122b9898965ffffffffffff16610c90565b905060006d04ee2d6d415b85acef8100000000670de0b6b3a7640000846122e08886612cd4565b6122ea9190612cd4565b6122f49190612cb2565b6122fe9190612cb2565b97506109b39650505050505050565b6001600160a01b03811660009081526004602052604090205460ff16610bc6576001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db001805473ffffffffffffffffffffffffffffffffffffffff19169091179055565b600080805b83518110156124795760008482815181106123c2576123c2612d41565b602002602001015190506123d687826125c0565b945092508215612442576123f46001600160a01b0382168785611f14565b806001600160a01b0316866001600160a01b03167f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e8560405161243991815260200190565b60405180910390a35b6000878152600a602090815260408083206001600160a01b039094168352929052208390558061247181612d0b565b9150506123a5565b505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526124d29085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611f59565b50505050565b600061252d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127a19092919063ffffffff16565b905080516000148061254e57508080602001905181019061254e9190612e2f565b611fbd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106ab565b6000806000806000600760009054906101000a90046001600160a01b03166001600160a01b031663d13996086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561261b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263f9190612c6c565b6000888152600a602090815260408083206001600160a01b038b168452909152902054600254919250908110156127495760405163f778e0a360e01b8152600481018990526000907f0000000000000000000000008d95f56b0bac46e8ac1d3a3f12fb1e5bc39b4c0c6001600160a01b03169063f778e0a390602401608060405180830381865afa1580156126d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126fc9190612da8565b600154909250600091506127188165ffffffffffff8516612cb2565b6127229190612cd4565b905060025481116127425760015460025461273d9190612c9b565b612744565b805b925050505b6032841015612793578181101561279357612765888883611fc2565b61276f9084612cf3565b92506001548161277f9190612cf3565b90508361278b81612d0b565b945050612749565b919791965090945050505050565b60606127b084846000856127b8565b949350505050565b6060824710156128305760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016106ab565b600080866001600160a01b0316858760405161284c9190612e51565b60006040518083038185875af1925050503d8060008114612889576040519150601f19603f3d011682016040523d82523d6000602084013e61288e565b606091505b509150915061289f878383876128aa565b979650505050505050565b60608315612919578251600003612912576001600160a01b0385163b6129125760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106ab565b50816127b0565b6127b0838381511561292e5781518083602001fd5b8060405162461bcd60e51b81526004016106ab9190612bff565b6001600160a01b0381168114610bc657600080fd5b6000806040838503121561297057600080fd5b82359150602083013561298281612948565b809150509250929050565b600080604083850312156129a057600080fd5b82356129ab81612948565b946020939093013593505050565b65ffffffffffff81168114610bc657600080fd5b6000806000606084860312156129e257600080fd5b8335925060208401356129f481612948565b91506040840135612a04816129b9565b809150509250925092565b600060208284031215612a2157600080fd5b81356109b381612948565b600060208284031215612a3e57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612a6c57600080fd5b8135602067ffffffffffffffff80831115612a8957612a89612a45565b8260051b604051601f19603f83011681018181108482111715612aae57612aae612a45565b604052938452858101830193838101925087851115612acc57600080fd5b83870191505b8482101561289f578135612ae581612948565b83529183019190830190612ad2565b600060208284031215612b0657600080fd5b813567ffffffffffffffff811115612b1d57600080fd5b6127b084828501612a5b565b60008060408385031215612b3c57600080fd5b50508035926020909101359150565b600080600060608486031215612b6057600080fd5b8335612b6b81612948565b92506020840135612b7b81612948565b929592945050506040919091013590565b60008060408385031215612b9f57600080fd5b82359150602083013567ffffffffffffffff811115612bbd57600080fd5b612bc985828601612a5b565b9150509250929050565b60005b83811015612bee578181015183820152602001612bd6565b838111156124d25750506000910152565b6020815260008251806020840152612c1e816040850160208701612bd3565b601f01601f19169190910160400192915050565b60008060408385031215612c4557600080fd5b8235612c5081612948565b9150602083013567ffffffffffffffff811115612bbd57600080fd5b600060208284031215612c7e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015612cad57612cad612c85565b500390565b600082612ccf57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612cee57612cee612c85565b500290565b60008219821115612d0657612d06612c85565b500190565b600060018201612d1d57612d1d612c85565b5060010190565b600060208284031215612d3657600080fd5b81516109b381612948565b634e487b7160e01b600052603260045260246000fd5b600181811c90821680612d6b57607f821691505b602082108103612d8b57634e487b7160e01b600052602260045260246000fd5b50919050565b8051600f81900b8114612da357600080fd5b919050565b6000808284036080811215612dbc57600080fd5b6060811215612dca57600080fd5b506040516060810181811067ffffffffffffffff82111715612dee57612dee612a45565b604052612dfa84612d91565b8152612e0860208501612d91565b6020820152612e1960408501612d91565b60408201526060840151909250612982816129b9565b600060208284031215612e4157600080fd5b815180151581146109b357600080fd5b60008251612e63818460208701612bd3565b919091019291505056fea2646970667358221220baa4148016a498d623ec530f5f4f597a324d387473354537bfb60fbfe6c1f6b664736f6c634300080d0033

Block Transaction Gas Used Reward
view all blocks sequenced

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

Validator Index Block Amount
View All Withdrawals

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

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