ETH Price: $2,006.46 (-3.12%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FeeDistributorV1

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "./interfaces/IVotingEscrow.sol";
import "./interfaces/IFactory.sol";
import "./UUPSBase.sol";

/// @title FeeDistributorV1
/// @author DeFiGeek Community Japan
/// @notice Distributes fees to ve holders according to their ve holdings
contract FeeDistributorV1 is UUPSBase, ReentrancyGuardUpgradeable {
    using SafeERC20 for IERC20;

    uint256 public constant WEEK = 7 * 86400;

    address public factory;
    uint256 public timeCursor;
    uint256 public lastCheckpointTotalSupplyTime;
    mapping(address => mapping(address => uint256)) public timeCursorOf; // user -> token -> timestamp
    mapping(address => mapping(address => uint256)) public userEpochOf; // user -> token -> epoch

    mapping(address => uint256) public lastTokenTime; // token -> timestamp
    mapping(address => uint256) public startTime; // token -> timestamp
    mapping(address => mapping(uint256 => uint256)) public tokensPerWeek; // token -> week(timestamp) -> amount

    address public votingEscrow;
    address[] public tokens;
    mapping(address => uint256) public tokenFlags; // token -> (0 -> Not registered, 1 -> Registered)

    mapping(address => uint256) public tokenLastBalance; // token -> balance
    mapping(uint256 => uint256) public veSupply; // VE total supply at week bounds

    uint256 public isKilled; // 0 -> Not killed, 1 -> killed

    struct ClaimParams {
        uint256 userEpoch;
        uint256 toDistribute;
        uint256 maxUserEpoch;
        uint256 startTime;
        uint256 thisWeek;
        uint256 lastTokenTime;
        uint256 latestFeeUnlockTime;
    }

    struct RewardParams {
        int256 dt;
        int256 balanceOf;
        uint256 tokensPerWeek;
    }

    event CheckpointToken(address indexed token, uint256 time, uint256 tokens);
    event Claimed(
        address indexed recipient,
        uint256 amount,
        uint256 claimEpoch,
        uint256 maxEpoch
    );
    event AddedToken(address indexed token);

    /***
     * @notice Contract constructor
     * @param votingEscrow_ VotingEscrow contract address
     * @param factory_ Auction Factory contract address
     * @param startTime_ Epoch time for fee distribution to start
     */
    function initialize(
        address votingEscrow_,
        address factory_,
        uint256 startTime_
    ) public initializer {
        __UUPSBase_init();
        __ReentrancyGuard_init();
        uint256 t = (startTime_ / WEEK) * WEEK;
        startTime[address(0)] = t;
        lastTokenTime[address(0)] = t;
        timeCursor = t;
        tokens.push(address(0));
        tokenFlags[address(0)] = 1;
        votingEscrow = votingEscrow_;
        factory = factory_;
    }

    function _checkpointToken(address token_) internal {
        uint256 _tokenBalance;
        if (token_ == address(0)) {
            _tokenBalance = address(this).balance;
        } else {
            _tokenBalance = IERC20(token_).balanceOf(address(this));
        }
        uint256 _toDistribute = _tokenBalance - tokenLastBalance[token_];
        tokenLastBalance[token_] = _tokenBalance;

        uint256 _t = lastTokenTime[token_];
        uint256 _sinceLast = block.timestamp - _t;
        uint256 _currentWeek = block.timestamp / WEEK;
        uint256 _sinceLastInWeeks = _currentWeek - (_t / WEEK);

        /* 
        If current timestamp crosses a week since the last checkpoint,
        set _t to the beginning of the week following the last checkpoint.

        |-x-|---|-●-|
        0   1   2   3
        x: Last checkpoint 
        ●: New checkpoint

        In this case, we start the calculation from (the beginning of) week 1. 
        No more fee will be allocated to week 0.
        */
        if (_sinceLastInWeeks > 0) {
            _t = ((_t + WEEK) / WEEK) * WEEK;
            _sinceLast = block.timestamp - _t;
            _sinceLastInWeeks = _currentWeek - _t / WEEK;
        }
        /*
        If _sinceLast has exceeded 20 weeks,
        set _t to the beginning of the week that is 19 weeks prior to the current block time.

        |-x-|-0-|-0-|-0-|-0-|-0-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|-1-|0.5●-|-
        0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25    26
        x: Last checkpoint 
        ●: New checkpoint

        In this case, we start the calculation from (the beginning of) week 6. 
        No fee will be allocated to the weeks prior to week 5.
        */
        if (_sinceLastInWeeks >= 20) {
            _t = ((block.timestamp - (WEEK * 19)) / WEEK) * WEEK;
            _sinceLast = block.timestamp - _t;
        }

        lastTokenTime[token_] = block.timestamp;
        uint256 _thisWeek = (_t / WEEK) * WEEK;
        uint256 _nextWeek;

        for (uint256 i; i < 20; ) {
            _nextWeek = _thisWeek + WEEK;
            if (block.timestamp < _nextWeek) {
                if (_sinceLast == 0 && block.timestamp == _t) {
                    tokensPerWeek[token_][_thisWeek] += _toDistribute;
                } else {
                    tokensPerWeek[token_][_thisWeek] +=
                        (_toDistribute * (block.timestamp - _t)) /
                        _sinceLast;
                }
                break;
            } else {
                if (_sinceLast == 0 && _nextWeek == _t) {
                    tokensPerWeek[token_][_thisWeek] += _toDistribute;
                } else {
                    tokensPerWeek[token_][_thisWeek] +=
                        (_toDistribute * (_nextWeek - _t)) /
                        _sinceLast;
                }
            }
            _t = _nextWeek;
            _thisWeek = _nextWeek;
            unchecked {
                ++i;
            }
        }

        emit CheckpointToken(token_, block.timestamp, _toDistribute);
    }

    /***
     * @notice Update the token checkpoint
     * @dev Calculates the total number of tokens to be distributed in a given week.
         This function is only callable by auctions or the contract owner.
     */
    function checkpointToken(address token_) external onlyAdminOrAuction {
        require(tokenFlags[token_] == 1, "Token not registered");

        if (block.timestamp >= timeCursor) {
            _checkpointTotalSupply();
        }

        _checkpointToken(token_);
    }

    function _findTimestampEpoch(
        address ve_,
        uint256 timestamp_
    ) internal view returns (uint256) {
        uint256 _min;
        uint256 _max = IVotingEscrow(ve_).epoch();

        unchecked {
            for (uint256 i; i < 128; ++i) {
                if (_min >= _max) {
                    break;
                }
                uint256 _mid = (_min + _max + 2) / 2;
                IVotingEscrow.Point memory _pt = IVotingEscrow(ve_)
                    .pointHistory(_mid);
                if (_pt.ts <= timestamp_) {
                    _min = _mid;
                } else {
                    _max = _mid - 1;
                }
            }
        }
        return _min;
    }

    function _findTimestampUserEpoch(
        address ve_,
        address user_,
        uint256 timestamp_,
        uint256 maxUserEpoch_
    ) internal view returns (uint256) {
        uint256 _min;
        uint256 _max = maxUserEpoch_;

        unchecked {
            for (uint256 i; i < 128; ++i) {
                if (_min >= _max) {
                    break;
                }
                uint256 _mid = (_min + _max + 2) / 2;
                IVotingEscrow.Point memory _pt = IVotingEscrow(ve_)
                    .userPointHistory(user_, _mid);
                if (_pt.ts <= timestamp_) {
                    _min = _mid;
                } else {
                    _max = _mid - 1;
                }
            }
        }
        return _min;
    }

    /***
     * @notice Get the veYNWK balance for `user_` at `timestamp_`
     * @param user_ Address to query balance for
     * @param timestamp_ Epoch time
     * @return uint256 veYNWK balance
     */
    function veForAt(
        address user_,
        uint256 timestamp_
    ) external view returns (uint256) {
        address _ve = votingEscrow;
        uint256 _maxUserEpoch = IVotingEscrow(_ve).userPointEpoch(user_);
        uint256 _epoch = _findTimestampUserEpoch(
            _ve,
            user_,
            timestamp_,
            _maxUserEpoch
        );
        IVotingEscrow.Point memory _pt = IVotingEscrow(_ve).userPointHistory(
            user_,
            _epoch
        );
        int128 _balance = _pt.bias -
            _pt.slope *
            int128(int256(timestamp_ - _pt.ts));
        if (_balance < 0) {
            return 0;
        } else {
            return uint256(uint128(_balance));
        }
    }

    function _checkpointTotalSupply() internal {
        address _ve = votingEscrow;
        uint256 _t = timeCursor;
        uint256 _roundedTimestamp = (block.timestamp / WEEK) * WEEK;
        IVotingEscrow(_ve).checkpoint();

        uint256 _sinceLastInWeeks;
        if (_t > 0 && _roundedTimestamp > _t) {
            unchecked {
                _sinceLastInWeeks = (_roundedTimestamp - _t) / WEEK;
            }
        }

        /*
        If the time since the last checkpoint exceeds 20 weeks,
        set the checkpoint time to the beginning of the week that is 19 weeks prior to the current block time.
        */
        if (_sinceLastInWeeks >= 20) {
            _t = (_roundedTimestamp - WEEK * 19);
        }

        /*
        If the last checkpoint total supply time is the previous week,
        update the veSupply to ensure it reflects the latest state.
        This prevents a scenario where checkpointTotalSupply and veToken's createLock
        occur in the same block, potentially causing veSupply to not be updated with the latest value.
        */
        uint256 _previousWeek = timeCursor > WEEK ? timeCursor - WEEK : 0;
        if (lastCheckpointTotalSupplyTime == _previousWeek) {
            _updateVeSupply(_ve, _previousWeek);
        }

        for (uint256 i; i < 20; ) {
            if (_t > _roundedTimestamp) {
                break;
            } else {
                _updateVeSupply(_ve, _t);
                _t += WEEK;
            }
            unchecked {
                ++i;
            }
        }

        lastCheckpointTotalSupplyTime = block.timestamp;
        timeCursor = _t;
    }

    /**
     * @notice Internal function to update veSupply for a given timestamp.
     * @param _ve The address of the veToken contract.
     * @param _t The timestamp to update veSupply for.
     */
    function _updateVeSupply(address _ve, uint256 _t) internal {
        uint256 _epoch = _findTimestampEpoch(_ve, _t);
        IVotingEscrow.Point memory _pt = IVotingEscrow(_ve).pointHistory(
            _epoch
        );
        int128 _dt;
        if (_t > _pt.ts) {
            _dt = int128(int256(_t) - int256(_pt.ts));
        }

        int128 _balance = _pt.bias - _pt.slope * _dt;
        if (_balance < 0) {
            veSupply[_t] = 0;
        } else {
            veSupply[_t] = uint256(uint128(_balance));
        }
    }

    /***
     * @notice Update the veYMWK total supply checkpoint
     * @dev The checkpoint is also updated by the first claimant each new epoch week. This function may be called independently of a claim, to reduce claiming gas costs.
     */
    function checkpointTotalSupply() external {
        _checkpointTotalSupply();
    }

    function _claim(
        address addr_,
        address token_,
        address ve_,
        uint256 lastTokenTime_
    ) internal returns (uint256) {
        // Minimal user_epoch is 0 (if user had no point)
        ClaimParams memory _cp = ClaimParams({
            userEpoch: 0,
            toDistribute: 0,
            maxUserEpoch: IVotingEscrow(ve_).userPointEpoch(addr_),
            startTime: startTime[token_],
            thisWeek: (block.timestamp / WEEK) * WEEK,
            lastTokenTime: lastTokenTime_,
            latestFeeUnlockTime: ((lastTokenTime_ + WEEK) / WEEK) * WEEK
        });

        if (_cp.thisWeek >= _cp.latestFeeUnlockTime) {
            _cp.lastTokenTime = _cp.latestFeeUnlockTime;
        }

        if (_cp.maxUserEpoch == 0) {
            // No lock = no fees
            return 0;
        }

        uint256 _weekCursor = timeCursorOf[addr_][token_];
        if (_weekCursor == 0) {
            // Need to do the initial binary search
            _cp.userEpoch = _findTimestampUserEpoch(
                ve_,
                addr_,
                _cp.startTime,
                _cp.maxUserEpoch
            );
        } else {
            _cp.userEpoch = userEpochOf[addr_][token_];
        }

        if (_cp.userEpoch == 0) {
            _cp.userEpoch = 1;
        }

        IVotingEscrow.Point memory _userPoint = IVotingEscrow(ve_)
            .userPointHistory(addr_, _cp.userEpoch);

        if (_weekCursor == 0) {
            _weekCursor = ((_userPoint.ts + WEEK - 1) / WEEK) * WEEK;
        }

        if (_weekCursor >= _cp.lastTokenTime) {
            return 0;
        }

        if (_weekCursor < _cp.startTime) {
            _weekCursor = _cp.startTime;
        }

        IVotingEscrow.Point memory _oldUserPoint = IVotingEscrow.Point({
            bias: 0,
            slope: 0,
            ts: 0,
            blk: 0
        });

        // Iterate over weeks
        for (uint256 i; i < 50; ) {
            if (_weekCursor >= _cp.lastTokenTime) {
                break;
            } else if (
                _weekCursor >= _userPoint.ts &&
                _cp.userEpoch <= _cp.maxUserEpoch
            ) {
                ++_cp.userEpoch;
                _oldUserPoint = IVotingEscrow.Point({
                    bias: _userPoint.bias,
                    slope: _userPoint.slope,
                    ts: _userPoint.ts,
                    blk: _userPoint.blk
                });
                if (_cp.userEpoch > _cp.maxUserEpoch) {
                    _userPoint = IVotingEscrow.Point({
                        bias: 0,
                        slope: 0,
                        ts: 0,
                        blk: 0
                    });
                } else {
                    _userPoint = IVotingEscrow(ve_).userPointHistory(
                        addr_,
                        _cp.userEpoch
                    );
                }
            } else {
                RewardParams memory _rp = RewardParams({
                    dt: int256(_weekCursor) - int256(_oldUserPoint.ts),
                    balanceOf: 0,
                    tokensPerWeek: 0
                });
                _rp.balanceOf =
                    int256(_oldUserPoint.bias) -
                    _rp.dt *
                    int256(_oldUserPoint.slope);

                if (_rp.balanceOf < 0) {
                    _rp.balanceOf = 0;
                }

                if (_rp.balanceOf == 0 && _cp.userEpoch > _cp.maxUserEpoch) {
                    break;
                }

                if (_rp.balanceOf > 0 && veSupply[_weekCursor] > 0) {
                    _rp.tokensPerWeek = tokensPerWeek[token_][_weekCursor];
                    _cp.toDistribute +=
                        (uint256(_rp.balanceOf) * _rp.tokensPerWeek) /
                        veSupply[_weekCursor];
                }
                _weekCursor += WEEK;
            }
            unchecked {
                ++i;
            }
        }

        _cp.userEpoch = Math.min(_cp.maxUserEpoch, _cp.userEpoch - 1);
        userEpochOf[addr_][token_] = _cp.userEpoch;
        timeCursorOf[addr_][token_] = _weekCursor;

        emit Claimed(addr_, _cp.toDistribute, _cp.userEpoch, _cp.maxUserEpoch);

        return _cp.toDistribute;
    }

    /***
     * @notice Claim fees for `msg.sender`
     * @dev Each call to claim look at a maximum of 50 user veYMWK points.
         For accounts with many veYMWK related actions, this function
         may need to be called more than once to claim all available
         fees. In the `Claimed` event that fires, if `claim_epoch` is
         less than `max_epoch`, the account may claim again.
     * @return uint256 Amount of fees claimed in the call
     */
    function claim(address token_) external nonReentrant returns (uint256) {
        require(isKilled == 0, "Contract is killed");
        require(tokenFlags[token_] == 1, "Token not registered");
        address _addr = msg.sender;
        if (block.timestamp >= timeCursor) {
            _checkpointTotalSupply();
        }

        uint256 _lastTokenTime = lastTokenTime[token_];

        unchecked {
            _lastTokenTime = (_lastTokenTime / WEEK) * WEEK;
        }

        uint256 _amount = _claim(_addr, token_, votingEscrow, _lastTokenTime);
        if (_amount != 0) {
            tokenLastBalance[token_] -= _amount;
            if (token_ == address(0)) {
                (bool success, ) = payable(_addr).call{value: _amount}("");
                require(success, "Transfer failed");
            } else {
                IERC20(token_).safeTransfer(_addr, _amount);
            }
        }

        return _amount;
    }

    /***
     * @notice Claim fees for `addr_`
     * @dev Each call to claim look at a maximum of 50 user veYMWK points.
         For accounts with many veYMWK related actions, this function
         may need to be called more than once to claim all available
         fees. In the `Claimed` event that fires, if `claim_epoch` is
         less than `max_epoch`, the account may claim again.
     * @param addr_ Address to claim fees for
     * @return uint256 Amount of fees claimed in the call
     */
    function claim(
        address addr_,
        address token_
    ) external nonReentrant returns (uint256) {
        require(isKilled == 0, "Contract is killed");
        require(tokenFlags[token_] == 1, "Token not registered");

        if (block.timestamp >= timeCursor) {
            _checkpointTotalSupply();
        }

        uint256 _lastTokenTime = lastTokenTime[token_];

        unchecked {
            _lastTokenTime = (_lastTokenTime / WEEK) * WEEK;
        }

        uint256 _amount = _claim(addr_, token_, votingEscrow, _lastTokenTime);
        if (_amount != 0) {
            tokenLastBalance[token_] -= _amount;
            if (token_ == address(0)) {
                (bool success, ) = payable(addr_).call{value: _amount}("");
                require(success, "Transfer failed");
            } else {
                IERC20(token_).safeTransfer(addr_, _amount);
            }
        }

        return _amount;
    }

    /***
     * @notice Make multiple fee claims in a single call
     * @dev Used to claim for many accounts at once, or to make
         multiple claims for the same address when that address
         has significant veYMWK history
     * @param receivers_ List of addresses to claim for. Claiming
                      terminates at the first `ZERO_ADDRESS`.
     * @return bool success
     */
    function claimMany(
        address[20] memory receivers_,
        address token_
    ) external nonReentrant returns (bool) {
        require(isKilled == 0, "Contract is killed");
        require(tokenFlags[token_] == 1, "Token not registered");

        if (block.timestamp >= timeCursor) {
            _checkpointTotalSupply();
        }

        uint256 _lastTokenTime = lastTokenTime[token_];

        unchecked {
            _lastTokenTime = (_lastTokenTime / WEEK) * WEEK;
        }

        uint256 _total = 0;
        uint256 _l = receivers_.length;
        for (uint256 i; i < _l; ) {
            address _addr = receivers_[i];
            if (_addr == address(0)) {
                break;
            }

            uint256 _amount = _claim(
                _addr,
                token_,
                votingEscrow,
                _lastTokenTime
            );
            if (_amount != 0) {
                _total += _amount;
                if (token_ == address(0)) {
                    (bool success, ) = payable(_addr).call{value: _amount}("");
                    require(success, "Transfer failed");
                } else {
                    IERC20(token_).safeTransfer(_addr, _amount);
                }
            }
            unchecked {
                ++i;
            }
        }

        if (_total != 0) {
            tokenLastBalance[token_] -= _total;
        }

        return true;
    }

    /***
     * @notice Claim multiple tokens in one go
     * @param addr_ Receiver address
     * @param tokens_ Token addresses
     * @return bool success
     */
    function claimMultipleTokens(
        address addr_,
        address[20] memory tokens_
    ) external nonReentrant returns (bool) {
        require(isKilled == 0, "Contract is killed");
        require(addr_ != address(0), "Address should not zero");

        if (block.timestamp >= timeCursor) {
            _checkpointTotalSupply();
        }

        uint256 _l = tokens_.length;
        for (uint256 i; i < _l; ) {
            require(tokenFlags[tokens_[i]] == 1, "Token not registered");

            address _token = tokens_[i];
            uint256 _lastTokenTime = lastTokenTime[_token];

            _lastTokenTime = (_lastTokenTime / WEEK) * WEEK;
            uint256 _amount = _claim(
                addr_,
                _token,
                votingEscrow,
                _lastTokenTime
            );
            if (_amount != 0) {
                tokenLastBalance[_token] -= _amount;
                if (_token == address(0)) {
                    (bool success, ) = payable(addr_).call{value: _amount}("");
                    require(success, "Transfer failed");
                } else {
                    IERC20(_token).safeTransfer(addr_, _amount);
                }
            }
            unchecked {
                ++i;
            }
        }

        return true;
    }

    /***
     * @notice Kill the contract
     * @dev Killing transfers the entire Ether balance to admin address
         and blocks the ability to claim. The contract cannot be unkilled.
         Tokens other than Ether should be transferred using recoverBalance() 
         to avoid failing killing the contract due to unexpected behavior of third party ERC20 tokens
     */
    function killMe() external onlyAdmin {
        isKilled = 1;
        (bool success, ) = payable(admin).call{value: address(this).balance}(
            ""
        );
        require(success, "Transfer failed");
    }

    /***
     * @notice Recover ERC20 tokens from this contract
     * @dev Tokens are sent to admin address.
     * @param coin_ Token address
     * @return bool success
     */
    function recoverBalance(address coin_) external onlyAdmin returns (bool) {
        require(tokenFlags[coin_] == 1, "Cannot recover this token");

        if (coin_ == address(0)) {
            (bool success, ) = payable(admin).call{
                value: address(this).balance
            }("");
            require(success, "Transfer failed");
        } else {
            IERC20(coin_).safeTransfer(
                admin,
                IERC20(coin_).balanceOf(address(this))
            );
        }
        return true;
    }

    /***
     * @notice Register ERC20 token address to reward tokens
     * @dev This function is suppose to be called during auctions to withdraw sales
     * @param coin_ Token address
     * @return bool success
     */
    function addRewardToken(
        address coin_
    ) external onlyAdminOrAuction returns (bool) {
        require(coin_ != address(0), "ETH is already registered");
        require(tokenFlags[coin_] == 0, "Token is already registered");

        lastTokenTime[coin_] = block.timestamp;
        startTime[coin_] = (block.timestamp / WEEK) * WEEK;
        tokenFlags[coin_] = 1;
        tokens.push(coin_);

        emit AddedToken(coin_);

        return true;
    }

    function getTokens() external view returns (address[] memory) {
        return tokens;
    }

    /// @dev Allow only auctions
    modifier onlyAuction() {
        require(
            IFactory(factory).auctions(msg.sender),
            "You are not the auction."
        );
        _;
    }

    /// @dev Allow only auctions or admin
    modifier onlyAdminOrAuction() {
        require(
            msg.sender == admin || IFactory(factory).auctions(msg.sender),
            "Unauthorized"
        );
        _;
    }

    receive() external payable {}
}

File 2 of 18 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

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

pragma solidity ^0.8.0;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 *
 * _Available since v4.8.3._
 */
interface IERC1967Upgradeable {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}

File 4 of 18 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import {Initializable} from "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

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

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

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

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeTo(address newImplementation) public virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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 ReentrancyGuardUpgradeable is Initializable {
    // 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;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _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;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// 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 AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * 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);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

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

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

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

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

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

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;

interface IFactory {
    function auctions(address _address) external view returns (bool);
}

// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

interface IVotingEscrow {
    struct Point {
        int128 bias;
        int128 slope;
        uint256 ts;
        uint256 blk;
    }

    function balanceOf(address addr, uint256 t) external view returns (uint256);

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

    function checkpoint() external;

    function epoch() external view returns (uint256);

    function getLastUserSlope(address addr) external view returns (int128);

    function lockedEnd(address addr) external view returns (uint256);

    function pointHistory(uint256 loc) external view returns (Point memory);

    function totalSupply(uint256 t) external view returns (uint256);

    function userPointEpoch(address user) external view returns (uint256);

    function userPointHistory(
        address addr,
        uint256 loc
    ) external view returns (Point memory);

    function userPointHistoryTs(
        address addr,
        uint256 epoch
    ) external view returns (uint256);
}

// interface IVotingEscrow {
//     function userPointEpoch(address addr) external view returns (uint256);

//     function epoch() external view returns (uint256);

//     function userPointHistory(
//         address addr,
//         uint256 loc
//     ) external view returns (Point memory);

//     function pointHistory(uint256 loc) external view returns (Point memory);

//     function checkpoint() external;
// }

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.19;

import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

/// @title UUPSBase
/// @author DeFiGeek Community Japan
contract UUPSBase is UUPSUpgradeable {
    event CommitOwnership(address admin);
    event ApplyOwnership(address admin);

    address public admin;
    address public futureAdmin;

    function __UUPSBase_init() internal onlyInitializing {
        __UUPSBase_init_unchained();
    }

    function __UUPSBase_init_unchained() internal onlyInitializing {
        admin = msg.sender;
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyAdmin {}

    /***
     * @notice Transfer ownership of GaugeController to `addr`
     * @param addr_ Address to have ownership transferred to
     */
    function commitTransferOwnership(address addr_) external onlyAdmin {
        futureAdmin = addr_;
        emit CommitOwnership(addr_);
    }

    /***
     * @notice Apply pending ownership transfer
     */
    function applyTransferOwnership() external onlyAdmin {
        address _admin = futureAdmin;
        require(_admin != address(0), "admin not set");
        admin = _admin;
        emit ApplyOwnership(_admin);
    }

    modifier onlyAdmin() {
        require(admin == msg.sender, "admin only");
        _;
    }
}

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

Contract Security Audit

Contract ABI

API
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"AddedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"ApplyOwnership","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"CheckpointToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimEpoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxEpoch","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"CommitOwnership","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"WEEK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coin_","type":"address"}],"name":"addRewardToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"applyTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"}],"name":"checkpointToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"checkpointTotalSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr_","type":"address"},{"internalType":"address","name":"token_","type":"address"}],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[20]","name":"receivers_","type":"address[20]"},{"internalType":"address","name":"token_","type":"address"}],"name":"claimMany","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr_","type":"address"},{"internalType":"address[20]","name":"tokens_","type":"address[20]"}],"name":"claimMultipleTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr_","type":"address"}],"name":"commitTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"futureAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"votingEscrow_","type":"address"},{"internalType":"address","name":"factory_","type":"address"},{"internalType":"uint256","name":"startTime_","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isKilled","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"killMe","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastCheckpointTotalSupplyTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastTokenTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"coin_","type":"address"}],"name":"recoverBalance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timeCursor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"timeCursorOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenFlags","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenLastBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokensPerWeek","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userEpochOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user_","type":"address"},{"internalType":"uint256","name":"timestamp_","type":"uint256"}],"name":"veForAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"veSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"votingEscrow","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523060805234801561001457600080fd5b506080516140d861004c60003960008181611041015281816110d701528181611345015281816113db015261150001526140d86000f3fe60806040526004361061021c5760003560e01c806368662ea01161011d578063c45a0155116100b0578063e1d2bf691161007f578063f364824111610064578063f364824114610679578063f4359ce514610699578063f851a440146106b057600080fd5b8063e1d2bf6914610636578063e855dd071461066357600080fd5b8063c45a0155146105b4578063c50d400d146105d4578063df0ab9d314610601578063e1cebf0b1461061657600080fd5b80638fe8a101116100ec5780638fe8a10114610547578063a186dc081461055d578063aa6ca8081461057d578063b603cd801461059f57600080fd5b806368662ea0146104b75780636e1dc66e146104d75780637d933227146105045780638736659b1461053157600080fd5b80633659cfe6116101b05780634f1ef2861161017f5780634f64b2be116101645780634f64b2be1461046257806352d1902d146104825780636089627f1461049757600080fd5b80634f1ef2861461042f5780634f2bfe5b1461044257600080fd5b80633659cfe61461037f57806338b74b471461039f5780633902b9bc146103d75780634cb654af146103f757600080fd5b80631c03e6cc116101ec5780631c03e6cc146102fa5780631e83409a1461032a57806321c0b3421461034a578063326a94071461036a57600080fd5b8062d440c114610228578063071cb5ad146102735780630f6592ef146102ab5780631794bb3c146102d857600080fd5b3661022357005b600080fd5b34801561023457600080fd5b50610260610243366004613a1e565b60a060209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b34801561027f57600080fd5b5061026061028e366004613a48565b609d60209081526000928352604080842090915290825290205481565b3480156102b757600080fd5b506102606102c6366004613a7b565b60a56020526000908152604090205481565b3480156102e457600080fd5b506102f86102f3366004613a94565b6106d0565b005b34801561030657600080fd5b5061031a610315366004613ad0565b610968565b604051901515815260200161026a565b34801561033657600080fd5b50610260610345366004613ad0565b610bf4565b34801561035657600080fd5b50610260610365366004613a48565b610e0f565b34801561037657600080fd5b506102f861102d565b34801561038b57600080fd5b506102f861039a366004613ad0565b611037565b3480156103ab57600080fd5b506102606103ba366004613a48565b609c60209081526000928352604080842090915290825290205481565b3480156103e357600080fd5b506102f86103f2366004613ad0565b6111d4565b34801561040357600080fd5b50606654610417906001600160a01b031681565b6040516001600160a01b03909116815260200161026a565b6102f861043d366004613b69565b61133b565b34801561044e57600080fd5b5060a154610417906001600160a01b031681565b34801561046e57600080fd5b5061041761047d366004613a7b565b6114c9565b34801561048e57600080fd5b506102606114f3565b3480156104a357600080fd5b5061031a6104b2366004613ca2565b6115b8565b3480156104c357600080fd5b5061031a6104d2366004613ad0565b6118a2565b3480156104e357600080fd5b506102606104f2366004613ad0565b609f6020526000908152604090205481565b34801561051057600080fd5b5061026061051f366004613ad0565b609e6020526000908152604090205481565b34801561053d57600080fd5b50610260609a5481565b34801561055357600080fd5b5061026060a65481565b34801561056957600080fd5b5061031a610578366004613cce565b611ac4565b34801561058957600080fd5b50610592611d41565b60405161026a9190613cfb565b3480156105ab57600080fd5b506102f8611da3565b3480156105c057600080fd5b50609954610417906001600160a01b031681565b3480156105e057600080fd5b506102606105ef366004613ad0565b60a36020526000908152604090205481565b34801561060d57600080fd5b506102f8611ea5565b34801561062257600080fd5b506102f8610631366004613ad0565b611fc5565b34801561064257600080fd5b50610260610651366004613ad0565b60a46020526000908152604090205481565b34801561066f57600080fd5b50610260609b5481565b34801561068557600080fd5b50610260610694366004613a1e565b612085565b3480156106a557600080fd5b5061026062093a8081565b3480156106bc57600080fd5b50606554610417906001600160a01b031681565b600054610100900460ff16158080156106f05750600054600160ff909116105b8061070a5750303b15801561070a575060005460ff166001145b6107815760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156107df57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6107e761221a565b6107ef61229f565b600062093a806107ff8185613d6b565b6108099190613da6565b7fa705961f203609058950cfd817eb7a7627c9e270651c936aad3abdfa253727ec8190557fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a95978819055609a555060a2805460018082019092557faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d0180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556000805260a36020527f69b4e8f94ad9e612080e13aad01219472d8c2c7ae7aa6cdf175400ddc8c4ed3d9190915560a1805482166001600160a01b038781169190911790915560998054909216908516179055801561096257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6065546000906001600160a01b0316331480610a0457506099546040517f1d59410a0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690631d59410a90602401602060405180830381865afa1580156109e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a049190613dbd565b610a505760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a656400000000000000000000000000000000000000006044820152606401610778565b6001600160a01b038216610aa65760405162461bcd60e51b815260206004820152601960248201527f45544820697320616c72656164792072656769737465726564000000000000006044820152606401610778565b6001600160a01b038216600090815260a3602052604090205415610b0c5760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20697320616c7265616479207265676973746572656400000000006044820152606401610778565b6001600160a01b0382166000908152609e60205260409020429081905562093a8090610b39908290613d6b565b610b439190613da6565b6001600160a01b0383166000818152609f602090815260408083209490945560a3905282812060019081905560a28054918201815582527faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001683179055915190917f4bbe03be846191383bf3fc4e9dcdc8312ef44d20eec28c2370c51603ba6f80a691a25060015b919050565b6000610bfe612324565b60a65415610c4e5760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a36020526040902054600114610cb65760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a5433904210610cc957610cc961237d565b6001600160a01b038381166000908152609e602052604081205460a15462093a809182900490910292610d01918591889116856124bd565b90508015610e01576001600160a01b038516600090815260a4602052604081208054839290610d31908490613ddf565b90915550506001600160a01b038516610ded576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114610d91576040519150601f19603f3d011682016040523d82523d6000602084013e610d96565b606091505b5050905080610de75760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50610e01565b610e016001600160a01b0386168483612ad2565b92505050610bef6001606755565b6000610e19612324565b60a65415610e695760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a36020526040902054600114610ed15760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a544210610ee257610ee261237d565b6001600160a01b038281166000908152609e602052604081205460a15462093a809182900490910292610f1a918791879116856124bd565b9050801561101a576001600160a01b038416600090815260a4602052604081208054839290610f4a908490613ddf565b90915550506001600160a01b038416611006576000856001600160a01b03168260405160006040518083038185875af1925050503d8060008114610faa576040519150601f19603f3d011682016040523d82523d6000602084013e610faf565b606091505b50509050806110005760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b5061101a565b61101a6001600160a01b0385168683612ad2565b9150506110276001606755565b92915050565b61103561237d565b565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036110d55760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610778565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166111307f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146111ac5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610778565b6111b581612b5e565b604080516000808252602082019092526111d191839190612bb8565b50565b6065546001600160a01b031633148061126d57506099546040517f1d59410a0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690631d59410a90602401602060405180830381865afa158015611249573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126d9190613dbd565b6112b95760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a656400000000000000000000000000000000000000006044820152606401610778565b6001600160a01b038116600090815260a360205260409020546001146113215760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a5442106113325761133261237d565b6111d181612d76565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036113d95760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610778565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166114347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146114b05760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610778565b6114b982612b5e565b6114c582826001612bb8565b5050565b60a281815481106114d957600080fd5b6000918252602090912001546001600160a01b0316905081565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146115935760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610778565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b60006115c2612324565b60a654156116125760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b0383166116685760405162461bcd60e51b815260206004820152601760248201527f416464726573732073686f756c64206e6f74207a65726f0000000000000000006044820152606401610778565b609a5442106116795761167961237d565b601460005b818110156118925760a3600085836014811061169c5761169c613df2565b60200201516001600160a01b03166001600160a01b03168152602001908152602001600020546001146117115760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b600084826014811061172557611725613df2565b602090810291909101516001600160a01b0381166000908152609e90925260409091205490915062093a8061175a8183613d6b565b6117649190613da6565b60a15490915060009061178490899085906001600160a01b0316856124bd565b90508015611884576001600160a01b038316600090815260a46020526040812080548392906117b4908490613ddf565b90915550506001600160a01b038316611870576000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114611814576040519150601f19603f3d011682016040523d82523d6000602084013e611819565b606091505b505090508061186a5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50611884565b6118846001600160a01b0384168983612ad2565b83600101935050505061167e565b5060019150506110276001606755565b6065546000906001600160a01b031633146118ff5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a360205260409020546001146119675760405162461bcd60e51b815260206004820152601960248201527f43616e6e6f74207265636f766572207468697320746f6b656e000000000000006044820152606401610778565b6001600160a01b038216611a1e576065546040516000916001600160a01b03169047908381818185875af1925050503d80600081146119c2576040519150601f19603f3d011682016040523d82523d6000602084013e6119c7565b606091505b5050905080611a185760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50611abc565b6065546040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152611abc916001600160a01b0390811691908516906370a0823190602401602060405180830381865afa158015611a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aab9190613e21565b6001600160a01b0385169190612ad2565b506001919050565b6000611ace612324565b60a65415611b1e5760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a36020526040902054600114611b865760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a544210611b9757611b9761237d565b6001600160a01b0382166000908152609e602052604081205462093a809081900402906014815b81811015611cfb576000878260148110611bda57611bda613df2565b602002015190506001600160a01b038116611bf55750611cfb565b60a154600090611c129083908a906001600160a01b0316896124bd565b90508015611cf157611c248186613e3a565b94506001600160a01b038816611cdd576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611c81576040519150601f19603f3d011682016040523d82523d6000602084013e611c86565b606091505b5050905080611cd75760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50611cf1565b611cf16001600160a01b0389168383612ad2565b5050600101611bbe565b508115611d30576001600160a01b038516600090815260a4602052604081208054849290611d2a908490613ddf565b90915550505b600193505050506110276001606755565b606060a2805480602002602001604051908101604052809291908181526020018280548015611d9957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d7b575b5050505050905090565b6065546001600160a01b03163314611dfd5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b600160a6556065546040516000916001600160a01b03169047908381818185875af1925050503d8060008114611e4f576040519150601f19603f3d011682016040523d82523d6000602084013e611e54565b606091505b50509050806111d15760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b6065546001600160a01b03163314611eff5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b6066546001600160a01b031680611f585760405162461bcd60e51b815260206004820152600d60248201527f61646d696e206e6f7420736574000000000000000000000000000000000000006044820152606401610778565b606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527febee2d5739011062cb4f14113f3b36bf0ffe3da5c0568f64189d1012a1189105906020015b60405180910390a150565b6065546001600160a01b0316331461201f5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b606680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f2f56810a6bf40af059b96d3aea4db54081f378029a518390491093a7b67032e990602001611fba565b60a1546040517f81fc83bb0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526000921690829082906381fc83bb90602401602060405180830381865afa1580156120ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121119190613e21565b905060006121218387878561312e565b6040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018390529192506000918516906334d901a490604401608060405180830381865afa15801561218d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b19190613e5f565b905060008160400151876121c59190613ddf565b82602001516121d49190613ed1565b82516121e09190613ef8565b9050600081600f0b12156121fc57600095505050505050611027565b6fffffffffffffffffffffffffffffffff1694506110279350505050565b600054610100900460ff166122975760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b61103561320d565b600054610100900460ff1661231c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b6110356132b6565b6002606754036123765760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610778565b6002606755565b60a154609a546001600160a01b0390911690600062093a8061239f8142613d6b565b6123a99190613da6565b9050826001600160a01b031663c2c4c5c16040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156123e657600080fd5b505af11580156123fa573d6000803e3d6000fd5b505050506000808311801561240e57508282115b1561241d575062093a80828203045b601481106124405761243362093a806013613da6565b61243d9083613ddf565b92505b600062093a80609a5411612455576000612466565b62093a80609a546124669190613ddf565b905080609b540361247b5761247b8582613333565b60005b60148110156124af578385116124af576124988686613333565b6124a562093a8086613e3a565b945060010161247e565b505042609b555050609a5550565b6000806040518060e001604052806000815260200160008152602001856001600160a01b03166381fc83bb896040518263ffffffff1660e01b815260040161251491906001600160a01b0391909116815260200190565b602060405180830381865afa158015612531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125559190613e21565b81526001600160a01b0387166000908152609f602090815260409182902054908301520162093a806125878142613d6b565b6125919190613da6565b81526020810185905260400162093a80806125ac8188613e3a565b6125b69190613d6b565b6125c09190613da6565b81525090508060c001518160800151106125df5760c081015160a08201525b80604001516000036125f5576000915050612aca565b6001600160a01b038087166000908152609c60209081526040808320938916835292905290812054908190036126405761263985888460600151856040015161312e565b8252612669565b6001600160a01b038088166000908152609d60209081526040808320938a168352929052205482525b815160000361267757600182525b81516040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b03898116600483015260248201929092526000918716906334d901a490604401608060405180830381865afa1580156126e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127079190613e5f565b90508160000361274c5762093a8080600162093a80846040015161272b9190613e3a565b6127359190613ddf565b61273f9190613d6b565b6127499190613da6565b91505b8260a0015182106127635760009350505050612aca565b826060015182101561277757826060015191505b6040805160808101825260008082526020820181905291810182905260608101829052905b6032811015612a16578460a00151841015612a1657826040015184101580156127ca57506040850151855111155b156128e657845185906127dc90613f46565b9052604080516080810182528451600f90810b825260208087015190910b9082015284820151818301526060808601519082015290860151865191935010156128515760405180608001604052806000600f0b81526020016000600f0b81526020016000815260200160008152509250612a0e565b84516040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b038c811660048301526024820192909252908916906334d901a490604401608060405180830381865afa1580156128bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128df9190613e5f565b9250612a0e565b600060405180606001604052808460400151876129039190613f7e565b815260200160008152602001600081525090508260200151600f0b816000015161292d9190613f9e565b835161293c9190600f0b613f7e565b602082018190526000131561295357600060208201525b6020810151158015612969575060408601518651115b156129745750612a16565b600081602001511380156129955750600085815260a5602052604090205415155b156129fd576001600160a01b038a16600090815260a06020908152604080832088845282528083205484820190815288845260a583529220549151908301516129de9190613da6565b6129e89190613d6b565b866020018181516129f99190613e3a565b9052505b612a0a62093a8086613e3a565b9450505b60010161279c565b50612a35846040015160018660000151612a309190613ddf565b613455565b8085526001600160a01b038a81166000818152609d60209081526040808320948e1680845294825280832095909555828252609c8152848220938252928352839020869055818701518751848901518551928352938201528084019290925291517f9cdcf2f7714cca3508c7f0110b04a90a80a3a8dd0e35de99689db74d28c5383e9181900360600190a25050506020015190505b949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052612b5290849061346d565b505050565b6001606755565b6065546001600160a01b031633146111d15760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612beb57612b5283613555565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612c63575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612c6091810190613e21565b60015b612cd55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610778565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612d6a5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610778565b50612b5283838361362b565b60006001600160a01b038216612d8d575047612e11565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015612dea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0e9190613e21565b90505b6001600160a01b038216600090815260a46020526040812054612e349083613ddf565b6001600160a01b038416600090815260a460209081526040808320869055609e909152812054919250612e678242613ddf565b90506000612e7862093a8042613d6b565b90506000612e8962093a8085613d6b565b612e939083613ddf565b90508015612ee65762093a8080612eaa8187613e3a565b612eb49190613d6b565b612ebe9190613da6565b9350612eca8442613ddf565b9250612ed962093a8085613d6b565b612ee39083613ddf565b90505b60148110612f2b5762093a8080612efe816013613da6565b612f089042613ddf565b612f129190613d6b565b612f1c9190613da6565b9350612f288442613ddf565b92505b6001600160a01b0387166000908152609e6020526040812042905562093a80612f548187613d6b565b612f5e9190613da6565b90506000805b60148110156130de57612f7a62093a8084613e3a565b9150814210156130265785158015612f9157508642145b15612fd4576001600160a01b038a16600090815260a060209081526040808320868452909152812080548a9290612fc9908490613e3a565b909155506130de9050565b85612fdf8842613ddf565b612fe9908a613da6565b612ff39190613d6b565b6001600160a01b038b16600090815260a06020908152604080832087845290915281208054909190612fc9908490613e3a565b8515801561303357508682145b15613076576001600160a01b038a16600090815260a060209081526040808320868452909152812080548a929061306b908490613e3a565b909155506130ce9050565b856130818884613ddf565b61308b908a613da6565b6130959190613d6b565b6001600160a01b038b16600090815260a060209081526040808320878452909152812080549091906130c8908490613e3a565b90915550505b9095508591508190600101612f64565b5060408051428152602081018990526001600160a01b038b16917f6df0a5bed078180e2881e76873c40450711146fa6156da26b23f6eb7d2de8735910160405180910390a2505050505050505050565b60008082815b60808110156132015781831015613201576040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152600284860181010460248301819052916000918b16906334d901a490604401608060405180830381865afa1580156131b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131db9190613e5f565b9050878160400151116131f0578194506131f7565b6001820393505b5050600101613134565b50909695505050505050565b600054610100900460ff1661328a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b606580547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055565b600054610100900460ff16612b575760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b600061333f8383613650565b6040517f8ad4c447000000000000000000000000000000000000000000000000000000008152600481018290529091506000906001600160a01b03851690638ad4c44790602401608060405180830381865afa1580156133a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133c79190613e5f565b9050600081604001518411156133e95760408201516133e69085613f7e565b90505b60008183602001516133fb9190613ed1565b83516134079190613ef8565b9050600081600f0b121561342957600085815260a5602052604081205561344d565b600085815260a5602052604090206fffffffffffffffffffffffffffffffff821690555b505050505050565b60008183106134645781613466565b825b9392505050565b60006134c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661378b9092919063ffffffff16565b90508051600014806134e35750808060200190518101906134e39190613dbd565b612b525760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610778565b6001600160a01b0381163b6135d25760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610778565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6136348361379a565b6000825111806136415750805b15612b525761096283836137da565b6000806000846001600160a01b031663900cf0cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613693573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b79190613e21565b905060005b60808110156137815781831015613781576040517f8ad4c447000000000000000000000000000000000000000000000000000000008152600283850181010460048201819052906000906001600160a01b03891690638ad4c44790602401608060405180830381865afa158015613737573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061375b9190613e5f565b90508681604001511161377057819450613777565b6001820393505b50506001016136bc565b5090949350505050565b6060612aca84846000856137ff565b6137a381613555565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060613466838360405180606001604052806027815260200161407c602791396138f1565b6060824710156138775760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610778565b600080866001600160a01b03168587604051613893919061400e565b60006040518083038185875af1925050503d80600081146138d0576040519150601f19603f3d011682016040523d82523d6000602084013e6138d5565b606091505b50915091506138e687838387613969565b979650505050505050565b6060600080856001600160a01b03168560405161390e919061400e565b600060405180830381855af49150503d8060008114613949576040519150601f19603f3d011682016040523d82523d6000602084013e61394e565b606091505b509150915061395f86838387613969565b9695505050505050565b606083156139d85782516000036139d1576001600160a01b0385163b6139d15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610778565b5081612aca565b612aca83838151156139ed5781518083602001fd5b8060405162461bcd60e51b8152600401610778919061402a565b80356001600160a01b0381168114610bef57600080fd5b60008060408385031215613a3157600080fd5b613a3a83613a07565b946020939093013593505050565b60008060408385031215613a5b57600080fd5b613a6483613a07565b9150613a7260208401613a07565b90509250929050565b600060208284031215613a8d57600080fd5b5035919050565b600080600060608486031215613aa957600080fd5b613ab284613a07565b9250613ac060208501613a07565b9150604084013590509250925092565b600060208284031215613ae257600080fd5b61346682613a07565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613b6157613b61613aeb565b604052919050565b60008060408385031215613b7c57600080fd5b613b8583613a07565b915060208084013567ffffffffffffffff80821115613ba357600080fd5b818601915086601f830112613bb757600080fd5b813581811115613bc957613bc9613aeb565b613bf9847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613b1a565b91508082528784828501011115613c0f57600080fd5b80848401858401376000848284010152508093505050509250929050565b600082601f830112613c3e57600080fd5b60405161028080820182811067ffffffffffffffff82111715613c6357613c63613aeb565b60405283018185821115613c7657600080fd5b845b82811015613c9757613c8981613a07565b825260209182019101613c78565b509195945050505050565b6000806102a08385031215613cb657600080fd5b613cbf83613a07565b9150613a728460208501613c2d565b6000806102a08385031215613ce257600080fd5b613cec8484613c2d565b9150613a726102808401613a07565b6020808252825182820181905260009190848201906040850190845b818110156132015783516001600160a01b031683529284019291840191600101613d17565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082613da1577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b808202811582820484141761102757611027613d3c565b600060208284031215613dcf57600080fd5b8151801515811461346657600080fd5b8181038181111561102757611027613d3c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613e3357600080fd5b5051919050565b8082018082111561102757611027613d3c565b8051600f81900b8114610bef57600080fd5b600060808284031215613e7157600080fd5b6040516080810181811067ffffffffffffffff82111715613e9457613e94613aeb565b604052613ea083613e4d565b8152613eae60208401613e4d565b602082015260408301516040820152606083015160608201528091505092915050565b600082600f0b82600f0b0280600f0b9150808214613ef157613ef1613d3c565b5092915050565b600f82810b9082900b037fffffffffffffffffffffffffffffffff8000000000000000000000000000000081126f7fffffffffffffffffffffffffffffff8213171561102757611027613d3c565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613f7757613f77613d3c565b5060010190565b8181036000831280158383131683831282161715613ef157613ef1613d3c565b808202600082127f800000000000000000000000000000000000000000000000000000000000000084141615613fd657613fd6613d3c565b818105831482151761102757611027613d3c565b60005b83811015614005578181015183820152602001613fed565b50506000910152565b60008251614020818460208701613fea565b9190910192915050565b6020815260008251806020840152614049816040850160208701613fea565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122068bda24ec4f83c2ca97b1182dc4ef855604c58da9bb898ab7eb556d1cf6c158464736f6c63430008130033

