ETH Price: $2,908.32 (-0.58%)

Contract

0xFA8f5A99Dd104E0489DB960B6a74776dF19Daead

Overview

ETH Balance

Linea Mainnet LogoLinea Mainnet LogoLinea Mainnet Logo0 ETH

ETH Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Add Rewards153996012025-02-04 1:11:02356 days ago1738631462IN
0xFA8f5A99...dF19Daead
0 ETH0.000022270.10863803
Add Rewards153851872025-02-03 16:09:36356 days ago1738598976IN
0xFA8f5A99...dF19Daead
0 ETH0.000028170.17685179
Sell Keys153314422025-02-02 8:43:31358 days ago1738485811IN
0xFA8f5A99...dF19Daead
0 ETH0.000011540.10742857
Sell Keys153313712025-02-02 8:40:58358 days ago1738485658IN
0xFA8f5A99...dF19Daead
0 ETH0.000013730.10742857
Withdraw Rewards151147352025-01-27 19:01:51363 days ago1738004511IN
0xFA8f5A99...dF19Daead
0 ETH0.000089960.75028572
Add Rewards151147242025-01-27 19:01:29363 days ago1738004489IN
0xFA8f5A99...dF19Daead
0 ETH0.000158030.75028572
Sell Keys151146962025-01-27 19:00:27363 days ago1738004427IN
0xFA8f5A99...dF19Daead
0 ETH0.000078890.75028572
Sell Keys150557462025-01-26 8:18:23365 days ago1737879503IN
0xFA8f5A99...dF19Daead
0 ETH0.000011540.10742857
Sell Keys150439272025-01-26 1:24:59365 days ago1737854699IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Withdraw Rewards150439102025-01-26 1:24:22365 days ago1737854662IN
0xFA8f5A99...dF19Daead
0 ETH0.00001480.10742857
Add Rewards150438982025-01-26 1:23:57365 days ago1737854637IN
0xFA8f5A99...dF19Daead
0 ETH0.000015280.10742857
Add Rewards150320862025-01-25 18:30:12365 days ago1737829812IN
0xFA8f5A99...dF19Daead
0 ETH0.000022020.10742857
Add Rewards150206452025-01-25 12:08:10365 days ago1737806890IN
0xFA8f5A99...dF19Daead
0 ETH0.00001870.10742857
Sell Keys150200282025-01-25 11:47:36365 days ago1737805656IN
0xFA8f5A99...dF19Daead
0 ETH0.000011020.10742857
Sell Keys150200012025-01-25 11:46:42365 days ago1737805602IN
0xFA8f5A99...dF19Daead
0 ETH0.000011540.10742857
Sell Keys150198592025-01-25 11:41:58365 days ago1737805318IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150197492025-01-25 11:38:18365 days ago1737805098IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150197202025-01-25 11:37:19365 days ago1737805039IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150196832025-01-25 11:36:04365 days ago1737804964IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150196562025-01-25 11:35:10365 days ago1737804910IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150196202025-01-25 11:33:58365 days ago1737804838IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150195812025-01-25 11:32:40365 days ago1737804760IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150194392025-01-25 11:27:56365 days ago1737804476IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150194112025-01-25 11:27:00365 days ago1737804420IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
Sell Keys150193692025-01-25 11:25:36365 days ago1737804336IN
0xFA8f5A99...dF19Daead
0 ETH0.000011290.10742857
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
200395652025-06-15 19:05:09224 days ago1750014309
0xFA8f5A99...dF19Daead
5.16887 ETH
200395652025-06-15 19:05:09224 days ago1750014309
0xFA8f5A99...dF19Daead
0 ETH
200395652025-06-15 19:05:09224 days ago1750014309
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153996012025-02-04 1:11:02356 days ago1738631462
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153851872025-02-03 16:09:36356 days ago1738598976
0xFA8f5A99...dF19Daead
0 ETH
153314422025-02-02 8:43:31358 days ago1738485811
0xFA8f5A99...dF19Daead
0.00010312 ETH
153314422025-02-02 8:43:31358 days ago1738485811
0xFA8f5A99...dF19Daead
0 ETH
153314422025-02-02 8:43:31358 days ago1738485811
0xFA8f5A99...dF19Daead
0.0001375 ETH
153314422025-02-02 8:43:31358 days ago1738485811
0xFA8f5A99...dF19Daead
0.00010312 ETH
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MemefiKeys

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 15 runs

