CRO Price: $0.18 (-2.68%)

Contract

0x195B8fb58e9E8Df10c7F08daA05efdc39cCd9bdC
Transaction Hash
Method
Block
From
To
Claim170129202024-12-02 17:48:133 hrs ago1733161693IN
Minted Network: Listing Reward Distributor
0 CRO4.220118355,050
Claim170123052024-12-02 16:48:494 hrs ago1733158129IN
Minted Network: Listing Reward Distributor
0 CRO3.965234755,050
Claim170078302024-12-02 9:37:0311 hrs ago1733132223IN
Minted Network: Listing Reward Distributor
0 CRO3.97800625,050
Claim170073432024-12-02 8:50:0512 hrs ago1733129405IN
Minted Network: Listing Reward Distributor
0 CRO4.18507965,200
Claim170070142024-12-02 8:18:2312 hrs ago1733127503IN
Minted Network: Listing Reward Distributor
0 CRO4.18514725,200
Claim170067212024-12-02 7:50:0713 hrs ago1733125807IN
Minted Network: Listing Reward Distributor
0 CRO3.990768765,066.0667653
Claim170044412024-12-02 4:10:2616 hrs ago1733112626IN
Minted Network: Listing Reward Distributor
0 CRO4.063219595,048.5
Claim170031482024-12-02 2:05:3619 hrs ago1733105136IN
Minted Network: Listing Reward Distributor
0 CRO4.046196055,048.5
Claim170020802024-12-02 0:22:1220 hrs ago1733098932IN
Minted Network: Listing Reward Distributor
0 CRO4.136584395,048.5
Update Trading R...170018822024-12-02 0:03:0621 hrs ago1733097786IN
Minted Network: Listing Reward Distributor
0 CRO0.55,000
Claim170011352024-12-01 22:50:5022 hrs ago1733093450IN
Minted Network: Listing Reward Distributor
0 CRO4.064194555,050
Claim170009672024-12-01 22:34:4422 hrs ago1733092484IN
Minted Network: Listing Reward Distributor
0 CRO4.06316915,048.5
Claim169992802024-12-01 19:51:2225 hrs ago1733082682IN
Minted Network: Listing Reward Distributor
0 CRO3.977879955,050
Claim169985472024-12-01 18:40:0226 hrs ago1733078402IN
Minted Network: Listing Reward Distributor
0 CRO3.978061755,050
Claim169983132024-12-01 18:17:1626 hrs ago1733077036IN
Minted Network: Listing Reward Distributor
0 CRO4.064366255,050
Claim169973962024-12-01 16:48:2228 hrs ago1733071702IN
Minted Network: Listing Reward Distributor
0 CRO4.13804075,050
Claim169965522024-12-01 15:26:2029 hrs ago1733066780IN
Minted Network: Listing Reward Distributor
0 CRO4.050441845,048.5
Claim169951292024-12-01 13:08:0832 hrs ago1733058488IN
Minted Network: Listing Reward Distributor
0 CRO4.132247735,048.5
Claim169933722024-12-01 10:17:2534 hrs ago1733048245IN
Minted Network: Listing Reward Distributor
0 CRO3.978061755,050
Claim169923942024-12-01 8:42:3236 hrs ago1733042552IN
Minted Network: Listing Reward Distributor
0 CRO4.06436125,050
Claim169918782024-12-01 7:52:2837 hrs ago1733039548IN
Minted Network: Listing Reward Distributor
0 CRO4.06426025,050
Claim169918572024-12-01 7:50:2537 hrs ago1733039425IN
Minted Network: Listing Reward Distributor
0 CRO4.046206145,048.5
Claim169908712024-12-01 6:14:5238 hrs ago1733033692IN
Minted Network: Listing Reward Distributor
0 CRO3.976890245,048.5
Claim169906912024-12-01 5:57:2539 hrs ago1733032645IN
Minted Network: Listing Reward Distributor
0 CRO4.06436125,050
Update Trading R...169870422024-12-01 0:03:0945 hrs ago1733011389IN
Minted Network: Listing Reward Distributor
0 CRO0.55,000
View all transactions

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RewardsDistributorWithVesting

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 37 : RewardDistributorWithVesting.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {MintedBoost} from "./MintedBoost.sol";
import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

/**
 * @title RewardsDistributor
 * @notice It distributes MINTED tokens with rolling Merkle airdrops.
 */
contract RewardsDistributorWithVesting is Pausable, ReentrancyGuard, AccessControlEnumerable {
    using SafeERC20 for IERC20;

    struct StakePool {
        uint256 shares;
        bool active;
    }
    bytes32 public constant UPDATE_REWARD_ROLE = keccak256("UPDATE_REWARD_ROLE");
    uint256[] public stakedPids;
    mapping(uint256 => StakePool) public stakePoolInfo;
    uint256 public constant TOTAL_SHARES = 10000; //100 percent

    uint256 public constant BUFFER_ADMIN_WITHDRAW = 3 days;

    IERC20 public immutable mintedToken;

    // Current reward round (users can only claim pending rewards for the current round)
    uint256 public currentRewardRound;

    // Last paused timestamp
    uint256 public lastPausedTimestamp;

    // Max amount per user in current tree
    uint256 public maximumAmountPerUserInCurrentTree;

    // Total amount claimed
    uint256 public totalClaimed;
    uint256 public totalReleased;

    MintedBoost public mintedBoost;
    uint256 public rewardSharesToUser;
    uint256 public rewardSharesToStake;

    // Total amount claimed by user (in MTD)
    mapping(address => uint256) public amountClaimedByUser;

    // Merkle root for a reward round
    mapping(uint256 => bytes32) public merkleRootOfRewardRound;

    // Checks whether a merkle root was used
    mapping(bytes32 => bool) public merkleRootUsed;

    // Keeps track on whether user has claimed at a given reward round
    mapping(uint256 => mapping(address => bool)) public hasUserClaimedForRewardRound;

    event RewardsClaim(address indexed user, uint256 indexed rewardRound, uint256 amount);
    event UpdateTradingRewards(uint256 indexed rewardRound);
    event TokenWithdrawnOwner(uint256 amount);
    event UpdateMintedBoost(address _newMintedBoost, address _oldMintedBoost);
    event AddPool(uint256 _pid);
    event UpdateShareDistribution(uint256 rewardSharesToUser, uint256 rewardSharesToStake);

    /**
     * @notice Constructor
     * @param _mintedToken address of the MTD token
     * @param _rewardSharesToUser percentage of token directly to user, 2500 = 25%
     * @param _rewardSharesToStake percentage of token to MintedBoost, 5000 = 50%
     * @param _pidsToStake array of pids in MintedBoost
     * @param _stakeshares percentage of token sent to each pid in _pidsToStake
     */
    constructor(
        address _mintedToken,
        uint256 _rewardSharesToUser,
        uint256 _rewardSharesToStake,
        uint256[] memory _pidsToStake,
        uint256[] memory _stakeshares
    ) {
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(UPDATE_REWARD_ROLE, msg.sender);
        require(_pidsToStake.length == _stakeshares.length, "length mismatch");
        require(_rewardSharesToUser + _rewardSharesToStake == 100_00, "wrong reward shares distribution");
        rewardSharesToUser = _rewardSharesToUser;

        for (uint256 i; i < _pidsToStake.length; i++) {
            require(stakePoolInfo[_pidsToStake[i]].active == false, "duplicate pid");
            rewardSharesToStake += _stakeshares[i];
            stakePoolInfo[_pidsToStake[i]] = StakePool(_stakeshares[i], true);
            stakedPids.push(_pidsToStake[i]);
        }

        require(rewardSharesToStake == _rewardSharesToStake, "wrong stake shares distribution");
        mintedToken = IERC20(_mintedToken);
        _pause();
    }

    function setMintedBoost(address _newMintedBoost) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(_newMintedBoost != address(0), "Invalid address");
        require(_newMintedBoost != address(mintedBoost), "mintedBoost already exist");
        address _oldmintedBoost = address(mintedBoost);
        mintedBoost = MintedBoost(_newMintedBoost);

        // Gas saving, pre-approve max
        mintedToken.approve(_newMintedBoost, type(uint256).max);

        emit UpdateMintedBoost(_newMintedBoost, _oldmintedBoost);
    }

    function stakePoolLength() public view returns (uint256) {
        return stakedPids.length;
    }

    /**
     * @notice Add a new MintedBoost pid. This only add a new pid and does not send
     *         user fund to the pid yet (share set as 0)
     */
    function addPool(uint256 _pid) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(address(mintedBoost) != address(0), "mintedBoost is not setup");
        uint256 pidLength = mintedBoost.poolLength();
        require(_pid < pidLength, "Invalid Pool ID");
        require(stakePoolInfo[_pid].active == false, "duplicate pid");
        stakePoolInfo[_pid] = StakePool(0, true);
        stakedPids.push(_pid);
        emit AddPool(_pid);
    }

    /**
     * @notice Update share distribution across all the pid.
     */
    function updateShareDistribution(
        uint256 _rewardSharesToUser,
        uint256 _rewardSharesToStake,
        uint256[] memory _pidsToStake,
        uint256[] memory _stakeshares
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(address(mintedBoost) != address(0), "mintedBoost is not setup");
        require(_pidsToStake.length == _stakeshares.length, "length mismatch");
        require(_rewardSharesToUser + _rewardSharesToStake == 100_00, "wrong reward shares distribution");

        rewardSharesToUser = _rewardSharesToUser;
        uint256 totalStakeShares;
        for (uint256 i; i < _pidsToStake.length; i++) {
            require(stakePoolInfo[_pidsToStake[i]].active == true, "pid doesn't exist");
            totalStakeShares += _stakeshares[i];
            stakePoolInfo[_pidsToStake[i]].shares = _stakeshares[i];
        }
        require(totalStakeShares == _rewardSharesToStake, "wrong stake shares distribution");
        rewardSharesToStake = _rewardSharesToStake;

        // Check if total pid share is still === _rewardSharesToStake
        uint256 totalStakedShare = 0;
        for (uint256 i = 0; i < stakedPids.length; i++) {
            totalStakedShare += stakePoolInfo[stakedPids[i]].shares;
        }
        require(totalStakedShare == _rewardSharesToStake, "totalStakedShare != _rewardSharesToStake");

        emit UpdateShareDistribution(_rewardSharesToUser, _rewardSharesToStake);
    }

    /**
     * @notice Claim pending rewards
     * @param amount amount to claim
     * @param merkleProof array containing the merkle proof
     */
    function claim(uint256 amount, bytes32[] calldata merkleProof) external whenNotPaused nonReentrant {
        require(address(mintedBoost) != address(0), "mintedBoost is not setup");
        // Verify the reward round is not claimed already
        require(!hasUserClaimedForRewardRound[currentRewardRound][msg.sender], "Rewards: Already claimed");
        require(amount >= amountClaimedByUser[msg.sender], "Rewards: underflow claim amount");

        (bool claimStatus, uint256 adjustedAmount) = _canClaim(msg.sender, amount, merkleProof);
        require(claimStatus, "Rewards: Invalid proof");
        require(maximumAmountPerUserInCurrentTree >= amount, "Rewards: Amount higher than max");

        // Set mapping for user and round as true
        hasUserClaimedForRewardRound[currentRewardRound][msg.sender] = true;

        // Adjust amount claimed
        amountClaimedByUser[msg.sender] += adjustedAmount;
        totalClaimed += adjustedAmount;

        // Take a percentage of adjustedAmount and lock into MintedBoost
        uint256 amountToUser = adjustedAmount;
        for (uint256 i; i < stakedPids.length; i++) {
            uint256 stakeAmount = (adjustedAmount * stakePoolInfo[stakedPids[i]].shares) / TOTAL_SHARES;
            if (stakeAmount > 0) {
                mintedBoost.depositFor(stakedPids[i], stakeAmount, msg.sender);
                amountToUser -= stakeAmount;
            }
        }

        // Transfer remaining amount to user
        if (rewardSharesToUser != 0) {
            // Do not send dust amount to user if rewardSharesToUser = 0 (prevent confusion)
            mintedToken.safeTransfer(msg.sender, amountToUser);
            totalReleased += amountToUser;
        }

        emit RewardsClaim(msg.sender, currentRewardRound, adjustedAmount);
    }

    /**
     * @notice Update trading rewards with a new merkle root
     * @dev It automatically increments the currentRewardRound
     * @param merkleRoot root of the computed merkle tree
     */
    function updateTradingRewards(bytes32 merkleRoot, uint256 newMaximumAmountPerUser) external {
        require(
            hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(UPDATE_REWARD_ROLE, msg.sender),
            "no permission to call"
        );
        require(
            newMaximumAmountPerUser >= maximumAmountPerUserInCurrentTree,
            "newMaximumAmountPerUser must be >= maximumAmountPerUserInCurrentTree"
        );
        require(address(mintedBoost) != address(0), "mintedBoost is not setup");
        require(!merkleRootUsed[merkleRoot], "Owner: Merkle root already used");
        currentRewardRound++;
        merkleRootOfRewardRound[currentRewardRound] = merkleRoot;
        merkleRootUsed[merkleRoot] = true;
        maximumAmountPerUserInCurrentTree = newMaximumAmountPerUser;
        emit UpdateTradingRewards(currentRewardRound);
    }

    /**
     * @notice Pause distribution
     */
    function pauseDistribution() external onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused {
        lastPausedTimestamp = block.timestamp;
        _pause();
    }

    /**
     * @notice Unpause distribution
     */
    function unpauseDistribution() external onlyRole(DEFAULT_ADMIN_ROLE) whenPaused {
        _unpause();
    }

    /**
     * @notice Transfer MTD tokens back to owner
     * @dev It is for emergency purposes
     * @param amount amount to withdraw
     */
    function withdrawTokenRewards(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) whenPaused {
        require(
            block.timestamp > (lastPausedTimestamp + BUFFER_ADMIN_WITHDRAW),
            "Owner: Too early to withdraw"
        );
        mintedToken.safeTransfer(msg.sender, amount);

        emit TokenWithdrawnOwner(amount);
    }

    /**
     * @notice Check whether it is possible to claim and how much based on previous distribution
     * @param user address of the user
     * @param amount amount to claim
     * @param merkleProof array with the merkle proof
     */
    function canClaim(
        address user,
        uint256 amount,
        bytes32[] calldata merkleProof
    ) external view returns (bool, uint256) {
        return _canClaim(user, amount, merkleProof);
    }

    /**
     * @notice Check whether it is possible to claim and how much based on previous distribution
     * @param user address of the user
     * @param amount amount to claim
     * @param merkleProof array with the merkle proof
     */
    function _canClaim(
        address user,
        uint256 amount,
        bytes32[] calldata merkleProof
    ) internal view returns (bool, uint256) {
        // return early if user has claimed or amount smaller than amountClaimed
        if ((hasUserClaimedForRewardRound[currentRewardRound][user]) || amount < amountClaimedByUser[user]) {
            return (false, 0);
        }

        // Compute the node and verify the merkle proof
        bytes32 node = keccak256(abi.encodePacked(user, amount));
        bool canUserClaim = MerkleProof.verify(
            merkleProof,
            merkleRootOfRewardRound[currentRewardRound],
            node
        );
        if (!canUserClaim) {
            return (false, 0);
        } else {
            return (true, amount - amountClaimedByUser[user]);
        }
    }
}

