false
true
0

Contract Address Details

0x4d5805F5E8ebf99B8A7653d59494006Ca877CAcF

Contract Name
MasterWizard
Creator
0x3697a5–584369 at 0xf4f1c2–ddb8bf
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
7,223 Transactions
Transfers
0 Transfers
Gas Used
0
Last Balance Update
25921953
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
MasterWizard




Optimization enabled
true
Compiler version
v0.8.24+commit.e11b9ed9




Optimization runs
200
EVM Version
shanghai




Verified at
2024-11-30T09:56:38.670868Z

src/MasterWizard.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.21;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

import {MagicToken} from "./Magic.sol";
import {RehypothecationProtocol} from "./Rehypothecation.sol";

// MasterWizard is the master of Hocus Pocus MAGIX. He can mint MAGIX and he is a fair guy.
//
// Note that it's ownable and the owner wields tremendous power. The ownership
// will be transferred to a governance smart contract once MAGIX is sufficiently
// distributed and the community can show to govern itself.
contract MasterWizard is AccessControl {
    using SafeERC20 for IERC20;
    using Address for address;

    // Info of each user.
    struct UserInfo {
        uint256 amount; // How many LP tokens the user has provided.
        uint256 rewardDebt; // Reward debt. See explanation below.
        //
        // We do some fancy math here. Basically, any point in time, the amount of MAGIX
        // entitled to a user but is pending to be distributed is:
        //
        //   pending reward = (user.amount * pool.accRewardTokensPerShare) - user.rewardDebt
        //
        // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
        //   1. The pool's `accRewardTokensPerShare` (and `lastRewardBlock`) gets updated.
        //   2. User receives the pending reward sent to his/her address.
        //   3. User's `amount` gets updated.
        //   4. User's `rewardDebt` gets updated.
    }

    // Info of each pool.
    struct PoolInfo {
        IERC20 lpToken; // Address of LP token contract.
        uint256 allocPoint; // How many allocation points assigned to this pool. MAGIX tokens to distribute per block.
        uint256 lastRewardBlock; // Last block number that MAGIX tokens distribution occurs.
        uint256 accRewardTokensPerShare; // Accumulated MAGIX tokens per share, times 1e12. See below.
        uint16 depositFeeBP; // Deposit fee in basis points
        uint16 withdrawFeeBP; // Withdraw fee in basis points
    }

    // Address of the reward token.
    MagicToken public rewardToken;
    // Dev address.
    address public devAddress;
    // Dev mint share in basis points.
    uint16 public devMintRatioBP;
    // Reward tokens created per block.
    uint256 public rewardTokenAmountPerBlock;
    // Maximum reward token amount per block.
    uint256 public maximumRewardTokensAmountPerBlock;
    // Deposit Fee address
    address public feeAddress;

    // Info of each pool.
    PoolInfo[] public poolInfo;
    // Amount of actual deposited tokens for each pool
    uint256[] public poolBalance;
    // Info of each user that stakes LP tokens.
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;
    // Total allocation points. Must be the sum of all allocation points in all pools.
    uint256 public totalAllocPoint = 0;
    // The block number when MAGIX emission starts.
    uint256 public startBlock;

    // Rehypothecation with other MasterChef contract.
    mapping(uint256 => RehypothecationProtocol) public rehypothecations;

    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event EmergencyWithdraw(
        address indexed user,
        uint256 indexed pid,
        uint256 amount
    );
    event EmissionRateUpdated(
        address indexed caller,
        uint256 previousRate,
        uint256 newRate
    );
    event DevMintRatioUpdated(
        address indexed caller,
        uint16 previousRatio,
        uint16 newRatio
    );

    // Empty constructor, actual construction is in initialize()
    constructor() {}

    function initialize(
        MagicToken _rewardToken,
        uint256 _rewardTokenPerBlock,
        uint256 _maximumRewardTokenPerBlock,
        address _devAddress,
        uint16 _devMintRatioBP,
        address _feeAddress,
        uint256 _startBlock
    ) public {
        require(address(rewardToken) == address(0), "Already initialized");
        require(_startBlock >= block.number);

        rewardToken = _rewardToken;
        rewardTokenAmountPerBlock = _rewardTokenPerBlock;
        maximumRewardTokensAmountPerBlock = _maximumRewardTokenPerBlock;

        devAddress = _devAddress;
        devMintRatioBP = _devMintRatioBP;
        feeAddress = _feeAddress;
        startBlock = _startBlock;

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    modifier validatePool(uint256 _pid) {
        require(_pid < poolInfo.length, "Pool Id invalid");
        _;
    }

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

    function isDuplicate(IERC20 _lpToken) public view returns (bool) {
        uint256 length = poolInfo.length;
        for (uint256 i = 0; i < length; ) {
            if (address(poolInfo[i].lpToken) == address(_lpToken)) {
                return true;
            }
            unchecked {
                i++;
            }
        }
        return false;
    }

    // Add a new pool. Can only be called by the owner.
    function add(
        uint256 _allocPoint,
        IERC20 _lpToken,
        uint16 _depositFeeBP,
        uint16 _withdrawFeeBP,
        bool _withUpdate,
        bool _checkDuplicate
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(_depositFeeBP <= 100_00, "Invalid deposit fee basis points");
        require(_withdrawFeeBP <= 100_00, "Invalid withdraw fee basis points");
        if (_withUpdate) {
            massUpdatePools();
        }
        if (_checkDuplicate) {
            require(!isDuplicate(_lpToken), "Pool exists");
        }
        uint256 lastRewardBlock = block.number > startBlock
            ? block.number
            : startBlock;
        totalAllocPoint = totalAllocPoint + _allocPoint;
        poolInfo.push(
            PoolInfo({
                lpToken: _lpToken,
                allocPoint: _allocPoint,
                lastRewardBlock: lastRewardBlock,
                accRewardTokensPerShare: 0,
                depositFeeBP: _depositFeeBP,
                withdrawFeeBP: _withdrawFeeBP
            })
        );
        poolBalance.push(0);
    }

    // Update the given pool's MAGIX allocation point and deposit fee. Can only be called by the owner.
    function set(
        uint256 _pid,
        uint256 _allocPoint,
        uint16 _depositFeeBP,
        uint16 _withdrawFeeBP,
        bool _withUpdate
    ) external validatePool(_pid) onlyRole(DEFAULT_ADMIN_ROLE) {
        require(_depositFeeBP <= 100_00, "Invalid deposit fee basis points");
        require(_withdrawFeeBP <= 100_00, "Invalid withdraw fee basis points");
        if (_withUpdate) {
            massUpdatePools();
        }
        totalAllocPoint =
            totalAllocPoint -
            poolInfo[_pid].allocPoint +
            _allocPoint;
        poolInfo[_pid].allocPoint = _allocPoint;
        poolInfo[_pid].depositFeeBP = _depositFeeBP;
        require(
            _withdrawFeeBP <= poolInfo[_pid].withdrawFeeBP,
            "Withdraw fee cannot be increased"
        );
        poolInfo[_pid].withdrawFeeBP = _withdrawFeeBP;
    }

    // Set rehypothecation farming protocol
    function setRehypothecation(
        uint256 _pid,
        RehypothecationProtocol _rehypothecation
    ) external validatePool(_pid) onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            getTotalDepositAmount(_pid) == 0,
            "Rehypothecation protocol can be changed only on empty pool"
        );
        rehypothecations[_pid] = _rehypothecation;
    }

    // Return reward multiplier over the given _from to _to block.
    function getMultiplier(
        uint256 _from,
        uint256 _to
    ) public pure returns (uint256) {
        if (_from > _to) {
            (_from, _to) = (_to, _from);
        }
        return (_to - _from);
    }

    // Return amount of tokens staked in pool _pid
    function getTotalDepositAmount(uint256 _pid) public view returns (uint256) {
        RehypothecationProtocol rhypo = rehypothecations[_pid];
        if (address(rhypo) == address(0)) {
            return poolBalance[_pid];
        }
        return rhypo.getTotalDepositAmount();
    }

    // View function to see pending reward on frontend.
    function pendingReward(
        uint256 _pid,
        address _user
    ) public view validatePool(_pid) returns (uint256) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];
        uint256 accRewardTokensPerShare = pool.accRewardTokensPerShare;
        uint256 lpSupply = getTotalDepositAmount(_pid);
        if (block.number > pool.lastRewardBlock && lpSupply != 0) {
            uint256 multiplier = getMultiplier(
                pool.lastRewardBlock,
                block.number
            );
            uint256 rewardTokenReward = (multiplier *
                rewardTokenAmountPerBlock *
                pool.allocPoint) / totalAllocPoint;
            accRewardTokensPerShare =
                accRewardTokensPerShare +
                (rewardTokenReward * 1e12) /
                lpSupply;
        }
        return (user.amount * accRewardTokensPerShare) / 1e12 - user.rewardDebt;
    }

    // Update reward variables for all pools. Be careful of gas spending!
    function massUpdatePools() public {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ) {
            _updatePool(pid);
            unchecked {
                ++pid;
            }
        }
    }

    // Update reward variables of the given pool to be up-to-date.
    function _updatePool(uint256 _pid) private {
        PoolInfo storage pool = poolInfo[_pid];
        if (block.number <= pool.lastRewardBlock) {
            return;
        }
        uint256 lpSupply = getTotalDepositAmount(_pid);
        if (lpSupply == 0 || pool.allocPoint == 0) {
            pool.lastRewardBlock = block.number;
            return;
        }
        uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
        uint256 rewardAmount = (multiplier *
            rewardTokenAmountPerBlock *
            pool.allocPoint) / totalAllocPoint;
        uint16 _devMintRatioBP = devMintRatioBP;
        if (_devMintRatioBP > 0) {
            rewardToken.mint(
                devAddress,
                (rewardAmount * _devMintRatioBP) / 100
            );
        }
        rewardToken.mint(address(this), rewardAmount);
        pool.accRewardTokensPerShare =
            pool.accRewardTokensPerShare +
            (rewardAmount * 1e12) /
            lpSupply;
        pool.lastRewardBlock = block.number;
    }

    function updatePool(uint256 _pid) public validatePool(_pid) {
        _updatePool(_pid);
    }

    // Deposit LP tokens to MasterWizard for MAGIX allocation.
    function deposit(uint256 _pid, uint256 _amount) public validatePool(_pid) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        address _freeAddress = feeAddress;
        updatePool(_pid);
        if (user.amount > 0) {
            uint256 pending = (user.amount * pool.accRewardTokensPerShare) /
                1e12 -
                user.rewardDebt;
            if (pending > 0) {
                safeRewardTokenTransfer(msg.sender, pending);
                _claimRehypothecationRewards(_pid, _freeAddress, false);
            }
        }
        if (_amount > 0) {
            IERC20 lpToken = pool.lpToken;
            uint256 before = lpToken.balanceOf(address(this));
            lpToken.safeTransferFrom(
                address(msg.sender),
                address(this),
                _amount
            );
            _amount = lpToken.balanceOf(address(this)) - before;
            if (_amount > 0) {
                if (pool.depositFeeBP > 0) {
                    uint256 depositFee = (_amount * pool.depositFeeBP) / 10000;
                    uint256 amountAfterFee = _amount - depositFee;
                    lpToken.safeTransfer(_freeAddress, depositFee);
                    poolBalance[_pid] += amountAfterFee;
                    user.amount = user.amount + amountAfterFee;

                    _depositRehypothecation(_pid, amountAfterFee);
                } else {
                    poolBalance[_pid] += _amount;
                    user.amount = user.amount + _amount;
                    _depositRehypothecation(_pid, _amount);
                }
            }
        }
        user.rewardDebt = (user.amount * pool.accRewardTokensPerShare) / 1e12;
        emit Deposit(msg.sender, _pid, _amount);
    }

    // Convenience method to name claim transaction more properly
    function claim(uint256 _pid) external {
        deposit(_pid, 0);
    }

    // Withdraw LP tokens from MasterWizard.
    function withdraw(
        uint256 _pid,
        uint256 _amount
    ) external validatePool(_pid) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        address _feeAddress = feeAddress;
        require(user.amount >= _amount, "Withdraw amount too high");
        updatePool(_pid);
        uint256 pending = (user.amount * pool.accRewardTokensPerShare) /
            1e12 -
            user.rewardDebt;
        if (pending > 0) {
            safeRewardTokenTransfer(msg.sender, pending);
            _claimRehypothecationRewards(_pid, _feeAddress, false);
        }
        if (_amount > 0) {
            _withdrawRehypothecation(_pid, _amount);
            user.amount = user.amount - _amount;
            poolBalance[_pid] -= _amount;

            if (pool.withdrawFeeBP > 0) {
                uint256 withdrawFee = (_amount * pool.withdrawFeeBP) / 100_00;
                pool.lpToken.safeTransfer(_feeAddress, withdrawFee);
                pool.lpToken.safeTransfer(
                    address(msg.sender),
                    _amount - withdrawFee
                );
            } else {
                pool.lpToken.safeTransfer(address(msg.sender), _amount);
            }
        }
        user.rewardDebt = (user.amount * pool.accRewardTokensPerShare) / 1e12;
        emit Withdraw(msg.sender, _pid, _amount);
    }

    function claimAll() public {
        uint256 length = poolInfo.length;
        for (uint256 _pid = 0; _pid < length; ) {
            this.deposit(_pid, 0);
            unchecked {
                _pid++;
            }
        }
    }

    // Withdraw without caring about rewards. EMERGENCY ONLY.
    function emergencyWithdraw(uint256 _pid) external validatePool(_pid) {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][msg.sender];
        uint256 amount = user.amount;
        user.amount = 0;
        user.rewardDebt = 0;
        RehypothecationProtocol rhypo = rehypothecations[_pid];
        if (address(rhypo) != address(0)) {
            require(
                pool.allocPoint == 0,
                "Emergency withdraw for pools with rehypothecation is allowed only for inactive pools"
            );
            // In case of rehypothecation, this may fail if enableEmergencyWithdraw() hasn't been called yet
            amount = rhypo.emergencyWithdraw(msg.sender);
        }
        poolBalance[_pid] -= amount;
        pool.lpToken.safeTransfer(address(msg.sender), amount);
        emit EmergencyWithdraw(msg.sender, _pid, amount);
    }

    // Safe rewardToken transfer function, just in case if rounding error causes pool to not have enough MAGIX tokens.
    function safeRewardTokenTransfer(address _to, uint256 _amount) internal {
        uint256 rewardTokenBal = rewardToken.balanceOf(address(this));
        if (_amount > rewardTokenBal) {
            rewardToken.transfer(_to, rewardTokenBal);
        } else {
            rewardToken.transfer(_to, _amount);
        }
    }

    function setDevAddress(
        address _devAddress
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        devAddress = _devAddress;
    }

    function setDevRatio(
        uint16 _devMintRatioBP
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            _devMintRatioBP < devMintRatioBP,
            "Dev mint ratio can only be lowered"
        );
        emit DevMintRatioUpdated(msg.sender, devMintRatioBP, _devMintRatioBP);
        devMintRatioBP = _devMintRatioBP;
    }

    function setFeeAddress(
        address _feeAddress
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        feeAddress = _feeAddress;
    }

    // Pancake has to add hidden dummy pools in order to alter the emission, here we make it simple and transparent to all.
    function updateEmissionRate(
        uint256 _rewardTokensAmountPerBlock
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            _rewardTokensAmountPerBlock <= maximumRewardTokensAmountPerBlock,
            "Emission rate too high"
        );
        massUpdatePools();
        emit EmissionRateUpdated(
            msg.sender,
            rewardTokenAmountPerBlock,
            _rewardTokensAmountPerBlock
        );
        rewardTokenAmountPerBlock = _rewardTokensAmountPerBlock;
    }

    function _depositRehypothecation(uint256 _pid, uint256 _amount) internal {
        RehypothecationProtocol rhypo = rehypothecations[_pid];
        if (address(rhypo) != address(0)) {
            poolInfo[_pid].lpToken.approve(address(rhypo), _amount);
            rhypo.deposit(msg.sender, _amount);
        }
    }

    function _withdrawRehypothecation(
        uint256 _pid,
        uint256 _amount
    ) internal returns (bool amountReturned) {
        RehypothecationProtocol rhypo = rehypothecations[_pid];
        if (address(rhypo) != address(0)) {
            rhypo.withdraw(msg.sender, _amount);
            amountReturned = true;
        }
    }

    function _claimRehypothecationRewards(
        uint256 _pid,
        address _feeAddress,
        bool _requireSuccess
    ) internal {
        RehypothecationProtocol rhypo = rehypothecations[_pid];
        if (address(rhypo) != address(0)) {
            try rhypo.claimRewards(_feeAddress) {} catch Error(
                string memory _err
            ) {
                if (_requireSuccess) revert(_err);
            } catch {
                if (_requireSuccess) revert("Claim failed");
            }
        }
    }

    function enableEmergencyWithdraw(
        uint256 _pid
    ) external validatePool(_pid) onlyRole(DEFAULT_ADMIN_ROLE) {
        RehypothecationProtocol rhypo = rehypothecations[_pid];
        require(
            address(rhypo) != address(0),
            "Needed only for pools with rehypothecation"
        );
        massUpdatePools();
        poolInfo[_pid].allocPoint = 0; // deactivate pool
        rhypo.enableEmergencyWithdraw(); // allows user emergency withdraws
    }

    function claimRehypothecationRewards(
        uint256 _pid
    ) external validatePool(_pid) onlyRole(DEFAULT_ADMIN_ROLE) {
        _claimRehypothecationRewards(_pid, feeAddress, true);
    }

    function claimAllRehypothecationRewards()
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        uint256 length = poolInfo.length;
        address _feeAddress = feeAddress;
        for (uint256 _pid = 0; _pid < length; ) {
            _claimRehypothecationRewards(_pid, _feeAddress, false);
            unchecked {
                _pid++;
            }
        }
    }

    function saveTokens(
        IERC20 tokenAddress
    ) public onlyRole(DEFAULT_ADMIN_ROLE) {
        require(!isDuplicate(tokenAddress), "Deposited tokens cannot be saved");
        IERC20(tokenAddress).transfer(
            msg.sender,
            IERC20(tokenAddress).balanceOf(address(this))
        );
    }
}
        