Other Settings:
paris EvmVersion, MIT license
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.18;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {IMemefiManagement} from "../management/IMemefiManagement.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract MemefiKeys is EIP712 {
    using SafeERC20 for IERC20;

    modifier onlyMainAdmin() {
        require(msg.sender == memefiManagement.mainAdmin(), "Not a main owner");
        _;
    }

    // --------- EVENTS ---------- //
    event Trade(
        address indexed trader,
        address indexed subject,
        uint256 keyAmount,
        uint256 tokenAmount,
        uint256 protocolFee,
        uint256 subjectFee,
        uint256 supply,
        uint256 nonce,
        uint256 rewardIndexOf,
        uint256 pendingRewards,
        bool isBuy
    );

    event Payed(
        address indexed payer,
        uint256 paymentType,
        address paymentToken,
        uint256 amount,
        uint256 nonce
    );

    event RewardAdded(
        address indexed subject,
        uint256 amount,
        uint256 rewardIndex,
        uint256[] nonces
    );

    event RewardWithdraw(
        address indexed receiver,
        address indexed subject,
        uint256 amount,
        uint256 rewardIndexOf
    );

    event NewSigner(address newSigner);

    event NewRewardDistributor(address newRewardDistributor);

    event AdminWithdrawUnclaimedRewards(uint256 amount);

    event NewRewardsToken(address newRewardsToken);

    event FeesUpdated(
        uint256 protocolFeePercent,
        uint256 subjectFeePercent,
        uint256 revenueFeePercent
    );

    // --------- VARIABLES ---------- //
    uint256 public protocolFeePercent;
    uint256 public subjectFeePercent;
    uint256 public revenueFeePercent;
    uint256 public constant firstKeyPrice = 6e13; // 0,00006 ETH

    // Nonce => used times
    mapping(uint256 => uint256) public nonceUsingCount;

    // KeysSubject => (Holder => Balance)
    mapping(address => mapping(address => uint256)) public keysBalance;

    // KeysSubject => Supply
    mapping(address => uint256) public keysSupply;

    // Management contract
    IMemefiManagement public immutable memefiManagement;

    uint256 private constant MULTIPLIER = 1e18;
    // KeysSubject => RewardIndex
    mapping(address => uint256) private rewardIndex;
    // KeysSubject => (Holder => RewardIndex)
    mapping(address => mapping(address => uint256)) private rewardIndexOf;
    // KeysSubject => (Holder => Earned)
    mapping(address => mapping(address => uint256)) public earned;
    // KeysSubject => (Holder => Reward Withdrawn)
    mapping(address => mapping(address => uint256)) public rewardWithdrawn;

    uint256 public totalUnclaimedRewards;

    // --------- CONSTRUCTOR ---------- //

    constructor(address _memefiManagement) EIP712("Memefi", "1") {
        memefiManagement = IMemefiManagement(_memefiManagement);
        require(_memefiManagement != address(0), "No management contract");
        require(
            memefiManagement.feesDistributor() != address(0),
            "No fees distributor"
        );
        require(
            memefiManagement.memefiToken() != address(0),
            "No memefi token"
        );
        protocolFeePercent = 30000000000000000;
        subjectFeePercent = 40000000000000000;
        revenueFeePercent = 30000000000000000;
        emit FeesUpdated(
            protocolFeePercent,
            subjectFeePercent,
            revenueFeePercent
        );
    }

    // --------- ADMIN FUNCTIONS ---------- //

    function setFees(
        uint256 _protocolFeePercent,
        uint256 _subjectFeePercent,
        uint256 _revenueFeePercent
    ) public onlyMainAdmin {
        require(
            _protocolFeePercent + _subjectFeePercent + _revenueFeePercent <=
                100000000000000000,
            "Fees must be less than 10%"
        );
        protocolFeePercent = _protocolFeePercent;
        subjectFeePercent = _subjectFeePercent;
        revenueFeePercent = _revenueFeePercent;
        emit FeesUpdated(
            _protocolFeePercent,
            _subjectFeePercent,
            _revenueFeePercent
        );
    }

    function memefiToken() public view returns (address) {
        return memefiManagement.memefiToken();
    }

    // --------- MATH FUNCTIONS ---------- //
    function _calculatePriceAndFees(
        uint256 supply,
        uint256 amount
    ) internal view returns (uint256, uint256, uint256, uint256) {
        uint256 price = getPrice(supply, amount);
        (
            uint256 protocolFee,
            uint256 subjectFee,
            uint256 revenueFee
        ) = _calculateFees(price);
        return (price, protocolFee, subjectFee, revenueFee);
    }

    function _calculateFees(
        uint256 price
    ) internal view returns (uint256, uint256, uint256) {
        uint256 protocolFee = (price * protocolFeePercent) / 1 ether;
        uint256 subjectFee = (price * subjectFeePercent) / 1 ether;
        uint256 revenueFee = (price * revenueFeePercent) / 1 ether;
        return (protocolFee, subjectFee, revenueFee);
    }

    function getPrice(
        uint256 supply,
        uint256 amount
    ) public view returns (uint256) {
        if (amount == 0) return 0;
        if (supply == 0) {
            return firstKeyPrice + getPrice(1, amount - 1);
        }
        uint256 sum1 = ((supply - 1) * (supply) * (2 * (supply - 1) + 1)) / 6;
        uint256 sum2 = ((supply - 1 + amount) *
            (supply + amount) *
            (2 * (supply - 1 + amount) + 1)) / 6;
        uint256 summation = sum2 - sum1;
        uint256 price = ((summation * 1 ether) / 16000);

        return price;
    }

    function getBuyPrice(
        address keysSubject,
        uint256 amount
    ) public view returns (uint256) {
        return getPrice(keysSupply[keysSubject], amount);
    }

    function getSellPrice(
        address keysSubject,
        uint256 amount
    ) public view returns (uint256) {
        return getPrice(keysSupply[keysSubject] - amount, amount);
    }

    function getBuyPriceAfterFee(
        address keysSubject,
        uint256 amount
    ) public view returns (uint256) {
        uint256 price = getBuyPrice(keysSubject, amount);
        (
            uint256 protocolFee,
            uint256 subjectFee,
            uint256 revenueFee
        ) = _calculateFees(price);
        return price + protocolFee + subjectFee + revenueFee;
    }

    function getSellPriceAfterFee(
        address keysSubject,
        uint256 amount
    ) public view returns (uint256) {
        uint256 price = getSellPrice(keysSubject, amount);
        (
            uint256 protocolFee,
            uint256 subjectFee,
            uint256 revenueFee
        ) = _calculateFees(price);
        return price - protocolFee - subjectFee - revenueFee;
    }

    function rewardOf(
        address keysSubject,
        address account
    ) external view returns (uint256, uint256, uint256) {
        return (
            earned[keysSubject][account],
            rewardWithdrawn[keysSubject][account],
            calculateReward(keysSubject, account)
        );
    }

    function calculateReward(
        address keysSubject,
        address account
    ) public view returns (uint256) {
        return _calculateRewards(keysSubject, account);
    }

    function _updateRewards(address keysSubject, address account) private {
        earned[keysSubject][account] += _calculateRewards(keysSubject, account);
        rewardIndexOf[keysSubject][account] = rewardIndex[keysSubject];
    }

    // --------- SIGNATURE FUNCTIONS ---------- //

    function _checkSignatureKeys(
        address paymentToken,
        uint256 paymentAmount,
        uint256[] memory itemIds,
        uint256[] memory itemMaxUsers,
        uint256 paymentType,
        uint256 nonce,
        uint256 deadline,
        bytes memory signature
    ) internal returns (bool) {
        require(deadline >= block.timestamp, "Signature expired");

        bytes32 typedHash = _hashTypedDataV4(
            keccak256(
                abi.encode(
                    keccak256(
                        "Payment(address executor,address paymentToken,uint256 paymentAmount,uint256[] itemIds,uint256[] itemMaxUsers,uint256 paymentType,uint256 nonce,uint256 deadline)"
                    ),
                    msg.sender,
                    paymentToken,
                    paymentAmount,
                    keccak256(abi.encodePacked(itemIds)),
                    keccak256(abi.encodePacked(itemMaxUsers)),
                    paymentType,
                    nonce,
                    deadline
                )
            )
        );

        return ECDSA.recover(typedHash, signature) == memefiManagement.signer();
    }

    function _checkSignatureRewards(
        address subject,
        uint256 amount,
        uint256 amountToSubject,
        uint256 nonce,
        bytes memory signature
    ) internal returns (bool) {
        bytes32 typedHash = _hashTypedDataV4(
            keccak256(
                abi.encode(
                    keccak256(
                        "AddReward(address subject,uint256 amount,uint256 amountToSubject,uint256 nonce)"
                    ),
                    subject,
                    amount,
                    amountToSubject,
                    nonce
                )
            )
        );

        return ECDSA.recover(typedHash, signature) == memefiManagement.signer();
    }

    // --------- REENTRENCY FUNCTIONS ---------- //

    function _useNonce(uint256 nonce, uint256 maxUseCount) internal {
        require(nonceUsingCount[nonce] < maxUseCount, "Nonce already used");
        nonceUsingCount[nonce] += 1;
    }

    // --------- MAIN FUNCTIONS ---------- //

    function _paymentTransfer(
        address paymentToken,
        uint256 paymentAmount,
        uint256 price,
        uint256 protocolFee,
        uint256 subjectFee,
        uint256 revenueFee
    ) internal {
        uint256 ethPaymentAmount = paymentToken == address(0)
            ? paymentAmount
            : 0;
        if (paymentToken == address(0)) {
            require(
                msg.value ==
                    price +
                        protocolFee +
                        subjectFee +
                        revenueFee +
                        ethPaymentAmount,
                "Insufficient payment"
            );
            _transaferEthIfNeeded(memefiManagement.treasury(), ethPaymentAmount);
        } else {
            if (paymentAmount > 0) {
                IERC20(paymentToken).safeTransferFrom(
                    msg.sender,
                    memefiManagement.treasury(),
                    paymentAmount
                );
            }
        }
    }

    function _addKeysBalanceAndSupply(
        address keysSubject,
        uint256 amount
    ) internal {
        keysBalance[keysSubject][msg.sender] += amount;
        keysSupply[keysSubject] += amount;
    }

    function _removeKeysBalanceAndSupply(
        address keysSubject,
        uint256 amount
    ) internal {
        keysBalance[keysSubject][msg.sender] -= amount;
        keysSupply[keysSubject] -= amount;
    }

    function _addKeysWithTransfer(
        address paymentToken,
        uint256 paymentAmount,
        uint256 supply,
        uint256 amount,
        address keysSubject,
        uint256 nonce
    ) internal {
        (
            uint256 price,
            uint256 protocolFee,
            uint256 subjectFee,
            uint256 revenueFee
        ) = _calculatePriceAndFees(supply, amount);

        _paymentTransfer(
            paymentToken,
            paymentAmount,
            price,
            protocolFee,
            subjectFee,
            revenueFee
        );

        _addKeysBalanceAndSupply(keysSubject, amount);

        _transferTokens(
            keysSubject,
            price,
            protocolFee,
            subjectFee,
            revenueFee,
            false
        );

        _emitTrade(
            keysSubject,
            amount,
            price,
            protocolFee,
            subjectFee,
            nonce,
            true
        );
    }

    function _emitTrade(
        address keySubject,
        uint256 amount,
        uint256 price,
        uint256 protocolFee,
        uint256 subjectFee,
        uint256 nonce,
        bool isBuy
    ) internal {
        uint256 rewardIndexOfP = rewardIndexOf[keySubject][msg.sender];
        uint256 earnedP = _calculateRewards(keySubject, msg.sender);
        uint256 supply = keysSupply[keySubject];
        emit Trade(
            msg.sender,
            keySubject,
            amount,
            price,
            protocolFee,
            subjectFee,
            supply,
            nonce,
            rewardIndexOfP,
            earnedP,
            isBuy
        );
    }

    function _removeKeysWithTransfer(
        uint256 supply,
        uint256 amount,
        address keysSubject
    ) internal {
        (
            uint256 price,
            uint256 protocolFee,
            uint256 subjectFee,
            uint256 revenueFee
        ) = _calculatePriceAndFees(supply - amount, amount);
        require(
            keysBalance[keysSubject][msg.sender] >= amount,
            "Insufficient keys"
        );

        _removeKeysBalanceAndSupply(keysSubject, amount);

        _transferTokens(
            keysSubject,
            price,
            protocolFee,
            subjectFee,
            revenueFee,
            true
        );

        _emitTrade(
            keysSubject,
            amount,
            price,
            protocolFee,
            subjectFee,
            0,
            false
        );
    }

    function _transaferEthIfNeeded(address to, uint256 amount) internal {
        if (amount > 0) {
            (bool success, ) = to.call{value: amount}("");
            require(success, "Unable to send funds");
        }
    }

    function _transferTokens(
        address keysSubject,
        uint256 price,
        uint256 protocolFee,
        uint256 subjectFee,
        uint256 revenueFee,
        bool isSell
    ) internal {
        if (isSell) {
            _transaferEthIfNeeded(
                msg.sender,
                price - protocolFee - subjectFee - revenueFee
            );
        }
        _transaferEthIfNeeded(memefiManagement.treasury(), protocolFee);
        _transaferEthIfNeeded(keysSubject, subjectFee);
        _transaferEthIfNeeded(memefiManagement.feesDistributor(), revenueFee);
    }

    function buyKeysWithPayment(
        address keysSubject,
        uint256 amount,
        address paymentToken,
        uint256 paymentAmount,
        uint256[] memory itemIds,
        uint256[] memory itemMaxUsers,
        uint256 nonce,
        uint256 deadline,
        bytes memory signature
    ) public payable {
        // we dont use pay() function because paymnet will be done in _buyKeys() function
        require(nonce > 0, "Nonce required");
        require(itemIds.length == itemMaxUsers.length, "Len mismatch");
        _useNonce(nonce, 1);
        for (uint256 i = 0; i < itemIds.length; i++) {
            _useNonce(itemIds[i], itemMaxUsers[i]);
        }
        require(
            _checkSignatureKeys(
                paymentToken,
                paymentAmount,
                itemIds,
                itemMaxUsers,
                0,
                nonce,
                deadline,
                signature
            ),
            "Invalid signature"
        );

        _buyKeys(paymentToken, paymentAmount, keysSubject, amount, nonce);
    }

    function pay(
        address paymentToken,
        uint256 paymentAmount,
        uint256[] memory itemIds,
        uint256[] memory itemMaxUsers,
        uint256 paymentType,
        uint256 nonce,
        uint256 deadline,
        bytes memory signature
    ) public payable {
        require(nonce > 0, "Nonce required");
        require(itemIds.length == itemMaxUsers.length, "Len mismatch");
        require(paymentAmount > 0, "Payment amount must be greater than 0");
        _useNonce(nonce, 1);
        for (uint256 i = 0; i < itemIds.length; i++) {
            _useNonce(itemIds[i], itemMaxUsers[i]);
        }
        require(
            _checkSignatureKeys(
                paymentToken,
                paymentAmount,
                itemIds,
                itemMaxUsers,
                paymentType,
                nonce,
                deadline,
                signature
            ),
            "Invalid signature"
        );

        if (paymentToken == address(0)) {
            require(msg.value == paymentAmount, "Invalid payment amount");
            (bool success, ) = memefiManagement.treasury().call{
                value: msg.value
            }("");
            require(success, "Unable to send funds");
        } else {
            IERC20(paymentToken).safeTransferFrom(
                msg.sender,
                memefiManagement.treasury(),
                paymentAmount
            );
        }
        emit Payed(msg.sender, paymentType, paymentToken, paymentAmount, nonce);
    }

    function buyKeys(address keysSubject, uint256 amount) public payable {
        require(
            keysSupply[keysSubject] > 0,
            "Initial key must be bought with payment"
        );
        _buyKeys(address(0), 0, keysSubject, amount, 0);
    }

    function _buyKeys(
        address paymentToken,
        uint256 paymentAmount,
        address keysSubject,
        uint256 amount,
        uint256 nonce
    ) internal {
        uint256 supply = keysSupply[keysSubject];
        require(
            supply > 0 || keysSubject == msg.sender,
            "Only the keys' subject can buy the first key"
        );

        //Updating rewards
        _updateRewards(keysSubject, msg.sender);

        //Add keys
        _addKeysWithTransfer(
            paymentToken,
            paymentAmount,
            supply,
            amount,
            keysSubject,
            nonce
        );
    }

    function sellKeys(address keysSubject, uint256 amount) public payable {
        uint256 supply = keysSupply[keysSubject];
        require(supply > amount, "Cannot sell the last key");

        //Updating rewards
        _updateRewards(keysSubject, msg.sender);

        //Remove keys
        _removeKeysWithTransfer(supply, amount, keysSubject);
    }

    function addRewardsInBatches(
        address[] memory subjects,
        uint256[] memory amountsToAdd,
        uint256[] memory amountsToSubject,
        uint256[] memory nonces,
        bytes[] memory signatures
    ) external {
        require(subjects.length > 0, "No subjects");
        if (subjects.length == 1) {
            return
                addRewards(
                    subjects[0],
                    amountsToAdd,
                    amountsToSubject,
                    nonces,
                    signatures
                );
        }
        uint256 batchesCount;
        uint256[] memory batchesStartIndexes = new uint256[](subjects.length);
        for (uint256 i = 1; i < subjects.length; i++) {
            if (i == 0) {
                batchesCount++;
                batchesStartIndexes[batchesCount] = i;
            } else {
                if (subjects[i] != subjects[i - 1]) {
                    batchesCount++;
                    batchesStartIndexes[batchesCount] = i;
                }
            }
        }
        for (uint256 i = 0; i < batchesCount; i++) {
            uint256 batchStartIndex = batchesStartIndexes[i];
            uint256 batchLastIndex = i == batchesCount - 1
                ? subjects.length - 1
                : batchesStartIndexes[i + 1] - 1;
            uint256 len = batchLastIndex - batchStartIndex + 1;
            uint256[] memory batchAmountsToAdd = new uint256[](len);
            uint256[] memory batchAmountsToSubject = new uint256[](len);
            uint256[] memory batchNonces = new uint256[](len);
            bytes[] memory batchSignatures = new bytes[](len);
            for (uint256 j = batchStartIndex; j <= batchLastIndex; j++) {
                uint256 intIndex = j - batchStartIndex;
                batchAmountsToAdd[intIndex] = amountsToAdd[j];
                batchAmountsToSubject[intIndex] = amountsToSubject[j];
                batchNonces[intIndex] = nonces[j];
                batchSignatures[intIndex] = signatures[j];
            }
            addRewards(
                subjects[i],
                batchAmountsToAdd,
                batchAmountsToSubject,
                batchNonces,
                batchSignatures
            );
        }
    }

    function addRewards(
        address subject,
        uint256[] memory amountsToAdd,
        uint256[] memory amountsToSubject,
        uint256[] memory nonces,
        bytes[] memory signatures
    ) public {
        require(
            amountsToAdd.length == nonces.length &&
                nonces.length == amountsToSubject.length &&
                amountsToSubject.length == signatures.length,
            "Arrays length mismatch"
        );

        require(
            keysBalance[subject][msg.sender] > 0,
            "Only keyholder can add rewards"
        );

        uint256 rewardsSum;
        uint256 sumToSubject;
        for (uint256 i = 0; i < amountsToAdd.length; i++) {
            require(
                _checkSignatureRewards(
                    subject,
                    amountsToAdd[i],
                    amountsToSubject[i],
                    nonces[i],
                    signatures[i]
                ),
                "Invalid signature"
            );
            _useNonce(nonces[i], 1);
            rewardsSum += amountsToAdd[i];
            sumToSubject += amountsToSubject[i];
        }

        _addReward(subject, rewardsSum, sumToSubject, nonces);
        _withdrawReward(subject, msg.sender);
        if (sumToSubject > 0) {
            IERC20 mt = IERC20(memefiManagement.memefiToken());
            mt.safeTransfer(subject, sumToSubject);
        }
    }

    function _addReward(
        address keysSubject,
        uint256 reward,
        uint256 rewardToSubject,
        uint256[] memory nonces
    ) internal {
        uint256 pureReward = reward - rewardToSubject;
        if (reward > 0) {
            IERC20 mt = IERC20(memefiManagement.memefiToken());
            mt.safeTransferFrom(
                memefiManagement.rewardDistributor(),
                address(this),
                reward
            );
        }
        if (pureReward > 0) {
            rewardIndex[keysSubject] +=
                (pureReward * MULTIPLIER) /
                keysSupply[keysSubject];
            totalUnclaimedRewards += pureReward;
            emit RewardAdded(
                keysSubject,
                pureReward,
                rewardIndex[keysSubject],
                nonces
            );
        }
    }

    function _calculateRewards(
        address keysSubject,
        address account
    ) private view returns (uint256) {
        uint256 keys = keysBalance[keysSubject][account];
        return
            (keys *
                (rewardIndex[keysSubject] -
                    rewardIndexOf[keysSubject][account])) / MULTIPLIER;
    }

    function _withdrawReward(
        address keySubject,
        address rewardReceiver
    ) internal returns (uint256) {
        _updateRewards(keySubject, rewardReceiver);

        uint256 reward = earned[keySubject][rewardReceiver];

        if (reward > 0) {
            totalUnclaimedRewards -= reward;
            rewardWithdrawn[keySubject][rewardReceiver] += reward;
            earned[keySubject][rewardReceiver] = 0;
            IERC20 mt = IERC20(memefiManagement.memefiToken());
            mt.safeTransfer(rewardReceiver, reward);
            emit RewardWithdraw(
                rewardReceiver,
                keySubject,
                reward,
                rewardIndexOf[keySubject][rewardReceiver]
            );
        }

        return reward;
    }

    function withdrawReward(address keySubject) public returns (uint256) {
        uint256 reward = _withdrawReward(keySubject, msg.sender);
        require(reward > 0, "No reward to withdraw");
        return reward;
    }

    function withdrawRewards(
        address[] memory keySubjects
    ) external returns (uint256) {
        uint256 totalReward;
        for (uint256 i = 0; i < keySubjects.length; i++) {
            totalReward += _withdrawReward(keySubjects[i], msg.sender);
        }
        require(totalReward > 0, "No reward to withdraw");
        return totalReward;
    }

    // SWAP FUNCTIONS
    function withdrawOnSwap(
        address tokenAddress,
        uint256 amount
    ) external {
        require(
            msg.sender == address(memefiManagement) ||
                msg.sender == memefiManagement.mainAdmin(),
            "Not allowed"
        );
        if (tokenAddress == address(0)) {
            (bool success, ) = msg.sender.call{value: amount}("");
            require(success, "Unable to send funds");
        } else {
            IERC20(tokenAddress).safeTransfer(msg.sender, amount);
        }
    }
}