File 2 of 37 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.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 Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _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) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

File 3 of 37 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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 ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

    uint256 private _status;

    constructor() {
        _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() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 4 of 37 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
     * consuming from one or the other at each step according to the instructions given by
     * `proofFlags`.
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 5 of 37 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

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

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

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

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

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

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

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 6 of 37 : MintedBoost.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {TokenDistributor} from "./TokenDistributor.sol";
import {FeeDistributor} from "./FeeDistributor.sol";

/**
 * @dev It calls TokenDistributor which in turns mint new MTD rewards
 * @dev It calls FeeDistributor which in turns mint new WCRO rewards
 * @dev Stake MTD to earn more MTD and WCRO
 */
contract MintedBoost is
    Initializable,
    UUPSUpgradeable,
    OwnableUpgradeable,
    ERC20Upgradeable,
    ReentrancyGuardUpgradeable
{
    using SafeERC20Upgradeable for IERC20Upgradeable;

    struct Stake {
        uint256 amount;
        uint256 poolId;
        uint256 weightedAmount;
        uint256 stakeTimestamp;
        uint256 unlockTimestamp;
        bool active;
    }

    struct PoolInfo {
        uint256 multiplier;
        uint256 lockPeriod;
        uint256 totalStaked;
    }

    struct UserInfo {
        uint256 weightedAmount;
        uint256 rewardDebt;
        uint256 croRewardDebt;
        Stake[] stakes;
    }

    mapping(address => UserInfo) public userInfo;
    PoolInfo[] public poolInfo;

    // multiplier -> lockPeriod -> poolID (in +1 format)
    mapping(uint256 => mapping(uint256 => uint256)) public activePoolMap;

    uint256 public lastMtdBalance;
    uint256 public accTokenPerShare;

    uint256 public lastWcroBalance;
    uint256 public accWcroPerShare;

    uint256 public lastRewardBlock;

    IERC20Upgradeable public mtd;
    IERC20Upgradeable public wcro;
    TokenDistributor public tokenDist;
    FeeDistributor public feeDist;
    uint256 public constant PRECISION = 10**18;

    event Deposit(
        address indexed user,
        uint256 indexed pid,
        uint256 indexed stakeId,
        uint256 amount,
        uint256 weightedAmount,
        uint256 unlockTimestamp
    );
    event Withdraw(address indexed user, uint256 indexed stakeId, uint256 amount, uint256 weightedAmount);
    event Upgrade(
        address indexed user,
        uint256 indexed stakeId,
        uint256 indexed newPid,
        uint256 newWeightedAmount,
        uint256 newUnlockTimestamp
    );
    event AddPool(uint256 indexed poolId, uint256 multiplier, uint256 lockPeriod);
    event SetPool(uint256 indexed poolId, uint256 multiplier, uint256 lockPeriod);
    event UpdateFeeDistributor(address _newFeeDistributor, address _oldFeeDist);
    event UpdateTokenDistributor(address _newTokenDistributor, address _oldTokenDist);

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

    function initialize(
        IERC20Upgradeable _mtd,
        IERC20Upgradeable _wcro,
        address _tokenDist,
        address _feeDist
    ) public initializer {
        mtd = _mtd;
        wcro = _wcro;
        tokenDist = TokenDistributor(_tokenDist);
        feeDist = FeeDistributor(_feeDist);
        __Ownable_init();
        __UUPSUpgradeable_init();
        __ERC20_init("MTD Boost Bearing Token", "MBOOST");
    }

    function updateFeeDistributor(address _newFeeDistributor) external onlyOwner {
        require(_newFeeDistributor != address(0), "Invalid address");
        require(_newFeeDistributor != address(feeDist), "FeeDistributor already exist");
        address _oldFeeDist = address(feeDist);
        feeDist = FeeDistributor(_newFeeDistributor);
        emit UpdateFeeDistributor(_newFeeDistributor, _oldFeeDist);
    }

    function updateTokenDistributor(address _newTokenDistributor) external onlyOwner {
        require(_newTokenDistributor != address(0), "Invalid address");
        require(_newTokenDistributor != address(tokenDist), "TokenDistributor already exist");
        address _oldTokenDist = address(tokenDist);
        tokenDist = TokenDistributor(_newTokenDistributor);
        emit UpdateTokenDistributor(_newTokenDistributor, _oldTokenDist);
    }

    function deposit(uint256 _pid, uint256 _amount) external {
        depositFor(_pid, _amount, msg.sender);
    }

    /// @param _user address to deposit on behalf on. MTD will come from msg.sender instead of user
    function depositFor(
        uint256 _pid,
        uint256 _amount,
        address _user
    ) public nonReentrant {
        PoolInfo storage pool = poolInfo[_pid];
        require(pool.multiplier > 0, "MintedBoost: Invalid Pool ID");

        _harvest();

        Stake memory stake;
        UserInfo storage user = userInfo[_user];

        if (user.weightedAmount > 0) {
            uint256 pending = (user.weightedAmount * accTokenPerShare) / PRECISION - user.rewardDebt;
            if (pending > 0) {
                // In case of rounding error, contract does not have enough minted
                if (lastMtdBalance < pending) {
                    pending = lastMtdBalance;
                }
                mtd.safeTransfer(_user, pending);
                lastMtdBalance = mtd.balanceOf(address(this));
            }
            uint256 pendingCro = (user.weightedAmount * accWcroPerShare) / PRECISION - user.croRewardDebt;
            if (pendingCro > 0) {
                if (lastWcroBalance < pendingCro) {
                    pendingCro = lastWcroBalance;
                }
                wcro.safeTransfer(_user, pendingCro);
                lastWcroBalance = wcro.balanceOf(address(this));
            }
        }

        if (_amount > 0) {
            uint256 weightedAmount = pool.multiplier * _amount;
            stake.amount = _amount;
            stake.poolId = _pid;
            stake.weightedAmount = weightedAmount;
            stake.stakeTimestamp = block.timestamp;
            stake.unlockTimestamp = block.timestamp + pool.lockPeriod;
            stake.active = true;

            pool.totalStaked += _amount;

            mtd.safeTransferFrom(msg.sender, address(this), _amount);
            lastMtdBalance = mtd.balanceOf(address(this));
            _mint(_user, weightedAmount);

            user.stakes.push(stake);
            user.weightedAmount += weightedAmount;
        }

        user.rewardDebt = (user.weightedAmount * accTokenPerShare) / PRECISION;
        user.croRewardDebt = (user.weightedAmount * accWcroPerShare) / PRECISION;
        emit Deposit(
            _user,
            _pid,
            user.stakes.length - 1,
            _amount,
            stake.weightedAmount,
            stake.unlockTimestamp
        );
    }

    function withdraw(uint256 _stakeId) public nonReentrant {
        UserInfo storage user = userInfo[msg.sender];
        Stake storage stake = user.stakes[_stakeId];
        PoolInfo storage pool = poolInfo[stake.poolId];
        require(block.timestamp >= stake.unlockTimestamp, "MintedBoost: Stake not Ready for Withdrawal");
        require(stake.active, "MintedBoost: Stake not Active");

        _harvest();

        if (user.weightedAmount > 0) {
            uint256 pending = (user.weightedAmount * accTokenPerShare) / PRECISION - user.rewardDebt;
            if (pending > 0) {
                // In case of rounding error, contract does not have enough minted
                if (lastMtdBalance < pending) {
                    pending = lastMtdBalance;
                }
                mtd.safeTransfer(msg.sender, pending);
                lastMtdBalance = mtd.balanceOf(address(this));
            }
            uint256 pendingCro = (user.weightedAmount * accWcroPerShare) / PRECISION - user.croRewardDebt;
            if (pendingCro > 0) {
                if (lastWcroBalance < pendingCro) {
                    pendingCro = lastWcroBalance;
                }
                wcro.safeTransfer(msg.sender, pendingCro);
                lastWcroBalance = wcro.balanceOf(address(this));
            }
        }
        mtd.safeTransfer(msg.sender, stake.amount);
        lastMtdBalance = mtd.balanceOf(address(this));

        user.weightedAmount -= stake.weightedAmount;
        _burn(msg.sender, stake.weightedAmount);

        pool.totalStaked -= stake.amount;
        stake.active = false;

        user.rewardDebt = (user.weightedAmount * accTokenPerShare) / PRECISION;
        user.croRewardDebt = (user.weightedAmount * accWcroPerShare) / PRECISION;
        emit Withdraw(msg.sender, _stakeId, stake.amount, stake.weightedAmount);
    }

    function upgrade(uint256 _stakeId, uint256 _newPid) public nonReentrant {
        UserInfo storage user = userInfo[msg.sender];
        Stake storage stake = user.stakes[_stakeId];
        PoolInfo storage oldPool = poolInfo[stake.poolId];
        PoolInfo storage newPool = poolInfo[_newPid];
        require(stake.active, "MintedBoost: Stake not Active");
        require(
            stake.stakeTimestamp + newPool.lockPeriod >= stake.unlockTimestamp,
            "MintedBoost: New Stake must be longer"
        );
        require(newPool.multiplier > stake.weightedAmount / stake.amount, "MintedBoost: Why downgrade");

        _harvest();
        if (user.weightedAmount > 0) {
            uint256 pending = (user.weightedAmount * accTokenPerShare) / PRECISION - user.rewardDebt;
            if (pending > 0) {
                // In case of rounding error, contract does not have enough minted
                if (lastMtdBalance < pending) {
                    pending = lastMtdBalance;
                }
                mtd.safeTransfer(msg.sender, pending);
                lastMtdBalance = mtd.balanceOf(address(this));
            }
            uint256 pendingCro = (user.weightedAmount * accWcroPerShare) / PRECISION - user.croRewardDebt;
            if (pendingCro > 0) {
                if (lastWcroBalance < pendingCro) {
                    pendingCro = lastWcroBalance;
                }
                wcro.safeTransfer(msg.sender, pendingCro);
                lastWcroBalance = wcro.balanceOf(address(this));
            }
        }

        stake.poolId = _newPid;
        stake.unlockTimestamp = stake.stakeTimestamp + newPool.lockPeriod;

        uint256 upgradeAmount = newPool.multiplier * stake.amount - stake.weightedAmount;
        user.weightedAmount += upgradeAmount;
        stake.weightedAmount += upgradeAmount;
        _mint(msg.sender, upgradeAmount);

        oldPool.totalStaked -= stake.amount;
        newPool.totalStaked += stake.amount;

        user.rewardDebt = (user.weightedAmount * accTokenPerShare) / PRECISION;
        user.croRewardDebt = (user.weightedAmount * accWcroPerShare) / PRECISION;
        emit Upgrade(msg.sender, _stakeId, _newPid, stake.weightedAmount, stake.unlockTimestamp);
    }

    function batchWithdraw(uint256[] calldata _stakeIds) external {
        for (uint256 i; i < _stakeIds.length; i++) {
            withdraw(_stakeIds[i]);
        }
    }

    function batchUpgrade(uint256[] calldata _stakeIds, uint256[] calldata _newPids) external {
        require(_stakeIds.length == _newPids.length, "MintedBoost: Array length mismatch");
        for (uint256 i; i < _stakeIds.length; i++) {
            upgrade(_stakeIds[i], _newPids[i]);
        }
    }

    function _harvest() internal {
        if (block.number <= lastRewardBlock) {
            return;
        }
        if (totalSupply() == 0) {
            lastRewardBlock = block.number;
            return;
        }
        tokenDist.updatePool();
        feeDist.updateRewards();

        uint256 harvestedMtd = mtd.balanceOf(address(this)) - lastMtdBalance;
        lastMtdBalance = mtd.balanceOf(address(this));
        accTokenPerShare += (PRECISION * harvestedMtd) / totalSupply();

        uint256 harvestedCro = wcro.balanceOf(address(this)) - lastWcroBalance;
        lastWcroBalance = wcro.balanceOf(address(this));
        accWcroPerShare += (PRECISION * harvestedCro) / totalSupply();

        lastRewardBlock = block.number;
    }

    function add(uint256 _multiplier, uint256 _lockPeriod) public onlyOwner {
        require(activePoolMap[_multiplier][_lockPeriod] == 0, "MintedBoost: Duplicate Pool");
        require(_multiplier > 0, "MintedBoost: Multiplier must be > 0");
        poolInfo.push(PoolInfo({multiplier: _multiplier, lockPeriod: _lockPeriod, totalStaked: 0}));
        activePoolMap[_multiplier][_lockPeriod] = poolInfo.length;
        emit AddPool(poolInfo.length - 1, _multiplier, _lockPeriod);
    }

    function set(
        uint256 _pid,
        uint256 _multiplier,
        uint256 _lockPeriod
    ) public onlyOwner {
        require(activePoolMap[_multiplier][_lockPeriod] == 0, "MintedBoost: Duplicate Pool");
        require(_multiplier > 0, "MintedBoost: Multiplier must be > 0");
        _harvest();

        PoolInfo storage pool = poolInfo[_pid];
        activePoolMap[pool.multiplier][pool.lockPeriod] = 0;
        pool.multiplier = _multiplier;
        pool.lockPeriod = _lockPeriod;
        activePoolMap[_multiplier][_lockPeriod] = _pid + 1;

        emit SetPool(_pid, _multiplier, _lockPeriod);
    }

    function getUserInfo(address _user)
        external
        view
        returns (
            uint256,
            uint256,
            Stake[] memory
        )
    {
        UserInfo memory user = userInfo[_user];
        return (user.weightedAmount, user.rewardDebt, user.stakes);
    }

    /**
     * @dev Just in case there are too many Stakes and jams `getUserInfo`
     */
    function getUserStake(address _user, uint256 _stakeId) external view returns (Stake memory) {
        return userInfo[_user].stakes[_stakeId];
    }

    function pendingMTD(address _user) external view returns (uint256) {
        if (totalSupply() == 0) {
            return 0;
        }
        UserInfo memory user = userInfo[_user];
        uint256 tAccTokenPerShare = accTokenPerShare;
        (uint256 mtdToHarvest, ) = tokenDist.getPendingRewards();
        tAccTokenPerShare += (PRECISION * mtdToHarvest) / totalSupply();
        uint256 pendingMtd = (user.weightedAmount * tAccTokenPerShare) / PRECISION - user.rewardDebt;
        return pendingMtd;
    }

    function pendingWCRO(address _user) external view returns (uint256) {
        if (totalSupply() == 0) {
            return 0;
        }
        UserInfo memory user = userInfo[_user];
        uint256 tAccWcroPerShare = accWcroPerShare;
        uint256 wcroToHarvest = feeDist.getPendingRewards();
        tAccWcroPerShare += (PRECISION * wcroToHarvest) / totalSupply();
        uint256 pendingCro = (user.weightedAmount * tAccWcroPerShare) / PRECISION - user.croRewardDebt;
        return pendingCro;
    }

    function poolLength() external view returns (uint256) {
        return poolInfo.length;
    }

    /**
     * @dev BOOST Token is currently non-transferable
     */
    function _beforeTokenTransfer(
        address _from,
        address _to,
        uint256
    ) internal pure override {
        require(_from == address(0) || _to == address(0), "MintedBoost: Transfer not permitted");
    }

    /**
     * @dev Required by EIP-1822 UUPS
     */
    function _authorizeUpgrade(address) internal override onlyOwner {}
}

File 7 of 37 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
}