Deployed Bytecode

0x60806040526004361061021c5760003560e01c806368662ea01161011d578063c45a0155116100b0578063e1d2bf691161007f578063f364824111610064578063f364824114610679578063f4359ce514610699578063f851a440146106b057600080fd5b8063e1d2bf6914610636578063e855dd071461066357600080fd5b8063c45a0155146105b4578063c50d400d146105d4578063df0ab9d314610601578063e1cebf0b1461061657600080fd5b80638fe8a101116100ec5780638fe8a10114610547578063a186dc081461055d578063aa6ca8081461057d578063b603cd801461059f57600080fd5b806368662ea0146104b75780636e1dc66e146104d75780637d933227146105045780638736659b1461053157600080fd5b80633659cfe6116101b05780634f1ef2861161017f5780634f64b2be116101645780634f64b2be1461046257806352d1902d146104825780636089627f1461049757600080fd5b80634f1ef2861461042f5780634f2bfe5b1461044257600080fd5b80633659cfe61461037f57806338b74b471461039f5780633902b9bc146103d75780634cb654af146103f757600080fd5b80631c03e6cc116101ec5780631c03e6cc146102fa5780631e83409a1461032a57806321c0b3421461034a578063326a94071461036a57600080fd5b8062d440c114610228578063071cb5ad146102735780630f6592ef146102ab5780631794bb3c146102d857600080fd5b3661022357005b600080fd5b34801561023457600080fd5b50610260610243366004613a1e565b60a060209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b34801561027f57600080fd5b5061026061028e366004613a48565b609d60209081526000928352604080842090915290825290205481565b3480156102b757600080fd5b506102606102c6366004613a7b565b60a56020526000908152604090205481565b3480156102e457600080fd5b506102f86102f3366004613a94565b6106d0565b005b34801561030657600080fd5b5061031a610315366004613ad0565b610968565b604051901515815260200161026a565b34801561033657600080fd5b50610260610345366004613ad0565b610bf4565b34801561035657600080fd5b50610260610365366004613a48565b610e0f565b34801561037657600080fd5b506102f861102d565b34801561038b57600080fd5b506102f861039a366004613ad0565b611037565b3480156103ab57600080fd5b506102606103ba366004613a48565b609c60209081526000928352604080842090915290825290205481565b3480156103e357600080fd5b506102f86103f2366004613ad0565b6111d4565b34801561040357600080fd5b50606654610417906001600160a01b031681565b6040516001600160a01b03909116815260200161026a565b6102f861043d366004613b69565b61133b565b34801561044e57600080fd5b5060a154610417906001600160a01b031681565b34801561046e57600080fd5b5061041761047d366004613a7b565b6114c9565b34801561048e57600080fd5b506102606114f3565b3480156104a357600080fd5b5061031a6104b2366004613ca2565b6115b8565b3480156104c357600080fd5b5061031a6104d2366004613ad0565b6118a2565b3480156104e357600080fd5b506102606104f2366004613ad0565b609f6020526000908152604090205481565b34801561051057600080fd5b5061026061051f366004613ad0565b609e6020526000908152604090205481565b34801561053d57600080fd5b50610260609a5481565b34801561055357600080fd5b5061026060a65481565b34801561056957600080fd5b5061031a610578366004613cce565b611ac4565b34801561058957600080fd5b50610592611d41565b60405161026a9190613cfb565b3480156105ab57600080fd5b506102f8611da3565b3480156105c057600080fd5b50609954610417906001600160a01b031681565b3480156105e057600080fd5b506102606105ef366004613ad0565b60a36020526000908152604090205481565b34801561060d57600080fd5b506102f8611ea5565b34801561062257600080fd5b506102f8610631366004613ad0565b611fc5565b34801561064257600080fd5b50610260610651366004613ad0565b60a46020526000908152604090205481565b34801561066f57600080fd5b50610260609b5481565b34801561068557600080fd5b50610260610694366004613a1e565b612085565b3480156106a557600080fd5b5061026062093a8081565b3480156106bc57600080fd5b50606554610417906001600160a01b031681565b600054610100900460ff16158080156106f05750600054600160ff909116105b8061070a5750303b15801561070a575060005460ff166001145b6107815760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156107df57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6107e761221a565b6107ef61229f565b600062093a806107ff8185613d6b565b6108099190613da6565b7fa705961f203609058950cfd817eb7a7627c9e270651c936aad3abdfa253727ec8190557fedae58bba15aea52a58242ef195db2cc4de2b75de265dbb0d58482df22a95978819055609a555060a2805460018082019092557faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d0180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556000805260a36020527f69b4e8f94ad9e612080e13aad01219472d8c2c7ae7aa6cdf175400ddc8c4ed3d9190915560a1805482166001600160a01b038781169190911790915560998054909216908516179055801561096257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6065546000906001600160a01b0316331480610a0457506099546040517f1d59410a0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690631d59410a90602401602060405180830381865afa1580156109e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a049190613dbd565b610a505760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a656400000000000000000000000000000000000000006044820152606401610778565b6001600160a01b038216610aa65760405162461bcd60e51b815260206004820152601960248201527f45544820697320616c72656164792072656769737465726564000000000000006044820152606401610778565b6001600160a01b038216600090815260a3602052604090205415610b0c5760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e20697320616c7265616479207265676973746572656400000000006044820152606401610778565b6001600160a01b0382166000908152609e60205260409020429081905562093a8090610b39908290613d6b565b610b439190613da6565b6001600160a01b0383166000818152609f602090815260408083209490945560a3905282812060019081905560a28054918201815582527faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d0180547fffffffffffffffffffffffff00000000000000000000000000000000000000001683179055915190917f4bbe03be846191383bf3fc4e9dcdc8312ef44d20eec28c2370c51603ba6f80a691a25060015b919050565b6000610bfe612324565b60a65415610c4e5760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a36020526040902054600114610cb65760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a5433904210610cc957610cc961237d565b6001600160a01b038381166000908152609e602052604081205460a15462093a809182900490910292610d01918591889116856124bd565b90508015610e01576001600160a01b038516600090815260a4602052604081208054839290610d31908490613ddf565b90915550506001600160a01b038516610ded576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114610d91576040519150601f19603f3d011682016040523d82523d6000602084013e610d96565b606091505b5050905080610de75760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50610e01565b610e016001600160a01b0386168483612ad2565b92505050610bef6001606755565b6000610e19612324565b60a65415610e695760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a36020526040902054600114610ed15760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a544210610ee257610ee261237d565b6001600160a01b038281166000908152609e602052604081205460a15462093a809182900490910292610f1a918791879116856124bd565b9050801561101a576001600160a01b038416600090815260a4602052604081208054839290610f4a908490613ddf565b90915550506001600160a01b038416611006576000856001600160a01b03168260405160006040518083038185875af1925050503d8060008114610faa576040519150601f19603f3d011682016040523d82523d6000602084013e610faf565b606091505b50509050806110005760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b5061101a565b61101a6001600160a01b0385168683612ad2565b9150506110276001606755565b92915050565b61103561237d565b565b6001600160a01b037f0000000000000000000000001d3d353382540ce14ec850d0920648d9ceb8eebf1630036110d55760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610778565b7f0000000000000000000000001d3d353382540ce14ec850d0920648d9ceb8eebf6001600160a01b03166111307f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146111ac5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610778565b6111b581612b5e565b604080516000808252602082019092526111d191839190612bb8565b50565b6065546001600160a01b031633148061126d57506099546040517f1d59410a0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690631d59410a90602401602060405180830381865afa158015611249573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126d9190613dbd565b6112b95760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a656400000000000000000000000000000000000000006044820152606401610778565b6001600160a01b038116600090815260a360205260409020546001146113215760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a5442106113325761133261237d565b6111d181612d76565b6001600160a01b037f0000000000000000000000001d3d353382540ce14ec850d0920648d9ceb8eebf1630036113d95760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610778565b7f0000000000000000000000001d3d353382540ce14ec850d0920648d9ceb8eebf6001600160a01b03166114347f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146114b05760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610778565b6114b982612b5e565b6114c582826001612bb8565b5050565b60a281815481106114d957600080fd5b6000918252602090912001546001600160a01b0316905081565b6000306001600160a01b037f0000000000000000000000001d3d353382540ce14ec850d0920648d9ceb8eebf16146115935760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610778565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b60006115c2612324565b60a654156116125760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b0383166116685760405162461bcd60e51b815260206004820152601760248201527f416464726573732073686f756c64206e6f74207a65726f0000000000000000006044820152606401610778565b609a5442106116795761167961237d565b601460005b818110156118925760a3600085836014811061169c5761169c613df2565b60200201516001600160a01b03166001600160a01b03168152602001908152602001600020546001146117115760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b600084826014811061172557611725613df2565b602090810291909101516001600160a01b0381166000908152609e90925260409091205490915062093a8061175a8183613d6b565b6117649190613da6565b60a15490915060009061178490899085906001600160a01b0316856124bd565b90508015611884576001600160a01b038316600090815260a46020526040812080548392906117b4908490613ddf565b90915550506001600160a01b038316611870576000886001600160a01b03168260405160006040518083038185875af1925050503d8060008114611814576040519150601f19603f3d011682016040523d82523d6000602084013e611819565b606091505b505090508061186a5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50611884565b6118846001600160a01b0384168983612ad2565b83600101935050505061167e565b5060019150506110276001606755565b6065546000906001600160a01b031633146118ff5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a360205260409020546001146119675760405162461bcd60e51b815260206004820152601960248201527f43616e6e6f74207265636f766572207468697320746f6b656e000000000000006044820152606401610778565b6001600160a01b038216611a1e576065546040516000916001600160a01b03169047908381818185875af1925050503d80600081146119c2576040519150601f19603f3d011682016040523d82523d6000602084013e6119c7565b606091505b5050905080611a185760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50611abc565b6065546040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152611abc916001600160a01b0390811691908516906370a0823190602401602060405180830381865afa158015611a87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aab9190613e21565b6001600160a01b0385169190612ad2565b506001919050565b6000611ace612324565b60a65415611b1e5760405162461bcd60e51b815260206004820152601260248201527f436f6e7472616374206973206b696c6c656400000000000000000000000000006044820152606401610778565b6001600160a01b038216600090815260a36020526040902054600114611b865760405162461bcd60e51b815260206004820152601460248201527f546f6b656e206e6f7420726567697374657265640000000000000000000000006044820152606401610778565b609a544210611b9757611b9761237d565b6001600160a01b0382166000908152609e602052604081205462093a809081900402906014815b81811015611cfb576000878260148110611bda57611bda613df2565b602002015190506001600160a01b038116611bf55750611cfb565b60a154600090611c129083908a906001600160a01b0316896124bd565b90508015611cf157611c248186613e3a565b94506001600160a01b038816611cdd576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611c81576040519150601f19603f3d011682016040523d82523d6000602084013e611c86565b606091505b5050905080611cd75760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b50611cf1565b611cf16001600160a01b0389168383612ad2565b5050600101611bbe565b508115611d30576001600160a01b038516600090815260a4602052604081208054849290611d2a908490613ddf565b90915550505b600193505050506110276001606755565b606060a2805480602002602001604051908101604052809291908181526020018280548015611d9957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d7b575b5050505050905090565b6065546001600160a01b03163314611dfd5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b600160a6556065546040516000916001600160a01b03169047908381818185875af1925050503d8060008114611e4f576040519150601f19603f3d011682016040523d82523d6000602084013e611e54565b606091505b50509050806111d15760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c656400000000000000000000000000000000006044820152606401610778565b6065546001600160a01b03163314611eff5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b6066546001600160a01b031680611f585760405162461bcd60e51b815260206004820152600d60248201527f61646d696e206e6f7420736574000000000000000000000000000000000000006044820152606401610778565b606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527febee2d5739011062cb4f14113f3b36bf0ffe3da5c0568f64189d1012a1189105906020015b60405180910390a150565b6065546001600160a01b0316331461201f5760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b606680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f2f56810a6bf40af059b96d3aea4db54081f378029a518390491093a7b67032e990602001611fba565b60a1546040517f81fc83bb0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526000921690829082906381fc83bb90602401602060405180830381865afa1580156120ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121119190613e21565b905060006121218387878561312e565b6040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018390529192506000918516906334d901a490604401608060405180830381865afa15801561218d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b19190613e5f565b905060008160400151876121c59190613ddf565b82602001516121d49190613ed1565b82516121e09190613ef8565b9050600081600f0b12156121fc57600095505050505050611027565b6fffffffffffffffffffffffffffffffff1694506110279350505050565b600054610100900460ff166122975760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b61103561320d565b600054610100900460ff1661231c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b6110356132b6565b6002606754036123765760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610778565b6002606755565b60a154609a546001600160a01b0390911690600062093a8061239f8142613d6b565b6123a99190613da6565b9050826001600160a01b031663c2c4c5c16040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156123e657600080fd5b505af11580156123fa573d6000803e3d6000fd5b505050506000808311801561240e57508282115b1561241d575062093a80828203045b601481106124405761243362093a806013613da6565b61243d9083613ddf565b92505b600062093a80609a5411612455576000612466565b62093a80609a546124669190613ddf565b905080609b540361247b5761247b8582613333565b60005b60148110156124af578385116124af576124988686613333565b6124a562093a8086613e3a565b945060010161247e565b505042609b555050609a5550565b6000806040518060e001604052806000815260200160008152602001856001600160a01b03166381fc83bb896040518263ffffffff1660e01b815260040161251491906001600160a01b0391909116815260200190565b602060405180830381865afa158015612531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125559190613e21565b81526001600160a01b0387166000908152609f602090815260409182902054908301520162093a806125878142613d6b565b6125919190613da6565b81526020810185905260400162093a80806125ac8188613e3a565b6125b69190613d6b565b6125c09190613da6565b81525090508060c001518160800151106125df5760c081015160a08201525b80604001516000036125f5576000915050612aca565b6001600160a01b038087166000908152609c60209081526040808320938916835292905290812054908190036126405761263985888460600151856040015161312e565b8252612669565b6001600160a01b038088166000908152609d60209081526040808320938a168352929052205482525b815160000361267757600182525b81516040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b03898116600483015260248201929092526000918716906334d901a490604401608060405180830381865afa1580156126e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127079190613e5f565b90508160000361274c5762093a8080600162093a80846040015161272b9190613e3a565b6127359190613ddf565b61273f9190613d6b565b6127499190613da6565b91505b8260a0015182106127635760009350505050612aca565b826060015182101561277757826060015191505b6040805160808101825260008082526020820181905291810182905260608101829052905b6032811015612a16578460a00151841015612a1657826040015184101580156127ca57506040850151855111155b156128e657845185906127dc90613f46565b9052604080516080810182528451600f90810b825260208087015190910b9082015284820151818301526060808601519082015290860151865191935010156128515760405180608001604052806000600f0b81526020016000600f0b81526020016000815260200160008152509250612a0e565b84516040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b038c811660048301526024820192909252908916906334d901a490604401608060405180830381865afa1580156128bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128df9190613e5f565b9250612a0e565b600060405180606001604052808460400151876129039190613f7e565b815260200160008152602001600081525090508260200151600f0b816000015161292d9190613f9e565b835161293c9190600f0b613f7e565b602082018190526000131561295357600060208201525b6020810151158015612969575060408601518651115b156129745750612a16565b600081602001511380156129955750600085815260a5602052604090205415155b156129fd576001600160a01b038a16600090815260a06020908152604080832088845282528083205484820190815288845260a583529220549151908301516129de9190613da6565b6129e89190613d6b565b866020018181516129f99190613e3a565b9052505b612a0a62093a8086613e3a565b9450505b60010161279c565b50612a35846040015160018660000151612a309190613ddf565b613455565b8085526001600160a01b038a81166000818152609d60209081526040808320948e1680845294825280832095909555828252609c8152848220938252928352839020869055818701518751848901518551928352938201528084019290925291517f9cdcf2f7714cca3508c7f0110b04a90a80a3a8dd0e35de99689db74d28c5383e9181900360600190a25050506020015190505b949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052612b5290849061346d565b505050565b6001606755565b6065546001600160a01b031633146111d15760405162461bcd60e51b815260206004820152600a60248201527f61646d696e206f6e6c79000000000000000000000000000000000000000000006044820152606401610778565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612beb57612b5283613555565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015612c63575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612c6091810190613e21565b60015b612cd55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610778565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114612d6a5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610778565b50612b5283838361362b565b60006001600160a01b038216612d8d575047612e11565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015612dea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0e9190613e21565b90505b6001600160a01b038216600090815260a46020526040812054612e349083613ddf565b6001600160a01b038416600090815260a460209081526040808320869055609e909152812054919250612e678242613ddf565b90506000612e7862093a8042613d6b565b90506000612e8962093a8085613d6b565b612e939083613ddf565b90508015612ee65762093a8080612eaa8187613e3a565b612eb49190613d6b565b612ebe9190613da6565b9350612eca8442613ddf565b9250612ed962093a8085613d6b565b612ee39083613ddf565b90505b60148110612f2b5762093a8080612efe816013613da6565b612f089042613ddf565b612f129190613d6b565b612f1c9190613da6565b9350612f288442613ddf565b92505b6001600160a01b0387166000908152609e6020526040812042905562093a80612f548187613d6b565b612f5e9190613da6565b90506000805b60148110156130de57612f7a62093a8084613e3a565b9150814210156130265785158015612f9157508642145b15612fd4576001600160a01b038a16600090815260a060209081526040808320868452909152812080548a9290612fc9908490613e3a565b909155506130de9050565b85612fdf8842613ddf565b612fe9908a613da6565b612ff39190613d6b565b6001600160a01b038b16600090815260a06020908152604080832087845290915281208054909190612fc9908490613e3a565b8515801561303357508682145b15613076576001600160a01b038a16600090815260a060209081526040808320868452909152812080548a929061306b908490613e3a565b909155506130ce9050565b856130818884613ddf565b61308b908a613da6565b6130959190613d6b565b6001600160a01b038b16600090815260a060209081526040808320878452909152812080549091906130c8908490613e3a565b90915550505b9095508591508190600101612f64565b5060408051428152602081018990526001600160a01b038b16917f6df0a5bed078180e2881e76873c40450711146fa6156da26b23f6eb7d2de8735910160405180910390a2505050505050505050565b60008082815b60808110156132015781831015613201576040517f34d901a40000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152600284860181010460248301819052916000918b16906334d901a490604401608060405180830381865afa1580156131b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131db9190613e5f565b9050878160400151116131f0578194506131f7565b6001820393505b5050600101613134565b50909695505050505050565b600054610100900460ff1661328a5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b606580547fffffffffffffffffffffffff00000000000000000000000000000000000000001633179055565b600054610100900460ff16612b575760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610778565b600061333f8383613650565b6040517f8ad4c447000000000000000000000000000000000000000000000000000000008152600481018290529091506000906001600160a01b03851690638ad4c44790602401608060405180830381865afa1580156133a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133c79190613e5f565b9050600081604001518411156133e95760408201516133e69085613f7e565b90505b60008183602001516133fb9190613ed1565b83516134079190613ef8565b9050600081600f0b121561342957600085815260a5602052604081205561344d565b600085815260a5602052604090206fffffffffffffffffffffffffffffffff821690555b505050505050565b60008183106134645781613466565b825b9392505050565b60006134c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661378b9092919063ffffffff16565b90508051600014806134e35750808060200190518101906134e39190613dbd565b612b525760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610778565b6001600160a01b0381163b6135d25760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610778565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6136348361379a565b6000825111806136415750805b15612b525761096283836137da565b6000806000846001600160a01b031663900cf0cf6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613693573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b79190613e21565b905060005b60808110156137815781831015613781576040517f8ad4c447000000000000000000000000000000000000000000000000000000008152600283850181010460048201819052906000906001600160a01b03891690638ad4c44790602401608060405180830381865afa158015613737573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061375b9190613e5f565b90508681604001511161377057819450613777565b6001820393505b50506001016136bc565b5090949350505050565b6060612aca84846000856137ff565b6137a381613555565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060613466838360405180606001604052806027815260200161407c602791396138f1565b6060824710156138775760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610778565b600080866001600160a01b03168587604051613893919061400e565b60006040518083038185875af1925050503d80600081146138d0576040519150601f19603f3d011682016040523d82523d6000602084013e6138d5565b606091505b50915091506138e687838387613969565b979650505050505050565b6060600080856001600160a01b03168560405161390e919061400e565b600060405180830381855af49150503d8060008114613949576040519150601f19603f3d011682016040523d82523d6000602084013e61394e565b606091505b509150915061395f86838387613969565b9695505050505050565b606083156139d85782516000036139d1576001600160a01b0385163b6139d15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610778565b5081612aca565b612aca83838151156139ed5781518083602001fd5b8060405162461bcd60e51b8152600401610778919061402a565b80356001600160a01b0381168114610bef57600080fd5b60008060408385031215613a3157600080fd5b613a3a83613a07565b946020939093013593505050565b60008060408385031215613a5b57600080fd5b613a6483613a07565b9150613a7260208401613a07565b90509250929050565b600060208284031215613a8d57600080fd5b5035919050565b600080600060608486031215613aa957600080fd5b613ab284613a07565b9250613ac060208501613a07565b9150604084013590509250925092565b600060208284031215613ae257600080fd5b61346682613a07565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613b6157613b61613aeb565b604052919050565b60008060408385031215613b7c57600080fd5b613b8583613a07565b915060208084013567ffffffffffffffff80821115613ba357600080fd5b818601915086601f830112613bb757600080fd5b813581811115613bc957613bc9613aeb565b613bf9847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601613b1a565b91508082528784828501011115613c0f57600080fd5b80848401858401376000848284010152508093505050509250929050565b600082601f830112613c3e57600080fd5b60405161028080820182811067ffffffffffffffff82111715613c6357613c63613aeb565b60405283018185821115613c7657600080fd5b845b82811015613c9757613c8981613a07565b825260209182019101613c78565b509195945050505050565b6000806102a08385031215613cb657600080fd5b613cbf83613a07565b9150613a728460208501613c2d565b6000806102a08385031215613ce257600080fd5b613cec8484613c2d565b9150613a726102808401613a07565b6020808252825182820181905260009190848201906040850190845b818110156132015783516001600160a01b031683529284019291840191600101613d17565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082613da1577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b808202811582820484141761102757611027613d3c565b600060208284031215613dcf57600080fd5b8151801515811461346657600080fd5b8181038181111561102757611027613d3c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215613e3357600080fd5b5051919050565b8082018082111561102757611027613d3c565b8051600f81900b8114610bef57600080fd5b600060808284031215613e7157600080fd5b6040516080810181811067ffffffffffffffff82111715613e9457613e94613aeb565b604052613ea083613e4d565b8152613eae60208401613e4d565b602082015260408301516040820152606083015160608201528091505092915050565b600082600f0b82600f0b0280600f0b9150808214613ef157613ef1613d3c565b5092915050565b600f82810b9082900b037fffffffffffffffffffffffffffffffff8000000000000000000000000000000081126f7fffffffffffffffffffffffffffffff8213171561102757611027613d3c565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613f7757613f77613d3c565b5060010190565b8181036000831280158383131683831282161715613ef157613ef1613d3c565b808202600082127f800000000000000000000000000000000000000000000000000000000000000084141615613fd657613fd6613d3c565b818105831482151761102757611027613d3c565b60005b83811015614005578181015183820152602001613fed565b50506000910152565b60008251614020818460208701613fea565b9190910192915050565b6020815260008251806020840152614049816040850160208701613fea565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122068bda24ec4f83c2ca97b1182dc4ef855604c58da9bb898ab7eb556d1cf6c158464736f6c63430008130033

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

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.