lib/openzeppelin-contracts/contracts/access/AccessControl.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../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:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, callerConfirmation);
    }

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

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

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

lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Burnable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.20;

import {ERC20} from "../ERC20.sol";
import {Context} from "../../../utils/Context.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys a `value` amount of tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 value) public virtual {
        _burn(_msgSender(), value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, deducting from
     * the caller's allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `value`.
     */
    function burnFrom(address account, uint256 value) public virtual {
        _spendAllowance(account, _msgSender(), value);
        _burn(account, value);
    }
}
          

lib/openzeppelin-contracts/contracts/access/IAccessControl.sol

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

lib/openzeppelin-contracts/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}
          

lib/openzeppelin-contracts/contracts/interfaces/IERC5267.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.20;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}
          

lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
          

lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * 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.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual 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 default value returned by this function, unless
     * it's 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 returns (uint8) {
        return 18;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual 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 `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` 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 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        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 `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` 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.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` 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.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

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

lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}
          

lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Permit.sol)

pragma solidity ^0.8.20;

import {IERC20Permit} from "./IERC20Permit.sol";
import {ERC20} from "../ERC20.sol";
import {ECDSA} from "../../../utils/cryptography/ECDSA.sol";
import {EIP712} from "../../../utils/cryptography/EIP712.sol";
import {Nonces} from "../../../utils/Nonces.sol";

/**
 * @dev Implementation 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.
 */
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces {
    bytes32 private constant PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

    /**
     * @dev Permit deadline has expired.
     */
    error ERC2612ExpiredSignature(uint256 deadline);

    /**
     * @dev Mismatched signature.
     */
    error ERC2612InvalidSigner(address signer, address owner);

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    constructor(string memory name) EIP712(name, "1") {}

    /**
     * @inheritdoc IERC20Permit
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        if (block.timestamp > deadline) {
            revert ERC2612ExpiredSignature(deadline);
        }

        bytes32 structHash = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSA.recover(hash, v, r, s);
        if (signer != owner) {
            revert ERC2612InvalidSigner(signer, owner);
        }

        _approve(owner, spender, value);
    }

    /**
     * @inheritdoc IERC20Permit
     */
    function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) {
        return super.nonces(owner);
    }

    /**
     * @inheritdoc IERC20Permit
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view virtual returns (bytes32) {
        return _domainSeparatorV4();
    }
}
          

lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @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);
}
          

lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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);
}
          

lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}
          

lib/openzeppelin-contracts/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // 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 FailedInnerCall();
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

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

lib/openzeppelin-contracts/contracts/utils/Nonces.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol)
pragma solidity ^0.8.20;

/**
 * @dev Provides tracking nonces for addresses. Nonces will only increment.
 */
abstract contract Nonces {
    /**
     * @dev The nonce used for an `account` is not the expected current nonce.
     */
    error InvalidAccountNonce(address account, uint256 currentNonce);

    mapping(address account => uint256) private _nonces;

    /**
     * @dev Returns the next unused nonce for an address.
     */
    function nonces(address owner) public view virtual returns (uint256) {
        return _nonces[owner];
    }

    /**
     * @dev Consumes a nonce.
     *
     * Returns the current value and increments nonce.
     */
    function _useNonce(address owner) internal virtual returns (uint256) {
        // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be
        // decremented or reset. This guarantees that the nonce never overflows.
        unchecked {
            // It is important to do x++ and not ++x here.
            return _nonces[owner]++;
        }
    }

    /**
     * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`.
     */
    function _useCheckedNonce(address owner, uint256 nonce) internal virtual {
        uint256 current = _useNonce(owner);
        if (nonce != current) {
            revert InvalidAccountNonce(owner, current);
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/ShortStrings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol)

pragma solidity ^0.8.20;

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

// | string  | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA   |
// | length  | 0x                                                              BB |
type ShortString is bytes32;

/**
 * @dev This library provides functions to convert short memory strings
 * into a `ShortString` type that can be used as an immutable variable.
 *
 * Strings of arbitrary length can be optimized using this library if
 * they are short enough (up to 31 bytes) by packing them with their
 * length (1 byte) in a single EVM word (32 bytes). Additionally, a
 * fallback mechanism can be used for every other case.
 *
 * Usage example:
 *
 * ```solidity
 * contract Named {
 *     using ShortStrings for *;
 *
 *     ShortString private immutable _name;
 *     string private _nameFallback;
 *
 *     constructor(string memory contractName) {
 *         _name = contractName.toShortStringWithFallback(_nameFallback);
 *     }
 *
 *     function name() external view returns (string memory) {
 *         return _name.toStringWithFallback(_nameFallback);
 *     }
 * }
 * ```
 */
library ShortStrings {
    // Used as an identifier for strings longer than 31 bytes.
    bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;

    error StringTooLong(string str);
    error InvalidShortString();

    /**
     * @dev Encode a string of at most 31 chars into a `ShortString`.
     *
     * This will trigger a `StringTooLong` error is the input string is too long.
     */
    function toShortString(string memory str) internal pure returns (ShortString) {
        bytes memory bstr = bytes(str);
        if (bstr.length > 31) {
            revert StringTooLong(str);
        }
        return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
    }

    /**
     * @dev Decode a `ShortString` back to a "normal" string.
     */
    function toString(ShortString sstr) internal pure returns (string memory) {
        uint256 len = byteLength(sstr);
        // using `new string(len)` would work locally but is not memory safe.
        string memory str = new string(32);
        /// @solidity memory-safe-assembly
        assembly {
            mstore(str, len)
            mstore(add(str, 0x20), sstr)
        }
        return str;
    }

    /**
     * @dev Return the length of a `ShortString`.
     */
    function byteLength(ShortString sstr) internal pure returns (uint256) {
        uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
        if (result > 31) {
            revert InvalidShortString();
        }
        return result;
    }

    /**
     * @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
     */
    function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
        if (bytes(value).length < 32) {
            return toShortString(value);
        } else {
            StorageSlot.getStringSlot(store).value = value;
            return ShortString.wrap(FALLBACK_SENTINEL);
        }
    }

    /**
     * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
     */
    function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
            return toString(value);
        } else {
            return store;
        }
    }

    /**
     * @dev Return the length of a string that was encoded to `ShortString` or written to storage using
     * {setWithFallback}.
     *
     * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
     * actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
     */
    function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
        if (ShortString.unwrap(value) != FALLBACK_SENTINEL) {
            return byteLength(value);
        } else {
            return bytes(store).length;
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol

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

pragma solidity ^0.8.20;

/**
 * @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:
 * ```solidity
 * 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(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes 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
        }
    }

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

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

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

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

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

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        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_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        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);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
          

lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS
    }

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError, bytes32) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS, s);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/cryptography/EIP712.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.20;

import {MessageHashUtils} from "./MessageHashUtils.sol";
import {ShortStrings, ShortString} from "../ShortStrings.sol";
import {IERC5267} from "../../interfaces/IERC5267.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
 * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract
 * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to
 * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 *
 * @custom:oz-upgrades-unsafe-allow state-variable-immutable
 */
abstract contract EIP712 is IERC5267 {
    using ShortStrings for *;

    bytes32 private constant TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _cachedDomainSeparator;
    uint256 private immutable _cachedChainId;
    address private immutable _cachedThis;

    bytes32 private immutable _hashedName;
    bytes32 private immutable _hashedVersion;

    ShortString private immutable _name;
    ShortString private immutable _version;
    string private _nameFallback;
    string private _versionFallback;

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        _name = name.toShortStringWithFallback(_nameFallback);
        _version = version.toShortStringWithFallback(_versionFallback);
        _hashedName = keccak256(bytes(name));
        _hashedVersion = keccak256(bytes(version));

        _cachedChainId = block.chainid;
        _cachedDomainSeparator = _buildDomainSeparator();
        _cachedThis = address(this);
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator();
        }
    }

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {IERC-5267}.
     */
    function eip712Domain()
        public
        view
        virtual
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _EIP712Name(),
            _EIP712Version(),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }

    /**
     * @dev The name parameter for the EIP712 domain.
     *
     * NOTE: By default this function reads _name which is an immutable value.
     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
     */
    // solhint-disable-next-line func-name-mixedcase
    function _EIP712Name() internal view returns (string memory) {
        return _name.toStringWithFallback(_nameFallback);
    }

    /**
     * @dev The version parameter for the EIP712 domain.
     *
     * NOTE: By default this function reads _version which is an immutable value.
     * It only reads from storage if necessary (in case the value is too large to fit in a ShortString).
     */
    // solhint-disable-next-line func-name-mixedcase
    function _EIP712Version() internal view returns (string memory) {
        return _version.toStringWithFallback(_versionFallback);
    }
}
          

lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }
}
          

lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol

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

pragma solidity ^0.8.20;

import {IERC165} from "./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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
          

lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

lib/openzeppelin-contracts/contracts/utils/math/Math.sol

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
          

src/Magic.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.21;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract MagicToken is ERC20, ERC20Burnable, Ownable, ERC20Permit {
    constructor(
        string memory name,
        string memory symbol,
        address initialOwner
    ) ERC20(name, symbol) Ownable(initialOwner) ERC20Permit(name) {}

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}
          

src/Rehypothecation.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.21;

import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {MasterWizard} from "./MasterWizard.sol";

/**
 * @title Interface for implementation of rehypothecation protocol in external
 * farming protocol where one ERC-20 token can be deposited for yield.
 *
 * @notice Rehypothecation should be carefully done for taxed tokens
 * because each deposit and withdraw does 2 transfers!
 *
 * @notice Implementation of non-view external methods must use onlyMasterWizard
 * modifier allowing only MasterWizard to call them
 */
interface IRehypothecationProtocol {
    /** Returns rehypothecation protocol name */
    function name() external returns (string memory);

    /**
     * Deposits funds for account at specified amount.
     *
     * Implementation shall assume that MasterWizard already owns funds
     * and approved this implementation to transfer funds further.
     *
     * Implementation must support multiple deposits for same account.
     * Implementation must handle use of zero amount.
     */
    function deposit(address _account, uint256 _amount) external;

    /**
     * Withdraws specified amount of funds for specified account.
     *
     * Implementation shall sent funds back to MasterWizard.
     * Implementation must handle use of zero amount.
     */
    function withdraw(address _account, uint256 _amount) external;

    /**
     * Called by MasterWizard admin to enable emergency withdraws for user accounts.
     * Typically means that related pool is deactivated and will not be used anymore.
     *
     * Implementation should revert if protocol does not need or does not support
     * emergency withdraw.
     */
    function enableEmergencyWithdraw() external;

    /**
     * Performs emergency withdraw of all funds for specified account.
     *
     * This should be implemented for protocols which support this method
     * such as traditional MasterChefs.
     *
     * Implementation may assume that enableEmergencyWithdraw() was already called.
     */
    function emergencyWithdraw(
        address _account
    ) external returns (uint256 userAmount);

