{"file_path":"contracts/VotingEscrow.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IVeArtProxy} from \"./interfaces/IVeArtProxy.sol\";\nimport {IVotingEscrow} from \"./interfaces/IVotingEscrow.sol\";\nimport {IVoter} from \"./interfaces/IVoter.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {IERC6372} from \"@openzeppelin/contracts/interfaces/IERC6372.sol\";\nimport {IReward} from \"./interfaces/IReward.sol\";\nimport {IFactoryRegistry} from \"./interfaces/factories/IFactoryRegistry.sol\";\nimport {IManagedRewardsFactory} from \"./interfaces/factories/IManagedRewardsFactory.sol\";\nimport {ERC2771Context} from \"@openzeppelin/contracts/metatx/ERC2771Context.sol\";\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport {DelegationLogicLibrary} from \"./libraries/DelegationLogicLibrary.sol\";\nimport {BalanceLogicLibrary} from \"./libraries/BalanceLogicLibrary.sol\";\n\n/// @title Voting Escrow V2\n/// @notice veNFT implementation that escrows ERC-20 tokens in the form of an ERC-721 NFT\n/// @notice Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for)\n/// @author Modified from Solidly (https://github.com/solidlyexchange/solidly/blob/master/contracts/ve.sol)\n/// @author Modified from Curve (https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/VotingEscrow.vy)\n/// @author velodrome.finance, @figs999, @pegahcarter\n/// @dev Vote weight decays linearly over time. Lock time cannot be more than `MAXTIME` (4 years).\ncontract VotingEscrow is IVotingEscrow, IERC6372, ERC2771Context, ReentrancyGuard {\n    using SafeERC20 for IERC20;\n    /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    address public immutable forwarder;\n    address public immutable factoryRegistry;\n    address public immutable token;\n    address public distributor;\n    address public voter;\n    address public team;\n    address public artProxy;\n    /// @dev address which can create managed NFTs\n    address public allowedManager;\n\n    mapping(uint256 => GlobalPoint) internal _pointHistory; // epoch -> unsigned global point\n\n    /// @dev Mapping of interface id to bool about whether or not it's supported\n    mapping(bytes4 => bool) internal supportedInterfaces;\n\n    /// @dev ERC165 interface ID of ERC165\n    bytes4 internal constant ERC165_INTERFACE_ID = 0x01ffc9a7;\n\n    /// @dev ERC165 interface ID of ERC721\n    bytes4 internal constant ERC721_INTERFACE_ID = 0x80ac58cd;\n\n    /// @dev ERC165 interface ID of ERC721Metadata\n    bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f;\n\n    /// @dev ERC165 interface ID of ERC4906\n    bytes4 internal constant ERC4906_INTERFACE_ID = 0x49064906;\n\n    /// @dev ERC165 interface ID of ERC6372\n    bytes4 internal constant ERC6372_INTERFACE_ID = 0xda287a1d;\n\n    /// @dev Current count of token\n    uint256 public tokenId;\n\n    /// @param _forwarder address of trusted forwarder\n    /// @param _token `VELO` token address\n    /// @param _factoryRegistry Factory Registry address\n    constructor(address _forwarder, address _token, address _factoryRegistry) ERC2771Context(_forwarder) {\n        forwarder = _forwarder;\n        token = _token;\n        factoryRegistry = _factoryRegistry;\n        team = _msgSender();\n        voter = _msgSender();\n\n        _pointHistory[0].blk = block.number;\n        _pointHistory[0].ts = block.timestamp;\n\n        supportedInterfaces[ERC165_INTERFACE_ID] = true;\n        supportedInterfaces[ERC721_INTERFACE_ID] = true;\n        supportedInterfaces[ERC721_METADATA_INTERFACE_ID] = true;\n        supportedInterfaces[ERC4906_INTERFACE_ID] = true;\n        supportedInterfaces[ERC6372_INTERFACE_ID] = true;\n\n        // mint-ish\n        emit Transfer(address(0), address(this), tokenId);\n        // burn-ish\n        emit Transfer(address(this), address(0), tokenId);\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                            MANAGED NFT STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => EscrowType) public escrowType;\n\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => uint256) public idToManaged;\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => mapping(uint256 => uint256)) public weights;\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => bool) public deactivated;\n\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => address) public managedToLocked;\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => address) public managedToFree;\n\n    /*///////////////////////////////////////////////////////////////\n                            MANAGED NFT LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotingEscrow\n    function createManagedLockFor(address _to) external nonReentrant returns (uint256 _mTokenId) {\n        address sender = _msgSender();\n        if (sender != allowedManager && sender != IVoter(voter).governor()) revert NotGovernorOrManager();\n\n        _mTokenId = ++tokenId;\n        _mint(_to, _mTokenId);\n        _depositFor(_mTokenId, 0, 0, LockedBalance(0, 0, true), DepositType.CREATE_LOCK_TYPE);\n\n        escrowType[_mTokenId] = EscrowType.MANAGED;\n\n        (address _lockedManagedReward, address _freeManagedReward) = IManagedRewardsFactory(\n            IFactoryRegistry(factoryRegistry).managedRewardsFactory()\n        ).createRewards(forwarder, voter);\n        managedToLocked[_mTokenId] = _lockedManagedReward;\n        managedToFree[_mTokenId] = _freeManagedReward;\n\n        emit CreateManaged(_to, _mTokenId, sender, _lockedManagedReward, _freeManagedReward);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function depositManaged(uint256 _tokenId, uint256 _mTokenId) external nonReentrant {\n        if (_msgSender() != voter) revert NotVoter();\n        if (escrowType[_mTokenId] != EscrowType.MANAGED) revert NotManagedNFT();\n        if (escrowType[_tokenId] != EscrowType.NORMAL) revert NotNormalNFT();\n        if (_balanceOfNFTAt(_tokenId, block.timestamp) == 0) revert ZeroBalance();\n\n        // adjust user nft\n        int128 _amount = _locked[_tokenId].amount;\n        if (_locked[_tokenId].isPermanent) {\n            permanentLockBalance -= uint256(uint128(_amount));\n            _delegate(_tokenId, 0);\n        }\n        _checkpoint(_tokenId, _locked[_tokenId], LockedBalance(0, 0, false));\n        _locked[_tokenId] = LockedBalance(0, 0, false);\n\n        // adjust managed nft\n        uint256 _weight = uint256(uint128(_amount));\n        permanentLockBalance += _weight;\n        LockedBalance memory newLocked = _locked[_mTokenId];\n        newLocked.amount += _amount;\n        _checkpointDelegatee(_delegates[_mTokenId], uint256(uint128(_amount)), true);\n        _checkpoint(_mTokenId, _locked[_mTokenId], newLocked);\n        _locked[_mTokenId] = newLocked;\n\n        weights[_tokenId][_mTokenId] = _weight;\n        idToManaged[_tokenId] = _mTokenId;\n        escrowType[_tokenId] = EscrowType.LOCKED;\n\n        address _lockedManagedReward = managedToLocked[_mTokenId];\n        IReward(_lockedManagedReward)._deposit(uint256(uint128(_amount)), _tokenId);\n        address _freeManagedReward = managedToFree[_mTokenId];\n        IReward(_freeManagedReward)._deposit(uint256(uint128(_amount)), _tokenId);\n\n        emit DepositManaged(_ownerOf(_tokenId), _tokenId, _mTokenId, _weight, block.timestamp);\n        emit MetadataUpdate(_tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function withdrawManaged(uint256 _tokenId) external nonReentrant {\n        uint256 _mTokenId = idToManaged[_tokenId];\n        if (_msgSender() != voter) revert NotVoter();\n        if (_mTokenId == 0) revert InvalidManagedNFTId();\n        if (escrowType[_tokenId] != EscrowType.LOCKED) revert NotLockedNFT();\n\n        // update accrued rewards\n        address _lockedManagedReward = managedToLocked[_mTokenId];\n        address _freeManagedReward = managedToFree[_mTokenId];\n        uint256 _weight = weights[_tokenId][_mTokenId];\n        uint256 _reward = IReward(_lockedManagedReward).earned(address(token), _tokenId);\n        uint256 _total = _weight + _reward;\n        uint256 _unlockTime = ((block.timestamp + MAXTIME) / WEEK) * WEEK;\n\n        // claim locked rewards (rebases + compounded reward)\n        address[] memory rewards = new address[](1);\n        rewards[0] = address(token);\n        IReward(_lockedManagedReward).getReward(_tokenId, rewards);\n\n        // adjust user nft\n        LockedBalance memory newLockedNormal = LockedBalance(int128(int256(_total)), _unlockTime, false);\n        _checkpoint(_tokenId, _locked[_tokenId], newLockedNormal);\n        _locked[_tokenId] = newLockedNormal;\n\n        // adjust managed nft\n        LockedBalance memory newLockedManaged = _locked[_mTokenId];\n        // do not expect _total > locked.amount / permanentLockBalance but just in case\n        newLockedManaged.amount -= (\n            int128(int256(_total)) < newLockedManaged.amount ? int128(int256(_total)) : newLockedManaged.amount\n        );\n        permanentLockBalance -= (_total < permanentLockBalance ? _total : permanentLockBalance);\n        _checkpointDelegatee(_delegates[_mTokenId], _total, false);\n        _checkpoint(_mTokenId, _locked[_mTokenId], newLockedManaged);\n        _locked[_mTokenId] = newLockedManaged;\n\n        IReward(_lockedManagedReward)._withdraw(uint256(uint128(_weight)), _tokenId);\n        IReward(_freeManagedReward)._withdraw(uint256(uint128(_weight)), _tokenId);\n\n        delete idToManaged[_tokenId];\n        delete weights[_tokenId][_mTokenId];\n        delete escrowType[_tokenId];\n\n        emit WithdrawManaged(_ownerOf(_tokenId), _tokenId, _mTokenId, _total, block.timestamp);\n        emit MetadataUpdate(_tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function setAllowedManager(address _allowedManager) external {\n        if (_msgSender() != IVoter(voter).governor()) revert NotGovernor();\n        if (_allowedManager == allowedManager) revert SameAddress();\n        if (_allowedManager == address(0)) revert ZeroAddress();\n        allowedManager = _allowedManager;\n        emit SetAllowedManager(_allowedManager);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function setManagedState(uint256 _mTokenId, bool _state) external {\n        if (_msgSender() != IVoter(voter).emergencyCouncil() && _msgSender() != IVoter(voter).governor())\n            revert NotEmergencyCouncilOrGovernor();\n        if (escrowType[_mTokenId] != EscrowType.MANAGED) revert NotManagedNFT();\n        if (deactivated[_mTokenId] == _state) revert SameState();\n        deactivated[_mTokenId] = _state;\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                             METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    string public constant name = \"veNFT\";\n    string public constant symbol = \"veNFT\";\n    string public constant version = \"2.0.0\";\n    uint8 public constant decimals = 18;\n\n    function setTeam(address _team) external {\n        if (_msgSender() != team) revert NotTeam();\n        if (_team == address(0)) revert ZeroAddress();\n        team = _team;\n    }\n\n    function setArtProxy(address _proxy) external {\n        if (_msgSender() != team) revert NotTeam();\n        artProxy = _proxy;\n        emit BatchMetadataUpdate(0, type(uint256).max);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function tokenURI(uint256 _tokenId) external view returns (string memory) {\n        if (_ownerOf(_tokenId) == address(0)) revert NonExistentToken();\n        return IVeArtProxy(artProxy).tokenURI(_tokenId);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                      ERC721 BALANCE/OWNER STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @dev Mapping from NFT ID to the address that owns it.\n    mapping(uint256 => address) internal idToOwner;\n\n    /// @dev Mapping from owner address to count of his tokens.\n    mapping(address => uint256) internal ownerToNFTokenCount;\n\n    function _ownerOf(uint256 _tokenId) internal view returns (address) {\n        return idToOwner[_tokenId];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function ownerOf(uint256 _tokenId) external view returns (address) {\n        return _ownerOf(_tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function balanceOf(address _owner) external view returns (uint256) {\n        return ownerToNFTokenCount[_owner];\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                         ERC721 APPROVAL STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @dev Mapping from NFT ID to approved address.\n    mapping(uint256 => address) internal idToApprovals;\n\n    /// @dev Mapping from owner address to mapping of operator addresses.\n    mapping(address => mapping(address => bool)) internal ownerToOperators;\n\n    mapping(uint256 => uint256) internal ownershipChange;\n\n    /// @inheritdoc IVotingEscrow\n    function getApproved(uint256 _tokenId) external view returns (address) {\n        return idToApprovals[_tokenId];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function isApprovedForAll(address _owner, address _operator) external view returns (bool) {\n        return (ownerToOperators[_owner])[_operator];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function isApprovedOrOwner(address _spender, uint256 _tokenId) external view returns (bool) {\n        return _isApprovedOrOwner(_spender, _tokenId);\n    }\n\n    function _isApprovedOrOwner(address _spender, uint256 _tokenId) internal view returns (bool) {\n        address owner = _ownerOf(_tokenId);\n        bool spenderIsOwner = owner == _spender;\n        bool spenderIsApproved = _spender == idToApprovals[_tokenId];\n        bool spenderIsApprovedForAll = (ownerToOperators[owner])[_spender];\n        return spenderIsOwner || spenderIsApproved || spenderIsApprovedForAll;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC721 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotingEscrow\n    function approve(address _approved, uint256 _tokenId) external {\n        address sender = _msgSender();\n        address owner = _ownerOf(_tokenId);\n        // Throws if `_tokenId` is not a valid NFT\n        if (owner == address(0)) revert ZeroAddress();\n        // Throws if `_approved` is the current owner\n        if (owner == _approved) revert SameAddress();\n        // Check requirements\n        bool senderIsOwner = (_ownerOf(_tokenId) == sender);\n        bool senderIsApprovedForAll = (ownerToOperators[owner])[sender];\n        if (!senderIsOwner && !senderIsApprovedForAll) revert NotApprovedOrOwner();\n        // Set the approval\n        idToApprovals[_tokenId] = _approved;\n        emit Approval(owner, _approved, _tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function setApprovalForAll(address _operator, bool _approved) external {\n        address sender = _msgSender();\n        // Throws if `_operator` is the `msg.sender`\n        if (_operator == sender) revert SameAddress();\n        ownerToOperators[sender][_operator] = _approved;\n        emit ApprovalForAll(sender, _operator, _approved);\n    }\n\n    /* TRANSFER FUNCTIONS */\n\n    function _transferFrom(address _from, address _to, uint256 _tokenId, address _sender) internal {\n        if (escrowType[_tokenId] == EscrowType.LOCKED) revert NotManagedOrNormalNFT();\n        // Check requirements\n        if (!_isApprovedOrOwner(_sender, _tokenId)) revert NotApprovedOrOwner();\n        // Clear approval. Throws if `_from` is not the current owner\n        if (_ownerOf(_tokenId) != _from) revert NotOwner();\n        delete idToApprovals[_tokenId];\n        // Remove NFT. Throws if `_tokenId` is not a valid NFT\n        _removeTokenFrom(_from, _tokenId);\n        // Update voting checkpoints\n        _checkpointDelegator(_tokenId, 0, _to);\n        // Add NFT\n        _addTokenTo(_to, _tokenId);\n        // Set the block of ownership transfer (for Flash NFT protection)\n        ownershipChange[_tokenId] = block.number;\n        // Log the transfer\n        emit Transfer(_from, _to, _tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function transferFrom(address _from, address _to, uint256 _tokenId) external {\n        _transferFrom(_from, _to, _tokenId, _msgSender());\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function safeTransferFrom(address _from, address _to, uint256 _tokenId) external {\n        safeTransferFrom(_from, _to, _tokenId, \"\");\n    }\n\n    function _isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) public {\n        address sender = _msgSender();\n        _transferFrom(_from, _to, _tokenId, sender);\n\n        if (_isContract(_to)) {\n            // Throws if transfer destination is a contract which does not implement 'onERC721Received'\n            try IERC721Receiver(_to).onERC721Received(sender, _from, _tokenId, _data) returns (bytes4 response) {\n                if (response != IERC721Receiver(_to).onERC721Received.selector) {\n                    revert ERC721ReceiverRejectedTokens();\n                }\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    revert ERC721TransferToNonERC721ReceiverImplementer();\n                } else {\n                    assembly {\n                        revert(add(32, reason), mload(reason))\n                    }\n                }\n            }\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC165 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotingEscrow\n    function supportsInterface(bytes4 _interfaceID) external view returns (bool) {\n        return supportedInterfaces[_interfaceID];\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotingEscrow\n    mapping(address => mapping(uint256 => uint256)) public ownerToNFTokenIdList;\n\n    /// @dev Mapping from NFT ID to index of owner\n    mapping(uint256 => uint256) internal tokenToOwnerIndex;\n\n    /// @dev Add a NFT to an index mapping to a given address\n    /// @param _to address of the receiver\n    /// @param _tokenId uint ID Of the token to be added\n    function _addTokenToOwnerList(address _to, uint256 _tokenId) internal {\n        uint256 currentCount = ownerToNFTokenCount[_to];\n\n        ownerToNFTokenIdList[_to][currentCount] = _tokenId;\n        tokenToOwnerIndex[_tokenId] = currentCount;\n    }\n\n    /// @dev Add a NFT to a given address\n    ///      Throws if `_tokenId` is owned by someone.\n    function _addTokenTo(address _to, uint256 _tokenId) internal {\n        // Throws if `_tokenId` is owned by someone\n        assert(_ownerOf(_tokenId) == address(0));\n        // Change the owner\n        idToOwner[_tokenId] = _to;\n        // Update owner token index tracking\n        _addTokenToOwnerList(_to, _tokenId);\n        // Change count tracking\n        ownerToNFTokenCount[_to] += 1;\n    }\n\n    /// @dev Function to mint tokens\n    ///      Throws if `_to` is zero address.\n    ///      Throws if `_tokenId` is owned by someone.\n    /// @param _to The address that will receive the minted tokens.\n    /// @param _tokenId The token id to mint.\n    /// @return A boolean that indicates if the operation was successful.\n    function _mint(address _to, uint256 _tokenId) internal returns (bool) {\n        // Throws if `_to` is zero address\n        assert(_to != address(0));\n        // Add NFT. Throws if `_tokenId` is owned by someone\n        _addTokenTo(_to, _tokenId);\n        // Update voting checkpoints\n        _checkpointDelegator(_tokenId, 0, _to);\n        emit Transfer(address(0), _to, _tokenId);\n        return true;\n    }\n\n    /// @dev Remove a NFT from an index mapping to a given address\n    /// @param _from address of the sender\n    /// @param _tokenId uint ID Of the token to be removed\n    function _removeTokenFromOwnerList(address _from, uint256 _tokenId) internal {\n        // Delete\n        uint256 currentCount = ownerToNFTokenCount[_from] - 1;\n        uint256 currentIndex = tokenToOwnerIndex[_tokenId];\n\n        if (currentCount == currentIndex) {\n            // update ownerToNFTokenIdList\n            ownerToNFTokenIdList[_from][currentCount] = 0;\n            // update tokenToOwnerIndex\n            tokenToOwnerIndex[_tokenId] = 0;\n        } else {\n            uint256 lastTokenId = ownerToNFTokenIdList[_from][currentCount];\n\n            // Add\n            // update ownerToNFTokenIdList\n            ownerToNFTokenIdList[_from][currentIndex] = lastTokenId;\n            // update tokenToOwnerIndex\n            tokenToOwnerIndex[lastTokenId] = currentIndex;\n\n            // Delete\n            // update ownerToNFTokenIdList\n            ownerToNFTokenIdList[_from][currentCount] = 0;\n            // update tokenToOwnerIndex\n            tokenToOwnerIndex[_tokenId] = 0;\n        }\n    }\n\n    /// @dev Remove a NFT from a given address\n    ///      Throws if `_from` is not the current owner.\n    function _removeTokenFrom(address _from, uint256 _tokenId) internal {\n        // Throws if `_from` is not the current owner\n        assert(_ownerOf(_tokenId) == _from);\n        // Change the owner\n        idToOwner[_tokenId] = address(0);\n        // Update owner token index tracking\n        _removeTokenFromOwnerList(_from, _tokenId);\n        // Change count tracking\n        ownerToNFTokenCount[_from] -= 1;\n    }\n\n    /// @dev Must be called prior to updating `LockedBalance`\n    function _burn(uint256 _tokenId) internal {\n        address sender = _msgSender();\n        if (!_isApprovedOrOwner(sender, _tokenId)) revert NotApprovedOrOwner();\n        address owner = _ownerOf(_tokenId);\n\n        // Clear approval\n        delete idToApprovals[_tokenId];\n        // Update voting checkpoints\n        _checkpointDelegator(_tokenId, 0, address(0));\n        // Remove token\n        _removeTokenFrom(owner, _tokenId);\n        emit Transfer(owner, address(0), _tokenId);\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                             ESCROW STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 internal constant WEEK = 1 weeks;\n    uint256 internal constant MAXTIME = 4 * 365 * 86400;\n    int128 internal constant iMAXTIME = 4 * 365 * 86400;\n    uint256 internal constant MULTIPLIER = 1 ether;\n\n    uint256 public epoch;\n    uint256 public supply;\n\n    mapping(uint256 => LockedBalance) internal _locked;\n    mapping(uint256 => UserPoint[1000000000]) internal _userPointHistory;\n    mapping(uint256 => uint256) public userPointEpoch;\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => int128) public slopeChanges;\n    mapping(address => bool) public canSplit;\n    /// @notice Aggregate permanent locked balances\n    uint256 public permanentLockBalance;\n\n    /// @inheritdoc IVotingEscrow\n    function locked(uint256 _tokenId) external view returns (LockedBalance memory) {\n        return _locked[_tokenId];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function userPointHistory(uint256 _tokenId, uint256 _loc) external view returns (UserPoint memory) {\n        return _userPointHistory[_tokenId][_loc];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function pointHistory(uint256 _loc) external view returns (GlobalPoint memory) {\n        return _pointHistory[_loc];\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                              ESCROW LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Record global and per-user data to checkpoints. Used by VotingEscrow system.\n    /// @param _tokenId NFT token ID. No user checkpoint if 0\n    /// @param _oldLocked Pevious locked amount / end lock time for the user\n    /// @param _newLocked New locked amount / end lock time for the user\n    function _checkpoint(uint256 _tokenId, LockedBalance memory _oldLocked, LockedBalance memory _newLocked) internal {\n        UserPoint memory uOld;\n        UserPoint memory uNew;\n        int128 oldDslope = 0;\n        int128 newDslope = 0;\n        uint256 _epoch = epoch;\n\n        if (_tokenId != 0) {\n            uNew.permanent = _newLocked.isPermanent ? uint256(int256(_newLocked.amount)) : 0;\n            // Calculate slopes and biases\n            // Kept at zero when they have to\n            if (_oldLocked.end > block.timestamp && _oldLocked.amount > 0) {\n                uOld.slope = _oldLocked.amount / iMAXTIME;\n                uOld.bias = uOld.slope * int128(int256(_oldLocked.end - block.timestamp));\n            }\n            if (_newLocked.end > block.timestamp && _newLocked.amount > 0) {\n                uNew.slope = _newLocked.amount / iMAXTIME;\n                uNew.bias = uNew.slope * int128(int256(_newLocked.end - block.timestamp));\n            }\n\n            // Read values of scheduled changes in the slope\n            // _oldLocked.end can be in the past and in the future\n            // _newLocked.end can ONLY by in the FUTURE unless everything expired: than zeros\n            oldDslope = slopeChanges[_oldLocked.end];\n            if (_newLocked.end != 0) {\n                if (_newLocked.end == _oldLocked.end) {\n                    newDslope = oldDslope;\n                } else {\n                    newDslope = slopeChanges[_newLocked.end];\n                }\n            }\n        }\n\n        GlobalPoint memory lastPoint = GlobalPoint({\n            bias: 0,\n            slope: 0,\n            ts: block.timestamp,\n            blk: block.number,\n            permanentLockBalance: 0\n        });\n        if (_epoch > 0) {\n            lastPoint = _pointHistory[_epoch];\n        }\n        uint256 lastCheckpoint = lastPoint.ts;\n        // initialLastPoint is used for extrapolation to calculate block number\n        // (approximately, for *At methods) and save them\n        // as we cannot figure that out exactly from inside the contract\n        GlobalPoint memory initialLastPoint = GlobalPoint({\n            bias: lastPoint.bias,\n            slope: lastPoint.slope,\n            ts: lastPoint.ts,\n            blk: lastPoint.blk,\n            permanentLockBalance: lastPoint.permanentLockBalance\n        });\n        uint256 blockSlope = 0; // dblock/dt\n        if (block.timestamp > lastPoint.ts) {\n            blockSlope = (MULTIPLIER * (block.number - lastPoint.blk)) / (block.timestamp - lastPoint.ts);\n        }\n        // If last point is already recorded in this block, slope=0\n        // But that's ok b/c we know the block in such case\n\n        // Go over weeks to fill history and calculate what the current point is\n        {\n            uint256 t_i = (lastCheckpoint / WEEK) * WEEK;\n            for (uint256 i = 0; i < 255; ++i) {\n                // Hopefully it won't happen that this won't get used in 5 years!\n                // If it does, users will be able to withdraw but vote weight will be broken\n                t_i += WEEK; // Initial value of t_i is always larger than the ts of the last point\n                int128 d_slope = 0;\n                if (t_i > block.timestamp) {\n                    t_i = block.timestamp;\n                } else {\n                    d_slope = slopeChanges[t_i];\n                }\n                lastPoint.bias -= lastPoint.slope * int128(int256(t_i - lastCheckpoint));\n                lastPoint.slope += d_slope;\n                if (lastPoint.bias < 0) {\n                    // This can happen\n                    lastPoint.bias = 0;\n                }\n                if (lastPoint.slope < 0) {\n                    // This cannot happen - just in case\n                    lastPoint.slope = 0;\n                }\n                lastCheckpoint = t_i;\n                lastPoint.ts = t_i;\n                lastPoint.blk = initialLastPoint.blk + (blockSlope * (t_i - initialLastPoint.ts)) / MULTIPLIER;\n                _epoch += 1;\n                if (t_i == block.timestamp) {\n                    lastPoint.blk = block.number;\n                    break;\n                } else {\n                    _pointHistory[_epoch] = lastPoint;\n                }\n            }\n        }\n\n        if (_tokenId != 0) {\n            // If last point was in this block, the slope change has been applied already\n            // But in such case we have 0 slope(s)\n            lastPoint.slope += (uNew.slope - uOld.slope);\n            lastPoint.bias += (uNew.bias - uOld.bias);\n            if (lastPoint.slope < 0) {\n                lastPoint.slope = 0;\n            }\n            if (lastPoint.bias < 0) {\n                lastPoint.bias = 0;\n            }\n            lastPoint.permanentLockBalance = permanentLockBalance;\n        }\n\n        // If timestamp of last global point is the same, overwrite the last global point\n        // Else record the new global point into history\n        // Exclude epoch 0 (note: _epoch is always >= 1, see above)\n        // Two possible outcomes:\n        // Missing global checkpoints in prior weeks. In this case, _epoch = epoch + x, where x > 1\n        // No missing global checkpoints, but timestamp != block.timestamp. Create new checkpoint.\n        // No missing global checkpoints, but timestamp == block.timestamp. Overwrite last checkpoint.\n        if (_epoch != 1 && _pointHistory[_epoch - 1].ts == block.timestamp) {\n            // _epoch = epoch + 1, so we do not increment epoch\n            _pointHistory[_epoch - 1] = lastPoint;\n        } else {\n            // more than one global point may have been written, so we update epoch\n            epoch = _epoch;\n            _pointHistory[_epoch] = lastPoint;\n        }\n\n        if (_tokenId != 0) {\n            // Schedule the slope changes (slope is going down)\n            // We subtract new_user_slope from [_newLocked.end]\n            // and add old_user_slope to [_oldLocked.end]\n            if (_oldLocked.end > block.timestamp) {\n                // oldDslope was <something> - uOld.slope, so we cancel that\n                oldDslope += uOld.slope;\n                if (_newLocked.end == _oldLocked.end) {\n                    oldDslope -= uNew.slope; // It was a new deposit, not extension\n                }\n                slopeChanges[_oldLocked.end] = oldDslope;\n            }\n\n            if (_newLocked.end > block.timestamp) {\n                // update slope if new lock is greater than old lock and is not permanent or if old lock is permanent\n                if ((_newLocked.end > _oldLocked.end)) {\n                    newDslope -= uNew.slope; // old slope disappeared at this point\n                    slopeChanges[_newLocked.end] = newDslope;\n                }\n                // else: we recorded it already in oldDslope\n            }\n            // If timestamp of last user point is the same, overwrite the last user point\n            // Else record the new user point into history\n            // Exclude epoch 0\n            uNew.ts = block.timestamp;\n            uNew.blk = block.number;\n            uint256 userEpoch = userPointEpoch[_tokenId];\n            if (userEpoch != 0 && _userPointHistory[_tokenId][userEpoch].ts == block.timestamp) {\n                _userPointHistory[_tokenId][userEpoch] = uNew;\n            } else {\n                userPointEpoch[_tokenId] = ++userEpoch;\n                _userPointHistory[_tokenId][userEpoch] = uNew;\n            }\n        }\n    }\n\n    /// @notice Deposit and lock tokens for a user\n    /// @param _tokenId NFT that holds lock\n    /// @param _value Amount to deposit\n    /// @param _unlockTime New time when to unlock the tokens, or 0 if unchanged\n    /// @param _oldLocked Previous locked amount / timestamp\n    /// @param _depositType The type of deposit\n    function _depositFor(\n        uint256 _tokenId,\n        uint256 _value,\n        uint256 _unlockTime,\n        LockedBalance memory _oldLocked,\n        DepositType _depositType\n    ) internal {\n        uint256 supplyBefore = supply;\n        supply = supplyBefore + _value;\n\n        // Set newLocked to _oldLocked without mangling memory\n        LockedBalance memory newLocked;\n        (newLocked.amount, newLocked.end, newLocked.isPermanent) = (\n            _oldLocked.amount,\n            _oldLocked.end,\n            _oldLocked.isPermanent\n        );\n\n        // Adding to existing lock, or if a lock is expired - creating a new one\n        newLocked.amount += int128(int256(_value));\n        if (_unlockTime != 0) {\n            newLocked.end = _unlockTime;\n        }\n        _locked[_tokenId] = newLocked;\n\n        // Possibilities:\n        // Both _oldLocked.end could be current or expired (>/< block.timestamp)\n        // or if the lock is a permanent lock, then _oldLocked.end == 0\n        // value == 0 (extend lock) or value > 0 (add to lock or extend lock)\n        // newLocked.end > block.timestamp (always)\n        _checkpoint(_tokenId, _oldLocked, newLocked);\n\n        address from = _msgSender();\n        if (_value != 0) {\n            IERC20(token).safeTransferFrom(from, address(this), _value);\n        }\n\n        emit Deposit(from, _tokenId, _depositType, _value, newLocked.end, block.timestamp);\n        emit Supply(supplyBefore, supplyBefore + _value);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function checkpoint() external nonReentrant {\n        _checkpoint(0, LockedBalance(0, 0, false), LockedBalance(0, 0, false));\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function depositFor(uint256 _tokenId, uint256 _value) external nonReentrant {\n        if (escrowType[_tokenId] == EscrowType.MANAGED && _msgSender() != distributor) revert NotDistributor();\n        _increaseAmountFor(_tokenId, _value, DepositType.DEPOSIT_FOR_TYPE);\n    }\n\n    /// @dev Deposit `_value` tokens for `_to` and lock for `_lockDuration`\n    /// @param _value Amount to deposit\n    /// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week)\n    /// @param _to Address to deposit\n    function _createLock(uint256 _value, uint256 _lockDuration, address _to) internal returns (uint256) {\n        uint256 unlockTime = ((block.timestamp + _lockDuration) / WEEK) * WEEK; // Locktime is rounded down to weeks\n\n        if (_value == 0) revert ZeroAmount();\n        if (unlockTime <= block.timestamp) revert LockDurationNotInFuture();\n        if (unlockTime > block.timestamp + MAXTIME) revert LockDurationTooLong();\n\n        uint256 _tokenId = ++tokenId;\n        _mint(_to, _tokenId);\n\n        _depositFor(_tokenId, _value, unlockTime, _locked[_tokenId], DepositType.CREATE_LOCK_TYPE);\n        return _tokenId;\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function createLock(uint256 _value, uint256 _lockDuration) external nonReentrant returns (uint256) {\n        return _createLock(_value, _lockDuration, _msgSender());\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function createLockFor(uint256 _value, uint256 _lockDuration, address _to) external nonReentrant returns (uint256) {\n        return _createLock(_value, _lockDuration, _to);\n    }\n\n    function _increaseAmountFor(uint256 _tokenId, uint256 _value, DepositType _depositType) internal {\n        EscrowType _escrowType = escrowType[_tokenId];\n        if (_escrowType == EscrowType.LOCKED) revert NotManagedOrNormalNFT();\n\n        LockedBalance memory oldLocked = _locked[_tokenId];\n\n        if (_value == 0) revert ZeroAmount();\n        if (oldLocked.amount <= 0) revert NoLockFound();\n        if (oldLocked.end <= block.timestamp && !oldLocked.isPermanent) revert LockExpired();\n\n        if (oldLocked.isPermanent) permanentLockBalance += _value;\n        _checkpointDelegatee(_delegates[_tokenId], _value, true);\n        _depositFor(_tokenId, _value, 0, oldLocked, _depositType);\n\n        if (_escrowType == EscrowType.MANAGED) {\n            // increaseAmount called on managed tokens are treated as locked rewards\n            address _lockedManagedReward = managedToLocked[_tokenId];\n            address _token = token;\n            IERC20(_token).safeApprove(_lockedManagedReward, _value);\n            IReward(_lockedManagedReward).notifyRewardAmount(_token, _value);\n            IERC20(_token).safeApprove(_lockedManagedReward, 0);\n        }\n\n        emit MetadataUpdate(_tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function increaseAmount(uint256 _tokenId, uint256 _value) external nonReentrant {\n        if (!_isApprovedOrOwner(_msgSender(), _tokenId)) revert NotApprovedOrOwner();\n        _increaseAmountFor(_tokenId, _value, DepositType.INCREASE_LOCK_AMOUNT);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external nonReentrant {\n        if (!_isApprovedOrOwner(_msgSender(), _tokenId)) revert NotApprovedOrOwner();\n        if (escrowType[_tokenId] != EscrowType.NORMAL) revert NotNormalNFT();\n\n        LockedBalance memory oldLocked = _locked[_tokenId];\n        if (oldLocked.isPermanent) revert PermanentLock();\n        uint256 unlockTime = ((block.timestamp + _lockDuration) / WEEK) * WEEK; // Locktime is rounded down to weeks\n\n        if (oldLocked.end <= block.timestamp) revert LockExpired();\n        if (oldLocked.amount <= 0) revert NoLockFound();\n        if (unlockTime <= oldLocked.end) revert LockDurationNotInFuture();\n        if (unlockTime > block.timestamp + MAXTIME) revert LockDurationTooLong();\n\n        _depositFor(_tokenId, 0, unlockTime, oldLocked, DepositType.INCREASE_UNLOCK_TIME);\n\n        emit MetadataUpdate(_tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function withdraw(uint256 _tokenId) external nonReentrant {\n        address sender = _msgSender();\n        if (!_isApprovedOrOwner(sender, _tokenId)) revert NotApprovedOrOwner();\n        if (voted[_tokenId]) revert AlreadyVoted();\n        if (escrowType[_tokenId] != EscrowType.NORMAL) revert NotNormalNFT();\n\n        LockedBalance memory oldLocked = _locked[_tokenId];\n        if (oldLocked.isPermanent) revert PermanentLock();\n        if (block.timestamp < oldLocked.end) revert LockNotExpired();\n        uint256 value = uint256(int256(oldLocked.amount));\n\n        // Burn the NFT\n        _burn(_tokenId);\n        _locked[_tokenId] = LockedBalance(0, 0, false);\n        uint256 supplyBefore = supply;\n        supply = supplyBefore - value;\n\n        // oldLocked can have either expired <= timestamp or zero end\n        // oldLocked has only 0 end\n        // Both can have >= 0 amount\n        _checkpoint(_tokenId, oldLocked, LockedBalance(0, 0, false));\n\n        IERC20(token).safeTransfer(sender, value);\n\n        emit Withdraw(sender, _tokenId, value, block.timestamp);\n        emit Supply(supplyBefore, supplyBefore - value);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function merge(uint256 _from, uint256 _to) external nonReentrant {\n        address sender = _msgSender();\n        if (voted[_from]) revert AlreadyVoted();\n        if (escrowType[_from] != EscrowType.NORMAL) revert NotNormalNFT();\n        if (escrowType[_to] != EscrowType.NORMAL) revert NotNormalNFT();\n        if (_from == _to) revert SameNFT();\n        if (!_isApprovedOrOwner(sender, _from)) revert NotApprovedOrOwner();\n        if (!_isApprovedOrOwner(sender, _to)) revert NotApprovedOrOwner();\n        LockedBalance memory oldLockedTo = _locked[_to];\n        if (oldLockedTo.end <= block.timestamp && !oldLockedTo.isPermanent) revert LockExpired();\n\n        LockedBalance memory oldLockedFrom = _locked[_from];\n        if (oldLockedFrom.isPermanent) revert PermanentLock();\n        uint256 end = oldLockedFrom.end >= oldLockedTo.end ? oldLockedFrom.end : oldLockedTo.end;\n\n        _burn(_from);\n        _locked[_from] = LockedBalance(0, 0, false);\n        _checkpoint(_from, oldLockedFrom, LockedBalance(0, 0, false));\n\n        LockedBalance memory newLockedTo;\n        newLockedTo.amount = oldLockedTo.amount + oldLockedFrom.amount;\n        newLockedTo.isPermanent = oldLockedTo.isPermanent;\n        if (newLockedTo.isPermanent) {\n            permanentLockBalance += uint256(int256(oldLockedFrom.amount));\n        } else {\n            newLockedTo.end = end;\n        }\n        _checkpointDelegatee(_delegates[_to], uint256(int256(oldLockedFrom.amount)), true);\n        _checkpoint(_to, oldLockedTo, newLockedTo);\n        _locked[_to] = newLockedTo;\n\n        emit Merge(\n            sender,\n            _from,\n            _to,\n            uint256(uint128(oldLockedFrom.amount)),\n            uint256(uint128(oldLockedTo.amount)),\n            uint256(uint128(newLockedTo.amount)),\n            uint256(uint128(newLockedTo.end)),\n            block.timestamp\n        );\n        emit MetadataUpdate(_to);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function split(\n        uint256 _from,\n        uint256 _amount\n    ) external nonReentrant returns (uint256 _tokenId1, uint256 _tokenId2) {\n        address sender = _msgSender();\n        address owner = _ownerOf(_from);\n        if (owner == address(0)) revert SplitNoOwner();\n        if (!canSplit[owner] && !canSplit[address(0)]) revert SplitNotAllowed();\n        if (escrowType[_from] != EscrowType.NORMAL) revert NotNormalNFT();\n        if (voted[_from]) revert AlreadyVoted();\n        if (!_isApprovedOrOwner(sender, _from)) revert NotApprovedOrOwner();\n        LockedBalance memory newLocked = _locked[_from];\n        if (newLocked.end <= block.timestamp && !newLocked.isPermanent) revert LockExpired();\n        int128 _splitAmount = int128(int256(_amount));\n        if (_splitAmount == 0) revert ZeroAmount();\n        if (newLocked.amount <= _splitAmount) revert AmountTooBig();\n\n        // Zero out and burn old veNFT\n        _burn(_from);\n        _locked[_from] = LockedBalance(0, 0, false);\n        _checkpoint(_from, newLocked, LockedBalance(0, 0, false));\n\n        // Create new veNFT using old balance - amount\n        newLocked.amount -= _splitAmount;\n        _tokenId1 = _createSplitNFT(owner, newLocked);\n\n        // Create new veNFT using amount\n        newLocked.amount = _splitAmount;\n        _tokenId2 = _createSplitNFT(owner, newLocked);\n\n        emit Split(\n            _from,\n            _tokenId1,\n            _tokenId2,\n            sender,\n            uint256(uint128(_locked[_tokenId1].amount)),\n            uint256(uint128(_splitAmount)),\n            uint256(uint128(newLocked.end)),\n            block.timestamp\n        );\n    }\n\n    function _createSplitNFT(address _to, LockedBalance memory _newLocked) private returns (uint256 _tokenId) {\n        _tokenId = ++tokenId;\n        _locked[_tokenId] = _newLocked;\n        _checkpoint(_tokenId, LockedBalance(0, 0, false), _newLocked);\n        _mint(_to, _tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function toggleSplit(address _account, bool _bool) external {\n        if (_msgSender() != team) revert NotTeam();\n        canSplit[_account] = _bool;\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function lockPermanent(uint256 _tokenId) external {\n        address sender = _msgSender();\n        if (!_isApprovedOrOwner(sender, _tokenId)) revert NotApprovedOrOwner();\n        if (escrowType[_tokenId] != EscrowType.NORMAL) revert NotNormalNFT();\n        LockedBalance memory _newLocked = _locked[_tokenId];\n        if (_newLocked.isPermanent) revert PermanentLock();\n        if (_newLocked.end <= block.timestamp) revert LockExpired();\n        if (_newLocked.amount <= 0) revert NoLockFound();\n\n        uint256 _amount = uint256(int256(_newLocked.amount));\n        permanentLockBalance += _amount;\n        _newLocked.end = 0;\n        _newLocked.isPermanent = true;\n        _checkpoint(_tokenId, _locked[_tokenId], _newLocked);\n        _locked[_tokenId] = _newLocked;\n\n        emit LockPermanent(sender, _tokenId, _amount, block.timestamp);\n        emit MetadataUpdate(_tokenId);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function unlockPermanent(uint256 _tokenId) external {\n        address sender = _msgSender();\n        if (!_isApprovedOrOwner(sender, _tokenId)) revert NotApprovedOrOwner();\n        if (escrowType[_tokenId] != EscrowType.NORMAL) revert NotNormalNFT();\n        if (voted[_tokenId]) revert AlreadyVoted();\n        LockedBalance memory _newLocked = _locked[_tokenId];\n        if (!_newLocked.isPermanent) revert NotPermanentLock();\n\n        uint256 _amount = uint256(int256(_newLocked.amount));\n        permanentLockBalance -= _amount;\n        _newLocked.end = ((block.timestamp + MAXTIME) / WEEK) * WEEK;\n        _newLocked.isPermanent = false;\n        _delegate(_tokenId, 0);\n        _checkpoint(_tokenId, _locked[_tokenId], _newLocked);\n        _locked[_tokenId] = _newLocked;\n\n        emit UnlockPermanent(sender, _tokenId, _amount, block.timestamp);\n        emit MetadataUpdate(_tokenId);\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                           GAUGE VOTING STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    function _balanceOfNFTAt(uint256 _tokenId, uint256 _t) internal view returns (uint256) {\n        return BalanceLogicLibrary.balanceOfNFTAt(userPointEpoch, _userPointHistory, _tokenId, _t);\n    }\n\n    function _supplyAt(uint256 _timestamp) internal view returns (uint256) {\n        return BalanceLogicLibrary.supplyAt(slopeChanges, _pointHistory, epoch, _timestamp);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function balanceOfNFT(uint256 _tokenId) public view returns (uint256) {\n        if (ownershipChange[_tokenId] == block.number) return 0;\n        return _balanceOfNFTAt(_tokenId, block.timestamp);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function balanceOfNFTAt(uint256 _tokenId, uint256 _t) external view returns (uint256) {\n        return _balanceOfNFTAt(_tokenId, _t);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function totalSupply() external view returns (uint256) {\n        return _supplyAt(block.timestamp);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function totalSupplyAt(uint256 _timestamp) external view returns (uint256) {\n        return _supplyAt(_timestamp);\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                            GAUGE VOTING LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => bool) public voted;\n\n    /// @inheritdoc IVotingEscrow\n    function setVoterAndDistributor(address _voter, address _distributor) external {\n        if (_msgSender() != voter) revert NotVoter();\n        voter = _voter;\n        distributor = _distributor;\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function voting(uint256 _tokenId, bool _voted) external {\n        if (_msgSender() != voter) revert NotVoter();\n        voted[_tokenId] = _voted;\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                            DAO VOTING STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice The EIP-712 typehash for the contract's domain\n    bytes32 public constant DOMAIN_TYPEHASH =\n        keccak256(\"EIP712Domain(string name,uint256 chainId,address verifyingContract)\");\n\n    /// @notice The EIP-712 typehash for the delegation struct used by the contract\n    bytes32 public constant DELEGATION_TYPEHASH =\n        keccak256(\"Delegation(uint256 delegator,uint256 delegatee,uint256 nonce,uint256 expiry)\");\n\n    /// @notice A record of each accounts delegate\n    mapping(uint256 => uint256) private _delegates;\n\n    /// @notice A record of delegated token checkpoints for each tokenId, by index\n    mapping(uint256 => mapping(uint48 => Checkpoint)) private _checkpoints;\n\n    /// @inheritdoc IVotingEscrow\n    mapping(uint256 => uint48) public numCheckpoints;\n\n    /// @inheritdoc IVotingEscrow\n    mapping(address => uint256) public nonces;\n\n    /// @inheritdoc IVotingEscrow\n    function delegates(uint256 delegator) external view returns (uint256) {\n        return _delegates[delegator];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function checkpoints(uint256 _tokenId, uint48 _index) external view returns (Checkpoint memory) {\n        return _checkpoints[_tokenId][_index];\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function getPastVotes(address _account, uint256 _tokenId, uint256 _timestamp) external view returns (uint256) {\n        return DelegationLogicLibrary.getPastVotes(numCheckpoints, _checkpoints, _account, _tokenId, _timestamp);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function getPastTotalSupply(uint256 _timestamp) external view returns (uint256) {\n        return _supplyAt(_timestamp);\n    }\n\n    /*///////////////////////////////////////////////////////////////\n                             DAO VOTING LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _checkpointDelegator(uint256 _delegator, uint256 _delegatee, address _owner) internal {\n        DelegationLogicLibrary.checkpointDelegator(\n            _locked,\n            numCheckpoints,\n            _checkpoints,\n            _delegates,\n            _delegator,\n            _delegatee,\n            _owner\n        );\n    }\n\n    function _checkpointDelegatee(uint256 _delegatee, uint256 balance_, bool _increase) internal {\n        DelegationLogicLibrary.checkpointDelegatee(numCheckpoints, _checkpoints, _delegatee, balance_, _increase);\n    }\n\n    /// @notice Record user delegation checkpoints. Used by voting system.\n    /// @dev Skips delegation if already delegated to `delegatee`.\n    function _delegate(uint256 _delegator, uint256 _delegatee) internal {\n        LockedBalance memory delegateLocked = _locked[_delegator];\n        if (!delegateLocked.isPermanent) revert NotPermanentLock();\n        if (_delegatee != 0 && _ownerOf(_delegatee) == address(0)) revert NonExistentToken();\n        if (ownershipChange[_delegator] == block.number) revert OwnershipChange();\n        if (_delegatee == _delegator) _delegatee = 0;\n        uint256 currentDelegate = _delegates[_delegator];\n        if (currentDelegate == _delegatee) return;\n\n        uint256 delegatedBalance = uint256(uint128(delegateLocked.amount));\n        _checkpointDelegator(_delegator, _delegatee, _ownerOf(_delegator));\n        _checkpointDelegatee(_delegatee, delegatedBalance, true);\n\n        emit DelegateChanged(_msgSender(), currentDelegate, _delegatee);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function delegate(uint256 delegator, uint256 delegatee) external {\n        if (!_isApprovedOrOwner(_msgSender(), delegator)) revert NotApprovedOrOwner();\n        return _delegate(delegator, delegatee);\n    }\n\n    /// @inheritdoc IVotingEscrow\n    function delegateBySig(\n        uint256 delegator,\n        uint256 delegatee,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) revert InvalidSignatureS();\n        bytes32 domainSeparator = keccak256(\n            abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), keccak256(bytes(version)), block.chainid, address(this))\n        );\n        bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegator, delegatee, nonce, expiry));\n        bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n        address signatory = ecrecover(digest, v, r, s);\n        if (!_isApprovedOrOwner(signatory, delegator)) revert NotApprovedOrOwner();\n        if (signatory == address(0)) revert InvalidSignature();\n        if (nonce != nonces[signatory]++) revert InvalidNonce();\n        if (block.timestamp > expiry) revert SignatureExpired();\n        return _delegate(delegator, delegatee);\n    }\n\n    function clock() external view returns (uint48) {\n        return uint48(block.timestamp);\n    }\n\n    function CLOCK_MODE() external view returns (string memory) {\n        return \"mode=timestamp\";\n    }\n}\n","deployed_bytecode":"0x608060405234801561001057600080fd5b50600436106104805760003560e01c806370a0823111610257578063b45a3c0e11610146578063e58f5947116100c3578063ec32e6df11610087578063ec32e6df14610ca7578063f04cb3a814610cba578063f52a36f714610d09578063f645d4f914610d3f578063fc0c546a14610d6657600080fd5b8063e58f594714610bfe578063e75b1c2e14610c1e578063e7a324dc14610c31578063e7e242d414610c58578063e985e9c514610c6b57600080fd5b8063c87b56dd1161010a578063c87b56dd14610b9f578063d1c2babb14610bb2578063d9a3495214610bc5578063e0514aba14610bd8578063e0c11f9a14610beb57600080fd5b8063b45a3c0e14610ad6578063b52c05fe14610b5e578063b88d4fde14610b71578063bfe1092814610b84578063c2c4c5c114610b9757600080fd5b806391ddadf4116101d4578063a22cb46511610198578063a22cb46514610a44578063a738da8214610a57578063a899b36c14610a80578063b1548afc14610aa3578063b2383e5514610ac357600080fd5b806391ddadf414610a1857806395d89b41146104de578063981b24d0146109d95780639954a98914610a1e5780639d507b8b14610a3157600080fd5b80638ad4c4471161021b5780638ad4c4471461099b5780638bf9d84c146109ae5780638e539e8c146109d95780638fbb38ff146109ec578063900cf0cf14610a0f57600080fd5b806370a08231146108fc5780637c728000146109255780637ecebe0014610955578063834b0b691461097557806385f2aef21461098857600080fd5b8063370fb5fa116103735780634bf5d7e9116102f057806354fd4d50116102b457806354fd4d501461085f5780635594a04514610883578063572b6c05146108965780635a4f459a146108d65780636352211e146108e957600080fd5b80634bf5d7e9146107af5780634d01cb66146107d95780634d6fb775146107e257806350589793146107f5578063515857d41461083457600080fd5b806342842e0e1161033757806342842e0e1461072e578063430c20811461074157806344acb42a1461075457806346c96aac146107745780634b19becc1461078757600080fd5b8063370fb5fa146106ab57806337b1f500146106be5780633a6396a5146106d15780633bf0c9fb146106e45780633d085a371461070b57600080fd5b806320606b70116104015780632e720f7d116103c55780632e720f7d146106455780632f7f9ba914610658578063313ce5671461066b57806333230dc01461068557806335b0f6bd1461069857600080fd5b806320606b70146105bc57806323b872dd146105e357806327a6ee98146105f65780632d0485ec1461061f5780632e1a7d4d1461063257600080fd5b8063095ea7b311610448578063095ea7b3146105655780630ec84dda1461057857806317d70f7c1461058b57806318160ddd1461059457806319a0a9d51461059c57600080fd5b806301ffc9a714610485578063047fc9aa146104c757806306fdde03146104de578063081812fc1461050f578063095cf5c614610550575b600080fd5b6104b261049336600461569c565b6001600160e01b03191660009081526007602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6104d060175481565b6040519081526020016104be565b610502604051806040016040528060058152602001641d9953919560da1b81525081565b6040516104be9190615709565b61053861051d36600461571c565b6000908152601160205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016104be565b61056361055e36600461574a565b610d8d565b005b610563610573366004615767565b610e11565b610563610586366004615793565b610f52565b6104d060085481565b6104d0610fdf565b6104d06105aa36600461571c565b600a6020526000908152604090205481565b6104d07f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6105636105f13660046157b5565b610fef565b61053861060436600461571c565b600e602052600090815260409020546001600160a01b031681565b61056361062d3660046157f6565b611007565b61056361064036600461571c565b611070565b61056361065336600461574a565b611315565b600554610538906001600160a01b031681565b610673601281565b60405160ff90911681526020016104be565b61056361069336600461583d565b6113a9565b6105636106a636600461571c565b61140f565b6105636106b936600461571c565b611676565b6105636106cc36600461586b565b611c98565b6104d06106df36600461574a565b611e7e565b6105387f000000000000000000000000f4c67cdeaab8360370f41514d06e32ccd8aa1d7b81565b6104b261071936600461574a565b601c6020526000908152604090205460ff1681565b61056361073c3660046157b5565b61217d565b6104b261074f366004615767565b612198565b610767610762366004615793565b6121ad565b6040516104be9190615890565b600254610538906001600160a01b031681565b61079a610795366004615793565b61222b565b604080519283526020830191909152016104be565b60408051808201909152600e81526d06d6f64653d74696d657374616d760941b6020820152610502565b6104d0601d5481565b6104d06107f03660046158cf565b612591565b61081d61080336600461571c565b60216020526000908152604090205465ffffffffffff1681565b60405165ffffffffffff90911681526020016104be565b6104d0610842366004615793565b600b60209081526000928352604080842090915290825290205481565b610502604051806040016040528060058152602001640322e302e360dc1b81525081565b600454610538906001600160a01b031681565b6104b26108a436600461574a565b7f00000000000000000000000006824df38d1d77eadeb6bafcb03904e27429ab746001600160a01b0390811691161490565b6105636108e436600461586b565b612636565b6105386108f736600461571c565b612691565b6104d061090a36600461574a565b6001600160a01b031660009081526010602052604090205490565b61094861093336600461571c565b60096020526000908152604090205460ff1681565b6040516104be919061591a565b6104d061096336600461574a565b60226020526000908152604090205481565b610563610983366004615942565b61269c565b600354610538906001600160a01b031681565b6107676109a936600461571c565b612976565b6104d06109bc366004615767565b601460209081526000928352604080842090915290825290205481565b6104d06109e736600461571c565b612a07565b6104b26109fa36600461571c565b601e6020526000908152604090205460ff1681565b6104d060165481565b4261081d565b610563610a2c36600461574a565b612a12565b610563610a3f366004615793565b612b61565b610563610a5236600461583d565b612d35565b610538610a6536600461571c565b600d602052600090815260409020546001600160a01b031681565b6104b2610a8e36600461571c565b600c6020526000908152604090205460ff1681565b6104d0610ab136600461571c565b6000908152601f602052604090205490565b610563610ad1366004615793565b612de0565b610b37610ae436600461571c565b6040805160608082018352600080835260208084018290529284018190529384526018825292829020825193840183528054600f0b84526001810154918401919091526002015460ff1615159082015290565b604080518251600f0b815260208084015190820152918101511515908201526060016104be565b6104d0610b6c366004615793565b612e1c565b610563610b7f366004615a16565b612e44565b600154610538906001600160a01b031681565b610563612f67565b610502610bad36600461571c565b612fb9565b610563610bc0366004615793565b61305c565b610563610bd3366004615793565b61348c565b6104d0610be6366004615793565b6134be565b610563610bf9366004615793565b6134ca565b6104d0610c0c36600461571c565b601a6020526000908152604090205481565b610563610c2c36600461571c565b61398d565b6104d07f9947d5709c1682eaa3946b2d84115c9c0d1c946b149d76e69b457458b42ea29e81565b6104d0610c6636600461571c565b613bb4565b6104b2610c793660046157f6565b6001600160a01b03918216600090815260126020908152604080832093909416825291909152205460ff1690565b6104d0610cb5366004615ac5565b613bdc565b610ccd610cc8366004615afe565b613bfd565b6040516104be9190815181526020808301516001600160a01b031690820152604080830151908201526060918201519181019190915260800190565b610d2c610d1736600461571c565b601b60205260009081526040902054600f0b81565b604051600f9190910b81526020016104be565b6105387f00000000000000000000000006824df38d1d77eadeb6bafcb03904e27429ab7481565b6105387f0000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db81565b6003546001600160a01b0316610da1613c8e565b6001600160a01b031614610dc857604051633a7cfa5d60e21b815260040160405180910390fd5b6001600160a01b038116610def5760405163d92e233d60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e1b613c8e565b90506000610e2883613cd2565b90506001600160a01b038116610e515760405163d92e233d60e01b815260040160405180910390fd5b836001600160a01b0316816001600160a01b031603610e835760405163367558c360e01b815260040160405180910390fd5b6000826001600160a01b0316610e9885613cd2565b6001600160a01b0384811660009081526012602090815260408083208985168452909152902054911691909114915060ff16811582610ed5575080155b15610ef35760405163390cdd9b60e21b815260040160405180910390fd5b60008581526011602052604080822080546001600160a01b0319166001600160a01b038a811691821790925591518893918716917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050505050565b610f5a613ced565b600260008381526009602052604090205460ff166002811115610f7f57610f7f615904565b148015610fa757506001546001600160a01b0316610f9b613c8e565b6001600160a01b031614155b15610fc55760405163385296d560e01b815260040160405180910390fd5b610fd182826000613d4b565b610fdb6001600055565b5050565b6000610fea42613f96565b905090565b611002838383610ffd613c8e565b614026565b505050565b6002546001600160a01b031661101b613c8e565b6001600160a01b0316146110425760405163c18384c160e01b815260040160405180910390fd5b600280546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b611078613ced565b6000611082613c8e565b905061108e8183614154565b6110ab5760405163390cdd9b60e21b815260040160405180910390fd5b6000828152601e602052604090205460ff16156110db57604051637c9a1cf960e01b815260040160405180910390fd5b60008281526009602052604081205460ff1660028111156110fe576110fe615904565b1461111c576040516317a66f3760e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161580159282019290925290611178576040516334d10f9560e11b815260040160405180910390fd5b806020015142101561119d5760405163342ad40160e11b815260040160405180910390fd5b8051600f0b6111ab846141be565b6040805160608101825260008082526020808301828152838501838152898452601890925293909120915182546001600160801b0319166001600160801b039091161782559151600182015590516002909101805460ff191691151591909117905560175461121a8282615b44565b6017556040805160608101825260008082526020820181905291810191909152611247908690859061426e565b61127b6001600160a01b037f0000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db168584614a27565b6040805183815242602082015286916001600160a01b038716917f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94910160405180910390a37f5e2aa66efd74cce82b21852e317e5490d9ecc9e6bb953ae24d90851258cc2f5c816112ec8482615b44565b6040805192835260208301919091520160405180910390a1505050506113126001600055565b50565b6003546001600160a01b0316611329613c8e565b6001600160a01b03161461135057604051633a7cfa5d60e21b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b038316179055604080516000815260001960208201527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c910160405180910390a150565b6003546001600160a01b03166113bd613c8e565b6001600160a01b0316146113e457604051633a7cfa5d60e21b815260040160405180910390fd5b6001600160a01b03919091166000908152601c60205260409020805460ff1916911515919091179055565b6000611419613c8e565b90506114258183614154565b6114425760405163390cdd9b60e21b815260040160405180910390fd5b60008281526009602052604081205460ff16600281111561146557611465615904565b14611483576040516317a66f3760e01b815260040160405180910390fd5b6000828152601e602052604090205460ff16156114b357604051637c9a1cf960e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff1615159181018290529061150d57604051632188f8ab60e01b815260040160405180910390fd5b60008160000151600f0b905080601d600082825461152b9190615b44565b9091555062093a80905080611544630784ce0042615b57565b61154e9190615b80565b6115589190615b94565b6020830152600060408301819052611571908590614a8a565b60008481526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161515918101919091526115ba9085908461426e565b600084815260186020908152604091829020845181546001600160801b0319166001600160801b03909116178155848201516001820155848301516002909101805460ff19169115159190911790558151838152429181019190915285916001600160a01b038616917f668d293c0a181c1f163fd0d3c757239a9c17bd26c5e483150e374455433b27fa91015b60405180910390a3604051848152600080516020615e668339815191529060200160405180910390a150505050565b61167e613ced565b6000818152600a60205260409020546002546001600160a01b03166116a1613c8e565b6001600160a01b0316146116c85760405163c18384c160e01b815260040160405180910390fd5b806000036116e95760405163d7caa26160e01b815260040160405180910390fd5b600160008381526009602052604090205460ff16600281111561170e5761170e615904565b1461172c57604051630fd82f7760e11b815260040160405180910390fd5b6000818152600d6020908152604080832054600e835281842054868552600b8452828520868652909352818420549151633e491d4760e01b81526001600160a01b037f0000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db81166004830152602482018890529182169491909316928490633e491d4790604401602060405180830381865afa1580156117ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f29190615bab565b905060006118008284615b57565b9050600062093a8080611817630784ce0042615b57565b6118219190615b80565b61182b9190615b94565b60408051600180825281830190925291925060009190602080830190803683370190505090507f0000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db8160008151811061188557611885615bc4565b6001600160a01b03928316602091820292909201015260405163f5f8d36560e01b81529088169063f5f8d365906118c2908c908590600401615bda565b600060405180830381600087803b1580156118dc57600080fd5b505af11580156118f0573d6000803e3d6000fd5b505050506000604051806060016040528085600f0b81526020018481526020016000151581525090506119838a601860008d81526020019081526020016000206040518060600160405290816000820160009054906101000a9004600f0b600f0b600f0b8152602001600182015481526020016002820160009054906101000a900460ff1615151515815250508361426e565b60008a8152601860209081526040808320845181546001600160801b0319166001600160801b0390911617815584830151600180830191909155858301516002928301805460ff19169115159190911790558d85529382902082516060810184528154600f90810b808352968301549582019590955291015460ff16151591810191909152919086900b12611a19578051611a1b565b845b81518290611a2a908390615c31565b600f0b905250601d548510611a4157601d54611a43565b845b601d6000828254611a549190615b44565b909155505060008a8152601f6020526040812054611a73918790614be9565b60008a81526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff16151591810191909152611abc908b908361426e565b60008a815260186020908152604091829020835181546001600160801b0319166001600160801b03918216178255918401516001820155838301516002909101805460ff1916911515919091179055905163278afc8b60e21b81529088166004820152602481018c90526001600160a01b038a1690639e2bf22c90604401600060405180830381600087803b158015611b5457600080fd5b505af1158015611b68573d6000803e3d6000fd5b505060405163278afc8b60e21b81526001600160801b038a166004820152602481018e90526001600160a01b038b169250639e2bf22c9150604401600060405180830381600087803b158015611bbd57600080fd5b505af1158015611bd1573d6000803e3d6000fd5b50505060008c8152600a60209081526040808320839055600b82528083208e845282528083208390558e835260099091529020805460ff1916905550898b611c1881613cd2565b6001600160a01b03167f5319474ec1e9d118585a40e615ea37be254007e6bb5b039756c3813c2d1354898842604051611c5b929190918252602082015260400190565b60405180910390a46040518b8152600080516020615e668339815191529060200160405180910390a1505050505050505050506113126001600055565b600260009054906101000a90046001600160a01b03166001600160a01b0316637778960e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ceb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d0f9190615c5e565b6001600160a01b0316611d20613c8e565b6001600160a01b031614158015611dc65750600260009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da99190615c5e565b6001600160a01b0316611dba613c8e565b6001600160a01b031614155b15611de45760405163459d6a3f60e01b815260040160405180910390fd5b600260008381526009602052604090205460ff166002811115611e0957611e09615904565b14611e275760405163054b1e0160e51b815260040160405180910390fd5b6000828152600c602052604090205481151560ff909116151503611e5e57604051631490ad1160e01b815260040160405180910390fd5b6000918252600c6020526040909120805460ff1916911515919091179055565b6000611e88613ced565b6000611e92613c8e565b6005549091506001600160a01b03808316911614801590611f3b5750600260009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f259190615c5e565b6001600160a01b0316816001600160a01b031614155b15611f5957604051633bc1d15f60e01b815260040160405180910390fd5b600860008154611f6890615c7b565b91829055509150611f798383614c66565b50611fab8260008060405180606001604052806000600f0b815260200160008152602001600115158152506001614cd5565b6000828152600960209081526040808320805460ff1916600217905580516301a15ccf60e31b8152905183926001600160a01b037f000000000000000000000000f4c67cdeaab8360370f41514d06e32ccd8aa1d7b1692630d0ae67892600480830193928290030181865afa158015612028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061204c9190615c5e565b60025460405163dabc8e8360e01b81526001600160a01b037f00000000000000000000000006824df38d1d77eadeb6bafcb03904e27429ab7481166004830152918216602482015291169063dabc8e839060440160408051808303816000875af11580156120be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120e29190615c94565b6000868152600d6020908152604080832080546001600160a01b038781166001600160a01b03199283168117909355600e8552948390208054878716921682179055825191825292810192909252939550919350858116928792918916917fae65a147ec014982132ce8b32019735e3c5f41457848d2ce2e2c3e0cbc9df7bc910160405180910390a45050506121786001600055565b919050565b61100283838360405180602001604052806000815250612e44565b60006121a48383614154565b90505b92915050565b6121b5615651565b600083815260196020526040902082633b9aca0081106121d7576121d7615bc4565b6040805160a081018252600492909202929092018054600f81810b8452600160801b909104900b60208301526001810154928201929092526002820154606082015260039091015460808201529392505050565b600080612236613ced565b6000612240613c8e565b9050600061224d86613cd2565b90506001600160a01b03811661227657604051632c2151ef60e11b815260040160405180910390fd5b6001600160a01b0381166000908152601c602052604090205460ff161580156122ca575060008052601c6020527fb9c6de81004e18dedadca3e5eabaab449ca91dff6f58efc9461da635fe77f8495460ff16155b156122e857604051633df16fd960e21b815260040160405180910390fd5b60008681526009602052604081205460ff16600281111561230b5761230b615904565b14612329576040516317a66f3760e01b815260040160405180910390fd5b6000868152601e602052604090205460ff161561235957604051637c9a1cf960e01b815260040160405180910390fd5b6123638287614154565b6123805760405163390cdd9b60e21b815260040160405180910390fd5b60008681526018602090815260409182902082516060810184528154600f0b8152600182015492810183905260029091015460ff1615159281019290925242108015906123cf57508060400151155b156123ed576040516307b7d7dd60e51b815260040160405180910390fd5b85600f81900b60000361241357604051631f2a200560e01b815260040160405180910390fd5b80600f0b8260000151600f0b1361243d57604051636b2f218360e01b815260040160405180910390fd5b612446886141be565b6040805160608082018352600080835260208084018281528486018381528e845260188352868420955186546001600160801b0319166001600160801b0390911617865590516001860155516002909401805460ff19169415159490941790935583519182018452808252918101829052918201526124c8908990849061426e565b80826000018181516124da9190615c31565b600f0b9052506124ea8383614e92565b600f82900b835295506124fd8383614e92565b600087815260186020908152604091829020548582015183516001600160a01b038a1681526001600160801b0392831693810193909352858216838501521660608201524260808201529051919650869188918b917f8303de8187a6102fdc3fe20c756dddd68df0ae027b77e2391c19a855e0821f339181900360a00190a45050505061258a6001600055565b9250929050565b6040516332b53f5360e11b815260216004820152602060248201526001600160a01b038416604482015260648101839052608481018290526000907373746410b0dd4526e1fa00d0854e99ba54aefd309063656a7ea69060a401602060405180830381865af4158015612608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262c9190615bab565b90505b9392505050565b6002546001600160a01b031661264a613c8e565b6001600160a01b0316146126715760405163c18384c160e01b815260040160405180910390fd5b6000918252601e6020526040909120805460ff1916911515919091179055565b60006121a782613cd2565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08111156126dd576040516317e97eb760e31b815260040160405180910390fd5b6040805180820182526005808252641d9953919560da1b60209283015282518084018452908152640322e302e360dc1b9082015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527fc792e9874e7b42c234d1e8448cec020a0f065019c8cd6f7ccdb65b8c110157e9818401527fb4bcb154e38601c389396fa918314da42d4626f13ef6d0ceb07e5f5d26b2fbc360608201524660808201523060a0808301919091528351808303909101815260c0820184528051908301207f9947d5709c1682eaa3946b2d84115c9c0d1c946b149d76e69b457458b42ea29e60e083015261010082018b905261012082018a905261014082018990526101608083018990528451808403909101815261018083019094528351939092019290922061190160f01b6101a08401526101a283018290526101c2830181905290916000906101e20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa15801561289c573d6000803e3d6000fd5b5050506020604051035190506128b2818c614154565b6128cf5760405163390cdd9b60e21b815260040160405180910390fd5b6001600160a01b0381166128f657604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b038116600090815260226020526040812080549161291a83615c7b565b91905055891461293d57604051633ab3447f60e11b815260040160405180910390fd5b8742111561295e57604051630819bdcd60e01b815260040160405180910390fd5b6129688b8b614a8a565b505050505b50505050505050565b6129ae6040518060a001604052806000600f0b81526020016000600f0b81526020016000815260200160008152602001600081525090565b50600090815260066020908152604091829020825160a0810184528154600f81810b8352600160801b909104900b9281019290925260018101549282019290925260028201546060820152600390910154608082015290565b60006121a782613f96565b600260009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a899190615c5e565b6001600160a01b0316612a9a613c8e565b6001600160a01b031614612ac157604051633b8d9d7560e21b815260040160405180910390fd5b6005546001600160a01b0390811690821603612af05760405163367558c360e01b815260040160405180910390fd5b6001600160a01b038116612b175760405163d92e233d60e01b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0383169081179091556040517f1a6ce72407c68def4b7d2e724c896070d89cf2b2a2dd56b6897b5febd88420f590600090a250565b612b69613ced565b612b7a612b74613c8e565b83614154565b612b975760405163390cdd9b60e21b815260040160405180910390fd5b60008281526009602052604081205460ff166002811115612bba57612bba615904565b14612bd8576040516317a66f3760e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161580159282019290925290612c34576040516334d10f9560e11b815260040160405180910390fd5b600062093a8080612c458542615b57565b612c4f9190615b80565b612c599190615b94565b905042826020015111612c7f576040516307b7d7dd60e51b815260040160405180910390fd5b60008260000151600f0b13612ca75760405163f90e998d60e01b815260040160405180910390fd5b81602001518111612ccb57604051638e6b5b6760e01b815260040160405180910390fd5b612cd9630784ce0042615b57565b811115612cf95760405163f761f1cd60e01b815260040160405180910390fd5b612d0884600083856003614cd5565b604051848152600080516020615e668339815191529060200160405180910390a15050610fdb6001600055565b6000612d3f613c8e565b9050806001600160a01b0316836001600160a01b031603612d735760405163367558c360e01b815260040160405180910390fd5b6001600160a01b03818116600081815260126020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612de8613ced565b612df3612b74613c8e565b612e105760405163390cdd9b60e21b815260040160405180910390fd5b610fd182826002613d4b565b6000612e26613ced565b612e388383612e33613c8e565b614f2d565b90506121a76001600055565b6000612e4e613c8e565b9050612e5c85858584614026565b833b15612f6057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612e95908490899088908890600401615cc3565b6020604051808303816000875af1925050508015612ed0575060408051601f3d908101601f19168201909252612ecd91810190615d00565b60015b612f2d573d808015612efe576040519150601f19603f3d011682016040523d82523d6000602084013e612f03565b606091505b508051600003612f2557604051626b5e2960e61b815260040160405180910390fd5b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14612f5e5760405163279929b160e21b815260040160405180910390fd5b505b5050505050565b612f6f613ced565b604080516060808201835260008083526020808401829052838501829052845192830185528183528201819052928101839052612fad92919061426e565b612fb76001600055565b565b60606000612fc683613cd2565b6001600160a01b031603612fed57604051634a1850bf60e11b815260040160405180910390fd5b6004805460405163c87b56dd60e01b81529182018490526001600160a01b03169063c87b56dd90602401600060405180830381865afa158015613034573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121a79190810190615d1d565b613064613ced565b600061306e613c8e565b6000848152601e602052604090205490915060ff16156130a157604051637c9a1cf960e01b815260040160405180910390fd5b60008381526009602052604081205460ff1660028111156130c4576130c4615904565b146130e2576040516317a66f3760e01b815260040160405180910390fd5b60008281526009602052604081205460ff16600281111561310557613105615904565b14613123576040516317a66f3760e01b815260040160405180910390fd5b818303613143576040516349da877960e11b815260040160405180910390fd5b61314d8184614154565b61316a5760405163390cdd9b60e21b815260040160405180910390fd5b6131748183614154565b6131915760405163390cdd9b60e21b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b8152600182015492810183905260029091015460ff1615159281019290925242108015906131e057508060400151155b156131fe576040516307b7d7dd60e51b815260040160405180910390fd5b60008481526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff16158015928201929092529061325a576040516334d10f9560e11b815260040160405180910390fd5b600082602001518260200151101561327657826020015161327c565b81602001515b9050613287866141be565b6040805160608082018352600080835260208084018281528486018381528c845260188352868420955186546001600160801b0319166001600160801b0390911617865590516001860155516002909401805460ff1916941515949094179093558351918201845280825291810182905291820152613309908790849061426e565b6040805160608101825260008082526020820181905291810191909152825184516133349190615d8b565b600f0b815260408085015115801591830191909152613371578260000151600f0b601d60008282546133669190615b57565b909155506133799050565b602081018290525b6000868152601f602052604090205483516133999190600f0b6001614be9565b6133a486858361426e565b600086815260186020908152604091829020835181546001600160801b039182166001600160801b0319909116811783558584015160018401819055868601516002909401805494151560ff19909516949094179093558751895186519184168252831694810194909452838501521660608201524260808201529051879189916001600160a01b038916917f986e3c958e3bdf1f58c2150357fc94624dd4e77b08f9802d8e2e885fa0d6a198919081900360a00190a4604051868152600080516020615e66833981519152906020015b60405180910390a15050505050610fdb6001600055565b613497612b74613c8e565b6134b45760405163390cdd9b60e21b815260040160405180910390fd5b610fdb8282614a8a565b60006121a4838361503f565b6134d2613ced565b6002546001600160a01b03166134e6613c8e565b6001600160a01b03161461350d5760405163c18384c160e01b815260040160405180910390fd5b600260008281526009602052604090205460ff16600281111561353257613532615904565b146135505760405163054b1e0160e51b815260040160405180910390fd5b60008281526009602052604081205460ff16600281111561357357613573615904565b14613591576040516317a66f3760e01b815260040160405180910390fd5b61359b824261503f565b6000036135bb5760405163334ab3f560e11b815260040160405180910390fd5b60008281526018602052604090208054600290910154600f9190910b9060ff161561360c57806001600160801b0316601d60008282546135fb9190615b44565b9091555061360c9050836000614a8a565b60008381526018602090815260408083208151606080820184528254600f0b825260018301548286015260029092015460ff1615158184015282519182018352848252928101849052908101929092526136689185919061426e565b60408051606081018252600080825260208083018281528385018381528884526018909252938220925183546001600160801b0319166001600160801b0391821617845593516001840155516002909201805460ff191692151592909217909155601d8054928416928392906136df908490615b57565b909155505060008381526018602090815260409182902082516060810184528154600f0b80825260018301549382019390935260029091015460ff1615159281019290925283908290613733908390615d8b565b600f0b9052506000848152601f602052604090205461375d906001600160801b0385166001614be9565b60008481526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161515918101919091526137a69085908361426e565b6000848152601860209081526040808320845181546001600160801b0319166001600160801b0391821617825585840151600180840191909155868401516002909301805460ff199081169415159490941790558a8652600b85528386208a875285528386208890558a8652600a85528386208a905560098552838620805490931617909155878452600d9092529182902054915163f320772360e01b81529085166004820152602481018790526001600160a01b0390911690819063f320772390604401600060405180830381600087803b15801561388557600080fd5b505af1158015613899573d6000803e3d6000fd5b5050506000868152600e60205260409081902054905163f320772360e01b81526001600160801b0387166004820152602481018990526001600160a01b039091169150819063f320772390604401600060405180830381600087803b15801561390157600080fd5b505af1158015613915573d6000803e3d6000fd5b50505050858761392489613cd2565b6001600160a01b03167ff7757ce35992f4ee014dee2e0c97ed6245758960a6ecc9e124897a5fb7b014238742604051613967929190918252602082015260400190565b60405180910390a4604051878152600080516020615e6683398151915290602001613475565b6000613997613c8e565b90506139a38183614154565b6139c05760405163390cdd9b60e21b815260040160405180910390fd5b60008281526009602052604081205460ff1660028111156139e3576139e3615904565b14613a01576040516317a66f3760e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161580159282019290925290613a5d576040516334d10f9560e11b815260040160405180910390fd5b42816020015111613a81576040516307b7d7dd60e51b815260040160405180910390fd5b60008160000151600f0b13613aa95760405163f90e998d60e01b815260040160405180910390fd5b60008160000151600f0b905080601d6000828254613ac79190615b57565b90915550506000602080840182905260016040808601829052878452601883529283902083516060810185528154600f0b8152918101549282019290925260029091015460ff16151591810191909152613b239085908461426e565b600084815260186020908152604091829020845181546001600160801b0319166001600160801b03909116178155848201516001820155848301516002909101805460ff19169115159190911790558151838152429181019190915285916001600160a01b038616917f793cb7a30a4bb8669ec607dfcbdc93f5a3e9d282f38191fddab43ccaf79efb809101611647565b600081815260136020526040812054439003613bd257506000919050565b6121a7824261503f565b6000613be6613ced565b613bf1848484614f2d565b905061262f6001600055565b613c3160405180608001604052806000815260200160006001600160a01b0316815260200160008152602001600081525090565b5060009182526020808052604080842065ffffffffffff9390931684529181529181902081516080810183528154815260018201546001600160a01b03169381019390935260028101549183019190915260030154606082015290565b60007f00000000000000000000000006824df38d1d77eadeb6bafcb03904e27429ab746001600160a01b03163303613ccd575060131936013560601c90565b503390565b6000908152600f60205260409020546001600160a01b031690565b600260005403613d445760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600055565b60008381526009602052604090205460ff166001816002811115613d7157613d71615904565b03613d8f57604051635eb32db160e11b815260040160405180910390fd5b600084815260186020908152604080832081516060810183528154600f0b81526001820154938101939093526002015460ff1615159082015290849003613de957604051631f2a200560e01b815260040160405180910390fd5b60008160000151600f0b13613e115760405163f90e998d60e01b815260040160405180910390fd5b42816020015111158015613e2757508060400151155b15613e45576040516307b7d7dd60e51b815260040160405180910390fd5b806040015115613e675783601d6000828254613e619190615b57565b90915550505b6000858152601f6020526040902054613e8290856001614be9565b613e90858560008487614cd5565b6002826002811115613ea457613ea4615904565b03613f6e576000858152600d60205260409020546001600160a01b03908116907f0000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db90613ef390821683886150cb565b60405163b66503cf60e01b81526001600160a01b0382811660048301526024820188905283169063b66503cf90604401600060405180830381600087803b158015613f3d57600080fd5b505af1158015613f51573d6000803e3d6000fd5b50613f6b925050506001600160a01b0382168360006150cb565b50505b604051858152600080516020615e668339815191529060200160405180910390a15050505050565b601654604051637259b01960e01b8152601b6004820152600660248201526044810191909152606481018290526000907379bca9bcc19e157cb5f8c5a2f4d6cb951b1f8dce90637259b01990608401602060405180830381865af4158015614002573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a79190615bab565b600160008381526009602052604090205460ff16600281111561404b5761404b615904565b0361406957604051635eb32db160e11b815260040160405180910390fd5b6140738183614154565b6140905760405163390cdd9b60e21b815260040160405180910390fd5b836001600160a01b03166140a383613cd2565b6001600160a01b0316146140ca576040516330cd747160e01b815260040160405180910390fd5b600082815260116020526040902080546001600160a01b03191690556140f084836151e0565b6140fc82600085615261565b61410683836152cb565b6000828152601360205260408082204390555183916001600160a01b0380871692908816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a450505050565b60008061416083613cd2565b6000848152601160209081526040808320546001600160a01b0380861680865260128552838620828c1680885295529290942054949550908214939216149060ff1682806141ab5750815b806141b35750805b979650505050505050565b60006141c8613c8e565b90506141d48183614154565b6141f15760405163390cdd9b60e21b815260040160405180910390fd5b60006141fc83613cd2565b600084815260116020526040812080546001600160a01b031916905590915061422790849080615261565b61423181846151e0565b60405183906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a4505050565b614276615651565b61427e615651565b601654600090819087156143bc57856040015161429c5760006142a2565b8551600f0b5b60808501526020870151421080156142c1575060008760000151600f0b135b156143065786516142d790630784ce0090615db8565b600f0b6020808701919091528701516142f1904290615b44565b85602001516143009190615df6565b600f0b85525b428660200151118015614320575060008660000151600f0b135b1561436557855161433690630784ce0090615db8565b600f0b602080860191909152860151614350904290615b44565b846020015161435f9190615df6565b600f0b84525b6020808801516000908152601b8252604090205490870151600f9190910b9350156143bc5786602001518660200151036143a1578291506143bc565b6020808701516000908152601b9091526040902054600f0b91505b6040805160a0810182526000808252602082018190524292820192909252436060820152608081019190915281156144455750600081815260066020908152604091829020825160a0810184528154600f81810b8352600160801b909104900b928101929092526001810154928201929092526002820154606082015260039091015460808201525b60008160400151905060006040518060a001604052808460000151600f0b81526020018460200151600f0b8152602001846040015181526020018460600151815260200184608001518152509050600083604001514211156144de5760408401516144b09042615b44565b60608501516144bf9043615b44565b6144d190670de0b6b3a7640000615b94565b6144db9190615b80565b90505b600062093a806144ee8186615b80565b6144f89190615b94565b905060005b60ff81101561467c5761451362093a8083615b57565b91506000428311156145275742925061453b565b506000828152601b6020526040902054600f0b5b6145458684615b44565b87602001516145549190615df6565b87518890614563908390615c31565b600f0b90525060208701805182919061457d908390615d8b565b600f90810b90915288516000910b1215905061459857600087525b60008760200151600f0b12156145b057600060208801525b60408088018490528501519295508592670de0b6b3a7640000906145d49085615b44565b6145de9086615b94565b6145e89190615b80565b85606001516145f79190615b57565b6060880152614607600189615b57565b975042830361461c575043606087015261467c565b6000888152600660209081526040918290208951918a01516001600160801b03908116600160801b0292169190911781559088015160018201556060880151600282015560808801516003909101555061467581615c7b565b90506144fd565b50508b1561470b57886020015188602001516146989190615c31565b846020018181516146a99190615d8b565b600f0b905250885188516146bd9190615c31565b845185906146cc908390615d8b565b600f90810b90915260208601516000910b121590506146ed57600060208501525b60008460000151600f0b121561470257600084525b601d5460808501525b8460011415801561473b57504260066000614727600189615b44565b815260200190815260200160002060010154145b156147a5578360066000614750600189615b44565b815260208082019290925260409081016000208351928401516001600160801b03908116600160801b0293169290921782558201516001820155606082015160028201556080909101516003909101556147fa565b60168590556000858152600660209081526040918290208651918701516001600160801b03908116600160801b0292169190911781559085015160018201556060850151600282015560808501516003909101555b8b15614a1957428b60200151111561486c57602089015161481b9088615d8b565b96508a602001518a602001510361483e57602088015161483b9088615c31565b96505b60208b8101516000908152601b9091526040902080546001600160801b0319166001600160801b0389161790555b428a6020015111156148c7578a602001518a6020015111156148c75760208801516148979087615c31565b60208b8101516000908152601b9091526040902080546001600160801b0319166001600160801b03831617905595505b426040808a01919091524360608a015260008d8152601a6020522054801580159061491b575060008d8152601960205260409020429082633b9aca00811061491157614911615bc4565b6004020160010154145b156149915760008d8152601960205260409020899082633b9aca00811061494457614944615bc4565b825160208401516001600160801b03908116600160801b02911617600491909102919091019081556040820151600182015560608201516002820155608090910151600390910155614a17565b61499a81615c7b565b60008e8152601a6020908152604080832084905560199091529020909150899082633b9aca0081106149ce576149ce615bc4565b825160208401516001600160801b03908116600160801b029116176004919091029190910190815560408201516001820155606082015160028201556080909101516003909101555b505b505050505050505050505050565b6040516001600160a01b03831660248201526044810182905261100290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261535d565b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff16151591810182905290614ae457604051632188f8ab60e01b815260040160405180910390fd5b8115801590614b0457506000614af983613cd2565b6001600160a01b0316145b15614b2257604051634a1850bf60e11b815260040160405180910390fd5b600083815260136020526040902054439003614b51576040516342d6fce760e01b815260040160405180910390fd5b828203614b5d57600091505b6000838152601f6020526040902054828103614b795750505050565b81516001600160801b0316614b978585614b9282613cd2565b615261565b614ba384826001614be9565b8382614bad613c8e565b6001600160a01b03167ff1aa2a9e40138176a3ee6099df056f5c175f8511a0d8b8275d94d1ea5de4677360405160405180910390a45050505050565b6040516375f199b960e11b81526021600482015260206024820152604481018490526064810183905281151560848201527373746410b0dd4526e1fa00d0854e99ba54aefd309063ebe333729060a4015b60006040518083038186803b158015614c5257600080fd5b505af415801561296d573d6000803e3d6000fd5b60006001600160a01b038316614c7e57614c7e615e16565b614c8883836152cb565b614c9482600085615261565b60405182906001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450600192915050565b601754614ce28582615b57565b6017556040805160608101825260008082526020808301828152838501928352875191880151948801511515909252929052600f9190910b80825286908290614d2c908390615d8b565b600f0b9052508415614d4057602081018590525b600087815260186020908152604091829020835181546001600160801b0319166001600160801b03909116178155908301516001820155908201516002909101805460ff1916911515919091179055614d9a87858361426e565b6000614da4613c8e565b90508615614de157614de16001600160a01b037f0000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db1682308a61542f565b836003811115614df357614df3615904565b602083810151604080518b8152928301919091524282820152518a916001600160a01b038516917f8835c22a0c751188de86681e15904223c054bedd5c68ec8858945b78312902739181900360600190a47f5e2aa66efd74cce82b21852e317e5490d9ecc9e6bb953ae24d90851258cc2f5c83614e708982615b57565b6040805192835260208301919091520160405180910390a15050505050505050565b6000600860008154614ea390615c7b565b91829055506000818152601860209081526040808320865181546001600160801b0319166001600160801b03909116178155868301516001820155868201516002909101805460ff19169115159190911790558051606081018252838152918201839052810191909152909150614f1c9082908461426e565b614f268382614c66565b5092915050565b60008062093a8080614f3f8642615b57565b614f499190615b80565b614f539190615b94565b905084600003614f7657604051631f2a200560e01b815260040160405180910390fd5b428111614f9657604051638e6b5b6760e01b815260040160405180910390fd5b614fa4630784ce0042615b57565b811115614fc45760405163f761f1cd60e01b815260040160405180910390fd5b6000600860008154614fd590615c7b565b91829055509050614fe68482614c66565b5060008181526018602090815260409182902082516060810184528154600f0b81526001808301549382019390935260029091015460ff1615159281019290925261503691839189918691614cd5565b95945050505050565b604051637b29b3d160e01b8152601a60048201526019602482015260448101839052606481018290526000907379bca9bcc19e157cb5f8c5a2f4d6cb951b1f8dce90637b29b3d190608401602060405180830381865af41580156150a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a49190615bab565b8015806151455750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561511f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151439190615bab565b155b6151b05760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401613d3b565b6040516001600160a01b03831660248201526044810182905261100290849063095ea7b360e01b90606401614a53565b816001600160a01b03166151f382613cd2565b6001600160a01b03161461520957615209615e16565b6000818152600f6020526040902080546001600160a01b031916905561522f828261546d565b6001600160a01b0382166000908152601060205260408120805460019290615258908490615b44565b90915550505050565b60405163690f66bf60e01b8152601860048201526021602482015260206044820152601f60648201526084810184905260a481018390526001600160a01b03821660c48201527373746410b0dd4526e1fa00d0854e99ba54aefd309063690f66bf9060e401614c3a565b60006152d682613cd2565b6001600160a01b0316146152ec576152ec615e16565b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b038716908117909155808452601080845282852080546014865284872081885286528487208890558787526015865293862093909355908452909152805460019290615258908490615b57565b60006153b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661552c9092919063ffffffff16565b80519091501561100257808060200190518101906153d09190615e2c565b6110025760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401613d3b565b6040516001600160a01b03808516602483015283166044820152606481018290526154679085906323b872dd60e01b90608401614a53565b50505050565b6001600160a01b03821660009081526010602052604081205461549290600190615b44565b6000838152601560205260409020549091508082036154e1576001600160a01b038416600090815260146020908152604080832085845282528083208390558583526015909152812055615467565b6001600160a01b039390931660009081526014602090815260408083209383529281528282208054868452848420819055835260159091528282209490945592839055908252812055565b606061262c848460008585600080866001600160a01b031685876040516155539190615e49565b60006040518083038185875af1925050503d8060008114615590576040519150601f19603f3d011682016040523d82523d6000602084013e615595565b606091505b50915091506155a6878383876155b3565b925050505b949350505050565b6060831561562257825160000361561b576001600160a01b0385163b61561b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401613d3b565b50816155ab565b6155ab83838151156156375781518083602001fd5b8060405162461bcd60e51b8152600401613d3b9190615709565b6040518060a001604052806000600f0b81526020016000600f0b81526020016000815260200160008152602001600081525090565b6001600160e01b03198116811461131257600080fd5b6000602082840312156156ae57600080fd5b813561262f81615686565b60005b838110156156d45781810151838201526020016156bc565b50506000910152565b600081518084526156f58160208601602086016156b9565b601f01601f19169290920160200192915050565b6020815260006121a460208301846156dd565b60006020828403121561572e57600080fd5b5035919050565b6001600160a01b038116811461131257600080fd5b60006020828403121561575c57600080fd5b813561262f81615735565b6000806040838503121561577a57600080fd5b823561578581615735565b946020939093013593505050565b600080604083850312156157a657600080fd5b50508035926020909101359150565b6000806000606084860312156157ca57600080fd5b83356157d581615735565b925060208401356157e581615735565b929592945050506040919091013590565b6000806040838503121561580957600080fd5b823561581481615735565b9150602083013561582481615735565b809150509250929050565b801515811461131257600080fd5b6000806040838503121561585057600080fd5b823561585b81615735565b915060208301356158248161582f565b6000806040838503121561587e57600080fd5b8235915060208301356158248161582f565b60a081016121a782848051600f0b82526020810151600f0b60208301526040810151604083015260608101516060830152608081015160808301525050565b6000806000606084860312156158e457600080fd5b83356158ef81615735565b95602085013595506040909401359392505050565b634e487b7160e01b600052602160045260246000fd5b602081016003831061593c57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600080600080600060e0888a03121561595d57600080fd5b87359650602088013595506040880135945060608801359350608088013560ff8116811461598a57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156159e6576159e66159a7565b604052919050565b600067ffffffffffffffff821115615a0857615a086159a7565b50601f01601f191660200190565b60008060008060808587031215615a2c57600080fd5b8435615a3781615735565b93506020850135615a4781615735565b925060408501359150606085013567ffffffffffffffff811115615a6a57600080fd5b8501601f81018713615a7b57600080fd5b8035615a8e615a89826159ee565b6159bd565b818152886020838501011115615aa357600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b600080600060608486031215615ada57600080fd5b83359250602084013591506040840135615af381615735565b809150509250925092565b60008060408385031215615b1157600080fd5b82359150602083013565ffffffffffff8116811461582457600080fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156121a7576121a7615b2e565b808201808211156121a7576121a7615b2e565b634e487b7160e01b600052601260045260246000fd5b600082615b8f57615b8f615b6a565b500490565b80820281158282048414176121a7576121a7615b2e565b600060208284031215615bbd57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000604082018483526020604081850152818551808452606086019150828701935060005b81811015615c245784516001600160a01b031683529383019391830191600101615bff565b5090979650505050505050565b600f82810b9082900b0360016001607f1b0319811260016001607f1b03821317156121a7576121a7615b2e565b600060208284031215615c7057600080fd5b815161262f81615735565b600060018201615c8d57615c8d615b2e565b5060010190565b60008060408385031215615ca757600080fd5b8251615cb281615735565b602084015190925061582481615735565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615cf6908301846156dd565b9695505050505050565b600060208284031215615d1257600080fd5b815161262f81615686565b600060208284031215615d2f57600080fd5b815167ffffffffffffffff811115615d4657600080fd5b8201601f81018413615d5757600080fd5b8051615d65615a89826159ee565b818152856020838501011115615d7a57600080fd5b6150368260208301602086016156b9565b600f81810b9083900b0160016001607f1b03811360016001607f1b0319821217156121a7576121a7615b2e565b600081600f0b83600f0b80615dcf57615dcf615b6a565b60016001607f1b0319821460001982141615615ded57615ded615b2e565b90059392505050565b600082600f0b82600f0b0280600f0b9150808214614f2657614f26615b2e565b634e487b7160e01b600052600160045260246000fd5b600060208284031215615e3e57600080fd5b815161262f8161582f565b60008251615e5b8184602087016156b9565b919091019291505056fef8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce7a2646970667358221220c775f186d65f1ef762c5b76afb4b778f0956d15e43522d2dd91ac354d1378e6864736f6c63430008130033","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"paris","libraries":{"contracts/art/PerlinNoise.sol:PerlinNoise":"0x08947e304064b3f3ef2b99fca7e549c5fc3f75d4","contracts/art/Trig.sol:Trig":"0xbdd6f9662e904a9176aafcbdded45d076b5170ef","contracts/libraries/BalanceLogicLibrary.sol:BalanceLogicLibrary":"0x79bca9bcc19e157cb5f8c5a2f4d6cb951b1f8dce","contracts/libraries/DelegationLogicLibrary.sol:DelegationLogicLibrary":"0x73746410b0dd4526e1fa00d0854e99ba54aefd30"},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":true,"runs":200},"remappings":[":@opengsn/=lib/gsn/packages/",":@openzeppelin/=lib/openzeppelin-contracts/",":@uniswap/v3-core/=lib/v3-core/",":concentrated-liquidity/=lib/concentrated-liquidity/",":ds-test/=lib/ds-test/src/",":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",":eth-gas-reporter/=node_modules/eth-gas-reporter/",":forge-std/=lib/forge-std/src/",":gsn/=lib/gsn/",":hardhat-deploy/=node_modules/hardhat-deploy/",":hardhat/=node_modules/hardhat/",":openzeppelin-contracts/=lib/openzeppelin-contracts/",":utils/=test/utils/",":v3-core/=lib/v3-core/"]},"optimization_runs":200,"sourcify_repo_url":"https://repo.sourcify.dev/contracts/partial_match/10/0xFAf8FD17D9840595845582fCB047DF13f006787d/","decoded_constructor_args":[["0xFC378dAA952ba7f163c4a11628f55a4df523b3EF",{"internalType":"address","name":"_forwarder","type":"address"}],["0x06824df38D1D77eADEB6baFCB03904E27429Ab74",{"internalType":"address","name":"_token","type":"address"}],["0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db",{"internalType":"address","name":"_factoryRegistry","type":"address"}]],"compiler_version":"0.8.19+commit.7dd6d404","is_verified_via_verifier_alliance":null,"verified_at":"2024-03-05T17:14:58.046536Z","implementations":[],"proxy_type":null,"external_libraries":[{"name":"contracts/art/PerlinNoise.sol:PerlinNoise","address_hash":"0x08947E304064B3f3EF2b99FCA7E549C5FC3F75D4"},{"name":"contracts/art/Trig.sol:Trig","address_hash":"0xbdD6F9662e904A9176AaFcbdDeD45d076B5170Ef"},{"name":"contracts/libraries/BalanceLogicLibrary.sol:BalanceLogicLibrary","address_hash":"0x79BCA9BcC19e157cB5f8C5a2F4d6Cb951b1f8DcE"},{"name":"contracts/libraries/DelegationLogicLibrary.sol:DelegationLogicLibrary","address_hash":"0x73746410b0DD4526e1Fa00D0854e99ba54aeFD30"}],"creation_bytecode":"0x6101006040523480156200001257600080fd5b50604051620061fd380380620061fd833981016040819052620000359162000266565b6001600160a01b038084166080819052600160005560a05282811660e052811660c0526200006262000221565b600380546001600160a01b0319166001600160a01b03929092169190911790556200008c62000221565b600280546001600160a01b0319166001600160a01b0392909216919091179055437f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4fa55427f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f95560076020527f1142c8ae8ad77901cd97fce843895a9ccf91a8cbd5b191350a94c1d957b07f74805460ff1990811660019081179092557f2379132be4428a30bdcf8f40c0757cba23c7e3f4204cd933dabcc3d42093e80480548216831790557f7108cf076693445f3e0461801864e91d74eb5e0eee196ef60b5961a16cd35b9380548216831790557fbc48a5b87e2e2cb168c956e8aca8ee5c5d50c657bb1c18b9ad30280d5cf98f5b805482168317905563da287a1d60e01b60009081527f7105fc4c24d760d461c0883f925f50b55888872394b962f52e936e529601d62a8054909216909217905560085460405190913091600080516020620061dd833981519152908290a46008546040516000903090600080516020620061dd833981519152908390a4505050620002b0565b6080516000906001600160a01b0316330362000244575060131936013560601c90565b503390565b80516001600160a01b03811681146200026157600080fd5b919050565b6000806000606084860312156200027c57600080fd5b620002878462000249565b9250620002976020850162000249565b9150620002a76040850162000249565b90509250925092565b60805160a05160c05160e051615ebb6200032260003960008181610d6b01528181611254015281816117700152818161185301528181613ec60152614db90152600081816106e90152611fe1015260008181610d4401526120660152600081816108a60152613c920152615ebb6000f3fe608060405234801561001057600080fd5b50600436106104805760003560e01c806370a0823111610257578063b45a3c0e11610146578063e58f5947116100c3578063ec32e6df11610087578063ec32e6df14610ca7578063f04cb3a814610cba578063f52a36f714610d09578063f645d4f914610d3f578063fc0c546a14610d6657600080fd5b8063e58f594714610bfe578063e75b1c2e14610c1e578063e7a324dc14610c31578063e7e242d414610c58578063e985e9c514610c6b57600080fd5b8063c87b56dd1161010a578063c87b56dd14610b9f578063d1c2babb14610bb2578063d9a3495214610bc5578063e0514aba14610bd8578063e0c11f9a14610beb57600080fd5b8063b45a3c0e14610ad6578063b52c05fe14610b5e578063b88d4fde14610b71578063bfe1092814610b84578063c2c4c5c114610b9757600080fd5b806391ddadf4116101d4578063a22cb46511610198578063a22cb46514610a44578063a738da8214610a57578063a899b36c14610a80578063b1548afc14610aa3578063b2383e5514610ac357600080fd5b806391ddadf414610a1857806395d89b41146104de578063981b24d0146109d95780639954a98914610a1e5780639d507b8b14610a3157600080fd5b80638ad4c4471161021b5780638ad4c4471461099b5780638bf9d84c146109ae5780638e539e8c146109d95780638fbb38ff146109ec578063900cf0cf14610a0f57600080fd5b806370a08231146108fc5780637c728000146109255780637ecebe0014610955578063834b0b691461097557806385f2aef21461098857600080fd5b8063370fb5fa116103735780634bf5d7e9116102f057806354fd4d50116102b457806354fd4d501461085f5780635594a04514610883578063572b6c05146108965780635a4f459a146108d65780636352211e146108e957600080fd5b80634bf5d7e9146107af5780634d01cb66146107d95780634d6fb775146107e257806350589793146107f5578063515857d41461083457600080fd5b806342842e0e1161033757806342842e0e1461072e578063430c20811461074157806344acb42a1461075457806346c96aac146107745780634b19becc1461078757600080fd5b8063370fb5fa146106ab57806337b1f500146106be5780633a6396a5146106d15780633bf0c9fb146106e45780633d085a371461070b57600080fd5b806320606b70116104015780632e720f7d116103c55780632e720f7d146106455780632f7f9ba914610658578063313ce5671461066b57806333230dc01461068557806335b0f6bd1461069857600080fd5b806320606b70146105bc57806323b872dd146105e357806327a6ee98146105f65780632d0485ec1461061f5780632e1a7d4d1461063257600080fd5b8063095ea7b311610448578063095ea7b3146105655780630ec84dda1461057857806317d70f7c1461058b57806318160ddd1461059457806319a0a9d51461059c57600080fd5b806301ffc9a714610485578063047fc9aa146104c757806306fdde03146104de578063081812fc1461050f578063095cf5c614610550575b600080fd5b6104b261049336600461569c565b6001600160e01b03191660009081526007602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6104d060175481565b6040519081526020016104be565b610502604051806040016040528060058152602001641d9953919560da1b81525081565b6040516104be9190615709565b61053861051d36600461571c565b6000908152601160205260409020546001600160a01b031690565b6040516001600160a01b0390911681526020016104be565b61056361055e36600461574a565b610d8d565b005b610563610573366004615767565b610e11565b610563610586366004615793565b610f52565b6104d060085481565b6104d0610fdf565b6104d06105aa36600461571c565b600a6020526000908152604090205481565b6104d07f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6105636105f13660046157b5565b610fef565b61053861060436600461571c565b600e602052600090815260409020546001600160a01b031681565b61056361062d3660046157f6565b611007565b61056361064036600461571c565b611070565b61056361065336600461574a565b611315565b600554610538906001600160a01b031681565b610673601281565b60405160ff90911681526020016104be565b61056361069336600461583d565b6113a9565b6105636106a636600461571c565b61140f565b6105636106b936600461571c565b611676565b6105636106cc36600461586b565b611c98565b6104d06106df36600461574a565b611e7e565b6105387f000000000000000000000000000000000000000000000000000000000000000081565b6104b261071936600461574a565b601c6020526000908152604090205460ff1681565b61056361073c3660046157b5565b61217d565b6104b261074f366004615767565b612198565b610767610762366004615793565b6121ad565b6040516104be9190615890565b600254610538906001600160a01b031681565b61079a610795366004615793565b61222b565b604080519283526020830191909152016104be565b60408051808201909152600e81526d06d6f64653d74696d657374616d760941b6020820152610502565b6104d0601d5481565b6104d06107f03660046158cf565b612591565b61081d61080336600461571c565b60216020526000908152604090205465ffffffffffff1681565b60405165ffffffffffff90911681526020016104be565b6104d0610842366004615793565b600b60209081526000928352604080842090915290825290205481565b610502604051806040016040528060058152602001640322e302e360dc1b81525081565b600454610538906001600160a01b031681565b6104b26108a436600461574a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b6105636108e436600461586b565b612636565b6105386108f736600461571c565b612691565b6104d061090a36600461574a565b6001600160a01b031660009081526010602052604090205490565b61094861093336600461571c565b60096020526000908152604090205460ff1681565b6040516104be919061591a565b6104d061096336600461574a565b60226020526000908152604090205481565b610563610983366004615942565b61269c565b600354610538906001600160a01b031681565b6107676109a936600461571c565b612976565b6104d06109bc366004615767565b601460209081526000928352604080842090915290825290205481565b6104d06109e736600461571c565b612a07565b6104b26109fa36600461571c565b601e6020526000908152604090205460ff1681565b6104d060165481565b4261081d565b610563610a2c36600461574a565b612a12565b610563610a3f366004615793565b612b61565b610563610a5236600461583d565b612d35565b610538610a6536600461571c565b600d602052600090815260409020546001600160a01b031681565b6104b2610a8e36600461571c565b600c6020526000908152604090205460ff1681565b6104d0610ab136600461571c565b6000908152601f602052604090205490565b610563610ad1366004615793565b612de0565b610b37610ae436600461571c565b6040805160608082018352600080835260208084018290529284018190529384526018825292829020825193840183528054600f0b84526001810154918401919091526002015460ff1615159082015290565b604080518251600f0b815260208084015190820152918101511515908201526060016104be565b6104d0610b6c366004615793565b612e1c565b610563610b7f366004615a16565b612e44565b600154610538906001600160a01b031681565b610563612f67565b610502610bad36600461571c565b612fb9565b610563610bc0366004615793565b61305c565b610563610bd3366004615793565b61348c565b6104d0610be6366004615793565b6134be565b610563610bf9366004615793565b6134ca565b6104d0610c0c36600461571c565b601a6020526000908152604090205481565b610563610c2c36600461571c565b61398d565b6104d07f9947d5709c1682eaa3946b2d84115c9c0d1c946b149d76e69b457458b42ea29e81565b6104d0610c6636600461571c565b613bb4565b6104b2610c793660046157f6565b6001600160a01b03918216600090815260126020908152604080832093909416825291909152205460ff1690565b6104d0610cb5366004615ac5565b613bdc565b610ccd610cc8366004615afe565b613bfd565b6040516104be9190815181526020808301516001600160a01b031690820152604080830151908201526060918201519181019190915260800190565b610d2c610d1736600461571c565b601b60205260009081526040902054600f0b81565b604051600f9190910b81526020016104be565b6105387f000000000000000000000000000000000000000000000000000000000000000081565b6105387f000000000000000000000000000000000000000000000000000000000000000081565b6003546001600160a01b0316610da1613c8e565b6001600160a01b031614610dc857604051633a7cfa5d60e21b815260040160405180910390fd5b6001600160a01b038116610def5760405163d92e233d60e01b815260040160405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e1b613c8e565b90506000610e2883613cd2565b90506001600160a01b038116610e515760405163d92e233d60e01b815260040160405180910390fd5b836001600160a01b0316816001600160a01b031603610e835760405163367558c360e01b815260040160405180910390fd5b6000826001600160a01b0316610e9885613cd2565b6001600160a01b0384811660009081526012602090815260408083208985168452909152902054911691909114915060ff16811582610ed5575080155b15610ef35760405163390cdd9b60e21b815260040160405180910390fd5b60008581526011602052604080822080546001600160a01b0319166001600160a01b038a811691821790925591518893918716917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050505050565b610f5a613ced565b600260008381526009602052604090205460ff166002811115610f7f57610f7f615904565b148015610fa757506001546001600160a01b0316610f9b613c8e565b6001600160a01b031614155b15610fc55760405163385296d560e01b815260040160405180910390fd5b610fd182826000613d4b565b610fdb6001600055565b5050565b6000610fea42613f96565b905090565b611002838383610ffd613c8e565b614026565b505050565b6002546001600160a01b031661101b613c8e565b6001600160a01b0316146110425760405163c18384c160e01b815260040160405180910390fd5b600280546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b611078613ced565b6000611082613c8e565b905061108e8183614154565b6110ab5760405163390cdd9b60e21b815260040160405180910390fd5b6000828152601e602052604090205460ff16156110db57604051637c9a1cf960e01b815260040160405180910390fd5b60008281526009602052604081205460ff1660028111156110fe576110fe615904565b1461111c576040516317a66f3760e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161580159282019290925290611178576040516334d10f9560e11b815260040160405180910390fd5b806020015142101561119d5760405163342ad40160e11b815260040160405180910390fd5b8051600f0b6111ab846141be565b6040805160608101825260008082526020808301828152838501838152898452601890925293909120915182546001600160801b0319166001600160801b039091161782559151600182015590516002909101805460ff191691151591909117905560175461121a8282615b44565b6017556040805160608101825260008082526020820181905291810191909152611247908690859061426e565b61127b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168584614a27565b6040805183815242602082015286916001600160a01b038716917f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94910160405180910390a37f5e2aa66efd74cce82b21852e317e5490d9ecc9e6bb953ae24d90851258cc2f5c816112ec8482615b44565b6040805192835260208301919091520160405180910390a1505050506113126001600055565b50565b6003546001600160a01b0316611329613c8e565b6001600160a01b03161461135057604051633a7cfa5d60e21b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b038316179055604080516000815260001960208201527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c910160405180910390a150565b6003546001600160a01b03166113bd613c8e565b6001600160a01b0316146113e457604051633a7cfa5d60e21b815260040160405180910390fd5b6001600160a01b03919091166000908152601c60205260409020805460ff1916911515919091179055565b6000611419613c8e565b90506114258183614154565b6114425760405163390cdd9b60e21b815260040160405180910390fd5b60008281526009602052604081205460ff16600281111561146557611465615904565b14611483576040516317a66f3760e01b815260040160405180910390fd5b6000828152601e602052604090205460ff16156114b357604051637c9a1cf960e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff1615159181018290529061150d57604051632188f8ab60e01b815260040160405180910390fd5b60008160000151600f0b905080601d600082825461152b9190615b44565b9091555062093a80905080611544630784ce0042615b57565b61154e9190615b80565b6115589190615b94565b6020830152600060408301819052611571908590614a8a565b60008481526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161515918101919091526115ba9085908461426e565b600084815260186020908152604091829020845181546001600160801b0319166001600160801b03909116178155848201516001820155848301516002909101805460ff19169115159190911790558151838152429181019190915285916001600160a01b038616917f668d293c0a181c1f163fd0d3c757239a9c17bd26c5e483150e374455433b27fa91015b60405180910390a3604051848152600080516020615e668339815191529060200160405180910390a150505050565b61167e613ced565b6000818152600a60205260409020546002546001600160a01b03166116a1613c8e565b6001600160a01b0316146116c85760405163c18384c160e01b815260040160405180910390fd5b806000036116e95760405163d7caa26160e01b815260040160405180910390fd5b600160008381526009602052604090205460ff16600281111561170e5761170e615904565b1461172c57604051630fd82f7760e11b815260040160405180910390fd5b6000818152600d6020908152604080832054600e835281842054868552600b8452828520868652909352818420549151633e491d4760e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018890529182169491909316928490633e491d4790604401602060405180830381865afa1580156117ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f29190615bab565b905060006118008284615b57565b9050600062093a8080611817630784ce0042615b57565b6118219190615b80565b61182b9190615b94565b60408051600180825281830190925291925060009190602080830190803683370190505090507f00000000000000000000000000000000000000000000000000000000000000008160008151811061188557611885615bc4565b6001600160a01b03928316602091820292909201015260405163f5f8d36560e01b81529088169063f5f8d365906118c2908c908590600401615bda565b600060405180830381600087803b1580156118dc57600080fd5b505af11580156118f0573d6000803e3d6000fd5b505050506000604051806060016040528085600f0b81526020018481526020016000151581525090506119838a601860008d81526020019081526020016000206040518060600160405290816000820160009054906101000a9004600f0b600f0b600f0b8152602001600182015481526020016002820160009054906101000a900460ff1615151515815250508361426e565b60008a8152601860209081526040808320845181546001600160801b0319166001600160801b0390911617815584830151600180830191909155858301516002928301805460ff19169115159190911790558d85529382902082516060810184528154600f90810b808352968301549582019590955291015460ff16151591810191909152919086900b12611a19578051611a1b565b845b81518290611a2a908390615c31565b600f0b905250601d548510611a4157601d54611a43565b845b601d6000828254611a549190615b44565b909155505060008a8152601f6020526040812054611a73918790614be9565b60008a81526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff16151591810191909152611abc908b908361426e565b60008a815260186020908152604091829020835181546001600160801b0319166001600160801b03918216178255918401516001820155838301516002909101805460ff1916911515919091179055905163278afc8b60e21b81529088166004820152602481018c90526001600160a01b038a1690639e2bf22c90604401600060405180830381600087803b158015611b5457600080fd5b505af1158015611b68573d6000803e3d6000fd5b505060405163278afc8b60e21b81526001600160801b038a166004820152602481018e90526001600160a01b038b169250639e2bf22c9150604401600060405180830381600087803b158015611bbd57600080fd5b505af1158015611bd1573d6000803e3d6000fd5b50505060008c8152600a60209081526040808320839055600b82528083208e845282528083208390558e835260099091529020805460ff1916905550898b611c1881613cd2565b6001600160a01b03167f5319474ec1e9d118585a40e615ea37be254007e6bb5b039756c3813c2d1354898842604051611c5b929190918252602082015260400190565b60405180910390a46040518b8152600080516020615e668339815191529060200160405180910390a1505050505050505050506113126001600055565b600260009054906101000a90046001600160a01b03166001600160a01b0316637778960e6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ceb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d0f9190615c5e565b6001600160a01b0316611d20613c8e565b6001600160a01b031614158015611dc65750600260009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611da99190615c5e565b6001600160a01b0316611dba613c8e565b6001600160a01b031614155b15611de45760405163459d6a3f60e01b815260040160405180910390fd5b600260008381526009602052604090205460ff166002811115611e0957611e09615904565b14611e275760405163054b1e0160e51b815260040160405180910390fd5b6000828152600c602052604090205481151560ff909116151503611e5e57604051631490ad1160e01b815260040160405180910390fd5b6000918252600c6020526040909120805460ff1916911515919091179055565b6000611e88613ced565b6000611e92613c8e565b6005549091506001600160a01b03808316911614801590611f3b5750600260009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f259190615c5e565b6001600160a01b0316816001600160a01b031614155b15611f5957604051633bc1d15f60e01b815260040160405180910390fd5b600860008154611f6890615c7b565b91829055509150611f798383614c66565b50611fab8260008060405180606001604052806000600f0b815260200160008152602001600115158152506001614cd5565b6000828152600960209081526040808320805460ff1916600217905580516301a15ccf60e31b8152905183926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001692630d0ae67892600480830193928290030181865afa158015612028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061204c9190615c5e565b60025460405163dabc8e8360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152918216602482015291169063dabc8e839060440160408051808303816000875af11580156120be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120e29190615c94565b6000868152600d6020908152604080832080546001600160a01b038781166001600160a01b03199283168117909355600e8552948390208054878716921682179055825191825292810192909252939550919350858116928792918916917fae65a147ec014982132ce8b32019735e3c5f41457848d2ce2e2c3e0cbc9df7bc910160405180910390a45050506121786001600055565b919050565b61100283838360405180602001604052806000815250612e44565b60006121a48383614154565b90505b92915050565b6121b5615651565b600083815260196020526040902082633b9aca0081106121d7576121d7615bc4565b6040805160a081018252600492909202929092018054600f81810b8452600160801b909104900b60208301526001810154928201929092526002820154606082015260039091015460808201529392505050565b600080612236613ced565b6000612240613c8e565b9050600061224d86613cd2565b90506001600160a01b03811661227657604051632c2151ef60e11b815260040160405180910390fd5b6001600160a01b0381166000908152601c602052604090205460ff161580156122ca575060008052601c6020527fb9c6de81004e18dedadca3e5eabaab449ca91dff6f58efc9461da635fe77f8495460ff16155b156122e857604051633df16fd960e21b815260040160405180910390fd5b60008681526009602052604081205460ff16600281111561230b5761230b615904565b14612329576040516317a66f3760e01b815260040160405180910390fd5b6000868152601e602052604090205460ff161561235957604051637c9a1cf960e01b815260040160405180910390fd5b6123638287614154565b6123805760405163390cdd9b60e21b815260040160405180910390fd5b60008681526018602090815260409182902082516060810184528154600f0b8152600182015492810183905260029091015460ff1615159281019290925242108015906123cf57508060400151155b156123ed576040516307b7d7dd60e51b815260040160405180910390fd5b85600f81900b60000361241357604051631f2a200560e01b815260040160405180910390fd5b80600f0b8260000151600f0b1361243d57604051636b2f218360e01b815260040160405180910390fd5b612446886141be565b6040805160608082018352600080835260208084018281528486018381528e845260188352868420955186546001600160801b0319166001600160801b0390911617865590516001860155516002909401805460ff19169415159490941790935583519182018452808252918101829052918201526124c8908990849061426e565b80826000018181516124da9190615c31565b600f0b9052506124ea8383614e92565b600f82900b835295506124fd8383614e92565b600087815260186020908152604091829020548582015183516001600160a01b038a1681526001600160801b0392831693810193909352858216838501521660608201524260808201529051919650869188918b917f8303de8187a6102fdc3fe20c756dddd68df0ae027b77e2391c19a855e0821f339181900360a00190a45050505061258a6001600055565b9250929050565b6040516332b53f5360e11b815260216004820152602060248201526001600160a01b038416604482015260648101839052608481018290526000907373746410b0dd4526e1fa00d0854e99ba54aefd309063656a7ea69060a401602060405180830381865af4158015612608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262c9190615bab565b90505b9392505050565b6002546001600160a01b031661264a613c8e565b6001600160a01b0316146126715760405163c18384c160e01b815260040160405180910390fd5b6000918252601e6020526040909120805460ff1916911515919091179055565b60006121a782613cd2565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08111156126dd576040516317e97eb760e31b815260040160405180910390fd5b6040805180820182526005808252641d9953919560da1b60209283015282518084018452908152640322e302e360dc1b9082015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527fc792e9874e7b42c234d1e8448cec020a0f065019c8cd6f7ccdb65b8c110157e9818401527fb4bcb154e38601c389396fa918314da42d4626f13ef6d0ceb07e5f5d26b2fbc360608201524660808201523060a0808301919091528351808303909101815260c0820184528051908301207f9947d5709c1682eaa3946b2d84115c9c0d1c946b149d76e69b457458b42ea29e60e083015261010082018b905261012082018a905261014082018990526101608083018990528451808403909101815261018083019094528351939092019290922061190160f01b6101a08401526101a283018290526101c2830181905290916000906101e20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa15801561289c573d6000803e3d6000fd5b5050506020604051035190506128b2818c614154565b6128cf5760405163390cdd9b60e21b815260040160405180910390fd5b6001600160a01b0381166128f657604051638baa579f60e01b815260040160405180910390fd5b6001600160a01b038116600090815260226020526040812080549161291a83615c7b565b91905055891461293d57604051633ab3447f60e11b815260040160405180910390fd5b8742111561295e57604051630819bdcd60e01b815260040160405180910390fd5b6129688b8b614a8a565b505050505b50505050505050565b6129ae6040518060a001604052806000600f0b81526020016000600f0b81526020016000815260200160008152602001600081525090565b50600090815260066020908152604091829020825160a0810184528154600f81810b8352600160801b909104900b9281019290925260018101549282019290925260028201546060820152600390910154608082015290565b60006121a782613f96565b600260009054906101000a90046001600160a01b03166001600160a01b0316630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a899190615c5e565b6001600160a01b0316612a9a613c8e565b6001600160a01b031614612ac157604051633b8d9d7560e21b815260040160405180910390fd5b6005546001600160a01b0390811690821603612af05760405163367558c360e01b815260040160405180910390fd5b6001600160a01b038116612b175760405163d92e233d60e01b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b0383169081179091556040517f1a6ce72407c68def4b7d2e724c896070d89cf2b2a2dd56b6897b5febd88420f590600090a250565b612b69613ced565b612b7a612b74613c8e565b83614154565b612b975760405163390cdd9b60e21b815260040160405180910390fd5b60008281526009602052604081205460ff166002811115612bba57612bba615904565b14612bd8576040516317a66f3760e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161580159282019290925290612c34576040516334d10f9560e11b815260040160405180910390fd5b600062093a8080612c458542615b57565b612c4f9190615b80565b612c599190615b94565b905042826020015111612c7f576040516307b7d7dd60e51b815260040160405180910390fd5b60008260000151600f0b13612ca75760405163f90e998d60e01b815260040160405180910390fd5b81602001518111612ccb57604051638e6b5b6760e01b815260040160405180910390fd5b612cd9630784ce0042615b57565b811115612cf95760405163f761f1cd60e01b815260040160405180910390fd5b612d0884600083856003614cd5565b604051848152600080516020615e668339815191529060200160405180910390a15050610fdb6001600055565b6000612d3f613c8e565b9050806001600160a01b0316836001600160a01b031603612d735760405163367558c360e01b815260040160405180910390fd5b6001600160a01b03818116600081815260126020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612de8613ced565b612df3612b74613c8e565b612e105760405163390cdd9b60e21b815260040160405180910390fd5b610fd182826002613d4b565b6000612e26613ced565b612e388383612e33613c8e565b614f2d565b90506121a76001600055565b6000612e4e613c8e565b9050612e5c85858584614026565b833b15612f6057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612e95908490899088908890600401615cc3565b6020604051808303816000875af1925050508015612ed0575060408051601f3d908101601f19168201909252612ecd91810190615d00565b60015b612f2d573d808015612efe576040519150601f19603f3d011682016040523d82523d6000602084013e612f03565b606091505b508051600003612f2557604051626b5e2960e61b815260040160405180910390fd5b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14612f5e5760405163279929b160e21b815260040160405180910390fd5b505b5050505050565b612f6f613ced565b604080516060808201835260008083526020808401829052838501829052845192830185528183528201819052928101839052612fad92919061426e565b612fb76001600055565b565b60606000612fc683613cd2565b6001600160a01b031603612fed57604051634a1850bf60e11b815260040160405180910390fd5b6004805460405163c87b56dd60e01b81529182018490526001600160a01b03169063c87b56dd90602401600060405180830381865afa158015613034573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121a79190810190615d1d565b613064613ced565b600061306e613c8e565b6000848152601e602052604090205490915060ff16156130a157604051637c9a1cf960e01b815260040160405180910390fd5b60008381526009602052604081205460ff1660028111156130c4576130c4615904565b146130e2576040516317a66f3760e01b815260040160405180910390fd5b60008281526009602052604081205460ff16600281111561310557613105615904565b14613123576040516317a66f3760e01b815260040160405180910390fd5b818303613143576040516349da877960e11b815260040160405180910390fd5b61314d8184614154565b61316a5760405163390cdd9b60e21b815260040160405180910390fd5b6131748183614154565b6131915760405163390cdd9b60e21b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b8152600182015492810183905260029091015460ff1615159281019290925242108015906131e057508060400151155b156131fe576040516307b7d7dd60e51b815260040160405180910390fd5b60008481526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff16158015928201929092529061325a576040516334d10f9560e11b815260040160405180910390fd5b600082602001518260200151101561327657826020015161327c565b81602001515b9050613287866141be565b6040805160608082018352600080835260208084018281528486018381528c845260188352868420955186546001600160801b0319166001600160801b0390911617865590516001860155516002909401805460ff1916941515949094179093558351918201845280825291810182905291820152613309908790849061426e565b6040805160608101825260008082526020820181905291810191909152825184516133349190615d8b565b600f0b815260408085015115801591830191909152613371578260000151600f0b601d60008282546133669190615b57565b909155506133799050565b602081018290525b6000868152601f602052604090205483516133999190600f0b6001614be9565b6133a486858361426e565b600086815260186020908152604091829020835181546001600160801b039182166001600160801b0319909116811783558584015160018401819055868601516002909401805494151560ff19909516949094179093558751895186519184168252831694810194909452838501521660608201524260808201529051879189916001600160a01b038916917f986e3c958e3bdf1f58c2150357fc94624dd4e77b08f9802d8e2e885fa0d6a198919081900360a00190a4604051868152600080516020615e66833981519152906020015b60405180910390a15050505050610fdb6001600055565b613497612b74613c8e565b6134b45760405163390cdd9b60e21b815260040160405180910390fd5b610fdb8282614a8a565b60006121a4838361503f565b6134d2613ced565b6002546001600160a01b03166134e6613c8e565b6001600160a01b03161461350d5760405163c18384c160e01b815260040160405180910390fd5b600260008281526009602052604090205460ff16600281111561353257613532615904565b146135505760405163054b1e0160e51b815260040160405180910390fd5b60008281526009602052604081205460ff16600281111561357357613573615904565b14613591576040516317a66f3760e01b815260040160405180910390fd5b61359b824261503f565b6000036135bb5760405163334ab3f560e11b815260040160405180910390fd5b60008281526018602052604090208054600290910154600f9190910b9060ff161561360c57806001600160801b0316601d60008282546135fb9190615b44565b9091555061360c9050836000614a8a565b60008381526018602090815260408083208151606080820184528254600f0b825260018301548286015260029092015460ff1615158184015282519182018352848252928101849052908101929092526136689185919061426e565b60408051606081018252600080825260208083018281528385018381528884526018909252938220925183546001600160801b0319166001600160801b0391821617845593516001840155516002909201805460ff191692151592909217909155601d8054928416928392906136df908490615b57565b909155505060008381526018602090815260409182902082516060810184528154600f0b80825260018301549382019390935260029091015460ff1615159281019290925283908290613733908390615d8b565b600f0b9052506000848152601f602052604090205461375d906001600160801b0385166001614be9565b60008481526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161515918101919091526137a69085908361426e565b6000848152601860209081526040808320845181546001600160801b0319166001600160801b0391821617825585840151600180840191909155868401516002909301805460ff199081169415159490941790558a8652600b85528386208a875285528386208890558a8652600a85528386208a905560098552838620805490931617909155878452600d9092529182902054915163f320772360e01b81529085166004820152602481018790526001600160a01b0390911690819063f320772390604401600060405180830381600087803b15801561388557600080fd5b505af1158015613899573d6000803e3d6000fd5b5050506000868152600e60205260409081902054905163f320772360e01b81526001600160801b0387166004820152602481018990526001600160a01b039091169150819063f320772390604401600060405180830381600087803b15801561390157600080fd5b505af1158015613915573d6000803e3d6000fd5b50505050858761392489613cd2565b6001600160a01b03167ff7757ce35992f4ee014dee2e0c97ed6245758960a6ecc9e124897a5fb7b014238742604051613967929190918252602082015260400190565b60405180910390a4604051878152600080516020615e6683398151915290602001613475565b6000613997613c8e565b90506139a38183614154565b6139c05760405163390cdd9b60e21b815260040160405180910390fd5b60008281526009602052604081205460ff1660028111156139e3576139e3615904565b14613a01576040516317a66f3760e01b815260040160405180910390fd5b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff161580159282019290925290613a5d576040516334d10f9560e11b815260040160405180910390fd5b42816020015111613a81576040516307b7d7dd60e51b815260040160405180910390fd5b60008160000151600f0b13613aa95760405163f90e998d60e01b815260040160405180910390fd5b60008160000151600f0b905080601d6000828254613ac79190615b57565b90915550506000602080840182905260016040808601829052878452601883529283902083516060810185528154600f0b8152918101549282019290925260029091015460ff16151591810191909152613b239085908461426e565b600084815260186020908152604091829020845181546001600160801b0319166001600160801b03909116178155848201516001820155848301516002909101805460ff19169115159190911790558151838152429181019190915285916001600160a01b038616917f793cb7a30a4bb8669ec607dfcbdc93f5a3e9d282f38191fddab43ccaf79efb809101611647565b600081815260136020526040812054439003613bd257506000919050565b6121a7824261503f565b6000613be6613ced565b613bf1848484614f2d565b905061262f6001600055565b613c3160405180608001604052806000815260200160006001600160a01b0316815260200160008152602001600081525090565b5060009182526020808052604080842065ffffffffffff9390931684529181529181902081516080810183528154815260018201546001600160a01b03169381019390935260028101549183019190915260030154606082015290565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303613ccd575060131936013560601c90565b503390565b6000908152600f60205260409020546001600160a01b031690565b600260005403613d445760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600055565b60008381526009602052604090205460ff166001816002811115613d7157613d71615904565b03613d8f57604051635eb32db160e11b815260040160405180910390fd5b600084815260186020908152604080832081516060810183528154600f0b81526001820154938101939093526002015460ff1615159082015290849003613de957604051631f2a200560e01b815260040160405180910390fd5b60008160000151600f0b13613e115760405163f90e998d60e01b815260040160405180910390fd5b42816020015111158015613e2757508060400151155b15613e45576040516307b7d7dd60e51b815260040160405180910390fd5b806040015115613e675783601d6000828254613e619190615b57565b90915550505b6000858152601f6020526040902054613e8290856001614be9565b613e90858560008487614cd5565b6002826002811115613ea457613ea4615904565b03613f6e576000858152600d60205260409020546001600160a01b03908116907f000000000000000000000000000000000000000000000000000000000000000090613ef390821683886150cb565b60405163b66503cf60e01b81526001600160a01b0382811660048301526024820188905283169063b66503cf90604401600060405180830381600087803b158015613f3d57600080fd5b505af1158015613f51573d6000803e3d6000fd5b50613f6b925050506001600160a01b0382168360006150cb565b50505b604051858152600080516020615e668339815191529060200160405180910390a15050505050565b601654604051637259b01960e01b8152601b6004820152600660248201526044810191909152606481018290526000907379bca9bcc19e157cb5f8c5a2f4d6cb951b1f8dce90637259b01990608401602060405180830381865af4158015614002573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a79190615bab565b600160008381526009602052604090205460ff16600281111561404b5761404b615904565b0361406957604051635eb32db160e11b815260040160405180910390fd5b6140738183614154565b6140905760405163390cdd9b60e21b815260040160405180910390fd5b836001600160a01b03166140a383613cd2565b6001600160a01b0316146140ca576040516330cd747160e01b815260040160405180910390fd5b600082815260116020526040902080546001600160a01b03191690556140f084836151e0565b6140fc82600085615261565b61410683836152cb565b6000828152601360205260408082204390555183916001600160a01b0380871692908816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a450505050565b60008061416083613cd2565b6000848152601160209081526040808320546001600160a01b0380861680865260128552838620828c1680885295529290942054949550908214939216149060ff1682806141ab5750815b806141b35750805b979650505050505050565b60006141c8613c8e565b90506141d48183614154565b6141f15760405163390cdd9b60e21b815260040160405180910390fd5b60006141fc83613cd2565b600084815260116020526040812080546001600160a01b031916905590915061422790849080615261565b61423181846151e0565b60405183906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a4505050565b614276615651565b61427e615651565b601654600090819087156143bc57856040015161429c5760006142a2565b8551600f0b5b60808501526020870151421080156142c1575060008760000151600f0b135b156143065786516142d790630784ce0090615db8565b600f0b6020808701919091528701516142f1904290615b44565b85602001516143009190615df6565b600f0b85525b428660200151118015614320575060008660000151600f0b135b1561436557855161433690630784ce0090615db8565b600f0b602080860191909152860151614350904290615b44565b846020015161435f9190615df6565b600f0b84525b6020808801516000908152601b8252604090205490870151600f9190910b9350156143bc5786602001518660200151036143a1578291506143bc565b6020808701516000908152601b9091526040902054600f0b91505b6040805160a0810182526000808252602082018190524292820192909252436060820152608081019190915281156144455750600081815260066020908152604091829020825160a0810184528154600f81810b8352600160801b909104900b928101929092526001810154928201929092526002820154606082015260039091015460808201525b60008160400151905060006040518060a001604052808460000151600f0b81526020018460200151600f0b8152602001846040015181526020018460600151815260200184608001518152509050600083604001514211156144de5760408401516144b09042615b44565b60608501516144bf9043615b44565b6144d190670de0b6b3a7640000615b94565b6144db9190615b80565b90505b600062093a806144ee8186615b80565b6144f89190615b94565b905060005b60ff81101561467c5761451362093a8083615b57565b91506000428311156145275742925061453b565b506000828152601b6020526040902054600f0b5b6145458684615b44565b87602001516145549190615df6565b87518890614563908390615c31565b600f0b90525060208701805182919061457d908390615d8b565b600f90810b90915288516000910b1215905061459857600087525b60008760200151600f0b12156145b057600060208801525b60408088018490528501519295508592670de0b6b3a7640000906145d49085615b44565b6145de9086615b94565b6145e89190615b80565b85606001516145f79190615b57565b6060880152614607600189615b57565b975042830361461c575043606087015261467c565b6000888152600660209081526040918290208951918a01516001600160801b03908116600160801b0292169190911781559088015160018201556060880151600282015560808801516003909101555061467581615c7b565b90506144fd565b50508b1561470b57886020015188602001516146989190615c31565b846020018181516146a99190615d8b565b600f0b905250885188516146bd9190615c31565b845185906146cc908390615d8b565b600f90810b90915260208601516000910b121590506146ed57600060208501525b60008460000151600f0b121561470257600084525b601d5460808501525b8460011415801561473b57504260066000614727600189615b44565b815260200190815260200160002060010154145b156147a5578360066000614750600189615b44565b815260208082019290925260409081016000208351928401516001600160801b03908116600160801b0293169290921782558201516001820155606082015160028201556080909101516003909101556147fa565b60168590556000858152600660209081526040918290208651918701516001600160801b03908116600160801b0292169190911781559085015160018201556060850151600282015560808501516003909101555b8b15614a1957428b60200151111561486c57602089015161481b9088615d8b565b96508a602001518a602001510361483e57602088015161483b9088615c31565b96505b60208b8101516000908152601b9091526040902080546001600160801b0319166001600160801b0389161790555b428a6020015111156148c7578a602001518a6020015111156148c75760208801516148979087615c31565b60208b8101516000908152601b9091526040902080546001600160801b0319166001600160801b03831617905595505b426040808a01919091524360608a015260008d8152601a6020522054801580159061491b575060008d8152601960205260409020429082633b9aca00811061491157614911615bc4565b6004020160010154145b156149915760008d8152601960205260409020899082633b9aca00811061494457614944615bc4565b825160208401516001600160801b03908116600160801b02911617600491909102919091019081556040820151600182015560608201516002820155608090910151600390910155614a17565b61499a81615c7b565b60008e8152601a6020908152604080832084905560199091529020909150899082633b9aca0081106149ce576149ce615bc4565b825160208401516001600160801b03908116600160801b029116176004919091029190910190815560408201516001820155606082015160028201556080909101516003909101555b505b505050505050505050505050565b6040516001600160a01b03831660248201526044810182905261100290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261535d565b60008281526018602090815260409182902082516060810184528154600f0b81526001820154928101929092526002015460ff16151591810182905290614ae457604051632188f8ab60e01b815260040160405180910390fd5b8115801590614b0457506000614af983613cd2565b6001600160a01b0316145b15614b2257604051634a1850bf60e11b815260040160405180910390fd5b600083815260136020526040902054439003614b51576040516342d6fce760e01b815260040160405180910390fd5b828203614b5d57600091505b6000838152601f6020526040902054828103614b795750505050565b81516001600160801b0316614b978585614b9282613cd2565b615261565b614ba384826001614be9565b8382614bad613c8e565b6001600160a01b03167ff1aa2a9e40138176a3ee6099df056f5c175f8511a0d8b8275d94d1ea5de4677360405160405180910390a45050505050565b6040516375f199b960e11b81526021600482015260206024820152604481018490526064810183905281151560848201527373746410b0dd4526e1fa00d0854e99ba54aefd309063ebe333729060a4015b60006040518083038186803b158015614c5257600080fd5b505af415801561296d573d6000803e3d6000fd5b60006001600160a01b038316614c7e57614c7e615e16565b614c8883836152cb565b614c9482600085615261565b60405182906001600160a01b038516906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450600192915050565b601754614ce28582615b57565b6017556040805160608101825260008082526020808301828152838501928352875191880151948801511515909252929052600f9190910b80825286908290614d2c908390615d8b565b600f0b9052508415614d4057602081018590525b600087815260186020908152604091829020835181546001600160801b0319166001600160801b03909116178155908301516001820155908201516002909101805460ff1916911515919091179055614d9a87858361426e565b6000614da4613c8e565b90508615614de157614de16001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001682308a61542f565b836003811115614df357614df3615904565b602083810151604080518b8152928301919091524282820152518a916001600160a01b038516917f8835c22a0c751188de86681e15904223c054bedd5c68ec8858945b78312902739181900360600190a47f5e2aa66efd74cce82b21852e317e5490d9ecc9e6bb953ae24d90851258cc2f5c83614e708982615b57565b6040805192835260208301919091520160405180910390a15050505050505050565b6000600860008154614ea390615c7b565b91829055506000818152601860209081526040808320865181546001600160801b0319166001600160801b03909116178155868301516001820155868201516002909101805460ff19169115159190911790558051606081018252838152918201839052810191909152909150614f1c9082908461426e565b614f268382614c66565b5092915050565b60008062093a8080614f3f8642615b57565b614f499190615b80565b614f539190615b94565b905084600003614f7657604051631f2a200560e01b815260040160405180910390fd5b428111614f9657604051638e6b5b6760e01b815260040160405180910390fd5b614fa4630784ce0042615b57565b811115614fc45760405163f761f1cd60e01b815260040160405180910390fd5b6000600860008154614fd590615c7b565b91829055509050614fe68482614c66565b5060008181526018602090815260409182902082516060810184528154600f0b81526001808301549382019390935260029091015460ff1615159281019290925261503691839189918691614cd5565b95945050505050565b604051637b29b3d160e01b8152601a60048201526019602482015260448101839052606481018290526000907379bca9bcc19e157cb5f8c5a2f4d6cb951b1f8dce90637b29b3d190608401602060405180830381865af41580156150a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a49190615bab565b8015806151455750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561511f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906151439190615bab565b155b6151b05760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401613d3b565b6040516001600160a01b03831660248201526044810182905261100290849063095ea7b360e01b90606401614a53565b816001600160a01b03166151f382613cd2565b6001600160a01b03161461520957615209615e16565b6000818152600f6020526040902080546001600160a01b031916905561522f828261546d565b6001600160a01b0382166000908152601060205260408120805460019290615258908490615b44565b90915550505050565b60405163690f66bf60e01b8152601860048201526021602482015260206044820152601f60648201526084810184905260a481018390526001600160a01b03821660c48201527373746410b0dd4526e1fa00d0854e99ba54aefd309063690f66bf9060e401614c3a565b60006152d682613cd2565b6001600160a01b0316146152ec576152ec615e16565b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b038716908117909155808452601080845282852080546014865284872081885286528487208890558787526015865293862093909355908452909152805460019290615258908490615b57565b60006153b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661552c9092919063ffffffff16565b80519091501561100257808060200190518101906153d09190615e2c565b6110025760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401613d3b565b6040516001600160a01b03808516602483015283166044820152606481018290526154679085906323b872dd60e01b90608401614a53565b50505050565b6001600160a01b03821660009081526010602052604081205461549290600190615b44565b6000838152601560205260409020549091508082036154e1576001600160a01b038416600090815260146020908152604080832085845282528083208390558583526015909152812055615467565b6001600160a01b039390931660009081526014602090815260408083209383529281528282208054868452848420819055835260159091528282209490945592839055908252812055565b606061262c848460008585600080866001600160a01b031685876040516155539190615e49565b60006040518083038185875af1925050503d8060008114615590576040519150601f19603f3d011682016040523d82523d6000602084013e615595565b606091505b50915091506155a6878383876155b3565b925050505b949350505050565b6060831561562257825160000361561b576001600160a01b0385163b61561b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401613d3b565b50816155ab565b6155ab83838151156156375781518083602001fd5b8060405162461bcd60e51b8152600401613d3b9190615709565b6040518060a001604052806000600f0b81526020016000600f0b81526020016000815260200160008152602001600081525090565b6001600160e01b03198116811461131257600080fd5b6000602082840312156156ae57600080fd5b813561262f81615686565b60005b838110156156d45781810151838201526020016156bc565b50506000910152565b600081518084526156f58160208601602086016156b9565b601f01601f19169290920160200192915050565b6020815260006121a460208301846156dd565b60006020828403121561572e57600080fd5b5035919050565b6001600160a01b038116811461131257600080fd5b60006020828403121561575c57600080fd5b813561262f81615735565b6000806040838503121561577a57600080fd5b823561578581615735565b946020939093013593505050565b600080604083850312156157a657600080fd5b50508035926020909101359150565b6000806000606084860312156157ca57600080fd5b83356157d581615735565b925060208401356157e581615735565b929592945050506040919091013590565b6000806040838503121561580957600080fd5b823561581481615735565b9150602083013561582481615735565b809150509250929050565b801515811461131257600080fd5b6000806040838503121561585057600080fd5b823561585b81615735565b915060208301356158248161582f565b6000806040838503121561587e57600080fd5b8235915060208301356158248161582f565b60a081016121a782848051600f0b82526020810151600f0b60208301526040810151604083015260608101516060830152608081015160808301525050565b6000806000606084860312156158e457600080fd5b83356158ef81615735565b95602085013595506040909401359392505050565b634e487b7160e01b600052602160045260246000fd5b602081016003831061593c57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600080600080600060e0888a03121561595d57600080fd5b87359650602088013595506040880135945060608801359350608088013560ff8116811461598a57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156159e6576159e66159a7565b604052919050565b600067ffffffffffffffff821115615a0857615a086159a7565b50601f01601f191660200190565b60008060008060808587031215615a2c57600080fd5b8435615a3781615735565b93506020850135615a4781615735565b925060408501359150606085013567ffffffffffffffff811115615a6a57600080fd5b8501601f81018713615a7b57600080fd5b8035615a8e615a89826159ee565b6159bd565b818152886020838501011115615aa357600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b600080600060608486031215615ada57600080fd5b83359250602084013591506040840135615af381615735565b809150509250925092565b60008060408385031215615b1157600080fd5b82359150602083013565ffffffffffff8116811461582457600080fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156121a7576121a7615b2e565b808201808211156121a7576121a7615b2e565b634e487b7160e01b600052601260045260246000fd5b600082615b8f57615b8f615b6a565b500490565b80820281158282048414176121a7576121a7615b2e565b600060208284031215615bbd57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000604082018483526020604081850152818551808452606086019150828701935060005b81811015615c245784516001600160a01b031683529383019391830191600101615bff565b5090979650505050505050565b600f82810b9082900b0360016001607f1b0319811260016001607f1b03821317156121a7576121a7615b2e565b600060208284031215615c7057600080fd5b815161262f81615735565b600060018201615c8d57615c8d615b2e565b5060010190565b60008060408385031215615ca757600080fd5b8251615cb281615735565b602084015190925061582481615735565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615cf6908301846156dd565b9695505050505050565b600060208284031215615d1257600080fd5b815161262f81615686565b600060208284031215615d2f57600080fd5b815167ffffffffffffffff811115615d4657600080fd5b8201601f81018413615d5757600080fd5b8051615d65615a89826159ee565b818152856020838501011115615d7a57600080fd5b6150368260208301602086016156b9565b600f81810b9083900b0160016001607f1b03811360016001607f1b0319821217156121a7576121a7615b2e565b600081600f0b83600f0b80615dcf57615dcf615b6a565b60016001607f1b0319821460001982141615615ded57615ded615b2e565b90059392505050565b600082600f0b82600f0b0280600f0b9150808214614f2657614f26615b2e565b634e487b7160e01b600052600160045260246000fd5b600060208284031215615e3e57600080fd5b815161262f8161582f565b60008251615e5b8184602087016156b9565b919091019291505056fef8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce7a2646970667358221220c775f186d65f1ef762c5b76afb4b778f0956d15e43522d2dd91ac354d1378e6864736f6c63430008130033ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef00000000000000000000000006824df38d1d77eadeb6bafcb03904e27429ab740000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db000000000000000000000000f4c67cdeaab8360370f41514d06e32ccd8aa1d7b","name":"VotingEscrow","is_blueprint":false,"license_type":"none","is_fully_verified":false,"is_verified_via_eth_bytecode_db":true,"language":"solidity","evm_version":"paris","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":true,"additional_sources":[{"file_path":"contracts/interfaces/IVoter.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IVoter {\n    error AlreadyVotedOrDeposited();\n    error DistributeWindow();\n    error FactoryPathNotApproved();\n    error GaugeAlreadyKilled();\n    error GaugeAlreadyRevived();\n    error GaugeExists();\n    error GaugeDoesNotExist(address _pool);\n    error GaugeNotAlive(address _gauge);\n    error InactiveManagedNFT();\n    error MaximumVotingNumberTooLow();\n    error NonZeroVotes();\n    error NotAPool();\n    error NotApprovedOrOwner();\n    error NotGovernor();\n    error NotEmergencyCouncil();\n    error NotMinter();\n    error NotWhitelistedNFT();\n    error NotWhitelistedToken();\n    error SameValue();\n    error SpecialVotingWindow();\n    error TooManyPools();\n    error UnequalLengths();\n    error ZeroBalance();\n    error ZeroAddress();\n\n    event GaugeCreated(\n        address indexed poolFactory,\n        address indexed votingRewardsFactory,\n        address indexed gaugeFactory,\n        address pool,\n        address bribeVotingReward,\n        address feeVotingReward,\n        address gauge,\n        address creator\n    );\n    event GaugeKilled(address indexed gauge);\n    event GaugeRevived(address indexed gauge);\n    event Voted(\n        address indexed voter,\n        address indexed pool,\n        uint256 indexed tokenId,\n        uint256 weight,\n        uint256 totalWeight,\n        uint256 timestamp\n    );\n    event Abstained(\n        address indexed voter,\n        address indexed pool,\n        uint256 indexed tokenId,\n        uint256 weight,\n        uint256 totalWeight,\n        uint256 timestamp\n    );\n    event NotifyReward(address indexed sender, address indexed reward, uint256 amount);\n    event DistributeReward(address indexed sender, address indexed gauge, uint256 amount);\n    event WhitelistToken(address indexed whitelister, address indexed token, bool indexed _bool);\n    event WhitelistNFT(address indexed whitelister, uint256 indexed tokenId, bool indexed _bool);\n\n    // mappings\n    function gauges(address pool) external view returns (address);\n\n    function poolForGauge(address gauge) external view returns (address);\n\n    function gaugeToFees(address gauge) external view returns (address);\n\n    function gaugeToBribe(address gauge) external view returns (address);\n\n    function weights(address pool) external view returns (uint256);\n\n    function votes(uint256 tokenId, address pool) external view returns (uint256);\n\n    function usedWeights(uint256 tokenId) external view returns (uint256);\n\n    function lastVoted(uint256 tokenId) external view returns (uint256);\n\n    function isGauge(address) external view returns (bool);\n\n    function isWhitelistedToken(address token) external view returns (bool);\n\n    function isWhitelistedNFT(uint256 tokenId) external view returns (bool);\n\n    function isAlive(address gauge) external view returns (bool);\n\n    function ve() external view returns (address);\n\n    function governor() external view returns (address);\n\n    function epochGovernor() external view returns (address);\n\n    function emergencyCouncil() external view returns (address);\n\n    function length() external view returns (uint256);\n\n    /// @notice Called by Minter to distribute weekly emissions rewards for disbursement amongst gauges.\n    /// @dev Assumes totalWeight != 0 (Will never be zero as long as users are voting).\n    ///      Throws if not called by minter.\n    /// @param _amount Amount of rewards to distribute.\n    function notifyRewardAmount(uint256 _amount) external;\n\n    /// @dev Utility to distribute to gauges of pools in range _start to _finish.\n    /// @param _start   Starting index of gauges to distribute to.\n    /// @param _finish  Ending index of gauges to distribute to.\n    function distribute(uint256 _start, uint256 _finish) external;\n\n    /// @dev Utility to distribute to gauges of pools in array.\n    /// @param _gauges Array of gauges to distribute to.\n    function distribute(address[] memory _gauges) external;\n\n    /// @notice Called by users to update voting balances in voting rewards contracts.\n    /// @param _tokenId Id of veNFT whose balance you wish to update.\n    function poke(uint256 _tokenId) external;\n\n    /// @notice Called by users to vote for pools. Votes distributed proportionally based on weights.\n    ///         Can only vote or deposit into a managed NFT once per epoch.\n    ///         Can only vote for gauges that have not been killed.\n    /// @dev Weights are distributed proportional to the sum of the weights in the array.\n    ///      Throws if length of _poolVote and _weights do not match.\n    /// @param _tokenId     Id of veNFT you are voting with.\n    /// @param _poolVote    Array of pools you are voting for.\n    /// @param _weights     Weights of pools.\n    function vote(uint256 _tokenId, address[] calldata _poolVote, uint256[] calldata _weights) external;\n\n    /// @notice Called by users to reset voting state. Required if you wish to make changes to\n    ///         veNFT state (e.g. merge, split, deposit into managed etc).\n    ///         Cannot reset in the same epoch that you voted in.\n    ///         Can vote or deposit into a managed NFT again after reset.\n    /// @param _tokenId Id of veNFT you are reseting.\n    function reset(uint256 _tokenId) external;\n\n    /// @notice Called by users to deposit into a managed NFT.\n    ///         Can only vote or deposit into a managed NFT once per epoch.\n    ///         Note that NFTs deposited into a managed NFT will be re-locked\n    ///         to the maximum lock time on withdrawal.\n    /// @dev Throws if not approved or owner.\n    ///      Throws if managed NFT is inactive.\n    ///      Throws if depositing within privileged window (one hour prior to epoch flip).\n    function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;\n\n    /// @notice Called by users to withdraw from a managed NFT.\n    ///         Cannot do it in the same epoch that you deposited into a managed NFT.\n    ///         Can vote or deposit into a managed NFT again after withdrawing.\n    ///         Note that the NFT withdrawn is re-locked to the maximum lock time.\n    function withdrawManaged(uint256 _tokenId) external;\n\n    /// @notice Claim emissions from gauges.\n    /// @param _gauges Array of gauges to collect emissions from.\n    function claimRewards(address[] memory _gauges) external;\n\n    /// @notice Claim bribes for a given NFT.\n    /// @dev Utility to help batch bribe claims.\n    /// @param _bribes  Array of BribeVotingReward contracts to collect from.\n    /// @param _tokens  Array of tokens that are used as bribes.\n    /// @param _tokenId Id of veNFT that you wish to claim bribes for.\n    function claimBribes(address[] memory _bribes, address[][] memory _tokens, uint256 _tokenId) external;\n\n    /// @notice Claim fees for a given NFT.\n    /// @dev Utility to help batch fee claims.\n    /// @param _fees    Array of FeesVotingReward contracts to collect from.\n    /// @param _tokens  Array of tokens that are used as fees.\n    /// @param _tokenId Id of veNFT that you wish to claim fees for.\n    function claimFees(address[] memory _fees, address[][] memory _tokens, uint256 _tokenId) external;\n\n    /// @notice Set new governor.\n    /// @dev Throws if not called by governor.\n    /// @param _governor .\n    function setGovernor(address _governor) external;\n\n    /// @notice Set new epoch based governor.\n    /// @dev Throws if not called by governor.\n    /// @param _epochGovernor .\n    function setEpochGovernor(address _epochGovernor) external;\n\n    /// @notice Set new emergency council.\n    /// @dev Throws if not called by emergency council.\n    /// @param _emergencyCouncil .\n    function setEmergencyCouncil(address _emergencyCouncil) external;\n\n    /// @notice Whitelist (or unwhitelist) token for use in bribes.\n    /// @dev Throws if not called by governor.\n    /// @param _token .\n    /// @param _bool .\n    function whitelistToken(address _token, bool _bool) external;\n\n    /// @notice Whitelist (or unwhitelist) token id for voting in last hour prior to epoch flip.\n    /// @dev Throws if not called by governor.\n    ///      Throws if already whitelisted.\n    /// @param _tokenId .\n    /// @param _bool .\n    function whitelistNFT(uint256 _tokenId, bool _bool) external;\n\n    /// @notice Create a new gauge (unpermissioned).\n    /// @dev Governor can create a new gauge for a pool with any address.\n    /// @dev V1 gauges can only be created by governor.\n    /// @param _poolFactory .\n    /// @param _pool .\n    function createGauge(address _poolFactory, address _pool) external returns (address);\n\n    /// @notice Kills a gauge. The gauge will not receive any new emissions and cannot be deposited into.\n    ///         Can still withdraw from gauge.\n    /// @dev Throws if not called by emergency council.\n    ///      Throws if gauge already killed.\n    /// @param _gauge .\n    function killGauge(address _gauge) external;\n\n    /// @notice Revives a killed gauge. Gauge will can receive emissions and deposits again.\n    /// @dev Throws if not called by emergency council.\n    ///      Throws if gauge is not killed.\n    /// @param _gauge .\n    function reviveGauge(address _gauge) external;\n\n    /// @dev Update claims to emissions for an array of gauges.\n    /// @param _gauges Array of gauges to update emissions for.\n    function updateFor(address[] memory _gauges) external;\n\n    /// @dev Update claims to emissions for gauges based on their pool id as stored in Voter.\n    /// @param _start   Starting index of pools.\n    /// @param _end     Ending index of pools.\n    function updateFor(uint256 _start, uint256 _end) external;\n\n    /// @dev Update claims to emissions for single gauge\n    /// @param _gauge .\n    function updateFor(address _gauge) external;\n}\n"},{"file_path":"contracts/interfaces/IVotingEscrow.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {IERC721, IERC721Metadata} from \"@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol\";\nimport {IERC4906} from \"@openzeppelin/contracts/interfaces/IERC4906.sol\";\nimport {IVotes} from \"../governance/IVotes.sol\";\n\ninterface IVotingEscrow is IVotes, IERC4906, IERC721Metadata {\n    struct LockedBalance {\n        int128 amount;\n        uint256 end;\n        bool isPermanent;\n    }\n\n    struct UserPoint {\n        int128 bias;\n        int128 slope; // # -dweight / dt\n        uint256 ts;\n        uint256 blk; // block\n        uint256 permanent;\n    }\n\n    struct GlobalPoint {\n        int128 bias;\n        int128 slope; // # -dweight / dt\n        uint256 ts;\n        uint256 blk; // block\n        uint256 permanentLockBalance;\n    }\n\n    /// @notice A checkpoint for recorded delegated voting weights at a certain timestamp\n    struct Checkpoint {\n        uint256 fromTimestamp;\n        address owner;\n        uint256 delegatedBalance;\n        uint256 delegatee;\n    }\n\n    enum DepositType {\n        DEPOSIT_FOR_TYPE,\n        CREATE_LOCK_TYPE,\n        INCREASE_LOCK_AMOUNT,\n        INCREASE_UNLOCK_TIME\n    }\n\n    /// @dev Different types of veNFTs:\n    /// NORMAL  - typical veNFT\n    /// LOCKED  - veNFT which is locked into a MANAGED veNFT\n    /// MANAGED - veNFT which can accept the deposit of NORMAL veNFTs\n    enum EscrowType {\n        NORMAL,\n        LOCKED,\n        MANAGED\n    }\n\n    error AlreadyVoted();\n    error AmountTooBig();\n    error ERC721ReceiverRejectedTokens();\n    error ERC721TransferToNonERC721ReceiverImplementer();\n    error InvalidNonce();\n    error InvalidSignature();\n    error InvalidSignatureS();\n    error InvalidManagedNFTId();\n    error LockDurationNotInFuture();\n    error LockDurationTooLong();\n    error LockExpired();\n    error LockNotExpired();\n    error NoLockFound();\n    error NonExistentToken();\n    error NotApprovedOrOwner();\n    error NotDistributor();\n    error NotEmergencyCouncilOrGovernor();\n    error NotGovernor();\n    error NotGovernorOrManager();\n    error NotManagedNFT();\n    error NotManagedOrNormalNFT();\n    error NotLockedNFT();\n    error NotNormalNFT();\n    error NotPermanentLock();\n    error NotOwner();\n    error NotTeam();\n    error NotVoter();\n    error OwnershipChange();\n    error PermanentLock();\n    error SameAddress();\n    error SameNFT();\n    error SameState();\n    error SplitNoOwner();\n    error SplitNotAllowed();\n    error SignatureExpired();\n    error TooManyTokenIDs();\n    error ZeroAddress();\n    error ZeroAmount();\n    error ZeroBalance();\n\n    event Deposit(\n        address indexed provider,\n        uint256 indexed tokenId,\n        DepositType indexed depositType,\n        uint256 value,\n        uint256 locktime,\n        uint256 ts\n    );\n    event Withdraw(address indexed provider, uint256 indexed tokenId, uint256 value, uint256 ts);\n    event LockPermanent(address indexed _owner, uint256 indexed _tokenId, uint256 amount, uint256 _ts);\n    event UnlockPermanent(address indexed _owner, uint256 indexed _tokenId, uint256 amount, uint256 _ts);\n    event Supply(uint256 prevSupply, uint256 supply);\n    event Merge(\n        address indexed _sender,\n        uint256 indexed _from,\n        uint256 indexed _to,\n        uint256 _amountFrom,\n        uint256 _amountTo,\n        uint256 _amountFinal,\n        uint256 _locktime,\n        uint256 _ts\n    );\n    event Split(\n        uint256 indexed _from,\n        uint256 indexed _tokenId1,\n        uint256 indexed _tokenId2,\n        address _sender,\n        uint256 _splitAmount1,\n        uint256 _splitAmount2,\n        uint256 _locktime,\n        uint256 _ts\n    );\n    event CreateManaged(\n        address indexed _to,\n        uint256 indexed _mTokenId,\n        address indexed _from,\n        address _lockedManagedReward,\n        address _freeManagedReward\n    );\n    event DepositManaged(\n        address indexed _owner,\n        uint256 indexed _tokenId,\n        uint256 indexed _mTokenId,\n        uint256 _weight,\n        uint256 _ts\n    );\n    event WithdrawManaged(\n        address indexed _owner,\n        uint256 indexed _tokenId,\n        uint256 indexed _mTokenId,\n        uint256 _weight,\n        uint256 _ts\n    );\n    event SetAllowedManager(address indexed _allowedManager);\n\n    // State variables\n    function factoryRegistry() external view returns (address);\n\n    function token() external view returns (address);\n\n    function distributor() external view returns (address);\n\n    function voter() external view returns (address);\n\n    function team() external view returns (address);\n\n    function artProxy() external view returns (address);\n\n    function allowedManager() external view returns (address);\n\n    function tokenId() external view returns (uint256);\n\n    /*///////////////////////////////////////////////////////////////\n                            MANAGED NFT STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @dev Mapping of token id to escrow type\n    ///      Takes advantage of the fact default value is EscrowType.NORMAL\n    function escrowType(uint256 tokenId) external view returns (EscrowType);\n\n    /// @dev Mapping of token id to managed id\n    function idToManaged(uint256 tokenId) external view returns (uint256 managedTokenId);\n\n    /// @dev Mapping of user token id to managed token id to weight of token id\n    function weights(uint256 tokenId, uint256 managedTokenId) external view returns (uint256 weight);\n\n    /// @dev Mapping of managed id to deactivated state\n    function deactivated(uint256 tokenId) external view returns (bool inactive);\n\n    /// @dev Mapping from managed nft id to locked managed rewards\n    ///      `token` denominated rewards (rebases/rewards) stored in locked managed rewards contract\n    ///      to prevent co-mingling of assets\n    function managedToLocked(uint256 tokenId) external view returns (address);\n\n    /// @dev Mapping from managed nft id to free managed rewards contract\n    ///      these rewards can be freely withdrawn by users\n    function managedToFree(uint256 tokenId) external view returns (address);\n\n    /*///////////////////////////////////////////////////////////////\n                            MANAGED NFT LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Create managed NFT (a permanent lock) for use within ecosystem.\n    /// @dev Throws if address already owns a managed NFT.\n    /// @return _mTokenId managed token id.\n    function createManagedLockFor(address _to) external returns (uint256 _mTokenId);\n\n    /// @notice Delegates balance to managed nft\n    ///         Note that NFTs deposited into a managed NFT will be re-locked\n    ///         to the maximum lock time on withdrawal.\n    ///         Permanent locks that are deposited will automatically unlock.\n    /// @dev Managed nft will remain max-locked as long as there is at least one\n    ///      deposit or withdrawal per week.\n    ///      Throws if deposit nft is managed.\n    ///      Throws if recipient nft is not managed.\n    ///      Throws if deposit nft is already locked.\n    ///      Throws if not called by voter.\n    /// @param _tokenId tokenId of NFT being deposited\n    /// @param _mTokenId tokenId of managed NFT that will receive the deposit\n    function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;\n\n    /// @notice Retrieves locked rewards and withdraws balance from managed nft.\n    ///         Note that the NFT withdrawn is re-locked to the maximum lock time.\n    /// @dev Throws if NFT not locked.\n    ///      Throws if not called by voter.\n    /// @param _tokenId tokenId of NFT being deposited.\n    function withdrawManaged(uint256 _tokenId) external;\n\n    /// @notice Permit one address to call createManagedLockFor() that is not Voter.governor()\n    function setAllowedManager(address _allowedManager) external;\n\n    /// @notice Set Managed NFT state. Inactive NFTs cannot be deposited into.\n    /// @param _mTokenId managed nft state to set\n    /// @param _state true => inactive, false => active\n    function setManagedState(uint256 _mTokenId, bool _state) external;\n\n    /*///////////////////////////////////////////////////////////////\n                             METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    function name() external view returns (string memory);\n\n    function symbol() external view returns (string memory);\n\n    function version() external view returns (string memory);\n\n    function decimals() external view returns (uint8);\n\n    function setTeam(address _team) external;\n\n    function setArtProxy(address _proxy) external;\n\n    /// @inheritdoc IERC721Metadata\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n\n    /*//////////////////////////////////////////////////////////////\n                      ERC721 BALANCE/OWNER STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @dev Mapping from owner address to mapping of index to tokenId\n    function ownerToNFTokenIdList(address _owner, uint256 _index) external view returns (uint256 _tokenId);\n\n    /// @inheritdoc IERC721\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /// @inheritdoc IERC721\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /*//////////////////////////////////////////////////////////////\n                         ERC721 APPROVAL STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IERC721\n    function getApproved(uint256 _tokenId) external view returns (address operator);\n\n    /// @inheritdoc IERC721\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n    /// @notice Check whether spender is owner or an approved user for a given veNFT\n    /// @param _spender .\n    /// @param _tokenId .\n    function isApprovedOrOwner(address _spender, uint256 _tokenId) external returns (bool);\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC721 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IERC721\n    function approve(address to, uint256 tokenId) external;\n\n    /// @inheritdoc IERC721\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /// @inheritdoc IERC721\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /// @inheritdoc IERC721\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /// @inheritdoc IERC721\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC165 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function supportsInterface(bytes4 _interfaceID) external view returns (bool);\n\n    /*//////////////////////////////////////////////////////////////\n                             ESCROW STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    function epoch() external view returns (uint256);\n\n    function supply() external view returns (uint256);\n\n    function userPointEpoch(uint256 _tokenId) external view returns (uint256 _epoch);\n\n    /// @notice time -> signed slope change\n    function slopeChanges(uint256 _timestamp) external view returns (int128);\n\n    /// @notice account -> can split\n    function canSplit(address _account) external view returns (bool);\n\n    /// @notice Global point history at a given index\n    function pointHistory(uint256 _loc) external view returns (GlobalPoint memory);\n\n    /// @notice Get the LockedBalance (amount, end) of a _tokenId\n    /// @param _tokenId .\n    /// @return LockedBalance of _tokenId\n    function locked(uint256 _tokenId) external view returns (LockedBalance memory);\n\n    /// @notice User -> UserPoint[userEpoch]\n    function userPointHistory(uint256 _tokenId, uint256 _loc) external view returns (UserPoint memory);\n\n    /*//////////////////////////////////////////////////////////////\n                              ESCROW LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Record global data to checkpoint\n    function checkpoint() external;\n\n    /// @notice Deposit `_value` tokens for `_tokenId` and add to the lock\n    /// @dev Anyone (even a smart contract) can deposit for someone else, but\n    ///      cannot extend their locktime and deposit for a brand new user\n    /// @param _tokenId lock NFT\n    /// @param _value Amount to add to user's lock\n    function depositFor(uint256 _tokenId, uint256 _value) external;\n\n    /// @notice Deposit `_value` tokens for `msg.sender` and lock for `_lockDuration`\n    /// @param _value Amount to deposit\n    /// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week)\n    /// @return TokenId of created veNFT\n    function createLock(uint256 _value, uint256 _lockDuration) external returns (uint256);\n\n    /// @notice Deposit `_value` tokens for `_to` and lock for `_lockDuration`\n    /// @param _value Amount to deposit\n    /// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week)\n    /// @param _to Address to deposit\n    /// @return TokenId of created veNFT\n    function createLockFor(uint256 _value, uint256 _lockDuration, address _to) external returns (uint256);\n\n    /// @notice Deposit `_value` additional tokens for `_tokenId` without modifying the unlock time\n    /// @param _value Amount of tokens to deposit and add to the lock\n    function increaseAmount(uint256 _tokenId, uint256 _value) external;\n\n    /// @notice Extend the unlock time for `_tokenId`\n    ///         Cannot extend lock time of permanent locks\n    /// @param _lockDuration New number of seconds until tokens unlock\n    function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external;\n\n    /// @notice Withdraw all tokens for `_tokenId`\n    /// @dev Only possible if the lock is both expired and not permanent\n    ///      This will burn the veNFT. Any rebases or rewards that are unclaimed\n    ///      will no longer be claimable. Claim all rebases and rewards prior to calling this.\n    function withdraw(uint256 _tokenId) external;\n\n    /// @notice Merges `_from` into `_to`.\n    /// @dev Cannot merge `_from` locks that are permanent or have already voted this epoch.\n    ///      Cannot merge `_to` locks that have already expired.\n    ///      This will burn the veNFT. Any rebases or rewards that are unclaimed\n    ///      will no longer be claimable. Claim all rebases and rewards prior to calling this.\n    /// @param _from VeNFT to merge from.\n    /// @param _to VeNFT to merge into.\n    function merge(uint256 _from, uint256 _to) external;\n\n    /// @notice Splits veNFT into two new veNFTS - one with oldLocked.amount - `_amount`, and the second with `_amount`\n    /// @dev    This burns the tokenId of the target veNFT\n    ///         Callable by approved or owner\n    ///         If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs\n    ///         Returns the two new split veNFTs to owner\n    ///         If `from` is permanent, will automatically dedelegate.\n    ///         This will burn the veNFT. Any rebases or rewards that are unclaimed\n    ///         will no longer be claimable. Claim all rebases and rewards prior to calling this.\n    /// @param _from VeNFT to split.\n    /// @param _amount Amount to split from veNFT.\n    /// @return _tokenId1 Return tokenId of veNFT with oldLocked.amount - `_amount`.\n    /// @return _tokenId2 Return tokenId of veNFT with `_amount`.\n    function split(uint256 _from, uint256 _amount) external returns (uint256 _tokenId1, uint256 _tokenId2);\n\n    /// @notice Toggle split for a specific veNFT.\n    /// @dev Toggle split for address(0) to enable or disable for all.\n    /// @param _account Address to toggle split permissions\n    /// @param _bool True to allow, false to disallow\n    function toggleSplit(address _account, bool _bool) external;\n\n    /// @notice Permanently lock a veNFT. Voting power will be equal to\n    ///         `LockedBalance.amount` with no decay. Required to delegate.\n    /// @dev Only callable by unlocked normal veNFTs.\n    /// @param _tokenId tokenId to lock.\n    function lockPermanent(uint256 _tokenId) external;\n\n    /// @notice Unlock a permanently locked veNFT. Voting power will decay.\n    ///         Will automatically dedelegate if delegated.\n    /// @dev Only callable by permanently locked veNFTs.\n    ///      Cannot unlock if already voted this epoch.\n    /// @param _tokenId tokenId to unlock.\n    function unlockPermanent(uint256 _tokenId) external;\n\n    /*///////////////////////////////////////////////////////////////\n                           GAUGE VOTING STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice Get the voting power for _tokenId at the current timestamp\n    /// @dev Returns 0 if called in the same block as a transfer.\n    /// @param _tokenId .\n    /// @return Voting power\n    function balanceOfNFT(uint256 _tokenId) external view returns (uint256);\n\n    /// @notice Get the voting power for _tokenId at a given timestamp\n    /// @param _tokenId .\n    /// @param _t Timestamp to query voting power\n    /// @return Voting power\n    function balanceOfNFTAt(uint256 _tokenId, uint256 _t) external view returns (uint256);\n\n    /// @notice Calculate total voting power at current timestamp\n    /// @return Total voting power at current timestamp\n    function totalSupply() external view returns (uint256);\n\n    /// @notice Calculate total voting power at a given timestamp\n    /// @param _t Timestamp to query total voting power\n    /// @return Total voting power at given timestamp\n    function totalSupplyAt(uint256 _t) external view returns (uint256);\n\n    /*///////////////////////////////////////////////////////////////\n                            GAUGE VOTING LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice See if a queried _tokenId has actively voted\n    /// @param _tokenId .\n    /// @return True if voted, else false\n    function voted(uint256 _tokenId) external view returns (bool);\n\n    /// @notice Set the global state voter and distributor\n    /// @dev This is only called once, at setup\n    function setVoterAndDistributor(address _voter, address _distributor) external;\n\n    /// @notice Set `voted` for _tokenId to true or false\n    /// @dev Only callable by voter\n    /// @param _tokenId .\n    /// @param _voted .\n    function voting(uint256 _tokenId, bool _voted) external;\n\n    /*///////////////////////////////////////////////////////////////\n                            DAO VOTING STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    /// @notice The number of checkpoints for each tokenId\n    function numCheckpoints(uint256 tokenId) external view returns (uint48);\n\n    /// @notice A record of states for signing / validating signatures\n    function nonces(address account) external view returns (uint256);\n\n    /// @inheritdoc IVotes\n    function delegates(uint256 delegator) external view returns (uint256);\n\n    /// @notice A record of delegated token checkpoints for each account, by index\n    /// @param tokenId .\n    /// @param index .\n    /// @return Checkpoint\n    function checkpoints(uint256 tokenId, uint48 index) external view returns (Checkpoint memory);\n\n    /// @inheritdoc IVotes\n    function getPastVotes(address account, uint256 tokenId, uint256 timestamp) external view returns (uint256);\n\n    /// @inheritdoc IVotes\n    function getPastTotalSupply(uint256 timestamp) external view returns (uint256);\n\n    /*///////////////////////////////////////////////////////////////\n                             DAO VOTING LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    /// @inheritdoc IVotes\n    function delegate(uint256 delegator, uint256 delegatee) external;\n\n    /// @inheritdoc IVotes\n    function delegateBySig(\n        uint256 delegator,\n        uint256 delegatee,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Address.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     *\n     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert(errorMessage);\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/Context.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"},{"file_path":"contracts/governance/IVotes.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\n/// Modified IVotes interface for tokenId based voting\ninterface IVotes {\n    /**\n     * @dev Emitted when an account changes their delegate.\n     */\n    event DelegateChanged(address indexed delegator, uint256 indexed fromDelegate, uint256 indexed toDelegate);\n\n    /**\n     * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.\n     */\n    event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance);\n\n    /**\n     * @dev Returns the amount of votes that `tokenId` had at a specific moment in the past.\n     *      If the account passed in is not the owner, returns 0.\n     */\n    function getPastVotes(address account, uint256 tokenId, uint256 timepoint) external view returns (uint256);\n\n    /**\n     * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is\n     * configured to use block numbers, this will return the value the end of the corresponding block.\n     *\n     * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.\n     * Votes that have not been delegated are still part of total supply, even though they would not participate in a\n     * vote.\n     */\n    function getPastTotalSupply(uint256 timepoint) external view returns (uint256);\n\n    /**\n     * @dev Returns the delegate that `tokenId` has chosen. Can never be equal to the delegator's `tokenId`.\n     *      Returns 0 if not delegated.\n     */\n    function delegates(uint256 tokenId) external view returns (uint256);\n\n    /**\n     * @dev Delegates votes from the sender to `delegatee`.\n     */\n    function delegate(uint256 delegator, uint256 delegatee) external;\n\n    /**\n     * @dev Delegates votes from `delegator` to `delegatee`. Signer must own `delegator`.\n     */\n    function delegateBySig(\n        uint256 delegator,\n        uint256 delegatee,\n        uint256 nonce,\n        uint256 expiry,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n}\n"},{"file_path":"contracts/interfaces/IReward.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IReward {\n    error InvalidReward();\n    error NotAuthorized();\n    error NotGauge();\n    error NotEscrowToken();\n    error NotSingleToken();\n    error NotVotingEscrow();\n    error NotWhitelisted();\n    error ZeroAmount();\n\n    event Deposit(address indexed from, uint256 indexed tokenId, uint256 amount);\n    event Withdraw(address indexed from, uint256 indexed tokenId, uint256 amount);\n    event NotifyReward(address indexed from, address indexed reward, uint256 indexed epoch, uint256 amount);\n    event ClaimRewards(address indexed from, address indexed reward, uint256 amount);\n\n    /// @notice Deposit an amount into the rewards contract to earn future rewards associated to a veNFT\n    /// @dev Internal notation used as only callable internally by `authorized`.\n    /// @param amount   Amount deposited for the veNFT\n    /// @param tokenId  Unique identifier of the veNFT\n    function _deposit(uint256 amount, uint256 tokenId) external;\n\n    /// @notice Withdraw an amount from the rewards contract associated to a veNFT\n    /// @dev Internal notation used as only callable internally by `authorized`.\n    /// @param amount   Amount deposited for the veNFT\n    /// @param tokenId  Unique identifier of the veNFT\n    function _withdraw(uint256 amount, uint256 tokenId) external;\n\n    /// @notice Claim the rewards earned by a veNFT staker\n    /// @param tokenId  Unique identifier of the veNFT\n    /// @param tokens   Array of tokens to claim rewards of\n    function getReward(uint256 tokenId, address[] memory tokens) external;\n\n    /// @notice Add rewards for stakers to earn\n    /// @param token    Address of token to reward\n    /// @param amount   Amount of token to transfer to rewards\n    function notifyRewardAmount(address token, uint256 amount) external;\n\n    /// @notice Determine the prior balance for an account as of a block number\n    /// @dev Block number must be a finalized block or else this function will revert to prevent misinformation.\n    /// @param tokenId      The token of the NFT to check\n    /// @param timestamp    The timestamp to get the balance at\n    /// @return The balance the account had as of the given block\n    function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp) external view returns (uint256);\n\n    /// @notice Determine the prior index of supply staked by of a timestamp\n    /// @dev Timestamp must be <= current timestamp\n    /// @param timestamp The timestamp to get the index at\n    /// @return Index of supply checkpoint\n    function getPriorSupplyIndex(uint256 timestamp) external view returns (uint256);\n\n    /// @notice Calculate how much in rewards are earned for a specific token and veNFT\n    /// @param token Address of token to fetch rewards of\n    /// @param tokenId Unique identifier of the veNFT\n    /// @return Amount of token earned in rewards\n    function earned(address token, uint256 tokenId) external view returns (uint256);\n}\n"},{"file_path":"contracts/interfaces/IVeArtProxy.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity ^0.8.0;\n\ninterface IVeArtProxy {\n    /// @dev Art configuration\n    struct Config {\n        // NFT metadata variables\n        int256 _tokenId;\n        int256 _balanceOf;\n        int256 _lockedEnd;\n        int256 _lockedAmount;\n        // Line art variables\n        int256 shape;\n        uint256 palette;\n        int256 maxLines;\n        int256 dash;\n        // Randomness variables\n        int256 seed1;\n        int256 seed2;\n        int256 seed3;\n    }\n\n    /// @dev Individual line art path variables.\n    struct lineConfig {\n        bytes8 color;\n        uint256 stroke;\n        uint256 offset;\n        uint256 offsetHalf;\n        uint256 offsetDashSum;\n        uint256 pathLength;\n    }\n\n    /// @dev Represents an (x,y) coordinate in a line.\n    struct Point {\n        int256 x;\n        int256 y;\n    }\n\n    /// @notice Generate a SVG based on veNFT metadata\n    /// @param _tokenId Unique veNFT identifier\n    /// @return output SVG metadata as HTML tag\n    function tokenURI(uint256 _tokenId) external view returns (string memory output);\n\n    /// @notice Generate only the foreground <path> elements of the line art for an NFT (excluding SVG header), for flexibility purposes.\n    /// @param _tokenId Unique veNFT identifier\n    /// @return output Encoded output of generateShape()\n    function lineArtPathsOnly(uint256 _tokenId) external view returns (bytes memory output);\n\n    /// @notice Generate the master art config metadata for a veNFT\n    /// @param _tokenId Unique veNFT identifier\n    /// @return cfg Config struct\n    function generateConfig(uint256 _tokenId) external view returns (Config memory cfg);\n\n    /// @notice Generate the points for two stripe lines based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of line drawn\n    /// @return Line (x, y) coordinates of the drawn stripes\n    function twoStripes(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for circles based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of circles drawn\n    /// @return Line (x, y) coordinates of the drawn circles\n    function circles(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for interlocking circles based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of interlocking circles drawn\n    /// @return Line (x, y) coordinates of the drawn interlocking circles\n    function interlockingCircles(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for corners based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of corners drawn\n    /// @return Line (x, y) coordinates of the drawn corners\n    function corners(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for a curve based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of curve drawn\n    /// @return Line (x, y) coordinates of the drawn curve\n    function curves(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for a spiral based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of spiral drawn\n    /// @return Line (x, y) coordinates of the drawn spiral\n    function spiral(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for an explosion based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of explosion drawn\n    /// @return Line (x, y) coordinates of the drawn explosion\n    function explosion(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n\n    /// @notice Generate the points for a wormhole based on the config generated for a veNFT\n    /// @param cfg Master art config metadata of a veNFT\n    /// @param l Number of wormhole drawn\n    /// @return Line (x, y) coordinates of the drawn wormhole\n    function wormhole(Config memory cfg, int256 l) external pure returns (Point[100] memory Line);\n}\n"},{"file_path":"contracts/interfaces/factories/IFactoryRegistry.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IFactoryRegistry {\n    error FallbackFactory();\n    error InvalidFactoriesToPoolFactory();\n    error PathAlreadyApproved();\n    error PathNotApproved();\n    error SameAddress();\n    error ZeroAddress();\n\n    event Approve(address indexed poolFactory, address indexed votingRewardsFactory, address indexed gaugeFactory);\n    event Unapprove(address indexed poolFactory, address indexed votingRewardsFactory, address indexed gaugeFactory);\n    event SetManagedRewardsFactory(address indexed _newRewardsFactory);\n\n    /// @notice Approve a set of factories used in Velodrome Protocol.\n    ///         Router.sol is able to swap any poolFactories currently approved.\n    ///         Cannot approve address(0) factories.\n    ///         Cannot aprove path that is already approved.\n    ///         Each poolFactory has one unique set and maintains state.  In the case a poolFactory is unapproved\n    ///             and then re-approved, the same set of factories must be used.  In other words, you cannot overwrite\n    ///             the factories tied to a poolFactory address.\n    ///         VotingRewardsFactories and GaugeFactories may use the same address across multiple poolFactories.\n    /// @dev Callable by onlyOwner\n    /// @param poolFactory .\n    /// @param votingRewardsFactory .\n    /// @param gaugeFactory .\n    function approve(address poolFactory, address votingRewardsFactory, address gaugeFactory) external;\n\n    /// @notice Unapprove a set of factories used in Velodrome Protocol.\n    ///         While a poolFactory is unapproved, Router.sol cannot swap with pools made from the corresponding factory\n    ///         Can only unapprove an approved path.\n    ///         Cannot unapprove the fallback path (core v2 factories).\n    /// @dev Callable by onlyOwner\n    /// @param poolFactory .\n    function unapprove(address poolFactory) external;\n\n    /// @notice Factory to create free and locked rewards for a managed veNFT\n    function managedRewardsFactory() external view returns (address);\n\n    /// @notice Set the rewards factory address\n    /// @dev Callable by onlyOwner\n    /// @param _newManagedRewardsFactory address of new managedRewardsFactory\n    function setManagedRewardsFactory(address _newManagedRewardsFactory) external;\n\n    /// @notice Get the factories correlated to a poolFactory.\n    ///         Once set, this can never be modified.\n    ///         Returns the correlated factories even after an approved poolFactory is unapproved.\n    function factoriesToPoolFactory(\n        address poolFactory\n    ) external view returns (address votingRewardsFactory, address gaugeFactory);\n\n    /// @notice Get all PoolFactories approved by the registry\n    /// @dev The same PoolFactory address cannot be used twice\n    /// @return Array of PoolFactory addresses\n    function poolFactories() external view returns (address[] memory);\n\n    /// @notice Check if a PoolFactory is approved within the factory registry.  Router uses this method to\n    ///         ensure a pool swapped from is approved.\n    /// @param poolFactory .\n    /// @return True if PoolFactory is approved, else false\n    function isPoolFactoryApproved(address poolFactory) external view returns (bool);\n\n    /// @notice Get the length of the poolFactories array\n    function poolFactoriesLength() external view returns (uint256);\n}\n"},{"file_path":"contracts/interfaces/factories/IManagedRewardsFactory.sol","source_code":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IManagedRewardsFactory {\n    event ManagedRewardCreated(\n        address indexed voter,\n        address indexed lockedManagedReward,\n        address indexed freeManagedReward\n    );\n\n    /// @notice creates a LockedManagedReward and a FreeManagedReward contract for a managed veNFT\n    /// @param _forwarder Address of trusted forwarder\n    /// @param _voter Address of Voter.sol\n    /// @return lockedManagedReward Address of LockedManagedReward contract created\n    /// @return freeManagedReward   Address of FreeManagedReward contract created\n    function createRewards(\n        address _forwarder,\n        address _voter\n    ) external returns (address lockedManagedReward, address freeManagedReward);\n}\n"},{"file_path":"contracts/libraries/BalanceLogicLibrary.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {IVotingEscrow} from \"../interfaces/IVotingEscrow.sol\";\n\nlibrary BalanceLogicLibrary {\n    uint256 internal constant WEEK = 1 weeks;\n\n    /// @notice Binary search to get the user point index for a token id at or prior to a given timestamp\n    /// @dev If a user point does not exist prior to the timestamp, this will return 0.\n    /// @param _userPointEpoch State of all user point epochs\n    /// @param _userPointHistory State of all user point history\n    /// @param _tokenId .\n    /// @param _timestamp .\n    /// @return User point index\n    function getPastUserPointIndex(\n        mapping(uint256 => uint256) storage _userPointEpoch,\n        mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage _userPointHistory,\n        uint256 _tokenId,\n        uint256 _timestamp\n    ) internal view returns (uint256) {\n        uint256 _userEpoch = _userPointEpoch[_tokenId];\n        if (_userEpoch == 0) return 0;\n        // First check most recent balance\n        if (_userPointHistory[_tokenId][_userEpoch].ts <= _timestamp) return (_userEpoch);\n        // Next check implicit zero balance\n        if (_userPointHistory[_tokenId][1].ts > _timestamp) return 0;\n\n        uint256 lower = 0;\n        uint256 upper = _userEpoch;\n        while (upper > lower) {\n            uint256 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n            IVotingEscrow.UserPoint storage userPoint = _userPointHistory[_tokenId][center];\n            if (userPoint.ts == _timestamp) {\n                return center;\n            } else if (userPoint.ts < _timestamp) {\n                lower = center;\n            } else {\n                upper = center - 1;\n            }\n        }\n        return lower;\n    }\n\n    /// @notice Binary search to get the global point index at or prior to a given timestamp\n    /// @dev If a checkpoint does not exist prior to the timestamp, this will return 0.\n    /// @param _epoch Current global point epoch\n    /// @param _pointHistory State of all global point history\n    /// @param _timestamp .\n    /// @return Global point index\n    function getPastGlobalPointIndex(\n        uint256 _epoch,\n        mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,\n        uint256 _timestamp\n    ) internal view returns (uint256) {\n        if (_epoch == 0) return 0;\n        // First check most recent balance\n        if (_pointHistory[_epoch].ts <= _timestamp) return (_epoch);\n        // Next check implicit zero balance\n        if (_pointHistory[1].ts > _timestamp) return 0;\n\n        uint256 lower = 0;\n        uint256 upper = _epoch;\n        while (upper > lower) {\n            uint256 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n            IVotingEscrow.GlobalPoint storage globalPoint = _pointHistory[center];\n            if (globalPoint.ts == _timestamp) {\n                return center;\n            } else if (globalPoint.ts < _timestamp) {\n                lower = center;\n            } else {\n                upper = center - 1;\n            }\n        }\n        return lower;\n    }\n\n    /// @notice Get the current voting power for `_tokenId`\n    /// @dev Adheres to the ERC20 `balanceOf` interface for Aragon compatibility\n    ///      Fetches last user point prior to a certain timestamp, then walks forward to timestamp.\n    /// @param _userPointEpoch State of all user point epochs\n    /// @param _userPointHistory State of all user point history\n    /// @param _tokenId NFT for lock\n    /// @param _t Epoch time to return voting power at\n    /// @return User voting power\n    function balanceOfNFTAt(\n        mapping(uint256 => uint256) storage _userPointEpoch,\n        mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage _userPointHistory,\n        uint256 _tokenId,\n        uint256 _t\n    ) external view returns (uint256) {\n        uint256 _epoch = getPastUserPointIndex(_userPointEpoch, _userPointHistory, _tokenId, _t);\n        // epoch 0 is an empty point\n        if (_epoch == 0) return 0;\n        IVotingEscrow.UserPoint memory lastPoint = _userPointHistory[_tokenId][_epoch];\n        if (lastPoint.permanent != 0) {\n            return lastPoint.permanent;\n        } else {\n            lastPoint.bias -= lastPoint.slope * int128(int256(_t) - int256(lastPoint.ts));\n            if (lastPoint.bias < 0) {\n                lastPoint.bias = 0;\n            }\n            return uint256(int256(lastPoint.bias));\n        }\n    }\n\n    /// @notice Calculate total voting power at some point in the past\n    /// @param _slopeChanges State of all slopeChanges\n    /// @param _pointHistory State of all global point history\n    /// @param _epoch The epoch to start search from\n    /// @param _t Time to calculate the total voting power at\n    /// @return Total voting power at that time\n    function supplyAt(\n        mapping(uint256 => int128) storage _slopeChanges,\n        mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,\n        uint256 _epoch,\n        uint256 _t\n    ) external view returns (uint256) {\n        uint256 epoch_ = getPastGlobalPointIndex(_epoch, _pointHistory, _t);\n        // epoch 0 is an empty point\n        if (epoch_ == 0) return 0;\n        IVotingEscrow.GlobalPoint memory _point = _pointHistory[epoch_];\n        int128 bias = _point.bias;\n        int128 slope = _point.slope;\n        uint256 ts = _point.ts;\n        uint256 t_i = (ts / WEEK) * WEEK;\n        for (uint256 i = 0; i < 255; ++i) {\n            t_i += WEEK;\n            int128 dSlope = 0;\n            if (t_i > _t) {\n                t_i = _t;\n            } else {\n                dSlope = _slopeChanges[t_i];\n            }\n            bias -= slope * int128(int256(t_i - ts));\n            if (t_i == _t) {\n                break;\n            }\n            slope += dSlope;\n            ts = t_i;\n        }\n\n        if (bias < 0) {\n            bias = 0;\n        }\n        return uint256(uint128(bias)) + _point.permanentLockBalance;\n    }\n}\n"},{"file_path":"contracts/libraries/DelegationLogicLibrary.sol","source_code":"// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.19;\n\nimport {IVotingEscrow} from \"../interfaces/IVotingEscrow.sol\";\n\nlibrary DelegationLogicLibrary {\n    /// @notice Used by `_mint`, `_transferFrom`, `_burn` and `delegate`\n    ///         to update delegator voting checkpoints.\n    ///         Automatically dedelegates, then updates checkpoint.\n    /// @dev This function depends on `_locked` and must be called prior to token state changes.\n    ///      If you wish to dedelegate only, use `_delegate(tokenId, 0)` instead.\n    /// @param _locked State of all locked balances\n    /// @param _numCheckpoints State of all user checkpoint counts\n    /// @param _checkpoints State of all user checkpoints\n    /// @param _delegates State of all user delegatees\n    /// @param _delegator The delegator to update checkpoints for\n    /// @param _delegatee The new delegatee for the delegator. Cannot be equal to `_delegator` (use 0 instead).\n    /// @param _owner The new (or current) owner for the delegator\n    function checkpointDelegator(\n        mapping(uint256 => IVotingEscrow.LockedBalance) storage _locked,\n        mapping(uint256 => uint48) storage _numCheckpoints,\n        mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage _checkpoints,\n        mapping(uint256 => uint256) storage _delegates,\n        uint256 _delegator,\n        uint256 _delegatee,\n        address _owner\n    ) external {\n        uint256 delegatedBalance = uint256(uint128(_locked[_delegator].amount));\n        uint48 numCheckpoint = _numCheckpoints[_delegator];\n        IVotingEscrow.Checkpoint storage cpOld = numCheckpoint > 0\n            ? _checkpoints[_delegator][numCheckpoint - 1]\n            : _checkpoints[_delegator][0];\n        // Dedelegate from delegatee if delegated\n        checkpointDelegatee(_numCheckpoints, _checkpoints, cpOld.delegatee, delegatedBalance, false);\n        IVotingEscrow.Checkpoint storage cp = _checkpoints[_delegator][numCheckpoint];\n        cp.fromTimestamp = block.timestamp;\n        cp.delegatedBalance = cpOld.delegatedBalance;\n        cp.delegatee = _delegatee;\n        cp.owner = _owner;\n\n        if (_isCheckpointInNewBlock(_numCheckpoints, _checkpoints, _delegator)) {\n            _numCheckpoints[_delegator]++;\n        } else {\n            _checkpoints[_delegator][numCheckpoint - 1] = cp;\n            delete _checkpoints[_delegator][numCheckpoint];\n        }\n\n        _delegates[_delegator] = _delegatee;\n    }\n\n    /// @notice Update delegatee's `delegatedBalance` by `balance`.\n    ///         Only updates if delegating to a new delegatee.\n    /// @dev If used with `balance` == `_locked[_tokenId].amount`, then this is the same as\n    ///      delegating or dedelegating from `_tokenId`\n    ///      If used with `balance` < `_locked[_tokenId].amount`, then this is used to adjust\n    ///      `delegatedBalance` when a user's balance is modified (e.g. `increaseAmount`, `merge` etc).\n    ///      If `delegatee` is 0 (i.e. user is not delegating), then do nothing.\n    /// @param _numCheckpoints State of all user checkpoint counts\n    /// @param _checkpoints State of all user checkpoints\n    /// @param _delegatee The delegatee's tokenId\n    /// @param balance_ The delta in balance change\n    /// @param _increase True if balance is increasing, false if decreasing\n    function checkpointDelegatee(\n        mapping(uint256 => uint48) storage _numCheckpoints,\n        mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage _checkpoints,\n        uint256 _delegatee,\n        uint256 balance_,\n        bool _increase\n    ) public {\n        if (_delegatee == 0) return;\n        uint48 numCheckpoint = _numCheckpoints[_delegatee];\n        IVotingEscrow.Checkpoint storage cpOld = numCheckpoint > 0\n            ? _checkpoints[_delegatee][numCheckpoint - 1]\n            : _checkpoints[_delegatee][0];\n        IVotingEscrow.Checkpoint storage cp = _checkpoints[_delegatee][numCheckpoint];\n        cp.fromTimestamp = block.timestamp;\n        cp.owner = cpOld.owner;\n        // do not expect balance_ > cpOld.delegatedBalance when decrementing but just in case\n        cp.delegatedBalance = _increase\n            ? cpOld.delegatedBalance + balance_\n            : (balance_ < cpOld.delegatedBalance ? cpOld.delegatedBalance - balance_ : 0);\n        cp.delegatee = cpOld.delegatee;\n\n        if (_isCheckpointInNewBlock(_numCheckpoints, _checkpoints, _delegatee)) {\n            _numCheckpoints[_delegatee]++;\n        } else {\n            _checkpoints[_delegatee][numCheckpoint - 1] = cp;\n            delete _checkpoints[_delegatee][numCheckpoint];\n        }\n    }\n\n    function _isCheckpointInNewBlock(\n        mapping(uint256 => uint48) storage _numCheckpoints,\n        mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage _checkpoints,\n        uint256 _tokenId\n    ) internal view returns (bool) {\n        uint48 _nCheckPoints = _numCheckpoints[_tokenId];\n\n        if (_nCheckPoints > 0 && _checkpoints[_tokenId][_nCheckPoints - 1].fromTimestamp == block.timestamp) {\n            return false;\n        } else {\n            return true;\n        }\n    }\n\n    /// @notice Binary search to get the voting checkpoint for a token id at or prior to a given timestamp.\n    /// @dev If a checkpoint does not exist prior to the timestamp, this will return 0.\n    /// @param _numCheckpoints State of all user checkpoint counts\n    /// @param _checkpoints State of all user checkpoints\n    /// @param _tokenId .\n    /// @param _timestamp .\n    /// @return The index of the checkpoint.\n    function getPastVotesIndex(\n        mapping(uint256 => uint48) storage _numCheckpoints,\n        mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage _checkpoints,\n        uint256 _tokenId,\n        uint256 _timestamp\n    ) internal view returns (uint48) {\n        uint48 nCheckpoints = _numCheckpoints[_tokenId];\n        if (nCheckpoints == 0) return 0;\n        // First check most recent balance\n        if (_checkpoints[_tokenId][nCheckpoints - 1].fromTimestamp <= _timestamp) return (nCheckpoints - 1);\n        // Next check implicit zero balance\n        if (_checkpoints[_tokenId][0].fromTimestamp > _timestamp) return 0;\n\n        uint48 lower = 0;\n        uint48 upper = nCheckpoints - 1;\n        while (upper > lower) {\n            uint48 center = upper - (upper - lower) / 2; // ceil, avoiding overflow\n            IVotingEscrow.Checkpoint storage cp = _checkpoints[_tokenId][center];\n            if (cp.fromTimestamp == _timestamp) {\n                return center;\n            } else if (cp.fromTimestamp < _timestamp) {\n                lower = center;\n            } else {\n                upper = center - 1;\n            }\n        }\n        return lower;\n    }\n\n    /// @notice Retrieves historical voting balance for a token id at a given timestamp.\n    /// @dev If a checkpoint does not exist prior to the timestamp, this will return 0.\n    ///      The user must also own the token at the time in order to receive a voting balance.\n    /// @param _numCheckpoints State of all user checkpoint counts\n    /// @param _checkpoints State of all user checkpoints\n    /// @param _account .\n    /// @param _tokenId .\n    /// @param _timestamp .\n    /// @return Total voting balance including delegations at a given timestamp.\n    function getPastVotes(\n        mapping(uint256 => uint48) storage _numCheckpoints,\n        mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage _checkpoints,\n        address _account,\n        uint256 _tokenId,\n        uint256 _timestamp\n    ) external view returns (uint256) {\n        uint48 _checkIndex = getPastVotesIndex(_numCheckpoints, _checkpoints, _tokenId, _timestamp);\n        IVotingEscrow.Checkpoint memory lastCheckpoint = _checkpoints[_tokenId][_checkIndex];\n        // If no point exists prior to the given timestamp, return 0\n        if (lastCheckpoint.fromTimestamp > _timestamp) return 0;\n        // Check ownership\n        if (_account != lastCheckpoint.owner) return 0;\n        uint256 votes = lastCheckpoint.delegatedBalance;\n        return\n            lastCheckpoint.delegatee == 0\n                ? votes + IVotingEscrow(address(this)).balanceOfNFTAt(_tokenId, _timestamp)\n                : votes;\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC4906.sol","source_code":"// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\nimport \"./IERC721.sol\";\n\n/// @title EIP-721 Metadata Update Extension\ninterface IERC4906 is IERC165, IERC721 {\n    /// @dev This event emits when the metadata of a token is changed.\n    /// So that the third-party platforms such as NFT market could\n    /// timely update the images and related attributes of the NFT.\n    event MetadataUpdate(uint256 _tokenId);\n\n    /// @dev This event emits when the metadata of a range of tokens is changed.\n    /// So that the third-party platforms such as NFT market could\n    /// timely update the images and related attributes of the NFTs.\n    event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC6372.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (interfaces/IERC6372.sol)\n\npragma solidity ^0.8.0;\n\ninterface IERC6372 {\n    /**\n     * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).\n     */\n    function clock() external view returns (uint48);\n\n    /**\n     * @dev Description of the clock\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function CLOCK_MODE() external view returns (string memory);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/interfaces/IERC721.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC721/IERC721.sol\";\n"},{"file_path":"lib/openzeppelin-contracts/contracts/metatx/ERC2771Context.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)\n\npragma solidity ^0.8.9;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Context variant with ERC2771 support.\n */\nabstract contract ERC2771Context is Context {\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address private immutable _trustedForwarder;\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor(address trustedForwarder) {\n        _trustedForwarder = trustedForwarder;\n    }\n\n    function isTrustedForwarder(address forwarder) public view virtual returns (bool) {\n        return forwarder == _trustedForwarder;\n    }\n\n    function _msgSender() internal view virtual override returns (address sender) {\n        if (isTrustedForwarder(msg.sender)) {\n            // The assembly code is more direct than the Solidity version using `abi.decode`.\n            /// @solidity memory-safe-assembly\n            assembly {\n                sender := shr(96, calldataload(sub(calldatasize(), 20)))\n            }\n        } else {\n            return super._msgSender();\n        }\n    }\n\n    function _msgData() internal view virtual override returns (bytes calldata) {\n        if (isTrustedForwarder(msg.sender)) {\n            return msg.data[:msg.data.length - 20];\n        } else {\n            return super._msgData();\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    constructor() {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be _NOT_ENTERED\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == _ENTERED;\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"},{"file_path":"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"_forwarder","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_factoryRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyVoted","type":"error"},{"inputs":[],"name":"AmountTooBig","type":"error"},{"inputs":[],"name":"ERC721ReceiverRejectedTokens","type":"error"},{"inputs":[],"name":"ERC721TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"InvalidManagedNFTId","type":"error"},{"inputs":[],"name":"InvalidNonce","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidSignatureS","type":"error"},{"inputs":[],"name":"LockDurationNotInFuture","type":"error"},{"inputs":[],"name":"LockDurationTooLong","type":"error"},{"inputs":[],"name":"LockExpired","type":"error"},{"inputs":[],"name":"LockNotExpired","type":"error"},{"inputs":[],"name":"NoLockFound","type":"error"},{"inputs":[],"name":"NonExistentToken","type":"error"},{"inputs":[],"name":"NotApprovedOrOwner","type":"error"},{"inputs":[],"name":"NotDistributor","type":"error"},{"inputs":[],"name":"NotEmergencyCouncilOrGovernor","type":"error"},{"inputs":[],"name":"NotGovernor","type":"error"},{"inputs":[],"name":"NotGovernorOrManager","type":"error"},{"inputs":[],"name":"NotLockedNFT","type":"error"},{"inputs":[],"name":"NotManagedNFT","type":"error"},{"inputs":[],"name":"NotManagedOrNormalNFT","type":"error"},{"inputs":[],"name":"NotNormalNFT","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"NotPermanentLock","type":"error"},{"inputs":[],"name":"NotTeam","type":"error"},{"inputs":[],"name":"NotVoter","type":"error"},{"inputs":[],"name":"OwnershipChange","type":"error"},{"inputs":[],"name":"PermanentLock","type":"error"},{"inputs":[],"name":"SameAddress","type":"error"},{"inputs":[],"name":"SameNFT","type":"error"},{"inputs":[],"name":"SameState","type":"error"},{"inputs":[],"name":"SignatureExpired","type":"error"},{"inputs":[],"name":"SplitNoOwner","type":"error"},{"inputs":[],"name":"SplitNotAllowed","type":"error"},{"inputs":[],"name":"TooManyTokenIDs","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"inputs":[],"name":"ZeroBalance","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"BatchMetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_mTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"address","name":"_lockedManagedReward","type":"address"},{"indexed":false,"internalType":"address","name":"_freeManagedReward","type":"address"}],"name":"CreateManaged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"uint256","name":"fromDelegate","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"toDelegate","type":"uint256"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"enum IVotingEscrow.DepositType","name":"depositType","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"locktime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ts","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_mTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_weight","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ts","type":"uint256"}],"name":"DepositManaged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ts","type":"uint256"}],"name":"LockPermanent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"_from","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_to","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountFrom","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountTo","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountFinal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_locktime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ts","type":"uint256"}],"name":"Merge","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"MetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_allowedManager","type":"address"}],"name":"SetAllowedManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_from","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_tokenId1","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_tokenId2","type":"uint256"},{"indexed":false,"internalType":"address","name":"_sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_splitAmount1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_splitAmount2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_locktime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ts","type":"uint256"}],"name":"Split","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supply","type":"uint256"}],"name":"Supply","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ts","type":"uint256"}],"name":"UnlockPermanent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ts","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_mTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_weight","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_ts","type":"uint256"}],"name":"WithdrawManaged","type":"event"},{"inputs":[],"name":"CLOCK_MODE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DELEGATION_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowedManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_approved","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"artProxy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"balanceOfNFT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_t","type":"uint256"}],"name":"balanceOfNFTAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"canSplit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint48","name":"_index","type":"uint48"}],"name":"checkpoints","outputs":[{"components":[{"internalType":"uint256","name":"fromTimestamp","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"delegatedBalance","type":"uint256"},{"internalType":"uint256","name":"delegatee","type":"uint256"}],"internalType":"struct IVotingEscrow.Checkpoint","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"clock","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_lockDuration","type":"uint256"}],"name":"createLock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint256","name":"_lockDuration","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"createLockFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"createManagedLockFor","outputs":[{"internalType":"uint256","name":"_mTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"deactivated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegator","type":"uint256"},{"internalType":"uint256","name":"delegatee","type":"uint256"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegator","type":"uint256"},{"internalType":"uint256","name":"delegatee","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"delegator","type":"uint256"}],"name":"delegates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"depositFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_mTokenId","type":"uint256"}],"name":"depositManaged","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"escrowType","outputs":[{"internalType":"enum IVotingEscrow.EscrowType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factoryRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"getPastTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"getPastVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"idToManaged","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"increaseAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_lockDuration","type":"uint256"}],"name":"increaseUnlockTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"isApprovedOrOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"lockPermanent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"locked","outputs":[{"components":[{"internalType":"int128","name":"amount","type":"int128"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"bool","name":"isPermanent","type":"bool"}],"internalType":"struct IVotingEscrow.LockedBalance","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"managedToFree","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"managedToLocked","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_from","type":"uint256"},{"internalType":"uint256","name":"_to","type":"uint256"}],"name":"merge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"numCheckpoints","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"ownerToNFTokenIdList","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permanentLockBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loc","type":"uint256"}],"name":"pointHistory","outputs":[{"components":[{"internalType":"int128","name":"bias","type":"int128"},{"internalType":"int128","name":"slope","type":"int128"},{"internalType":"uint256","name":"ts","type":"uint256"},{"internalType":"uint256","name":"blk","type":"uint256"},{"internalType":"uint256","name":"permanentLockBalance","type":"uint256"}],"internalType":"struct IVotingEscrow.GlobalPoint","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_allowedManager","type":"address"}],"name":"setAllowedManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_proxy","type":"address"}],"name":"setArtProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mTokenId","type":"uint256"},{"internalType":"bool","name":"_state","type":"bool"}],"name":"setManagedState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_team","type":"address"}],"name":"setTeam","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_voter","type":"address"},{"internalType":"address","name":"_distributor","type":"address"}],"name":"setVoterAndDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"slopeChanges","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_from","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"split","outputs":[{"internalType":"uint256","name":"_tokenId1","type":"uint256"},{"internalType":"uint256","name":"_tokenId2","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"supply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"team","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_bool","type":"bool"}],"name":"toggleSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unlockPermanent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"userPointEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_loc","type":"uint256"}],"name":"userPointHistory","outputs":[{"components":[{"internalType":"int128","name":"bias","type":"int128"},{"internalType":"int128","name":"slope","type":"int128"},{"internalType":"uint256","name":"ts","type":"uint256"},{"internalType":"uint256","name":"blk","type":"uint256"},{"internalType":"uint256","name":"permanent","type":"uint256"}],"internalType":"struct IVotingEscrow.UserPoint","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"voted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bool","name":"_voted","type":"bool"}],"name":"voting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"weights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"withdrawManaged","outputs":[],"stateMutability":"nonpayable","type":"function"}],"is_changed_bytecode":false,"is_partially_verified":true,"constructor_args":"ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef00000000000000000000000006824df38d1d77eadeb6bafcb03904e27429ab740000000000000000000000009560e827af36c94d2ac33a39bce1fe78631088db000000000000000000000000f4c67cdeaab8360370f41514d06e32ccd8aa1d7b"}