File 8 of 37 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 10 of 37 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 11 of 37 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 12 of 37 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 14 of 37 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

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

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

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

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

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

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

    function safePermit(
        IERC20PermitUpgradeable token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 16 of 37 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC20_init_unchained(name_, symbol_);
    }

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

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

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

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

File 17 of 37 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

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

File 18 of 37 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

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

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

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

File 19 of 37 : TokenDistributor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IMintedToken.sol";

import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title TokenDistributor
 * @notice It handles the distribution of MTD token.
 * It auto-adjusts block rewards over a set number of periods.
 */
contract TokenDistributor is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using SafeERC20 for IMintedToken;
    uint256 public constant PRECISION_FACTOR = 10**18;
    struct StakingPeriod {
        uint256 rewardPerBlockForStaking;
        uint256 rewardPerBlockForOthers;
        uint256 periodLengthInBlock;
    }

    IMintedToken public immutable mintedToken;

    address public immutable tokenSplitter;
    address public stakingAddr;

    // Number of reward periods
    uint256 public immutable NUMBER_PERIODS;

    // Block number when rewards start
    uint256 public immutable START_BLOCK;

    // Current phase for rewards
    uint256 public currentPhase;

    // Block number when rewards end
    uint256 public endBlock;

    // Block number of the last update
    uint256 public lastRewardBlock;

    // Tokens distributed per block for other purposes (team + treasury + trading rewards)
    uint256 public rewardPerBlockForOthers;

    // Tokens distributed per block for staking
    uint256 public rewardPerBlockForStaking;

    mapping(uint256 => StakingPeriod) public stakingPeriod;

    event NewRewardsPerBlock(
        uint256 indexed currentPhase,
        uint256 startBlock,
        uint256 rewardPerBlockForStaking,
        uint256 rewardPerBlockForOthers
    );
    event SetupStakingAddress(address stakingAddr);

    /**
     * @notice Constructor
     * @param _mintedToken MTD token address
     * @param _tokenSplitter token splitter contract address (for team and trading rewards)
     * @param _startBlock start block for reward program
     * @param _rewardsPerBlockForStaking array of rewards per block for staking
     * @param _rewardsPerBlockForOthers array of rewards per block for other purposes (team + treasury + trading rewards)
     * @param _periodLengthesInBlocks array of period lengthes
     * @param _numberPeriods number of periods with different rewards/lengthes (e.g., if 3 changes --> 4 periods)
     */
    constructor(
        address _mintedToken,
        address _tokenSplitter,
        uint256 _startBlock,
        uint256[] memory _rewardsPerBlockForStaking,
        uint256[] memory _rewardsPerBlockForOthers,
        uint256[] memory _periodLengthesInBlocks,
        uint256 _numberPeriods,
        uint256 slippage
    ) {
        require(_mintedToken != address(0), "Distributor: mintedToken must not be address(0)");
        require(
            (_periodLengthesInBlocks.length == _numberPeriods) &&
                (_rewardsPerBlockForStaking.length == _numberPeriods) &&
                (_rewardsPerBlockForOthers.length == _numberPeriods),
            "Distributor: lengths must match numberPeriods"
        );
        require(_tokenSplitter != address(0), "Distributor: tokenSplitter must not be address(0)");

        // 1. Operational checks for supply
        uint256 nonCirculatingSupply = IMintedToken(_mintedToken).SUPPLY_CAP() -
            IMintedToken(_mintedToken).totalSupply();

        uint256 amountTokensToBeMinted;

        for (uint256 i = 0; i < _numberPeriods; i++) {
            amountTokensToBeMinted +=
                (_rewardsPerBlockForStaking[i] * _periodLengthesInBlocks[i]) +
                (_rewardsPerBlockForOthers[i] * _periodLengthesInBlocks[i]);

            stakingPeriod[i] = StakingPeriod({
                rewardPerBlockForStaking: _rewardsPerBlockForStaking[i],
                rewardPerBlockForOthers: _rewardsPerBlockForOthers[i],
                periodLengthInBlock: _periodLengthesInBlocks[i]
            });
        }
        require(amountTokensToBeMinted <= nonCirculatingSupply, "Distributor: rewards exceeds supply");
        uint256 residueAmt = nonCirculatingSupply - amountTokensToBeMinted;
        uint256 rewardSlippage = (residueAmt * 100 * PRECISION_FACTOR) / nonCirculatingSupply;
        require(rewardSlippage <= slippage, "Distributor: slippage exceeds");
        // 2. Store values
        mintedToken = IMintedToken(_mintedToken);
        tokenSplitter = _tokenSplitter;
        rewardPerBlockForStaking = _rewardsPerBlockForStaking[0];
        rewardPerBlockForOthers = _rewardsPerBlockForOthers[0];

        START_BLOCK = _startBlock;
        endBlock = _startBlock + _periodLengthesInBlocks[0];

        NUMBER_PERIODS = _numberPeriods;

        // Set the lastRewardBlock as the startBlock
        lastRewardBlock = _startBlock;
    }

    /**
     * @dev updates the staking adddress as a mintedBoost contract address once it is deployed.
     */

    function setupStakingAddress(address _stakingAddr) external onlyOwner {
        require(_stakingAddr != address(0), "invalid address");
        stakingAddr = _stakingAddr;
        emit SetupStakingAddress(stakingAddr);
    }

    /**
     * @notice Update pool rewards
     */
    function updatePool() external nonReentrant {
        _updatePool();
    }

    /**
     * @notice Update reward variables of the pool
     */
    function _updatePool() internal {
        require(stakingAddr != address(0), "staking address not setup");
        if (block.number <= lastRewardBlock) {
            return;
        }
        (uint256 tokenRewardForStaking, uint256 tokenRewardForOthers) = _calculatePendingRewards();
        // mint tokens only if token rewards for staking are not null
        if (tokenRewardForStaking > 0) {
            // It allows protection against potential issues to prevent funds from being locked
            mintedToken.mint(stakingAddr, tokenRewardForStaking);
            mintedToken.mint(tokenSplitter, tokenRewardForOthers);
        }

        // Update last reward block only if it wasn't updated after or at the end block
        if (lastRewardBlock <= endBlock) {
            lastRewardBlock = block.number;
        }
    }

    function _calculatePendingRewards() internal returns (uint256, uint256) {
        if (block.number <= lastRewardBlock) {
            return (0, 0);
        }
        // Calculate multiplier
        uint256 multiplier = _getMultiplier(lastRewardBlock, block.number, endBlock);
        // Calculate rewards for staking and others
        uint256 tokenRewardForStaking = multiplier * rewardPerBlockForStaking;
        uint256 tokenRewardForOthers = multiplier * rewardPerBlockForOthers;

        // Check whether to adjust multipliers and reward per block
        while ((block.number > endBlock) && (currentPhase < (NUMBER_PERIODS - 1))) {
            // Update rewards per block
            _updateRewardsPerBlock(endBlock);

            uint256 previousEndBlock = endBlock;

            // Adjust the end block
            endBlock += stakingPeriod[currentPhase].periodLengthInBlock;

            // Adjust multiplier to cover the missing periods with other lower inflation schedule
            uint256 newMultiplier = _getMultiplier(previousEndBlock, block.number, endBlock);

            // Adjust token rewards
            tokenRewardForStaking += (newMultiplier * rewardPerBlockForStaking);
            tokenRewardForOthers += (newMultiplier * rewardPerBlockForOthers);
        }
        return (tokenRewardForStaking, tokenRewardForOthers);
    }

    function getPendingRewards() external view returns (uint256, uint256) {
        if (block.number <= lastRewardBlock) {
            return (0, 0);
        }
        // shadow state vars to avoid updates
        uint256 tEndBlock = endBlock;
        uint256 tCurrentPhase = currentPhase;
        uint256 tRewardPerBlockForStaking = rewardPerBlockForStaking;
        uint256 tRewardPerBlockForOthers = rewardPerBlockForOthers;
        // Calculate multiplier
        uint256 multiplier = _getMultiplier(lastRewardBlock, block.number, tEndBlock);
        // Calculate rewards for staking and others
        uint256 tokenRewardForStaking = multiplier * tRewardPerBlockForStaking;
        uint256 tokenRewardForOthers = multiplier * tRewardPerBlockForOthers;
        // Check whether to adjust multipliers and reward per block
        while ((block.number > tEndBlock) && (tCurrentPhase < (NUMBER_PERIODS - 1))) {
            // Update rewards per block
            tCurrentPhase++;
            tRewardPerBlockForStaking = stakingPeriod[tCurrentPhase].rewardPerBlockForStaking;
            tRewardPerBlockForOthers = stakingPeriod[tCurrentPhase].rewardPerBlockForOthers;
            uint256 previousEndBlock = tEndBlock;

            // Adjust the end block
            tEndBlock += stakingPeriod[tCurrentPhase].periodLengthInBlock;

            // Adjust multiplier to cover the missing periods with other lower inflation schedule
            uint256 newMultiplier = _getMultiplier(previousEndBlock, block.number, tEndBlock);

            // Adjust token rewards
            tokenRewardForStaking += (newMultiplier * tRewardPerBlockForStaking);
            tokenRewardForOthers += (newMultiplier * tRewardPerBlockForOthers);
        }
        return (tokenRewardForStaking, tokenRewardForOthers);
    }

    function getPendingStakingRewards() external view returns (uint256) {
        if (block.number <= lastRewardBlock) {
            return 0;
        }
        uint256 multiplier = block.number - lastRewardBlock;
        return multiplier * rewardPerBlockForStaking;
    }

    /**
     * @notice Update rewards per block
     * @dev Rewards are halved by 2 (for staking + others)
     */
    function _updateRewardsPerBlock(uint256 _newStartBlock) internal {
        // Update current phase
        currentPhase++;

        // Update rewards per block
        rewardPerBlockForStaking = stakingPeriod[currentPhase].rewardPerBlockForStaking;
        rewardPerBlockForOthers = stakingPeriod[currentPhase].rewardPerBlockForOthers;

        emit NewRewardsPerBlock(
            currentPhase,
            _newStartBlock,
            rewardPerBlockForStaking,
            rewardPerBlockForOthers
        );
    }

    /**
     * @notice Return reward multiplier over the given "from" to "to" block.
     * @param from block to start calculating reward
     * @param to block to finish calculating reward
     * @return the multiplier for the period
     */
    function _getMultiplier(
        uint256 from,
        uint256 to,
        uint256 tEndBlock
    ) internal pure returns (uint256) {
        if (to <= tEndBlock) {
            return to - from;
        } else if (from >= tEndBlock) {
            return 0;
        } else {
            return tEndBlock - from;
        }
    }
}

