{
  "language": "Solidity",
  "sources": {
    "contracts/BoostedVotingEscrowDelegate.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"./VotingEscrowDelegate.sol\";\n\ncontract BoostedVotingEscrowDelegate is VotingEscrowDelegate {\n    uint256 public immutable minDuration;\n    uint256 public immutable maxBoost;\n    uint256 public immutable deadline;\n\n    constructor(\n        address _ve,\n        address _token,\n        address _discountToken,\n        uint256 _minDuration,\n        uint256 _maxBoost,\n        uint256 _deadline\n    ) VotingEscrowDelegate(_ve, _token, _discountToken) {\n        minDuration = _minDuration;\n        maxBoost = _maxBoost;\n        deadline = _deadline;\n    }\n\n    function _createLock(\n        uint256 amountToken,\n        uint256 duration,\n        bool discounted\n    ) internal override {\n        require(block.timestamp < deadline, \"BVED: EXPIRED\");\n        require(duration >= minDuration, \"BVED: DURATION_TOO_SHORT\");\n\n        super._createLock(amountToken, duration, discounted);\n    }\n\n    function _increaseAmount(uint256 amountToken, bool discounted) internal override {\n        require(block.timestamp < deadline, \"BVED: EXPIRED\");\n\n        super._increaseAmount(amountToken, discounted);\n    }\n\n    function _getAmounts(uint256 amount, uint256 duration)\n        internal\n        view\n        override\n        returns (uint256 amountVE, uint256 amountToken)\n    {\n        amountVE = (amount * maxBoost * duration) / _maxDuration;\n        amountToken = amount;\n    }\n}\n"
    },
    "contracts/VotingEscrowDelegate.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"./interfaces/IVotingEscrowDelegate.sol\";\nimport \"./interfaces/IVotingEscrow.sol\";\nimport \"./interfaces/INFT.sol\";\n\nabstract contract VotingEscrowDelegate is IVotingEscrowDelegate {\n    address public immutable ve;\n    address public immutable token;\n    address public immutable discountToken;\n\n    uint256 internal immutable _maxDuration;\n    uint256 internal immutable _interval;\n\n    event CreateLock(address indexed account, uint256 amount, uint256 discount, uint256 indexed locktime);\n    event IncreaseAmount(address indexed account, uint256 amount, uint256 discount);\n\n    constructor(\n        address _ve,\n        address _token,\n        address _discountToken\n    ) {\n        ve = _ve;\n        token = _token;\n        discountToken = _discountToken;\n\n        _maxDuration = IVotingEscrow(_ve).maxDuration();\n        _interval = IVotingEscrow(ve).interval();\n    }\n\n    modifier eligibleForDiscount {\n        require(INFT(discountToken).balanceOf(msg.sender) > 0, \"VED: DISCOUNT_TOKEN_NOT_OWNED\");\n        _;\n    }\n\n    function createLockDiscounted(uint256 amount, uint256 duration) external eligibleForDiscount {\n        _createLock(amount, duration, true);\n    }\n\n    function createLock(uint256 amount, uint256 duration) external {\n        _createLock(amount, duration, false);\n    }\n\n    function _createLock(\n        uint256 amount,\n        uint256 duration,\n        bool discounted\n    ) internal virtual {\n        require(duration <= _maxDuration, \"VED: DURATION_TOO_LONG\");\n\n        uint256 unlockTime = ((block.timestamp + duration) / _interval) * _interval; // rounded down to a multiple of interval\n        uint256 _duration = unlockTime - block.timestamp;\n        (uint256 amountVE, uint256 amountToken) = _getAmounts(amount, _duration);\n        if (discounted) {\n            amountVE = (amountVE * 100) / 90;\n        }\n\n        emit CreateLock(msg.sender, amountVE, amountVE - amountToken, unlockTime);\n        IVotingEscrow(ve).createLockFor(msg.sender, amountVE, amountVE - amountToken, _duration);\n    }\n\n    function increaseAmountDiscounted(uint256 amount) external eligibleForDiscount {\n        _increaseAmount(amount, true);\n    }\n\n    function increaseAmount(uint256 amount) external {\n        _increaseAmount(amount, false);\n    }\n\n    function _increaseAmount(uint256 amount, bool discounted) internal virtual {\n        uint256 unlockTime = IVotingEscrow(ve).unlockTime(msg.sender);\n        require(unlockTime > 0, \"VED: LOCK_NOT_FOUND\");\n\n        (uint256 amountVE, uint256 amountToken) = _getAmounts(amount, unlockTime - block.timestamp);\n        if (discounted) {\n            amountVE = (amountVE * 100) / 90;\n        }\n\n        emit IncreaseAmount(msg.sender, amountVE, amountVE - amountToken);\n        IVotingEscrow(ve).increaseAmountFor(msg.sender, amountVE, amountVE - amountToken);\n    }\n\n    function _getAmounts(uint256 amount, uint256 duration)\n        internal\n        view\n        virtual\n        returns (uint256 amountVE, uint256 amountToken);\n\n    function withdraw(address, uint256) external virtual override {\n        // Empty\n    }\n}\n"
    },
    "contracts/interfaces/IVotingEscrowDelegate.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IVotingEscrowDelegate {\n    event Withdraw(address indexed addr, uint256 amount, uint256 penaltyRate);\n\n    function withdraw(address addr, uint256 penaltyRate) external;\n}\n"
    },
    "contracts/interfaces/IVotingEscrow.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IVotingEscrow {\n    event SetMigrator(address indexed account);\n    event SetDelegate(address indexed account, bool isDelegate);\n    event Deposit(\n        address indexed provider,\n        uint256 value,\n        uint256 discount,\n        uint256 indexed unlockTime,\n        int128 indexed _type,\n        uint256 ts\n    );\n    event Cancel(address indexed provider, uint256 value, uint256 discount, uint256 penaltyRate, uint256 ts);\n    event Withdraw(address indexed provider, uint256 value, uint256 discount, uint256 ts);\n    event Migrate(address indexed provider, uint256 value, uint256 discount, uint256 ts);\n    event Supply(uint256 prevSupply, uint256 supply);\n\n    function interval() external view returns (uint256);\n\n    function maxDuration() external view returns (uint256);\n\n    function token() external view returns (address);\n\n    function name() external view returns (string memory);\n\n    function symbol() external view returns (string memory);\n\n    function decimals() external view returns (uint8);\n\n    function migrator() external view returns (address);\n\n    function isDelegate(address account) external view returns (bool);\n\n    function supply() external view returns (uint256);\n\n    function migrated(address account) external view returns (bool);\n\n    function delegateAt(address account, uint256 index) external view returns (address);\n\n    function locked(address account)\n        external\n        view\n        returns (\n            int128 amount,\n            int128 discount,\n            uint256 start,\n            uint256 end\n        );\n\n    function epoch() external view returns (uint256);\n\n    function pointHistory(uint256 epoch)\n        external\n        view\n        returns (\n            int128 bias,\n            int128 slope,\n            uint256 ts,\n            uint256 blk\n        );\n\n    function userPointHistory(address account, uint256 epoch)\n        external\n        view\n        returns (\n            int128 bias,\n            int128 slope,\n            uint256 ts,\n            uint256 blk\n        );\n\n    function userPointEpoch(address account) external view returns (uint256);\n\n    function slopeChanges(uint256 epoch) external view returns (int128);\n\n    function delegateLength(address addr) external view returns (uint256);\n\n    function getLastUserSlope(address addr) external view returns (int128);\n\n    function getCheckpointTime(address _addr, uint256 _idx) external view returns (uint256);\n\n    function unlockTime(address _addr) external view returns (uint256);\n\n    function setMigrator(address _migrator) external;\n\n    function setDelegate(address account, bool _isDelegate) external;\n\n    function checkpoint() external;\n\n    function depositFor(address _addr, uint256 _value) external;\n\n    function createLockFor(\n        address _addr,\n        uint256 _value,\n        uint256 _discount,\n        uint256 _duration\n    ) external;\n\n    function createLock(uint256 _value, uint256 _duration) external;\n\n    function increaseAmountFor(\n        address _addr,\n        uint256 _value,\n        uint256 _discount\n    ) external;\n\n    function increaseAmount(uint256 _value) external;\n\n    function increaseUnlockTime(uint256 _duration) external;\n\n    function cancel() external;\n\n    function withdraw() external;\n\n    function migrate() external;\n\n    function balanceOf(address addr) external view returns (uint256);\n\n    function balanceOf(address addr, uint256 _t) external view returns (uint256);\n\n    function balanceOfAt(address addr, uint256 _block) external view returns (uint256);\n\n    function totalSupply() external view returns (uint256);\n\n    function totalSupply(uint256 t) external view returns (uint256);\n\n    function totalSupplyAt(uint256 _block) external view returns (uint256);\n}\n"
    },
    "contracts/interfaces/INFT.sol": {
      "content": "// SPDX-License-Identifier: WTFPL\npragma solidity ^0.8.0;\n\ninterface INFT {\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    function mint(\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external;\n\n    function mintBatch(\n        address to,\n        uint256[] calldata tokenIds,\n        bytes calldata data\n    ) external;\n\n    function burn(\n        uint256 tokenId,\n        uint256 label,\n        bytes32 data\n    ) external;\n}\n"
    },
    "contracts/LPVotingEscrowDelegate.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"./uniswapv2/interfaces/IUniswapV2Pair.sol\";\nimport \"./VotingEscrowDelegate.sol\";\nimport \"./interfaces/IVotingEscrowMigrator.sol\";\n\ncontract LPVotingEscrowDelegate is VotingEscrowDelegate {\n    using SafeERC20 for IERC20;\n\n    struct LockedBalance {\n        uint256 amount;\n        uint256 end;\n    }\n\n    bool internal immutable isToken1;\n    uint256 public immutable minAmount;\n    uint256 public immutable maxBoost;\n\n    uint256 public lockedTotal;\n    mapping(address => uint256) public locked;\n\n    constructor(\n        address _ve,\n        address _lpToken,\n        address _discountToken,\n        bool _isToken1,\n        uint256 _minAmount,\n        uint256 _maxBoost\n    ) VotingEscrowDelegate(_ve, _lpToken, _discountToken) {\n        isToken1 = _isToken1;\n        minAmount = _minAmount;\n        maxBoost = _maxBoost;\n    }\n\n    function _createLock(\n        uint256 amount,\n        uint256 duration,\n        bool discounted\n    ) internal override {\n        require(amount >= minAmount, \"LSVED: AMOUNT_TOO_LOW\");\n\n        super._createLock(amount, duration, discounted);\n\n        lockedTotal += amount;\n        locked[msg.sender] += amount;\n        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);\n    }\n\n    function _increaseAmount(uint256 amount, bool discounted) internal override {\n        require(amount >= minAmount, \"LSVED: AMOUNT_TOO_LOW\");\n\n        super._increaseAmount(amount, discounted);\n\n        lockedTotal += amount;\n        locked[msg.sender] += amount;\n        IERC20(token).safeTransferFrom(msg.sender, address(this), amount);\n    }\n\n    function _getAmounts(uint256 amount, uint256)\n        internal\n        view\n        override\n        returns (uint256 amountVE, uint256 amountToken)\n    {\n        (uint112 reserve0, uint112 reserve1, ) = IUniswapV2Pair(token).getReserves();\n        uint256 reserve = isToken1 ? uint256(reserve1) : uint256(reserve0);\n\n        uint256 totalSupply = IUniswapV2Pair(token).totalSupply();\n        uint256 _amountToken = (amount * reserve) / totalSupply;\n\n        amountVE = _amountToken + (_amountToken * maxBoost * (totalSupply - lockedTotal)) / totalSupply / totalSupply;\n        uint256 upperBound = (_amountToken * 333) / 10;\n        if (amountVE > upperBound) {\n            amountVE = upperBound;\n        }\n        amountToken = 0;\n    }\n\n    function withdraw(address addr, uint256 penaltyRate) external override {\n        require(msg.sender == ve, \"LSVED: FORBIDDEN\");\n\n        uint256 amount = locked[addr];\n        require(amount > 0, \"LSVED: LOCK_NOT_FOUND\");\n\n        lockedTotal -= amount;\n        locked[addr] = 0;\n        IERC20(token).safeTransfer(addr, (amount * (1e18 - penaltyRate)) / 1e18);\n\n        emit Withdraw(addr, amount, penaltyRate);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.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(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) 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(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) 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(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) 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(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) 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    /**\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"
    },
    "contracts/uniswapv2/interfaces/IUniswapV2Pair.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n    event Approval(address indexed owner, address indexed spender, uint value);\n    event Transfer(address indexed from, address indexed to, uint value);\n\n    function name() external pure returns (string memory);\n    function symbol() external pure returns (string memory);\n    function decimals() external pure returns (uint8);\n    function totalSupply() external view returns (uint);\n    function balanceOf(address owner) external view returns (uint);\n    function allowance(address owner, address spender) external view returns (uint);\n\n    function approve(address spender, uint value) external returns (bool);\n    function transfer(address to, uint value) external returns (bool);\n    function transferFrom(address from, address to, uint value) external returns (bool);\n\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n    function PERMIT_TYPEHASH() external pure returns (bytes32);\n    function nonces(address owner) external view returns (uint);\n\n    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n    event Mint(address indexed sender, uint amount0, uint amount1);\n    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n    event Swap(\n        address indexed sender,\n        uint amount0In,\n        uint amount1In,\n        uint amount0Out,\n        uint amount1Out,\n        address indexed to\n    );\n    event Sync(uint112 reserve0, uint112 reserve1);\n\n    function MINIMUM_LIQUIDITY() external pure returns (uint);\n    function factory() external view returns (address);\n    function token0() external view returns (address);\n    function token1() external view returns (address);\n    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n    function price0CumulativeLast() external view returns (uint);\n    function price1CumulativeLast() external view returns (uint);\n    function kLast() external view returns (uint);\n\n    function mint(address to) external returns (uint liquidity);\n    function burn(address to) external returns (uint amount0, uint amount1);\n    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n    function skim(address to) external;\n    function sync() external;\n\n    function initialize(address, address) external;\n}"
    },
    "contracts/interfaces/IVotingEscrowMigrator.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface IVotingEscrowMigrator {\n    function migrate(\n        address account,\n        int128 amount,\n        int128 discount,\n        uint256 start,\n        uint256 end,\n        address[] calldata delegates\n    ) external;\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// 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(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.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     *\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://diligence.consensys.net/posts/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 functionCall(target, data, \"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(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) 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        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(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        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(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        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason 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            // 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\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}\n"
    },
    "contracts/VotingEscrow.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"./interfaces/IVotingEscrow.sol\";\nimport \"./interfaces/IVotingEscrowMigrator.sol\";\nimport \"./interfaces/IVotingEscrowDelegate.sol\";\nimport \"./libraries/Integers.sol\";\n\n/**\n * @title Voting Escrow\n * @author LevX (team@levx.io)\n * @notice Votes have a weight depending on time, so that users are\n *         committed to the future of (whatever they are voting for)\n * @dev Vote weight decays linearly over time. Lock time cannot be\n *      more than `MAXTIME`.\n * @dev Ported from vyper (https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/VotingEscrow.vy)\n */\n\n// Voting escrow to have time-weighted votes\n// Votes have a weight depending on time, so that users are committed\n// to the future of (whatever they are voting for).\n// The weight in this implementation is linear, and lock cannot be more than maxtime:\n// w ^\n// 1 +        /\n//   |      /\n//   |    /\n//   |  /\n//   |/\n// 0 +--------+------> time\n//       maxtime\n\ncontract VotingEscrow is Ownable, ReentrancyGuard, IVotingEscrow {\n    using SafeERC20 for IERC20;\n    using Integers for int128;\n    using Integers for uint256;\n\n    struct Point {\n        int128 bias;\n        int128 slope; // - dweight / dt\n        uint256 ts;\n        uint256 blk; // block\n    }\n\n    struct LockedBalance {\n        int128 amount;\n        int128 discount;\n        uint256 start;\n        uint256 end;\n    }\n\n    int128 public constant DEPOSIT_FOR_TYPE = 0;\n    int128 public constant CRETE_LOCK_TYPE = 1;\n    int128 public constant INCREASE_LOCK_AMOUNT = 2;\n    int128 public constant INCREASE_UNLOCK_TIME = 3;\n    uint256 internal constant MULTIPLIER = 1e18;\n\n    uint256 public immutable override interval;\n    uint256 public immutable override maxDuration;\n    address public immutable override token;\n    string public override name;\n    string public override symbol;\n    uint8 public immutable override decimals;\n\n    address public override migrator;\n    mapping(address => bool) public override isDelegate;\n\n    uint256 public override supply;\n    mapping(address => bool) public override migrated;\n    mapping(address => address[]) public override delegateAt;\n    mapping(address => LockedBalance) public override locked;\n    uint256 public override epoch;\n\n    mapping(uint256 => Point) public override pointHistory; // epoch -> unsigned point\n    mapping(address => mapping(uint256 => Point)) public override userPointHistory; // user -> Point[user_epoch]\n    mapping(address => uint256) public override userPointEpoch;\n    mapping(uint256 => int128) public override slopeChanges; // time -> signed slope change\n\n    constructor(\n        address _token,\n        string memory _name,\n        string memory _symbol,\n        uint256 _interval,\n        uint256 _maxDuration\n    ) {\n        token = _token;\n        name = _name;\n        symbol = _symbol;\n        decimals = IERC20Metadata(_token).decimals();\n\n        interval = _interval;\n        maxDuration = (_maxDuration / _interval) * _interval; // rounded down to a multiple of interval\n\n        pointHistory[0].blk = block.number;\n        pointHistory[0].ts = block.timestamp;\n    }\n\n    modifier beforeMigrated(address addr) {\n        require(!migrated[addr], \"VE: LOCK_MIGRATED\");\n        _;\n    }\n\n    modifier onlyDelegate {\n        require(isDelegate[msg.sender], \"VE: NOT_DELEGATE\");\n        _;\n    }\n\n    /**\n     * @notice Check if the call is from an EOA or a whitelisted smart contract, revert if not\n     */\n    modifier authorized {\n        if (msg.sender != tx.origin) {\n            require(isDelegate[msg.sender], \"VE: CONTRACT_NOT_DELEGATE\");\n        }\n        _;\n    }\n\n    function delegateLength(address addr) external view returns (uint256) {\n        return delegateAt[addr].length;\n    }\n\n    /**\n     * @notice Get the most recently recorded rate of voting power decrease for `addr`\n     * @param addr Address of the user wallet\n     * @return Value of the slope\n     */\n    function getLastUserSlope(address addr) external view override returns (int128) {\n        uint256 uepoch = userPointEpoch[addr];\n        return userPointHistory[addr][uepoch].slope;\n    }\n\n    /**\n     * @notice Get the timestamp for checkpoint `_idx` for `_addr`\n     * @param _addr User wallet address\n     * @param _idx User epoch number\n     * @return Epoch time of the checkpoint\n     */\n    function getCheckpointTime(address _addr, uint256 _idx) external view override returns (uint256) {\n        return userPointHistory[_addr][_idx].ts;\n    }\n\n    /**\n     * @notice Get timestamp when `_addr`'s lock finishes\n     * @param _addr User wallet\n     * @return Epoch time of the lock end\n     */\n    function unlockTime(address _addr) external view override returns (uint256) {\n        return locked[_addr].end;\n    }\n\n    function setMigrator(address _migrator) external override onlyOwner {\n        require(migrator == address(0), \"VE: MIGRATOR_SET\");\n\n        migrator = _migrator;\n\n        emit SetMigrator(_migrator);\n    }\n\n    function setDelegate(address account, bool _isDelegate) external override onlyOwner {\n        isDelegate[account] = _isDelegate;\n\n        emit SetDelegate(account, _isDelegate);\n    }\n\n    /**\n     * @notice Record global and per-user data to checkpoint\n     * @param addr User's wallet address. No user checkpoint if 0x0\n     * @param old_locked Pevious locked amount / end lock time for the user\n     * @param new_locked New locked amount / end lock time for the user\n     */\n    function _checkpoint(\n        address addr,\n        LockedBalance memory old_locked,\n        LockedBalance memory new_locked\n    ) internal {\n        Point memory u_old;\n        Point memory u_new;\n        int128 old_dslope;\n        int128 new_dslope;\n        uint256 _epoch = epoch;\n\n        if (addr != address(0)) {\n            // Calculate slopes and biases\n            // Kept at zero when they have to\n            if (old_locked.end > block.timestamp && old_locked.amount > 0) {\n                u_old.slope = old_locked.amount / maxDuration.toInt128();\n                u_old.bias = u_old.slope * (old_locked.end - block.timestamp).toInt128();\n            }\n            if (new_locked.end > block.timestamp && new_locked.amount > 0) {\n                u_new.slope = new_locked.amount / maxDuration.toInt128();\n                u_new.bias = u_new.slope * (new_locked.end - block.timestamp).toInt128();\n            }\n\n            // Read values of scheduled changes in the slope\n            // old_locked.end can be in the past and in the future\n            // new_locked.end can ONLY by in the FUTURE unless everything expired: than zeros\n            old_dslope = slopeChanges[old_locked.end];\n            if (new_locked.end != 0) {\n                if (new_locked.end == old_locked.end) new_dslope = old_dslope;\n                else new_dslope = slopeChanges[new_locked.end];\n            }\n        }\n\n        Point memory last_point = Point({bias: 0, slope: 0, ts: block.timestamp, blk: block.number});\n        if (_epoch > 0) last_point = pointHistory[_epoch];\n        uint256 last_checkpoint = last_point.ts;\n        // initial_last_point 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        Point memory initial_last_point = Point(last_point.bias, last_point.slope, last_point.ts, last_point.blk);\n        uint256 block_slope; // dblock/dt\n        if (block.timestamp > last_point.ts)\n            block_slope = (MULTIPLIER * (block.number - last_point.blk)) / (block.timestamp - last_point.ts);\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        {\n            // Go over weeks to fill history and calculate what the current point is\n            uint256 t_i = (last_checkpoint / interval) * interval;\n            for (uint256 i; 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 += interval;\n                int128 d_slope;\n                if (t_i > block.timestamp) t_i = block.timestamp;\n                else d_slope = slopeChanges[t_i];\n                last_point.bias -= last_point.slope * (t_i - last_checkpoint).toInt128();\n                last_point.slope += d_slope;\n                if (last_point.bias < 0)\n                    // This can happen\n                    last_point.bias = 0;\n                if (last_point.slope < 0)\n                    // This cannot happen - just in case\n                    last_point.slope = 0;\n                last_checkpoint = t_i;\n                last_point.ts = t_i;\n                last_point.blk = initial_last_point.blk + (block_slope * (t_i - initial_last_point.ts)) / MULTIPLIER;\n                _epoch += 1;\n                if (t_i == block.timestamp) {\n                    last_point.blk = block.number;\n                    break;\n                } else pointHistory[_epoch] = last_point;\n            }\n        }\n\n        epoch = _epoch;\n        // Now point_history is filled until t=now\n\n        if (addr != address(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            last_point.slope += (u_new.slope - u_old.slope);\n            last_point.bias += (u_new.bias - u_old.bias);\n            if (last_point.slope < 0) last_point.slope = 0;\n            if (last_point.bias < 0) last_point.bias = 0;\n        }\n\n        // Record the changed point into history\n        pointHistory[_epoch] = last_point;\n\n        if (addr != address(0)) {\n            // Schedule the slope changes (slope is going down)\n            // We subtract new_user_slope from [new_locked.end]\n            // and add old_user_slope to [old_locked.end]\n            if (old_locked.end > block.timestamp) {\n                // old_dslope was <something> - u_old.slope, so we cancel that\n                old_dslope += u_old.slope;\n                if (new_locked.end == old_locked.end) old_dslope -= u_new.slope; // It was a new deposit, not extension\n                slopeChanges[old_locked.end] = old_dslope;\n            }\n\n            if (new_locked.end > block.timestamp) {\n                if (new_locked.end > old_locked.end) {\n                    new_dslope -= u_new.slope; // old slope disappeared at this point\n                    slopeChanges[new_locked.end] = new_dslope;\n                }\n                // else: we recorded it already in old_dslope\n            }\n\n            // Now handle user history\n            uint256 user_epoch = userPointEpoch[addr] + 1;\n\n            userPointEpoch[addr] = user_epoch;\n            u_new.ts = block.timestamp;\n            u_new.blk = block.number;\n            userPointHistory[addr][user_epoch] = u_new;\n        }\n    }\n\n    /**\n     * @notice Deposit and lock tokens for a user\n     * @param _addr User's wallet address\n     * @param _value Amount to deposit\n     * @param _discount Amount to get discounted out of _value\n     * @param unlock_time New time when to unlock the tokens, or 0 if unchanged\n     * @param locked_balance Previous locked amount / timestamp\n     */\n    function _depositFor(\n        address _addr,\n        uint256 _value,\n        uint256 _discount,\n        uint256 unlock_time,\n        LockedBalance memory locked_balance,\n        int128 _type\n    ) internal {\n        LockedBalance memory _locked = locked_balance;\n        uint256 supply_before = supply;\n\n        supply = supply_before + _value;\n        LockedBalance memory old_locked;\n        (old_locked.amount, old_locked.discount, old_locked.start, old_locked.end) = (\n            _locked.amount,\n            _locked.discount,\n            _locked.start,\n            _locked.end\n        );\n        // Adding to existing lock, or if a lock is expired - creating a new one\n        _locked.amount += (_value).toInt128();\n        if (_discount != 0) _locked.discount += _discount.toInt128();\n        if (unlock_time != 0) {\n            if (_locked.start == 0) _locked.start = block.timestamp;\n            _locked.end = unlock_time;\n        }\n        locked[_addr] = _locked;\n\n        // Possibilities:\n        // Both old_locked.end could be current or expired (>/< block.timestamp)\n        // value == 0 (extend lock) or value > 0 (add to lock or extend lock)\n        // _locked.end > block.timestamp (always)\n        _checkpoint(_addr, old_locked, _locked);\n\n        if (_value > _discount) {\n            IERC20(token).safeTransferFrom(_addr, address(this), _value - _discount);\n        }\n\n        emit Deposit(_addr, _value, _discount, _locked.end, _type, block.timestamp);\n        emit Supply(supply_before, supply_before + _value);\n    }\n\n    function _pushDelegate(address addr, address delegate) internal {\n        bool found;\n        address[] storage delegates = delegateAt[addr];\n        for (uint256 i; i < delegates.length; ) {\n            if (delegates[i] == delegate) found = true;\n            unchecked {\n                ++i;\n            }\n        }\n        if (!found) delegateAt[addr].push(delegate);\n    }\n\n    /**\n     * @notice Record global data to checkpoint\n     */\n    function checkpoint() external override {\n        _checkpoint(address(0), LockedBalance(0, 0, 0, 0), LockedBalance(0, 0, 0, 0));\n    }\n\n    /**\n     * @notice Deposit `_value` tokens for `_addr` 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 _addr User's wallet address\n     * @param _value Amount to add to user's lock\n     */\n    function depositFor(address _addr, uint256 _value) external override nonReentrant beforeMigrated(_addr) {\n        LockedBalance memory _locked = locked[_addr];\n\n        require(_value > 0, \"VE: INVALID_VALUE\");\n        require(_locked.amount > 0, \"VE: LOCK_NOT_FOUND\");\n        require(_locked.end > block.timestamp, \"VE: LOCK_EXPIRED\");\n\n        _depositFor(_addr, _value, 0, 0, _locked, DEPOSIT_FOR_TYPE);\n    }\n\n    /**\n     * @notice Deposit `_value` tokens with `_discount` for `_addr` and lock for `_duration`\n     * @dev Only delegates can creat a lock for someone else\n     * @param _addr User's wallet address\n     * @param _value Amount to add to user's lock\n     * @param _discount Amount to get discounted out of _value\n     * @param _duration Epoch time until tokens unlock from now\n     */\n    function createLockFor(\n        address _addr,\n        uint256 _value,\n        uint256 _discount,\n        uint256 _duration\n    ) external override nonReentrant onlyDelegate beforeMigrated(_addr) {\n        _pushDelegate(_addr, msg.sender);\n\n        uint256 unlock_time = ((block.timestamp + _duration) / interval) * interval; // Locktime is rounded down to a multiple of interval\n        LockedBalance memory _locked = locked[_addr];\n\n        require(_value > 0, \"VE: INVALID_VALUE\");\n        require(_value >= _discount, \"VE: DISCOUNT_TOO_HIGH\");\n        require(_locked.amount == 0, \"VE: EXISTING_LOCK_FOUND\");\n        require(unlock_time > block.timestamp, \"VE: UNLOCK_TIME_TOO_EARLY\");\n        require(unlock_time <= block.timestamp + maxDuration, \"VE: UNLOCK_TIME_TOO_LATE\");\n\n        _depositFor(_addr, _value, _discount, unlock_time, _locked, CRETE_LOCK_TYPE);\n    }\n\n    /**\n     * @notice Deposit `_value` tokens for `msg.sender` and lock for `_duration`\n     * @param _value Amount to deposit\n     * @param _duration Epoch time until tokens unlock from now\n     */\n    function createLock(uint256 _value, uint256 _duration)\n        external\n        override\n        nonReentrant\n        authorized\n        beforeMigrated(msg.sender)\n    {\n        uint256 unlock_time = ((block.timestamp + _duration) / interval) * interval; // Locktime is rounded down to a multiple of interval\n        LockedBalance memory _locked = locked[msg.sender];\n\n        require(_value > 0, \"VE: INVALID_VALUE\");\n        require(_locked.amount == 0, \"VE: EXISTING_LOCK_FOUND\");\n        require(unlock_time > block.timestamp, \"VE: UNLOCK_TIME_TOO_EARLY\");\n        require(unlock_time <= block.timestamp + maxDuration, \"VE: UNLOCK_TIME_TOO_LATE\");\n\n        _depositFor(msg.sender, _value, 0, unlock_time, _locked, CRETE_LOCK_TYPE);\n    }\n\n    /**\n     * @notice Deposit `_value` additional tokens for `msg.sender`\n     *          without modifying the unlock time\n     * @param _addr User's wallet address\n     * @param _value Amount of tokens to deposit and add to the lock\n     * @param _discount Amount to get discounted out of _value\n     */\n    function increaseAmountFor(\n        address _addr,\n        uint256 _value,\n        uint256 _discount\n    ) external override nonReentrant onlyDelegate beforeMigrated(_addr) {\n        _pushDelegate(_addr, msg.sender);\n\n        LockedBalance memory _locked = locked[_addr];\n\n        require(_value > 0, \"VE: INVALID_VALUE\");\n        require(_value >= _discount, \"VE: DISCOUNT_TOO_HIGH\");\n        require(_locked.amount > 0, \"VE: LOCK_NOT_FOUND\");\n        require(_locked.end > block.timestamp, \"VE: LOCK_EXPIRED\");\n\n        _depositFor(_addr, _value, _discount, 0, _locked, INCREASE_LOCK_AMOUNT);\n    }\n\n    /**\n     * @notice Deposit `_value` additional tokens for `msg.sender`\n     *          without modifying the unlock time\n     * @param _value Amount of tokens to deposit and add to the lock\n     */\n    function increaseAmount(uint256 _value) external override nonReentrant authorized beforeMigrated(msg.sender) {\n        LockedBalance memory _locked = locked[msg.sender];\n\n        require(_value > 0, \"VE: INVALID_VALUE\");\n        require(_locked.amount > 0, \"VE: LOCK_NOT_FOUND\");\n        require(_locked.end > block.timestamp, \"VE: LOCK_EXPIRED\");\n\n        _depositFor(msg.sender, _value, 0, 0, _locked, INCREASE_LOCK_AMOUNT);\n    }\n\n    /**\n     * @notice Extend the unlock time for `msg.sender` to `_duration`\n     * @param _duration Increased epoch time for unlocking\n     */\n    function increaseUnlockTime(uint256 _duration)\n        external\n        override\n        nonReentrant\n        authorized\n        beforeMigrated(msg.sender)\n    {\n        LockedBalance memory _locked = locked[msg.sender];\n        uint256 unlock_time = ((_locked.end + _duration) / interval) * interval; // Locktime is rounded down to a multiple of interval\n\n        require(_locked.end > block.timestamp, \"VE: LOCK_EXPIRED\");\n        require(_locked.amount > 0, \"VE: LOCK_NOT_FOUND\");\n        require(_locked.discount == 0, \"VE: LOCK_DISCOUNTED\");\n        require(unlock_time >= _locked.end + interval, \"VE: UNLOCK_TIME_TOO_EARLY\");\n        require(unlock_time <= block.timestamp + maxDuration, \"VE: UNLOCK_TIME_TOO_LATE\");\n\n        _depositFor(msg.sender, 0, 0, unlock_time, _locked, INCREASE_UNLOCK_TIME);\n    }\n\n    /**\n     * @notice Cancel the existing lock of `msg.sender` with penalty\n     * @dev Only possible if the lock exists\n     */\n    function cancel() external override nonReentrant {\n        LockedBalance memory _locked = locked[msg.sender];\n        require(_locked.amount > 0, \"VE: LOCK_NOT_FOUND\");\n        require(_locked.end > block.timestamp, \"VE: LOCK_EXPIRED\");\n\n        uint256 penaltyRate = _penaltyRate(_locked.start, _locked.end);\n        uint256 supply_before = _clear(_locked, penaltyRate);\n\n        uint256 value = _locked.amount.toUint256();\n        uint256 discount = _locked.discount.toUint256();\n\n        IERC20(token).safeTransfer(msg.sender, ((value - discount) * (1e18 - penaltyRate)) / 1e18);\n\n        emit Cancel(msg.sender, value, discount, penaltyRate, block.timestamp);\n        emit Supply(supply_before, supply_before - value);\n    }\n\n    function _penaltyRate(uint256 start, uint256 end) internal view returns (uint256 penalty) {\n        penalty = (1e18 * (end - block.timestamp)) / (end - start);\n        if (penalty < 1e18 / 2) penalty = 1e18 / 2;\n    }\n\n    /**\n     * @notice Withdraw all tokens for `msg.sender`\n     * @dev Only possible if the lock has expired\n     */\n    function withdraw() external override nonReentrant {\n        LockedBalance memory _locked = locked[msg.sender];\n        require(block.timestamp >= _locked.end, \"VE: LOCK_NOT_EXPIRED\");\n\n        uint256 supply_before = _clear(_locked, 0);\n\n        uint256 value = _locked.amount.toUint256();\n        uint256 discount = _locked.discount.toUint256();\n\n        if (value > discount) {\n            IERC20(token).safeTransfer(msg.sender, value - discount);\n        }\n\n        emit Withdraw(msg.sender, value, discount, block.timestamp);\n        emit Supply(supply_before, supply_before - value);\n    }\n\n    function migrate() external override nonReentrant beforeMigrated(msg.sender) {\n        require(migrator != address(0), \"VE: MIGRATOR_NOT_SET\");\n\n        LockedBalance memory _locked = locked[msg.sender];\n        require(_locked.amount > 0, \"VE: LOCK_NOT_FOUND\");\n        require(_locked.end > block.timestamp, \"VE: LOCK_EXPIRED\");\n\n        address[] memory delegates = delegateAt[msg.sender];\n        uint256 supply_before = _clear(_locked, 0);\n\n        uint256 value = _locked.amount.toUint256();\n        uint256 discount = _locked.discount.toUint256();\n\n        IVotingEscrowMigrator(migrator).migrate(\n            msg.sender,\n            _locked.amount,\n            _locked.discount,\n            _locked.start,\n            _locked.end,\n            delegates\n        );\n        migrated[msg.sender] = true;\n\n        if (value > discount) {\n            IERC20(token).safeTransfer(migrator, value - discount);\n        }\n\n        emit Migrate(msg.sender, value, discount, block.timestamp);\n        emit Supply(supply_before, supply_before - value);\n    }\n\n    function _clear(LockedBalance memory _locked, uint256 penaltyRate) internal returns (uint256 supply_before) {\n        uint256 value = _locked.amount.toUint256();\n\n        locked[msg.sender] = LockedBalance(0, 0, 0, 0);\n        supply_before = supply;\n        supply = supply_before - value;\n\n        // old_locked can have either expired <= timestamp or zero end\n        // _locked has only 0 end\n        // Both can have >= 0 amount\n        _checkpoint(msg.sender, _locked, LockedBalance(0, 0, 0, 0));\n\n        address[] storage delegates = delegateAt[msg.sender];\n        for (uint256 i; i < delegates.length; ) {\n            IVotingEscrowDelegate(delegates[i]).withdraw(msg.sender, penaltyRate);\n            unchecked {\n                ++i;\n            }\n        }\n        delete delegateAt[msg.sender];\n    }\n\n    // The following ERC20/minime-compatible methods are not real balanceOf and supply!\n    // They measure the weights for the purpose of voting, so they don't represent\n    // real coins.\n\n    /**\n     * @notice Binary search to estimate timestamp for block number\n     * @param _block Block to find\n     * @param max_epoch Don't go beyond this epoch\n     * @return Approximate timestamp for block\n     */\n    function _findBlockEpoch(uint256 _block, uint256 max_epoch) internal view returns (uint256) {\n        uint256 _min;\n        uint256 _max = max_epoch;\n        for (uint256 i; i < 128; i++) {\n            if (_min >= _max) break;\n            uint256 _mid = (_min + _max + 1) / 2;\n            if (pointHistory[_mid].blk <= _block) _min = _mid;\n            else _max = _mid - 1;\n        }\n        return _min;\n    }\n\n    function balanceOf(address addr) public view override returns (uint256) {\n        return balanceOf(addr, block.timestamp);\n    }\n\n    /**\n     * @notice Get the current voting power for `msg.sender`\n     * @dev Adheres to the ERC20 `balanceOf` interface for Aragon compatibility\n     * @param addr User wallet address\n     * @param _t Epoch time to return voting power at\n     * @return User voting power\n     */\n    function balanceOf(address addr, uint256 _t) public view override returns (uint256) {\n        uint256 _epoch = userPointEpoch[addr];\n        if (_epoch == 0) return 0;\n        else {\n            Point memory last_point = userPointHistory[addr][_epoch];\n            last_point.bias -= last_point.slope * (_t - last_point.ts).toInt128();\n            if (last_point.bias < 0) last_point.bias = 0;\n            return last_point.bias.toUint256();\n        }\n    }\n\n    /**\n     * @notice Measure voting power of `addr` at block height `_block`\n     * @dev Adheres to MiniMe `balanceOfAt` interface: https://github.com/Giveth/minime\n     * @param addr User's wallet address\n     * @param _block Block to calculate the voting power at\n     * @return Voting power\n     */\n    function balanceOfAt(address addr, uint256 _block) external view override returns (uint256) {\n        // Copying and pasting totalSupply code because Vyper cannot pass by\n        // reference yet\n        require(_block <= block.number);\n\n        // Binary search\n        uint256 _min;\n        uint256 _max = userPointEpoch[addr];\n        for (uint256 i; i < 128; i++) {\n            if (_min >= _max) break;\n            uint256 _mid = (_min + _max + 1) / 2;\n            if (userPointHistory[addr][_mid].blk <= _block) _min = _mid;\n            else _max = _mid - 1;\n        }\n\n        Point memory upoint = userPointHistory[addr][_min];\n\n        uint256 max_epoch = epoch;\n        uint256 _epoch = _findBlockEpoch(_block, max_epoch);\n        Point memory point_0 = pointHistory[_epoch];\n        uint256 d_block;\n        uint256 d_t;\n        if (_epoch < max_epoch) {\n            Point memory point_1 = pointHistory[_epoch + 1];\n            d_block = point_1.blk - point_0.blk;\n            d_t = point_1.ts - point_0.ts;\n        } else {\n            d_block = block.number - point_0.blk;\n            d_t = block.timestamp - point_0.ts;\n        }\n        uint256 block_time = point_0.ts;\n        if (d_block != 0) block_time += ((d_t * (_block - point_0.blk)) / d_block);\n\n        upoint.bias -= upoint.slope * (block_time - upoint.ts).toInt128();\n        if (upoint.bias >= 0) return upoint.bias.toUint256();\n        else return 0;\n    }\n\n    /**\n     * @notice Calculate total voting power at some point in the past\n     * @param point The point (bias/slope) to start search from\n     * @param t Time to calculate the total voting power at\n     * @return Total voting power at that time\n     */\n    function _supplyAt(Point memory point, uint256 t) internal view returns (uint256) {\n        Point memory last_point = point;\n        uint256 t_i = (last_point.ts / interval) * interval;\n        for (uint256 i; i < 255; i++) {\n            t_i += interval;\n            int128 d_slope;\n            if (t_i > t) t_i = t;\n            else d_slope = slopeChanges[t_i];\n            last_point.bias -= last_point.slope * (t_i - last_point.ts).toInt128();\n            if (t_i == t) break;\n            last_point.slope += d_slope;\n            last_point.ts = t_i;\n        }\n\n        if (last_point.bias < 0) last_point.bias = 0;\n        return last_point.bias.toUint256();\n    }\n\n    function totalSupply() public view override returns (uint256) {\n        return totalSupply(block.timestamp);\n    }\n\n    /**\n     * @notice Calculate total voting power\n     * @dev Adheres to the ERC20 `totalSupply` interface for Aragon compatibility\n     * @return Total voting power\n     */\n    function totalSupply(uint256 t) public view override returns (uint256) {\n        uint256 _epoch = epoch;\n        Point memory last_point = pointHistory[_epoch];\n        return _supplyAt(last_point, t);\n    }\n\n    /**\n     * @notice Calculate total voting power at some point in the past\n     * @param _block Block to calculate the total voting power at\n     * @return Total voting power at `_block`\n     */\n    function totalSupplyAt(uint256 _block) external view override returns (uint256) {\n        require(_block <= block.number);\n        uint256 _epoch = epoch;\n        uint256 target_epoch = _findBlockEpoch(_block, _epoch);\n\n        Point memory point = pointHistory[target_epoch];\n        uint256 dt;\n        if (target_epoch < _epoch) {\n            Point memory point_next = pointHistory[target_epoch + 1];\n            if (point.blk != point_next.blk)\n                dt = ((_block - point.blk) * (point_next.ts - point.ts)) / (point_next.blk - point.blk);\n        } else if (point.blk != block.number)\n            dt = ((_block - point.blk) * (block.timestamp - point.ts)) / (block.number - point.blk);\n        // Now dt contains info on how far are we beyond point\n\n        return _supplyAt(point, point.ts + dt);\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
    },
    "@openzeppelin/contracts/security/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (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        // On the first call to nonReentrant, _notEntered will be true\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\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"
    },
    "contracts/libraries/Integers.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nlibrary Integers {\n    function toInt128(uint256 u) internal pure returns (int128) {\n        return int128(int256(u));\n    }\n\n    function toUint256(int128 i) internal pure returns (uint256) {\n        return uint256(uint128(i));\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// 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"
    },
    "contracts/mocks/VotingEscrowMigratorMock.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/IVotingEscrow.sol\";\nimport \"../interfaces/IVotingEscrowMigrator.sol\";\nimport \"../libraries/Integers.sol\";\n\ncontract VotingEscrowMigratorMock is IVotingEscrowMigrator {\n    using SafeERC20 for IERC20;\n    using Integers for int128;\n    using Integers for uint256;\n\n    struct LockedBalance {\n        int128 amount;\n        int128 discount;\n        uint256 start;\n        uint256 end;\n    }\n\n    address public immutable token;\n    mapping(address => LockedBalance) public locked;\n    mapping(address => address[]) public delegates;\n\n    constructor(address ve) {\n        token = IVotingEscrow(ve).token();\n    }\n\n    function migrate(\n        address account,\n        int128 amount,\n        int128 discount,\n        uint256 start,\n        uint256 end,\n        address[] calldata _delegates\n    ) external override {\n        locked[account] = LockedBalance(amount, discount, start, end);\n        delegates[account] = _delegates;\n    }\n\n    function withdraw() external {\n        LockedBalance memory _locked = locked[msg.sender];\n        require(block.timestamp >= _locked.end, \"VE: LOCK_NOT_EXPIRED\");\n\n        uint256 value = _locked.amount.toUint256();\n        uint256 discount = _locked.discount.toUint256();\n\n        locked[msg.sender] = LockedBalance(0, 0, 0, 0);\n\n        if (value > discount) {\n            IERC20(token).safeTransfer(msg.sender, value - discount);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC721/ERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n    using Address for address;\n    using Strings for uint256;\n\n    // Token name\n    string private _name;\n\n    // Token symbol\n    string private _symbol;\n\n    // Mapping from token ID to owner address\n    mapping(uint256 => address) private _owners;\n\n    // Mapping owner address to token count\n    mapping(address => uint256) private _balances;\n\n    // Mapping from token ID to approved address\n    mapping(uint256 => address) private _tokenApprovals;\n\n    // Mapping from owner to operator approvals\n    mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n    /**\n     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return\n            interfaceId == type(IERC721).interfaceId ||\n            interfaceId == type(IERC721Metadata).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721-balanceOf}.\n     */\n    function balanceOf(address owner) public view virtual override returns (uint256) {\n        require(owner != address(0), \"ERC721: balance query for the zero address\");\n        return _balances[owner];\n    }\n\n    /**\n     * @dev See {IERC721-ownerOf}.\n     */\n    function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n        address owner = _owners[tokenId];\n        require(owner != address(0), \"ERC721: owner query for nonexistent token\");\n        return owner;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-name}.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-symbol}.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-tokenURI}.\n     */\n    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n        require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n\n        string memory baseURI = _baseURI();\n        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n    }\n\n    /**\n     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n     * by default, can be overridden in child contracts.\n     */\n    function _baseURI() internal view virtual returns (string memory) {\n        return \"\";\n    }\n\n    /**\n     * @dev See {IERC721-approve}.\n     */\n    function approve(address to, uint256 tokenId) public virtual override {\n        address owner = ERC721.ownerOf(tokenId);\n        require(to != owner, \"ERC721: approval to current owner\");\n\n        require(\n            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n            \"ERC721: approve caller is not owner nor approved for all\"\n        );\n\n        _approve(to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-getApproved}.\n     */\n    function getApproved(uint256 tokenId) public view virtual override returns (address) {\n        require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\n\n        return _tokenApprovals[tokenId];\n    }\n\n    /**\n     * @dev See {IERC721-setApprovalForAll}.\n     */\n    function setApprovalForAll(address operator, bool approved) public virtual override {\n        _setApprovalForAll(_msgSender(), operator, approved);\n    }\n\n    /**\n     * @dev See {IERC721-isApprovedForAll}.\n     */\n    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n        return _operatorApprovals[owner][operator];\n    }\n\n    /**\n     * @dev See {IERC721-transferFrom}.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) public virtual override {\n        //solhint-disable-next-line max-line-length\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n\n        _transfer(from, to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) public virtual override {\n        safeTransferFrom(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory _data\n    ) public virtual override {\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n        _safeTransfer(from, to, tokenId, _data);\n    }\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     * `_data` is additional data, it has no specified format and it is sent in call to `to`.\n     *\n     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n     * implement alternative mechanisms to perform token transfer, such as signature-based.\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 `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 _safeTransfer(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory _data\n    ) internal virtual {\n        _transfer(from, to, tokenId);\n        require(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\n    }\n\n    /**\n     * @dev Returns whether `tokenId` exists.\n     *\n     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n     *\n     * Tokens start existing when they are minted (`_mint`),\n     * and stop existing when they are burned (`_burn`).\n     */\n    function _exists(uint256 tokenId) internal view virtual returns (bool) {\n        return _owners[tokenId] != address(0);\n    }\n\n    /**\n     * @dev Returns whether `spender` is allowed to manage `tokenId`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n        require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\n        address owner = ERC721.ownerOf(tokenId);\n        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n    }\n\n    /**\n     * @dev Safely mints `tokenId` and transfers it to `to`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\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 _safeMint(address to, uint256 tokenId) internal virtual {\n        _safeMint(to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeMint(\n        address to,\n        uint256 tokenId,\n        bytes memory _data\n    ) internal virtual {\n        _mint(to, tokenId);\n        require(\n            _checkOnERC721Received(address(0), to, tokenId, _data),\n            \"ERC721: transfer to non ERC721Receiver implementer\"\n        );\n    }\n\n    /**\n     * @dev Mints `tokenId` and transfers it to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - `to` cannot be the zero address.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _mint(address to, uint256 tokenId) internal virtual {\n        require(to != address(0), \"ERC721: mint to the zero address\");\n        require(!_exists(tokenId), \"ERC721: token already minted\");\n\n        _beforeTokenTransfer(address(0), to, tokenId);\n\n        _balances[to] += 1;\n        _owners[tokenId] = to;\n\n        emit Transfer(address(0), to, tokenId);\n\n        _afterTokenTransfer(address(0), to, tokenId);\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId) internal virtual {\n        address owner = ERC721.ownerOf(tokenId);\n\n        _beforeTokenTransfer(owner, address(0), tokenId);\n\n        // Clear approvals\n        _approve(address(0), tokenId);\n\n        _balances[owner] -= 1;\n        delete _owners[tokenId];\n\n        emit Transfer(owner, address(0), tokenId);\n\n        _afterTokenTransfer(owner, address(0), tokenId);\n    }\n\n    /**\n     * @dev Transfers `tokenId` from `from` to `to`.\n     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _transfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual {\n        require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n        require(to != address(0), \"ERC721: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, tokenId);\n\n        // Clear approvals from the previous owner\n        _approve(address(0), tokenId);\n\n        _balances[from] -= 1;\n        _balances[to] += 1;\n        _owners[tokenId] = to;\n\n        emit Transfer(from, to, tokenId);\n\n        _afterTokenTransfer(from, to, tokenId);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * Emits a {Approval} event.\n     */\n    function _approve(address to, uint256 tokenId) internal virtual {\n        _tokenApprovals[tokenId] = to;\n        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n    }\n\n    /**\n     * @dev Approve `operator` to operate on all of `owner` tokens\n     *\n     * Emits a {ApprovalForAll} event.\n     */\n    function _setApprovalForAll(\n        address owner,\n        address operator,\n        bool approved\n    ) internal virtual {\n        require(owner != operator, \"ERC721: approve to caller\");\n        _operatorApprovals[owner][operator] = approved;\n        emit ApprovalForAll(owner, operator, approved);\n    }\n\n    /**\n     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n     * The call is not executed if the target address is not a contract.\n     *\n     * @param from address representing the previous owner of the given token ID\n     * @param to target address that will receive the tokens\n     * @param tokenId uint256 ID of the token to be transferred\n     * @param _data bytes optional data to send along with the call\n     * @return bool whether the call correctly returned the expected magic value\n     */\n    function _checkOnERC721Received(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory _data\n    ) private returns (bool) {\n        if (to.isContract()) {\n            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {\n                return retval == IERC721Receiver.onERC721Received.selector;\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n                } else {\n                    assembly {\n                        revert(add(32, reason), mload(reason))\n                    }\n                }\n            }\n        } else {\n            return true;\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any token transfer. This includes minting\n     * and burning.\n     *\n     * Calling conditions:\n     *\n     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n     * transferred to `to`.\n     * - When `from` is zero, `tokenId` will be minted for `to`.\n     * - When `to` is zero, ``from``'s `tokenId` will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual {}\n}\n"
    },
    "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.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(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) 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 be 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(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\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(\n        address from,\n        address to,\n        uint256 tokenId\n    ) 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"
    },
    "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
      "content": "// 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"
    },
    "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
      "content": "// 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"
    },
    "@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// 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"
    },
    "contracts/mocks/NFTMock.sol": {
      "content": "// SPDX-License-Identifier: WTFPL\n\npragma solidity ^0.8.14;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport \"../interfaces/INFT.sol\";\n\ncontract NFTMock is ERC721, Ownable, INFT {\n    constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {\n        // Empty\n    }\n\n    function balanceOf(address owner) public view override(ERC721, INFT) returns (uint256 balance) {\n        return ERC721.balanceOf(owner);\n    }\n\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) public override(ERC721, INFT) {\n        ERC721.safeTransferFrom(from, to, tokenId);\n    }\n\n    function mint(\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external override onlyOwner {\n        _safeMint(to, tokenId, data);\n    }\n\n    function mintBatch(\n        address to,\n        uint256[] calldata tokenIds,\n        bytes calldata data\n    ) external override onlyOwner {\n        for (uint256 i; i < tokenIds.length; i++) {\n            _safeMint(to, tokenIds[i], data);\n        }\n    }\n\n    function burn(\n        uint256 tokenId,\n        uint256,\n        bytes32\n    ) external override {\n        _burn(tokenId);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/ERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * The default value of {decimals} is 18. To select a different value for\n     * {decimals} you should overload it.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless this function is\n     * overridden;\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address to, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n     * `transferFrom`. This is semantically equivalent to an infinite approval.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * NOTE: Does not update the allowance if the current allowance\n     * is the maximum `uint256`.\n     *\n     * Requirements:\n     *\n     * - `from` and `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, amount);\n        _transfer(from, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, allowance(owner, spender) + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        uint256 currentAllowance = allowance(owner, spender);\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(owner, spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `sender` to `recipient`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     */\n    function _transfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {\n        require(from != address(0), \"ERC20: transfer from the zero address\");\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, amount);\n\n        uint256 fromBalance = _balances[from];\n        require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[from] = fromBalance - amount;\n        }\n        _balances[to] += amount;\n\n        emit Transfer(from, to, amount);\n\n        _afterTokenTransfer(from, to, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n        }\n        _totalSupply -= amount;\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n     *\n     * Does not update the allowance amount in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Might emit an {Approval} event.\n     */\n    function _spendAllowance(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance != type(uint256).max) {\n            require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n            unchecked {\n                _approve(owner, spender, currentAllowance - amount);\n            }\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n}\n"
    },
    "contracts/mocks/ERC20Mock.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract ERC20Mock is ERC20 {\n    constructor(\n        string memory name,\n        string memory symbol,\n        uint256 initialSupply\n    ) ERC20(name, symbol) {\n        _mint(msg.sender, initialSupply);\n    }\n}\n"
    },
    "contracts/uniswapv2/interfaces/IWETH.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IWETH {\n    function deposit() external payable;\n    function transfer(address to, uint value) external returns (bool);\n    function withdraw(uint) external;\n}"
    },
    "contracts/uniswapv2/interfaces/IERC20.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IERC20Uniswap {\n    event Approval(address indexed owner, address indexed spender, uint value);\n    event Transfer(address indexed from, address indexed to, uint value);\n\n    function name() external view returns (string memory);\n    function symbol() external view returns (string memory);\n    function decimals() external view returns (uint8);\n    function totalSupply() external view returns (uint);\n    function balanceOf(address owner) external view returns (uint);\n    function allowance(address owner, address spender) external view returns (uint);\n\n    function approve(address spender, uint value) external returns (bool);\n    function transfer(address to, uint value) external returns (bool);\n    function transferFrom(address from, address to, uint value) external returns (bool);\n}\n"
    },
    "contracts/uniswapv2/interfaces/IUniswapV2Callee.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Callee {\n    function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;\n}\n"
    },
    "contracts/uniswapv2/interfaces/IUniswapV2Factory.sol": {
      "content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Factory {\n    event PairCreated(address indexed token0, address indexed token1, address pair, uint);\n\n    function feeTo() external view returns (address);\n    function feeToSetter() external view returns (address);\n    function migrator() external view returns (address);\n\n    function getPair(address tokenA, address tokenB) external view returns (address pair);\n    function allPairs(uint) external view returns (address pair);\n    function allPairsLength() external view returns (uint);\n\n    function createPair(address tokenA, address tokenB) external returns (address pair);\n\n    function setFeeTo(address) external;\n    function setFeeToSetter(address) external;\n    function setMigrator(address) external;\n}\n"
    },
    "contracts/uniswapv2/interfaces/IUniswapV2Router02.sol": {
      "content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n    function removeLiquidityETHSupportingFeeOnTransferTokens(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountETH);\n    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountETH);\n\n    function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n    function swapExactETHForTokensSupportingFeeOnTransferTokens(\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external payable;\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external;\n}"
    },
    "contracts/uniswapv2/interfaces/IUniswapV2Router01.sol": {
      "content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n    function factory() external pure returns (address);\n    function WETH() external pure returns (address);\n\n    function addLiquidity(\n        address tokenA,\n        address tokenB,\n        uint amountADesired,\n        uint amountBDesired,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountA, uint amountB, uint liquidity);\n    function addLiquidityETH(\n        address token,\n        uint amountTokenDesired,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n    function removeLiquidity(\n        address tokenA,\n        address tokenB,\n        uint liquidity,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountA, uint amountB);\n    function removeLiquidityETH(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline\n    ) external returns (uint amountToken, uint amountETH);\n    function removeLiquidityWithPermit(\n        address tokenA,\n        address tokenB,\n        uint liquidity,\n        uint amountAMin,\n        uint amountBMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountA, uint amountB);\n    function removeLiquidityETHWithPermit(\n        address token,\n        uint liquidity,\n        uint amountTokenMin,\n        uint amountETHMin,\n        address to,\n        uint deadline,\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\n    ) external returns (uint amountToken, uint amountETH);\n    function swapExactTokensForTokens(\n        uint amountIn,\n        uint amountOutMin,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external returns (uint[] memory amounts);\n    function swapTokensForExactTokens(\n        uint amountOut,\n        uint amountInMax,\n        address[] calldata path,\n        address to,\n        uint deadline\n    ) external returns (uint[] memory amounts);\n    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n        external\n        payable\n        returns (uint[] memory amounts);\n    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n        external\n        returns (uint[] memory amounts);\n    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n        external\n        returns (uint[] memory amounts);\n    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n        external\n        payable\n        returns (uint[] memory amounts);\n\n    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}"
    },
    "contracts/uniswapv2/libraries/TransferHelper.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\npragma solidity >=0.6.0;\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n    function safeApprove(address token, address to, uint value) internal {\n        // bytes4(keccak256(bytes('approve(address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');\n    }\n\n    function safeTransfer(address token, address to, uint value) internal {\n        // bytes4(keccak256(bytes('transfer(address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');\n    }\n\n    function safeTransferFrom(address token, address from, address to, uint value) internal {\n        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));\n        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');\n    }\n\n    function safeTransferETH(address to, uint value) internal {\n        (bool success,) = to.call{value:value}(new bytes(0));\n        require(success, 'TransferHelper: ETH_TRANSFER_FAILED');\n    }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "devdoc",
          "userdoc",
          "storageLayout",
          "evm.gasEstimates"
        ],
        "": [
          "ast"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    },
    "libraries": {
      "": {
        "__CACHE_BREAKER__": "0x00000000d41867734bbee4c6863d9255b2b06ac1"
      }
    }
  }
}