File 2 of 15 : 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
        );
}

// 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);
}

// 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);
}

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

// 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();
        }
    }
}

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

// 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
        }
    }
}

// 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));
    }
}

// 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);
        }
    }
}

// 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);
    }
}

// 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)
        }
    }
}

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

// 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);
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.18;

interface IMemefiManagement {
    function treasury() external returns (address);

    function signer() external returns (address);

    function rewardDistributor() external returns (address);

    function mainAdmin() external returns (address);

    function hasRole(
        uint256 role,
        address walletAddress
    ) external view returns (bool);

    function uniqueRoleAddress(
        uint256 uniqueRole
    ) external view returns (address);

    function memefiToken() external view returns (address);

    function storageSlot(uint256 _slot) external view returns (string memory);

    function feesDistributor() external returns (address);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_memefiManagement","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AdminWithdrawUnclaimedRewards","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"protocolFeePercent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"subjectFeePercent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"revenueFeePercent","type":"uint256"}],"name":"FeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newRewardDistributor","type":"address"}],"name":"NewRewardDistributor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newRewardsToken","type":"address"}],"name":"NewRewardsToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newSigner","type":"address"}],"name":"NewSigner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"uint256","name":"paymentType","type":"uint256"},{"indexed":false,"internalType":"address","name":"paymentToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"Payed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"subject","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardIndex","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"nonces","type":"uint256[]"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"subject","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardIndexOf","type":"uint256"}],"name":"RewardWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"subject","type":"address"},{"indexed":false,"internalType":"uint256","name":"keyAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"protocolFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"subjectFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"supply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardIndexOf","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pendingRewards","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isBuy","type":"bool"}],"name":"Trade","type":"event"},{"inputs":[{"internalType":"address","name":"subject","type":"address"},{"internalType":"uint256[]","name":"amountsToAdd","type":"uint256[]"},{"internalType":"uint256[]","name":"amountsToSubject","type":"uint256[]"},{"internalType":"uint256[]","name":"nonces","type":"uint256[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"addRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"subjects","type":"address[]"},{"internalType":"uint256[]","name":"amountsToAdd","type":"uint256[]"},{"internalType":"uint256[]","name":"amountsToSubject","type":"uint256[]"},{"internalType":"uint256[]","name":"nonces","type":"uint256[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"addRewardsInBatches","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyKeys","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"itemMaxUsers","type":"uint256[]"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"buyKeysWithPayment","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"calculateReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstKeyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getBuyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getBuyPriceAfterFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getSellPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getSellPriceAfterFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"keysBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"keysSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"memefiManagement","outputs":[{"internalType":"contract IMemefiManagement","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"memefiToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nonceUsingCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"itemMaxUsers","type":"uint256[]"},{"internalType":"uint256","name":"paymentType","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"pay","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"protocolFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revenueFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"rewardOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"rewardWithdrawn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keysSubject","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sellKeys","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_protocolFeePercent","type":"uint256"},{"internalType":"uint256","name":"_subjectFeePercent","type":"uint256"},{"internalType":"uint256","name":"_revenueFeePercent","type":"uint256"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subjectFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalUnclaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawOnSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"keySubject","type":"address"}],"name":"withdrawReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"keySubjects","type":"address[]"}],"name":"withdrawRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

6101806040523480156200001257600080fd5b506040516200403a3803806200403a8339810160408190526200003591620003f0565b60408051808201825260068152654d656d65666960d01b602080830191909152825180840190935260018352603160f81b90830152906200007882600062000374565b610120526200008981600162000374565b61014052815160208084019190912060e052815190820120610100524660a0526200011760e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c0526001600160a01b038116610160819052620001825760405162461bcd60e51b815260206004820152601660248201527f4e6f206d616e6167656d656e7420636f6e74726163740000000000000000000060448201526064015b60405180910390fd5b60006001600160a01b0316610160516001600160a01b0316638e0bae7f6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015620001d1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001f79190620003f0565b6001600160a01b0316036200024f5760405162461bcd60e51b815260206004820152601360248201527f4e6f2066656573206469737472696275746f7200000000000000000000000000604482015260640162000179565b60006001600160a01b0316610160516001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200029c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002c29190620003f0565b6001600160a01b0316036200030c5760405162461bcd60e51b815260206004820152600f60248201526e27379036b2b6b2b334903a37b5b2b760891b604482015260640162000179565b666a94d74f4300006002819055668e1bc9bf040000600381905560048290556040805183815260208101929092528101919091527fcf8a1e1d5f09cf3c97dbb653cd9a4d7aace9292fbc1bb8211febf2d400febbdd9060600160405180910390a15062000608565b600060208351101562000394576200038c83620003ad565b9050620003a7565b81620003a18482620004c7565b5060ff90505b92915050565b600080829050601f81511115620003db578260405163305a27a960e01b815260040162000179919062000593565b8051620003e882620005e3565b179392505050565b6000602082840312156200040357600080fd5b81516001600160a01b03811681146200041b57600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200044d57607f821691505b6020821081036200046e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620004c257600081815260208120601f850160051c810160208610156200049d5750805b601f850160051c820191505b81811015620004be57828155600101620004a9565b5050505b505050565b81516001600160401b03811115620004e357620004e362000422565b620004fb81620004f4845462000438565b8462000474565b602080601f8311600181146200053357600084156200051a5750858301515b600019600386901b1c1916600185901b178555620004be565b600085815260208120601f198616915b82811015620005645788860151825594840194600190910190840162000543565b5085821015620005835787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083528351808285015260005b81811015620005c257858101830151858201604001528201620005a4565b506000604082860101526040601f19601f8301168501019250505092915050565b805160208083015191908110156200046e5760001960209190910360031b1b16919050565b60805160a05160c05160e0516101005161012051610140516101605161395c620006de600039600081816101bc015281816108cc01528181610b2f01528181610c2d01528181610d2801528181610d5101528181611286015281816118b101528181611b5a01528181611d1c01528181611dde01528181611e650152818161209e015281816126a00152818161273701528181612b570152612bf0015260006122d7015260006122aa015260006129640152600061293c01526000612897015260006128c1015260006128eb015261395c6000f3fe60806040526004361061015d5760003560e01c80630f026f6d146101625780631d1e84b3146101955780631dd1b2bb146101aa578063211dc32d146101eb57806321c2024d146102235780632267a89c1461024357806324dc441d146102635780632d826bdf14610279578063324777bf14610293578063342465cb146102a65780633bb36b5c146102bc5780634635256e146102dc5780634732aa1d146102fc578063592de11d146103375780635cf4ee911461034a57806362d76d061461036a57806369f066a31461038a5780637756df44146103a05780637ca44fcf146103cd57806384b0196e146103ed5780639111ac89146104155780639ae7178114610428578063b86e321c14610448578063cec10c1114610468578063cfd88b1214610488578063d6e6eb9f146104c0578063e575ab96146104d6578063e6e88e2914610503578063ead097c014610523578063fc255d6514610538575b600080fd5b34801561016e57600080fd5b5061018261017d366004612fb2565b610570565b6040519081526020015b60405180910390f35b6101a86101a3366004613121565b6105c1565b005b3480156101b657600080fd5b506101de7f000000000000000000000000000000000000000000000000000000000000000081565b60405161018c91906131f1565b3480156101f757600080fd5b50610182610206366004613205565b600a60209081526000928352604080842090915290825290205481565b34801561022f57600080fd5b506101a861023e3660046132bd565b6106b6565b34801561024f57600080fd5b5061018261025e366004612fb2565b61096d565b34801561026f57600080fd5b5061018260035481565b34801561028557600080fd5b50610182653691d6afc00081565b6101a86102a136600461337c565b6109b1565b3480156102b257600080fd5b5061018260045481565b3480156102c857600080fd5b506101a86102d7366004612fb2565b610d1d565b3480156102e857600080fd5b506101826102f7366004612fb2565b610eb5565b34801561030857600080fd5b5061031c610317366004613205565b610edf565b6040805193845260208401929092529082015260600161018c565b6101a8610345366004612fb2565b610f38565b34801561035657600080fd5b5061018261036536600461343b565b610fbc565b34801561037657600080fd5b506101826103853660046134c1565b6110ec565b34801561039657600080fd5b50610182600c5481565b3480156103ac57600080fd5b506101826103bb3660046134f5565b60056020526000908152604090205481565b3480156103d957600080fd5b506101826103e8366004613205565b61115d565b3480156103f957600080fd5b50610402611169565b60405161018c9796959493929190613599565b6101a8610423366004612fb2565b6111af565b34801561043457600080fd5b50610182610443366004612fb2565b611227565b34801561045457600080fd5b50610182610463366004613609565b611255565b34801561047457600080fd5b506101a8610483366004613626565b611284565b34801561049457600080fd5b506101826104a3366004613205565b600b60209081526000928352604080842090915290825290205481565b3480156104cc57600080fd5b5061018260025481565b3480156104e257600080fd5b506101826104f1366004613609565b60076020526000908152604090205481565b34801561050f57600080fd5b506101a861051e366004613652565b611419565b34801561052f57600080fd5b506101de6118ad565b34801561054457600080fd5b50610182610553366004613205565b600660209081526000928352604080842090915290825290205481565b60008061057d8484610eb5565b9050600080600061058d84611936565b9194509250905080826105a085876136b9565b6105aa91906136b9565b6105b491906136b9565b9450505050505b92915050565b600083116105ea5760405162461bcd60e51b81526004016105e1906136cc565b60405180910390fd5b835185511461060b5760405162461bcd60e51b81526004016105e1906136f4565b6106168360016119b5565b60005b85518110156106705761065e8682815181106106375761063761371a565b60200260200101518683815181106106515761065161371a565b60200260200101516119b5565b8061066881613730565b915050610619565b50610682878787876000888888611a2f565b61069e5760405162461bcd60e51b81526004016105e190613749565b6106ab87878b8b87611c07565b505050505050505050565b815184511480156106c8575082518251145b80156106d5575080518351145b61071a5760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b60448201526064016105e1565b6001600160a01b038516600090815260066020908152604080832033845290915290205461078a5760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c79206b6579686f6c6465722063616e206164642072657761726473000060448201526064016105e1565b60008060005b86518110156108aa5761080a888883815181106107af576107af61371a565b60200260200101518884815181106107c9576107c961371a565b60200260200101518885815181106107e3576107e361371a565b60200260200101518886815181106107fd576107fd61371a565b6020026020010151611cb7565b6108265760405162461bcd60e51b81526004016105e190613749565b61084a85828151811061083b5761083b61371a565b602002602001015160016119b5565b86818151811061085c5761085c61371a565b60200260200101518361086f91906136b9565b92508581815181106108835761088361371a565b60200260200101518261089691906136b9565b9150806108a281613730565b915050610790565b506108b787838387611dc6565b6108c18733611fd8565b5080156109645760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094c9190613774565b90506109626001600160a01b038216898461218a565b505b50505050505050565b60008061097a8484611227565b9050600080600061098a84611936565b91945092509050808261099d8587613791565b6109a79190613791565b6105b49190613791565b600083116109d15760405162461bcd60e51b81526004016105e1906136cc565b84518651146109f25760405162461bcd60e51b81526004016105e1906136f4565b60008711610a505760405162461bcd60e51b815260206004820152602560248201527f5061796d656e7420616d6f756e74206d75737420626520677265617465722074604482015264068616e20360dc1b60648201526084016105e1565b610a5b8360016119b5565b60005b8651811015610aa857610a96878281518110610a7c57610a7c61371a565b60200260200101518783815181106106515761065161371a565b80610aa081613730565b915050610a5e565b50610ab98888888888888888611a2f565b610ad55760405162461bcd60e51b81526004016105e190613749565b6001600160a01b038816610c2757863414610b2b5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a59081c185e5b595b9d08185b5bdd5b9d60521b60448201526064016105e1565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb19190613774565b6001600160a01b03163460405160006040518083038185875af1925050503d8060008114610bfb576040519150601f19603f3d011682016040523d82523d6000602084013e610c00565b606091505b5050905080610c215760405162461bcd60e51b81526004016105e1906137a4565b50610cc1565b610cc1337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190613774565b6001600160a01b038b1691908a6121e9565b604080518581526001600160a01b038a1660208201529081018890526060810184905233907fce6d38800f185a3ea05a466d1da359c3aedecb48740391666def25626b8e71ca9060800160405180910390a25050505050505050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480610de857507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fb6b04ba6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd39190613774565b6001600160a01b0316336001600160a01b0316145b610e225760405162461bcd60e51b815260206004820152600b60248201526a139bdd08185b1b1bddd95960aa1b60448201526064016105e1565b6001600160a01b038216610e9d57604051600090339083908381818185875af1925050503d8060008114610e72576040519150601f19603f3d011682016040523d82523d6000602084013e610e77565b606091505b5050905080610e985760405162461bcd60e51b81526004016105e1906137a4565b505050565b610eb16001600160a01b038316338361218a565b5050565b6001600160a01b038216600090815260076020526040812054610ed89083610fbc565b9392505050565b6001600160a01b038083166000818152600a6020908152604080832094861680845294825280832054938352600b82528083209483529390529182205482918291610f2a878761115d565b9250925092505b9250925092565b6001600160a01b038216600090815260076020526040902054610fad5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c206b6579206d75737420626520626f756768742077697468206044820152661c185e5b595b9d60ca1b60648201526084016105e1565b610eb160008084846000611c07565b600081600003610fce575060006105bb565b82600003610ffc57610fe560016103658185613791565b610ff590653691d6afc0006136b9565b90506105bb565b6000600661100b600186613791565b6110169060026137d2565b6110219060016136b9565b8561102d600182613791565b61103791906137d2565b61104191906137d2565b61104b91906137e9565b9050600060068461105d600188613791565b61106791906136b9565b6110729060026137d2565b61107d9060016136b9565b61108786886136b9565b8661109360018a613791565b61109d91906136b9565b6110a791906137d2565b6110b191906137d2565b6110bb91906137e9565b905060006110c98383613791565b90506000613e806110e283670de0b6b3a76400006137d2565b6105b491906137e9565b60008060005b835181101561113c5761111e8482815181106111105761111061371a565b602002602001015133611fd8565b61112890836136b9565b91508061113481613730565b9150506110f2565b50600081116105bb5760405162461bcd60e51b81526004016105e19061380b565b6000610ed88383612228565b60006060806000806000606061117d6122a3565b6111856122d0565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b6001600160a01b0382166000908152600760205260409020548181116112125760405162461bcd60e51b815260206004820152601860248201527743616e6e6f742073656c6c20746865206c617374206b657960401b60448201526064016105e1565b61121c83336122fd565b610e98818385612374565b6001600160a01b038216600090815260076020526040812054610ed89061124f908490613791565b83610fbc565b6000806112628333611fd8565b9050600081116105bb5760405162461bcd60e51b81526004016105e19061380b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663fb6b04ba6040518163ffffffff1660e01b81526004016020604051808303816000875af11580156112e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113089190613774565b6001600160a01b0316336001600160a01b03161461135b5760405162461bcd60e51b815260206004820152601060248201526f2737ba10309036b0b4b71037bbb732b960811b60448201526064016105e1565b67016345785d8a00008161136f84866136b9565b61137991906136b9565b11156113c45760405162461bcd60e51b815260206004820152601a60248201527946656573206d757374206265206c657373207468616e2031302560301b60448201526064016105e1565b60028390556003829055600481905560408051848152602081018490529081018290527fcf8a1e1d5f09cf3c97dbb653cd9a4d7aace9292fbc1bb8211febf2d400febbdd9060600160405180910390a1505050565b60008551116114585760405162461bcd60e51b815260206004820152600b60248201526a4e6f207375626a6563747360a81b60448201526064016105e1565b845160010361148d57611488856000815181106114775761147761371a565b6020026020010151858585856106b6565b6118a6565b60008086516001600160401b038111156114a9576114a9612fde565b6040519080825280602002602001820160405280156114d2578160200160208202803683370190505b50905060015b87518110156115ae578060000361151a57826114f381613730565b935050808284815181106115095761150961371a565b60200260200101818152505061159c565b87611526600183613791565b815181106115365761153661371a565b60200260200101516001600160a01b03168882815181106115595761155961371a565b60200260200101516001600160a01b03161461159c578261157981613730565b9350508082848151811061158f5761158f61371a565b6020026020010181815250505b806115a681613730565b9150506114d8565b5060005b828110156109625760008282815181106115ce576115ce61371a565b6020026020010151905060006001856115e79190613791565b8314611621576001846115fa85836136b9565b8151811061160a5761160a61371a565b602002602001015161161c9190613791565b61162f565b60018a5161162f9190613791565b9050600061163d8383613791565b6116489060016136b9565b90506000816001600160401b0381111561166457611664612fde565b60405190808252806020026020018201604052801561168d578160200160208202803683370190505b5090506000826001600160401b038111156116aa576116aa612fde565b6040519080825280602002602001820160405280156116d3578160200160208202803683370190505b5090506000836001600160401b038111156116f0576116f0612fde565b604051908082528060200260200182016040528015611719578160200160208202803683370190505b5090506000846001600160401b0381111561173657611736612fde565b60405190808252806020026020018201604052801561176957816020015b60608152602001906001900390816117545790505b509050865b8681116118765760006117818983613791565b90508f82815181106117955761179561371a565b60200260200101518682815181106117af576117af61371a565b6020026020010181815250508e82815181106117cd576117cd61371a565b60200260200101518582815181106117e7576117e761371a565b6020026020010181815250508d82815181106118055761180561371a565b602002602001015184828151811061181f5761181f61371a565b6020026020010181815250508c828151811061183d5761183d61371a565b60200260200101518382815181106118575761185761371a565b602002602001018190525050808061186e90613730565b91505061176e565b5061188c8f89815181106114775761147761371a565b50505050505050808061189e90613730565b9150506115b2565b5050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561190d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119319190613774565b905090565b600080600080670de0b6b3a76400006002548661195391906137d2565b61195d91906137e9565b90506000670de0b6b3a76400006003548761197891906137d2565b61198291906137e9565b90506000670de0b6b3a76400006004548861199d91906137d2565b6119a791906137e9565b929791965091945092505050565b6000828152600560205260409020548111611a075760405162461bcd60e51b8152602060048201526012602482015271139bdb98d948185b1c9958591e481d5cd95960721b60448201526064016105e1565b6000828152600560205260408120805460019290611a269084906136b9565b90915550505050565b600042831015611a755760405162461bcd60e51b815260206004820152601160248201527014da59db985d1d5c9948195e1c1a5c9959607a1b60448201526064016105e1565b6000611b567fe99b1c2a501b1c1e183b113a9d9b7c30f5e07f07821bf8cd7d0a38961d366eb8338c8c8c604051602001611aaf919061383a565b604051602081830303815290604052805190602001208c604051602001611ad6919061383a565b60408051601f198184030181528282528051602091820120908301979097526001600160a01b0395861690820152939092166060840152608083015260a082015260c081019190915260e0810188905261010081018790526101208101869052610140015b60405160208183030381529060405280519060200120612426565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663238ac9336040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdc9190613774565b6001600160a01b0316611bef8285612453565b6001600160a01b0316149a9950505050505050505050565b6001600160a01b03831660009081526007602052604090205480151580611c3657506001600160a01b03841633145b611c975760405162461bcd60e51b815260206004820152602c60248201527f4f6e6c7920746865206b65797327207375626a6563742063616e20627579207460448201526b6865206669727374206b657960a01b60648201526084016105e1565b611ca184336122fd565b611caf86868386888761247d565b505050505050565b604080517f2ae13b3e9f43dd3f483ddedf916486af119d991a488c9df2f4c08da49b92358260208201526001600160a01b03871691810191909152606081018590526080810184905260a081018390526000908190611d189060c001611b3b565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663238ac9336040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611d7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9e9190613774565b6001600160a01b0316611db18285612453565b6001600160a01b031614979650505050505050565b6000611dd28385613791565b90508315611efb5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5e9190613774565b9050611ef97f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663acc2166a6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee79190613774565b6001600160a01b0383169030886121e9565b505b80156118a6576001600160a01b038516600090815260076020526040902054611f2c670de0b6b3a7640000836137d2565b611f3691906137e9565b6001600160a01b03861660009081526008602052604081208054909190611f5e9084906136b9565b9250508190555080600c6000828254611f7791906136b9565b90915550506001600160a01b038516600081815260086020526040908190205490517fa6af97c57588b1f0a3d42c13588e8017f413111a8e7f5b9cc832899bfe18d42e91611fc9918591908790613870565b60405180910390a25050505050565b6000611fe483836122fd565b6001600160a01b038084166000908152600a60209081526040808320938616835292905220548015610ed85780600c60008282546120229190613791565b90915550506001600160a01b038085166000908152600b602090815260408083209387168352929052908120805483929061205e9084906136b9565b90915550506001600160a01b038085166000908152600a602090815260408083208785168452825280832083905580516303ab425f60e61b8152905192937f0000000000000000000000000000000000000000000000000000000000000000169263ead097c0926004808401939192918290030181865afa1580156120e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210b9190613774565b90506121216001600160a01b038216858461218a565b6001600160a01b03858116600081815260096020908152604080832094891680845294825291829020548251878152918201529192917f95ce0e9616a1212f228bd4500789cf3572aab0777f130b1a29484dbff0587acd910160405180910390a3509392505050565b6040516001600160a01b03838116602483015260448201839052610e9891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506124d8565b6040516001600160a01b0384811660248301528381166044830152606482018390526122229186918216906323b872dd906084016121b7565b50505050565b6001600160a01b0380831660008181526006602090815260408083209486168084529482528083205484845260098352818420958452948252808320549383526008909152812054909291670de0b6b3a7640000916122879190613791565b61229190836137d2565b61229b91906137e9565b949350505050565b60606119317f00000000000000000000000000000000000000000000000000000000000000006000612532565b60606119317f00000000000000000000000000000000000000000000000000000000000000006001612532565b6123078282612228565b6001600160a01b038084166000908152600a602090815260408083209386168352929052908120805490919061233e9084906136b9565b90915550506001600160a01b03918216600090815260086020908152604080832054600983528184209490951683529290522055565b600080808061238c6123868789613791565b876125d6565b6001600160a01b0389166000908152600660209081526040808320338452909152902054939750919550935091508611156123fd5760405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e74206b65797360781b60448201526064016105e1565b612407858761260c565b6124168585858585600161266c565b61096485878686866000806127bf565b60006105bb61243361288a565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060008061246386866129b5565b92509250925061247382826129ff565b5090949350505050565b60008060008061248d88886125d6565b93509350935093506124a38a8a86868686612ab8565b6124ad8688612c84565b6124bc8685858585600061266c565b6124cc86888686868a60016127bf565b50505050505050505050565b60006124ed6001600160a01b03841683612ce4565b905080516000141580156125125750808060200190518101906125109190613898565b155b15610e985782604051635274afe760e01b81526004016105e191906131f1565b606060ff831461254557610ff583612cf2565b818054612551906138ba565b80601f016020809104026020016040519081016040528092919081815260200182805461257d906138ba565b80156125ca5780601f1061259f576101008083540402835291602001916125ca565b820191906000526020600020905b8154815290600101906020018083116125ad57829003601f168201915b505050505090506105bb565b60008060008060006125e88787610fbc565b905060008060006125f884611936565b959c919b5099509397509295505050505050565b6001600160a01b03821660009081526006602090815260408083203384529091528120805483929061263f908490613791565b90915550506001600160a01b03821660009081526007602052604081208054839290611a26908490613791565b801561269b5761269b338385612682888a613791565b61268c9190613791565b6126969190613791565b612d31565b6127287f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af11580156126fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127229190613774565b85612d31565b6127328684612d31565b611caf7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638e0bae7f6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612795573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b99190613774565b83612d31565b6001600160a01b038716600090815260096020908152604080832033808552925282205491906127f0908a90612228565b6001600160a01b038a166000818152600760209081526040918290205482518d81529182018c90529181018a9052606081018990526080810182905260a0810188905260c0810186905260e081018490528615156101008201529293509133907f22a9d5b18fa6904e4e44967debf208c9ccb69a36eceed9ede0dab19030d87335906101200160405180910390a350505050505050505050565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156128e357507f000000000000000000000000000000000000000000000000000000000000000046145b1561290d57507f000000000000000000000000000000000000000000000000000000000000000090565b611931604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080600083516041036129ef5760208401516040850151606086015160001a6129e188828585612d84565b955095509550505050610f31565b5050815160009150600290610f31565b6000826003811115612a1357612a136138f4565b03612a1c575050565b6001826003811115612a3057612a306138f4565b03612a4e5760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115612a6257612a626138f4565b03612a835760405163fce698f760e01b8152600481018290526024016105e1565b6003826003811115612a9757612a976138f4565b03610eb1576040516335e2f38360e21b8152600481018290526024016105e1565b60006001600160a01b03871615612ad0576000612ad2565b855b90506001600160a01b038716612be457808284612aef87896136b9565b612af991906136b9565b612b0391906136b9565b612b0d91906136b9565b3414612b525760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b60448201526064016105e1565b612bdf7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bd99190613774565b82612d31565b610964565b851561096457610964337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612c4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c729190613774565b6001600160a01b038a169190896121e9565b6001600160a01b038216600090815260066020908152604080832033845290915281208054839290612cb79084906136b9565b90915550506001600160a01b03821660009081526007602052604081208054839290611a269084906136b9565b6060610ed883836000612e49565b60606000612cff83612ee6565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b8015610eb1576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610e72576040519150601f19603f3d011682016040523d82523d6000602084013e610e77565b600080806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03841115612db55750600091506003905082612e3f565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015612e09573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612e3557506000925060019150829050612e3f565b9250600091508190505b9450945094915050565b606081471015612e6e573060405163cd78605960e01b81526004016105e191906131f1565b600080856001600160a01b03168486604051612e8a919061390a565b60006040518083038185875af1925050503d8060008114612ec7576040519150601f19603f3d011682016040523d82523d6000602084013e612ecc565b606091505b5091509150612edc868383612f0e565b9695505050505050565b600060ff8216601f8111156105bb57604051632cd44ac360e21b815260040160405180910390fd5b606082612f2357612f1e82612f61565b610ed8565b8151158015612f3a57506001600160a01b0384163b155b15612f5a5783604051639996b31560e01b81526004016105e191906131f1565b5080610ed8565b805115612f715780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b6001600160a01b0381168114612f8a57600080fd5b8035612fad81612f8d565b919050565b60008060408385031215612fc557600080fd5b8235612fd081612f8d565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561301c5761301c612fde565b604052919050565b60006001600160401b0382111561303d5761303d612fde565b5060051b60200190565b600082601f83011261305857600080fd5b8135602061306d61306883613024565b612ff4565b82815260059290921b8401810191818101908684111561308c57600080fd5b8286015b848110156130a75780358352918301918301613090565b509695505050505050565b600082601f8301126130c357600080fd5b81356001600160401b038111156130dc576130dc612fde565b6130ef601f8201601f1916602001612ff4565b81815284602083860101111561310457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060008060006101208a8c03121561314057600080fd5b6131498a612fa2565b985060208a0135975061315e60408b01612fa2565b965060608a0135955060808a01356001600160401b038082111561318157600080fd5b61318d8d838e01613047565b965060a08c01359150808211156131a357600080fd5b6131af8d838e01613047565b955060c08c0135945060e08c013593506101008c01359150808211156131d457600080fd5b506131e18c828d016130b2565b9150509295985092959850929598565b6001600160a01b0391909116815260200190565b6000806040838503121561321857600080fd5b823561322381612f8d565b9150602083013561323381612f8d565b809150509250929050565b600082601f83011261324f57600080fd5b8135602061325f61306883613024565b82815260059290921b8401810191818101908684111561327e57600080fd5b8286015b848110156130a75780356001600160401b038111156132a15760008081fd5b6132af8986838b01016130b2565b845250918301918301613282565b600080600080600060a086880312156132d557600080fd5b85356132e081612f8d565b945060208601356001600160401b03808211156132fc57600080fd5b61330889838a01613047565b9550604088013591508082111561331e57600080fd5b61332a89838a01613047565b9450606088013591508082111561334057600080fd5b61334c89838a01613047565b9350608088013591508082111561336257600080fd5b5061336f8882890161323e565b9150509295509295909350565b600080600080600080600080610100898b03121561339957600080fd5b6133a289612fa2565b97506020890135965060408901356001600160401b03808211156133c557600080fd5b6133d18c838d01613047565b975060608b01359150808211156133e757600080fd5b6133f38c838d01613047565b965060808b0135955060a08b0135945060c08b0135935060e08b013591508082111561341e57600080fd5b5061342b8b828c016130b2565b9150509295985092959890939650565b6000806040838503121561344e57600080fd5b50508035926020909101359150565b600082601f83011261346e57600080fd5b8135602061347e61306883613024565b82815260059290921b8401810191818101908684111561349d57600080fd5b8286015b848110156130a75780356134b481612f8d565b83529183019183016134a1565b6000602082840312156134d357600080fd5b81356001600160401b038111156134e957600080fd5b61229b8482850161345d565b60006020828403121561350757600080fd5b5035919050565b60005b83811015613529578181015183820152602001613511565b50506000910152565b6000815180845261354a81602086016020860161350e565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b8381101561358e57815187529582019590820190600101613572565b509495945050505050565b60ff60f81b8816815260e0602082015260006135b860e0830189613532565b82810360408401526135ca8189613532565b606084018890526001600160a01b038716608085015260a0840186905283810360c085015290506135fb818561355e565b9a9950505050505050505050565b60006020828403121561361b57600080fd5b8135610ed881612f8d565b60008060006060848603121561363b57600080fd5b505081359360208301359350604090920135919050565b600080600080600060a0868803121561366a57600080fd5b85356001600160401b038082111561368157600080fd5b61368d89838a0161345d565b965060208801359150808211156132fc57600080fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156105bb576105bb6136a3565b6020808252600e908201526d139bdb98d9481c995c5d5a5c995960921b604082015260600190565b6020808252600c908201526b098cadc40dad2e6dac2e8c6d60a31b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060018201613742576137426136a3565b5060010190565b602080825260119082015270496e76616c6964207369676e617475726560781b604082015260600190565b60006020828403121561378657600080fd5b8151610ed881612f8d565b818103818111156105bb576105bb6136a3565b602080825260149082015273556e61626c6520746f2073656e642066756e647360601b604082015260600190565b80820281158282048414176105bb576105bb6136a3565b60008261380657634e487b7160e01b600052601260045260246000fd5b500490565b6020808252601590820152744e6f2072657761726420746f20776974686472617760581b604082015260600190565b815160009082906020808601845b8381101561386457815185529382019390820190600101613848565b50929695505050505050565b83815282602082015260606040820152600061388f606083018461355e565b95945050505050565b6000602082840312156138aa57600080fd5b81518015158114610ed857600080fd5b600181811c908216806138ce57607f821691505b6020821081036138ee57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052602160045260246000fd5b6000825161391c81846020870161350e565b919091019291505056fea2646970667358221220f50d69addd12b11e2bb82cfe574b0ceea4cfa381a7df9372187750c6fff0649a64736f6c63430008140033000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e

Deployed Bytecode

0x60806040526004361061015d5760003560e01c80630f026f6d146101625780631d1e84b3146101955780631dd1b2bb146101aa578063211dc32d146101eb57806321c2024d146102235780632267a89c1461024357806324dc441d146102635780632d826bdf14610279578063324777bf14610293578063342465cb146102a65780633bb36b5c146102bc5780634635256e146102dc5780634732aa1d146102fc578063592de11d146103375780635cf4ee911461034a57806362d76d061461036a57806369f066a31461038a5780637756df44146103a05780637ca44fcf146103cd57806384b0196e146103ed5780639111ac89146104155780639ae7178114610428578063b86e321c14610448578063cec10c1114610468578063cfd88b1214610488578063d6e6eb9f146104c0578063e575ab96146104d6578063e6e88e2914610503578063ead097c014610523578063fc255d6514610538575b600080fd5b34801561016e57600080fd5b5061018261017d366004612fb2565b610570565b6040519081526020015b60405180910390f35b6101a86101a3366004613121565b6105c1565b005b3480156101b657600080fd5b506101de7f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e81565b60405161018c91906131f1565b3480156101f757600080fd5b50610182610206366004613205565b600a60209081526000928352604080842090915290825290205481565b34801561022f57600080fd5b506101a861023e3660046132bd565b6106b6565b34801561024f57600080fd5b5061018261025e366004612fb2565b61096d565b34801561026f57600080fd5b5061018260035481565b34801561028557600080fd5b50610182653691d6afc00081565b6101a86102a136600461337c565b6109b1565b3480156102b257600080fd5b5061018260045481565b3480156102c857600080fd5b506101a86102d7366004612fb2565b610d1d565b3480156102e857600080fd5b506101826102f7366004612fb2565b610eb5565b34801561030857600080fd5b5061031c610317366004613205565b610edf565b6040805193845260208401929092529082015260600161018c565b6101a8610345366004612fb2565b610f38565b34801561035657600080fd5b5061018261036536600461343b565b610fbc565b34801561037657600080fd5b506101826103853660046134c1565b6110ec565b34801561039657600080fd5b50610182600c5481565b3480156103ac57600080fd5b506101826103bb3660046134f5565b60056020526000908152604090205481565b3480156103d957600080fd5b506101826103e8366004613205565b61115d565b3480156103f957600080fd5b50610402611169565b60405161018c9796959493929190613599565b6101a8610423366004612fb2565b6111af565b34801561043457600080fd5b50610182610443366004612fb2565b611227565b34801561045457600080fd5b50610182610463366004613609565b611255565b34801561047457600080fd5b506101a8610483366004613626565b611284565b34801561049457600080fd5b506101826104a3366004613205565b600b60209081526000928352604080842090915290825290205481565b3480156104cc57600080fd5b5061018260025481565b3480156104e257600080fd5b506101826104f1366004613609565b60076020526000908152604090205481565b34801561050f57600080fd5b506101a861051e366004613652565b611419565b34801561052f57600080fd5b506101de6118ad565b34801561054457600080fd5b50610182610553366004613205565b600660209081526000928352604080842090915290825290205481565b60008061057d8484610eb5565b9050600080600061058d84611936565b9194509250905080826105a085876136b9565b6105aa91906136b9565b6105b491906136b9565b9450505050505b92915050565b600083116105ea5760405162461bcd60e51b81526004016105e1906136cc565b60405180910390fd5b835185511461060b5760405162461bcd60e51b81526004016105e1906136f4565b6106168360016119b5565b60005b85518110156106705761065e8682815181106106375761063761371a565b60200260200101518683815181106106515761065161371a565b60200260200101516119b5565b8061066881613730565b915050610619565b50610682878787876000888888611a2f565b61069e5760405162461bcd60e51b81526004016105e190613749565b6106ab87878b8b87611c07565b505050505050505050565b815184511480156106c8575082518251145b80156106d5575080518351145b61071a5760405162461bcd60e51b8152602060048201526016602482015275082e4e4c2f2e640d8cadccee8d040dad2e6dac2e8c6d60531b60448201526064016105e1565b6001600160a01b038516600090815260066020908152604080832033845290915290205461078a5760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c79206b6579686f6c6465722063616e206164642072657761726473000060448201526064016105e1565b60008060005b86518110156108aa5761080a888883815181106107af576107af61371a565b60200260200101518884815181106107c9576107c961371a565b60200260200101518885815181106107e3576107e361371a565b60200260200101518886815181106107fd576107fd61371a565b6020026020010151611cb7565b6108265760405162461bcd60e51b81526004016105e190613749565b61084a85828151811061083b5761083b61371a565b602002602001015160016119b5565b86818151811061085c5761085c61371a565b60200260200101518361086f91906136b9565b92508581815181106108835761088361371a565b60200260200101518261089691906136b9565b9150806108a281613730565b915050610790565b506108b787838387611dc6565b6108c18733611fd8565b5080156109645760007f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094c9190613774565b90506109626001600160a01b038216898461218a565b505b50505050505050565b60008061097a8484611227565b9050600080600061098a84611936565b91945092509050808261099d8587613791565b6109a79190613791565b6105b49190613791565b600083116109d15760405162461bcd60e51b81526004016105e1906136cc565b84518651146109f25760405162461bcd60e51b81526004016105e1906136f4565b60008711610a505760405162461bcd60e51b815260206004820152602560248201527f5061796d656e7420616d6f756e74206d75737420626520677265617465722074604482015264068616e20360dc1b60648201526084016105e1565b610a5b8360016119b5565b60005b8651811015610aa857610a96878281518110610a7c57610a7c61371a565b60200260200101518783815181106106515761065161371a565b80610aa081613730565b915050610a5e565b50610ab98888888888888888611a2f565b610ad55760405162461bcd60e51b81526004016105e190613749565b6001600160a01b038816610c2757863414610b2b5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a59081c185e5b595b9d08185b5bdd5b9d60521b60448201526064016105e1565b60007f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610b8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb19190613774565b6001600160a01b03163460405160006040518083038185875af1925050503d8060008114610bfb576040519150601f19603f3d011682016040523d82523d6000602084013e610c00565b606091505b5050905080610c215760405162461bcd60e51b81526004016105e1906137a4565b50610cc1565b610cc1337f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190613774565b6001600160a01b038b1691908a6121e9565b604080518581526001600160a01b038a1660208201529081018890526060810184905233907fce6d38800f185a3ea05a466d1da359c3aedecb48740391666def25626b8e71ca9060800160405180910390a25050505050505050565b336001600160a01b037f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e161480610de857507f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663fb6b04ba6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd39190613774565b6001600160a01b0316336001600160a01b0316145b610e225760405162461bcd60e51b815260206004820152600b60248201526a139bdd08185b1b1bddd95960aa1b60448201526064016105e1565b6001600160a01b038216610e9d57604051600090339083908381818185875af1925050503d8060008114610e72576040519150601f19603f3d011682016040523d82523d6000602084013e610e77565b606091505b5050905080610e985760405162461bcd60e51b81526004016105e1906137a4565b505050565b610eb16001600160a01b038316338361218a565b5050565b6001600160a01b038216600090815260076020526040812054610ed89083610fbc565b9392505050565b6001600160a01b038083166000818152600a6020908152604080832094861680845294825280832054938352600b82528083209483529390529182205482918291610f2a878761115d565b9250925092505b9250925092565b6001600160a01b038216600090815260076020526040902054610fad5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c206b6579206d75737420626520626f756768742077697468206044820152661c185e5b595b9d60ca1b60648201526084016105e1565b610eb160008084846000611c07565b600081600003610fce575060006105bb565b82600003610ffc57610fe560016103658185613791565b610ff590653691d6afc0006136b9565b90506105bb565b6000600661100b600186613791565b6110169060026137d2565b6110219060016136b9565b8561102d600182613791565b61103791906137d2565b61104191906137d2565b61104b91906137e9565b9050600060068461105d600188613791565b61106791906136b9565b6110729060026137d2565b61107d9060016136b9565b61108786886136b9565b8661109360018a613791565b61109d91906136b9565b6110a791906137d2565b6110b191906137d2565b6110bb91906137e9565b905060006110c98383613791565b90506000613e806110e283670de0b6b3a76400006137d2565b6105b491906137e9565b60008060005b835181101561113c5761111e8482815181106111105761111061371a565b602002602001015133611fd8565b61112890836136b9565b91508061113481613730565b9150506110f2565b50600081116105bb5760405162461bcd60e51b81526004016105e19061380b565b6000610ed88383612228565b60006060806000806000606061117d6122a3565b6111856122d0565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b6001600160a01b0382166000908152600760205260409020548181116112125760405162461bcd60e51b815260206004820152601860248201527743616e6e6f742073656c6c20746865206c617374206b657960401b60448201526064016105e1565b61121c83336122fd565b610e98818385612374565b6001600160a01b038216600090815260076020526040812054610ed89061124f908490613791565b83610fbc565b6000806112628333611fd8565b9050600081116105bb5760405162461bcd60e51b81526004016105e19061380b565b7f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663fb6b04ba6040518163ffffffff1660e01b81526004016020604051808303816000875af11580156112e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113089190613774565b6001600160a01b0316336001600160a01b03161461135b5760405162461bcd60e51b815260206004820152601060248201526f2737ba10309036b0b4b71037bbb732b960811b60448201526064016105e1565b67016345785d8a00008161136f84866136b9565b61137991906136b9565b11156113c45760405162461bcd60e51b815260206004820152601a60248201527946656573206d757374206265206c657373207468616e2031302560301b60448201526064016105e1565b60028390556003829055600481905560408051848152602081018490529081018290527fcf8a1e1d5f09cf3c97dbb653cd9a4d7aace9292fbc1bb8211febf2d400febbdd9060600160405180910390a1505050565b60008551116114585760405162461bcd60e51b815260206004820152600b60248201526a4e6f207375626a6563747360a81b60448201526064016105e1565b845160010361148d57611488856000815181106114775761147761371a565b6020026020010151858585856106b6565b6118a6565b60008086516001600160401b038111156114a9576114a9612fde565b6040519080825280602002602001820160405280156114d2578160200160208202803683370190505b50905060015b87518110156115ae578060000361151a57826114f381613730565b935050808284815181106115095761150961371a565b60200260200101818152505061159c565b87611526600183613791565b815181106115365761153661371a565b60200260200101516001600160a01b03168882815181106115595761155961371a565b60200260200101516001600160a01b03161461159c578261157981613730565b9350508082848151811061158f5761158f61371a565b6020026020010181815250505b806115a681613730565b9150506114d8565b5060005b828110156109625760008282815181106115ce576115ce61371a565b6020026020010151905060006001856115e79190613791565b8314611621576001846115fa85836136b9565b8151811061160a5761160a61371a565b602002602001015161161c9190613791565b61162f565b60018a5161162f9190613791565b9050600061163d8383613791565b6116489060016136b9565b90506000816001600160401b0381111561166457611664612fde565b60405190808252806020026020018201604052801561168d578160200160208202803683370190505b5090506000826001600160401b038111156116aa576116aa612fde565b6040519080825280602002602001820160405280156116d3578160200160208202803683370190505b5090506000836001600160401b038111156116f0576116f0612fde565b604051908082528060200260200182016040528015611719578160200160208202803683370190505b5090506000846001600160401b0381111561173657611736612fde565b60405190808252806020026020018201604052801561176957816020015b60608152602001906001900390816117545790505b509050865b8681116118765760006117818983613791565b90508f82815181106117955761179561371a565b60200260200101518682815181106117af576117af61371a565b6020026020010181815250508e82815181106117cd576117cd61371a565b60200260200101518582815181106117e7576117e761371a565b6020026020010181815250508d82815181106118055761180561371a565b602002602001015184828151811061181f5761181f61371a565b6020026020010181815250508c828151811061183d5761183d61371a565b60200260200101518382815181106118575761185761371a565b602002602001018190525050808061186e90613730565b91505061176e565b5061188c8f89815181106114775761147761371a565b50505050505050808061189e90613730565b9150506115b2565b5050505050565b60007f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa15801561190d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119319190613774565b905090565b600080600080670de0b6b3a76400006002548661195391906137d2565b61195d91906137e9565b90506000670de0b6b3a76400006003548761197891906137d2565b61198291906137e9565b90506000670de0b6b3a76400006004548861199d91906137d2565b6119a791906137e9565b929791965091945092505050565b6000828152600560205260409020548111611a075760405162461bcd60e51b8152602060048201526012602482015271139bdb98d948185b1c9958591e481d5cd95960721b60448201526064016105e1565b6000828152600560205260408120805460019290611a269084906136b9565b90915550505050565b600042831015611a755760405162461bcd60e51b815260206004820152601160248201527014da59db985d1d5c9948195e1c1a5c9959607a1b60448201526064016105e1565b6000611b567fe99b1c2a501b1c1e183b113a9d9b7c30f5e07f07821bf8cd7d0a38961d366eb8338c8c8c604051602001611aaf919061383a565b604051602081830303815290604052805190602001208c604051602001611ad6919061383a565b60408051601f198184030181528282528051602091820120908301979097526001600160a01b0395861690820152939092166060840152608083015260a082015260c081019190915260e0810188905261010081018790526101208101869052610140015b60405160208183030381529060405280519060200120612426565b90507f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663238ac9336040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611bb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bdc9190613774565b6001600160a01b0316611bef8285612453565b6001600160a01b0316149a9950505050505050505050565b6001600160a01b03831660009081526007602052604090205480151580611c3657506001600160a01b03841633145b611c975760405162461bcd60e51b815260206004820152602c60248201527f4f6e6c7920746865206b65797327207375626a6563742063616e20627579207460448201526b6865206669727374206b657960a01b60648201526084016105e1565b611ca184336122fd565b611caf86868386888761247d565b505050505050565b604080517f2ae13b3e9f43dd3f483ddedf916486af119d991a488c9df2f4c08da49b92358260208201526001600160a01b03871691810191909152606081018590526080810184905260a081018390526000908190611d189060c001611b3b565b90507f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663238ac9336040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611d7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9e9190613774565b6001600160a01b0316611db18285612453565b6001600160a01b031614979650505050505050565b6000611dd28385613791565b90508315611efb5760007f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663ead097c06040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5e9190613774565b9050611ef97f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b031663acc2166a6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015611ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee79190613774565b6001600160a01b0383169030886121e9565b505b80156118a6576001600160a01b038516600090815260076020526040902054611f2c670de0b6b3a7640000836137d2565b611f3691906137e9565b6001600160a01b03861660009081526008602052604081208054909190611f5e9084906136b9565b9250508190555080600c6000828254611f7791906136b9565b90915550506001600160a01b038516600081815260086020526040908190205490517fa6af97c57588b1f0a3d42c13588e8017f413111a8e7f5b9cc832899bfe18d42e91611fc9918591908790613870565b60405180910390a25050505050565b6000611fe483836122fd565b6001600160a01b038084166000908152600a60209081526040808320938616835292905220548015610ed85780600c60008282546120229190613791565b90915550506001600160a01b038085166000908152600b602090815260408083209387168352929052908120805483929061205e9084906136b9565b90915550506001600160a01b038085166000908152600a602090815260408083208785168452825280832083905580516303ab425f60e61b8152905192937f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e169263ead097c0926004808401939192918290030181865afa1580156120e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210b9190613774565b90506121216001600160a01b038216858461218a565b6001600160a01b03858116600081815260096020908152604080832094891680845294825291829020548251878152918201529192917f95ce0e9616a1212f228bd4500789cf3572aab0777f130b1a29484dbff0587acd910160405180910390a3509392505050565b6040516001600160a01b03838116602483015260448201839052610e9891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506124d8565b6040516001600160a01b0384811660248301528381166044830152606482018390526122229186918216906323b872dd906084016121b7565b50505050565b6001600160a01b0380831660008181526006602090815260408083209486168084529482528083205484845260098352818420958452948252808320549383526008909152812054909291670de0b6b3a7640000916122879190613791565b61229190836137d2565b61229b91906137e9565b949350505050565b60606119317f4d656d65666900000000000000000000000000000000000000000000000000066000612532565b60606119317f31000000000000000000000000000000000000000000000000000000000000016001612532565b6123078282612228565b6001600160a01b038084166000908152600a602090815260408083209386168352929052908120805490919061233e9084906136b9565b90915550506001600160a01b03918216600090815260086020908152604080832054600983528184209490951683529290522055565b600080808061238c6123868789613791565b876125d6565b6001600160a01b0389166000908152600660209081526040808320338452909152902054939750919550935091508611156123fd5760405162461bcd60e51b8152602060048201526011602482015270496e73756666696369656e74206b65797360781b60448201526064016105e1565b612407858761260c565b6124168585858585600161266c565b61096485878686866000806127bf565b60006105bb61243361288a565b8360405161190160f01b8152600281019290925260228201526042902090565b60008060008061246386866129b5565b92509250925061247382826129ff565b5090949350505050565b60008060008061248d88886125d6565b93509350935093506124a38a8a86868686612ab8565b6124ad8688612c84565b6124bc8685858585600061266c565b6124cc86888686868a60016127bf565b50505050505050505050565b60006124ed6001600160a01b03841683612ce4565b905080516000141580156125125750808060200190518101906125109190613898565b155b15610e985782604051635274afe760e01b81526004016105e191906131f1565b606060ff831461254557610ff583612cf2565b818054612551906138ba565b80601f016020809104026020016040519081016040528092919081815260200182805461257d906138ba565b80156125ca5780601f1061259f576101008083540402835291602001916125ca565b820191906000526020600020905b8154815290600101906020018083116125ad57829003601f168201915b505050505090506105bb565b60008060008060006125e88787610fbc565b905060008060006125f884611936565b959c919b5099509397509295505050505050565b6001600160a01b03821660009081526006602090815260408083203384529091528120805483929061263f908490613791565b90915550506001600160a01b03821660009081526007602052604081208054839290611a26908490613791565b801561269b5761269b338385612682888a613791565b61268c9190613791565b6126969190613791565b612d31565b6127287f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af11580156126fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127229190613774565b85612d31565b6127328684612d31565b611caf7f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b0316638e0bae7f6040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612795573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b99190613774565b83612d31565b6001600160a01b038716600090815260096020908152604080832033808552925282205491906127f0908a90612228565b6001600160a01b038a166000818152600760209081526040918290205482518d81529182018c90529181018a9052606081018990526080810182905260a0810188905260c0810186905260e081018490528615156101008201529293509133907f22a9d5b18fa6904e4e44967debf208c9ccb69a36eceed9ede0dab19030d87335906101200160405180910390a350505050505050505050565b6000306001600160a01b037f000000000000000000000000fa8f5a99dd104e0489db960b6a74776df19daead161480156128e357507f000000000000000000000000000000000000000000000000000000000000e70846145b1561290d57507f3ae8fff76f3e0680386ecbf889a2266f54d963b88a0c54ba90ce4d80fd86a3ae90565b611931604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527fcc225e45ed82df463c9b335646835adb36462e9f000f6da87056c704bbd5ca46918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080600083516041036129ef5760208401516040850151606086015160001a6129e188828585612d84565b955095509550505050610f31565b5050815160009150600290610f31565b6000826003811115612a1357612a136138f4565b03612a1c575050565b6001826003811115612a3057612a306138f4565b03612a4e5760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115612a6257612a626138f4565b03612a835760405163fce698f760e01b8152600481018290526024016105e1565b6003826003811115612a9757612a976138f4565b03610eb1576040516335e2f38360e21b8152600481018290526024016105e1565b60006001600160a01b03871615612ad0576000612ad2565b855b90506001600160a01b038716612be457808284612aef87896136b9565b612af991906136b9565b612b0391906136b9565b612b0d91906136b9565b3414612b525760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b60448201526064016105e1565b612bdf7f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bd99190613774565b82612d31565b610964565b851561096457610964337f000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e6001600160a01b03166361d027b36040518163ffffffff1660e01b81526004016020604051808303816000875af1158015612c4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c729190613774565b6001600160a01b038a169190896121e9565b6001600160a01b038216600090815260066020908152604080832033845290915281208054839290612cb79084906136b9565b90915550506001600160a01b03821660009081526007602052604081208054839290611a269084906136b9565b6060610ed883836000612e49565b60606000612cff83612ee6565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b8015610eb1576000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610e72576040519150601f19603f3d011682016040523d82523d6000602084013e610e77565b600080806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03841115612db55750600091506003905082612e3f565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015612e09573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612e3557506000925060019150829050612e3f565b9250600091508190505b9450945094915050565b606081471015612e6e573060405163cd78605960e01b81526004016105e191906131f1565b600080856001600160a01b03168486604051612e8a919061390a565b60006040518083038185875af1925050503d8060008114612ec7576040519150601f19603f3d011682016040523d82523d6000602084013e612ecc565b606091505b5091509150612edc868383612f0e565b9695505050505050565b600060ff8216601f8111156105bb57604051632cd44ac360e21b815260040160405180910390fd5b606082612f2357612f1e82612f61565b610ed8565b8151158015612f3a57506001600160a01b0384163b155b15612f5a5783604051639996b31560e01b81526004016105e191906131f1565b5080610ed8565b805115612f715780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b6001600160a01b0381168114612f8a57600080fd5b8035612fad81612f8d565b919050565b60008060408385031215612fc557600080fd5b8235612fd081612f8d565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561301c5761301c612fde565b604052919050565b60006001600160401b0382111561303d5761303d612fde565b5060051b60200190565b600082601f83011261305857600080fd5b8135602061306d61306883613024565b612ff4565b82815260059290921b8401810191818101908684111561308c57600080fd5b8286015b848110156130a75780358352918301918301613090565b509695505050505050565b600082601f8301126130c357600080fd5b81356001600160401b038111156130dc576130dc612fde565b6130ef601f8201601f1916602001612ff4565b81815284602083860101111561310457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060008060006101208a8c03121561314057600080fd5b6131498a612fa2565b985060208a0135975061315e60408b01612fa2565b965060608a0135955060808a01356001600160401b038082111561318157600080fd5b61318d8d838e01613047565b965060a08c01359150808211156131a357600080fd5b6131af8d838e01613047565b955060c08c0135945060e08c013593506101008c01359150808211156131d457600080fd5b506131e18c828d016130b2565b9150509295985092959850929598565b6001600160a01b0391909116815260200190565b6000806040838503121561321857600080fd5b823561322381612f8d565b9150602083013561323381612f8d565b809150509250929050565b600082601f83011261324f57600080fd5b8135602061325f61306883613024565b82815260059290921b8401810191818101908684111561327e57600080fd5b8286015b848110156130a75780356001600160401b038111156132a15760008081fd5b6132af8986838b01016130b2565b845250918301918301613282565b600080600080600060a086880312156132d557600080fd5b85356132e081612f8d565b945060208601356001600160401b03808211156132fc57600080fd5b61330889838a01613047565b9550604088013591508082111561331e57600080fd5b61332a89838a01613047565b9450606088013591508082111561334057600080fd5b61334c89838a01613047565b9350608088013591508082111561336257600080fd5b5061336f8882890161323e565b9150509295509295909350565b600080600080600080600080610100898b03121561339957600080fd5b6133a289612fa2565b97506020890135965060408901356001600160401b03808211156133c557600080fd5b6133d18c838d01613047565b975060608b01359150808211156133e757600080fd5b6133f38c838d01613047565b965060808b0135955060a08b0135945060c08b0135935060e08b013591508082111561341e57600080fd5b5061342b8b828c016130b2565b9150509295985092959890939650565b6000806040838503121561344e57600080fd5b50508035926020909101359150565b600082601f83011261346e57600080fd5b8135602061347e61306883613024565b82815260059290921b8401810191818101908684111561349d57600080fd5b8286015b848110156130a75780356134b481612f8d565b83529183019183016134a1565b6000602082840312156134d357600080fd5b81356001600160401b038111156134e957600080fd5b61229b8482850161345d565b60006020828403121561350757600080fd5b5035919050565b60005b83811015613529578181015183820152602001613511565b50506000910152565b6000815180845261354a81602086016020860161350e565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b8381101561358e57815187529582019590820190600101613572565b509495945050505050565b60ff60f81b8816815260e0602082015260006135b860e0830189613532565b82810360408401526135ca8189613532565b606084018890526001600160a01b038716608085015260a0840186905283810360c085015290506135fb818561355e565b9a9950505050505050505050565b60006020828403121561361b57600080fd5b8135610ed881612f8d565b60008060006060848603121561363b57600080fd5b505081359360208301359350604090920135919050565b600080600080600060a0868803121561366a57600080fd5b85356001600160401b038082111561368157600080fd5b61368d89838a0161345d565b965060208801359150808211156132fc57600080fd5b634e487b7160e01b600052601160045260246000fd5b808201808211156105bb576105bb6136a3565b6020808252600e908201526d139bdb98d9481c995c5d5a5c995960921b604082015260600190565b6020808252600c908201526b098cadc40dad2e6dac2e8c6d60a31b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060018201613742576137426136a3565b5060010190565b602080825260119082015270496e76616c6964207369676e617475726560781b604082015260600190565b60006020828403121561378657600080fd5b8151610ed881612f8d565b818103818111156105bb576105bb6136a3565b602080825260149082015273556e61626c6520746f2073656e642066756e647360601b604082015260600190565b80820281158282048414176105bb576105bb6136a3565b60008261380657634e487b7160e01b600052601260045260246000fd5b500490565b6020808252601590820152744e6f2072657761726420746f20776974686472617760581b604082015260600190565b815160009082906020808601845b8381101561386457815185529382019390820190600101613848565b50929695505050505050565b83815282602082015260606040820152600061388f606083018461355e565b95945050505050565b6000602082840312156138aa57600080fd5b81518015158114610ed857600080fd5b600181811c908216806138ce57607f821691505b6020821081036138ee57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052602160045260246000fd5b6000825161391c81846020870161350e565b919091019291505056fea2646970667358221220f50d69addd12b11e2bb82cfe574b0ceea4cfa381a7df9372187750c6fff0649a64736f6c63430008140033

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

000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e

-----Decoded View---------------
Arg [0] : _memefiManagement (address): 0xE19A705f88B39c8516044f898f1d46c4cC74e89E

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000e19a705f88b39c8516044f898f1d46c4cc74e89e


Block Transaction Gas Used Reward
view all blocks sequenced

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

Validator Index Block Amount
View All Withdrawals

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

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