File 20 of 37 : FeeDistributor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract FeeDistributor is Ownable, ReentrancyGuard {
    using SafeERC20 for IERC20;

    uint256 public TOTAL_SHARES;
    IERC20 public wcroToken;
    address public treasury;
    address public mintedBoost;
    uint256 public treasuryShares;
    uint256 public mintedBoostShares;

    uint256 public periodEndBlock;
    uint256 public rewardDurationInBlocks;
    uint256 public currentRewardsPerBlock;
    uint256 public lastUpdatedBlock;

    event UpdateTreasury(address _newTreasury, address _oldTreasury);
    event UpdateMintedBoost(address _newMintedBoost, address _oldMintedBoost);
    event UpdateShares(uint256 treasuryShares, uint256 mintedBoostShares);
    event SetupMintedBoost(address mintedBoost);

    /**
     * @notice Constructor
     * @dev this contract is a fee receipient to minted exchange rewards
     * @dev It handles the wcro fee distribution
     * @dev accumlated rewards are distributed per block over a period
     * @param _mintedBoostShares percentage shares of mintedBoost
     * @param _treasuryShares percentage shares of treasury
     * @param _rewardDurationInBlocks duration of each reward round
     */
    constructor(
        address _wcroToken,
        uint256 _mintedBoostShares,
        address _treasury,
        uint256 _treasuryShares,
        uint256 _rewardDurationInBlocks
    ) {
        require(_treasuryShares > 0, "FeeDistributor: treasuryShares is 0");
        require(_mintedBoostShares > 0, "FeeDistributor: mintedBoostShares is 0");
        require(_rewardDurationInBlocks > 0, "FeeDistributor: rewardDurationInBlocks is 0");

        wcroToken = IERC20(_wcroToken);
        treasury = _treasury;
        treasuryShares = _treasuryShares;
        mintedBoostShares = _mintedBoostShares;
        rewardDurationInBlocks = _rewardDurationInBlocks;

        periodEndBlock = block.number + rewardDurationInBlocks;
        lastUpdatedBlock = block.number;
        TOTAL_SHARES = _treasuryShares + _mintedBoostShares;
    }

    function updateTreasury(address _newTreasury) external onlyOwner {
        require(_newTreasury != address(0), "Invalid address");
        require(_newTreasury != treasury, "treasury already exist");
        address _oldTreasury = treasury;
        treasury = _newTreasury;
        emit UpdateTreasury(_newTreasury, _oldTreasury);
    }

    function updateMintedBoost(address _newMintedBoost) external onlyOwner {
        require(_newMintedBoost != address(0), "Invalid address");
        require(_newMintedBoost != mintedBoost, "mintedBoost already exist");
        address _oldmintedBoost = mintedBoost;
        mintedBoost = _newMintedBoost;
        emit UpdateMintedBoost(_newMintedBoost, _oldmintedBoost);
    }

    function updateShares(uint256 _treasuryShares, uint256 _mintedBoostShares) external onlyOwner {
        require(_treasuryShares > 0, "FeeDistributor: treasuryShares is 0");
        require(_mintedBoostShares > 0, "FeeDistributor: mintedBoostShares is 0");
        treasuryShares = _treasuryShares;
        mintedBoostShares = _mintedBoostShares;
        TOTAL_SHARES = _treasuryShares + _mintedBoostShares;
        emit UpdateShares(treasuryShares, mintedBoostShares);
    }

    function updateRewards() external nonReentrant {
        _updateRewards();
    }

    function _updateRewards() internal {
        require(mintedBoost != address(0), "FeeDistributor: mintedBoost doesn't exist");
        if (block.number <= periodEndBlock) {
            _releaseTradingRewards();
        } else {
            // block.number > periodEndBlock implies end of the perious reward round and start of the new
            // to accomdate we distributed pending rewards of previous round,
            // sets the new reward round and distribute the rewards of current reward round
            _releaseTradingRewards();
            _updateRewardPerBlock();
            _releaseTradingRewards();
        }
    }

    /**
     * @notice send wcro reward to MintedBoost
     * @dev this only send the wcro reward for this period, call _updateRewardPerBlock to update to next period
     */
    function _releaseTradingRewards() internal {
        // limits the rewards to the current reward round wrt _lastUpdatedBlock
        (uint256 multiplier, uint256 _lastUpdatedBlock) = _getMultiplier();
        if (currentRewardsPerBlock > 0) {
            uint256 amountToTransfer = multiplier * currentRewardsPerBlock;
            wcroToken.safeTransfer(mintedBoost, amountToTransfer);
        }
        lastUpdatedBlock = _lastUpdatedBlock;
    }

    /**
    * @notice starts new reward round, splits the accumlated rewards and send treasury reward share upfront
              sets the currentRewardsPerBlock for the new reward round
    */
    function _updateRewardPerBlock() internal {
        if (block.number > periodEndBlock) {
            (uint256 tradingRewards, uint256 treasuryRewards) = getRewardShares();
            periodEndBlock = block.number + rewardDurationInBlocks;
            // for gas saving reason, when tradingRewards > 0, treasuryReward will be > 0
            if (tradingRewards > 0) {
                wcroToken.safeTransfer(treasury, treasuryRewards);
                // reward duration = lapsed period from lastUpdatedBlock + rewardDurationInBlocks
                currentRewardsPerBlock = (tradingRewards / (periodEndBlock - lastUpdatedBlock));
            } else {
                currentRewardsPerBlock = 0;
            }
        }
    }

    /**
     * @return rewards between MintedBoost and treasury
     */
    function getRewardShares() public view returns (uint256, uint256) {
        uint256 rewards = wcroToken.balanceOf(address(this));
        uint256 tradingRewards = (rewards * mintedBoostShares) / TOTAL_SHARES;
        uint256 treasuryRewards = rewards - tradingRewards;
        return (tradingRewards, treasuryRewards);
    }

    /**
     * @return pending wcro reward for MintedBoost
     */
    function getPendingRewards() external view returns (uint256) {
        if (mintedBoost == address(0)) {
            return 0;
        }

        if (block.number <= periodEndBlock) {
            (uint256 multiplier, ) = _getMultiplier();
            return multiplier * currentRewardsPerBlock;
        } else {
            // calculate current round reward
            (uint256 multiplier, ) = _getMultiplier();
            uint256 pendingRewardsForCurrentRound = multiplier * currentRewardsPerBlock;

            // calculate next round reward
            uint256 rewards = wcroToken.balanceOf(address(this)) - pendingRewardsForCurrentRound;
            uint256 tradingRewards = (rewards * mintedBoostShares) / TOTAL_SHARES;
            uint256 nextPeriodEndBlock = block.number + rewardDurationInBlocks;
            uint256 nextRewardPerBlock = (tradingRewards / (nextPeriodEndBlock - periodEndBlock));
            uint256 pendingRewardsForNextRound = (block.number - periodEndBlock) * nextRewardPerBlock;

            return pendingRewardsForCurrentRound + pendingRewardsForNextRound;
        }
    }

    function _getMultiplier() internal view returns (uint256, uint256) {
        if (block.number <= periodEndBlock) {
            return (block.number - lastUpdatedBlock, block.number);
        } else {
            // considers only pending rewards in previous round
            return (periodEndBlock - lastUpdatedBlock, periodEndBlock);
        }
    }
}

