ETH Price: $3,126.54 (-0.23%)

Contract

0xc01E7dCC6CCA1Af57a5099f1DcaB90084408bFDb
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60a06040150448852022-06-29 11:51:06872 days ago1656503466IN
 Create: Vesting
0 ETH0.1972827445

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Vesting

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion
File 1 of 31 : Vesting.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import { ERC721EnumerableUpgradeable, ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { SafeERC20Upgradeable, IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import { SafeCastUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import { CountersUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import { IVesting } from "./interfaces/IVesting.sol";
import { IBondsRegistry } from "./interfaces/IBondsRegistry.sol";
import { Position } from "./libraries/vesting/Position.sol";
import { Constants } from "./libraries/Constants.sol";

/// @title ERC721 Vesting contract
/// @notice Vesting positions contract
/// @dev Each non fungible position is represented in this contract by a tokenId
/// using the ERC721 standard, which can be freely transferred to a new address if desired,
/// and allows more flexibility of integrations such as revenue distributions, bonds
/// and DeFi composability in general.
/// @dev This contract used for ILV tokens can be extended/modified for supporting different
/// underlying ERC20 tokens in Illuvium protocol in the future.
/// @author Pedro Bergamini | 0xpedro.eth
contract Vesting is IVesting, UUPSUpgradeable, ERC721EnumerableUpgradeable, OwnableUpgradeable, PausableUpgradeable {
    /* ======== LIBRARIES ======== */
    using Position for Position.Data;
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using SafeCastUpgradeable for uint256;
    using CountersUpgradeable for CountersUpgradeable.Counter;

    /* ======== STATE VARIABLES ======== */
    /// @dev Underlying ERC20 token address (ILV token)
    IERC20Upgradeable public underlying;
    /// @dev Revenue distributions vault contract address
    address public vault;
    /// @dev Bonds contract address
    IBondsRegistry public bondsRegistry;
    /// @dev Tracks token id to be used for the next minted token
    CountersUpgradeable.Counter public tokenIdTracker;
    /// @dev Revenue distribution allocated per token, used to calculate
    /// revdis rewards for locked positions
    uint256 public revDisPerToken;
    /// @dev Total amount of underlying tokens in positions
    uint256 public underlyingSupplied;
    /// @dev Whether ERC721 transfers should be allowed. Needs to be set to true in order
    /// to allow ERC721 transfers.
    bool public isTransferAllowed;
    /// @dev Value used to store baseURI returned in {ERC721Upgradeable._baseURI}
    string internal baseURI_;
    /// @dev Locked token holders vesting positions
    mapping(uint256 => Position.Data) public positions;

    /* ======== EVENTS ======== */
    event LogSetTransferState(bool shouldAllow);
    event LogSetBaseURI(string oldBaseURI, string newBaseURI);
    event LogSetBonds(address oldBonds, address newBonds);
    event LogSetVault(address oldVault, address newVault);
    event LogSetPositions(address[] holders, Position.InitParams[] _positions, uint256 totalUnderlying);
    event LogUnlock(address indexed caller, uint256 indexed tokenId, uint256 value);
    event LogClaimRevenueDistribution(address indexed caller, uint256 indexed tokenId, uint256 value);
    event LogReceiveVaultRewards(address indexed vault, uint256 reward);

    /* ======== MODIFIERS ======== */
    modifier onlyBondsRegistry() {
        require(msg.sender == address(bondsRegistry), "only bonds registry allowed");
        _;
    }

    modifier onlyVault() {
        require(msg.sender == vault, "only vault allowed");
        _;
    }

    modifier onlyApprovedOrOwner(address _caller, uint256 _tokenId) {
        require(_isApprovedOrOwner(_caller, _tokenId), "invalid _caller");
        _;
    }

    modifier updateRevDis(uint256 _tokenId) {
        Position.Data storage position = positions[_tokenId];
        position.pendingRevDis = position.earnedRevDis(revDisPerToken).toUint128();
        position.revDisPerTokenPaid = revDisPerToken;
        _;
    }

    /// @dev Disables initializer functions in the implementation contract when deployed.
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /// @dev UUPSUpgradeable initializer
    function initialize(
        string memory _name,
        string memory _symbol,
        IERC20Upgradeable _underlying,
        address _vault
    ) external initializer {
        require(
            bytes(_name).length != 0 &&
                bytes(_symbol).length != 0 &&
                address(_underlying) != address(0) &&
                _vault != address(0),
            "invalid inputs"
        );
        underlying = _underlying;
        vault = _vault;

        __UUPSUpgradeable_init();
        __ERC721_init(_name, _symbol);
        __Ownable_init();
        __Pausable_init();
    }

    /// @inheritdoc IVesting
    function vestedUnderlyingFor(uint256 _tokenId) external view virtual returns (uint256 vestedUnderlying) {
        vestedUnderlying = positions[_tokenId].vestedUnderlying();
    }

    /// @inheritdoc IVesting
    function availableUnderlyingFor(uint256 _tokenId) public view virtual returns (uint256 availableUnderlying) {
        uint256 vestedUnderlying = positions[_tokenId].vestedUnderlying();
        uint256 positionAvailableBalance = positions[_tokenId].balance;
        availableUnderlying = vestedUnderlying > positionAvailableBalance ? positionAvailableBalance : vestedUnderlying;
    }

    /// @inheritdoc IVesting
    function pendingRevDisFor(uint256 _tokenId) external view virtual returns (uint256) {
        return positions[_tokenId].earnedRevDis(revDisPerToken);
    }

    /// @inheritdoc IVesting
    function poolTokenReserve() external view virtual returns (uint256) {
        return underlyingSupplied;
    }

    /// @inheritdoc IVesting
    function isApprovedOrOwner(address _spender, uint256 _tokenId) external view virtual returns (bool) {
        return _isApprovedOrOwner(_spender, _tokenId);
    }

    /// @inheritdoc IVesting
    function setPauseState(bool _shouldPause) external virtual onlyOwner {
        if (_shouldPause) {
            _pause();
        } else {
            _unpause();
        }
    }

    /// @inheritdoc IVesting
    function setTransferState(bool _shouldAllow) external virtual onlyOwner {
        emit LogSetTransferState(_shouldAllow);
        isTransferAllowed = _shouldAllow;
    }

    /// @inheritdoc IVesting
    function setBaseURI(string memory _newBaseURI) external virtual onlyOwner {
        emit LogSetBaseURI(baseURI_, _newBaseURI);
        baseURI_ = _newBaseURI;
    }

    /// @inheritdoc IVesting
    function setBondsContract(IBondsRegistry _bondsRegistry) external virtual onlyOwner {
        require(address(_bondsRegistry) != address(0), "invalid _bondsRegistry");
        emit LogSetBonds(address(bondsRegistry), address(_bondsRegistry));
        bondsRegistry = _bondsRegistry;
    }

    /// @inheritdoc IVesting
    function setVaultContract(address _vault) external virtual onlyOwner {
        require(_vault != address(0), "invalid _vault");
        emit LogSetVault(vault, _vault);
        vault = _vault;
    }

    /// @inheritdoc IVesting
    function setPositions(address[] calldata _holders, Position.InitParams[] calldata _positions)
        external
        virtual
        override
        onlyOwner
    {
        require(_holders.length == _positions.length, "array length mismatch");
        uint256 totalUnderlying;
        for (uint256 i = 0; i < _holders.length; i++) {
            require(
                _positions[i].end > _positions[i].start && _positions[i].start > 0 && _positions[i].balance > 0,
                "invalid position input"
            );
            totalUnderlying += _positions[i].balance;
            tokenIdTracker.increment();
            uint256 currentTokenId = tokenIdTracker.current();
            _mint(_holders[i], currentTokenId);
            Position.Data memory _position = Position.Data({
                balance: _positions[i].balance,
                unlocked: 0,
                start: _positions[i].start,
                end: _positions[i].end,
                rate: uint256(_positions[i].balance / (_positions[i].end - _positions[i].start)).toUint128(),
                pendingRevDis: 0,
                revDisPerTokenPaid: revDisPerToken
            });
            positions[currentTokenId] = _position;
        }
        underlyingSupplied += totalUnderlying;

        emit LogSetPositions(_holders, _positions, totalUnderlying);
    }

    /// @inheritdoc IVesting
    function unlock(uint256 _tokenId)
        external
        virtual
        whenNotPaused
        onlyApprovedOrOwner(msg.sender, _tokenId)
        updateRevDis(_tokenId)
    {
        address tokenOwner = ownerOf(_tokenId);
        Position.Data storage position = positions[_tokenId];
        uint256 valueToUnlock = availableUnderlyingFor(_tokenId);
        require(valueToUnlock > 0, "zero value to unlock");
        position.balance -= valueToUnlock.toUint128();
        position.unlocked += valueToUnlock.toUint128();
        uint256 currentUnderlyingSupplied = underlyingSupplied;
        if (valueToUnlock > currentUnderlyingSupplied) {
            valueToUnlock = currentUnderlyingSupplied;
        }
        // we assume valueToUnlock is valid if position.balance didn't underflow
        unchecked {
            underlyingSupplied = currentUnderlyingSupplied - valueToUnlock;
        }

        underlying.safeTransfer(tokenOwner, valueToUnlock);
        emit LogUnlock(msg.sender, _tokenId, valueToUnlock);
    }

    /// @inheritdoc IVesting
    function claimRevenueDistribution(uint256 _tokenId)
        external
        virtual
        whenNotPaused
        onlyApprovedOrOwner(msg.sender, _tokenId)
        updateRevDis(_tokenId)
    {
        address tokenOwner = ownerOf(_tokenId);
        Position.Data storage position = positions[_tokenId];
        uint256 pendingRevDis = position.pendingRevDis;
        position.pendingRevDis = 0;

        require(pendingRevDis > 0, "0 pending revdis");
        underlying.safeTransfer(tokenOwner, pendingRevDis);
        emit LogClaimRevenueDistribution(msg.sender, _tokenId, pendingRevDis);
    }

    /// @inheritdoc IVesting
    function afterUnderlyingOffer(
        address _caller,
        uint256 _tokenId,
        uint256 _value
    ) external virtual whenNotPaused onlyBondsRegistry onlyApprovedOrOwner(_caller, _tokenId) updateRevDis(_tokenId) {
        require(_value > 0, "zero underlying");
        positions[_tokenId].balance -= _value.toUint128();
        underlyingSupplied -= _value;

        underlying.safeTransfer(msg.sender, _value);
    }

    /// @inheritdoc IVesting
    function afterOfferResignation(
        address _caller,
        uint256 _tokenId,
        uint256 _value
    ) external virtual whenNotPaused onlyBondsRegistry onlyApprovedOrOwner(_caller, _tokenId) updateRevDis(_tokenId) {
        require(_value > 0, "zero underlying");
        positions[_tokenId].balance += _value.toUint128();
        underlyingSupplied += _value;
    }

    /// @inheritdoc IVesting
    function receiveVaultRewards(uint256 _reward) external virtual whenNotPaused onlyVault {
        require(underlyingSupplied > 0 && _reward > 0, "invalid state or input");

        revDisPerToken += (_reward * Constants.BASE_MULTIPLIER) / underlyingSupplied;
        underlying.safeTransferFrom(msg.sender, address(this), _reward);

        emit LogReceiveVaultRewards(msg.sender, _reward);
    }

    /// @inheritdoc ERC721Upgradeable
    function _baseURI() internal view virtual override returns (string memory) {
        return baseURI_;
    }

    /// @inheritdoc ERC721Upgradeable
    /// @dev Blocks ERC721 transfers after all positions are setup.
    function _beforeTokenTransfer(
        address _from,
        address _to,
        uint256 _tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(_from, _to, _tokenId);
        require(msg.sender == owner() || isTransferAllowed, "ERC721 transfers not allowed");
    }

    /// @inheritdoc UUPSUpgradeable
    function _authorizeUpgrade(address) internal virtual override onlyOwner {}

    /// @dev UUPSUpgradeable storage gap
    uint256[41] private __gap;
}

File 2 of 31 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

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

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

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

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

File 3 of 31 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

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

File 4 of 31 : ERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
    function __ERC721Enumerable_init() internal onlyInitializing {
    }

    function __ERC721Enumerable_init_unchained() internal onlyInitializing {
    }
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) {
        return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721Upgradeable.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }

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

File 5 of 31 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

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

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

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

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

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

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

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

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

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

File 6 of 31 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 7 of 31 : SafeCastUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCastUpgradeable {
    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 8 of 31 : CountersUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 9 of 31 : IVesting.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

import { Position } from "../libraries/vesting/Position.sol";
import { IBondsRegistry } from "./IBondsRegistry.sol";

interface IVesting {
    /// @notice Returns total underlying vested for given holder.
    /// @dev It won't take into account if the holder has enough balance available to unlock,
    /// for that scenario use {availableUnderlyingFor} function.
    /// @param _tokenId position nft identifier
    /// @return vestedUnderlying the number of tokens vested
    function vestedUnderlyingFor(uint256 _tokenId) external view returns (uint256);

    /// @notice Returns total underlying available to be unlocked for given holder.
    /// @dev It compares the vested value to the position available balance and returns
    /// the highest amount of underlying that is available to be unlocked.
    /// @dev Availability might be less than the vested amount of the position holder
    /// offers some underlying to the Bonds contract.
    /// @param _tokenId position nft identifier
    /// @return availableUnderlying the number of tokens available to be unlocked (vested or balance)
    function availableUnderlyingFor(uint256 _tokenId) external view returns (uint256 availableUnderlying);

    /// @notice Returns pending revenue distribution claim for given position.
    /// @param _tokenId position nft identifier
    function pendingRevDisFor(uint256 _tokenId) external view returns (uint256);

    /// @notice Returns the underlying supplied value.
    /// @dev Value used by Illuvium's Vault contract to calculate revenue
    /// distributions.
    function poolTokenReserve() external view returns (uint256);

    /// @notice Returns whether spender is the position owner or an approved address.
    /// @param _spender Address using the position nft
    /// @param _tokenId position nft identifier
    function isApprovedOrOwner(address _spender, uint256 _tokenId) external view returns (bool);

    /// @notice Pauses critical functionality in the contract.
    /// @dev Can be called by the eDAO multisig in case the contract needs to be paused
    /// in an emergency and unpaused later.
    /// @param _shouldPause whether the contract needs to be paused/unpaused
    function setPauseState(bool _shouldPause) external;

    /// @notice Enables/disables ERC721 transfer functionality.
    /// @dev Only owner (the eDAO) is able to enable/disable the ERC721
    /// transfer functionality. By default it's disabled for all position NFT
    /// holders, only the owner is able to do it, in order to be able to call
    /// {setPositions()}.
    function setTransferState(bool _shouldAllow) external;

    /// @notice Updates ERC721 base URI value.
    function setBaseURI(string memory _newBaseURI) external;

    /// @notice Updates Bonds contract address stored.
    /// @dev Can only be called by the owner (eDAO multisig)
    /// @param _bondsRegistry Bonds contract address
    function setBondsContract(IBondsRegistry _bondsRegistry) external;

    /// @notice Updates Vault contract address stored.
    /// @dev Can only be called by the owner (eDAO multisig)
    /// @param _vault Vault contract address
    function setVaultContract(address _vault) external;

    /// @notice Sets vesting positions for an array of addresses.
    /// @dev Only the contract owner (eDAO gnosis multisig) is able to add new positions.
    /// @param _holders an array of locked token holders addresses
    /// @param _positions position data for each holder address
    function setPositions(address[] calldata _holders, Position.InitParams[] calldata _positions) external;

    /// @notice Unlocks vested tokens for the given position.
    /// @dev If holder has less available balance than the vested underlying (due to bonds),
    /// it should unlock the whole balance.
    /// @dev It's expected that holders are able to move tokens to Bonds contract
    /// and bring back unsold underlying and keep unlocking at the same rate.
    /// @param _tokenId position nft identifier
    function unlock(uint256 _tokenId) external;

    /// @notice Claims pending revenue distribution for the given position.
    /// @dev Only approved address or token owner can request the revdis claim.
    /// @dev Position's revdis values must be updated before proceeding to the claim,
    /// in order to keep correct calculations.
    /// @param _tokenId position nft identifier
    function claimRevenueDistribution(uint256 _tokenId) external;

    /// @notice Hook called by the bonds contract after a position balance
    /// is offered.
    /// @dev Important checks are performed, only the token owner or an approved party
    /// is able to offer a part of or the whole position underlying balance to be
    /// sold in the bonds contract.
    /// @dev Call is restricted to the bonds contract.
    /// @dev It should remove the underlying value supplied to become an offer.
    /// @param _caller address who initiated the call in the bonds contract
    /// @param _tokenId position nft identifier
    /// @param _value number of underlying tokens to be offered
    function afterUnderlyingOffer(
        address _caller,
        uint256 _tokenId,
        uint256 _value
    ) external;

    /// @notice Hook called by the bonds contract after a position holder
    /// offer in the contract is resigned.
    /// @dev Important checks are performed, only the token owner or an approved party
    /// is able to resign a previously created offer and bring back the leftover underlying.
    /// @dev It returns to the position the remaining underlying, tokens that haven't
    /// been sold as bonds.
    /// @param _caller address who initiated the call in the bonds contract
    /// @param _tokenId position nft identifier
    /// @param _value number of underlying tokens to be returned
    function afterOfferResignation(
        address _caller,
        uint256 _tokenId,
        uint256 _value
    ) external;

    /// @notice Asks for underlying tokens from the vault contract and distributes
    /// revenue.
    /// @dev Only the vault contract is able to trigger this function.
    /// @param _reward underlying reward to be distributed as revdis.
    function receiveVaultRewards(uint256 _reward) external;
}

File 10 of 31 : IBondsRegistry.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

import { Bond } from "../libraries/bonds/Bond.sol";
import { IOracle } from "./IOracle.sol";
import { IStakingRewards } from "./IStakingRewards.sol";

interface IBondsRegistry {
    /// @param discount registered discount to be applied
    /// @param lockDuration how long the underlying should be locked in the bond
    struct DiscountOption {
        uint128 discount;
        uint128 lockDuration;
    }

    /// @dev Underlying token offers from locked token holders
    /// @dev Offer id key is equal to the position token id
    function offers(uint256 _offerId)
        external
        view
        returns (
            uint128 balance,
            uint128 payout,
            uint256 payoutPerTokenApplied,
            uint256 debtPerTokenApplied
        );

    /// @dev ERC721 bonds minted representing an amount of locked underlying
    function bonds(uint256 _bondId) external view returns (uint128 payout, uint128 expiration);

    /// @dev Lock duration options mapped to applied underlying discounts (in BPS)
    function discountOptions(uint256 _lockDuration) external view returns (uint256);

    /// @notice Returns amount of purchase tokens accumulated for given offer.
    /// @param _offerId position offer nft id
    function payoutEarnedFor(uint256 _offerId) external view returns (uint256);

    /// @notice Returns the available balance for a given offer.
    /// @dev It takes into account the protocol's debt and applies how many underlying
    /// tokens must be removed from the offer's balance, according to current sales data.
    /// @param _offerId position offer nft id
    function availableBalanceFor(uint256 _offerId) external view returns (uint128);

    /// @notice Updates price oracle contract address.
    /// @param _oracle new oracle address
    function setOracle(IOracle _oracle) external;

    /// @notice Updates staking contract address.
    /// @param _staking new staking address
    function setStaking(IStakingRewards _staking) external;

    /// @notice Updates bond discount options available.
    /// @dev Owner is able to set discount tiers for different lock durations,
    /// where each duration returns a price discount in BPS.
    /// @param _discountOptions array with discounts and token lock duration in bonds
    function setDiscounts(DiscountOption[] calldata _discountOptions) external;

    /// @notice Updates ERC721 base URI value.
    /// @param _newBaseURI new base URI value
    function setBaseURI(string memory _newBaseURI) external;

    /// @notice Pauses critical functionality in the contract.
    /// @dev Can be called by the eDAO multisig in case the contract needs to be paused
    /// in an emergency and unpaused later.
    /// @param _shouldPause whether the contract needs to be paused/unpaused
    function setPauseState(bool _shouldPause) external;

    /// @notice Offer an amount of locked tokens in a vesting position to be sold
    /// for purchase tokens.
    /// @dev Important checks and state updates are executed in the vesting contract's context.
    /// @param _offerId position nft token id to be offered
    /// @param _value amount of locked tokens in the position to be offered
    function offer(uint256 _offerId, uint256 _value) external;

    /// @notice Resigns an amount of tokens available in an offer.
    /// @dev Resigned tokens in the offer are returned to the vesting contract.
    /// @dev Important checks and state updates are executed in the vesting contract's context.
    /// @param _offerId position offer nft id
    /// @param _value amount of locked tokens in the position to be removed
    function resign(uint256 _offerId, uint256 _value) external;

    /// @notice Purchases underlying tokens locked for a given duration with a discount.
    /// @dev Expects user to receive a bond with at least the amount of underlying tokens
    /// specified in the `_minUnderlyingOut` parameter.
    /// @dev A discount is applied to the price provided by the oracle contract, hence
    /// increasing the amount of underlying tokens acquired.
    /// @dev Every purchase accumulates a purchase payout for offers and a shared debt
    /// which needs to be applied in order to reduce an individual offer's balance in
    /// its next interaction. Global values are updated atomically.
    /// @param _value amount of purchase tokens provided
    /// @param _duration underlying lock duration (used to figure out discount)
    /// @param _minUnderlyingOut minimum amount of underlying tokens expected from the purchase
    /// @param _autostake whether the bond should be automatically staked in staking rewards contract
    function buy(
        uint256 _value,
        uint256 _duration,
        uint256 _minUnderlyingOut,
        bool _autostake
    ) external;

    /// @notice Claims payout in purchase tokens for a given offer.
    /// @dev Only approved caller or vesting position token owner is allowed to
    /// trigger the payout, which is always sent to the owner.
    /// @param _offerId position offer nft id
    function claimOfferPayout(uint256 _offerId) external;

    /// @notice Claims bond underlying tokens payout after expiration.
    /// @dev Only nft owner is able to trigger the payout and the bond must be expired.
    /// @param _bondId bond nft id
    function claimBondPayout(uint256 _bondId) external;
}

File 11 of 31 : Position.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

import { Constants } from "../Constants.sol";

library Position {
    /// @param balance total underlying balance
    /// @param unlocked underlying value already unlocked
    /// @param rate value unlocked per second, up to ~1.84e19 tokens per second
    /// @param start when position starts unlocking
    /// @param end when position unlocking ends
    /// @param pendingRevDis pending revenue distribution share to be claimed
    /// @param revDisPerTokenPaid last revDisPerToken applied to the position
    struct Data {
        uint128 balance;
        uint128 unlocked;
        uint64 start;
        uint64 end;
        uint128 rate;
        uint128 pendingRevDis;
        uint256 revDisPerTokenPaid;
    }

    /// @param balance total underlying balance
    /// @param start when position starts unlocking
    /// @param end when position unlocking ends
    struct InitParams {
        uint128 balance;
        uint64 start;
        uint64 end;
    }

    /// @dev Vesting schedule uses the position unlock rate to determine how much
    /// underlying has vested (and is able to be unlocked) instead of the balance.
    /// @dev Holders are able to move back and forward their positions balances
    /// to the Bonds contract without sacrificing how many tokens can be unlocked per second.
    function vestedUnderlying(Data storage _position) internal view returns (uint256) {
        if (block.timestamp <= _position.start) {
            return 0;
        } else if (block.timestamp < _position.end) {
            return ((block.timestamp - _position.start) * _position.rate) - _position.unlocked;
        } else {
            return _position.balance;
        }
    }

    /// @dev Calculates accumulated revenue distribution for given position using
    /// the latest values.
    function earnedRevDis(Data storage _position, uint256 _revDisPerToken) internal view returns (uint256) {
        return
            ((_position.balance * (_revDisPerToken - _position.revDisPerTokenPaid)) / Constants.BASE_MULTIPLIER) +
            _position.pendingRevDis;
    }
}

File 12 of 31 : Constants.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

library Constants {
    /// @dev Magic constant used for multiplications/divisions
    uint256 internal constant BASE_MULTIPLIER = 1e18;
    /// @dev ETH/USD price feed decimals value
    uint256 internal constant ETH_USD_DECIMALS = 1e8;
    /// @dev USDC token decimals value
    uint256 internal constant USDC_DECIMALS = 1e6;
    /// @dev Minimum underlying lock duration, set for extra security
    uint256 internal constant MINIMUM_LOCK_DURATION = 30 days;
    /// @dev Base value used for calculating prices after discount
    uint256 internal constant DISCOUNT_BASE = 10_000;
}

File 13 of 31 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

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

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

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

File 14 of 31 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}

File 15 of 31 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 16 of 31 : ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
        return
            interfaceId == type(IERC721Upgradeable).interfaceId ||
            interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

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

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

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

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

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

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

File 18 of 31 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

File 19 of 31 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 20 of 31 : IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 21 of 31 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 22 of 31 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

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

File 23 of 31 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

File 25 of 31 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

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

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

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

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

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

pragma solidity ^0.8.0;

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

File 27 of 31 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

File 28 of 31 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 29 of 31 : Bond.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

import { Constants } from "../Constants.sol";

library Bond {
    /// @param payout unlocked underlying tokens that will be received upon expiration
    /// @param expiresAt Timestamp of when the bond expires and is able to unlock the payout
    struct Data {
        uint128 payout;
        uint128 expiresAt;
    }

    struct Stake {
        uint128 balance;
        uint128 pendingYield;
        uint256 pendingRevDis;
        uint256 yieldPerTokenPaid;
        uint256 revDisPerTokenPaid;
    }

    /// @dev Calculates accumulated revenue distribution for given staked bond using
    /// the latest values.
    function earnedRevDis(Stake storage _stakedBond, uint256 _revDisPerToken) internal view returns (uint256) {
        return
            ((_stakedBond.balance * (_revDisPerToken - _stakedBond.revDisPerTokenPaid)) / Constants.BASE_MULTIPLIER) +
            _stakedBond.pendingRevDis;
    }

    /// @dev Calculates accumulated yield for given staked bond using
    /// the latest values.
    function earnedYield(Stake storage _stakedBond, uint256 _yieldPerToken) internal view returns (uint256) {
        return
            ((_stakedBond.balance * (_yieldPerToken - _stakedBond.yieldPerTokenPaid)) / Constants.BASE_MULTIPLIER) +
            _stakedBond.pendingYield;
    }
}

File 30 of 31 : IOracle.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

interface IOracle {
    /// @notice Returns the underlying price in purchase tokens.
    /// @dev Gets data from a Chainlink aggregator.
    function quote() external view returns (uint256);

    /// @notice Converts purchase token in value to the number of underlying out
    /// with a discount applied.
    function purchaseTokenToUnderlying(uint256 _purchaseTokenIn, uint256 _discount) external view returns (uint256);
}

File 31 of 31 : IStakingRewards.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.11;

interface IStakingRewards {
    /// @dev List of bond nfts staked by address and token id
    function stakedBonds(address _holder, uint256 _bondId)
        external
        view
        returns (
            uint128 balance,
            uint128 pendingYield,
            uint256 pendingRevDis,
            uint256 yieldPerTokenPaid,
            uint256 revDisPerTokenPaid
        );

    /// @notice Returns ILV staking rewards pool token.
    /// @dev Standard value queried by Staking V2 Pool Factory when
    /// registering a new staking pool.
    function poolToken() external view returns (address);

    /// @notice Tells the Pool Factory that this isn't a
    /// flash pool contract.
    /// @dev Standard value queried by Staking V2 Pool Factory when
    /// registering a new pool.
    function isFlashPool() external pure returns (bool);

    /// @notice Returns latest timestamp to be applied for yield calculations.
    /// @dev If staking v2 has ended, it returns the ending timestamp.
    /// @dev It's required to check if lastTimeYieldApplicable() < lastYieldDistribution
    /// when updating state, so the contract knows if yield rewards have started or not.
    function lastTimeYieldApplicable() external view returns (uint256);

    /// @notice Returns pending yield rewards for a given staked bond.
    function pendingYieldFor(address _who, uint256 _tokenId) external view returns (uint256);

    /// @notice Returns pending revenue distribution for a given staked bond.
    /// @param _who address owning the staked bond
    /// @param _tokenId bond nft identifier
    function pendingRevDisFor(address _who, uint256 _tokenId) external view returns (uint256);

    /// @notice Returns latest yield per token value.
    /// @dev If there isn't any ILV underlying supplied to the contract, or yield
    /// rewards haven't started we just return current stored value.
    /// @dev Yield per token value is calculating by checking how many seconds have passed
    /// since last distribution, checks how much ilv per second the contract is receiving
    /// from staking v2, by using {factory.ilvPerSecond} and {factory.totalWeight} and checking
    /// against this contract's weight and finally dividing by the total amount of ILV tokens
    /// represented.
    function yieldPerToken() external view returns (uint256);

    /// @notice Returns the underlying supplied value.
    /// @dev Value used by Illuvium's Vault contract to calculate revenue
    /// distributions.
    function poolTokenReserve() external view returns (uint256);

    /// @notice Called by staking v2 pool factory, updates the contract rewards
    /// allocation weight.
    /// @param _weight new pool weight to be set
    function setWeight(uint32 _weight) external;

    /// @notice Pauses critical functionality in the contract.
    /// @dev Can be called by the eDAO multisig in case the contract needs to be paused
    /// in an emergency and unpaused later.
    /// @param _shouldPause whether the contract needs to be paused/unpaused
    function setPauseState(bool _shouldPause) external;

    /// @notice Updates Vault contract address stored.
    /// @dev Can only be called by the owner (eDAO multisig)
    /// @param _vault Vault contract address
    function setVaultContract(address _vault) external;

    /// @notice Stakes a bond of given token id for yield and revenue distributions.
    /// @dev Bonds without pending payout (i.e pending locked tokens to be claimed) must not be staked.
    /// This should never happen but we assert just to make sure.
    /// @dev Update reward modifier must be included every time we mutate a Bond.Stake.
    /// @param _tokenId bond nft identifier
    function stake(uint256 _tokenId) external;

    /// @notice Automatically stakes a bond from the bonds registry when purchasing.
    /// @dev Only the bonds registry contract can call this function when the auto stake flag
    /// is set to true when buying locked ILV tokens (and minting a non fungible bond).
    function stake(address _tokenOwner, uint256 _tokenId) external;

    /// @notice Unstakes a bond of given token id and auto claims rewards in ILV or sILV2.
    /// @dev We auto claim pending rewards so we can delete the whole Bond.Stake before
    /// transferring back the ERC721 token.
    /// @param _tokenId staked bond nft identifier
    /// @param _useSILV whether yield should be claimed in ILV or sILV2
    function unstake(uint256 _tokenId, bool _useSILV) external;

    /// @notice Claim pending yield rewards in ILV or sILV.
    /// @param _tokenId staked bond nft identifier
    /// @param _useSILV whether yield should be claimed in ILV or sILV2
    function claimRewards(uint256 _tokenId, bool _useSILV) external;

    /// @notice Asks for underlying tokens from the vault contract and distributes
    /// revenue.
    /// @dev Only the vault contract is able to trigger this function.
    /// @param _reward underlying reward to be distributed as revdis.
    function receiveVaultRewards(uint256 _reward) external;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"LogClaimRevenueDistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"LogReceiveVaultRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"oldBaseURI","type":"string"},{"indexed":false,"internalType":"string","name":"newBaseURI","type":"string"}],"name":"LogSetBaseURI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldBonds","type":"address"},{"indexed":false,"internalType":"address","name":"newBonds","type":"address"}],"name":"LogSetBonds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"holders","type":"address[]"},{"components":[{"internalType":"uint128","name":"balance","type":"uint128"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"}],"indexed":false,"internalType":"struct Position.InitParams[]","name":"_positions","type":"tuple[]"},{"indexed":false,"internalType":"uint256","name":"totalUnderlying","type":"uint256"}],"name":"LogSetPositions","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"shouldAllow","type":"bool"}],"name":"LogSetTransferState","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldVault","type":"address"},{"indexed":false,"internalType":"address","name":"newVault","type":"address"}],"name":"LogSetVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"LogUnlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"address","name":"_caller","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"afterOfferResignation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_caller","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"afterUnderlyingOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"availableUnderlyingFor","outputs":[{"internalType":"uint256","name":"availableUnderlying","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bondsRegistry","outputs":[{"internalType":"contract IBondsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"claimRevenueDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"contract IERC20Upgradeable","name":"_underlying","type":"address"},{"internalType":"address","name":"_vault","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"isApprovedOrOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTransferAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"pendingRevDisFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolTokenReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"positions","outputs":[{"internalType":"uint128","name":"balance","type":"uint128"},{"internalType":"uint128","name":"unlocked","type":"uint128"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"},{"internalType":"uint128","name":"rate","type":"uint128"},{"internalType":"uint128","name":"pendingRevDis","type":"uint128"},{"internalType":"uint256","name":"revDisPerTokenPaid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_reward","type":"uint256"}],"name":"receiveVaultRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revDisPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IBondsRegistry","name":"_bondsRegistry","type":"address"}],"name":"setBondsContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldPause","type":"bool"}],"name":"setPauseState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_holders","type":"address[]"},{"components":[{"internalType":"uint128","name":"balance","type":"uint128"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"}],"internalType":"struct Position.InitParams[]","name":"_positions","type":"tuple[]"}],"name":"setPositions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldAllow","type":"bool"}],"name":"setTransferState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"}],"name":"setVaultContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenIdTracker","outputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlyingSupplied","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"vestedUnderlyingFor","outputs":[{"internalType":"uint256","name":"vestedUnderlying","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a0604052306080523480156200001557600080fd5b506200002062000026565b62000156565b6200003260ff62000035565b50565b60008054610100900460ff1615620000ce578160ff1660011480156200006e57506200006c306200014760201b620029b81760201c565b155b620000c65760405162461bcd60e51b815260206004820152602e602482015260008051602062004f8183398151915260448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b506000919050565b60005460ff8084169116106200012d5760405162461bcd60e51b815260206004820152602e602482015260008051602062004f8183398151915260448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401620000bd565b506000805460ff191660ff92909216919091179055600190565b6001600160a01b03163b151590565b608051614df36200018e600039600081816113fe0152818161148301528181611a3901528181611abe0152611c4c0152614df36000f3fe6080604052600436106103125760003560e01c80636352211e1161019a578063a22cb465116100e1578063cdb88ad11161008a578063e985e9c511610064578063e985e9c51461093c578063f2fde38b14610985578063fbfa77cf146109a557600080fd5b8063cdb88ad1146108e6578063ce11154114610906578063e2bdc5141461091c57600080fd5b8063b88d4fde116100bb578063b88d4fde1461088b578063c87b56dd146108ab578063cd8c063b146108cb57600080fd5b8063a22cb4651461082b578063a27cbb421461084b578063a4669efa1461086b57600080fd5b80638f15b4141161014357806395d89b411161011d57806395d89b411461072857806396f4ada61461073d57806399fbab881461075d57600080fd5b80638f15b414146106c757806392c1ee40146106e757806393fbb3f61461070857600080fd5b806370a082311161017457806370a0823114610673578063715018a6146106935780638da5cb5b146106a857600080fd5b80636352211e1461061b57806363f6c7a71461063b5780636f307dc31461065257600080fd5b806336a595291161025e5780634f1ef2861161020757806355f804b3116101e157806355f804b3146105c25780635c975abb146105e25780636198e339146105fb57600080fd5b80634f1ef2861461057a5780634f6ccce71461058d57806352d1902d146105ad57600080fd5b806342842e0e1161023857806342842e0e1461051a57806342b931e31461053a578063430c20811461055a57600080fd5b806336a59529146104c357806336fd986a146104da5780633ecb51c0146104fa57600080fd5b806318160ddd116102c05780633021a5601161029a5780633021a5601461046357806330d8b5cd146104835780633659cfe6146104a357600080fd5b806318160ddd1461040e57806323b872dd146104235780632f745c591461044357600080fd5b806306fdde03116102f157806306fdde0314610394578063081812fc146103b6578063095ea7b3146103ee57600080fd5b80623232f61461031757806301ffc9a71461033957806302bf3d561461036e575b600080fd5b34801561032357600080fd5b50610337610332366004614421565b6109c6565b005b34801561034557600080fd5b506103596103543660046144ff565b610eb4565b60405190151581526020015b60405180910390f35b34801561037a57600080fd5b50610194546103869081565b604051908152602001610365565b3480156103a057600080fd5b506103a9610edf565b6040516103659190614574565b3480156103c257600080fd5b506103d66103d1366004614587565b610f71565b6040516001600160a01b039091168152602001610365565b3480156103fa57600080fd5b506103376104093660046145b5565b611006565b34801561041a57600080fd5b5060fd54610386565b34801561042f57600080fd5b5061033761043e3660046145e1565b61111c565b34801561044f57600080fd5b5061038661045e3660046145b5565b6111a3565b34801561046f57600080fd5b5061033761047e366004614587565b61124b565b34801561048f57600080fd5b5061038661049e366004614587565b6113d4565b3480156104af57600080fd5b506103376104be366004614622565b6113f3565b3480156104cf57600080fd5b506103866101965481565b3480156104e657600080fd5b506103376104f536600461463f565b61156f565b34801561050657600080fd5b50610337610515366004614682565b61177d565b34801561052657600080fd5b506103376105353660046145e1565b61180f565b34801561054657600080fd5b5061033761055536600461463f565b61182a565b34801561056657600080fd5b506103596105753660046145b5565b611a1b565b610337610588366004614742565b611a2e565b34801561059957600080fd5b506103866105a8366004614587565b611b9b565b3480156105b957600080fd5b50610386611c3f565b3480156105ce57600080fd5b506103376105dd366004614792565b611d04565b3480156105ee57600080fd5b5061015f5460ff16610359565b34801561060757600080fd5b50610337610616366004614587565b611d9c565b34801561062757600080fd5b506103d6610636366004614587565b612001565b34801561064757600080fd5b506103866101955481565b34801561065e57600080fd5b50610191546103d6906001600160a01b031681565b34801561067f57600080fd5b5061038661068e366004614622565b61208c565b34801561069f57600080fd5b50610337612126565b3480156106b457600080fd5b5061012d546001600160a01b03166103d6565b3480156106d357600080fd5b506103376106e23660046147c7565b61217b565b3480156106f357600080fd5b50610193546103d6906001600160a01b031681565b34801561071457600080fd5b50610386610723366004614587565b6122c0565b34801561073457600080fd5b506103a96122d8565b34801561074957600080fd5b50610337610758366004614622565b6122e7565b34801561076957600080fd5b506107db610778366004614587565b6101996020526000908152604090208054600182015460028301546003909301546001600160801b0380841694600160801b9485900482169467ffffffffffffffff80861695680100000000000000008104909116949190048316929091169087565b604080516001600160801b039889168152968816602088015267ffffffffffffffff9586169087015292909316606085015284166080840152921660a082015260c081019190915260e001610365565b34801561083757600080fd5b50610337610846366004614850565b6123f1565b34801561085757600080fd5b50610337610866366004614587565b6123fc565b34801561087757600080fd5b50610337610886366004614622565b6125be565b34801561089757600080fd5b506103376108a6366004614889565b6126c8565b3480156108b757600080fd5b506103a96108c6366004614587565b612756565b3480156108d757600080fd5b50610197546103599060ff1681565b3480156108f257600080fd5b50610337610901366004614682565b61283e565b34801561091257600080fd5b5061019654610386565b34801561092857600080fd5b50610386610937366004614587565b61289d565b34801561094857600080fd5b506103596109573660046148f5565b6001600160a01b03918216600090815260ce6020908152604080832093909416825291909152205460ff1690565b34801561099157600080fd5b506103376109a0366004614622565b6128ea565b3480156109b157600080fd5b50610192546103d6906001600160a01b031681565b61012d546001600160a01b03163314610a145760405162461bcd60e51b81526020600482018190526024820152600080516020614da083398151915260448201526064015b60405180910390fd5b828114610a635760405162461bcd60e51b815260206004820152601560248201527f6172726179206c656e677468206d69736d6174636800000000000000000000006044820152606401610a0b565b6000805b84811015610e5457838382818110610a8157610a81614923565b9050606002016020016020810190610a999190614951565b67ffffffffffffffff16848483818110610ab557610ab5614923565b9050606002016040016020810190610acd9190614951565b67ffffffffffffffff16118015610b1757506000848483818110610af357610af3614923565b9050606002016020016020810190610b0b9190614951565b67ffffffffffffffff16115b8015610b5357506000848483818110610b3257610b32614923565b610b489260206060909202019081019150614983565b6001600160801b0316115b610b9f5760405162461bcd60e51b815260206004820152601660248201527f696e76616c696420706f736974696f6e20696e707574000000000000000000006044820152606401610a0b565b838382818110610bb157610bb1614923565b610bc79260206060909202019081019150614983565b610bda906001600160801b0316836149b4565b9150610beb61019480546001019055565b6000610bf76101945490565b9050610c29878784818110610c0e57610c0e614923565b9050602002016020810190610c239190614622565b826129c7565b60006040518060e00160405280878786818110610c4857610c48614923565b610c5e9260206060909202019081019150614983565b6001600160801b0316815260006020820152604001878786818110610c8557610c85614923565b9050606002016020016020810190610c9d9190614951565b67ffffffffffffffff168152602001878786818110610cbe57610cbe614923565b9050606002016040016020810190610cd69190614951565b67ffffffffffffffff168152602001610d90888887818110610cfa57610cfa614923565b9050606002016020016020810190610d129190614951565b898988818110610d2457610d24614923565b9050606002016040016020810190610d3c9190614951565b610d4691906149cc565b67ffffffffffffffff16898988818110610d6257610d62614923565b610d789260206060909202019081019150614983565b610d829190614a0b565b6001600160801b0316612b15565b6001600160801b03908116825260006020808401829052610195546040948501529581526101998652829020835195840151958216600160801b9683168702178155918301516001830180546060860151608087015167ffffffffffffffff9485166001600160801b03199384161768010000000000000000959092169490940217841692841690970291909117905560a083015160028301805490961691161790935560c001516003909201919091555080610e4c81614a31565b915050610a67565b50806101966000828254610e6891906149b4565b90915550506040517fdf01283be3b53c10dd5865c887a9218504d01cfe718eb87444d763aad8132d9590610ea59087908790879087908790614a4c565b60405180910390a15050505050565b60006001600160e01b0319821663780e9d6360e01b1480610ed95750610ed982612b98565b92915050565b606060c98054610eee90614b21565b80601f0160208091040260200160405190810160405280929190818152602001828054610f1a90614b21565b8015610f675780601f10610f3c57610100808354040283529160200191610f67565b820191906000526020600020905b815481529060010190602001808311610f4a57829003601f168201915b5050505050905090565b600081815260cb60205260408120546001600160a01b0316610fea5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a0b565b50600090815260cd60205260409020546001600160a01b031690565b600061101182612001565b9050806001600160a01b0316836001600160a01b0316141561107f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a0b565b336001600160a01b038216148061109b575061109b8133610957565b61110d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a0b565b6111178383612be8565b505050565b6111263382612c56565b6111985760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610a0b565b611117838383612d4c565b60006111ae8361208c565b82106112225760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610a0b565b506001600160a01b0391909116600090815260fb60209081526040808320938352929052205490565b61015f5460ff16156112925760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b610192546001600160a01b031633146112ed5760405162461bcd60e51b815260206004820152601260248201527f6f6e6c79207661756c7420616c6c6f77656400000000000000000000000000006044820152606401610a0b565b6000610196541180156113005750600081115b61134c5760405162461bcd60e51b815260206004820152601660248201527f696e76616c6964207374617465206f7220696e707574000000000000000000006044820152606401610a0b565b61019654611362670de0b6b3a764000083614b5c565b61136c9190614b7b565b610195600082825461137e91906149b4565b90915550506101915461139c906001600160a01b0316333084612f0b565b60405181815233907f55fd0bec59e0b2fdf9406c9890f568c6ec6f92c752012ef7e3ebaee44d4d6cad9060200160405180910390a250565b610195546000828152610199602052604081209091610ed99190612f8b565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156114815760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610a0b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166114dc7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146115475760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610a0b565b61155081612fdf565b6040805160008082526020820190925261156c91839190613028565b50565b61015f5460ff16156115b65760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b610193546001600160a01b031633146116115760405162461bcd60e51b815260206004820152601b60248201527f6f6e6c7920626f6e647320726567697374727920616c6c6f77656400000000006044820152606401610a0b565b828261161d8282612c56565b61165b5760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b6000848152610199602052604090206101955485919061168590611680908390612f8b565b612b15565b6002820180546001600160801b0319166001600160801b0392909216919091179055610195546003820155846116ef5760405162461bcd60e51b815260206004820152600f60248201526e7a65726f20756e6465726c79696e6760881b6044820152606401610a0b565b6116f885612b15565b60008781526101996020526040812080549091906117209084906001600160801b0316614b8f565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508461019660008282546117579190614baf565b909155505061019154611774906001600160a01b031633876131c8565b50505050505050565b61012d546001600160a01b031633146117c65760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b60405181151581527f6626a495c12d20fcd56323beda487784c2f149273f33aa1e5e91503f5beaeaec9060200160405180910390a1610197805460ff1916911515919091179055565b611117838383604051806020016040528060008152506126c8565b61015f5460ff16156118715760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b610193546001600160a01b031633146118cc5760405162461bcd60e51b815260206004820152601b60248201527f6f6e6c7920626f6e647320726567697374727920616c6c6f77656400000000006044820152606401610a0b565b82826118d88282612c56565b6119165760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b6000848152610199602052604090206101955485919061193b90611680908390612f8b565b6002820180546001600160801b0319166001600160801b0392909216919091179055610195546003820155846119a55760405162461bcd60e51b815260206004820152600f60248201526e7a65726f20756e6465726c79696e6760881b6044820152606401610a0b565b6119ae85612b15565b60008781526101996020526040812080549091906119d69084906001600160801b0316614bc6565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550846101966000828254611a0d91906149b4565b909155505050505050505050565b6000611a278383612c56565b9392505050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415611abc5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610a0b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611b177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614611b825760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610a0b565b611b8b82612fdf565b611b9782826001613028565b5050565b6000611ba660fd5490565b8210611c1a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610a0b565b60fd8281548110611c2d57611c2d614923565b90600052602060002001549050919050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611cdf5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610a0b565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b61012d546001600160a01b03163314611d4d5760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b7f1207a63f0a002f772f8bd43fa2e5939a59bd400c5a9d635a6700462ad3ca7a8e61019882604051611d80929190614bf1565b60405180910390a18051611b9790610198906020840190614391565b61015f5460ff1615611de35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b3381611def8282612c56565b611e2d5760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b60008381526101996020526040902061019554849190611e5290611680908390612f8b565b6002820180546001600160801b0319166001600160801b03929092169190911790556101955460038201556000611e8886612001565b600087815261019960205260408120919250611ea38861289d565b905060008111611ef55760405162461bcd60e51b815260206004820152601460248201527f7a65726f2076616c756520746f20756e6c6f636b0000000000000000000000006044820152606401610a0b565b611efe81612b15565b82548390600090611f199084906001600160801b0316614b8f565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550611f4681612b15565b82548390601090611f68908490600160801b90046001600160801b0316614bc6565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550600061019654905080821115611fa0578091505b8181036101965561019154611fbf906001600160a01b031685846131c8565b604051828152899033907f59b8f181b35d2091471227c68eb856ad709d72c40b9ad5f46e140d970b28ebf79060200160405180910390a3505050505050505050565b600081815260cb60205260408120546001600160a01b031680610ed95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610a0b565b60006001600160a01b03821661210a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610a0b565b506001600160a01b0316600090815260cc602052604090205490565b61012d546001600160a01b0316331461216f5760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b61217960006131f8565b565b6000612187600161324b565b9050801561219f576000805461ff0019166101001790555b8451158015906121af5750835115155b80156121c357506001600160a01b03831615155b80156121d757506001600160a01b03821615155b6122235760405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420696e707574730000000000000000000000000000000000006044820152606401610a0b565b61019180546001600160a01b038086166001600160a01b03199283161790925561019280549285169290911691909117905561225d613366565b61226785856133d1565b61226f613446565b6122776134b9565b80156122b9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610ea5565b5050505050565b600081815261019960205260408120610ed99061352c565b606060ca8054610eee90614b21565b61012d546001600160a01b031633146123305760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b6001600160a01b0381166123865760405162461bcd60e51b815260206004820152600e60248201527f696e76616c6964205f7661756c740000000000000000000000000000000000006044820152606401610a0b565b61019254604080516001600160a01b03928316815291831660208301527f9364e08f31e8053a800c27bdd7dc0a677bd6ec519e22cbcfafeb749a28d68907910160405180910390a161019280546001600160a01b0319166001600160a01b0392909216919091179055565b611b973383836135c3565b61015f5460ff16156124435760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b338161244f8282612c56565b61248d5760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b600083815261019960205260409020610195548491906124b290611680908390612f8b565b6002820180546001600160801b0319166001600160801b039290921691909117905561019554600382015560006124e886612001565b6000878152610199602052604090206002810180546001600160801b03198116909155919250906001600160801b0316806125655760405162461bcd60e51b815260206004820152601060248201527f302070656e64696e6720726576646973000000000000000000000000000000006044820152606401610a0b565b6101915461257d906001600160a01b031684836131c8565b604051818152889033907f73a7e592630f3a5ec42d849cf32016157e87cdb4889a2b1f52ca8f89a24e64959060200160405180910390a35050505050505050565b61012d546001600160a01b031633146126075760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b6001600160a01b03811661265d5760405162461bcd60e51b815260206004820152601660248201527f696e76616c6964205f626f6e64735265676973747279000000000000000000006044820152606401610a0b565b61019354604080516001600160a01b03928316815291831660208301527fce91615be49fced4227941935cd56339df453f049b8924214fd14e50f760b71a910160405180910390a161019380546001600160a01b0319166001600160a01b0392909216919091179055565b6126d23383612c56565b6127445760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610a0b565b61275084848484613692565b50505050565b600081815260cb60205260409020546060906001600160a01b03166127e35760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610a0b565b60006127ed61371b565b9050600081511161280d5760405180602001604052806000815250611a27565b806128178461372b565b604051602001612828929190614ca4565b6040516020818303038152906040529392505050565b61012d546001600160a01b031633146128875760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b80156128955761156c613841565b61156c6138db565b60008181526101996020526040812081906128b79061352c565b600084815261019960205260409020549091506001600160801b03168082116128e057816128e2565b805b949350505050565b61012d546001600160a01b031633146129335760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b6001600160a01b0381166129af5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610a0b565b61156c816131f8565b6001600160a01b03163b151590565b6001600160a01b038216612a1d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a0b565b600081815260cb60205260409020546001600160a01b031615612a825760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a0b565b612a8e60008383613960565b6001600160a01b038216600090815260cc60205260408120805460019290612ab79084906149b4565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160801b03821115612b945760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610a0b565b5090565b60006001600160e01b031982166380ac58cd60e01b1480612bc957506001600160e01b03198216635b5e139f60e01b145b80610ed957506301ffc9a760e01b6001600160e01b0319831614610ed9565b600081815260cd6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612c1d82612001565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081815260cb60205260408120546001600160a01b0316612ccf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a0b565b6000612cda83612001565b9050806001600160a01b0316846001600160a01b03161480612d2157506001600160a01b03808216600090815260ce602090815260408083209388168352929052205460ff165b806128e25750836001600160a01b0316612d3a84610f71565b6001600160a01b031614949350505050565b826001600160a01b0316612d5f82612001565b6001600160a01b031614612ddb5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610a0b565b6001600160a01b038216612e3d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a0b565b612e48838383613960565b612e53600082612be8565b6001600160a01b038316600090815260cc60205260408120805460019290612e7c908490614baf565b90915550506001600160a01b038216600090815260cc60205260408120805460019290612eaa9084906149b4565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6040516001600160a01b03808516602483015283166044820152606481018290526127509085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526139d4565b600282015460038301546000916001600160801b031690670de0b6b3a764000090612fb69085614baf565b8554612fcb91906001600160801b0316614b5c565b612fd59190614b7b565b611a2791906149b4565b61012d546001600160a01b0316331461156c5760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561305b5761111783613ab9565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156130b5575060408051601f3d908101601f191682019092526130b291810190614cca565b60015b6131275760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610a0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146131bc5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610a0b565b50611117838383613b77565b6040516001600160a01b03831660248201526044810182905261111790849063a9059cbb60e01b90606401612f3f565b61012d80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008054610100900460ff16156132d9578160ff16600114801561326e5750303b155b6132d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a0b565b506000919050565b60005460ff8084169116106133475760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a0b565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166121795760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b600054610100900460ff1661343c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b611b978282613b9c565b600054610100900460ff166134b15760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b612179613c2e565b600054610100900460ff166135245760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b612179613ca2565b600181015460009067ffffffffffffffff16421161354c57506000919050565b600182015468010000000000000000900467ffffffffffffffff164210156135b557815460018301546001600160801b03600160801b92839004811692820416906135a19067ffffffffffffffff1642614baf565b6135ab9190614b5c565b610ed99190614baf565b50546001600160801b031690565b816001600160a01b0316836001600160a01b031614156136255760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a0b565b6001600160a01b03838116600081815260ce6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61369d848484612d4c565b6136a984848484613d1a565b6127505760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a0b565b60606101988054610eee90614b21565b60608161374f5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613779578061376381614a31565b91506137729050600a83614b7b565b9150613753565b60008167ffffffffffffffff8111156137945761379461469f565b6040519080825280601f01601f1916602001820160405280156137be576020820181803683370190505b5090505b84156128e2576137d3600183614baf565b91506137e0600a86614ce3565b6137eb9060306149b4565b60f81b81838151811061380057613800614923565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061383a600a86614b7b565b94506137c2565b61015f5460ff16156138885760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b61015f805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586138be3390565b6040516001600160a01b03909116815260200160405180910390a1565b61015f5460ff1661392e5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610a0b565b61015f805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336138be565b61396b838383613e6e565b61012d546001600160a01b031633148061398857506101975460ff165b6111175760405162461bcd60e51b815260206004820152601c60248201527f455243373231207472616e7366657273206e6f7420616c6c6f776564000000006044820152606401610a0b565b6000613a29826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613f269092919063ffffffff16565b8051909150156111175780806020019051810190613a479190614cf7565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a0b565b6001600160a01b0381163b613b365760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610a0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b613b8083613f35565b600082511180613b8d5750805b15611117576127508383613f75565b600054610100900460ff16613c075760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b8151613c1a9060c9906020850190614391565b5080516111179060ca906020840190614391565b600054610100900460ff16613c995760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b612179336131f8565b600054610100900460ff16613d0d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b61015f805460ff19169055565b60006001600160a01b0384163b15613e6357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613d5e903390899088908890600401614d14565b6020604051808303816000875af1925050508015613d99575060408051601f3d908101601f19168201909252613d9691810190614d50565b60015b613e49573d808015613dc7576040519150601f19603f3d011682016040523d82523d6000602084013e613dcc565b606091505b508051613e415760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a0b565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506128e2565b506001949350505050565b6001600160a01b038316613ec957613ec48160fd8054600083815260fe60205260408120829055600182018355919091527f9346ac6dd7de6b96975fec380d4d994c4c12e6a8897544f22915316cc6cca2800155565b613eec565b816001600160a01b0316836001600160a01b031614613eec57613eec8382614080565b6001600160a01b038216613f03576111178161411d565b826001600160a01b0316826001600160a01b0316146111175761111782826141cc565b60606128e28484600085614210565b613f3e81613ab9565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b613ff45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610a0b565b600080846001600160a01b03168460405161400f9190614d6d565b600060405180830381855af49150503d806000811461404a576040519150601f19603f3d011682016040523d82523d6000602084013e61404f565b606091505b50915091506140778282604051806060016040528060278152602001614dc060279139614358565b95945050505050565b6000600161408d8461208c565b6140979190614baf565b600083815260fc60205260409020549091508082146140ea576001600160a01b038416600090815260fb60209081526040808320858452825280832054848452818420819055835260fc90915290208190555b50600091825260fc602090815260408084208490556001600160a01b03909416835260fb81528383209183525290812055565b60fd5460009061412f90600190614baf565b600083815260fe602052604081205460fd805493945090928490811061415757614157614923565b906000526020600020015490508060fd838154811061417857614178614923565b600091825260208083209091019290925582815260fe909152604080822084905585825281205560fd8054806141b0576141b0614d89565b6001900381819060005260206000200160009055905550505050565b60006141d78361208c565b6001600160a01b03909316600090815260fb60209081526040808320868452825280832085905593825260fc9052919091209190915550565b6060824710156142885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a0b565b6001600160a01b0385163b6142df5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a0b565b600080866001600160a01b031685876040516142fb9190614d6d565b60006040518083038185875af1925050503d8060008114614338576040519150601f19603f3d011682016040523d82523d6000602084013e61433d565b606091505b509150915061434d828286614358565b979650505050505050565b60608315614367575081611a27565b8251156143775782518084602001fd5b8160405162461bcd60e51b8152600401610a0b9190614574565b82805461439d90614b21565b90600052602060002090601f0160209004810192826143bf5760008555614405565b82601f106143d857805160ff1916838001178555614405565b82800160010185558215614405579182015b828111156144055782518255916020019190600101906143ea565b50612b949291505b80821115612b94576000815560010161440d565b6000806000806040858703121561443757600080fd5b843567ffffffffffffffff8082111561444f57600080fd5b818701915087601f83011261446357600080fd5b81358181111561447257600080fd5b8860208260051b850101111561448757600080fd5b6020928301965094509086013590808211156144a257600080fd5b818701915087601f8301126144b657600080fd5b8135818111156144c557600080fd5b8860206060830285010111156144da57600080fd5b95989497505060200194505050565b6001600160e01b03198116811461156c57600080fd5b60006020828403121561451157600080fd5b8135611a27816144e9565b60005b8381101561453757818101518382015260200161451f565b838111156127505750506000910152565b6000815180845261456081602086016020860161451c565b601f01601f19169290920160200192915050565b602081526000611a276020830184614548565b60006020828403121561459957600080fd5b5035919050565b6001600160a01b038116811461156c57600080fd5b600080604083850312156145c857600080fd5b82356145d3816145a0565b946020939093013593505050565b6000806000606084860312156145f657600080fd5b8335614601816145a0565b92506020840135614611816145a0565b929592945050506040919091013590565b60006020828403121561463457600080fd5b8135611a27816145a0565b60008060006060848603121561465457600080fd5b833561465f816145a0565b95602085013595506040909401359392505050565b801515811461156c57600080fd5b60006020828403121561469457600080fd5b8135611a2781614674565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126146c657600080fd5b813567ffffffffffffffff808211156146e1576146e161469f565b604051601f8301601f19908116603f011681019082821181831017156147095761470961469f565b8160405283815286602085880101111561472257600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561475557600080fd5b8235614760816145a0565b9150602083013567ffffffffffffffff81111561477c57600080fd5b614788858286016146b5565b9150509250929050565b6000602082840312156147a457600080fd5b813567ffffffffffffffff8111156147bb57600080fd5b6128e2848285016146b5565b600080600080608085870312156147dd57600080fd5b843567ffffffffffffffff808211156147f557600080fd5b614801888389016146b5565b9550602087013591508082111561481757600080fd5b50614824878288016146b5565b9350506040850135614835816145a0565b91506060850135614845816145a0565b939692955090935050565b6000806040838503121561486357600080fd5b823561486e816145a0565b9150602083013561487e81614674565b809150509250929050565b6000806000806080858703121561489f57600080fd5b84356148aa816145a0565b935060208501356148ba816145a0565b925060408501359150606085013567ffffffffffffffff8111156148dd57600080fd5b6148e9878288016146b5565b91505092959194509250565b6000806040838503121561490857600080fd5b8235614913816145a0565b9150602083013561487e816145a0565b634e487b7160e01b600052603260045260246000fd5b803567ffffffffffffffff8116811461336157600080fd5b60006020828403121561496357600080fd5b611a2782614939565b80356001600160801b038116811461336157600080fd5b60006020828403121561499557600080fd5b611a278261496c565b634e487b7160e01b600052601160045260246000fd5b600082198211156149c7576149c761499e565b500190565b600067ffffffffffffffff838116908316818110156149ed576149ed61499e565b039392505050565b634e487b7160e01b600052601260045260246000fd5b60006001600160801b0380841680614a2557614a256149f5565b92169190910492915050565b6000600019821415614a4557614a4561499e565b5060010190565b60608082528181018690526000908760808401835b89811015614a91578235614a74816145a0565b6001600160a01b0316825260209283019290910190600101614a61565b5084810360208681019190915287825291508790820160005b88811015614b09576001600160801b03614ac38461496c565b168252614ad1848401614939565b67ffffffffffffffff9081168386015260409080614af0868401614939565b1691840191909152509184019190840190600101614aaa565b50809450505050508260408301529695505050505050565b600181811c90821680614b3557607f821691505b60208210811415614b5657634e487b7160e01b600052602260045260246000fd5b50919050565b6000816000190483118215151615614b7657614b7661499e565b500290565b600082614b8a57614b8a6149f5565b500490565b60006001600160801b03838116908316818110156149ed576149ed61499e565b600082821015614bc157614bc161499e565b500390565b60006001600160801b03808316818516808303821115614be857614be861499e565b01949350505050565b60408152600080845481600182811c915080831680614c1157607f831692505b6020808410821415614c3157634e487b7160e01b86526022600452602486fd5b6040880184905260608801828015614c505760018114614c6157614c8c565b60ff19871682528282019750614c8c565b60008c81526020902060005b87811015614c8657815484820152908601908401614c6d565b83019850505b50508786038189015250505050506140778185614548565b60008351614cb681846020880161451c565b835190830190614be881836020880161451c565b600060208284031215614cdc57600080fd5b5051919050565b600082614cf257614cf26149f5565b500690565b600060208284031215614d0957600080fd5b8151611a2781614674565b60006001600160a01b03808716835280861660208401525083604083015260806060830152614d466080830184614548565b9695505050505050565b600060208284031215614d6257600080fd5b8151611a27816144e9565b60008251614d7f81846020870161451c565b9190910192915050565b634e487b7160e01b600052603160045260246000fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c634300080b000a496e697469616c697a61626c653a20636f6e747261637420697320616c726561

Deployed Bytecode

0x6080604052600436106103125760003560e01c80636352211e1161019a578063a22cb465116100e1578063cdb88ad11161008a578063e985e9c511610064578063e985e9c51461093c578063f2fde38b14610985578063fbfa77cf146109a557600080fd5b8063cdb88ad1146108e6578063ce11154114610906578063e2bdc5141461091c57600080fd5b8063b88d4fde116100bb578063b88d4fde1461088b578063c87b56dd146108ab578063cd8c063b146108cb57600080fd5b8063a22cb4651461082b578063a27cbb421461084b578063a4669efa1461086b57600080fd5b80638f15b4141161014357806395d89b411161011d57806395d89b411461072857806396f4ada61461073d57806399fbab881461075d57600080fd5b80638f15b414146106c757806392c1ee40146106e757806393fbb3f61461070857600080fd5b806370a082311161017457806370a0823114610673578063715018a6146106935780638da5cb5b146106a857600080fd5b80636352211e1461061b57806363f6c7a71461063b5780636f307dc31461065257600080fd5b806336a595291161025e5780634f1ef2861161020757806355f804b3116101e157806355f804b3146105c25780635c975abb146105e25780636198e339146105fb57600080fd5b80634f1ef2861461057a5780634f6ccce71461058d57806352d1902d146105ad57600080fd5b806342842e0e1161023857806342842e0e1461051a57806342b931e31461053a578063430c20811461055a57600080fd5b806336a59529146104c357806336fd986a146104da5780633ecb51c0146104fa57600080fd5b806318160ddd116102c05780633021a5601161029a5780633021a5601461046357806330d8b5cd146104835780633659cfe6146104a357600080fd5b806318160ddd1461040e57806323b872dd146104235780632f745c591461044357600080fd5b806306fdde03116102f157806306fdde0314610394578063081812fc146103b6578063095ea7b3146103ee57600080fd5b80623232f61461031757806301ffc9a71461033957806302bf3d561461036e575b600080fd5b34801561032357600080fd5b50610337610332366004614421565b6109c6565b005b34801561034557600080fd5b506103596103543660046144ff565b610eb4565b60405190151581526020015b60405180910390f35b34801561037a57600080fd5b50610194546103869081565b604051908152602001610365565b3480156103a057600080fd5b506103a9610edf565b6040516103659190614574565b3480156103c257600080fd5b506103d66103d1366004614587565b610f71565b6040516001600160a01b039091168152602001610365565b3480156103fa57600080fd5b506103376104093660046145b5565b611006565b34801561041a57600080fd5b5060fd54610386565b34801561042f57600080fd5b5061033761043e3660046145e1565b61111c565b34801561044f57600080fd5b5061038661045e3660046145b5565b6111a3565b34801561046f57600080fd5b5061033761047e366004614587565b61124b565b34801561048f57600080fd5b5061038661049e366004614587565b6113d4565b3480156104af57600080fd5b506103376104be366004614622565b6113f3565b3480156104cf57600080fd5b506103866101965481565b3480156104e657600080fd5b506103376104f536600461463f565b61156f565b34801561050657600080fd5b50610337610515366004614682565b61177d565b34801561052657600080fd5b506103376105353660046145e1565b61180f565b34801561054657600080fd5b5061033761055536600461463f565b61182a565b34801561056657600080fd5b506103596105753660046145b5565b611a1b565b610337610588366004614742565b611a2e565b34801561059957600080fd5b506103866105a8366004614587565b611b9b565b3480156105b957600080fd5b50610386611c3f565b3480156105ce57600080fd5b506103376105dd366004614792565b611d04565b3480156105ee57600080fd5b5061015f5460ff16610359565b34801561060757600080fd5b50610337610616366004614587565b611d9c565b34801561062757600080fd5b506103d6610636366004614587565b612001565b34801561064757600080fd5b506103866101955481565b34801561065e57600080fd5b50610191546103d6906001600160a01b031681565b34801561067f57600080fd5b5061038661068e366004614622565b61208c565b34801561069f57600080fd5b50610337612126565b3480156106b457600080fd5b5061012d546001600160a01b03166103d6565b3480156106d357600080fd5b506103376106e23660046147c7565b61217b565b3480156106f357600080fd5b50610193546103d6906001600160a01b031681565b34801561071457600080fd5b50610386610723366004614587565b6122c0565b34801561073457600080fd5b506103a96122d8565b34801561074957600080fd5b50610337610758366004614622565b6122e7565b34801561076957600080fd5b506107db610778366004614587565b6101996020526000908152604090208054600182015460028301546003909301546001600160801b0380841694600160801b9485900482169467ffffffffffffffff80861695680100000000000000008104909116949190048316929091169087565b604080516001600160801b039889168152968816602088015267ffffffffffffffff9586169087015292909316606085015284166080840152921660a082015260c081019190915260e001610365565b34801561083757600080fd5b50610337610846366004614850565b6123f1565b34801561085757600080fd5b50610337610866366004614587565b6123fc565b34801561087757600080fd5b50610337610886366004614622565b6125be565b34801561089757600080fd5b506103376108a6366004614889565b6126c8565b3480156108b757600080fd5b506103a96108c6366004614587565b612756565b3480156108d757600080fd5b50610197546103599060ff1681565b3480156108f257600080fd5b50610337610901366004614682565b61283e565b34801561091257600080fd5b5061019654610386565b34801561092857600080fd5b50610386610937366004614587565b61289d565b34801561094857600080fd5b506103596109573660046148f5565b6001600160a01b03918216600090815260ce6020908152604080832093909416825291909152205460ff1690565b34801561099157600080fd5b506103376109a0366004614622565b6128ea565b3480156109b157600080fd5b50610192546103d6906001600160a01b031681565b61012d546001600160a01b03163314610a145760405162461bcd60e51b81526020600482018190526024820152600080516020614da083398151915260448201526064015b60405180910390fd5b828114610a635760405162461bcd60e51b815260206004820152601560248201527f6172726179206c656e677468206d69736d6174636800000000000000000000006044820152606401610a0b565b6000805b84811015610e5457838382818110610a8157610a81614923565b9050606002016020016020810190610a999190614951565b67ffffffffffffffff16848483818110610ab557610ab5614923565b9050606002016040016020810190610acd9190614951565b67ffffffffffffffff16118015610b1757506000848483818110610af357610af3614923565b9050606002016020016020810190610b0b9190614951565b67ffffffffffffffff16115b8015610b5357506000848483818110610b3257610b32614923565b610b489260206060909202019081019150614983565b6001600160801b0316115b610b9f5760405162461bcd60e51b815260206004820152601660248201527f696e76616c696420706f736974696f6e20696e707574000000000000000000006044820152606401610a0b565b838382818110610bb157610bb1614923565b610bc79260206060909202019081019150614983565b610bda906001600160801b0316836149b4565b9150610beb61019480546001019055565b6000610bf76101945490565b9050610c29878784818110610c0e57610c0e614923565b9050602002016020810190610c239190614622565b826129c7565b60006040518060e00160405280878786818110610c4857610c48614923565b610c5e9260206060909202019081019150614983565b6001600160801b0316815260006020820152604001878786818110610c8557610c85614923565b9050606002016020016020810190610c9d9190614951565b67ffffffffffffffff168152602001878786818110610cbe57610cbe614923565b9050606002016040016020810190610cd69190614951565b67ffffffffffffffff168152602001610d90888887818110610cfa57610cfa614923565b9050606002016020016020810190610d129190614951565b898988818110610d2457610d24614923565b9050606002016040016020810190610d3c9190614951565b610d4691906149cc565b67ffffffffffffffff16898988818110610d6257610d62614923565b610d789260206060909202019081019150614983565b610d829190614a0b565b6001600160801b0316612b15565b6001600160801b03908116825260006020808401829052610195546040948501529581526101998652829020835195840151958216600160801b9683168702178155918301516001830180546060860151608087015167ffffffffffffffff9485166001600160801b03199384161768010000000000000000959092169490940217841692841690970291909117905560a083015160028301805490961691161790935560c001516003909201919091555080610e4c81614a31565b915050610a67565b50806101966000828254610e6891906149b4565b90915550506040517fdf01283be3b53c10dd5865c887a9218504d01cfe718eb87444d763aad8132d9590610ea59087908790879087908790614a4c565b60405180910390a15050505050565b60006001600160e01b0319821663780e9d6360e01b1480610ed95750610ed982612b98565b92915050565b606060c98054610eee90614b21565b80601f0160208091040260200160405190810160405280929190818152602001828054610f1a90614b21565b8015610f675780601f10610f3c57610100808354040283529160200191610f67565b820191906000526020600020905b815481529060010190602001808311610f4a57829003601f168201915b5050505050905090565b600081815260cb60205260408120546001600160a01b0316610fea5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a0b565b50600090815260cd60205260409020546001600160a01b031690565b600061101182612001565b9050806001600160a01b0316836001600160a01b0316141561107f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a0b565b336001600160a01b038216148061109b575061109b8133610957565b61110d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a0b565b6111178383612be8565b505050565b6111263382612c56565b6111985760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610a0b565b611117838383612d4c565b60006111ae8361208c565b82106112225760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610a0b565b506001600160a01b0391909116600090815260fb60209081526040808320938352929052205490565b61015f5460ff16156112925760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b610192546001600160a01b031633146112ed5760405162461bcd60e51b815260206004820152601260248201527f6f6e6c79207661756c7420616c6c6f77656400000000000000000000000000006044820152606401610a0b565b6000610196541180156113005750600081115b61134c5760405162461bcd60e51b815260206004820152601660248201527f696e76616c6964207374617465206f7220696e707574000000000000000000006044820152606401610a0b565b61019654611362670de0b6b3a764000083614b5c565b61136c9190614b7b565b610195600082825461137e91906149b4565b90915550506101915461139c906001600160a01b0316333084612f0b565b60405181815233907f55fd0bec59e0b2fdf9406c9890f568c6ec6f92c752012ef7e3ebaee44d4d6cad9060200160405180910390a250565b610195546000828152610199602052604081209091610ed99190612f8b565b306001600160a01b037f000000000000000000000000c01e7dcc6cca1af57a5099f1dcab90084408bfdb1614156114815760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610a0b565b7f000000000000000000000000c01e7dcc6cca1af57a5099f1dcab90084408bfdb6001600160a01b03166114dc7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146115475760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610a0b565b61155081612fdf565b6040805160008082526020820190925261156c91839190613028565b50565b61015f5460ff16156115b65760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b610193546001600160a01b031633146116115760405162461bcd60e51b815260206004820152601b60248201527f6f6e6c7920626f6e647320726567697374727920616c6c6f77656400000000006044820152606401610a0b565b828261161d8282612c56565b61165b5760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b6000848152610199602052604090206101955485919061168590611680908390612f8b565b612b15565b6002820180546001600160801b0319166001600160801b0392909216919091179055610195546003820155846116ef5760405162461bcd60e51b815260206004820152600f60248201526e7a65726f20756e6465726c79696e6760881b6044820152606401610a0b565b6116f885612b15565b60008781526101996020526040812080549091906117209084906001600160801b0316614b8f565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508461019660008282546117579190614baf565b909155505061019154611774906001600160a01b031633876131c8565b50505050505050565b61012d546001600160a01b031633146117c65760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b60405181151581527f6626a495c12d20fcd56323beda487784c2f149273f33aa1e5e91503f5beaeaec9060200160405180910390a1610197805460ff1916911515919091179055565b611117838383604051806020016040528060008152506126c8565b61015f5460ff16156118715760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b610193546001600160a01b031633146118cc5760405162461bcd60e51b815260206004820152601b60248201527f6f6e6c7920626f6e647320726567697374727920616c6c6f77656400000000006044820152606401610a0b565b82826118d88282612c56565b6119165760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b6000848152610199602052604090206101955485919061193b90611680908390612f8b565b6002820180546001600160801b0319166001600160801b0392909216919091179055610195546003820155846119a55760405162461bcd60e51b815260206004820152600f60248201526e7a65726f20756e6465726c79696e6760881b6044820152606401610a0b565b6119ae85612b15565b60008781526101996020526040812080549091906119d69084906001600160801b0316614bc6565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550846101966000828254611a0d91906149b4565b909155505050505050505050565b6000611a278383612c56565b9392505050565b306001600160a01b037f000000000000000000000000c01e7dcc6cca1af57a5099f1dcab90084408bfdb161415611abc5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610a0b565b7f000000000000000000000000c01e7dcc6cca1af57a5099f1dcab90084408bfdb6001600160a01b0316611b177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614611b825760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610a0b565b611b8b82612fdf565b611b9782826001613028565b5050565b6000611ba660fd5490565b8210611c1a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610a0b565b60fd8281548110611c2d57611c2d614923565b90600052602060002001549050919050565b6000306001600160a01b037f000000000000000000000000c01e7dcc6cca1af57a5099f1dcab90084408bfdb1614611cdf5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610a0b565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b61012d546001600160a01b03163314611d4d5760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b7f1207a63f0a002f772f8bd43fa2e5939a59bd400c5a9d635a6700462ad3ca7a8e61019882604051611d80929190614bf1565b60405180910390a18051611b9790610198906020840190614391565b61015f5460ff1615611de35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b3381611def8282612c56565b611e2d5760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b60008381526101996020526040902061019554849190611e5290611680908390612f8b565b6002820180546001600160801b0319166001600160801b03929092169190911790556101955460038201556000611e8886612001565b600087815261019960205260408120919250611ea38861289d565b905060008111611ef55760405162461bcd60e51b815260206004820152601460248201527f7a65726f2076616c756520746f20756e6c6f636b0000000000000000000000006044820152606401610a0b565b611efe81612b15565b82548390600090611f199084906001600160801b0316614b8f565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550611f4681612b15565b82548390601090611f68908490600160801b90046001600160801b0316614bc6565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550600061019654905080821115611fa0578091505b8181036101965561019154611fbf906001600160a01b031685846131c8565b604051828152899033907f59b8f181b35d2091471227c68eb856ad709d72c40b9ad5f46e140d970b28ebf79060200160405180910390a3505050505050505050565b600081815260cb60205260408120546001600160a01b031680610ed95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610a0b565b60006001600160a01b03821661210a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610a0b565b506001600160a01b0316600090815260cc602052604090205490565b61012d546001600160a01b0316331461216f5760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b61217960006131f8565b565b6000612187600161324b565b9050801561219f576000805461ff0019166101001790555b8451158015906121af5750835115155b80156121c357506001600160a01b03831615155b80156121d757506001600160a01b03821615155b6122235760405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420696e707574730000000000000000000000000000000000006044820152606401610a0b565b61019180546001600160a01b038086166001600160a01b03199283161790925561019280549285169290911691909117905561225d613366565b61226785856133d1565b61226f613446565b6122776134b9565b80156122b9576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610ea5565b5050505050565b600081815261019960205260408120610ed99061352c565b606060ca8054610eee90614b21565b61012d546001600160a01b031633146123305760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b6001600160a01b0381166123865760405162461bcd60e51b815260206004820152600e60248201527f696e76616c6964205f7661756c740000000000000000000000000000000000006044820152606401610a0b565b61019254604080516001600160a01b03928316815291831660208301527f9364e08f31e8053a800c27bdd7dc0a677bd6ec519e22cbcfafeb749a28d68907910160405180910390a161019280546001600160a01b0319166001600160a01b0392909216919091179055565b611b973383836135c3565b61015f5460ff16156124435760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b338161244f8282612c56565b61248d5760405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b2102fb1b0b63632b960891b6044820152606401610a0b565b600083815261019960205260409020610195548491906124b290611680908390612f8b565b6002820180546001600160801b0319166001600160801b039290921691909117905561019554600382015560006124e886612001565b6000878152610199602052604090206002810180546001600160801b03198116909155919250906001600160801b0316806125655760405162461bcd60e51b815260206004820152601060248201527f302070656e64696e6720726576646973000000000000000000000000000000006044820152606401610a0b565b6101915461257d906001600160a01b031684836131c8565b604051818152889033907f73a7e592630f3a5ec42d849cf32016157e87cdb4889a2b1f52ca8f89a24e64959060200160405180910390a35050505050505050565b61012d546001600160a01b031633146126075760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b6001600160a01b03811661265d5760405162461bcd60e51b815260206004820152601660248201527f696e76616c6964205f626f6e64735265676973747279000000000000000000006044820152606401610a0b565b61019354604080516001600160a01b03928316815291831660208301527fce91615be49fced4227941935cd56339df453f049b8924214fd14e50f760b71a910160405180910390a161019380546001600160a01b0319166001600160a01b0392909216919091179055565b6126d23383612c56565b6127445760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610a0b565b61275084848484613692565b50505050565b600081815260cb60205260409020546060906001600160a01b03166127e35760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610a0b565b60006127ed61371b565b9050600081511161280d5760405180602001604052806000815250611a27565b806128178461372b565b604051602001612828929190614ca4565b6040516020818303038152906040529392505050565b61012d546001600160a01b031633146128875760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b80156128955761156c613841565b61156c6138db565b60008181526101996020526040812081906128b79061352c565b600084815261019960205260409020549091506001600160801b03168082116128e057816128e2565b805b949350505050565b61012d546001600160a01b031633146129335760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b6001600160a01b0381166129af5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610a0b565b61156c816131f8565b6001600160a01b03163b151590565b6001600160a01b038216612a1d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a0b565b600081815260cb60205260409020546001600160a01b031615612a825760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a0b565b612a8e60008383613960565b6001600160a01b038216600090815260cc60205260408120805460019290612ab79084906149b4565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160801b03821115612b945760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610a0b565b5090565b60006001600160e01b031982166380ac58cd60e01b1480612bc957506001600160e01b03198216635b5e139f60e01b145b80610ed957506301ffc9a760e01b6001600160e01b0319831614610ed9565b600081815260cd6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612c1d82612001565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081815260cb60205260408120546001600160a01b0316612ccf5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a0b565b6000612cda83612001565b9050806001600160a01b0316846001600160a01b03161480612d2157506001600160a01b03808216600090815260ce602090815260408083209388168352929052205460ff165b806128e25750836001600160a01b0316612d3a84610f71565b6001600160a01b031614949350505050565b826001600160a01b0316612d5f82612001565b6001600160a01b031614612ddb5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610a0b565b6001600160a01b038216612e3d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a0b565b612e48838383613960565b612e53600082612be8565b6001600160a01b038316600090815260cc60205260408120805460019290612e7c908490614baf565b90915550506001600160a01b038216600090815260cc60205260408120805460019290612eaa9084906149b4565b9091555050600081815260cb602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6040516001600160a01b03808516602483015283166044820152606481018290526127509085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526139d4565b600282015460038301546000916001600160801b031690670de0b6b3a764000090612fb69085614baf565b8554612fcb91906001600160801b0316614b5c565b612fd59190614b7b565b611a2791906149b4565b61012d546001600160a01b0316331461156c5760405162461bcd60e51b81526020600482018190526024820152600080516020614da08339815191526044820152606401610a0b565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561305b5761111783613ab9565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156130b5575060408051601f3d908101601f191682019092526130b291810190614cca565b60015b6131275760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610a0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146131bc5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610a0b565b50611117838383613b77565b6040516001600160a01b03831660248201526044810182905261111790849063a9059cbb60e01b90606401612f3f565b61012d80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008054610100900460ff16156132d9578160ff16600114801561326e5750303b155b6132d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a0b565b506000919050565b60005460ff8084169116106133475760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a0b565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166121795760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b600054610100900460ff1661343c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b611b978282613b9c565b600054610100900460ff166134b15760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b612179613c2e565b600054610100900460ff166135245760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b612179613ca2565b600181015460009067ffffffffffffffff16421161354c57506000919050565b600182015468010000000000000000900467ffffffffffffffff164210156135b557815460018301546001600160801b03600160801b92839004811692820416906135a19067ffffffffffffffff1642614baf565b6135ab9190614b5c565b610ed99190614baf565b50546001600160801b031690565b816001600160a01b0316836001600160a01b031614156136255760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a0b565b6001600160a01b03838116600081815260ce6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61369d848484612d4c565b6136a984848484613d1a565b6127505760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a0b565b60606101988054610eee90614b21565b60608161374f5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613779578061376381614a31565b91506137729050600a83614b7b565b9150613753565b60008167ffffffffffffffff8111156137945761379461469f565b6040519080825280601f01601f1916602001820160405280156137be576020820181803683370190505b5090505b84156128e2576137d3600183614baf565b91506137e0600a86614ce3565b6137eb9060306149b4565b60f81b81838151811061380057613800614923565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061383a600a86614b7b565b94506137c2565b61015f5460ff16156138885760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a0b565b61015f805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586138be3390565b6040516001600160a01b03909116815260200160405180910390a1565b61015f5460ff1661392e5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610a0b565b61015f805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336138be565b61396b838383613e6e565b61012d546001600160a01b031633148061398857506101975460ff165b6111175760405162461bcd60e51b815260206004820152601c60248201527f455243373231207472616e7366657273206e6f7420616c6c6f776564000000006044820152606401610a0b565b6000613a29826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613f269092919063ffffffff16565b8051909150156111175780806020019051810190613a479190614cf7565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a0b565b6001600160a01b0381163b613b365760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610a0b565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b613b8083613f35565b600082511180613b8d5750805b15611117576127508383613f75565b600054610100900460ff16613c075760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b8151613c1a9060c9906020850190614391565b5080516111179060ca906020840190614391565b600054610100900460ff16613c995760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b612179336131f8565b600054610100900460ff16613d0d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610a0b565b61015f805460ff19169055565b60006001600160a01b0384163b15613e6357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290613d5e903390899088908890600401614d14565b6020604051808303816000875af1925050508015613d99575060408051601f3d908101601f19168201909252613d9691810190614d50565b60015b613e49573d808015613dc7576040519150601f19603f3d011682016040523d82523d6000602084013e613dcc565b606091505b508051613e415760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610a0b565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506128e2565b506001949350505050565b6001600160a01b038316613ec957613ec48160fd8054600083815260fe60205260408120829055600182018355919091527f9346ac6dd7de6b96975fec380d4d994c4c12e6a8897544f22915316cc6cca2800155565b613eec565b816001600160a01b0316836001600160a01b031614613eec57613eec8382614080565b6001600160a01b038216613f03576111178161411d565b826001600160a01b0316826001600160a01b0316146111175761111782826141cc565b60606128e28484600085614210565b613f3e81613ab9565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b613ff45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401610a0b565b600080846001600160a01b03168460405161400f9190614d6d565b600060405180830381855af49150503d806000811461404a576040519150601f19603f3d011682016040523d82523d6000602084013e61404f565b606091505b50915091506140778282604051806060016040528060278152602001614dc060279139614358565b95945050505050565b6000600161408d8461208c565b6140979190614baf565b600083815260fc60205260409020549091508082146140ea576001600160a01b038416600090815260fb60209081526040808320858452825280832054848452818420819055835260fc90915290208190555b50600091825260fc602090815260408084208490556001600160a01b03909416835260fb81528383209183525290812055565b60fd5460009061412f90600190614baf565b600083815260fe602052604081205460fd805493945090928490811061415757614157614923565b906000526020600020015490508060fd838154811061417857614178614923565b600091825260208083209091019290925582815260fe909152604080822084905585825281205560fd8054806141b0576141b0614d89565b6001900381819060005260206000200160009055905550505050565b60006141d78361208c565b6001600160a01b03909316600090815260fb60209081526040808320868452825280832085905593825260fc9052919091209190915550565b6060824710156142885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a0b565b6001600160a01b0385163b6142df5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a0b565b600080866001600160a01b031685876040516142fb9190614d6d565b60006040518083038185875af1925050503d8060008114614338576040519150601f19603f3d011682016040523d82523d6000602084013e61433d565b606091505b509150915061434d828286614358565b979650505050505050565b60608315614367575081611a27565b8251156143775782518084602001fd5b8160405162461bcd60e51b8152600401610a0b9190614574565b82805461439d90614b21565b90600052602060002090601f0160209004810192826143bf5760008555614405565b82601f106143d857805160ff1916838001178555614405565b82800160010185558215614405579182015b828111156144055782518255916020019190600101906143ea565b50612b949291505b80821115612b94576000815560010161440d565b6000806000806040858703121561443757600080fd5b843567ffffffffffffffff8082111561444f57600080fd5b818701915087601f83011261446357600080fd5b81358181111561447257600080fd5b8860208260051b850101111561448757600080fd5b6020928301965094509086013590808211156144a257600080fd5b818701915087601f8301126144b657600080fd5b8135818111156144c557600080fd5b8860206060830285010111156144da57600080fd5b95989497505060200194505050565b6001600160e01b03198116811461156c57600080fd5b60006020828403121561451157600080fd5b8135611a27816144e9565b60005b8381101561453757818101518382015260200161451f565b838111156127505750506000910152565b6000815180845261456081602086016020860161451c565b601f01601f19169290920160200192915050565b602081526000611a276020830184614548565b60006020828403121561459957600080fd5b5035919050565b6001600160a01b038116811461156c57600080fd5b600080604083850312156145c857600080fd5b82356145d3816145a0565b946020939093013593505050565b6000806000606084860312156145f657600080fd5b8335614601816145a0565b92506020840135614611816145a0565b929592945050506040919091013590565b60006020828403121561463457600080fd5b8135611a27816145a0565b60008060006060848603121561465457600080fd5b833561465f816145a0565b95602085013595506040909401359392505050565b801515811461156c57600080fd5b60006020828403121561469457600080fd5b8135611a2781614674565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126146c657600080fd5b813567ffffffffffffffff808211156146e1576146e161469f565b604051601f8301601f19908116603f011681019082821181831017156147095761470961469f565b8160405283815286602085880101111561472257600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561475557600080fd5b8235614760816145a0565b9150602083013567ffffffffffffffff81111561477c57600080fd5b614788858286016146b5565b9150509250929050565b6000602082840312156147a457600080fd5b813567ffffffffffffffff8111156147bb57600080fd5b6128e2848285016146b5565b600080600080608085870312156147dd57600080fd5b843567ffffffffffffffff808211156147f557600080fd5b614801888389016146b5565b9550602087013591508082111561481757600080fd5b50614824878288016146b5565b9350506040850135614835816145a0565b91506060850135614845816145a0565b939692955090935050565b6000806040838503121561486357600080fd5b823561486e816145a0565b9150602083013561487e81614674565b809150509250929050565b6000806000806080858703121561489f57600080fd5b84356148aa816145a0565b935060208501356148ba816145a0565b925060408501359150606085013567ffffffffffffffff8111156148dd57600080fd5b6148e9878288016146b5565b91505092959194509250565b6000806040838503121561490857600080fd5b8235614913816145a0565b9150602083013561487e816145a0565b634e487b7160e01b600052603260045260246000fd5b803567ffffffffffffffff8116811461336157600080fd5b60006020828403121561496357600080fd5b611a2782614939565b80356001600160801b038116811461336157600080fd5b60006020828403121561499557600080fd5b611a278261496c565b634e487b7160e01b600052601160045260246000fd5b600082198211156149c7576149c761499e565b500190565b600067ffffffffffffffff838116908316818110156149ed576149ed61499e565b039392505050565b634e487b7160e01b600052601260045260246000fd5b60006001600160801b0380841680614a2557614a256149f5565b92169190910492915050565b6000600019821415614a4557614a4561499e565b5060010190565b60608082528181018690526000908760808401835b89811015614a91578235614a74816145a0565b6001600160a01b0316825260209283019290910190600101614a61565b5084810360208681019190915287825291508790820160005b88811015614b09576001600160801b03614ac38461496c565b168252614ad1848401614939565b67ffffffffffffffff9081168386015260409080614af0868401614939565b1691840191909152509184019190840190600101614aaa565b50809450505050508260408301529695505050505050565b600181811c90821680614b3557607f821691505b60208210811415614b5657634e487b7160e01b600052602260045260246000fd5b50919050565b6000816000190483118215151615614b7657614b7661499e565b500290565b600082614b8a57614b8a6149f5565b500490565b60006001600160801b03838116908316818110156149ed576149ed61499e565b600082821015614bc157614bc161499e565b500390565b60006001600160801b03808316818516808303821115614be857614be861499e565b01949350505050565b60408152600080845481600182811c915080831680614c1157607f831692505b6020808410821415614c3157634e487b7160e01b86526022600452602486fd5b6040880184905260608801828015614c505760018114614c6157614c8c565b60ff19871682528282019750614c8c565b60008c81526020902060005b87811015614c8657815484820152908601908401614c6d565b83019850505b50508786038189015250505050506140778185614548565b60008351614cb681846020880161451c565b835190830190614be881836020880161451c565b600060208284031215614cdc57600080fd5b5051919050565b600082614cf257614cf26149f5565b500690565b600060208284031215614d0957600080fd5b8151611a2781614674565b60006001600160a01b03808716835280861660208401525083604083015260806060830152614d466080830184614548565b9695505050505050565b600060208284031215614d6257600080fd5b8151611a27816144e9565b60008251614d7f81846020870161451c565b9190910192915050565b634e487b7160e01b600052603160045260246000fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c634300080b000a

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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