    /**
     * Claim rewards from rehypothecation and transfer them to MasterWizard's feeAddress.
     * Returns true if there are some rewards.
     *
     * Implementations may transfer rewards also at other circumstances
     * such as deposit or withdraw as appropriate for underlying protocol.
     */
    function claimRewards(address feeAddress) external returns (bool);

    /** Returns sum of deposits for all accounts. */
    function getTotalDepositAmount() external view returns (uint256);

    /** Returns sum of deposits for specified account. */
    function getUserDepositAmount(
        address _account
    ) external view returns (uint256);
}

abstract contract RehypothecationProtocol is
    IRehypothecationProtocol,
    AccessControl
{
    MasterWizard public masterWizard;
    string private protocolName;

    constructor(MasterWizard _masterWizard, string memory _name) {
        masterWizard = _masterWizard;
        protocolName = string.concat("MasterWizard.", _name);
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    modifier onlyMasterWizard() {
        require(msg.sender == address(masterWizard));
        _;
    }

    function name() public view returns (string memory) {
        return protocolName;
    }
}
          

Compiler Settings

{"viaIR":true,"remappings":["@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/","@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","ds-test/=lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","forge-std/=lib/forge-std/src/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"libraries":{},"evmVersion":"shanghai"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"AccessControlBadConfirmation","inputs":[]},{"type":"error","name":"AccessControlUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bytes32","name":"neededRole","internalType":"bytes32"}]},{"type":"error","name":"AddressEmptyCode","inputs":[{"type":"address","name":"target","internalType":"address"}]},{"type":"error","name":"AddressInsufficientBalance","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"FailedInnerCall","inputs":[]},{"type":"error","name":"SafeERC20FailedOperation","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"event","name":"Deposit","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DevMintRatioUpdated","inputs":[{"type":"address","name":"caller","internalType":"address","indexed":true},{"type":"uint16","name":"previousRatio","internalType":"uint16","indexed":false},{"type":"uint16","name":"newRatio","internalType":"uint16","indexed":false}],"anonymous":false},{"type":"event","name":"EmergencyWithdraw","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"EmissionRateUpdated","inputs":[{"type":"address","name":"caller","internalType":"address","indexed":true},{"type":"uint256","name":"previousRate","internalType":"uint256","indexed":false},{"type":"uint256","name":"newRate","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Withdraw","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"pid","internalType":"uint256","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"add","inputs":[{"type":"uint256","name":"_allocPoint","internalType":"uint256"},{"type":"address","name":"_lpToken","internalType":"contract IERC20"},{"type":"uint16","name":"_depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"_withdrawFeeBP","internalType":"uint16"},{"type":"bool","name":"_withUpdate","internalType":"bool"},{"type":"bool","name":"_checkDuplicate","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claim","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimAll","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimAllRehypothecationRewards","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimRehypothecationRewards","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deposit","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"devAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"devMintRatioBP","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"emergencyWithdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"enableEmergencyWithdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"feeAddress","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getMultiplier","inputs":[{"type":"uint256","name":"_from","internalType":"uint256"},{"type":"uint256","name":"_to","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTotalDepositAmount","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_rewardToken","internalType":"contract MagicToken"},{"type":"uint256","name":"_rewardTokenPerBlock","internalType":"uint256"},{"type":"uint256","name":"_maximumRewardTokenPerBlock","internalType":"uint256"},{"type":"address","name":"_devAddress","internalType":"address"},{"type":"uint16","name":"_devMintRatioBP","internalType":"uint16"},{"type":"address","name":"_feeAddress","internalType":"address"},{"type":"uint256","name":"_startBlock","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDuplicate","inputs":[{"type":"address","name":"_lpToken","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"massUpdatePools","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maximumRewardTokensAmountPerBlock","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"pendingReward","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolBalance","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"lpToken","internalType":"contract IERC20"},{"type":"uint256","name":"allocPoint","internalType":"uint256"},{"type":"uint256","name":"lastRewardBlock","internalType":"uint256"},{"type":"uint256","name":"accRewardTokensPerShare","internalType":"uint256"},{"type":"uint16","name":"depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"withdrawFeeBP","internalType":"uint16"}],"name":"poolInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"poolLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract RehypothecationProtocol"}],"name":"rehypothecations","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"callerConfirmation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract MagicToken"}],"name":"rewardToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardTokenAmountPerBlock","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"saveTokens","inputs":[{"type":"address","name":"tokenAddress","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"set","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_allocPoint","internalType":"uint256"},{"type":"uint16","name":"_depositFeeBP","internalType":"uint16"},{"type":"uint16","name":"_withdrawFeeBP","internalType":"uint16"},{"type":"bool","name":"_withUpdate","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDevAddress","inputs":[{"type":"address","name":"_devAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDevRatio","inputs":[{"type":"uint16","name":"_devMintRatioBP","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeeAddress","inputs":[{"type":"address","name":"_feeAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRehypothecation","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"address","name":"_rehypothecation","internalType":"contract RehypothecationProtocol"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startBlock","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalAllocPoint","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateEmissionRate","inputs":[{"type":"uint256","name":"_rewardTokensAmountPerBlock","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updatePool","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"rewardDebt","internalType":"uint256"}],"name":"userInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"_pid","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
              

Contract Creation Code

0x6080806040523461001a575f6009556128fb908161001f8239f35b5f80fdfe6080604081815260049182361015610015575f80fd5b5f925f3560e01c91826301ffc9a714611c0d57508163081e3eda14611bef5781630ba84cd214611b4e57816312545ac314611b3257816312d6a19114611a585781631526fe27146119e357816317caf6f1146119c5578163248a9ca31461199c5781632f2ff15d1461196357816336568abe1461191d578163379607f5146118415781633ad10ef61461181957816341275358146117f1578163441a3e7014611567578163469ce95e1461153857816348cd4cb1146115195781634a7fa021146113c95781634d2ad53b1461126057816351eb05a6146112365781635312ea8e14611033578163630b5ba1146110175781636a6d964e14610fde578163771e6d5414610ee45781637bd7bde814610e10578163819a777e14610ddd5781638705fcd414610d9d5781638b7c048414610c9d5781638dbb1e3a14610c6b5781638e2e272314610c4b57816391d1485414610c0857816393f1a40b14610bbd57816398969e8214610a7657816398c99c9e14610916578163a217fddf146108fb578163d0d41fe1146108bb578163d1058e5914610839578163d4f5063b14610619578163d547741f146105da578163d86ec35f146105b4578163e2bbb1581461028f57508063e34f749114610244578063eb9b3e36146102265763f7c618c1146101fb575f80fd5b3461022257816003193601126102225760015490516001600160a01b039091168152602090f35b5080fd5b50346102225781600319360112610222576020906003549051908152f35b823461028c578060031936011261028c5761025d611fed565b6006546005546001600160a01b0316825b828110610279578380f35b80610286836001936123b0565b0161026e565b80fd5b9050346105b05761029f36611cfa565b90926006548410906102b082611d54565b826102ba86611c81565b5086885260209360088552838920335f528552835f209260018060a01b036102e6816005541693611d54565b6102ef8a6124f7565b84548061056c575b5081610339575b5050505f805160206128a683398151915294955064e8d4a5100061032b6001926003855491015490611d92565b04910155519283523392a380f35b835486516370a0823160e01b808252308c83015294995091169290918783602481875afa928315610562578c93610533575b508651906323b872dd60e01b8983015233602483015230604483015260648201526064815260a0810181811067ffffffffffffffff8211176105205787526103b39084612792565b855190815230898201528681602481865afa908115610516578b916104d2575b50925f805160206128a68339815191529764e8d4a51000936103fa61032b94600197611dd7565b9a8b61040d575b505050928897506102fe565b8301918b61ffff918285541615155f146104955761044261271061043a6104489561048d98541685611d92565b048093611dd7565b936124b4565b61047a6104548d611d1f565b6104648483548360031b1c611ec6565b82545f1960039390931b92831b1916911b179055565b610485818854611ec6565b87558b6126b3565b5f8080610401565b50505050506104b66104a68b611d1f565b6104648c83548360031b1c611ec6565b6104c1898654611ec6565b85556104cd898b6126b3565b61048d565b929390508683813d831161050f575b6104eb8183611efb565b8101031261050b5791519192915f805160206128a68339815191526103d3565b5f80fd5b503d6104e1565b86513d8d823e3d90fd5b60418b634e487b7160e01b5f525260245ffd5b9092508781813d831161055b575b61054b8183611efb565b8101031261050b5751915f61036b565b503d610541565b87513d8e823e3d90fd5b64e8d4a5100061058461059092600388015490611d92565b04600187015490611dd7565b80156102f7576105a09033612215565b6105aa838b6123b0565b5f6102f7565b8280fd5b50503461022257816003193601126102225760209061ffff60025460a01c169051908152f35b919050346105b057806003193601126105b057610615913561061060016105ff611cce565b938387528660205286200154612043565b6121a3565b5080f35b8383346102225760c0366003190112610222578235610636611cce565b9161063f611c5f565b90610648611c70565b90610651611d10565b9360a435801515810361050b57610666611fed565b61ffff8095169561068b8661271096610681888b1115611e25565b1695861115611e70565b61082c575b6107ed575b600a548043115f146107e85750435b6106b082600954611ec6565b60095582519260c0840184811067ffffffffffffffff8211176105205781526001600160a01b039788168452602084019283528301908152606083018881526080840196875260a08401948552600654680100000000000000009891939190898110156107d5578060016107279201600655611c81565b9590956107c35751855491166001600160a01b031990911617845551600184015551600283015551600382015592519286018054915163ffff000090841660101b1663ffffffff199092169290931663ffff0000191691909117179055600754908110156107b05780600161079f9201600755611d1f565b8154905f199060031b1b1916905580f35b506041602492634e487b7160e01b835252fd5b634e487b7160e01b8b528a8c5260248bfd5b634e487b7160e01b8b5260418c5260248bfd5b6106a4565b6107f686611de4565b1561069557815162461bcd60e51b81526020818a0152600b60248201526a506f6f6c2065786973747360a81b6044820152606490fd5b610834611f1d565b610690565b9050346105b057826003193601126105b05760065491835b83811061085c578480f35b303b156108ad57848251631c57762b60e31b81528285820152816024820152818160448183305af180156108b157610899575b5050600101610851565b6108a290611ed3565b6108ad57845f61088f565b8480fd5b84513d84823e3d90fd5b833461028c57602036600319011261028c576108d5611ce4565b6108dd611fed565b60018060a01b03166001600160601b0360a01b600254161760025580f35b50503461022257816003193601126102225751908152602090f35b9050346105b05760209182600319360112610a7257610933611ce4565b61093b611fed565b61094481611de4565b610a315781516370a0823160e01b815230818501526001600160a01b0391909116928482602481875afa918215610a27579085929187926109f4575b50835163a9059cbb60e01b8152339181019182526020820192909252909384918290889082906040015b03925af19081156109eb57506109be578280f35b816109dd92903d106109e4575b6109d58183611efb565b810190611fd5565b505f808280f35b503d6109cb565b513d85823e3d90fd5b8381949293503d8311610a20575b610a0c8183611efb565b8101031261050b57905184916109aa610980565b503d610a02565b83513d88823e3d90fd5b509180606493519262461bcd60e51b845283015260248201527f4465706f736974656420746f6b656e732063616e6e6f742062652073617665646044820152fd5b8380fd5b82843461028c578160031936011261028c578235610a92611cce565b610a9f6006548310611d54565b610aa882611c81565b509082845260086020528484209060018060a01b03165f52602052835f2092610ad5600383015493611f3f565b91600281015480431180610bb4575b610b14575b602087610b0d88600164e8d4a51000610b038b8454611d92565b0491015490611dd7565b9051908152f35b610b4f916001610b3d610b34610b46944381438111610ba9575b50611dd7565b60035490611d92565b91015490611d92565b60095490611db9565b9064e8d4a5100091828102928184041490151715610b96575060209550610b03610b8f610b0d9594610b8960019564e8d4a5100095611db9565b90611ec6565b9394610ae9565b634e487b7160e01b815260118752602490fd5b91505043908e610b2e565b50831515610ae4565b9050823461028c578260031936011261028c578290610bda611cce565b923581526008602052209060018060a01b03165f52602052805f206001815491015482519182526020820152f35b9050346105b057816003193601126105b05781602093610c26611cce565b92358152808552209060018060a01b03165f52825260ff815f20541690519015158152f35b82843461028c57602036600319011261028c5750610b0d60209235611f3f565b50503461022257602090610b0d610c8136611cfa565b8082818111610c92575b5050611dd7565b915091508580610c8b565b8391503461022257602036600319011261022257803592610cc16006548510611d54565b610cc9611fed565b838352600b602052808320546001600160a01b0316918215610d4857836001610cfa8297610cf5611f1d565b611c81565b500155823b15610d43578151633630153360e01b81529284918491829084905af1908115610d3a5750610d2a5750f35b610d3390611ed3565b61028c5780f35b513d84823e3d90fd5b505050fd5b6020608492519162461bcd60e51b8352820152602a60248201527f4e6565646564206f6e6c7920666f7220706f6f6c73207769746820726568797060448201526937ba3432b1b0ba34b7b760b11b6064820152fd5b833461028c57602036600319011261028c57610db7611ce4565b610dbf611fed565b60018060a01b03166001600160601b0360a01b600554161760055580f35b9050346105b05760203660031901126105b057358252600b6020908152918190205490516001600160a01b039091168152f35b919050346105b057806003193601126105b0576024356001600160a01b038116928035918490036108ad57610e486006548310611d54565b610e50611fed565b610e5982611f3f565b610e7b57508352600b602052822080546001600160a01b031916909117905580f35b608490602084519162461bcd60e51b8352820152603a60248201527f52656879706f746865636174696f6e2070726f746f636f6c2063616e2062652060448201527f6368616e676564206f6e6c79206f6e20656d70747920706f6f6c0000000000006064820152fd5b9050346105b05760e03660031901126105b0576001600160a01b03813581811692908390036108ad5760643582811680910361050b576084359161ffff8316830361050b5760a4359484861680960361050b5760c43596600154958616610fa65750438710610fa2576001600160601b0360a01b8095161760015560243560035560443590556002549161ffff60a01b9060a01b169169ffffffffffffffffffff60b01b1617176002556005541617600555600a5561061533612082565b8780fd5b5162461bcd60e51b81526020818401526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606490fd5b9050346105b05760203660031901126105b057359160075483101561028c5750611009602092611d1f565b91905490519160031b1c8152f35b833461028c578060031936011261028c57611030611f1d565b80f35b919050346105b05760209182600319360112610a72578035926110596006548510611d54565b61106284611c81565b509284865260088252808620335f528252805f20928660018554958281550155858752600b835260018060a01b039081838920541690816110f7575b5050837fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059594956110ed926110e46110d48a611d1f565b6104648683548360031b1c611dd7565b339154166124b4565b519283523392a380f35b9091945060018601546111b05787916024859285519485938492631bfc726f60e21b845233908401525af19081156111a6578791611159575b5092807fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059561109e565b90508281813d831161119f575b6111708183611efb565b8101031261050b57517fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae0595611130565b503d611166565b82513d89823e3d90fd5b825162461bcd60e51b8152908101849052605460248201527f456d657267656e637920776974686472617720666f7220706f6f6c732077697460448201527f682072656879706f746865636174696f6e20697320616c6c6f776564206f6e6c6064820152737920666f7220696e61637469766520706f6f6c7360601b608482015260a490fd5b83903461022257602036600319011261022257611030903561125b6006548210611d54565b6124f7565b9050346105b057602080600319360112610a725781356112836006548210611d54565b61128b611fed565b6005545f918252600b835290849020546001600160a01b039081169116816112b1578580f35b915f916024869794839697519485938492633bd73ee360e21b84528a8401525af190816113ac575b5061139f57505f60033d11611390575b6308c379a014611323575b606492519162461bcd60e51b8352820152600c60248201526b10db185a5b4819985a5b195960a21b6044820152fd5b61132b61233f565b8061133657506112f4565b8282855193849262461bcd60e51b84528301528251908160248401525f935b828510611377575050604492505f838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350611355565b50815f803e5f5160e01c6112e9565b925050505f808080808580f35b6113c290843d86116109e4576109d58183611efb565b505f6112d9565b839150346102225760a0366003190112610222576024359080356113eb611c5f565b926113f4611c70565b936113fd611d10565b9161140b6006548510611d54565b611413611fed565b61ffff809216906127109361142a85841115611e25565b61143984891695861115611e70565b61150c575b6114618161145c60095460016114538a611c81565b50015490611dd7565b611ec6565b600955600161146f86611c81565b5001558461147c85611c81565b50019061ffff198254161790558361149384611c81565b50015460101c16106114c957906114ad6110309392611c81565b50019063ffff000082549160101b169063ffff00001916179055565b845162461bcd60e51b8152602081840181905260248201527f5769746864726177206665652063616e6e6f7420626520696e637265617365646044820152606490fd5b611514611f1d565b61143e565b505034610222578160031936011261022257602090600a549051908152f35b5050346102225760203660031901126102225760209061155e611559611ce4565b611de4565b90519015158152f35b9190503461050b5761157836611cfa565b919092600654841061158981611d54565b61159285611c81565b5090855f526008602052835f20335f52602052835f209060018060a01b0390816005541690878454106117ae57918893916115d06115f39694611d54565b6115d9856124f7565b82549389600382019564e8d4a51000988991885490611d92565b0498611605600187019a8b5490611dd7565b80611794575b5081611655575b5050505050611625925054905490611d92565b049055519081527ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56860203392a380f35b875f52600b602052848b5f20541680611706575b506116966116866116259961167f858a54611dd7565b8955611d1f565b6104648583548360031b1c611dd7565b8201805461ffff919060101c8216156116f0576127106116c86116e597946116dd96946116d4945460101c1690611d92565b048095848454166124b4565b5416918a611dd7565b9033906124b4565b87925f808981611612565b5050915061170192339154166124b4565b6116e5565b915091929394959650803b1561050b57895163f3fef3a360e01b815233838201908152602081018d905290915f9183919082908490829060400103925af1801561178a5761175d575b8b9695949392918b91611669565b8b9c506116259695949392916117738c92611ed3565b6116966116865f9f5050509192939495965061174f565b8a513d5f823e3d90fd5b61179e9033612215565b6117a884896123b0565b5f61160b565b865162461bcd60e51b8152602081880152601860248201527f576974686472617720616d6f756e7420746f6f206869676800000000000000006044820152606490fd5b823461050b575f36600319011261050b5760055490516001600160a01b039091168152602090f35b823461050b575f36600319011261050b5760025490516001600160a01b039091168152602090f35b90503461050b57602036600319011261050b573590600654821061186481611d54565b600164e8d4a510006118c161187886611c81565b50865f526008602052855f20335f52602052855f20946118a1858060a01b036005541691611d54565b6118aa886124f7565b8554806118de575b50506003855491015490611d92565b04910155515f81525f805160206128a683398151915260203392a3005b846118f16118fc92600386015490611d92565b048688015490611dd7565b9081156118b2576119106119169233612215565b886123b0565b87806118b2565b823461050b578060031936011261050b57611936611cce565b90336001600160a01b03831603611954575061195291356121a3565b005b5163334bd91960e11b81529050fd5b823461050b578060031936011261050b5761195291356119976001611986611cce565b93835f525f6020525f200154612043565b612127565b823461050b57602036600319011261050b57602091355f525f82526001815f2001549051908152f35b823461050b575f36600319011261050b576020906009549051908152f35b823461050b57602036600319011261050b5781359160065483101561050b57611a0d60c093611c81565b509160018060a01b038354169260018101549260028201549060038301549201549261ffff94815196875260208701528501526060840152818116608084015260101c1660a0820152f35b90503461050b57602036600319011261050b5780359061ffff9283831680840361050b57611a84611fed565b600254948560a01c169283821015611ae45750907f7fa0c746a78467fbdf5bb34adcbaa07b8d38d3ba394c9d90fd77569bb6c44d7691815193845260208401523392a261ffff60a01b1990911660a09190911b61ffff60a01b1617600255005b608490602084519162461bcd60e51b8352820152602260248201527f446576206d696e7420726174696f2063616e206f6e6c79206265206c6f776572604482015261195960f21b6064820152fd5b823461050b575f36600319011261050b57602091549051908152f35b823461050b57602036600319011261050b57813591611b6b611fed565b80548311611bb45750611b7c611f1d565b7feedc6338c9c1ad8f3cd6c90dd09dbe98dbd57e610d3e59a17996d07acb0d95116003549180519283528360208401523392a2600355005b6020606492519162461bcd60e51b8352820152601660248201527508adad2e6e6d2dedc40e4c2e8ca40e8dede40d0d2ced60531b6044820152fd5b823461050b575f36600319011261050b576020906006549051908152f35b903461050b57602036600319011261050b57359063ffffffff60e01b821680920361050b57602091637965db0b60e01b8114908115611c4e575b5015158152f35b6301ffc9a760e01b14905083611c47565b6044359061ffff8216820361050b57565b6064359061ffff8216820361050b57565b600654811015611cba5760059060065f52027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01905f90565b634e487b7160e01b5f52603260045260245ffd5b602435906001600160a01b038216820361050b57565b600435906001600160a01b038216820361050b57565b604090600319011261050b576004359060243590565b60843590811515820361050b57565b600754811015611cba5760075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801905f90565b15611d5b57565b60405162461bcd60e51b815260206004820152600f60248201526e141bdbdb081259081a5b9d985b1a59608a1b6044820152606490fd5b81810292918115918404141715611da557565b634e487b7160e01b5f52601160045260245ffd5b8115611dc3570490565b634e487b7160e01b5f52601260045260245ffd5b91908203918211611da557565b600654905f5b828110611df8575050505f90565b611e0181611c81565b50546001600160a01b03838116911614611e1d57600101611dea565b505050600190565b15611e2c57565b606460405162461bcd60e51b815260206004820152602060248201527f496e76616c6964206465706f7369742066656520626173697320706f696e74736044820152fd5b15611e7757565b60405162461bcd60e51b815260206004820152602160248201527f496e76616c69642077697468647261772066656520626173697320706f696e746044820152607360f81b6064820152608490fd5b91908201809211611da557565b67ffffffffffffffff8111611ee757604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff821117611ee757604052565b6006545f5b818110611f2d575050565b80611f396001926124f7565b01611f22565b5f818152600b60205260409020546001600160a01b0316908115611fc15750602060049160405192838092630f26e5ff60e21b82525afa908115611fb6575f91611f87575090565b90506020813d602011611fae575b81611fa260209383611efb565b8101031261050b575190565b3d9150611f95565b6040513d5f823e3d90fd5b611fcb9150611d1f565b90549060031b1c90565b9081602091031261050b5751801515810361050b5790565b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561202557565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f525f60205260405f20335f5260205260ff60405f205416156120645750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b6001600160a01b03165f8181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16612122575f8181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb560205260408120805460ff191660011790553391907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f205416155f1461219d57815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b50505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f2054165f1461219d57815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b600154604080516370a0823160e01b81523060048201526020946001600160a01b03938416949293919291908684602481895afa938415612335579087949392915f94612304575b50838111156122d25750600154855163a9059cbb60e01b81526001600160a01b0390931660048401526024830193909352909450849116815f81604481015b03925af19081156122c957506122b0575050565b816122c692903d106109e4576109d58183611efb565b50565b513d5f823e3d90fd5b855163a9059cbb60e01b81526001600160a01b03909316600484015260248301525093849150815f816044810161229c565b8581969295503d831161232e575b61231c8183611efb565b8101031261050b57869351925f61225d565b503d612312565b85513d5f823e3d90fd5b5f60443d1061239c57604051600319913d83016004833e815167ffffffffffffffff918282113d60248401111761239f578184019485519384116123a7573d8501016020848701011161239f575061239c92910160200190611efb565b90565b949350505050565b50949350505050565b5f908152600b602052604081205490916001600160a01b0391821691826123d8575b50505050565b60246020925f6040519586948593633bd73ee360e21b85521660048401525af19081612495575b5061248f5760015f60033d1161247f575b6308c379a014612469575b61242b575b505b5f8080806123d2565b612435575f612420565b60405162461bcd60e51b815260206004820152600c60248201526b10db185a5b4819985a5b195960a21b6044820152606490fd5b61247161233f565b1561241b5750505f8061241b565b5060045f803e5f5160e01c612410565b50612422565b6124ad9060203d6020116109e4576109d58183611efb565b505f6123ff565b60405163a9059cbb60e01b60208201526001600160a01b039290921660248301526044808301939093529181526124f5916124f0606483611efb565b612792565b565b61250081611c81565b5060028101918254905f914311156123d25761251b90611f3f565b801580156126a7575b61269f57612550610b46612545610b34875443814381116126945750611dd7565b600186015490611d92565b9260025461ffff8160a01c169081612617575b50506001546001600160a01b0316803b15610a72576040516340c10f1960e01b8152306004820152602481018690529084908290604490829084905af1801561260c579084916125f8575b50506003019283549264e8d4a51000918281029281840414901517156125e457506125dd9291610b8991611db9565b9055439055565b634e487b7160e01b81526011600452602490fd5b61260190611ed3565b6105b057825f6125ae565b6040513d86823e3d90fd5b6001546001600160a01b0392908316906064906126349089611d92565b0490803b1561050b576040516340c10f1960e01b8152939092166001600160a01b0316600484015260248301525f9082908183816044810103925af18015611fb657612681575b80612563565b61268c919350611ed3565b5f915f61267b565b91505043905f610b2e565b505050439055565b50600183015415612524565b5f818152600b60205260409020546001600160a01b0390811691826126d85750505050565b6126e190611c81565b505460405163095ea7b360e01b81526001600160a01b03841660048201526024810185905291602091839160449183915f91165af18015611fb657612773575b50803b1561050b576040516311f9fbc960e21b815233600482015260248101929092525f908290604490829084905af18015611fb657612764575b8080806123d2565b61276d90611ed3565b5f61275c565b61278b9060203d6020116109e4576109d58183611efb565b505f612721565b81516001600160a01b03909116915f91829160200182855af13d15612836573d67ffffffffffffffff8111611ee7576127ed91604051916127dd6020601f19601f8401160184611efb565b82523d5f602084013e5b83612842565b805190811515918261281b575b50506128035750565b60249060405190635274afe760e01b82526004820152fd5b61282e9250602080918301019101611fd5565b155f806127fa565b6127ed906060906127e7565b90612869575080511561285757805190602001fd5b604051630a12f52160e11b8152600490fd5b8151158061289c575b61287a575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561287256fe90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15a2646970667358221220b7750b702c70aad1764d7776543979a8a12019dc14e16dfa175e632b8b7f1cbf64736f6c63430008180033

Deployed ByteCode

0x6080604081815260049182361015610015575f80fd5b5f925f3560e01c91826301ffc9a714611c0d57508163081e3eda14611bef5781630ba84cd214611b4e57816312545ac314611b3257816312d6a19114611a585781631526fe27146119e357816317caf6f1146119c5578163248a9ca31461199c5781632f2ff15d1461196357816336568abe1461191d578163379607f5146118415781633ad10ef61461181957816341275358146117f1578163441a3e7014611567578163469ce95e1461153857816348cd4cb1146115195781634a7fa021146113c95781634d2ad53b1461126057816351eb05a6146112365781635312ea8e14611033578163630b5ba1146110175781636a6d964e14610fde578163771e6d5414610ee45781637bd7bde814610e10578163819a777e14610ddd5781638705fcd414610d9d5781638b7c048414610c9d5781638dbb1e3a14610c6b5781638e2e272314610c4b57816391d1485414610c0857816393f1a40b14610bbd57816398969e8214610a7657816398c99c9e14610916578163a217fddf146108fb578163d0d41fe1146108bb578163d1058e5914610839578163d4f5063b14610619578163d547741f146105da578163d86ec35f146105b4578163e2bbb1581461028f57508063e34f749114610244578063eb9b3e36146102265763f7c618c1146101fb575f80fd5b3461022257816003193601126102225760015490516001600160a01b039091168152602090f35b5080fd5b50346102225781600319360112610222576020906003549051908152f35b823461028c578060031936011261028c5761025d611fed565b6006546005546001600160a01b0316825b828110610279578380f35b80610286836001936123b0565b0161026e565b80fd5b9050346105b05761029f36611cfa565b90926006548410906102b082611d54565b826102ba86611c81565b5086885260209360088552838920335f528552835f209260018060a01b036102e6816005541693611d54565b6102ef8a6124f7565b84548061056c575b5081610339575b5050505f805160206128a683398151915294955064e8d4a5100061032b6001926003855491015490611d92565b04910155519283523392a380f35b835486516370a0823160e01b808252308c83015294995091169290918783602481875afa928315610562578c93610533575b508651906323b872dd60e01b8983015233602483015230604483015260648201526064815260a0810181811067ffffffffffffffff8211176105205787526103b39084612792565b855190815230898201528681602481865afa908115610516578b916104d2575b50925f805160206128a68339815191529764e8d4a51000936103fa61032b94600197611dd7565b9a8b61040d575b505050928897506102fe565b8301918b61ffff918285541615155f146104955761044261271061043a6104489561048d98541685611d92565b048093611dd7565b936124b4565b61047a6104548d611d1f565b6104648483548360031b1c611ec6565b82545f1960039390931b92831b1916911b179055565b610485818854611ec6565b87558b6126b3565b5f8080610401565b50505050506104b66104a68b611d1f565b6104648c83548360031b1c611ec6565b6104c1898654611ec6565b85556104cd898b6126b3565b61048d565b929390508683813d831161050f575b6104eb8183611efb565b8101031261050b5791519192915f805160206128a68339815191526103d3565b5f80fd5b503d6104e1565b86513d8d823e3d90fd5b60418b634e487b7160e01b5f525260245ffd5b9092508781813d831161055b575b61054b8183611efb565b8101031261050b5751915f61036b565b503d610541565b87513d8e823e3d90fd5b64e8d4a5100061058461059092600388015490611d92565b04600187015490611dd7565b80156102f7576105a09033612215565b6105aa838b6123b0565b5f6102f7565b8280fd5b50503461022257816003193601126102225760209061ffff60025460a01c169051908152f35b919050346105b057806003193601126105b057610615913561061060016105ff611cce565b938387528660205286200154612043565b6121a3565b5080f35b8383346102225760c0366003190112610222578235610636611cce565b9161063f611c5f565b90610648611c70565b90610651611d10565b9360a435801515810361050b57610666611fed565b61ffff8095169561068b8661271096610681888b1115611e25565b1695861115611e70565b61082c575b6107ed575b600a548043115f146107e85750435b6106b082600954611ec6565b60095582519260c0840184811067ffffffffffffffff8211176105205781526001600160a01b039788168452602084019283528301908152606083018881526080840196875260a08401948552600654680100000000000000009891939190898110156107d5578060016107279201600655611c81565b9590956107c35751855491166001600160a01b031990911617845551600184015551600283015551600382015592519286018054915163ffff000090841660101b1663ffffffff199092169290931663ffff0000191691909117179055600754908110156107b05780600161079f9201600755611d1f565b8154905f199060031b1b1916905580f35b506041602492634e487b7160e01b835252fd5b634e487b7160e01b8b528a8c5260248bfd5b634e487b7160e01b8b5260418c5260248bfd5b6106a4565b6107f686611de4565b1561069557815162461bcd60e51b81526020818a0152600b60248201526a506f6f6c2065786973747360a81b6044820152606490fd5b610834611f1d565b610690565b9050346105b057826003193601126105b05760065491835b83811061085c578480f35b303b156108ad57848251631c57762b60e31b81528285820152816024820152818160448183305af180156108b157610899575b5050600101610851565b6108a290611ed3565b6108ad57845f61088f565b8480fd5b84513d84823e3d90fd5b833461028c57602036600319011261028c576108d5611ce4565b6108dd611fed565b60018060a01b03166001600160601b0360a01b600254161760025580f35b50503461022257816003193601126102225751908152602090f35b9050346105b05760209182600319360112610a7257610933611ce4565b61093b611fed565b61094481611de4565b610a315781516370a0823160e01b815230818501526001600160a01b0391909116928482602481875afa918215610a27579085929187926109f4575b50835163a9059cbb60e01b8152339181019182526020820192909252909384918290889082906040015b03925af19081156109eb57506109be578280f35b816109dd92903d106109e4575b6109d58183611efb565b810190611fd5565b505f808280f35b503d6109cb565b513d85823e3d90fd5b8381949293503d8311610a20575b610a0c8183611efb565b8101031261050b57905184916109aa610980565b503d610a02565b83513d88823e3d90fd5b509180606493519262461bcd60e51b845283015260248201527f4465706f736974656420746f6b656e732063616e6e6f742062652073617665646044820152fd5b8380fd5b82843461028c578160031936011261028c578235610a92611cce565b610a9f6006548310611d54565b610aa882611c81565b509082845260086020528484209060018060a01b03165f52602052835f2092610ad5600383015493611f3f565b91600281015480431180610bb4575b610b14575b602087610b0d88600164e8d4a51000610b038b8454611d92565b0491015490611dd7565b9051908152f35b610b4f916001610b3d610b34610b46944381438111610ba9575b50611dd7565b60035490611d92565b91015490611d92565b60095490611db9565b9064e8d4a5100091828102928184041490151715610b96575060209550610b03610b8f610b0d9594610b8960019564e8d4a5100095611db9565b90611ec6565b9394610ae9565b634e487b7160e01b815260118752602490fd5b91505043908e610b2e565b50831515610ae4565b9050823461028c578260031936011261028c578290610bda611cce565b923581526008602052209060018060a01b03165f52602052805f206001815491015482519182526020820152f35b9050346105b057816003193601126105b05781602093610c26611cce565b92358152808552209060018060a01b03165f52825260ff815f20541690519015158152f35b82843461028c57602036600319011261028c5750610b0d60209235611f3f565b50503461022257602090610b0d610c8136611cfa565b8082818111610c92575b5050611dd7565b915091508580610c8b565b8391503461022257602036600319011261022257803592610cc16006548510611d54565b610cc9611fed565b838352600b602052808320546001600160a01b0316918215610d4857836001610cfa8297610cf5611f1d565b611c81565b500155823b15610d43578151633630153360e01b81529284918491829084905af1908115610d3a5750610d2a5750f35b610d3390611ed3565b61028c5780f35b513d84823e3d90fd5b505050fd5b6020608492519162461bcd60e51b8352820152602a60248201527f4e6565646564206f6e6c7920666f7220706f6f6c73207769746820726568797060448201526937ba3432b1b0ba34b7b760b11b6064820152fd5b833461028c57602036600319011261028c57610db7611ce4565b610dbf611fed565b60018060a01b03166001600160601b0360a01b600554161760055580f35b9050346105b05760203660031901126105b057358252600b6020908152918190205490516001600160a01b039091168152f35b919050346105b057806003193601126105b0576024356001600160a01b038116928035918490036108ad57610e486006548310611d54565b610e50611fed565b610e5982611f3f565b610e7b57508352600b602052822080546001600160a01b031916909117905580f35b608490602084519162461bcd60e51b8352820152603a60248201527f52656879706f746865636174696f6e2070726f746f636f6c2063616e2062652060448201527f6368616e676564206f6e6c79206f6e20656d70747920706f6f6c0000000000006064820152fd5b9050346105b05760e03660031901126105b0576001600160a01b03813581811692908390036108ad5760643582811680910361050b576084359161ffff8316830361050b5760a4359484861680960361050b5760c43596600154958616610fa65750438710610fa2576001600160601b0360a01b8095161760015560243560035560443590556002549161ffff60a01b9060a01b169169ffffffffffffffffffff60b01b1617176002556005541617600555600a5561061533612082565b8780fd5b5162461bcd60e51b81526020818401526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606490fd5b9050346105b05760203660031901126105b057359160075483101561028c5750611009602092611d1f565b91905490519160031b1c8152f35b833461028c578060031936011261028c57611030611f1d565b80f35b919050346105b05760209182600319360112610a72578035926110596006548510611d54565b61106284611c81565b509284865260088252808620335f528252805f20928660018554958281550155858752600b835260018060a01b039081838920541690816110f7575b5050837fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059594956110ed926110e46110d48a611d1f565b6104648683548360031b1c611dd7565b339154166124b4565b519283523392a380f35b9091945060018601546111b05787916024859285519485938492631bfc726f60e21b845233908401525af19081156111a6578791611159575b5092807fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059561109e565b90508281813d831161119f575b6111708183611efb565b8101031261050b57517fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae0595611130565b503d611166565b82513d89823e3d90fd5b825162461bcd60e51b8152908101849052605460248201527f456d657267656e637920776974686472617720666f7220706f6f6c732077697460448201527f682072656879706f746865636174696f6e20697320616c6c6f776564206f6e6c6064820152737920666f7220696e61637469766520706f6f6c7360601b608482015260a490fd5b83903461022257602036600319011261022257611030903561125b6006548210611d54565b6124f7565b9050346105b057602080600319360112610a725781356112836006548210611d54565b61128b611fed565b6005545f918252600b835290849020546001600160a01b039081169116816112b1578580f35b915f916024869794839697519485938492633bd73ee360e21b84528a8401525af190816113ac575b5061139f57505f60033d11611390575b6308c379a014611323575b606492519162461bcd60e51b8352820152600c60248201526b10db185a5b4819985a5b195960a21b6044820152fd5b61132b61233f565b8061133657506112f4565b8282855193849262461bcd60e51b84528301528251908160248401525f935b828510611377575050604492505f838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350611355565b50815f803e5f5160e01c6112e9565b925050505f808080808580f35b6113c290843d86116109e4576109d58183611efb565b505f6112d9565b839150346102225760a0366003190112610222576024359080356113eb611c5f565b926113f4611c70565b936113fd611d10565b9161140b6006548510611d54565b611413611fed565b61ffff809216906127109361142a85841115611e25565b61143984891695861115611e70565b61150c575b6114618161145c60095460016114538a611c81565b50015490611dd7565b611ec6565b600955600161146f86611c81565b5001558461147c85611c81565b50019061ffff198254161790558361149384611c81565b50015460101c16106114c957906114ad6110309392611c81565b50019063ffff000082549160101b169063ffff00001916179055565b845162461bcd60e51b8152602081840181905260248201527f5769746864726177206665652063616e6e6f7420626520696e637265617365646044820152606490fd5b611514611f1d565b61143e565b505034610222578160031936011261022257602090600a549051908152f35b5050346102225760203660031901126102225760209061155e611559611ce4565b611de4565b90519015158152f35b9190503461050b5761157836611cfa565b919092600654841061158981611d54565b61159285611c81565b5090855f526008602052835f20335f52602052835f209060018060a01b0390816005541690878454106117ae57918893916115d06115f39694611d54565b6115d9856124f7565b82549389600382019564e8d4a51000988991885490611d92565b0498611605600187019a8b5490611dd7565b80611794575b5081611655575b5050505050611625925054905490611d92565b049055519081527ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b56860203392a380f35b875f52600b602052848b5f20541680611706575b506116966116866116259961167f858a54611dd7565b8955611d1f565b6104648583548360031b1c611dd7565b8201805461ffff919060101c8216156116f0576127106116c86116e597946116dd96946116d4945460101c1690611d92565b048095848454166124b4565b5416918a611dd7565b9033906124b4565b87925f808981611612565b5050915061170192339154166124b4565b6116e5565b915091929394959650803b1561050b57895163f3fef3a360e01b815233838201908152602081018d905290915f9183919082908490829060400103925af1801561178a5761175d575b8b9695949392918b91611669565b8b9c506116259695949392916117738c92611ed3565b6116966116865f9f5050509192939495965061174f565b8a513d5f823e3d90fd5b61179e9033612215565b6117a884896123b0565b5f61160b565b865162461bcd60e51b8152602081880152601860248201527f576974686472617720616d6f756e7420746f6f206869676800000000000000006044820152606490fd5b823461050b575f36600319011261050b5760055490516001600160a01b039091168152602090f35b823461050b575f36600319011261050b5760025490516001600160a01b039091168152602090f35b90503461050b57602036600319011261050b573590600654821061186481611d54565b600164e8d4a510006118c161187886611c81565b50865f526008602052855f20335f52602052855f20946118a1858060a01b036005541691611d54565b6118aa886124f7565b8554806118de575b50506003855491015490611d92565b04910155515f81525f805160206128a683398151915260203392a3005b846118f16118fc92600386015490611d92565b048688015490611dd7565b9081156118b2576119106119169233612215565b886123b0565b87806118b2565b823461050b578060031936011261050b57611936611cce565b90336001600160a01b03831603611954575061195291356121a3565b005b5163334bd91960e11b81529050fd5b823461050b578060031936011261050b5761195291356119976001611986611cce565b93835f525f6020525f200154612043565b612127565b823461050b57602036600319011261050b57602091355f525f82526001815f2001549051908152f35b823461050b575f36600319011261050b576020906009549051908152f35b823461050b57602036600319011261050b5781359160065483101561050b57611a0d60c093611c81565b509160018060a01b038354169260018101549260028201549060038301549201549261ffff94815196875260208701528501526060840152818116608084015260101c1660a0820152f35b90503461050b57602036600319011261050b5780359061ffff9283831680840361050b57611a84611fed565b600254948560a01c169283821015611ae45750907f7fa0c746a78467fbdf5bb34adcbaa07b8d38d3ba394c9d90fd77569bb6c44d7691815193845260208401523392a261ffff60a01b1990911660a09190911b61ffff60a01b1617600255005b608490602084519162461bcd60e51b8352820152602260248201527f446576206d696e7420726174696f2063616e206f6e6c79206265206c6f776572604482015261195960f21b6064820152fd5b823461050b575f36600319011261050b57602091549051908152f35b823461050b57602036600319011261050b57813591611b6b611fed565b80548311611bb45750611b7c611f1d565b7feedc6338c9c1ad8f3cd6c90dd09dbe98dbd57e610d3e59a17996d07acb0d95116003549180519283528360208401523392a2600355005b6020606492519162461bcd60e51b8352820152601660248201527508adad2e6e6d2dedc40e4c2e8ca40e8dede40d0d2ced60531b6044820152fd5b823461050b575f36600319011261050b576020906006549051908152f35b903461050b57602036600319011261050b57359063ffffffff60e01b821680920361050b57602091637965db0b60e01b8114908115611c4e575b5015158152f35b6301ffc9a760e01b14905083611c47565b6044359061ffff8216820361050b57565b6064359061ffff8216820361050b57565b600654811015611cba5760059060065f52027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01905f90565b634e487b7160e01b5f52603260045260245ffd5b602435906001600160a01b038216820361050b57565b600435906001600160a01b038216820361050b57565b604090600319011261050b576004359060243590565b60843590811515820361050b57565b600754811015611cba5760075f527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801905f90565b15611d5b57565b60405162461bcd60e51b815260206004820152600f60248201526e141bdbdb081259081a5b9d985b1a59608a1b6044820152606490fd5b81810292918115918404141715611da557565b634e487b7160e01b5f52601160045260245ffd5b8115611dc3570490565b634e487b7160e01b5f52601260045260245ffd5b91908203918211611da557565b600654905f5b828110611df8575050505f90565b611e0181611c81565b50546001600160a01b03838116911614611e1d57600101611dea565b505050600190565b15611e2c57565b606460405162461bcd60e51b815260206004820152602060248201527f496e76616c6964206465706f7369742066656520626173697320706f696e74736044820152fd5b15611e7757565b60405162461bcd60e51b815260206004820152602160248201527f496e76616c69642077697468647261772066656520626173697320706f696e746044820152607360f81b6064820152608490fd5b91908201809211611da557565b67ffffffffffffffff8111611ee757604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff821117611ee757604052565b6006545f5b818110611f2d575050565b80611f396001926124f7565b01611f22565b5f818152600b60205260409020546001600160a01b0316908115611fc15750602060049160405192838092630f26e5ff60e21b82525afa908115611fb6575f91611f87575090565b90506020813d602011611fae575b81611fa260209383611efb565b8101031261050b575190565b3d9150611f95565b6040513d5f823e3d90fd5b611fcb9150611d1f565b90549060031b1c90565b9081602091031261050b5751801515810361050b5790565b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561202557565b60405163e2517d3f60e01b81523360048201525f6024820152604490fd5b805f525f60205260405f20335f5260205260ff60405f205416156120645750565b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b6001600160a01b03165f8181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16612122575f8181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb560205260408120805460ff191660011790553391907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f205416155f1461219d57815f525f60205260405f20815f5260205260405f20600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b50505f90565b90815f525f60205260405f209060018060a01b031690815f5260205260ff60405f2054165f1461219d57815f525f60205260405f20815f5260205260405f2060ff19815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b600154604080516370a0823160e01b81523060048201526020946001600160a01b03938416949293919291908684602481895afa938415612335579087949392915f94612304575b50838111156122d25750600154855163a9059cbb60e01b81526001600160a01b0390931660048401526024830193909352909450849116815f81604481015b03925af19081156122c957506122b0575050565b816122c692903d106109e4576109d58183611efb565b50565b513d5f823e3d90fd5b855163a9059cbb60e01b81526001600160a01b03909316600484015260248301525093849150815f816044810161229c565b8581969295503d831161232e575b61231c8183611efb565b8101031261050b57869351925f61225d565b503d612312565b85513d5f823e3d90fd5b5f60443d1061239c57604051600319913d83016004833e815167ffffffffffffffff918282113d60248401111761239f578184019485519384116123a7573d8501016020848701011161239f575061239c92910160200190611efb565b90565b949350505050565b50949350505050565b5f908152600b602052604081205490916001600160a01b0391821691826123d8575b50505050565b60246020925f6040519586948593633bd73ee360e21b85521660048401525af19081612495575b5061248f5760015f60033d1161247f575b6308c379a014612469575b61242b575b505b5f8080806123d2565b612435575f612420565b60405162461bcd60e51b815260206004820152600c60248201526b10db185a5b4819985a5b195960a21b6044820152606490fd5b61247161233f565b1561241b5750505f8061241b565b5060045f803e5f5160e01c612410565b50612422565b6124ad9060203d6020116109e4576109d58183611efb565b505f6123ff565b60405163a9059cbb60e01b60208201526001600160a01b039290921660248301526044808301939093529181526124f5916124f0606483611efb565b612792565b565b61250081611c81565b5060028101918254905f914311156123d25761251b90611f3f565b801580156126a7575b61269f57612550610b46612545610b34875443814381116126945750611dd7565b600186015490611d92565b9260025461ffff8160a01c169081612617575b50506001546001600160a01b0316803b15610a72576040516340c10f1960e01b8152306004820152602481018690529084908290604490829084905af1801561260c579084916125f8575b50506003019283549264e8d4a51000918281029281840414901517156125e457506125dd9291610b8991611db9565b9055439055565b634e487b7160e01b81526011600452602490fd5b61260190611ed3565b6105b057825f6125ae565b6040513d86823e3d90fd5b6001546001600160a01b0392908316906064906126349089611d92565b0490803b1561050b576040516340c10f1960e01b8152939092166001600160a01b0316600484015260248301525f9082908183816044810103925af18015611fb657612681575b80612563565b61268c919350611ed3565b5f915f61267b565b91505043905f610b2e565b505050439055565b50600183015415612524565b5f818152600b60205260409020546001600160a01b0390811691826126d85750505050565b6126e190611c81565b505460405163095ea7b360e01b81526001600160a01b03841660048201526024810185905291602091839160449183915f91165af18015611fb657612773575b50803b1561050b576040516311f9fbc960e21b815233600482015260248101929092525f908290604490829084905af18015611fb657612764575b8080806123d2565b61276d90611ed3565b5f61275c565b61278b9060203d6020116109e4576109d58183611efb565b505f612721565b81516001600160a01b03909116915f91829160200182855af13d15612836573d67ffffffffffffffff8111611ee7576127ed91604051916127dd6020601f19601f8401160184611efb565b82523d5f602084013e5b83612842565b805190811515918261281b575b50506128035750565b60249060405190635274afe760e01b82526004820152fd5b61282e9250602080918301019101611fd5565b155f806127fa565b6127ed906060906127e7565b90612869575080511561285757805190602001fd5b604051630a12f52160e11b8152600490fd5b8151158061289c575b61287a575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561287256fe90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15a2646970667358221220b7750b702c70aad1764d7776543979a8a12019dc14e16dfa175e632b8b7f1cbf64736f6c63430008180033