ETH Price: $2,934.45 (+4.06%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040205884302024-08-23 2:49:2377 days ago1724381363IN
 Create: ERC721Staking
0 ETH0.003711271.08629286

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC721Staking

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 15 : ERC721Staking.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {AccessControlDefaultAdminRulesUpgradeable} from "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @title Monprotocol Staking Contract
/// @author zihangg
contract ERC721Staking is Initializable, ReentrancyGuardUpgradeable, AccessControlDefaultAdminRulesUpgradeable, PausableUpgradeable {
    /*///////////////////////////////////////////////////////////////
                               CONSTANTS
    //////////////////////////////////////////////////////////////*/

    bytes32 public constant DEVELOPER_ROLE = keccak256("DEVELOPER");

    uint256 private constant MAX_PAGE_SIZE = 1000;

    /*///////////////////////////////////////////////////////////////
                               STRUCTS
    //////////////////////////////////////////////////////////////*/

    /// @notice Records staking schedules internally.
    struct StakingSchedule {
        uint64 lockDuration /* Duration of token lock in seconds. */;
        address[] whitelistedCollections /* Collections that are able to be locked for this schedule. */;
        bool isActive /* Whether or not the schedule can be staked to.*/;
    }

    /// @notice Records token data internally.
    struct StakedToken {
        address owner;
        uint256 stakeStartTime;
        uint256 stakeScheduleId;
    }

    /// @notice Used to return token info for view function.
    struct UserStakedTokenInfo {
        address collectionAddress;
        uint256 tokenId;
        uint256 stakeStartTime;
        uint256 stakeScheduleId;
    }

    /*///////////////////////////////////////////////////////////////
                               VARIABLES
    //////////////////////////////////////////////////////////////*/

    /* Staking Schedule IDs */
    uint256[] internal stakingScheduleIds;

    /* Mapping to track user's staked amounts. */
    mapping(address owner => uint256 stakedAmount) internal stakedAmountByOwner;

    /* Maintaining a mapping for easier read access. */
    mapping(uint256 stakingScheduleId => mapping(address collectionAddress => bool isWhitelisted)) internal whitelistedCollections;

    /* Staking Schedules, mapped to their schedule ID. */
    mapping(uint256 stakingScheduleId => StakingSchedule stakingSchedule) internal stakingSchedules;

    /* Mapping of token IDs to their schedule IDs. */
    mapping(uint256 stakingScheduleId => mapping(address collectionAddress => uint256[] tokenId)) internal stakedTokensBySchedule;

    /* Mapping of user's staked tokens. */
    mapping(address owner => mapping(address collectionAddress => uint256[] tokenId)) internal stakedTokensByOwner;

    /* Mapping of tokens in each collection to their schedule ID. */
    mapping(address collectionAddress => mapping(uint256 tokenId => StakedToken stakedToken)) internal stakedTokensData;

    /*///////////////////////////////////////////////////////////////
                                ERRORS 
    //////////////////////////////////////////////////////////////*/

    error CollectionNotWhitelisted();
    error InvalidCollectionAddress();
    error InvalidLockDuration();
    error InvalidScheduleId();
    error InvalidSchedule();
    error InvalidPageSize();
    error MismatchedArrays();
    error NotOwner();
    error ScheduleInactive();
    error StakingDurationNotEnded();
    error TokenNotStaked();

    /*///////////////////////////////////////////////////////////////
                                EVENTS 
    //////////////////////////////////////////////////////////////*/

    event StakingScheduleCreated(uint256 indexed stakingScheduleId, StakingSchedule stakingSchedule);
    event StakingScheduleUpdated(uint256 indexed stakingScheduleId, StakingSchedule stakingSchedule);
    event TokenEmergencyUnlocked(address indexed user, address indexed collectionAddress, uint256 indexed tokenId);
    event TokenEmergencyUnlockedAndTransferred(address indexed user, address indexed collectionAddress, uint256 indexed tokenId);
    event TokenStaked(address indexed user, address indexed collectionAddress, uint256 indexed tokenId, uint256 stakingScheduleId);
    event TokenStakeStartTimeUpdated(
        address indexed collectionAddress,
        uint256 indexed tokenId,
        uint256 currentStakeStartTime,
        uint256 newStakeStartTime
    );
    event TokenWithdrawn(address indexed user, address indexed collectionAddress, uint256 indexed tokenId);

    /*///////////////////////////////////////////////////////////////
                              MODIFIERS 
    //////////////////////////////////////////////////////////////*/

    /// @notice Modifier to check for similar array length
    modifier validArrayLength(uint256 length1, uint256 length2) {
        if (length1 != length2) {
            revert MismatchedArrays();
        }
        _;
    }

    /*///////////////////////////////////////////////////////////////
                              CONSTRUCTOR 
    //////////////////////////////////////////////////////////////*/

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(address _defaultAdminAddress, address[] calldata _developers) external initializer {
        __Pausable_init();
        __ReentrancyGuard_init();
        __AccessControlDefaultAdminRules_init(1 days, _defaultAdminAddress);

        /* Set owner and developers into DEVELOPER_ROLE */
        _grantRole(DEVELOPER_ROLE, _defaultAdminAddress);
        for (uint256 i; i < _developers.length; ) {
            _grantRole(DEVELOPER_ROLE, _developers[i]);
            unchecked {
                ++i;
            }
        }

        /* Create Reserve Schedule At ID = 0 for Unlocks */
        stakingSchedules[0] = StakingSchedule(0, new address[](0), true);
        stakingScheduleIds.push(0);

        /* Pause Contract on Deployment */
        _pause();
    }

    /*///////////////////////////////////////////////////////////////
                              STAKING LOGIC
    //////////////////////////////////////////////////////////////*/

    /// @notice Batch Stake whitelisted ERC721s to a specific time-locked schedule.
    /// @param _collectionAddresses  Collection addresses for tokens.
    /// @param _tokenIds  Tokens to be staked.
    /// @param _stakingScheduleIds  Schedules to stake tokens in.
    function batchStake(
        address[] calldata _collectionAddresses,
        uint256[] calldata _tokenIds,
        uint256[] calldata _stakingScheduleIds
    )
        external
        nonReentrant
        whenNotPaused
        validArrayLength(_stakingScheduleIds.length, _tokenIds.length)
        validArrayLength(_stakingScheduleIds.length, _collectionAddresses.length)
    {
        _batchStake(_collectionAddresses, _tokenIds, _stakingScheduleIds);
    }

    /// @notice Internal function to stake whitelisted ERC721s to a specific time-locked schedule.
    /// @param _collectionAddresses  Collection addresses for tokens.
    /// @param _tokenIds  Tokens to be staked.
    /// @param _stakingScheduleIds  Schedules to stake tokens in.
    function _batchStake(address[] calldata _collectionAddresses, uint256[] calldata _tokenIds, uint256[] calldata _stakingScheduleIds) internal {
        uint256 stakingScheduleIdsLength = _stakingScheduleIds.length;

        for (uint256 i; i < stakingScheduleIdsLength; ) {
            address collectionAddress = _collectionAddresses[i];
            uint256 tokenId = _tokenIds[i];
            uint256 stakingScheduleId = _stakingScheduleIds[i];

            /* Do not allow staking to schedule 0, as it is reserved for unlocks. */
            if (stakingScheduleId == 0) revert InvalidScheduleId();

            if (stakingSchedules[stakingScheduleId].lockDuration == 0) revert InvalidSchedule();

            if (stakingSchedules[stakingScheduleId].isActive == false) revert ScheduleInactive();

            if (!_isWhitelisted(collectionAddress, stakingScheduleId)) revert CollectionNotWhitelisted();

            if (IERC721(collectionAddress).ownerOf(tokenId) != msg.sender) revert NotOwner();

            _recordStakedToken(stakingScheduleId, collectionAddress, tokenId, msg.sender);

            IERC721(collectionAddress).safeTransferFrom(msg.sender, address(this), tokenId);

            emit TokenStaked(msg.sender, collectionAddress, tokenId, stakingScheduleId);

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Checks to see whether collection address is whitelisted in the schedule.
    /// @param collectionAddress  Incoming collection address.
    /// @param scheduleId   Schedule to check if collection address is whitelisted.
    function _isWhitelisted(address collectionAddress, uint256 scheduleId) internal view returns (bool) {
        return whitelistedCollections[scheduleId][collectionAddress];
    }

    /*///////////////////////////////////////////////////////////////
                              UNSTAKING LOGIC
    //////////////////////////////////////////////////////////////*/

    /// @notice Batch Unstake function to allow users to unstake their tokens after time-lock is complete.
    /// @param _collectionAddresses   Collection addresses of tokens to be unstaked.
    /// @param _tokenIds    Token IDs to be unstaked.
    function batchUnstake(
        address[] calldata _collectionAddresses,
        uint256[] calldata _tokenIds
    ) external nonReentrant whenNotPaused validArrayLength(_collectionAddresses.length, _tokenIds.length) {
        _batchUnstake(_collectionAddresses, _tokenIds);
    }

    /// @notice Internal unstake function to allow users to unstake their tokens after time-lock is complete.
    /// @param _collectionAddresses   Collection addresses of tokens to be unstaked.
    /// @param _tokenIds    Token IDs to be unstaked.
    function _batchUnstake(address[] calldata _collectionAddresses, uint256[] calldata _tokenIds) internal {
        uint256 length = _collectionAddresses.length;

        for (uint256 i; i < length; ) {
            address collectionAddress = _collectionAddresses[i];
            uint256 tokenId = _tokenIds[i];
            uint256 scheduleId = stakedTokensData[collectionAddress][tokenId].stakeScheduleId;

            /* Check if token is staked. */
            if (stakedTokensData[collectionAddress][tokenId].owner == address(0)) revert TokenNotStaked();

            /* Check if caller owns the token. */
            address owner = stakedTokensData[collectionAddress][tokenId].owner;
            if (msg.sender != owner) revert NotOwner();

            /* Check if staked period has passed time-lock. */
            uint256 stakeStartTime = stakedTokensData[collectionAddress][tokenId].stakeStartTime;
            uint256 lockDuration = stakingSchedules[scheduleId].lockDuration;
            if (block.timestamp < stakeStartTime + lockDuration) revert StakingDurationNotEnded();

            _unstake(collectionAddress, tokenId, scheduleId, owner);

            emit TokenWithdrawn(msg.sender, collectionAddress, tokenId);

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Internal singular unstake function to allow users to unstake their tokens and return to owner's wallet. Also removes relevant information from mappings and arrays.
    /// @param collectionAddress Collection address of token to be unstaked.
    /// @param tokenId Token ID to be unstaked.
    /// @param stakingScheduleId  Staking schedule that the token is currently in.
    /// @param tokenOwner  Current owner of the token.
    function _unstake(address collectionAddress, uint256 tokenId, uint256 stakingScheduleId, address tokenOwner) internal {
        /* Removing staked tokens from storage. */
        _removeStakedToken(stakingScheduleId, collectionAddress, tokenId, tokenOwner);

        /* Transfer token back to owner */
        IERC721(collectionAddress).safeTransferFrom(address(this), tokenOwner, tokenId);
    }

    /*///////////////////////////////////////////////////////////////
                             SCHEDULE FUNCTIONS 
    //////////////////////////////////////////////////////////////*/

    /// @notice Creates a new staking schedule.
    /// @param _stakingSchedule    Staking Schedule to be added.
    function createStakingSchedule(
        StakingSchedule calldata _stakingSchedule
    ) external onlyRole(DEFAULT_ADMIN_ROLE) returns (uint256 stakingScheduleId) {
        stakingScheduleId = stakingScheduleIds.length;

        _upsertStakingSchedule(stakingScheduleId, _stakingSchedule);

        stakingScheduleIds.push(stakingScheduleId);

        emit StakingScheduleCreated(stakingScheduleId, _stakingSchedule);
    }

    /// @notice Updates an existing staking schedule.
    //  @param _stakingScheduleId  Staking Schedule ID to be modified.
    /// @param _stakingSchedule    New Staking Schedule.
    function updateStakingSchedule(uint256 _stakingScheduleId, StakingSchedule calldata _stakingSchedule) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _upsertStakingSchedule(_stakingScheduleId, _stakingSchedule);

        emit StakingScheduleUpdated(_stakingScheduleId, _stakingSchedule);
    }

    /// @notice Internal function to upsert staking schedule, used by both Create and Update.
    /// @param _stakingScheduleId   Staking Schedule Unique ID.
    /// @param _stakingSchedule   Staking Schedule to be added.
    function _upsertStakingSchedule(uint256 _stakingScheduleId, StakingSchedule calldata _stakingSchedule) internal {
        if (_stakingScheduleId > 0 && _stakingSchedule.lockDuration == 0) {
            revert InvalidLockDuration();
        }

        /* Reverting if any of the collection addresses is a ZeroAddress. */
        for (uint256 i; i < _stakingSchedule.whitelistedCollections.length; ) {
            if (_stakingSchedule.whitelistedCollections[i] == address(0)) {
                revert InvalidCollectionAddress();
            }

            unchecked {
                ++i;
            }
        }

        StakingSchedule memory currentSchedule = stakingSchedules[_stakingScheduleId];

        stakingSchedules[_stakingScheduleId] = StakingSchedule(
            _stakingSchedule.lockDuration,
            _stakingSchedule.whitelistedCollections,
            _stakingSchedule.isActive
        );

        /* Unset old whitelisted collections. */
        for (uint256 i; i < currentSchedule.whitelistedCollections.length; ) {
            whitelistedCollections[_stakingScheduleId][currentSchedule.whitelistedCollections[i]] = false;

            unchecked {
                ++i;
            }
        }

        /* Set new whitelisted collections. */
        for (uint256 i; i < _stakingSchedule.whitelistedCollections.length; ) {
            whitelistedCollections[_stakingScheduleId][_stakingSchedule.whitelistedCollections[i]] = true;

            unchecked {
                ++i;
            }
        }
    }

    /*///////////////////////////////////////////////////////////////
                              ADMIN FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /// @notice Pauses contract.
    function pause() external onlyRole(DEVELOPER_ROLE) {
        _pause();
    }

    /// @notice Unpauses contract.
    function unpause() external onlyRole(DEVELOPER_ROLE) {
        _unpause();
    }

    /// @notice Allows owner to unlock the tokens for stakers to claim before time-lock is completed. This does not return the token to the owner of the token.
    /// @param _collectionAddresses   Collection addresses of tokens to be unstaked.
    /// @param _tokenIds    Token IDs to be unstaked.
    function emergencyUnlock(
        address[] calldata _collectionAddresses,
        uint256[] calldata _tokenIds
    ) external nonReentrant validArrayLength(_collectionAddresses.length, _tokenIds.length) onlyRole(DEFAULT_ADMIN_ROLE) {
        uint256 length = _collectionAddresses.length;

        for (uint256 i; i < length; ) {
            address collectionAddress = _collectionAddresses[i];
            uint256 tokenId = _tokenIds[i];
            uint256 scheduleId = stakedTokensData[collectionAddress][tokenId].stakeScheduleId;
            address owner = stakedTokensData[collectionAddress][tokenId].owner;

            /* Check if token is staked. */
            if (stakedTokensData[collectionAddress][tokenId].owner == address(0)) revert TokenNotStaked();

            _removeStakedToken(scheduleId, collectionAddress, tokenId, owner);
            _recordStakedToken(0, collectionAddress, tokenId, owner);

            emit TokenEmergencyUnlocked(owner, collectionAddress, tokenId);

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Allows owner to unlock and return tokens to users before time-lock is completed.
    /// @param _collectionAddresses   Collection addresses of tokens to be unstaked.
    /// @param _tokenIds    Token IDs to be unstaked.
    function emergencyUnlockAndTransfer(
        address[] calldata _collectionAddresses,
        uint256[] calldata _tokenIds
    ) external nonReentrant validArrayLength(_collectionAddresses.length, _tokenIds.length) onlyRole(DEFAULT_ADMIN_ROLE) {
        uint256 length = _collectionAddresses.length;

        for (uint256 i; i < length; ) {
            address collectionAddress = _collectionAddresses[i];
            uint256 tokenId = _tokenIds[i];
            uint256 scheduleId = stakedTokensData[collectionAddress][tokenId].stakeScheduleId;
            address owner = stakedTokensData[collectionAddress][tokenId].owner;

            /* Check if token is staked. */
            if (stakedTokensData[collectionAddress][tokenId].owner == address(0)) revert TokenNotStaked();

            _unstake(collectionAddress, tokenId, scheduleId, owner);

            emit TokenEmergencyUnlockedAndTransferred(owner, collectionAddress, tokenId);

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Internal reusable function to update stake start time for a token.
    /// @param _collectionAddress  Collection Address of token.
    /// @param _tokenId  Token ID of token.
    /// @param _newStakeStartTime  New Stake Start Time for token.
    function _updateTokenStakeStartTime(address _collectionAddress, uint256 _tokenId, uint256 _newStakeStartTime) internal {
        /* Must be staked token. */
        if (stakedTokensData[_collectionAddress][_tokenId].owner == address(0)) revert TokenNotStaked();

        uint256 currentStakeStartTime = stakedTokensData[_collectionAddress][_tokenId].stakeStartTime;

        stakedTokensData[_collectionAddress][_tokenId].stakeStartTime = _newStakeStartTime;

        emit TokenStakeStartTimeUpdated(_collectionAddress, _tokenId, currentStakeStartTime, _newStakeStartTime);
    }

    /// @notice External function to update stake start time for a token.
    /// @param _collectionAddress  Collection Address of token.
    /// @param _tokenId  Token ID of token.
    /// @param _newStakeStartTime  New Stake Start Time for token.
    function updateTokenStakeStartTime(
        address _collectionAddress,
        uint256 _tokenId,
        uint256 _newStakeStartTime
    ) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        _updateTokenStakeStartTime(_collectionAddress, _tokenId, _newStakeStartTime);
    }

    /// @notice External function to batch update stake start time for a token.
    /// @param _collectionAddresses Collection Addresses of tokens to be updated.
    /// @param _tokenIds  Token IDs of tokens to be updated.
    /// @param _newStakeStartTimes  New Stake Start Times for tokens to be updated.
    function batchUpdateTokenStakeStartTime(
        address[] calldata _collectionAddresses,
        uint256[] calldata _tokenIds,
        uint256[] calldata _newStakeStartTimes
    )
        external
        nonReentrant
        onlyRole(DEFAULT_ADMIN_ROLE)
        validArrayLength(_collectionAddresses.length, _tokenIds.length)
        validArrayLength(_collectionAddresses.length, _newStakeStartTimes.length)
    {
        uint256 length = _collectionAddresses.length;

        for (uint256 i; i < length; ) {
            _updateTokenStakeStartTime(_collectionAddresses[i], _tokenIds[i], _newStakeStartTimes[i]);

            unchecked {
                ++i;
            }
        }
    }

    /*///////////////////////////////////////////////////////////////
                              UTILS
    //////////////////////////////////////////////////////////////*/

    function _recordStakedToken(uint256 stakingScheduleId, address collectionAddress, uint256 tokenId, address owner) internal {
        /* Incrementing staked amount by owner. */
        stakedAmountByOwner[owner]++;

        /* Saving tokens staked in schedule. */
        stakedTokensBySchedule[stakingScheduleId][collectionAddress].push(tokenId);

        /* Saving tokens staked by owner. */
        stakedTokensByOwner[owner][collectionAddress].push(tokenId);

        /* Saving which schedule ID token subscribed to for direct access. */
        StakedToken memory stakedToken = StakedToken({owner: owner, stakeStartTime: block.timestamp, stakeScheduleId: stakingScheduleId});
        stakedTokensData[collectionAddress][tokenId] = stakedToken;
    }

    function _removeStakedToken(uint256 stakingScheduleId, address collectionAddress, uint256 tokenId, address owner) internal {
        /* Decrementing staked amount by owner. */
        stakedAmountByOwner[owner]--;

        /* Remove token from stakedTokensBySchedule */
        uint256[] storage scheduleTokens = stakedTokensBySchedule[stakingScheduleId][collectionAddress];
        for (uint256 i; i < scheduleTokens.length; ) {
            if (scheduleTokens[i] == tokenId) {
                scheduleTokens[i] = scheduleTokens[scheduleTokens.length - 1];
                scheduleTokens.pop();
                break;
            }

            unchecked {
                ++i;
            }
        }

        /* Remove token from stakedTokensByOwner */
        uint256[] storage ownerTokens = stakedTokensByOwner[owner][collectionAddress];
        for (uint256 i; i < ownerTokens.length; ) {
            if (ownerTokens[i] == tokenId) {
                ownerTokens[i] = ownerTokens[ownerTokens.length - 1];
                ownerTokens.pop();
                break;
            }

            unchecked {
                ++i;
            }
        }

        /* Remove token data */
        delete stakedTokensData[collectionAddress][tokenId];
    }

    /// @notice Internal function to retrieves user balance.
    /// @param owner  User to pull balance for.
    function _balance(address owner) internal view returns (uint256 balance) {
        return stakedAmountByOwner[owner];
    }

    /*///////////////////////////////////////////////////////////////
                              VIEWS/GETTERS
    //////////////////////////////////////////////////////////////*/

    /// @notice Retrieves all schedule ids.
    function getStakingScheduleIds() external view returns (uint256[] memory scheduleIds) {
        return stakingScheduleIds;
    }

    /// @notice Retrieves a staking schedule by their id.
    /// @param stakingScheduleId  ID of schedule to be pulled.
    /// @return stakingSchedule  Staking schedule at ID.
    function getStakingSchedule(uint256 stakingScheduleId) external view returns (StakingSchedule memory stakingSchedule) {
        return stakingSchedules[stakingScheduleId];
    }

    /// @notice Retrieves all staking schedules.
    /// @return allStakingScheduleIds  All IDs of Staking Schedules.
    /// @return allStakingSchedules  All Staking Schedule Information.
    function getStakingSchedules() external view returns (uint256[] memory allStakingScheduleIds, StakingSchedule[] memory allStakingSchedules) {
        uint256 len = stakingScheduleIds.length;
        allStakingScheduleIds = new uint256[](len);
        allStakingSchedules = new StakingSchedule[](len);

        for (uint256 i; i < len; ) {
            allStakingScheduleIds[i] = stakingScheduleIds[i];
            allStakingSchedules[i] = stakingSchedules[stakingScheduleIds[i]];

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Retrieves staked tokens in a specific Schedule ID.
    /// @param stakingScheduleId  Schedule ID to retrieve staked tokens from.
    /// @param collectionAddress  Collection to filter token IDs.
    function getTokensStakedInSchedule(uint256 stakingScheduleId, address collectionAddress) external view returns (uint256[] memory) {
        return stakedTokensBySchedule[stakingScheduleId][collectionAddress];
    }

    /// @notice Retrieves staked tokens count in a specific Schedule ID, used to paginate.
    /// @param stakingScheduleId  Schedule ID to retrieve staked tokens from.
    /// @param collectionAddress  Collection to filter token IDs.
    function getTokenCountInScheduleByCollectionAddress(uint256 stakingScheduleId, address collectionAddress) external view returns (uint256) {
        return stakedTokensBySchedule[stakingScheduleId][collectionAddress].length;
    }

    /// @notice Retrieves staked tokens data in a specific Schedule ID with a simple pagination logic.
    /// @param stakingScheduleId  Schedule ID to retrieve staked tokens from.
    /// @param collectionAddress  Collection to filter token IDs.
    /// @param startIndex Start index for tokens within the schedule -> collectionAddress.
    /// @param pageSize Page size to return.
    function getStakedTokenDataInScheduleByCollectionAddress(
        uint256 stakingScheduleId,
        address collectionAddress,
        uint256 startIndex,
        uint256 pageSize
    ) external view returns (uint256[] memory tokenIds, StakedToken[] memory stakedTokens) {
        if (pageSize > MAX_PAGE_SIZE) revert InvalidPageSize();

        uint256[] memory allTokenIds = stakedTokensBySchedule[stakingScheduleId][collectionAddress];

        uint256 endIndex = startIndex + pageSize;
        if (endIndex > allTokenIds.length) {
            endIndex = allTokenIds.length;
        }
        uint256 resultSize = endIndex - startIndex;

        tokenIds = new uint256[](resultSize);
        stakedTokens = new StakedToken[](resultSize);

        for (uint256 i = 0; i < resultSize; ) {
            tokenIds[i] = allTokenIds[startIndex + i];
            stakedTokens[i] = stakedTokensData[collectionAddress][allTokenIds[startIndex + i]];
            unchecked {
                ++i;
            }
        }
    }

    /// @notice Retrieve user's staked tokens for a collection.
    /// @param owner  Address to pull token IDs for.
    /// @param collectionAddress  Collection address of Token.
    function getUserStakedTokenByCollection(address owner, address collectionAddress) external view returns (uint256[] memory tokenIds) {
        return stakedTokensByOwner[owner][collectionAddress];
    }

    /// @notice Retrieve Token Data of a collection -> token ID.
    /// @param collectionAddress  Collection address of Token.
    /// @param tokenId  Token ID to retrieve stake status for.
    function getStakedTokenData(address collectionAddress, uint256 tokenId) external view returns (StakedToken memory stakedToken) {
        return stakedTokensData[collectionAddress][tokenId];
    }

    /// @notice Retrieves total balance of user's tokens in contract.
    /// @param owner  Address to pull token count for.
    function balanceOf(address owner) public view returns (uint256 balance) {
        return _balance(owner);
    }

    /// @notice Retrieves total balance of users tokens in contract.
    /// @param owners  Addresses to pull token count for.
    function balancesOf(address[] calldata owners) public view returns (uint256[] memory balances) {
        balances = new uint256[](owners.length);

        for (uint256 i; i < owners.length; ) {
            balances[i] = _balance(owners[i]);
            unchecked {
                i++;
            }
        }
    }

    /// @notice Pulls all tokens that was staked by a specific owner.
    /// @dev Requires double pass due to having to setup a fixed length array.
    /// @param owner  Owner to pull tokens for.
    function getUserStakedTokens(address owner) external view returns (UserStakedTokenInfo[] memory userStakedTokens) {
        uint256 balance = balanceOf(owner);
        userStakedTokens = new UserStakedTokenInfo[](balance);
        uint256 index;

        uint256 stakingScheduleIdsLength = stakingScheduleIds.length;
        for (uint256 i; i < stakingScheduleIdsLength; ) {
            uint256 scheduleId = stakingScheduleIds[i];
            StakingSchedule memory stakingSchedule = stakingSchedules[scheduleId];

            for (uint256 j; j < stakingSchedule.whitelistedCollections.length; ) {
                address collectionAddress = stakingSchedule.whitelistedCollections[j];
                uint256[] memory tokenIds = stakedTokensByOwner[owner][collectionAddress];

                for (uint256 k; k < tokenIds.length; ) {
                    uint256 tokenId = tokenIds[k];
                    StakedToken memory stakedToken = stakedTokensData[collectionAddress][tokenId];

                    if (stakedToken.stakeScheduleId == scheduleId) {
                        userStakedTokens[index] = UserStakedTokenInfo({
                            collectionAddress: collectionAddress,
                            tokenId: tokenId,
                            stakeStartTime: stakedToken.stakeStartTime,
                            stakeScheduleId: stakedToken.stakeScheduleId
                        });

                        index++;

                        /* Exit after filling array. */
                        if (index == balance) {
                            return userStakedTokens;
                        }
                    }

                    unchecked {
                        ++k;
                    }
                }

                unchecked {
                    ++j;
                }
            }

            unchecked {
                ++i;
            }
        }
    }

    /*///////////////////////////////////////////////////////////////
                              ERC721
    //////////////////////////////////////////////////////////////*/

    function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

File 2 of 15 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
    struct AccessControlStorage {
        mapping(bytes32 role => RoleData) _roles;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;

    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
        assembly {
            $.slot := AccessControlStorageLocation
        }
    }

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    function __AccessControl_init() internal onlyInitializing {
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        return $._roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        AccessControlStorage storage $ = _getAccessControlStorage();
        bytes32 previousAdminRole = getRoleAdmin(role);
        $._roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (!hasRole(role, account)) {
            $._roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (hasRole(role, account)) {
            $._roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 3 of 15 : AccessControlDefaultAdminRulesUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol)

pragma solidity ^0.8.20;

import {IAccessControlDefaultAdminRules} from "@openzeppelin/contracts/access/extensions/IAccessControlDefaultAdminRules.sol";
import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IERC5313} from "@openzeppelin/contracts/interfaces/IERC5313.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows specifying special rules to manage
 * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions
 * over other roles that may potentially have privileged rights in the system.
 *
 * If a specific role doesn't have an admin role assigned, the holder of the
 * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it.
 *
 * This contract implements the following risk mitigations on top of {AccessControl}:
 *
 * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced.
 * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account.
 * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.
 * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}.
 * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`.
 *
 * Example usage:
 *
 * ```solidity
 * contract MyToken is AccessControlDefaultAdminRules {
 *   constructor() AccessControlDefaultAdminRules(
 *     3 days,
 *     msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder
 *    ) {}
 * }
 * ```
 */
abstract contract AccessControlDefaultAdminRulesUpgradeable is Initializable, IAccessControlDefaultAdminRules, IERC5313, AccessControlUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlDefaultAdminRules
    struct AccessControlDefaultAdminRulesStorage {
        // pending admin pair read/written together frequently
        address _pendingDefaultAdmin;
        uint48 _pendingDefaultAdminSchedule; // 0 == unset

        uint48 _currentDelay;
        address _currentDefaultAdmin;

        // pending delay pair read/written together frequently
        uint48 _pendingDelay;
        uint48 _pendingDelaySchedule; // 0 == unset
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlDefaultAdminRules")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlDefaultAdminRulesStorageLocation = 0xeef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698400;

    function _getAccessControlDefaultAdminRulesStorage() private pure returns (AccessControlDefaultAdminRulesStorage storage $) {
        assembly {
            $.slot := AccessControlDefaultAdminRulesStorageLocation
        }
    }

    /**
     * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address.
     */
    function __AccessControlDefaultAdminRules_init(uint48 initialDelay, address initialDefaultAdmin) internal onlyInitializing {
        __AccessControlDefaultAdminRules_init_unchained(initialDelay, initialDefaultAdmin);
    }

    function __AccessControlDefaultAdminRules_init_unchained(uint48 initialDelay, address initialDefaultAdmin) internal onlyInitializing {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        if (initialDefaultAdmin == address(0)) {
            revert AccessControlInvalidDefaultAdmin(address(0));
        }
        $._currentDelay = initialDelay;
        _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin);
    }

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

    /**
     * @dev See {IERC5313-owner}.
     */
    function owner() public view virtual returns (address) {
        return defaultAdmin();
    }

    ///
    /// Override AccessControl role management
    ///

    /**
     * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function grantRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert AccessControlEnforcedDefaultAdminRules();
        }
        super.grantRole(role, account);
    }

    /**
     * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert AccessControlEnforcedDefaultAdminRules();
        }
        super.revokeRole(role, account);
    }

    /**
     * @dev See {AccessControl-renounceRole}.
     *
     * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling
     * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule
     * has also passed when calling this function.
     *
     * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions.
     *
     * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin},
     * thereby disabling any functionality that is only available for it, and the possibility of reassigning a
     * non-administrated role.
     */
    function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControl) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
            (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin();
            if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) {
                revert AccessControlEnforcedDefaultAdminDelay(schedule);
            }
            delete $._pendingDefaultAdminSchedule;
        }
        super.renounceRole(role, account);
    }

    /**
     * @dev See {AccessControl-_grantRole}.
     *
     * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the
     * role has been previously renounced.
     *
     * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE`
     * assignable again. Make sure to guarantee this is the expected behavior in your implementation.
     */
    function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        if (role == DEFAULT_ADMIN_ROLE) {
            if (defaultAdmin() != address(0)) {
                revert AccessControlEnforcedDefaultAdminRules();
            }
            $._currentDefaultAdmin = account;
        }
        return super._grantRole(role, account);
    }

    /**
     * @dev See {AccessControl-_revokeRole}.
     */
    function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
            delete $._currentDefaultAdmin;
        }
        return super._revokeRole(role, account);
    }

    /**
     * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert AccessControlEnforcedDefaultAdminRules();
        }
        super._setRoleAdmin(role, adminRole);
    }

    ///
    /// AccessControlDefaultAdminRules accessors
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdmin() public view virtual returns (address) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        return $._currentDefaultAdmin;
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        return ($._pendingDefaultAdmin, $._pendingDefaultAdminSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdminDelay() public view virtual returns (uint48) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        uint48 schedule = $._pendingDelaySchedule;
        return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? $._pendingDelay : $._currentDelay;
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        schedule = $._pendingDelaySchedule;
        return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? ($._pendingDelay, schedule) : (0, 0);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) {
        return 5 days;
    }

    ///
    /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _beginDefaultAdminTransfer(newAdmin);
    }

    /**
     * @dev See {beginDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _beginDefaultAdminTransfer(address newAdmin) internal virtual {
        uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay();
        _setPendingDefaultAdmin(newAdmin, newSchedule);
        emit DefaultAdminTransferScheduled(newAdmin, newSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _cancelDefaultAdminTransfer();
    }

    /**
     * @dev See {cancelDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _cancelDefaultAdminTransfer() internal virtual {
        _setPendingDefaultAdmin(address(0), 0);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function acceptDefaultAdminTransfer() public virtual {
        (address newDefaultAdmin, ) = pendingDefaultAdmin();
        if (_msgSender() != newDefaultAdmin) {
            // Enforce newDefaultAdmin explicit acceptance.
            revert AccessControlInvalidDefaultAdmin(_msgSender());
        }
        _acceptDefaultAdminTransfer();
    }

    /**
     * @dev See {acceptDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _acceptDefaultAdminTransfer() internal virtual {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        (address newAdmin, uint48 schedule) = pendingDefaultAdmin();
        if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) {
            revert AccessControlEnforcedDefaultAdminDelay(schedule);
        }
        _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin());
        _grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
        delete $._pendingDefaultAdmin;
        delete $._pendingDefaultAdminSchedule;
    }

    ///
    /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _changeDefaultAdminDelay(newDelay);
    }

    /**
     * @dev See {changeDefaultAdminDelay}.
     *
     * Internal function without access restriction.
     */
    function _changeDefaultAdminDelay(uint48 newDelay) internal virtual {
        uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay);
        _setPendingDelay(newDelay, newSchedule);
        emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _rollbackDefaultAdminDelay();
    }

    /**
     * @dev See {rollbackDefaultAdminDelay}.
     *
     * Internal function without access restriction.
     */
    function _rollbackDefaultAdminDelay() internal virtual {
        _setPendingDelay(0, 0);
    }

    /**
     * @dev Returns the amount of seconds to wait after the `newDelay` will
     * become the new {defaultAdminDelay}.
     *
     * The value returned guarantees that if the delay is reduced, it will go into effect
     * after a wait that honors the previously set delay.
     *
     * See {defaultAdminDelayIncreaseWait}.
     */
    function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) {
        uint48 currentDelay = defaultAdminDelay();

        // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up
        // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day
        // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new
        // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like
        // using milliseconds instead of seconds.
        //
        // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees
        // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled.
        // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days.
        return
            newDelay > currentDelay
                ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48
                : currentDelay - newDelay;
    }

    ///
    /// Private setters
    ///

    /**
     * @dev Setter of the tuple for pending admin and its schedule.
     *
     * May emit a DefaultAdminTransferCanceled event.
     */
    function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        (, uint48 oldSchedule) = pendingDefaultAdmin();

        $._pendingDefaultAdmin = newAdmin;
        $._pendingDefaultAdminSchedule = newSchedule;

        // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted.
        if (_isScheduleSet(oldSchedule)) {
            // Emit for implicit cancellations when another default admin was scheduled.
            emit DefaultAdminTransferCanceled();
        }
    }

    /**
     * @dev Setter of the tuple for pending delay and its schedule.
     *
     * May emit a DefaultAdminDelayChangeCanceled event.
     */
    function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private {
        AccessControlDefaultAdminRulesStorage storage $ = _getAccessControlDefaultAdminRulesStorage();
        uint48 oldSchedule = $._pendingDelaySchedule;

        if (_isScheduleSet(oldSchedule)) {
            if (_hasSchedulePassed(oldSchedule)) {
                // Materialize a virtual delay
                $._currentDelay = $._pendingDelay;
            } else {
                // Emit for implicit cancellations when another delay was scheduled.
                emit DefaultAdminDelayChangeCanceled();
            }
        }

        $._pendingDelay = newDelay;
        $._pendingDelaySchedule = newSchedule;
    }

    ///
    /// Private helpers
    ///

    /**
     * @dev Defines if an `schedule` is considered set. For consistency purposes.
     */
    function _isScheduleSet(uint48 schedule) private pure returns (bool) {
        return schedule != 0;
    }

    /**
     * @dev Defines if an `schedule` is considered passed. For consistency purposes.
     */
    function _hasSchedulePassed(uint48 schedule) private view returns (bool) {
        return schedule < block.timestamp;
    }
}

File 4 of 15 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

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

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

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

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

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

File 5 of 15 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 6 of 15 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../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);
 * }
 * ```
 */
abstract contract ERC165Upgradeable is Initializable, IERC165 {
    function __ERC165_init() internal onlyInitializing {
    }

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

File 7 of 15 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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 {
    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable
    struct PausableStorage {
        bool _paused;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;

    function _getPausableStorage() private pure returns (PausableStorage storage $) {
        assembly {
            $.slot := PausableStorageLocation
        }
    }

    /**
     * @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);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

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

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

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

File 8 of 15 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

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

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
    struct ReentrancyGuardStorage {
        uint256 _status;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
        assembly {
            $.slot := ReentrancyGuardStorageLocation
        }
    }

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        $._status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if ($._status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        $._status = ENTERED;
    }

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

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

File 9 of 15 : IAccessControlDefaultAdminRules.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlDefaultAdminRules.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev External interface of AccessControlDefaultAdminRules declared to support ERC165 detection.
 */
interface IAccessControlDefaultAdminRules is IAccessControl {
    /**
     * @dev The new default admin is not a valid default admin.
     */
    error AccessControlInvalidDefaultAdmin(address defaultAdmin);

    /**
     * @dev At least one of the following rules was violated:
     *
     * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself.
     * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time.
     * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps.
     */
    error AccessControlEnforcedDefaultAdminRules();

    /**
     * @dev The delay for transferring the default admin delay is enforced and
     * the operation must wait until `schedule`.
     *
     * NOTE: `schedule` can be 0 indicating there's no transfer scheduled.
     */
    error AccessControlEnforcedDefaultAdminDelay(uint48 schedule);

    /**
     * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next
     * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule`
     * passes.
     */
    event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule);

    /**
     * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule.
     */
    event DefaultAdminTransferCanceled();

    /**
     * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next
     * delay to be applied between default admin transfer after `effectSchedule` has passed.
     */
    event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule);

    /**
     * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass.
     */
    event DefaultAdminDelayChangeCanceled();

    /**
     * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder.
     */
    function defaultAdmin() external view returns (address);

    /**
     * @dev Returns a tuple of a `newAdmin` and an accept schedule.
     *
     * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role
     * by calling {acceptDefaultAdminTransfer}, completing the role transfer.
     *
     * A zero value only in `acceptSchedule` indicates no pending admin transfer.
     *
     * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced.
     */
    function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule);

    /**
     * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started.
     *
     * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set
     * the acceptance schedule.
     *
     * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this
     * function returns the new delay. See {changeDefaultAdminDelay}.
     */
    function defaultAdminDelay() external view returns (uint48);

    /**
     * @dev Returns a tuple of `newDelay` and an effect schedule.
     *
     * After the `schedule` passes, the `newDelay` will get into effect immediately for every
     * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.
     *
     * A zero value only in `effectSchedule` indicates no pending delay change.
     *
     * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay}
     * will be zero after the effect schedule.
     */
    function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule);

    /**
     * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance
     * after the current timestamp plus a {defaultAdminDelay}.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * Emits a DefaultAdminRoleChangeStarted event.
     */
    function beginDefaultAdminTransfer(address newAdmin) external;

    /**
     * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
     *
     * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * May emit a DefaultAdminTransferCanceled event.
     */
    function cancelDefaultAdminTransfer() external;

    /**
     * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
     *
     * After calling the function:
     *
     * - `DEFAULT_ADMIN_ROLE` should be granted to the caller.
     * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder.
     * - {pendingDefaultAdmin} should be reset to zero values.
     *
     * Requirements:
     *
     * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`.
     * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed.
     */
    function acceptDefaultAdminTransfer() external;

    /**
     * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting
     * into effect after the current timestamp plus a {defaultAdminDelay}.
     *
     * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this
     * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay}
     * set before calling.
     *
     * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then
     * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin}
     * complete transfer (including acceptance).
     *
     * The schedule is designed for two scenarios:
     *
     * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by
     * {defaultAdminDelayIncreaseWait}.
     * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`.
     *
     * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.
     */
    function changeDefaultAdminDelay(uint48 newDelay) external;

    /**
     * @dev Cancels a scheduled {defaultAdminDelay} change.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * May emit a DefaultAdminDelayChangeCanceled event.
     */
    function rollbackDefaultAdminDelay() external;

    /**
     * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay})
     * to take effect. Default to 5 days.
     *
     * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with
     * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds)
     * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can
     * be overrode for a custom {defaultAdminDelay} increase scheduling.
     *
     * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise,
     * there's a risk of setting a high new delay that goes into effect almost immediately without the
     * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
     */
    function defaultAdminDelayIncreaseWait() external view returns (uint48);
}