File 21 of 37 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 25 of 37 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

File 26 of 37 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20PermitUpgradeable {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 27 of 37 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

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

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

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

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

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

File 29 of 37 : IMintedToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IMintedToken is IERC20 {
    function SUPPLY_CAP() external view returns (uint256);

    function mint(address account, uint256 amount) external returns (bool);
}

File 30 of 37 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

File 31 of 37 : IAccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 32 of 37 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.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:
 *
 * ```
 * 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}:
 *
 * ```
 * 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.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @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 override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @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 override returns (bytes32) {
        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 override 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 override 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 `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

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

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 33 of 37 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 *  Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
 *  See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 *  In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 34 of 37 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @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.
     *
     * _Available since v3.1._
     */
    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 `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 35 of 37 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

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

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

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

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface 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);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_mintedToken","type":"address"},{"internalType":"uint256","name":"_rewardSharesToUser","type":"uint256"},{"internalType":"uint256","name":"_rewardSharesToStake","type":"uint256"},{"internalType":"uint256[]","name":"_pidsToStake","type":"uint256[]"},{"internalType":"uint256[]","name":"_stakeshares","type":"uint256[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"AddPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"rewardRound","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RewardsClaim","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":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenWithdrawnOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newMintedBoost","type":"address"},{"indexed":false,"internalType":"address","name":"_oldMintedBoost","type":"address"}],"name":"UpdateMintedBoost","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rewardSharesToUser","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardSharesToStake","type":"uint256"}],"name":"UpdateShareDistribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"rewardRound","type":"uint256"}],"name":"UpdateTradingRewards","type":"event"},{"inputs":[],"name":"BUFFER_ADMIN_WITHDRAW","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOTAL_SHARES","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPDATE_REWARD_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"addPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"amountClaimedByUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"canClaim","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentRewardRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"hasUserClaimedForRewardRound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPausedTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumAmountPerUserInCurrentTree","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"merkleRootOfRewardRound","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"merkleRootUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintedBoost","outputs":[{"internalType":"contract MintedBoost","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintedToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"rewardSharesToStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardSharesToUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newMintedBoost","type":"address"}],"name":"setMintedBoost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakePoolInfo","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakePoolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakedPids","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalReleased","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpauseDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardSharesToUser","type":"uint256"},{"internalType":"uint256","name":"_rewardSharesToStake","type":"uint256"},{"internalType":"uint256[]","name":"_pidsToStake","type":"uint256[]"},{"internalType":"uint256[]","name":"_stakeshares","type":"uint256[]"}],"name":"updateShareDistribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"newMaximumAmountPerUser","type":"uint256"}],"name":"updateTradingRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawTokenRewards","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b5060405162002d1738038062002d17833981016040819052620000349162000613565b6000805460ff19168155600180556200004e90336200036b565b6200007a7fef1a8c2f845a229a760b7c2971263fd3c7b09f058eee445efe894a279ef0e121336200036b565b8051825114620000c35760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b60448201526064015b60405180910390fd5b620000cf8385620006ae565b61271014620001215760405162461bcd60e51b815260206004820181905260248201527f77726f6e67207265776172642073686172657320646973747269627574696f6e6044820152606401620000ba565b600c84905560005b8251811015620002f057600560008483815181106200015857634e487b7160e01b600052603260045260246000fd5b60209081029190910181015182528101919091526040016000206001015460ff1615620001b85760405162461bcd60e51b815260206004820152600d60248201526c191d5c1b1a58d85d19481c1a59609a1b6044820152606401620000ba565b818181518110620001d957634e487b7160e01b600052603260045260246000fd5b6020026020010151600d6000828254620001f49190620006ae565b9250508190555060405180604001604052808383815181106200022757634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200160011515815250600560008584815181106200026057634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825281810192909252604001600020825181559101516001909101805460ff19169115159190911790558251600490849083908110620002bc57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101518254600181018455600093845291909220015580620002e781620006c9565b91505062000129565b5082600d5414620003445760405162461bcd60e51b815260206004820152601f60248201527f77726f6e67207374616b652073686172657320646973747269627574696f6e006044820152606401620000ba565b6001600160601b0319606086901b1660805262000360620003ae565b505050505062000713565b6200038282826200040b60201b620015751760201c565b6000828152600360209081526040909120620003a9918390620015fb620004b0821b17901c565b505050565b620003b8620004d0565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620003ee3390565b6040516001600160a01b03909116815260200160405180910390a1565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff16620004ac5760008281526002602090815260408083206001600160a01b03851684529091529020805460ff191660011790556200046b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6000620004c7836001600160a01b0384166200051a565b90505b92915050565b60005460ff1615620005185760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401620000ba565b565b60008181526001830160205260408120546200056357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620004ca565b506000620004ca565b600082601f8301126200057d578081fd5b815160206001600160401b03808311156200059c576200059c620006fd565b8260051b604051601f19603f83011681018181108482111715620005c457620005c4620006fd565b60405284815283810192508684018288018501891015620005e3578687fd5b8692505b8583101562000607578051845292840192600192909201918401620005e7565b50979650505050505050565b600080600080600060a086880312156200062b578081fd5b85516001600160a01b038116811462000642578182fd5b60208701516040880151606089015192975090955093506001600160401b03808211156200066e578283fd5b6200067c89838a016200056c565b9350608088015191508082111562000692578283fd5b50620006a1888289016200056c565b9150509295509295909350565b60008219821115620006c457620006c4620006e7565b500190565b6000600019821415620006e057620006e0620006e7565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b60805160601c6125d062000747600039600081816103fd0152818161097b015281816112a8015261149b01526125d06000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c80638542925a11610130578063ba42590d116100b8578063d88cb9f81161007c578063d88cb9f814610521578063dc38bdb514610534578063e33b7de31461055e578063fa46197414610567578063ff0a4eb01461057057600080fd5b8063ba42590d146104c6578063c6500abf146104e9578063ca15c873146104f2578063d547741f14610505578063d54ad2a11461051857600080fd5b80639010d07c116100ff5780639010d07c1461046257806391d14854146104755780639ea76f3414610488578063a217fddf146104b6578063b94ec9d0146104be57600080fd5b80638542925a146103f857806385e3f9971461041f5780638923e2f7146104285780638c9727681461043b57600080fd5b806336568abe116101be5780634e543878116101825780634e5438781461039f5780635c975abb146103a75780637769ea0a146103b257806384483c86146103c5578063847fadca146103e557600080fd5b806336568abe1461033d5780633b66f49d146103505780633e48bc29146103705780634dc2e8eb146103795780634dd6a5e01461038c57600080fd5b8063248a9ca311610205578063248a9ca3146102ab5780632f2ff15d146102ce5780632f52ebb7146102e3578063308c084d146102f657806331cec7a31461033557600080fd5b806301ffc9a7146102375780631040faf91461025f578063141fd8c8146102765780631a567dc214610280575b600080fd5b61024a6102453660046122a5565b610579565b60405190151581526020015b60405180910390f35b61026860065481565b604051908152602001610256565b6102686203f48081565b600b54610293906001600160a01b031681565b6040516001600160a01b039091168152602001610256565b6102686102b9366004612241565b60009081526002602052604090206001015490565b6102e16102dc366004612259565b6105a4565b005b6102e16102f13660046122e5565b6105ce565b610320610304366004612241565b6005602052600090815260409020805460019091015460ff1682565b60408051928352901515602083015201610256565b6102e16109fe565b6102e161034b366004612259565b610a20565b61026861035e3660046121af565b600e6020526000908152604090205481565b610268600d5481565b6102e161038736600461232f565b610a9e565b61026861039a366004612241565b610e22565b600454610268565b60005460ff1661024a565b6102e16103c0366004612241565b610e43565b6102686103d3366004612241565b600f6020526000908152604090205481565b6102e16103f3366004612284565b611029565b6102937f000000000000000000000000000000000000000000000000000000000000000081565b61026861271081565b6102e1610436366004612241565b611229565b6102687fef1a8c2f845a229a760b7c2971263fd3c7b09f058eee445efe894a279ef0e12181565b610293610470366004612284565b611306565b61024a610483366004612259565b611325565b61024a610496366004612259565b601160209081526000928352604080842090915290825290205460ff1681565b610268600081565b6102e1611350565b61024a6104d4366004612241565b60106020526000908152604090205460ff1681565b610268600c5481565b610268610500366004612241565b61136b565b6102e1610513366004612259565b611382565b61026860095481565b6102e161052f3660046121af565b6113a7565b6105476105423660046121c9565b611558565b604080519215158352602083019190915201610256565b610268600a5481565b61026860075481565b61026860085481565b60006001600160e01b03198216635a05180f60e01b148061059e575061059e82611610565b92915050565b6000828152600260205260409020600101546105bf81611645565b6105c9838361164f565b505050565b6105d6611671565b6002600154141561062e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600155600b546001600160a01b031661065b5760405162461bcd60e51b815260040161062590612467565b600654600090815260116020908152604080832033845290915290205460ff16156106c85760405162461bcd60e51b815260206004820152601860248201527f526577617264733a20416c726561647920636c61696d656400000000000000006044820152606401610625565b336000908152600e60205260409020548310156107275760405162461bcd60e51b815260206004820152601f60248201527f526577617264733a20756e646572666c6f7720636c61696d20616d6f756e74006044820152606401610625565b600080610736338686866116b9565b91509150816107805760405162461bcd60e51b81526020600482015260166024820152752932bbb0b932399d1024b73b30b634b210383937b7b360511b6044820152606401610625565b8460085410156107d25760405162461bcd60e51b815260206004820152601f60248201527f526577617264733a20416d6f756e7420686967686572207468616e206d6178006044820152606401610625565b60065460009081526011602090815260408083203384528252808320805460ff19166001179055600e9091528120805483929061081090849061249e565b925050819055508060096000828254610829919061249e565b9091555081905060005b600454811015610965576000612710600560006004858154811061086757634e487b7160e01b600052603260045260246000fd5b90600052602060002001548152602001908152602001600020600001548561088f91906124d6565b61089991906124b6565b9050801561095257600b54600480546001600160a01b03909216916390210d7e9190859081106108d957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546040516001600160e01b031960e084901b168152600481019190915260248101849052336044820152606401600060405180830381600087803b15801561092b57600080fd5b505af115801561093f573d6000803e3d6000fd5b50505050808361094f91906124f5565b92505b508061095d81612553565b915050610833565b50600c54156109ba576109a26001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633836117ec565b80600a60008282546109b4919061249e565b90915550505b60065460405183815233907fe8dbd8c18906df11a70832fe7c874d1fddf6952cee2320658d669256183879999060200160405180910390a350506001805550505050565b6000610a0981611645565b610a11611671565b42600755610a1d61183e565b50565b6001600160a01b0381163314610a905760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610625565b610a9a8282611898565b5050565b6000610aa981611645565b600b546001600160a01b0316610ad15760405162461bcd60e51b815260040161062590612467565b8151835114610b145760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610625565b610b1e848661249e565b61271014610b6e5760405162461bcd60e51b815260206004820181905260248201527f77726f6e67207265776172642073686172657320646973747269627574696f6e6044820152606401610625565b600c8590556000805b8451811015610cbb5760056000868381518110610ba457634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825281019190915260400160002060019081015460ff16151514610c0a5760405162461bcd60e51b81526020600482015260116024820152701c1a5908191bd95cdb89dd08195e1a5cdd607a1b6044820152606401610625565b838181518110610c2a57634e487b7160e01b600052603260045260246000fd5b602002602001015182610c3d919061249e565b9150838181518110610c5f57634e487b7160e01b600052603260045260246000fd5b602002602001015160056000878481518110610c8b57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600001819055508080610cb390612553565b915050610b77565b50848114610d0b5760405162461bcd60e51b815260206004820152601f60248201527f77726f6e67207374616b652073686172657320646973747269627574696f6e006044820152606401610625565b600d8590556000805b600454811015610d7f576005600060048381548110610d4357634e487b7160e01b600052603260045260246000fd5b906000526020600020015481526020019081526020016000206000015482610d6b919061249e565b915080610d7781612553565b915050610d14565b50858114610de05760405162461bcd60e51b815260206004820152602860248201527f746f74616c5374616b6564536861726520213d205f726577617264536861726560448201526773546f5374616b6560c01b6064820152608401610625565b60408051888152602081018890527f39a337929995ecb69b39b73c5a3367874fba7a460ba5a53b291d03727fe729de910160405180910390a150505050505050565b60048181548110610e3257600080fd5b600091825260209091200154905081565b6000610e4e81611645565b600b546001600160a01b0316610e765760405162461bcd60e51b815260040161062590612467565b600b546040805163040f1f6d60e11b815290516000926001600160a01b03169163081e3eda916004808301926020929190829003018186803b158015610ebb57600080fd5b505afa158015610ecf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef391906122cd565b9050808310610f365760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a5908141bdbdb081251608a1b6044820152606401610625565b60008381526005602052604090206001015460ff1615610f885760405162461bcd60e51b815260206004820152600d60248201526c191d5c1b1a58d85d19481c1a59609a1b6044820152606401610625565b604080518082018252600080825260016020808401828152888452600582528584209451855551938201805460ff1916941515949094179093556004805491820181559091527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0185905590518481527f6f92874181ba07c8e988c53b7d3c2fdcff7154a3500137bf6a350ebac65c087091015b60405180910390a1505050565b611034600033611325565b8061106457506110647fef1a8c2f845a229a760b7c2971263fd3c7b09f058eee445efe894a279ef0e12133611325565b6110a85760405162461bcd60e51b81526020600482015260156024820152741b9bc81c195c9b5a5cdcda5bdb881d1bc818d85b1b605a1b6044820152606401610625565b60085481101561112e5760405162461bcd60e51b8152602060048201526044602482018190527f6e65774d6178696d756d416d6f756e7450657255736572206d75737420626520908201527f3e3d206d6178696d756d416d6f756e7450657255736572496e43757272656e746064820152635472656560e01b608482015260a401610625565b600b546001600160a01b03166111565760405162461bcd60e51b815260040161062590612467565b60008281526010602052604090205460ff16156111b55760405162461bcd60e51b815260206004820152601f60248201527f4f776e65723a204d65726b6c6520726f6f7420616c72656164792075736564006044820152606401610625565b600680549060006111c583612553565b9091555050600680546000908152600f602090815260408083208690558583526010909152808220805460ff191660011790556008849055915491517f0b1d6b49e69d133866d064a73f0181e1e35aa94fde3ef0095587d7ebd0423caa9190a25050565b600061123481611645565b61123c6118ba565b6203f48060075461124d919061249e565b421161129b5760405162461bcd60e51b815260206004820152601c60248201527f4f776e65723a20546f6f206561726c7920746f207769746864726177000000006044820152606401610625565b6112cf6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633846117ec565b6040518281527fb4cd5c4a08bbed33abfe773ece179d156730e39629e065b7dcd8263027387c1d9060200160405180910390a15050565b600082815260036020526040812061131e9083611903565b9392505050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600061135b81611645565b6113636118ba565b610a1d61190f565b600081815260036020526040812061059e90611948565b60008281526002602052604090206001015461139d81611645565b6105c98383611898565b60006113b281611645565b6001600160a01b0382166113fa5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610625565b600b546001600160a01b03838116911614156114585760405162461bcd60e51b815260206004820152601960248201527f6d696e746564426f6f737420616c7265616479206578697374000000000000006044820152606401610625565b600b80546001600160a01b031981166001600160a01b0385811691821790935560405163095ea7b360e01b815260048101919091526000196024820152908216917f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b390604401602060405180830381600087803b1580156114df57600080fd5b505af11580156114f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115179190612221565b50604080516001600160a01b038086168252831660208201527f77eb1f1d31eec686cedb8c57ea528ef1628f0854063b8ffa4bab67b95b93f04f910161101c565b600080611567868686866116b9565b915091505b94509492505050565b61157f8282611325565b610a9a5760008281526002602090815260408083206001600160a01b03851684529091529020805460ff191660011790556115b73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061131e836001600160a01b038416611952565b60006001600160e01b03198216637965db0b60e01b148061059e57506301ffc9a760e01b6001600160e01b031983161461059e565b610a1d81336119a1565b6116598282611575565b60008281526003602052604090206105c990826115fb565b60005460ff16156116b75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610625565b565b60065460009081526011602090815260408083206001600160a01b0388168452909152812054819060ff168061170657506001600160a01b0386166000908152600e602052604090205485105b156117165750600090508061156c565b6040516bffffffffffffffffffffffff19606088901b1660208201526034810186905260009060540160405160208183030381529060405280519060200120905060006117a686868080602002602001604051908101604052809392919081815260200183836020028082843760009201829052506006548152600f60205260409020549250869150611a059050565b9050806117bb5760008093509350505061156c565b6001600160a01b0388166000908152600e60205260409020546001906117e190896124f5565b93509350505061156c565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105c9908490611a1b565b611846611671565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861187b3390565b6040516001600160a01b03909116815260200160405180910390a1565b6118a28282611aed565b60008281526003602052604090206105c99082611b54565b60005460ff166116b75760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610625565b600061131e8383611b69565b6119176118ba565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa3361187b565b600061059e825490565b60008181526001830160205260408120546119995750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561059e565b50600061059e565b6119ab8282611325565b610a9a576119c3816001600160a01b03166014611ba1565b6119ce836020611ba1565b6040516020016119df9291906123bf565b60408051601f198184030181529082905262461bcd60e51b825261062591600401612434565b600082611a128584611d83565b14949350505050565b6000611a70826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611dde9092919063ffffffff16565b8051909150156105c95780806020019051810190611a8e9190612221565b6105c95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610625565b611af78282611325565b15610a9a5760008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061131e836001600160a01b038416611df5565b6000826000018281548110611b8e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606000611bb08360026124d6565b611bbb90600261249e565b67ffffffffffffffff811115611be157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611c0b576020820181803683370190505b509050600360fc1b81600081518110611c3457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611c7157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611c958460026124d6565b611ca090600161249e565b90505b6001811115611d34576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611ce257634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611d0657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611d2d8161253c565b9050611ca3565b50831561131e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610625565b600081815b8451811015611dd657611dc282868381518110611db557634e487b7160e01b600052603260045260246000fd5b6020026020010151611f12565b915080611dce81612553565b915050611d88565b509392505050565b6060611ded8484600085611f41565b949350505050565b60008181526001830160205260408120548015611f08576000611e196001836124f5565b8554909150600090611e2d906001906124f5565b9050818114611eae576000866000018281548110611e5b57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110611e8c57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611ecd57634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061059e565b600091505061059e565b6000818310611f2e57600082815260208490526040902061131e565b600083815260208390526040902061131e565b606082471015611fa25760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610625565b6001600160a01b0385163b611ff95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610625565b600080866001600160a01b0316858760405161201591906123a3565b60006040518083038185875af1925050503d8060008114612052576040519150601f19603f3d011682016040523d82523d6000602084013e612057565b606091505b5091509150612067828286612072565b979650505050505050565b6060831561208157508161131e565b8251156120915782518084602001fd5b8160405162461bcd60e51b81526004016106259190612434565b80356001600160a01b03811681146120c257600080fd5b919050565b60008083601f8401126120d8578081fd5b50813567ffffffffffffffff8111156120ef578182fd5b6020830191508360208260051b850101111561210a57600080fd5b9250929050565b600082601f830112612121578081fd5b8135602067ffffffffffffffff8083111561213e5761213e612584565b8260051b604051601f19603f8301168101818110848211171561216357612163612584565b60405284815283810192508684018288018501891015612181578687fd5b8692505b858310156121a3578035845292840192600192909201918401612185565b50979650505050505050565b6000602082840312156121c0578081fd5b61131e826120ab565b600080600080606085870312156121de578283fd5b6121e7856120ab565b935060208501359250604085013567ffffffffffffffff811115612209578283fd5b612215878288016120c7565b95989497509550505050565b600060208284031215612232578081fd5b8151801515811461131e578182fd5b600060208284031215612252578081fd5b5035919050565b6000806040838503121561226b578182fd5b8235915061227b602084016120ab565b90509250929050565b60008060408385031215612296578182fd5b50508035926020909101359150565b6000602082840312156122b6578081fd5b81356001600160e01b03198116811461131e578182fd5b6000602082840312156122de578081fd5b5051919050565b6000806000604084860312156122f9578283fd5b83359250602084013567ffffffffffffffff811115612316578283fd5b612322868287016120c7565b9497909650939450505050565b60008060008060808587031215612344578384fd5b8435935060208501359250604085013567ffffffffffffffff80821115612369578384fd5b61237588838901612111565b9350606087013591508082111561238a578283fd5b5061239787828801612111565b91505092959194509250565b600082516123b581846020870161250c565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516123f781601785016020880161250c565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161242881602884016020880161250c565b01602801949350505050565b602081526000825180602084015261245381604085016020870161250c565b601f01601f19169190910160400192915050565b60208082526018908201527f6d696e746564426f6f7374206973206e6f742073657475700000000000000000604082015260600190565b600082198211156124b1576124b161256e565b500190565b6000826124d157634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156124f0576124f061256e565b500290565b6000828210156125075761250761256e565b500390565b60005b8381101561252757818101518382015260200161250f565b83811115612536576000848401525b50505050565b60008161254b5761254b61256e565b506000190190565b60006000198214156125675761256761256e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212200552f691b86f2849a985898a4bf2f6a4e946c707ec9e9d2f8df38e7095bdaae864736f6c634300080400330000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e100000000000000000000000000000000000000000000000000000000000009c40000000000000000000000000000000000000000000000000000000000001d4c00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000009c4

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102325760003560e01c80638542925a11610130578063ba42590d116100b8578063d88cb9f81161007c578063d88cb9f814610521578063dc38bdb514610534578063e33b7de31461055e578063fa46197414610567578063ff0a4eb01461057057600080fd5b8063ba42590d146104c6578063c6500abf146104e9578063ca15c873146104f2578063d547741f14610505578063d54ad2a11461051857600080fd5b80639010d07c116100ff5780639010d07c1461046257806391d14854146104755780639ea76f3414610488578063a217fddf146104b6578063b94ec9d0146104be57600080fd5b80638542925a146103f857806385e3f9971461041f5780638923e2f7146104285780638c9727681461043b57600080fd5b806336568abe116101be5780634e543878116101825780634e5438781461039f5780635c975abb146103a75780637769ea0a146103b257806384483c86146103c5578063847fadca146103e557600080fd5b806336568abe1461033d5780633b66f49d146103505780633e48bc29146103705780634dc2e8eb146103795780634dd6a5e01461038c57600080fd5b8063248a9ca311610205578063248a9ca3146102ab5780632f2ff15d146102ce5780632f52ebb7146102e3578063308c084d146102f657806331cec7a31461033557600080fd5b806301ffc9a7146102375780631040faf91461025f578063141fd8c8146102765780631a567dc214610280575b600080fd5b61024a6102453660046122a5565b610579565b60405190151581526020015b60405180910390f35b61026860065481565b604051908152602001610256565b6102686203f48081565b600b54610293906001600160a01b031681565b6040516001600160a01b039091168152602001610256565b6102686102b9366004612241565b60009081526002602052604090206001015490565b6102e16102dc366004612259565b6105a4565b005b6102e16102f13660046122e5565b6105ce565b610320610304366004612241565b6005602052600090815260409020805460019091015460ff1682565b60408051928352901515602083015201610256565b6102e16109fe565b6102e161034b366004612259565b610a20565b61026861035e3660046121af565b600e6020526000908152604090205481565b610268600d5481565b6102e161038736600461232f565b610a9e565b61026861039a366004612241565b610e22565b600454610268565b60005460ff1661024a565b6102e16103c0366004612241565b610e43565b6102686103d3366004612241565b600f6020526000908152604090205481565b6102e16103f3366004612284565b611029565b6102937f0000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e181565b61026861271081565b6102e1610436366004612241565b611229565b6102687fef1a8c2f845a229a760b7c2971263fd3c7b09f058eee445efe894a279ef0e12181565b610293610470366004612284565b611306565b61024a610483366004612259565b611325565b61024a610496366004612259565b601160209081526000928352604080842090915290825290205460ff1681565b610268600081565b6102e1611350565b61024a6104d4366004612241565b60106020526000908152604090205460ff1681565b610268600c5481565b610268610500366004612241565b61136b565b6102e1610513366004612259565b611382565b61026860095481565b6102e161052f3660046121af565b6113a7565b6105476105423660046121c9565b611558565b604080519215158352602083019190915201610256565b610268600a5481565b61026860075481565b61026860085481565b60006001600160e01b03198216635a05180f60e01b148061059e575061059e82611610565b92915050565b6000828152600260205260409020600101546105bf81611645565b6105c9838361164f565b505050565b6105d6611671565b6002600154141561062e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600155600b546001600160a01b031661065b5760405162461bcd60e51b815260040161062590612467565b600654600090815260116020908152604080832033845290915290205460ff16156106c85760405162461bcd60e51b815260206004820152601860248201527f526577617264733a20416c726561647920636c61696d656400000000000000006044820152606401610625565b336000908152600e60205260409020548310156107275760405162461bcd60e51b815260206004820152601f60248201527f526577617264733a20756e646572666c6f7720636c61696d20616d6f756e74006044820152606401610625565b600080610736338686866116b9565b91509150816107805760405162461bcd60e51b81526020600482015260166024820152752932bbb0b932399d1024b73b30b634b210383937b7b360511b6044820152606401610625565b8460085410156107d25760405162461bcd60e51b815260206004820152601f60248201527f526577617264733a20416d6f756e7420686967686572207468616e206d6178006044820152606401610625565b60065460009081526011602090815260408083203384528252808320805460ff19166001179055600e9091528120805483929061081090849061249e565b925050819055508060096000828254610829919061249e565b9091555081905060005b600454811015610965576000612710600560006004858154811061086757634e487b7160e01b600052603260045260246000fd5b90600052602060002001548152602001908152602001600020600001548561088f91906124d6565b61089991906124b6565b9050801561095257600b54600480546001600160a01b03909216916390210d7e9190859081106108d957634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546040516001600160e01b031960e084901b168152600481019190915260248101849052336044820152606401600060405180830381600087803b15801561092b57600080fd5b505af115801561093f573d6000803e3d6000fd5b50505050808361094f91906124f5565b92505b508061095d81612553565b915050610833565b50600c54156109ba576109a26001600160a01b037f0000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e11633836117ec565b80600a60008282546109b4919061249e565b90915550505b60065460405183815233907fe8dbd8c18906df11a70832fe7c874d1fddf6952cee2320658d669256183879999060200160405180910390a350506001805550505050565b6000610a0981611645565b610a11611671565b42600755610a1d61183e565b50565b6001600160a01b0381163314610a905760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610625565b610a9a8282611898565b5050565b6000610aa981611645565b600b546001600160a01b0316610ad15760405162461bcd60e51b815260040161062590612467565b8151835114610b145760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610625565b610b1e848661249e565b61271014610b6e5760405162461bcd60e51b815260206004820181905260248201527f77726f6e67207265776172642073686172657320646973747269627574696f6e6044820152606401610625565b600c8590556000805b8451811015610cbb5760056000868381518110610ba457634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825281019190915260400160002060019081015460ff16151514610c0a5760405162461bcd60e51b81526020600482015260116024820152701c1a5908191bd95cdb89dd08195e1a5cdd607a1b6044820152606401610625565b838181518110610c2a57634e487b7160e01b600052603260045260246000fd5b602002602001015182610c3d919061249e565b9150838181518110610c5f57634e487b7160e01b600052603260045260246000fd5b602002602001015160056000878481518110610c8b57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600001819055508080610cb390612553565b915050610b77565b50848114610d0b5760405162461bcd60e51b815260206004820152601f60248201527f77726f6e67207374616b652073686172657320646973747269627574696f6e006044820152606401610625565b600d8590556000805b600454811015610d7f576005600060048381548110610d4357634e487b7160e01b600052603260045260246000fd5b906000526020600020015481526020019081526020016000206000015482610d6b919061249e565b915080610d7781612553565b915050610d14565b50858114610de05760405162461bcd60e51b815260206004820152602860248201527f746f74616c5374616b6564536861726520213d205f726577617264536861726560448201526773546f5374616b6560c01b6064820152608401610625565b60408051888152602081018890527f39a337929995ecb69b39b73c5a3367874fba7a460ba5a53b291d03727fe729de910160405180910390a150505050505050565b60048181548110610e3257600080fd5b600091825260209091200154905081565b6000610e4e81611645565b600b546001600160a01b0316610e765760405162461bcd60e51b815260040161062590612467565b600b546040805163040f1f6d60e11b815290516000926001600160a01b03169163081e3eda916004808301926020929190829003018186803b158015610ebb57600080fd5b505afa158015610ecf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef391906122cd565b9050808310610f365760405162461bcd60e51b815260206004820152600f60248201526e125b9d985b1a5908141bdbdb081251608a1b6044820152606401610625565b60008381526005602052604090206001015460ff1615610f885760405162461bcd60e51b815260206004820152600d60248201526c191d5c1b1a58d85d19481c1a59609a1b6044820152606401610625565b604080518082018252600080825260016020808401828152888452600582528584209451855551938201805460ff1916941515949094179093556004805491820181559091527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0185905590518481527f6f92874181ba07c8e988c53b7d3c2fdcff7154a3500137bf6a350ebac65c087091015b60405180910390a1505050565b611034600033611325565b8061106457506110647fef1a8c2f845a229a760b7c2971263fd3c7b09f058eee445efe894a279ef0e12133611325565b6110a85760405162461bcd60e51b81526020600482015260156024820152741b9bc81c195c9b5a5cdcda5bdb881d1bc818d85b1b605a1b6044820152606401610625565b60085481101561112e5760405162461bcd60e51b8152602060048201526044602482018190527f6e65774d6178696d756d416d6f756e7450657255736572206d75737420626520908201527f3e3d206d6178696d756d416d6f756e7450657255736572496e43757272656e746064820152635472656560e01b608482015260a401610625565b600b546001600160a01b03166111565760405162461bcd60e51b815260040161062590612467565b60008281526010602052604090205460ff16156111b55760405162461bcd60e51b815260206004820152601f60248201527f4f776e65723a204d65726b6c6520726f6f7420616c72656164792075736564006044820152606401610625565b600680549060006111c583612553565b9091555050600680546000908152600f602090815260408083208690558583526010909152808220805460ff191660011790556008849055915491517f0b1d6b49e69d133866d064a73f0181e1e35aa94fde3ef0095587d7ebd0423caa9190a25050565b600061123481611645565b61123c6118ba565b6203f48060075461124d919061249e565b421161129b5760405162461bcd60e51b815260206004820152601c60248201527f4f776e65723a20546f6f206561726c7920746f207769746864726177000000006044820152606401610625565b6112cf6001600160a01b037f0000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e11633846117ec565b6040518281527fb4cd5c4a08bbed33abfe773ece179d156730e39629e065b7dcd8263027387c1d9060200160405180910390a15050565b600082815260036020526040812061131e9083611903565b9392505050565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600061135b81611645565b6113636118ba565b610a1d61190f565b600081815260036020526040812061059e90611948565b60008281526002602052604090206001015461139d81611645565b6105c98383611898565b60006113b281611645565b6001600160a01b0382166113fa5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610625565b600b546001600160a01b03838116911614156114585760405162461bcd60e51b815260206004820152601960248201527f6d696e746564426f6f737420616c7265616479206578697374000000000000006044820152606401610625565b600b80546001600160a01b031981166001600160a01b0385811691821790935560405163095ea7b360e01b815260048101919091526000196024820152908216917f0000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e1169063095ea7b390604401602060405180830381600087803b1580156114df57600080fd5b505af11580156114f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115179190612221565b50604080516001600160a01b038086168252831660208201527f77eb1f1d31eec686cedb8c57ea528ef1628f0854063b8ffa4bab67b95b93f04f910161101c565b600080611567868686866116b9565b915091505b94509492505050565b61157f8282611325565b610a9a5760008281526002602090815260408083206001600160a01b03851684529091529020805460ff191660011790556115b73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061131e836001600160a01b038416611952565b60006001600160e01b03198216637965db0b60e01b148061059e57506301ffc9a760e01b6001600160e01b031983161461059e565b610a1d81336119a1565b6116598282611575565b60008281526003602052604090206105c990826115fb565b60005460ff16156116b75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610625565b565b60065460009081526011602090815260408083206001600160a01b0388168452909152812054819060ff168061170657506001600160a01b0386166000908152600e602052604090205485105b156117165750600090508061156c565b6040516bffffffffffffffffffffffff19606088901b1660208201526034810186905260009060540160405160208183030381529060405280519060200120905060006117a686868080602002602001604051908101604052809392919081815260200183836020028082843760009201829052506006548152600f60205260409020549250869150611a059050565b9050806117bb5760008093509350505061156c565b6001600160a01b0388166000908152600e60205260409020546001906117e190896124f5565b93509350505061156c565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526105c9908490611a1b565b611846611671565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861187b3390565b6040516001600160a01b03909116815260200160405180910390a1565b6118a28282611aed565b60008281526003602052604090206105c99082611b54565b60005460ff166116b75760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610625565b600061131e8383611b69565b6119176118ba565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa3361187b565b600061059e825490565b60008181526001830160205260408120546119995750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561059e565b50600061059e565b6119ab8282611325565b610a9a576119c3816001600160a01b03166014611ba1565b6119ce836020611ba1565b6040516020016119df9291906123bf565b60408051601f198184030181529082905262461bcd60e51b825261062591600401612434565b600082611a128584611d83565b14949350505050565b6000611a70826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611dde9092919063ffffffff16565b8051909150156105c95780806020019051810190611a8e9190612221565b6105c95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610625565b611af78282611325565b15610a9a5760008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061131e836001600160a01b038416611df5565b6000826000018281548110611b8e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b60606000611bb08360026124d6565b611bbb90600261249e565b67ffffffffffffffff811115611be157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611c0b576020820181803683370190505b509050600360fc1b81600081518110611c3457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611c7157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611c958460026124d6565b611ca090600161249e565b90505b6001811115611d34576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611ce257634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611d0657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611d2d8161253c565b9050611ca3565b50831561131e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610625565b600081815b8451811015611dd657611dc282868381518110611db557634e487b7160e01b600052603260045260246000fd5b6020026020010151611f12565b915080611dce81612553565b915050611d88565b509392505050565b6060611ded8484600085611f41565b949350505050565b60008181526001830160205260408120548015611f08576000611e196001836124f5565b8554909150600090611e2d906001906124f5565b9050818114611eae576000866000018281548110611e5b57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080876000018481548110611e8c57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611ecd57634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061059e565b600091505061059e565b6000818310611f2e57600082815260208490526040902061131e565b600083815260208390526040902061131e565b606082471015611fa25760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610625565b6001600160a01b0385163b611ff95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610625565b600080866001600160a01b0316858760405161201591906123a3565b60006040518083038185875af1925050503d8060008114612052576040519150601f19603f3d011682016040523d82523d6000602084013e612057565b606091505b5091509150612067828286612072565b979650505050505050565b6060831561208157508161131e565b8251156120915782518084602001fd5b8160405162461bcd60e51b81526004016106259190612434565b80356001600160a01b03811681146120c257600080fd5b919050565b60008083601f8401126120d8578081fd5b50813567ffffffffffffffff8111156120ef578182fd5b6020830191508360208260051b850101111561210a57600080fd5b9250929050565b600082601f830112612121578081fd5b8135602067ffffffffffffffff8083111561213e5761213e612584565b8260051b604051601f19603f8301168101818110848211171561216357612163612584565b60405284815283810192508684018288018501891015612181578687fd5b8692505b858310156121a3578035845292840192600192909201918401612185565b50979650505050505050565b6000602082840312156121c0578081fd5b61131e826120ab565b600080600080606085870312156121de578283fd5b6121e7856120ab565b935060208501359250604085013567ffffffffffffffff811115612209578283fd5b612215878288016120c7565b95989497509550505050565b600060208284031215612232578081fd5b8151801515811461131e578182fd5b600060208284031215612252578081fd5b5035919050565b6000806040838503121561226b578182fd5b8235915061227b602084016120ab565b90509250929050565b60008060408385031215612296578182fd5b50508035926020909101359150565b6000602082840312156122b6578081fd5b81356001600160e01b03198116811461131e578182fd5b6000602082840312156122de578081fd5b5051919050565b6000806000604084860312156122f9578283fd5b83359250602084013567ffffffffffffffff811115612316578283fd5b612322868287016120c7565b9497909650939450505050565b60008060008060808587031215612344578384fd5b8435935060208501359250604085013567ffffffffffffffff80821115612369578384fd5b61237588838901612111565b9350606087013591508082111561238a578283fd5b5061239787828801612111565b91505092959194509250565b600082516123b581846020870161250c565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516123f781601785016020880161250c565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161242881602884016020880161250c565b01602801949350505050565b602081526000825180602084015261245381604085016020870161250c565b601f01601f19169190910160400192915050565b60208082526018908201527f6d696e746564426f6f7374206973206e6f742073657475700000000000000000604082015260600190565b600082198211156124b1576124b161256e565b500190565b6000826124d157634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156124f0576124f061256e565b500290565b6000828210156125075761250761256e565b500390565b60005b8381101561252757818101518382015260200161250f565b83811115612536576000848401525b50505050565b60008161254b5761254b61256e565b506000190190565b60006000198214156125675761256761256e565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212200552f691b86f2849a985898a4bf2f6a4e946c707ec9e9d2f8df38e7095bdaae864736f6c63430008040033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e100000000000000000000000000000000000000000000000000000000000009c40000000000000000000000000000000000000000000000000000000000001d4c00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000009c4

-----Decoded View---------------
Arg [0] : _mintedToken (address): 0x0224010BA2d567ffa014222eD960D1fa43B8C8E1
Arg [1] : _rewardSharesToUser (uint256): 2500
Arg [2] : _rewardSharesToStake (uint256): 7500
Arg [3] : _pidsToStake (uint256[]): 0,1,2
Arg [4] : _stakeshares (uint256[]): 2500,2500,2500

-----Encoded View---------------
13 Constructor Arguments found :
Arg [0] : 0000000000000000000000000224010ba2d567ffa014222ed960d1fa43b8c8e1
Arg [1] : 00000000000000000000000000000000000000000000000000000000000009c4
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001d4c
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [10] : 00000000000000000000000000000000000000000000000000000000000009c4
Arg [11] : 00000000000000000000000000000000000000000000000000000000000009c4
Arg [12] : 00000000000000000000000000000000000000000000000000000000000009c4


Block Transaction Gas Used Reward
view all blocks validated

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.