File 10 of 15 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

File 11 of 15 : IERC5313.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5313.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface for the Light Contract Ownership Standard.
 *
 * A standardized minimal interface required to identify an account that controls a contract
 */
interface IERC5313 {
    /**
     * @dev Gets the address of the owner.
     */
    function owner() external view returns (address);
}

File 12 of 15 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

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

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

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * 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 13 of 15 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

File 14 of 15 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

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

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

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

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

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

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 15 of 15 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @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.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @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) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(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) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(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) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(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) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(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) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(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) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        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) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        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) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, 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
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, 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
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, 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
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, 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
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, 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
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, 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
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"CollectionNotWhitelisted","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidCollectionAddress","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLockDuration","type":"error"},{"inputs":[],"name":"InvalidPageSize","type":"error"},{"inputs":[],"name":"InvalidSchedule","type":"error"},{"inputs":[],"name":"InvalidScheduleId","type":"error"},{"inputs":[],"name":"MismatchedArrays","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotOwner","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"ScheduleInactive","type":"error"},{"inputs":[],"name":"StakingDurationNotEnded","type":"error"},{"inputs":[],"name":"TokenNotStaked","type":"error"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"stakingScheduleId","type":"uint256"},{"components":[{"internalType":"uint64","name":"lockDuration","type":"uint64"},{"internalType":"address[]","name":"whitelistedCollections","type":"address[]"},{"internalType":"bool","name":"isActive","type":"bool"}],"indexed":false,"internalType":"struct ERC721Staking.StakingSchedule","name":"stakingSchedule","type":"tuple"}],"name":"StakingScheduleCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"stakingScheduleId","type":"uint256"},{"components":[{"internalType":"uint64","name":"lockDuration","type":"uint64"},{"internalType":"address[]","name":"whitelistedCollections","type":"address[]"},{"internalType":"bool","name":"isActive","type":"bool"}],"indexed":false,"internalType":"struct ERC721Staking.StakingSchedule","name":"stakingSchedule","type":"tuple"}],"name":"StakingScheduleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenEmergencyUnlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenEmergencyUnlockedAndTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"currentStakeStartTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newStakeStartTime","type":"uint256"}],"name":"TokenStakeStartTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakingScheduleId","type":"uint256"}],"name":"TokenStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"collectionAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEVELOPER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"}],"name":"balancesOf","outputs":[{"internalType":"uint256[]","name":"balances","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_collectionAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_stakingScheduleIds","type":"uint256[]"}],"name":"batchStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_collectionAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"batchUnstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_collectionAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_newStakeStartTimes","type":"uint256[]"}],"name":"batchUpdateTokenStakeStartTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"lockDuration","type":"uint64"},{"internalType":"address[]","name":"whitelistedCollections","type":"address[]"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct ERC721Staking.StakingSchedule","name":"_stakingSchedule","type":"tuple"}],"name":"createStakingSchedule","outputs":[{"internalType":"uint256","name":"stakingScheduleId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_collectionAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"emergencyUnlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_collectionAddresses","type":"address[]"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"emergencyUnlockAndTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getStakedTokenData","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"stakeStartTime","type":"uint256"},{"internalType":"uint256","name":"stakeScheduleId","type":"uint256"}],"internalType":"struct ERC721Staking.StakedToken","name":"stakedToken","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakingScheduleId","type":"uint256"},{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"startIndex","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getStakedTokenDataInScheduleByCollectionAddress","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"stakeStartTime","type":"uint256"},{"internalType":"uint256","name":"stakeScheduleId","type":"uint256"}],"internalType":"struct ERC721Staking.StakedToken[]","name":"stakedTokens","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakingScheduleId","type":"uint256"}],"name":"getStakingSchedule","outputs":[{"components":[{"internalType":"uint64","name":"lockDuration","type":"uint64"},{"internalType":"address[]","name":"whitelistedCollections","type":"address[]"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct ERC721Staking.StakingSchedule","name":"stakingSchedule","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakingScheduleIds","outputs":[{"internalType":"uint256[]","name":"scheduleIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakingSchedules","outputs":[{"internalType":"uint256[]","name":"allStakingScheduleIds","type":"uint256[]"},{"components":[{"internalType":"uint64","name":"lockDuration","type":"uint64"},{"internalType":"address[]","name":"whitelistedCollections","type":"address[]"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct ERC721Staking.StakingSchedule[]","name":"allStakingSchedules","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakingScheduleId","type":"uint256"},{"internalType":"address","name":"collectionAddress","type":"address"}],"name":"getTokenCountInScheduleByCollectionAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"stakingScheduleId","type":"uint256"},{"internalType":"address","name":"collectionAddress","type":"address"}],"name":"getTokensStakedInSchedule","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"collectionAddress","type":"address"}],"name":"getUserStakedTokenByCollection","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getUserStakedTokens","outputs":[{"components":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"stakeStartTime","type":"uint256"},{"internalType":"uint256","name":"stakeScheduleId","type":"uint256"}],"internalType":"struct ERC721Staking.UserStakedTokenInfo[]","name":"userStakedTokens","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_defaultAdminAddress","type":"address"},{"internalType":"address[]","name":"_developers","type":"address[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","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":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_stakingScheduleId","type":"uint256"},{"components":[{"internalType":"uint64","name":"lockDuration","type":"uint64"},{"internalType":"address[]","name":"whitelistedCollections","type":"address[]"},{"internalType":"bool","name":"isActive","type":"bool"}],"internalType":"struct ERC721Staking.StakingSchedule","name":"_stakingSchedule","type":"tuple"}],"name":"updateStakingSchedule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collectionAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_newStakeStartTime","type":"uint256"}],"name":"updateTokenStakeStartTime","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b506200001c62000022565b620000d6565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000735760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d35780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b613c5780620000e66000396000f3fe608060405234801561001057600080fd5b50600436106102695760003560e01c80639103a0e011610151578063ae1a01a2116100c3578063cefc142911610087578063cefc1429146105c3578063cf6eefb7146105cb578063d33137af146105f9578063d547741f1461060c578063d602b9fd1461061f578063f97ef5c01461062757600080fd5b8063ae1a01a21461053f578063c44c768c1461055f578063cab00e1914610595578063cc8463c8146105a8578063ce36d101146105b057600080fd5b80639e1510ce116101155780639e1510ce146104b75780639f799bcf146104ca578063a1eda53c146104ea578063a217fddf14610511578063a3c4bd7914610519578063a46e9e291461052c57600080fd5b80639103a0e01461045357806391d14854146104685780639433418f1461047b578063946d920414610491578063980434c8146104a457600080fd5b80633f4ba83a116101ea57806364a77ec1116101ae57806364a77ec1146103ea57806370a08231146103fd5780637e20bc2e146104105780638456cb591461042357806384ef8ffc1461042b5780638da5cb5b1461044b57600080fd5b80633f4ba83a1461038357806358ed9ff81461038b5780635c975abb146103ac578063634e93da146103c4578063649a5ec7146103d757600080fd5b8063248a9ca311610231578063248a9ca3146103095780632cafce661461032a5780632f2ff15d1461034a57806336568abe1461035d5780633d564e491461037057600080fd5b806301ffc9a71461026e578063022d63fb1461029657806305510d08146102b25780630aa6220b146102c7578063150b7a02146102d1575b600080fd5b61028161027c3660046131d6565b61063a565b60405190151581526020015b60405180910390f35b620697805b60405165ffffffffffff909116815260200161028d565b6102ba610665565b60405161028d919061323c565b6102cf6106bd565b005b6102f06102df366004613264565b630a85bd0160e11b95945050505050565b6040516001600160e01b0319909116815260200161028d565b61031c610317366004613302565b6106d3565b60405190815260200161028d565b61033d61033836600461331b565b6106f5565b60405161028d9190613347565b6102cf610358366004613371565b61076f565b6102cf61036b366004613371565b61079b565b6102cf61037e3660046133ec565b610864565b6102cf6108c1565b61039e610399366004613457565b6108e1565b60405161028d929190613494565b600080516020613bc28339815191525460ff16610281565b6102cf6103d2366004613512565b610b5a565b6102cf6103e536600461352f565b610b6e565b6102cf6103f836600461356f565b610b82565b61031c61040b366004613512565b610bd4565b6102ba61041e3660046135b5565b610bf2565b6102cf610cb4565b610433610cd4565b6040516001600160a01b03909116815260200161028d565b610433610cf0565b61031c600080516020613b6283398151915281565b610281610476366004613371565b610cff565b610483610d37565b60405161028d929190613670565b6102cf61049f3660046136e2565b610f2e565b61031c6104b2366004613736565b6111b9565b6102ba6104c536600461376a565b611246565b6104dd6104d8366004613302565b6112bf565b60405161028d9190613798565b6104f261138d565b6040805165ffffffffffff93841681529290911660208301520161028d565b61031c600081565b6102cf6105273660046137ab565b611400565b6102ba61053a366004613371565b611485565b61055261054d366004613512565b6114f7565b60405161028d9190613844565b61031c61056d366004613371565b60009182526004602090815260408084206001600160a01b0393909316845291905290205490565b6102cf6105a33660046137ab565b61181b565b61029b611905565b6102cf6105be3660046133ec565b611983565b6102cf611ad5565b6105d3611b15565b604080516001600160a01b03909316835265ffffffffffff90911660208301520161028d565b6102cf6106073660046138b1565b611b43565b6102cf61061a366004613371565b611b79565b6102cf611ba1565b6102cf6106353660046133ec565b611bb4565b60006001600160e01b031982166318a4c3c360e11b148061065f575061065f82611cf7565b92915050565b606060008054806020026020016040519081016040528092919081815260200182805480156106b357602002820191906000526020600020905b81548152602001906001019080831161069f575b5050505050905090565b60006106c881611d2c565b6106d0611d36565b50565b6000908152600080516020613ba2833981519152602052604090206001015490565b610722604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b506001600160a01b03918216600090815260066020908152604080832093835292815290829020825160608101845281549094168452600181015491840191909152600201549082015290565b8161078d57604051631fe1e13d60e11b815260040160405180910390fd5b6107978282611d43565b5050565b600080516020613b82833981519152821580156107d057506107bb610cd4565b6001600160a01b0316826001600160a01b0316145b15610855576000806107e0611b15565b90925090506001600160a01b038216151580610802575065ffffffffffff8116155b8061081557504265ffffffffffff821610155b15610842576040516319ca5ebb60e01b815265ffffffffffff821660048201526024015b60405180910390fd5b5050805465ffffffffffff60a01b191681555b61085f8383611d5f565b505050565b61086c611d92565b610874611dca565b82818082146108965760405163a121188760e01b815260040160405180910390fd5b6108a286868686611dfb565b50506108bb6001600080516020613be283398151915255565b50505050565b600080516020613b628339815191526108d981611d2c565b6106d0611fb4565b6060806103e8831115610907576040516372dbed9760e11b815260040160405180910390fd5b60008681526004602090815260408083206001600160a01b038916845282528083208054825181850281018501909352808352919290919083018282801561096e57602002820191906000526020600020905b81548152602001906001019080831161095a575b505050505090506000848661098391906138fc565b90508151811115610992575080515b600061099e878361390f565b9050806001600160401b038111156109b8576109b8613922565b6040519080825280602002602001820160405280156109e1578160200160208202803683370190505b509450806001600160401b038111156109fc576109fc613922565b604051908082528060200260200182016040528015610a5a57816020015b610a47604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b815260200190600190039081610a1a5790505b50935060005b81811015610b4d5783610a73828a6138fc565b81518110610a8357610a83613938565b6020026020010151868281518110610a9d57610a9d613938565b6020908102919091018101919091526001600160a01b038a1660009081526006909152604081209085610ad0848c6138fc565b81518110610ae057610ae0613938565b6020908102919091018101518252818101929092526040908101600020815160608101835281546001600160a01b0316815260018201549381019390935260020154908201528551869083908110610b3a57610b3a613938565b6020908102919091010152600101610a60565b5050505094509492505050565b6000610b6581611d2c565b61079782612014565b6000610b7981611d2c565b61079782612087565b6000610b8d81611d2c565b610b9783836120f7565b827ff4a19234515a920376348043be06222a7d0130071ee66e9c165cb605aa51e2d283604051610bc7919061397a565b60405180910390a2505050565b6001600160a01b03811660009081526001602052604081205461065f565b6060816001600160401b03811115610c0c57610c0c613922565b604051908082528060200260200182016040528015610c35578160200160208202803683370190505b50905060005b82811015610cad57610c88848483818110610c5857610c58613938565b9050602002016020810190610c6d9190613512565b6001600160a01b031660009081526001602052604090205490565b828281518110610c9a57610c9a613938565b6020908102919091010152600101610c3b565b5092915050565b600080516020613b62833981519152610ccc81611d2c565b6106d061243e565b600080516020613c02833981519152546001600160a01b031690565b6000610cfa610cd4565b905090565b6000918252600080516020613ba2833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000546060908190806001600160401b03811115610d5757610d57613922565b604051908082528060200260200182016040528015610d80578160200160208202803683370190505b509250806001600160401b03811115610d9b57610d9b613922565b604051908082528060200260200182016040528015610dfb57816020015b610de8604051806060016040528060006001600160401b03168152602001606081526020016000151581525090565b815260200190600190039081610db95790505b50915060005b81811015610f285760008181548110610e1c57610e1c613938565b9060005260206000200154848281518110610e3957610e39613938565b60200260200101818152505060036000808381548110610e5b57610e5b613938565b600091825260208083209091015483528281019390935260409182019020815160608101835281546001600160401b031681526001820180548451818702810187019095528085529194929385840193909290830182828015610ee757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ec9575b50505091835250506002919091015460ff1615156020909101528351849083908110610f1557610f15613938565b6020908102919091010152600101610e01565b50509091565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610f735750825b90506000826001600160401b03166001148015610f8f5750303b155b905081158015610f9d575080155b15610fbb5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610fe557845460ff60401b1916600160401b1785555b610fed612487565b610ff5612497565b61100262015180896124a7565b61101a600080516020613b62833981519152896124b9565b5060005b8681101561106d57611064600080516020613b6283398151915289898481811061104a5761104a613938565b905060200201602081019061105f9190613512565b6124b9565b5060010161101e565b506040805160608101825260008082528251818152602080820185528084019182526001948401949094529080526003835281517f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff805467ffffffffffffffff19166001600160401b039092169190911781559051805192939192611115927f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92f00920190613165565b50604091909101516002909101805460ff1916911515919091179055600080546001810182558180527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563015561116961243e565b83156111af57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b6000806111c581611d2c565b60005491506111d482846120f7565b600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630182905560405182907f581474dfd0750f7d6a71bdb3369e042e0c32a9e78f5759ca5b54123ca48932859061123890869061397a565b60405180910390a250919050565b6001600160a01b0380831660009081526005602090815260408083209385168352928152908290208054835181840281018401909452808452606093928301828280156112b257602002820191906000526020600020905b81548152602001906001019080831161129e575b5050505050905092915050565b6112ee604051806060016040528060006001600160401b03168152602001606081526020016000151581525090565b600082815260036020908152604091829020825160608101845281546001600160401b031681526001820180548551818602810186019096528086529194929385810193929083018282801561136d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161134f575b50505091835250506002919091015460ff16151560209091015292915050565b600080516020613c0283398151915254600090600160d01b900465ffffffffffff16600080516020613b8283398151915281158015906113d557504265ffffffffffff831610155b6113e1576000806113f7565b6001810154600160a01b900465ffffffffffff16825b92509250509091565b611408611d92565b611410611dca565b80838082146114325760405163a121188760e01b815260040160405180910390fd5b82878082146114545760405163a121188760e01b815260040160405180910390fd5b6114628a8a8a8a8a8a612530565b5050505061147d6001600080516020613be283398151915255565b505050505050565b60008281526004602090815260408083206001600160a01b03851684528252918290208054835181840281018401909452808452606093928301828280156112b2576020028201919060005260206000209081548152602001906001019080831161129e575050505050905092915050565b6060600061150483610bd4565b9050806001600160401b0381111561151e5761151e613922565b60405190808252806020026020018201604052801561158357816020015b611570604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b81526020019060019003908161153c5790505b506000805491935090815b818110156118125760008082815481106115aa576115aa613938565b6000918252602080832090910154808352600382526040808420815160608101835281546001600160401b0316815260018201805484518188028101880190955280855294975090949193858301939283018282801561163357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611615575b50505091835250506002919091015460ff161515602090910152905060005b8160200151518110156118045760008260200151828151811061167757611677613938565b6020908102919091018101516001600160a01b03808d166000908152600584526040808220928416825291845281812080548351818702810187019094528084529395509093919290918301828280156116f057602002820191906000526020600020905b8154815260200190600101908083116116dc575b5050505050905060005b81518110156117f657600082828151811061171757611717613938565b6020908102919091018101516001600160a01b038087166000908152600684526040808220848352855290819020815160608101835281549093168352600181015494830194909452600290930154928101839052909250908890036117ec576040518060800160405280866001600160a01b031681526020018381526020018260200151815260200182604001518152508d8c815181106117bb576117bb613938565b60200260200101819052508a806117d190613a41565b9b50508b8b036117ec57505050505050505050505050919050565b50506001016116fa565b508260010192505050611652565b50826001019250505061158e565b50505050919050565b611823611d92565b600061182e81611d2c565b85848082146118505760405163a121188760e01b815260040160405180910390fd5b87848082146118725760405163a121188760e01b815260040160405180910390fd5b8960005b818110156118e7576118df8d8d8381811061189357611893613938565b90506020020160208101906118a89190613512565b8c8c848181106118ba576118ba613938565b905060200201358b8b858181106118d3576118d3613938565b905060200201356127d2565b600101611876565b5050505050505061147d6001600080516020613be283398151915255565b600080516020613c0283398151915254600090600080516020613b8283398151915290600160d01b900465ffffffffffff16801580159061194d57504265ffffffffffff8216105b611967578154600160d01b900465ffffffffffff1661197c565b6001820154600160a01b900465ffffffffffff165b9250505090565b61198b611d92565b82818082146119ad5760405163a121188760e01b815260040160405180910390fd5b60006119b881611d2c565b8560005b81811015611ab95760008989838181106119d8576119d8613938565b90506020020160208101906119ed9190613512565b90506000888884818110611a0357611a03613938565b6001600160a01b038581166000908152600660209081526040808320948202969096013580835293905293909320600281015490549194509216905080611a5d57604051630a49bbc360e21b815260040160405180910390fd5b611a6984848484612883565b82846001600160a01b0316826001600160a01b03167fdff3a2b820f7c5b6a198a1f89433db7e547d4fbc4a4eb5434f523960addc81b360405160405180910390a4846001019450505050506119bc565b50505050506108bb6001600080516020613be283398151915255565b6000611adf611b15565b509050336001600160a01b03821614611b0d57604051636116401160e11b8152336004820152602401610839565b6106d06128f3565b600080516020613b82833981519152546001600160a01b03811691600160a01b90910465ffffffffffff1690565b611b4b611d92565b6000611b5681611d2c565b611b618484846127d2565b5061085f6001600080516020613be283398151915255565b81611b9757604051631fe1e13d60e11b815260040160405180910390fd5b6107978282612990565b6000611bac81611d2c565b6106d06129ac565b611bbc611d92565b8281808214611bde5760405163a121188760e01b815260040160405180910390fd5b6000611be981611d2c565b8560005b81811015611ab9576000898983818110611c0957611c09613938565b9050602002016020810190611c1e9190613512565b90506000888884818110611c3457611c34613938565b6001600160a01b038581166000908152600660209081526040808320948202969096013580835293905293909320600281015490549194509216905080611c8e57604051630a49bbc360e21b815260040160405180910390fd5b611c9a828585846129b7565b611ca76000858584612bc7565b82846001600160a01b0316826001600160a01b03167f01d992c19f1eab82c4dbe8cbb29ff00405ecfb8e83e595aa280e4a54e088694a60405160405180910390a484600101945050505050611bed565b60006001600160e01b03198216637965db0b60e01b148061065f57506301ffc9a760e01b6001600160e01b031983161461065f565b6106d08133612ca3565b611d41600080612cdc565b565b611d4c826106d3565b611d5581611d2c565b6108bb83836124b9565b6001600160a01b0381163314611d885760405163334bd91960e11b815260040160405180910390fd5b61085f8282612db7565b600080516020613be2833981519152805460011901611dc457604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b600080516020613bc28339815191525460ff1615611d415760405163d93c066560e01b815260040160405180910390fd5b8260005b8181101561147d576000868683818110611e1b57611e1b613938565b9050602002016020810190611e309190613512565b90506000858584818110611e4657611e46613938565b6001600160a01b0385811660009081526006602090815260408083209482029690960135808352939052939093206002810154905491945092169050611e9f57604051630a49bbc360e21b815260040160405180910390fd5b6001600160a01b03808416600090815260066020908152604080832086845290915290205416338114611ee5576040516330cd747160e01b815260040160405180910390fd5b6001600160a01b03841660009081526006602090815260408083208684528252808320600101548584526003909252909120546001600160401b0316611f2b81836138fc565b421015611f4b576040516320a6f12d60e01b815260040160405180910390fd5b611f5786868686612883565b60405185906001600160a01b0388169033907f8210728e7c071f615b840ee026032693858fbcd5e5359e67e438c890f59e562090600090a4866001019650505050505050611dff565b6001600080516020613be283398151915255565b611fbc612e10565b600080516020613bc2833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b600061201e611905565b61202742612e40565b6120319190613a5a565b905061203d8282612e77565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b600061209282612f04565b61209b42612e40565b6120a59190613a5a565b90506120b18282612cdc565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b910160405180910390a15050565b60008211801561211a575061210f6020820182613a79565b6001600160401b0316155b1561213857604051630f962f3d60e31b815260040160405180910390fd5b60005b6121486020830183613a94565b90508110156121b45760006121606020840184613a94565b8381811061217057612170613938565b90506020020160208101906121859190613512565b6001600160a01b0316036121ac5760405163db781b8360e01b815260040160405180910390fd5b60010161213b565b506000828152600360209081526040808320815160608101835281546001600160401b03168152600182018054845181870281018701909552808552919492938584019390929083018282801561223457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612216575b50505091835250506002919091015460ff1615156020918201526040805160608101909152919250819061226a90850185613a79565b6001600160401b031681526020018380602001906122889190613a94565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016122cf6060850160408601613add565b1515905260008481526003602090815260409091208251815467ffffffffffffffff19166001600160401b03909116178155828201518051919261231b92600185019290910190613165565b50604091909101516002909101805460ff191691151591909117905560005b8160200151518110156123ae5760006002600086815260200190815260200160002060008460200151848151811061237457612374613938565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905560010161233a565b5060005b6123bf6020840184613a94565b90508110156108bb576000848152600260209081526040822060019290916123e990870187613a94565b858181106123f9576123f9613938565b905060200201602081019061240e9190613512565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016123b2565b612446611dca565b600080516020613bc2833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611ff6565b61248f612f53565b611d41612f9c565b61249f612f53565b611d41612fbd565b6124af612f53565b6107978282612fc5565b6000600080516020613b828339815191528361251e5760006124d9610cd4565b6001600160a01b03161461250057604051631fe1e13d60e11b815260040160405180910390fd5b6001810180546001600160a01b0319166001600160a01b0385161790555b612528848461302e565b949350505050565b8060005b818110156111af57600088888381811061255057612550613938565b90506020020160208101906125659190613512565b9050600087878481811061257b5761257b613938565b905060200201359050600086868581811061259857612598613938565b905060200201359050806000036125c257604051630151be2560e11b815260040160405180910390fd5b6000818152600360205260408120546001600160401b031690036125f957604051631b742d9d60e31b815260040160405180910390fd5b60008181526003602052604081206002015460ff161515900361262f5760405163bf3388b960e01b815260040160405180910390fd5b60008181526002602090815260408083206001600160a01b038716845290915290205460ff1661267257604051632f579acf60e11b815260040160405180910390fd5b6040516331a9108f60e11b81526004810183905233906001600160a01b03851690636352211e90602401602060405180830381865afa1580156126b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126dd9190613af8565b6001600160a01b031614612704576040516330cd747160e01b815260040160405180910390fd5b61271081848433612bc7565b604051632142170760e11b8152336004820152306024820152604481018390526001600160a01b038416906342842e0e90606401600060405180830381600087803b15801561275e57600080fd5b505af1158015612772573d6000803e3d6000fd5b5050505081836001600160a01b0316336001600160a01b03167fd8e8011c01a346ba74a0fa83d93d6d910a03355e9ea9efb6c7f95518428b88d9846040516127bc91815260200190565b60405180910390a4836001019350505050612534565b6001600160a01b0383811660009081526006602090815260408083208684529091529020541661281557604051630a49bbc360e21b815260040160405180910390fd5b6001600160a01b0383166000818152600660209081526040808320868452825291829020600101805490859055825181815291820185905292859290917f7a660c85503813cab2ecd35686a6998f9ee34da67f42bf87fbb4ca3d4eeaa564910160405180910390a350505050565b61288f828585846129b7565b604051632142170760e11b81523060048201526001600160a01b038281166024830152604482018590528516906342842e0e90606401600060405180830381600087803b1580156128df57600080fd5b505af11580156111af573d6000803e3d6000fd5b600080516020613b8283398151915260008061290d611b15565b915091506129228165ffffffffffff16151590565b158061293657504265ffffffffffff821610155b1561295e576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610839565b612970600061296b610cd4565b612db7565b5061297c6000836124b9565b505081546001600160d01b03191690915550565b612999826106d3565b6129a281611d2c565b6108bb8383612db7565b611d41600080612e77565b6001600160a01b03811660009081526001602052604081208054916129db83613b15565b909155505060008481526004602090815260408083206001600160a01b03871684529091528120905b8154811015612aae5783828281548110612a2057612a20613938565b906000526020600020015403612aa65781548290612a409060019061390f565b81548110612a5057612a50613938565b9060005260206000200154828281548110612a6d57612a6d613938565b906000526020600020018190555081805480612a8b57612a8b613b2c565b60019003818190600052602060002001600090559055612aae565b600101612a04565b506001600160a01b0380831660009081526005602090815260408083209388168352929052908120905b8154811015612b825784828281548110612af457612af4613938565b906000526020600020015403612b7a5781548290612b149060019061390f565b81548110612b2457612b24613938565b9060005260206000200154828281548110612b4157612b41613938565b906000526020600020018190555081805480612b5f57612b5f613b2c565b60019003818190600052602060002001600090559055612b82565b600101612ad8565b5050506001600160a01b03909216600090815260066020908152604080832093835292905290812080546001600160a01b031916815560018101829055600201555050565b6001600160a01b0381166000908152600160205260408120805491612beb83613a41565b909155505060008481526004602090815260408083206001600160a01b03968716808552908352818420805460018082018355918652848620018790559487168085526005845282852082865284528285208054808801825590865284862001879055825160608101845290815242818501908152818401998a529185526006845282852096855295909252909120925183546001600160a01b03191694169390931782559151918101919091559051600290910155565b612cad8282610cff565b6107975760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610839565b600080516020613c0283398151915254600080516020613b8283398151915290600160d01b900465ffffffffffff168015612d79574265ffffffffffff82161015612d4f57600182015482546001600160d01b0316600160a01b90910465ffffffffffff16600160d01b02178255612d79565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b5060010180546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b6000600080516020613b8283398151915283158015612dee5750612dd9610cd4565b6001600160a01b0316836001600160a01b0316145b15612e06576001810180546001600160a01b03191690555b61252884846130d3565b600080516020613bc28339815191525460ff16611d4157604051638dfc202b60e01b815260040160405180910390fd5b600065ffffffffffff821115612e73576040516306dfcc6560e41b81526030600482015260248101839052604401610839565b5090565b600080516020613b828339815191526000612e90611b15565b835465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b038816171784559150612ed090508165ffffffffffff16151590565b156108bb576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a150505050565b600080612f0f611905565b90508065ffffffffffff168365ffffffffffff1611612f3757612f328382613b42565b612f4c565b612f4c65ffffffffffff84166206978061314f565b9392505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16611d4157604051631afcd79f60e31b815260040160405180910390fd5b612fa4612f53565b600080516020613bc2833981519152805460ff19169055565b611fa0612f53565b612fcd612f53565b600080516020613b828339815191526001600160a01b03821661300657604051636116401160e11b815260006004820152602401610839565b80546001600160d01b0316600160d01b65ffffffffffff8516021781556108bb6000836124b9565b6000600080516020613ba28339815191526130498484610cff565b6130c9576000848152602082815260408083206001600160a01b03871684529091529020805460ff1916600117905561307f3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505061065f565b600091505061065f565b6000600080516020613ba28339815191526130ee8484610cff565b156130c9576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4600191505061065f565b600081831061315e5781612f4c565b5090919050565b8280548282559060005260206000209081019282156131ba579160200282015b828111156131ba57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613185565b50612e739291505b80821115612e7357600081556001016131c2565b6000602082840312156131e857600080fd5b81356001600160e01b031981168114612f4c57600080fd5b60008151808452602080850194506020840160005b8381101561323157815187529582019590820190600101613215565b509495945050505050565b602081526000612f4c6020830184613200565b6001600160a01b03811681146106d057600080fd5b60008060008060006080868803121561327c57600080fd5b85356132878161324f565b945060208601356132978161324f565b93506040860135925060608601356001600160401b03808211156132ba57600080fd5b818801915088601f8301126132ce57600080fd5b8135818111156132dd57600080fd5b8960208285010111156132ef57600080fd5b9699959850939650602001949392505050565b60006020828403121561331457600080fd5b5035919050565b6000806040838503121561332e57600080fd5b82356133398161324f565b946020939093013593505050565b81516001600160a01b0316815260208083015190820152604080830151908201526060810161065f565b6000806040838503121561338457600080fd5b8235915060208301356133968161324f565b809150509250929050565b60008083601f8401126133b357600080fd5b5081356001600160401b038111156133ca57600080fd5b6020830191508360208260051b85010111156133e557600080fd5b9250929050565b6000806000806040858703121561340257600080fd5b84356001600160401b038082111561341957600080fd5b613425888389016133a1565b9096509450602087013591508082111561343e57600080fd5b5061344b878288016133a1565b95989497509550505050565b6000806000806080858703121561346d57600080fd5b84359350602085013561347f8161324f565b93969395505050506040820135916060013590565b6040815260006134a76040830185613200565b82810360208481019190915284518083528582019282019060005b81811015613505576134f283865180516001600160a01b0316825260208082015190830152604090810151910152565b93830193606092909201916001016134c2565b5090979650505050505050565b60006020828403121561352457600080fd5b8135612f4c8161324f565b60006020828403121561354157600080fd5b813565ffffffffffff81168114612f4c57600080fd5b60006060828403121561356957600080fd5b50919050565b6000806040838503121561358257600080fd5b8235915060208301356001600160401b0381111561359f57600080fd5b6135ab85828601613557565b9150509250929050565b600080602083850312156135c857600080fd5b82356001600160401b038111156135de57600080fd5b6135ea858286016133a1565b90969095509350505050565b6000606083016001600160401b03835116845260208084015160606020870152828151808552608088019150602083019450600092505b808310156136565784516001600160a01b0316825293830193600192909201919083019061362d565b506040860151151560408801528094505050505092915050565b6040815260006136836040830185613200565b6020838203818501528185518084528284019150828160051b85010183880160005b838110156136d357601f198784030185526136c18383516135f6565b948601949250908501906001016136a5565b50909998505050505050505050565b6000806000604084860312156136f757600080fd5b83356137028161324f565b925060208401356001600160401b0381111561371d57600080fd5b613729868287016133a1565b9497909650939450505050565b60006020828403121561374857600080fd5b81356001600160401b0381111561375e57600080fd5b61252884828501613557565b6000806040838503121561377d57600080fd5b82356137888161324f565b915060208301356133968161324f565b602081526000612f4c60208301846135f6565b600080600080600080606087890312156137c457600080fd5b86356001600160401b03808211156137db57600080fd5b6137e78a838b016133a1565b9098509650602089013591508082111561380057600080fd5b61380c8a838b016133a1565b9096509450604089013591508082111561382557600080fd5b5061383289828a016133a1565b979a9699509497509295939492505050565b602080825282518282018190526000919060409081850190868401855b828110156138a457815180516001600160a01b03168552868101518786015285810151868601526060908101519085015260809093019290850190600101613861565b5091979650505050505050565b6000806000606084860312156138c657600080fd5b83356138d18161324f565b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561065f5761065f6138e6565b8181038181111561065f5761065f6138e6565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b80356001600160401b038116811461396557600080fd5b919050565b8035801515811461396557600080fd5b60006020808352608083016001600160401b03806139978761394e565b168386015282860135601e198736030181126139b257600080fd5b86018381019035828111156139c657600080fd5b8060051b36038213156139d857600080fd5b60606040880152928390529160a0860191506000905b80821015613a20578335613a018161324f565b6001600160a01b031683529284019291840191600191909101906139ee565b5050613a2e6040870161396a565b8015156060870152925095945050505050565b600060018201613a5357613a536138e6565b5060010190565b65ffffffffffff818116838216019080821115610cad57610cad6138e6565b600060208284031215613a8b57600080fd5b612f4c8261394e565b6000808335601e19843603018112613aab57600080fd5b8301803591506001600160401b03821115613ac557600080fd5b6020019150600581901b36038213156133e557600080fd5b600060208284031215613aef57600080fd5b612f4c8261396a565b600060208284031215613b0a57600080fd5b8151612f4c8161324f565b600081613b2457613b246138e6565b506000190190565b634e487b7160e01b600052603160045260246000fd5b65ffffffffffff828116828216039080821115610cad57610cad6138e656fe2714cbbaddbb71bcae9366d8bf7770636ec7ae63227b573986d2f54fffacb39deef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d869840002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00eef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698401a2646970667358221220441455bd861659cec65b5b4db22a27ed445161a2ac88fb9be6db1f652cc4f29464736f6c63430008180033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102695760003560e01c80639103a0e011610151578063ae1a01a2116100c3578063cefc142911610087578063cefc1429146105c3578063cf6eefb7146105cb578063d33137af146105f9578063d547741f1461060c578063d602b9fd1461061f578063f97ef5c01461062757600080fd5b8063ae1a01a21461053f578063c44c768c1461055f578063cab00e1914610595578063cc8463c8146105a8578063ce36d101146105b057600080fd5b80639e1510ce116101155780639e1510ce146104b75780639f799bcf146104ca578063a1eda53c146104ea578063a217fddf14610511578063a3c4bd7914610519578063a46e9e291461052c57600080fd5b80639103a0e01461045357806391d14854146104685780639433418f1461047b578063946d920414610491578063980434c8146104a457600080fd5b80633f4ba83a116101ea57806364a77ec1116101ae57806364a77ec1146103ea57806370a08231146103fd5780637e20bc2e146104105780638456cb591461042357806384ef8ffc1461042b5780638da5cb5b1461044b57600080fd5b80633f4ba83a1461038357806358ed9ff81461038b5780635c975abb146103ac578063634e93da146103c4578063649a5ec7146103d757600080fd5b8063248a9ca311610231578063248a9ca3146103095780632cafce661461032a5780632f2ff15d1461034a57806336568abe1461035d5780633d564e491461037057600080fd5b806301ffc9a71461026e578063022d63fb1461029657806305510d08146102b25780630aa6220b146102c7578063150b7a02146102d1575b600080fd5b61028161027c3660046131d6565b61063a565b60405190151581526020015b60405180910390f35b620697805b60405165ffffffffffff909116815260200161028d565b6102ba610665565b60405161028d919061323c565b6102cf6106bd565b005b6102f06102df366004613264565b630a85bd0160e11b95945050505050565b6040516001600160e01b0319909116815260200161028d565b61031c610317366004613302565b6106d3565b60405190815260200161028d565b61033d61033836600461331b565b6106f5565b60405161028d9190613347565b6102cf610358366004613371565b61076f565b6102cf61036b366004613371565b61079b565b6102cf61037e3660046133ec565b610864565b6102cf6108c1565b61039e610399366004613457565b6108e1565b60405161028d929190613494565b600080516020613bc28339815191525460ff16610281565b6102cf6103d2366004613512565b610b5a565b6102cf6103e536600461352f565b610b6e565b6102cf6103f836600461356f565b610b82565b61031c61040b366004613512565b610bd4565b6102ba61041e3660046135b5565b610bf2565b6102cf610cb4565b610433610cd4565b6040516001600160a01b03909116815260200161028d565b610433610cf0565b61031c600080516020613b6283398151915281565b610281610476366004613371565b610cff565b610483610d37565b60405161028d929190613670565b6102cf61049f3660046136e2565b610f2e565b61031c6104b2366004613736565b6111b9565b6102ba6104c536600461376a565b611246565b6104dd6104d8366004613302565b6112bf565b60405161028d9190613798565b6104f261138d565b6040805165ffffffffffff93841681529290911660208301520161028d565b61031c600081565b6102cf6105273660046137ab565b611400565b6102ba61053a366004613371565b611485565b61055261054d366004613512565b6114f7565b60405161028d9190613844565b61031c61056d366004613371565b60009182526004602090815260408084206001600160a01b0393909316845291905290205490565b6102cf6105a33660046137ab565b61181b565b61029b611905565b6102cf6105be3660046133ec565b611983565b6102cf611ad5565b6105d3611b15565b604080516001600160a01b03909316835265ffffffffffff90911660208301520161028d565b6102cf6106073660046138b1565b611b43565b6102cf61061a366004613371565b611b79565b6102cf611ba1565b6102cf6106353660046133ec565b611bb4565b60006001600160e01b031982166318a4c3c360e11b148061065f575061065f82611cf7565b92915050565b606060008054806020026020016040519081016040528092919081815260200182805480156106b357602002820191906000526020600020905b81548152602001906001019080831161069f575b5050505050905090565b60006106c881611d2c565b6106d0611d36565b50565b6000908152600080516020613ba2833981519152602052604090206001015490565b610722604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b506001600160a01b03918216600090815260066020908152604080832093835292815290829020825160608101845281549094168452600181015491840191909152600201549082015290565b8161078d57604051631fe1e13d60e11b815260040160405180910390fd5b6107978282611d43565b5050565b600080516020613b82833981519152821580156107d057506107bb610cd4565b6001600160a01b0316826001600160a01b0316145b15610855576000806107e0611b15565b90925090506001600160a01b038216151580610802575065ffffffffffff8116155b8061081557504265ffffffffffff821610155b15610842576040516319ca5ebb60e01b815265ffffffffffff821660048201526024015b60405180910390fd5b5050805465ffffffffffff60a01b191681555b61085f8383611d5f565b505050565b61086c611d92565b610874611dca565b82818082146108965760405163a121188760e01b815260040160405180910390fd5b6108a286868686611dfb565b50506108bb6001600080516020613be283398151915255565b50505050565b600080516020613b628339815191526108d981611d2c565b6106d0611fb4565b6060806103e8831115610907576040516372dbed9760e11b815260040160405180910390fd5b60008681526004602090815260408083206001600160a01b038916845282528083208054825181850281018501909352808352919290919083018282801561096e57602002820191906000526020600020905b81548152602001906001019080831161095a575b505050505090506000848661098391906138fc565b90508151811115610992575080515b600061099e878361390f565b9050806001600160401b038111156109b8576109b8613922565b6040519080825280602002602001820160405280156109e1578160200160208202803683370190505b509450806001600160401b038111156109fc576109fc613922565b604051908082528060200260200182016040528015610a5a57816020015b610a47604051806060016040528060006001600160a01b0316815260200160008152602001600081525090565b815260200190600190039081610a1a5790505b50935060005b81811015610b4d5783610a73828a6138fc565b81518110610a8357610a83613938565b6020026020010151868281518110610a9d57610a9d613938565b6020908102919091018101919091526001600160a01b038a1660009081526006909152604081209085610ad0848c6138fc565b81518110610ae057610ae0613938565b6020908102919091018101518252818101929092526040908101600020815160608101835281546001600160a01b0316815260018201549381019390935260020154908201528551869083908110610b3a57610b3a613938565b6020908102919091010152600101610a60565b5050505094509492505050565b6000610b6581611d2c565b61079782612014565b6000610b7981611d2c565b61079782612087565b6000610b8d81611d2c565b610b9783836120f7565b827ff4a19234515a920376348043be06222a7d0130071ee66e9c165cb605aa51e2d283604051610bc7919061397a565b60405180910390a2505050565b6001600160a01b03811660009081526001602052604081205461065f565b6060816001600160401b03811115610c0c57610c0c613922565b604051908082528060200260200182016040528015610c35578160200160208202803683370190505b50905060005b82811015610cad57610c88848483818110610c5857610c58613938565b9050602002016020810190610c6d9190613512565b6001600160a01b031660009081526001602052604090205490565b828281518110610c9a57610c9a613938565b6020908102919091010152600101610c3b565b5092915050565b600080516020613b62833981519152610ccc81611d2c565b6106d061243e565b600080516020613c02833981519152546001600160a01b031690565b6000610cfa610cd4565b905090565b6000918252600080516020613ba2833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000546060908190806001600160401b03811115610d5757610d57613922565b604051908082528060200260200182016040528015610d80578160200160208202803683370190505b509250806001600160401b03811115610d9b57610d9b613922565b604051908082528060200260200182016040528015610dfb57816020015b610de8604051806060016040528060006001600160401b03168152602001606081526020016000151581525090565b815260200190600190039081610db95790505b50915060005b81811015610f285760008181548110610e1c57610e1c613938565b9060005260206000200154848281518110610e3957610e39613938565b60200260200101818152505060036000808381548110610e5b57610e5b613938565b600091825260208083209091015483528281019390935260409182019020815160608101835281546001600160401b031681526001820180548451818702810187019095528085529194929385840193909290830182828015610ee757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ec9575b50505091835250506002919091015460ff1615156020909101528351849083908110610f1557610f15613938565b6020908102919091010152600101610e01565b50509091565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610f735750825b90506000826001600160401b03166001148015610f8f5750303b155b905081158015610f9d575080155b15610fbb5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610fe557845460ff60401b1916600160401b1785555b610fed612487565b610ff5612497565b61100262015180896124a7565b61101a600080516020613b62833981519152896124b9565b5060005b8681101561106d57611064600080516020613b6283398151915289898481811061104a5761104a613938565b905060200201602081019061105f9190613512565b6124b9565b5060010161101e565b506040805160608101825260008082528251818152602080820185528084019182526001948401949094529080526003835281517f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff805467ffffffffffffffff19166001600160401b039092169190911781559051805192939192611115927f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92f00920190613165565b50604091909101516002909101805460ff1916911515919091179055600080546001810182558180527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563015561116961243e565b83156111af57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050565b6000806111c581611d2c565b60005491506111d482846120f7565b600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5630182905560405182907f581474dfd0750f7d6a71bdb3369e042e0c32a9e78f5759ca5b54123ca48932859061123890869061397a565b60405180910390a250919050565b6001600160a01b0380831660009081526005602090815260408083209385168352928152908290208054835181840281018401909452808452606093928301828280156112b257602002820191906000526020600020905b81548152602001906001019080831161129e575b5050505050905092915050565b6112ee604051806060016040528060006001600160401b03168152602001606081526020016000151581525090565b600082815260036020908152604091829020825160608101845281546001600160401b031681526001820180548551818602810186019096528086529194929385810193929083018282801561136d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161134f575b50505091835250506002919091015460ff16151560209091015292915050565b600080516020613c0283398151915254600090600160d01b900465ffffffffffff16600080516020613b8283398151915281158015906113d557504265ffffffffffff831610155b6113e1576000806113f7565b6001810154600160a01b900465ffffffffffff16825b92509250509091565b611408611d92565b611410611dca565b80838082146114325760405163a121188760e01b815260040160405180910390fd5b82878082146114545760405163a121188760e01b815260040160405180910390fd5b6114628a8a8a8a8a8a612530565b5050505061147d6001600080516020613be283398151915255565b505050505050565b60008281526004602090815260408083206001600160a01b03851684528252918290208054835181840281018401909452808452606093928301828280156112b2576020028201919060005260206000209081548152602001906001019080831161129e575050505050905092915050565b6060600061150483610bd4565b9050806001600160401b0381111561151e5761151e613922565b60405190808252806020026020018201604052801561158357816020015b611570604051806080016040528060006001600160a01b031681526020016000815260200160008152602001600081525090565b81526020019060019003908161153c5790505b506000805491935090815b818110156118125760008082815481106115aa576115aa613938565b6000918252602080832090910154808352600382526040808420815160608101835281546001600160401b0316815260018201805484518188028101880190955280855294975090949193858301939283018282801561163357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611615575b50505091835250506002919091015460ff161515602090910152905060005b8160200151518110156118045760008260200151828151811061167757611677613938565b6020908102919091018101516001600160a01b03808d166000908152600584526040808220928416825291845281812080548351818702810187019094528084529395509093919290918301828280156116f057602002820191906000526020600020905b8154815260200190600101908083116116dc575b5050505050905060005b81518110156117f657600082828151811061171757611717613938565b6020908102919091018101516001600160a01b038087166000908152600684526040808220848352855290819020815160608101835281549093168352600181015494830194909452600290930154928101839052909250908890036117ec576040518060800160405280866001600160a01b031681526020018381526020018260200151815260200182604001518152508d8c815181106117bb576117bb613938565b60200260200101819052508a806117d190613a41565b9b50508b8b036117ec57505050505050505050505050919050565b50506001016116fa565b508260010192505050611652565b50826001019250505061158e565b50505050919050565b611823611d92565b600061182e81611d2c565b85848082146118505760405163a121188760e01b815260040160405180910390fd5b87848082146118725760405163a121188760e01b815260040160405180910390fd5b8960005b818110156118e7576118df8d8d8381811061189357611893613938565b90506020020160208101906118a89190613512565b8c8c848181106118ba576118ba613938565b905060200201358b8b858181106118d3576118d3613938565b905060200201356127d2565b600101611876565b5050505050505061147d6001600080516020613be283398151915255565b600080516020613c0283398151915254600090600080516020613b8283398151915290600160d01b900465ffffffffffff16801580159061194d57504265ffffffffffff8216105b611967578154600160d01b900465ffffffffffff1661197c565b6001820154600160a01b900465ffffffffffff165b9250505090565b61198b611d92565b82818082146119ad5760405163a121188760e01b815260040160405180910390fd5b60006119b881611d2c565b8560005b81811015611ab95760008989838181106119d8576119d8613938565b90506020020160208101906119ed9190613512565b90506000888884818110611a0357611a03613938565b6001600160a01b038581166000908152600660209081526040808320948202969096013580835293905293909320600281015490549194509216905080611a5d57604051630a49bbc360e21b815260040160405180910390fd5b611a6984848484612883565b82846001600160a01b0316826001600160a01b03167fdff3a2b820f7c5b6a198a1f89433db7e547d4fbc4a4eb5434f523960addc81b360405160405180910390a4846001019450505050506119bc565b50505050506108bb6001600080516020613be283398151915255565b6000611adf611b15565b509050336001600160a01b03821614611b0d57604051636116401160e11b8152336004820152602401610839565b6106d06128f3565b600080516020613b82833981519152546001600160a01b03811691600160a01b90910465ffffffffffff1690565b611b4b611d92565b6000611b5681611d2c565b611b618484846127d2565b5061085f6001600080516020613be283398151915255565b81611b9757604051631fe1e13d60e11b815260040160405180910390fd5b6107978282612990565b6000611bac81611d2c565b6106d06129ac565b611bbc611d92565b8281808214611bde5760405163a121188760e01b815260040160405180910390fd5b6000611be981611d2c565b8560005b81811015611ab9576000898983818110611c0957611c09613938565b9050602002016020810190611c1e9190613512565b90506000888884818110611c3457611c34613938565b6001600160a01b038581166000908152600660209081526040808320948202969096013580835293905293909320600281015490549194509216905080611c8e57604051630a49bbc360e21b815260040160405180910390fd5b611c9a828585846129b7565b611ca76000858584612bc7565b82846001600160a01b0316826001600160a01b03167f01d992c19f1eab82c4dbe8cbb29ff00405ecfb8e83e595aa280e4a54e088694a60405160405180910390a484600101945050505050611bed565b60006001600160e01b03198216637965db0b60e01b148061065f57506301ffc9a760e01b6001600160e01b031983161461065f565b6106d08133612ca3565b611d41600080612cdc565b565b611d4c826106d3565b611d5581611d2c565b6108bb83836124b9565b6001600160a01b0381163314611d885760405163334bd91960e11b815260040160405180910390fd5b61085f8282612db7565b600080516020613be2833981519152805460011901611dc457604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b600080516020613bc28339815191525460ff1615611d415760405163d93c066560e01b815260040160405180910390fd5b8260005b8181101561147d576000868683818110611e1b57611e1b613938565b9050602002016020810190611e309190613512565b90506000858584818110611e4657611e46613938565b6001600160a01b0385811660009081526006602090815260408083209482029690960135808352939052939093206002810154905491945092169050611e9f57604051630a49bbc360e21b815260040160405180910390fd5b6001600160a01b03808416600090815260066020908152604080832086845290915290205416338114611ee5576040516330cd747160e01b815260040160405180910390fd5b6001600160a01b03841660009081526006602090815260408083208684528252808320600101548584526003909252909120546001600160401b0316611f2b81836138fc565b421015611f4b576040516320a6f12d60e01b815260040160405180910390fd5b611f5786868686612883565b60405185906001600160a01b0388169033907f8210728e7c071f615b840ee026032693858fbcd5e5359e67e438c890f59e562090600090a4866001019650505050505050611dff565b6001600080516020613be283398151915255565b611fbc612e10565b600080516020613bc2833981519152805460ff191681557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a150565b600061201e611905565b61202742612e40565b6120319190613a5a565b905061203d8282612e77565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b600061209282612f04565b61209b42612e40565b6120a59190613a5a565b90506120b18282612cdc565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b910160405180910390a15050565b60008211801561211a575061210f6020820182613a79565b6001600160401b0316155b1561213857604051630f962f3d60e31b815260040160405180910390fd5b60005b6121486020830183613a94565b90508110156121b45760006121606020840184613a94565b8381811061217057612170613938565b90506020020160208101906121859190613512565b6001600160a01b0316036121ac5760405163db781b8360e01b815260040160405180910390fd5b60010161213b565b506000828152600360209081526040808320815160608101835281546001600160401b03168152600182018054845181870281018701909552808552919492938584019390929083018282801561223457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612216575b50505091835250506002919091015460ff1615156020918201526040805160608101909152919250819061226a90850185613a79565b6001600160401b031681526020018380602001906122889190613a94565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016122cf6060850160408601613add565b1515905260008481526003602090815260409091208251815467ffffffffffffffff19166001600160401b03909116178155828201518051919261231b92600185019290910190613165565b50604091909101516002909101805460ff191691151591909117905560005b8160200151518110156123ae5760006002600086815260200190815260200160002060008460200151848151811061237457612374613938565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905560010161233a565b5060005b6123bf6020840184613a94565b90508110156108bb576000848152600260209081526040822060019290916123e990870187613a94565b858181106123f9576123f9613938565b905060200201602081019061240e9190613512565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016123b2565b612446611dca565b600080516020613bc2833981519152805460ff191660011781557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611ff6565b61248f612f53565b611d41612f9c565b61249f612f53565b611d41612fbd565b6124af612f53565b6107978282612fc5565b6000600080516020613b828339815191528361251e5760006124d9610cd4565b6001600160a01b03161461250057604051631fe1e13d60e11b815260040160405180910390fd5b6001810180546001600160a01b0319166001600160a01b0385161790555b612528848461302e565b949350505050565b8060005b818110156111af57600088888381811061255057612550613938565b90506020020160208101906125659190613512565b9050600087878481811061257b5761257b613938565b905060200201359050600086868581811061259857612598613938565b905060200201359050806000036125c257604051630151be2560e11b815260040160405180910390fd5b6000818152600360205260408120546001600160401b031690036125f957604051631b742d9d60e31b815260040160405180910390fd5b60008181526003602052604081206002015460ff161515900361262f5760405163bf3388b960e01b815260040160405180910390fd5b60008181526002602090815260408083206001600160a01b038716845290915290205460ff1661267257604051632f579acf60e11b815260040160405180910390fd5b6040516331a9108f60e11b81526004810183905233906001600160a01b03851690636352211e90602401602060405180830381865afa1580156126b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126dd9190613af8565b6001600160a01b031614612704576040516330cd747160e01b815260040160405180910390fd5b61271081848433612bc7565b604051632142170760e11b8152336004820152306024820152604481018390526001600160a01b038416906342842e0e90606401600060405180830381600087803b15801561275e57600080fd5b505af1158015612772573d6000803e3d6000fd5b5050505081836001600160a01b0316336001600160a01b03167fd8e8011c01a346ba74a0fa83d93d6d910a03355e9ea9efb6c7f95518428b88d9846040516127bc91815260200190565b60405180910390a4836001019350505050612534565b6001600160a01b0383811660009081526006602090815260408083208684529091529020541661281557604051630a49bbc360e21b815260040160405180910390fd5b6001600160a01b0383166000818152600660209081526040808320868452825291829020600101805490859055825181815291820185905292859290917f7a660c85503813cab2ecd35686a6998f9ee34da67f42bf87fbb4ca3d4eeaa564910160405180910390a350505050565b61288f828585846129b7565b604051632142170760e11b81523060048201526001600160a01b038281166024830152604482018590528516906342842e0e90606401600060405180830381600087803b1580156128df57600080fd5b505af11580156111af573d6000803e3d6000fd5b600080516020613b8283398151915260008061290d611b15565b915091506129228165ffffffffffff16151590565b158061293657504265ffffffffffff821610155b1561295e576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610839565b612970600061296b610cd4565b612db7565b5061297c6000836124b9565b505081546001600160d01b03191690915550565b612999826106d3565b6129a281611d2c565b6108bb8383612db7565b611d41600080612e77565b6001600160a01b03811660009081526001602052604081208054916129db83613b15565b909155505060008481526004602090815260408083206001600160a01b03871684529091528120905b8154811015612aae5783828281548110612a2057612a20613938565b906000526020600020015403612aa65781548290612a409060019061390f565b81548110612a5057612a50613938565b9060005260206000200154828281548110612a6d57612a6d613938565b906000526020600020018190555081805480612a8b57612a8b613b2c565b60019003818190600052602060002001600090559055612aae565b600101612a04565b506001600160a01b0380831660009081526005602090815260408083209388168352929052908120905b8154811015612b825784828281548110612af457612af4613938565b906000526020600020015403612b7a5781548290612b149060019061390f565b81548110612b2457612b24613938565b9060005260206000200154828281548110612b4157612b41613938565b906000526020600020018190555081805480612b5f57612b5f613b2c565b60019003818190600052602060002001600090559055612b82565b600101612ad8565b5050506001600160a01b03909216600090815260066020908152604080832093835292905290812080546001600160a01b031916815560018101829055600201555050565b6001600160a01b0381166000908152600160205260408120805491612beb83613a41565b909155505060008481526004602090815260408083206001600160a01b03968716808552908352818420805460018082018355918652848620018790559487168085526005845282852082865284528285208054808801825590865284862001879055825160608101845290815242818501908152818401998a529185526006845282852096855295909252909120925183546001600160a01b03191694169390931782559151918101919091559051600290910155565b612cad8282610cff565b6107975760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610839565b600080516020613c0283398151915254600080516020613b8283398151915290600160d01b900465ffffffffffff168015612d79574265ffffffffffff82161015612d4f57600182015482546001600160d01b0316600160a01b90910465ffffffffffff16600160d01b02178255612d79565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b5060010180546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b6000600080516020613b8283398151915283158015612dee5750612dd9610cd4565b6001600160a01b0316836001600160a01b0316145b15612e06576001810180546001600160a01b03191690555b61252884846130d3565b600080516020613bc28339815191525460ff16611d4157604051638dfc202b60e01b815260040160405180910390fd5b600065ffffffffffff821115612e73576040516306dfcc6560e41b81526030600482015260248101839052604401610839565b5090565b600080516020613b828339815191526000612e90611b15565b835465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b038816171784559150612ed090508165ffffffffffff16151590565b156108bb576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a150505050565b600080612f0f611905565b90508065ffffffffffff168365ffffffffffff1611612f3757612f328382613b42565b612f4c565b612f4c65ffffffffffff84166206978061314f565b9392505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16611d4157604051631afcd79f60e31b815260040160405180910390fd5b612fa4612f53565b600080516020613bc2833981519152805460ff19169055565b611fa0612f53565b612fcd612f53565b600080516020613b828339815191526001600160a01b03821661300657604051636116401160e11b815260006004820152602401610839565b80546001600160d01b0316600160d01b65ffffffffffff8516021781556108bb6000836124b9565b6000600080516020613ba28339815191526130498484610cff565b6130c9576000848152602082815260408083206001600160a01b03871684529091529020805460ff1916600117905561307f3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4600191505061065f565b600091505061065f565b6000600080516020613ba28339815191526130ee8484610cff565b156130c9576000848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4600191505061065f565b600081831061315e5781612f4c565b5090919050565b8280548282559060005260206000209081019282156131ba579160200282015b828111156131ba57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613185565b50612e739291505b80821115612e7357600081556001016131c2565b6000602082840312156131e857600080fd5b81356001600160e01b031981168114612f4c57600080fd5b60008151808452602080850194506020840160005b8381101561323157815187529582019590820190600101613215565b509495945050505050565b602081526000612f4c6020830184613200565b6001600160a01b03811681146106d057600080fd5b60008060008060006080868803121561327c57600080fd5b85356132878161324f565b945060208601356132978161324f565b93506040860135925060608601356001600160401b03808211156132ba57600080fd5b818801915088601f8301126132ce57600080fd5b8135818111156132dd57600080fd5b8960208285010111156132ef57600080fd5b9699959850939650602001949392505050565b60006020828403121561331457600080fd5b5035919050565b6000806040838503121561332e57600080fd5b82356133398161324f565b946020939093013593505050565b81516001600160a01b0316815260208083015190820152604080830151908201526060810161065f565b6000806040838503121561338457600080fd5b8235915060208301356133968161324f565b809150509250929050565b60008083601f8401126133b357600080fd5b5081356001600160401b038111156133ca57600080fd5b6020830191508360208260051b85010111156133e557600080fd5b9250929050565b6000806000806040858703121561340257600080fd5b84356001600160401b038082111561341957600080fd5b613425888389016133a1565b9096509450602087013591508082111561343e57600080fd5b5061344b878288016133a1565b95989497509550505050565b6000806000806080858703121561346d57600080fd5b84359350602085013561347f8161324f565b93969395505050506040820135916060013590565b6040815260006134a76040830185613200565b82810360208481019190915284518083528582019282019060005b81811015613505576134f283865180516001600160a01b0316825260208082015190830152604090810151910152565b93830193606092909201916001016134c2565b5090979650505050505050565b60006020828403121561352457600080fd5b8135612f4c8161324f565b60006020828403121561354157600080fd5b813565ffffffffffff81168114612f4c57600080fd5b60006060828403121561356957600080fd5b50919050565b6000806040838503121561358257600080fd5b8235915060208301356001600160401b0381111561359f57600080fd5b6135ab85828601613557565b9150509250929050565b600080602083850312156135c857600080fd5b82356001600160401b038111156135de57600080fd5b6135ea858286016133a1565b90969095509350505050565b6000606083016001600160401b03835116845260208084015160606020870152828151808552608088019150602083019450600092505b808310156136565784516001600160a01b0316825293830193600192909201919083019061362d565b506040860151151560408801528094505050505092915050565b6040815260006136836040830185613200565b6020838203818501528185518084528284019150828160051b85010183880160005b838110156136d357601f198784030185526136c18383516135f6565b948601949250908501906001016136a5565b50909998505050505050505050565b6000806000604084860312156136f757600080fd5b83356137028161324f565b925060208401356001600160401b0381111561371d57600080fd5b613729868287016133a1565b9497909650939450505050565b60006020828403121561374857600080fd5b81356001600160401b0381111561375e57600080fd5b61252884828501613557565b6000806040838503121561377d57600080fd5b82356137888161324f565b915060208301356133968161324f565b602081526000612f4c60208301846135f6565b600080600080600080606087890312156137c457600080fd5b86356001600160401b03808211156137db57600080fd5b6137e78a838b016133a1565b9098509650602089013591508082111561380057600080fd5b61380c8a838b016133a1565b9096509450604089013591508082111561382557600080fd5b5061383289828a016133a1565b979a9699509497509295939492505050565b602080825282518282018190526000919060409081850190868401855b828110156138a457815180516001600160a01b03168552868101518786015285810151868601526060908101519085015260809093019290850190600101613861565b5091979650505050505050565b6000806000606084860312156138c657600080fd5b83356138d18161324f565b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561065f5761065f6138e6565b8181038181111561065f5761065f6138e6565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b80356001600160401b038116811461396557600080fd5b919050565b8035801515811461396557600080fd5b60006020808352608083016001600160401b03806139978761394e565b168386015282860135601e198736030181126139b257600080fd5b86018381019035828111156139c657600080fd5b8060051b36038213156139d857600080fd5b60606040880152928390529160a0860191506000905b80821015613a20578335613a018161324f565b6001600160a01b031683529284019291840191600191909101906139ee565b5050613a2e6040870161396a565b8015156060870152925095945050505050565b600060018201613a5357613a536138e6565b5060010190565b65ffffffffffff818116838216019080821115610cad57610cad6138e6565b600060208284031215613a8b57600080fd5b612f4c8261394e565b6000808335601e19843603018112613aab57600080fd5b8301803591506001600160401b03821115613ac557600080fd5b6020019150600581901b36038213156133e557600080fd5b600060208284031215613aef57600080fd5b612f4c8261396a565b600060208284031215613b0a57600080fd5b8151612f4c8161324f565b600081613b2457613b246138e6565b506000190190565b634e487b7160e01b600052603160045260246000fd5b65ffffffffffff828116828216039080821115610cad57610cad6138e656fe2714cbbaddbb71bcae9366d8bf7770636ec7ae63227b573986d2f54fffacb39deef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d869840002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00eef3dac4538c82c8ace4063ab0acd2d15cdb5883aa1dff7c2673abb3d8698401a2646970667358221220441455bd861659cec65b5b4db22a27ed445161a2ac88fb9be6db1f652cc4f29464736f6c63430008180033

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.