ETH Price: $3,361.91 (-0.65%)
Gas: 1 Gwei

Contract

0xAF59A3Be12fdE3614083AFbEE3c787e61f2c97D0
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Buy With Permiss...154881562022-09-07 4:00:11662 days ago1662523211IN
0xAF59A3Be...61f2c97D0
0 ETH0.0023288815.15499171
Set Closing Time154828112022-09-06 7:47:59662 days ago1662450479IN
0xAF59A3Be...61f2c97D0
0 ETH0.000253858.86761414
Set Closing Time154396412022-08-30 9:37:03669 days ago1661852223IN
0xAF59A3Be...61f2c97D0
0 ETH0.0004815716.82931166
Buy With Permiss...152318122022-07-28 15:30:43702 days ago1659022243IN
0xAF59A3Be...61f2c97D0
0 ETH0.0119149849.17267201
Buy With Permiss...152317752022-07-28 15:25:05702 days ago1659021905IN
0xAF59A3Be...61f2c97D0
0 ETH0.0090589958.95826577
Set Closing Time152239322022-07-27 10:15:08703 days ago1658916908IN
0xAF59A3Be...61f2c97D0
0 ETH0.000136434.76805427
Buy With Permiss...152179032022-07-26 11:46:12704 days ago1658835972IN
0xAF59A3Be...61f2c97D0
0 ETH0.0017405310.77106586
Buy With Permiss...152126652022-07-25 16:05:38705 days ago1658765138IN
0xAF59A3Be...61f2c97D0
0 ETH0.0034554833.75450932
Buy With Permiss...152070182022-07-24 18:51:54706 days ago1658688714IN
0xAF59A3Be...61f2c97D0
0 ETH0.0017655911.49091493
Buy With Permiss...151980632022-07-23 9:14:06707 days ago1658567646IN
0xAF59A3Be...61f2c97D0
0 ETH0.000861315.60569056
Buy With Permiss...151959182022-07-23 1:18:53708 days ago1658539133IN
0xAF59A3Be...61f2c97D0
0 ETH0.0015880310.33400929
Buy With Permiss...151944792022-07-22 20:03:06708 days ago1658520186IN
0xAF59A3Be...61f2c97D0
0 ETH0.0032713819.66186643
Buy With Permiss...151865362022-07-21 14:50:05709 days ago1658415005IN
0xAF59A3Be...61f2c97D0
0 ETH0.0070521145.90055585
Buy With Permiss...151861632022-07-21 13:29:19709 days ago1658410159IN
0xAF59A3Be...61f2c97D0
0 ETH0.0025012615.47753183
Buy With Permiss...151855812022-07-21 11:18:01709 days ago1658402281IN
0xAF59A3Be...61f2c97D0
0 ETH0.0020143512.71471807
Buy With Permiss...151851272022-07-21 9:27:41709 days ago1658395661IN
0xAF59A3Be...61f2c97D0
0 ETH0.0025860116
Buy With Permiss...151834562022-07-21 3:11:16710 days ago1658373076IN
0xAF59A3Be...61f2c97D0
0 ETH0.0044108827.83400352
Buy With Permiss...151822772022-07-20 22:49:27710 days ago1658357367IN
0xAF59A3Be...61f2c97D0
0 ETH0.0026449717.21464958
Buy With Permiss...151821362022-07-20 22:19:21710 days ago1658355561IN
0xAF59A3Be...61f2c97D0
0 ETH0.0050448530.90317602
Buy With Permiss...151819392022-07-20 21:33:42710 days ago1658352822IN
0xAF59A3Be...61f2c97D0
0 ETH0.0052527834.18735591
Buy With Permiss...151811042022-07-20 18:27:41710 days ago1658341661IN
0xAF59A3Be...61f2c97D0
0 ETH0.0040727924.47208338
Buy With Permiss...151810672022-07-20 18:20:39710 days ago1658341239IN
0xAF59A3Be...61f2c97D0
0 ETH0.0043916827.17527794
Buy With Permiss...151808842022-07-20 17:38:55710 days ago1658338735IN
0xAF59A3Be...61f2c97D0
0 ETH0.0049604829.80807052
Buy With Permiss...151800962022-07-20 14:41:00710 days ago1658328060IN
0xAF59A3Be...61f2c97D0
0 ETH0.006337939.21827406
Buy With Permiss...151799112022-07-20 13:57:17710 days ago1658325437IN
0xAF59A3Be...61f2c97D0
0 ETH0.0033455521.77374413
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ICO

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 14 : ICO.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";

error InvalidAddress();
error ClosingTimeMustBeGreaterThanOpeningTime();
error AcceptedTokensLimitExceeded();
error ICOClosed();
error NotAcceptedPaymentToken();
error CapExceeded();
error InvalidPaymentTokenDecimals();
error InvalidSignature();

/**
 * @title ICO
 */
contract ICO is Ownable, EIP712 {
    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    uint8 private constant _ACCEPTED_PAYMENT_TOKENS_LIMIT = 5;
    uint8 private constant _PAYMENT_TOKENS_DECIMALS = 6;
    uint8 private constant _TOKEN_DECIMALS = 18;
    bytes32 private constant _WHITELIST_TYPEHASH = keccak256("Whitelist(address user)");

    uint256 public cap;
    uint256 public openingTime;
    uint256 public closingTime;
    uint256 public tokenPrice;
    address public wallet;
    address public authorizer;
    address[] private _acceptedPaymentTokens;

    struct TokenDeposit {
        mapping(address => uint256) perToken;
        uint256 total;
    }

    mapping(address => TokenDeposit) private _contributions;
    TokenDeposit private _totalContribution;

    mapping(address => uint256) public purchasedTokens;
    uint256 public totalPurchasedTokens;

    event BuyWithPermission(address indexed paymentToken, uint256 paidAmount, uint256 purchasedAmount);

    constructor(
        address walletAddress,
        address authorizerAddress,
        uint256 capValue,
        uint256 openingTimeValue,
        uint256 closingTimeValue,
        uint256 tokenPriceValue,
        address[] memory acceptedPaymentTokensValue
    ) EIP712("ICO", "1") {
        if (!_addressIsValid(walletAddress))
            revert InvalidAddress();
        if (!_addressIsValid(authorizerAddress))
            revert InvalidAddress();
        if (openingTimeValue > closingTimeValue)
            revert ClosingTimeMustBeGreaterThanOpeningTime();
        if (_acceptedPaymentTokens.length > _ACCEPTED_PAYMENT_TOKENS_LIMIT)
            revert AcceptedTokensLimitExceeded();

        for (uint i = 0; i < acceptedPaymentTokensValue.length; i++) {
            if (!_addressIsValid(acceptedPaymentTokensValue[i]))
                revert InvalidAddress();
            if (ERC20(acceptedPaymentTokensValue[i]).decimals() != _PAYMENT_TOKENS_DECIMALS)
                revert InvalidPaymentTokenDecimals();
        }

        wallet = walletAddress;
        authorizer = authorizerAddress;
        cap = capValue;
        openingTime = openingTimeValue;
        closingTime = closingTimeValue;
        tokenPrice = tokenPriceValue;
        _acceptedPaymentTokens = acceptedPaymentTokensValue;
    }

    function buyWithPermission(
        address paymentToken,
        uint256 amount,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external {
        if (!isAcceptedPaymentToken(paymentToken))
            revert NotAcceptedPaymentToken();
        if (!isOpen())
            revert ICOClosed();

        uint256 amountToBuy = amount.mul(10 ** _TOKEN_DECIMALS).div(tokenPrice);

        if (totalPurchasedTokens + amountToBuy > cap)
            revert CapExceeded();

        // Check signature - the address has to be whitelisted by authorizer
        bytes32 structHash = keccak256(abi.encode(_WHITELIST_TYPEHASH, _msgSender()));
        bytes32 hash = _hashTypedDataV4(structHash);
        address signer = ECDSA.recover(hash, v, r, s);
        if (signer != authorizer)
            revert InvalidSignature();

        // Transfer sent tokens to wallet
        IERC20(paymentToken).safeTransferFrom(_msgSender(), wallet, amount);

        // Increase account contribution
        _contributions[_msgSender()].total += amount;

        // Increase account contribution per token
        _contributions[_msgSender()].perToken[paymentToken] += amount;

        // Increase total contribution
        _totalContribution.total += amount;

        // Increase total contribution per token
        _totalContribution.perToken[paymentToken] += amount;

        totalPurchasedTokens += amountToBuy;
        purchasedTokens[_msgSender()] += amountToBuy;

        emit BuyWithPermission(paymentToken, amount, amountToBuy);
    }

    function setCap(uint256 capValue) external onlyOwner {
        cap = capValue;
    }

    function setOpeningTime(uint256 time) external onlyOwner {
        openingTime = time;
    }

    function setClosingTime(uint256 time) external onlyOwner {
        closingTime = time;
    }

    function setTokenPrice(uint256 price) external onlyOwner {
        tokenPrice = price;
    }

    function setWallet(address walletAddress) external onlyOwner {
        wallet = walletAddress;
    }

    function setAuthorizer(address authorizerAddress) external onlyOwner {
        authorizer = authorizerAddress;
    }

    function setAcceptedPaymentTokens(address[] memory tokens) external onlyOwner {
        if (tokens.length > _ACCEPTED_PAYMENT_TOKENS_LIMIT) revert AcceptedTokensLimitExceeded();
        _acceptedPaymentTokens = tokens;
    }

    function isOpen() public view returns (bool) {
        return !(block.timestamp < openingTime || block.timestamp > closingTime);
    }

    function isAcceptedPaymentToken(address token) public view returns (bool) {
        for (uint i = 0; i < _acceptedPaymentTokens.length; i++) {
            if (_acceptedPaymentTokens[i] == token)
                return true;
        }
        return false;
    }

    function acceptedPaymentTokens() public view returns (address[] memory) {
        return _acceptedPaymentTokens;
    }

    function totalContribution() public view returns (uint256, address[] memory, uint256[] memory) {
        address[] memory tokens = new address[](_acceptedPaymentTokens.length);
        uint256[] memory amounts = new uint256[](_acceptedPaymentTokens.length);

        for (uint i = 0; i < _acceptedPaymentTokens.length; i++) {
            address token = _acceptedPaymentTokens[i];
            uint256 depositAmount = _totalContribution.perToken[token];
            tokens[i] = token;
            amounts[i] = depositAmount;
        }

        return (_totalContribution.total, tokens, amounts);
    }

    function contribution(address account) public view returns (uint256, address[] memory, uint256[] memory) {
        address[] memory tokens = new address[](_acceptedPaymentTokens.length);
        uint256[] memory amounts = new uint256[](_acceptedPaymentTokens.length);

        for (uint i = 0; i < _acceptedPaymentTokens.length; i++) {
            address token = _acceptedPaymentTokens[i];
            uint256 depositAmount = _contributions[account].perToken[token];
            tokens[i] = token;
            amounts[i] = depositAmount;
        }

        return (_contributions[account].total, tokens, amounts);
    }

    function _addressIsValid(address addr) internal pure returns (bool) {
        return addr != address(0);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

        return true;
    }

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

        _beforeTokenTransfer(from, to, amount);

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

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

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

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

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

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

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

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

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

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

File 6 of 14 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    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.
     *
     * _Available since v3.4._
     */
    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.
     *
     * _Available since v3.4._
     */
    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.
     *
     * _Available since v3.4._
     */
    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.
     *
     * _Available since v3.4._
     */
    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 addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 7 of 14 : EnumerableMap.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableMap.sol)

pragma solidity ^0.8.0;

import "./EnumerableSet.sol";

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * The following map types are supported:
 *
 * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0
 * - `bytes32 -> bytes32` (`Bytes32ToBytes32`) since v4.6.0
 */
library EnumerableMap {
    using EnumerableSet for EnumerableSet.Bytes32Set;

    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct Bytes32ToBytes32Map {
        // Storage of keys
        EnumerableSet.Bytes32Set _keys;
        mapping(bytes32 => bytes32) _values;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        bytes32 value
    ) internal returns (bool) {
        map._values[key] = value;
        return map._keys.add(key);
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
        delete map._values[key];
        return map._keys.remove(key);
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
        return map._keys.contains(key);
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
        return map._keys.length();
    }

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

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
        bytes32 value = map._values[key];
        if (value == bytes32(0)) {
            return (contains(map, key), bytes32(0));
        } else {
            return (true, value);
        }
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
        return value;
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function get(
        Bytes32ToBytes32Map storage map,
        bytes32 key,
        string memory errorMessage
    ) internal view returns (bytes32) {
        bytes32 value = map._values[key];
        require(value != 0 || contains(map, key), errorMessage);
        return value;
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        UintToAddressMap storage map,
        uint256 key,
        address value
    ) internal returns (bool) {
        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

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

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
    }

    // AddressToUintMap

    struct AddressToUintMap {
        Bytes32ToBytes32Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        AddressToUintMap storage map,
        address key,
        uint256 value
    ) internal returns (bool) {
        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
    }

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

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

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(AddressToUintMap storage map) internal view returns (uint256) {
        return length(map._inner);
    }

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

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
        return (success, uint256(value));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(
        AddressToUintMap storage map,
        address key,
        string memory errorMessage
    ) internal view returns (uint256) {
        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
    }
}

File 8 of 14 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

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

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode 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 {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]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        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.
            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 if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode 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 {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        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]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        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.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // 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);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

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

        return (signer, RecoverError.NoError);
    }

    /**
     * @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) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 9 of 14 : draft-EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic 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 their contracts 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].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // 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 _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @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) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, 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 ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 13 of 14 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"walletAddress","type":"address"},{"internalType":"address","name":"authorizerAddress","type":"address"},{"internalType":"uint256","name":"capValue","type":"uint256"},{"internalType":"uint256","name":"openingTimeValue","type":"uint256"},{"internalType":"uint256","name":"closingTimeValue","type":"uint256"},{"internalType":"uint256","name":"tokenPriceValue","type":"uint256"},{"internalType":"address[]","name":"acceptedPaymentTokensValue","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AcceptedTokensLimitExceeded","type":"error"},{"inputs":[],"name":"CapExceeded","type":"error"},{"inputs":[],"name":"ClosingTimeMustBeGreaterThanOpeningTime","type":"error"},{"inputs":[],"name":"ICOClosed","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidPaymentTokenDecimals","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"NotAcceptedPaymentToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"paymentToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"paidAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"purchasedAmount","type":"uint256"}],"name":"BuyWithPermission","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptedPaymentTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"authorizer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"buyWithPermission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"contribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isAcceptedPaymentToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"purchasedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"setAcceptedPaymentTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"authorizerAddress","type":"address"}],"name":"setAuthorizer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"capValue","type":"uint256"}],"name":"setCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"setClosingTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"setOpeningTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setTokenPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"walletAddress","type":"address"}],"name":"setWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tokenPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalContribution","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPurchasedTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101406040523480156200001257600080fd5b5060405162001f2138038062001f21833981016040819052620000359162000450565b6040518060400160405280600381526020016249434f60e81b815250604051806040016040528060018152602001603160f81b815250620000856200007f6200033a60201b60201c565b6200033e565b815160208084019190912082518383012060e08290526101008190524660a0818152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81880181905281830187905260608201869052608082019490945230818401528151808203909301835260c00190528051940193909320919290916080523060c05261012052505050506001600160a01b0387166200013e5760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b038616620001665760405163e6c4247b60e01b815260040160405180910390fd5b828411156200018857604051632cd1ac3560e11b815260040160405180910390fd5b60075460051015620001ad57604051630b10dbad60e31b815260040160405180910390fd5b60005b8151811015620002d257620001e7828281518110620001d357620001d362000573565b60200260200101516200038e60201b60201c565b620002055760405163e6c4247b60e01b815260040160405180910390fd5b600660ff168282815181106200021f576200021f62000573565b60200260200101516001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156200026057600080fd5b505afa15801562000275573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029b919062000589565b60ff1614620002bd57604051631815aa4d60e01b815260040160405180910390fd5b80620002c981620005b5565b915050620001b0565b50600580546001600160a01b03808a166001600160a01b0319928316179092556006805492891692909116919091179055600185905560028490556003839055600482905580516200032c9060079060208401906200039c565b5050505050505050620005df565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0316151590565b828054828255906000526020600020908101928215620003f4579160200282015b82811115620003f457825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190620003bd565b506200040292915062000406565b5090565b5b8082111562000402576000815560010162000407565b80516001600160a01b03811681146200043557600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080600080600080600060e0888a0312156200046c57600080fd5b62000477886200041d565b9650602062000488818a016200041d565b60408a015160608b015160808c015160a08d015160c08e0151949b50929950909750955093506001600160401b0380821115620004c457600080fd5b818b0191508b601f830112620004d957600080fd5b815181811115620004ee57620004ee6200043a565b8060051b604051601f19603f830116810181811085821117156200051657620005166200043a565b60405291825284820192508381018501918e8311156200053557600080fd5b938501935b828510156200055e576200054e856200041d565b845293850193928501926200053a565b80965050505050505092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156200059c57600080fd5b815160ff81168114620005ae57600080fd5b9392505050565b6000600019821415620005d857634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c05160e05161010051610120516118f26200062f6000396000610ddf01526000610e2101526000610e0001526000610d6401526000610d8e01526000610db801526118f26000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80637ff9b596116100c3578063b7a8807c1161007c578063b7a8807c146102c7578063d09edf31146102d0578063deaa59df146102e3578063e25b2c35146102f6578063e2dc431014610309578063f2fde38b1461031c57600080fd5b80637ff9b5961461025f5780638da5cb5b146102685780639c46a87414610279578063a14e40231461028c578063aa2aedc41461029f578063abdd11a8146102b457600080fd5b80634b89c41d116101155780634b89c41d146101dd5780634bae6f3f146101f0578063521eb273146102105780635b6a07aa1461023b5780636a61e5fc14610244578063715018a61461025757600080fd5b8063058a628f1461015d5780630dcf4b8f14610172578063355274ea1461019257806347535d7b146101a957806347786d37146101c15780634b6753bc146101d4575b600080fd5b61017061016b36600461142a565b61032f565b005b61017a610384565b60405161018993929190611489565b60405180910390f35b61019b60015481565b604051908152602001610189565b6101b16104e3565b6040519015158152602001610189565b6101706101cf3660046114e4565b6104fc565b61019b60035481565b6101706101eb3660046114e4565b61052b565b61019b6101fe36600461142a565b600b6020526000908152604090205481565b600554610223906001600160a01b031681565b6040516001600160a01b039091168152602001610189565b61019b600c5481565b6101706102523660046114e4565b61055a565b610170610589565b61019b60045481565b6000546001600160a01b0316610223565b6101706102873660046114fd565b6105bf565b61017061029a366004611569565b610844565b6102a76108a8565b604051610189919061162e565b6101706102c23660046114e4565b61090a565b61019b60025481565b600654610223906001600160a01b031681565b6101706102f136600461142a565b610939565b6101b161030436600461142a565b610985565b61017a61031736600461142a565b6109ef565b61017061032a36600461142a565b610b75565b6000546001600160a01b031633146103625760405162461bcd60e51b815260040161035990611641565b60405180910390fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6000606080600060078054905067ffffffffffffffff8111156103a9576103a9611553565b6040519080825280602002602001820160405280156103d2578160200160208202803683370190505b5060075490915060009067ffffffffffffffff8111156103f4576103f4611553565b60405190808252806020026020018201604052801561041d578160200160208202803683370190505b50905060005b6007548110156104d55760006007828154811061044257610442611676565b60009182526020808320909101546001600160a01b03168083526009909152604090912054855191925090829086908590811061048157610481611676565b60200260200101906001600160a01b031690816001600160a01b031681525050808484815181106104b4576104b4611676565b602002602001018181525050505080806104cd906116a2565b915050610423565b50600a549591945092509050565b60006002544210806104f6575060035442115b15905090565b6000546001600160a01b031633146105265760405162461bcd60e51b815260040161035990611641565b600155565b6000546001600160a01b031633146105555760405162461bcd60e51b815260040161035990611641565b600355565b6000546001600160a01b031633146105845760405162461bcd60e51b815260040161035990611641565b600455565b6000546001600160a01b031633146105b35760405162461bcd60e51b815260040161035990611641565b6105bd6000610c10565b565b6105c885610985565b6105e55760405163418a149f60e11b815260040160405180910390fd5b6105ed6104e3565b61060a57604051636274c3e360e01b815260040160405180910390fd5b600061063060045461062a6012600a61062391906117a1565b8890610c60565b90610c75565b905060015481600c5461064391906117b0565b11156106625760405163a4875a4960e01b815260040160405180910390fd5b604080517f7da008bd4400c227b0db9db6ce34f9b2386dc6492514864fc6f3b1c307dd5af160208083019190915233828401528251808303840181526060909201909252805191012060006106b682610c81565b905060006106c682888888610ccf565b6006549091506001600160a01b038083169116146106f757604051638baa579f60e01b815260040160405180910390fd5b610712336005546001600160a01b038c81169291168b610cf7565b33600090815260086020526040812060010180548a92906107349084906117b0565b90915550503360009081526008602090815260408083206001600160a01b038d168452909152812080548a929061076c9084906117b0565b9091555050600a80548991906000906107869084906117b0565b90915550506001600160a01b038916600090815260096020526040812080548a92906107b39084906117b0565b9250508190555083600c60008282546107cc91906117b0565b9091555050336000908152600b6020526040812080548692906107f09084906117b0565b909155505060408051898152602081018690526001600160a01b038b16917f2e50c677bae4f935cf3cae75a4f965446f702ca5f089ccd5bb77df65f6c85519910160405180910390a2505050505050505050565b6000546001600160a01b0316331461086e5760405162461bcd60e51b815260040161035990611641565b80516005101561089157604051630b10dbad60e31b815260040160405180910390fd5b80516108a4906007906020840190611394565b5050565b6060600780548060200260200160405190810160405280929190818152602001828054801561090057602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108e2575b5050505050905090565b6000546001600160a01b031633146109345760405162461bcd60e51b815260040161035990611641565b600255565b6000546001600160a01b031633146109635760405162461bcd60e51b815260040161035990611641565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000805b6007548110156109e657826001600160a01b0316600782815481106109b0576109b0611676565b6000918252602090912001546001600160a01b031614156109d45750600192915050565b806109de816116a2565b915050610989565b50600092915050565b6000606080600060078054905067ffffffffffffffff811115610a1457610a14611553565b604051908082528060200260200182016040528015610a3d578160200160208202803683370190505b5060075490915060009067ffffffffffffffff811115610a5f57610a5f611553565b604051908082528060200260200182016040528015610a88578160200160208202803683370190505b50905060005b600754811015610b4c57600060078281548110610aad57610aad611676565b60009182526020808320909101546001600160a01b038b81168452600883526040808520919092168085529252909120548551919250908290869085908110610af857610af8611676565b60200260200101906001600160a01b031690816001600160a01b03168152505080848481518110610b2b57610b2b611676565b60200260200101818152505050508080610b44906116a2565b915050610a8e565b506001600160a01b03959095166000908152600860205260409020600101549590949350915050565b6000546001600160a01b03163314610b9f5760405162461bcd60e51b815260040161035990611641565b6001600160a01b038116610c045760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610359565b610c0d81610c10565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610c6c82846117c8565b90505b92915050565b6000610c6c82846117e7565b6000610c6f610c8e610d57565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000610ce087878787610e4a565b91509150610ced81610f37565b5095945050505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610d519085906110f2565b50505050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015610db057507f000000000000000000000000000000000000000000000000000000000000000046145b15610dda57507f000000000000000000000000000000000000000000000000000000000000000090565b610e457f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006111c9565b905090565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610e815750600090506003610f2e565b8460ff16601b14158015610e9957508460ff16601c14155b15610eaa5750600090506004610f2e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610efe573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610f2757600060019250925050610f2e565b9150600090505b94509492505050565b6000816004811115610f4b57610f4b611809565b1415610f545750565b6001816004811115610f6857610f68611809565b1415610fb65760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610359565b6002816004811115610fca57610fca611809565b14156110185760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610359565b600381600481111561102c5761102c611809565b14156110855760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610359565b600481600481111561109957611099611809565b1415610c0d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610359565b6000611147826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112139092919063ffffffff16565b8051909150156111c45780806020019051810190611165919061181f565b6111c45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610359565b505050565b6040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090505b9392505050565b6060611222848460008561122a565b949350505050565b60608247101561128b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610359565b6001600160a01b0385163b6112e25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610359565b600080866001600160a01b031685876040516112fe919061186d565b60006040518083038185875af1925050503d806000811461133b576040519150601f19603f3d011682016040523d82523d6000602084013e611340565b606091505b509150915061135082828661135b565b979650505050505050565b6060831561136a57508161120c565b82511561137a5782518084602001fd5b8160405162461bcd60e51b81526004016103599190611889565b8280548282559060005260206000209081019282156113e9579160200282015b828111156113e957825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906113b4565b506113f59291506113f9565b5090565b5b808211156113f557600081556001016113fa565b80356001600160a01b038116811461142557600080fd5b919050565b60006020828403121561143c57600080fd5b610c6c8261140e565b600081518084526020808501945080840160005b8381101561147e5781516001600160a01b031687529582019590820190600101611459565b509495945050505050565b838152600060206060818401526114a36060840186611445565b838103604085015284518082528286019183019060005b818110156114d6578351835292840192918401916001016114ba565b509098975050505050505050565b6000602082840312156114f657600080fd5b5035919050565b600080600080600060a0868803121561151557600080fd5b61151e8661140e565b945060208601359350604086013560ff8116811461153b57600080fd5b94979396509394606081013594506080013592915050565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561157c57600080fd5b823567ffffffffffffffff8082111561159457600080fd5b818501915085601f8301126115a857600080fd5b8135818111156115ba576115ba611553565b8060051b604051601f19603f830116810181811085821117156115df576115df611553565b6040529182528482019250838101850191888311156115fd57600080fd5b938501935b82851015611622576116138561140e565b84529385019392850192611602565b98975050505050505050565b602081526000610c6c6020830184611445565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156116b6576116b661168c565b5060010190565b600181815b808511156116f85781600019048211156116de576116de61168c565b808516156116eb57918102915b93841c93908002906116c2565b509250929050565b60008261170f57506001610c6f565b8161171c57506000610c6f565b8160018114611732576002811461173c57611758565b6001915050610c6f565b60ff84111561174d5761174d61168c565b50506001821b610c6f565b5060208310610133831016604e8410600b841016171561177b575081810a610c6f565b61178583836116bd565b80600019048211156117995761179961168c565b029392505050565b6000610c6c60ff841683611700565b600082198211156117c3576117c361168c565b500190565b60008160001904831182151516156117e2576117e261168c565b500290565b60008261180457634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fd5b60006020828403121561183157600080fd5b8151801515811461120c57600080fd5b60005b8381101561185c578181015183820152602001611844565b83811115610d515750506000910152565b6000825161187f818460208701611841565b9190910192915050565b60208152600082518060208401526118a8816040850160208701611841565b601f01601f1916919091016040019291505056fea2646970667358221220327277d054406ae6c1e03ce21a2f913a0dcb7520a1a213b066876e5c9fb41c3864736f6c63430008090033000000000000000000000000dec2ced03dba3c7fa13bb1d9b1c4dc60c23fe09a000000000000000000000000cf33208823c3b6e872a006f37d5e6102f6fccc66000000000000000000000000000000000000000000084595161401484a0000000000000000000000000000000000000000000000000000000000000062d664800000000000000000000000000000000000000000000000000000000062e0f080000000000000000000000000000000000000000000000000000000000000c35000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101585760003560e01c80637ff9b596116100c3578063b7a8807c1161007c578063b7a8807c146102c7578063d09edf31146102d0578063deaa59df146102e3578063e25b2c35146102f6578063e2dc431014610309578063f2fde38b1461031c57600080fd5b80637ff9b5961461025f5780638da5cb5b146102685780639c46a87414610279578063a14e40231461028c578063aa2aedc41461029f578063abdd11a8146102b457600080fd5b80634b89c41d116101155780634b89c41d146101dd5780634bae6f3f146101f0578063521eb273146102105780635b6a07aa1461023b5780636a61e5fc14610244578063715018a61461025757600080fd5b8063058a628f1461015d5780630dcf4b8f14610172578063355274ea1461019257806347535d7b146101a957806347786d37146101c15780634b6753bc146101d4575b600080fd5b61017061016b36600461142a565b61032f565b005b61017a610384565b60405161018993929190611489565b60405180910390f35b61019b60015481565b604051908152602001610189565b6101b16104e3565b6040519015158152602001610189565b6101706101cf3660046114e4565b6104fc565b61019b60035481565b6101706101eb3660046114e4565b61052b565b61019b6101fe36600461142a565b600b6020526000908152604090205481565b600554610223906001600160a01b031681565b6040516001600160a01b039091168152602001610189565b61019b600c5481565b6101706102523660046114e4565b61055a565b610170610589565b61019b60045481565b6000546001600160a01b0316610223565b6101706102873660046114fd565b6105bf565b61017061029a366004611569565b610844565b6102a76108a8565b604051610189919061162e565b6101706102c23660046114e4565b61090a565b61019b60025481565b600654610223906001600160a01b031681565b6101706102f136600461142a565b610939565b6101b161030436600461142a565b610985565b61017a61031736600461142a565b6109ef565b61017061032a36600461142a565b610b75565b6000546001600160a01b031633146103625760405162461bcd60e51b815260040161035990611641565b60405180910390fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6000606080600060078054905067ffffffffffffffff8111156103a9576103a9611553565b6040519080825280602002602001820160405280156103d2578160200160208202803683370190505b5060075490915060009067ffffffffffffffff8111156103f4576103f4611553565b60405190808252806020026020018201604052801561041d578160200160208202803683370190505b50905060005b6007548110156104d55760006007828154811061044257610442611676565b60009182526020808320909101546001600160a01b03168083526009909152604090912054855191925090829086908590811061048157610481611676565b60200260200101906001600160a01b031690816001600160a01b031681525050808484815181106104b4576104b4611676565b602002602001018181525050505080806104cd906116a2565b915050610423565b50600a549591945092509050565b60006002544210806104f6575060035442115b15905090565b6000546001600160a01b031633146105265760405162461bcd60e51b815260040161035990611641565b600155565b6000546001600160a01b031633146105555760405162461bcd60e51b815260040161035990611641565b600355565b6000546001600160a01b031633146105845760405162461bcd60e51b815260040161035990611641565b600455565b6000546001600160a01b031633146105b35760405162461bcd60e51b815260040161035990611641565b6105bd6000610c10565b565b6105c885610985565b6105e55760405163418a149f60e11b815260040160405180910390fd5b6105ed6104e3565b61060a57604051636274c3e360e01b815260040160405180910390fd5b600061063060045461062a6012600a61062391906117a1565b8890610c60565b90610c75565b905060015481600c5461064391906117b0565b11156106625760405163a4875a4960e01b815260040160405180910390fd5b604080517f7da008bd4400c227b0db9db6ce34f9b2386dc6492514864fc6f3b1c307dd5af160208083019190915233828401528251808303840181526060909201909252805191012060006106b682610c81565b905060006106c682888888610ccf565b6006549091506001600160a01b038083169116146106f757604051638baa579f60e01b815260040160405180910390fd5b610712336005546001600160a01b038c81169291168b610cf7565b33600090815260086020526040812060010180548a92906107349084906117b0565b90915550503360009081526008602090815260408083206001600160a01b038d168452909152812080548a929061076c9084906117b0565b9091555050600a80548991906000906107869084906117b0565b90915550506001600160a01b038916600090815260096020526040812080548a92906107b39084906117b0565b9250508190555083600c60008282546107cc91906117b0565b9091555050336000908152600b6020526040812080548692906107f09084906117b0565b909155505060408051898152602081018690526001600160a01b038b16917f2e50c677bae4f935cf3cae75a4f965446f702ca5f089ccd5bb77df65f6c85519910160405180910390a2505050505050505050565b6000546001600160a01b0316331461086e5760405162461bcd60e51b815260040161035990611641565b80516005101561089157604051630b10dbad60e31b815260040160405180910390fd5b80516108a4906007906020840190611394565b5050565b6060600780548060200260200160405190810160405280929190818152602001828054801561090057602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108e2575b5050505050905090565b6000546001600160a01b031633146109345760405162461bcd60e51b815260040161035990611641565b600255565b6000546001600160a01b031633146109635760405162461bcd60e51b815260040161035990611641565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000805b6007548110156109e657826001600160a01b0316600782815481106109b0576109b0611676565b6000918252602090912001546001600160a01b031614156109d45750600192915050565b806109de816116a2565b915050610989565b50600092915050565b6000606080600060078054905067ffffffffffffffff811115610a1457610a14611553565b604051908082528060200260200182016040528015610a3d578160200160208202803683370190505b5060075490915060009067ffffffffffffffff811115610a5f57610a5f611553565b604051908082528060200260200182016040528015610a88578160200160208202803683370190505b50905060005b600754811015610b4c57600060078281548110610aad57610aad611676565b60009182526020808320909101546001600160a01b038b81168452600883526040808520919092168085529252909120548551919250908290869085908110610af857610af8611676565b60200260200101906001600160a01b031690816001600160a01b03168152505080848481518110610b2b57610b2b611676565b60200260200101818152505050508080610b44906116a2565b915050610a8e565b506001600160a01b03959095166000908152600860205260409020600101549590949350915050565b6000546001600160a01b03163314610b9f5760405162461bcd60e51b815260040161035990611641565b6001600160a01b038116610c045760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610359565b610c0d81610c10565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610c6c82846117c8565b90505b92915050565b6000610c6c82846117e7565b6000610c6f610c8e610d57565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000610ce087878787610e4a565b91509150610ced81610f37565b5095945050505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610d519085906110f2565b50505050565b6000306001600160a01b037f000000000000000000000000af59a3be12fde3614083afbee3c787e61f2c97d016148015610db057507f000000000000000000000000000000000000000000000000000000000000000146145b15610dda57507fb81d31430d1ae325ee62fd014cf56bdfa675fafc8b9e2511e71f9d05d45b4de290565b610e457f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f2eed07af5bdc16d511d9d3be63ff87caf8cc9110a03ad1ebe3b7d0a8a5b294517fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66111c9565b905090565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115610e815750600090506003610f2e565b8460ff16601b14158015610e9957508460ff16601c14155b15610eaa5750600090506004610f2e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610efe573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610f2757600060019250925050610f2e565b9150600090505b94509492505050565b6000816004811115610f4b57610f4b611809565b1415610f545750565b6001816004811115610f6857610f68611809565b1415610fb65760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610359565b6002816004811115610fca57610fca611809565b14156110185760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610359565b600381600481111561102c5761102c611809565b14156110855760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610359565b600481600481111561109957611099611809565b1415610c0d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610359565b6000611147826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112139092919063ffffffff16565b8051909150156111c45780806020019051810190611165919061181f565b6111c45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610359565b505050565b6040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090505b9392505050565b6060611222848460008561122a565b949350505050565b60608247101561128b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610359565b6001600160a01b0385163b6112e25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610359565b600080866001600160a01b031685876040516112fe919061186d565b60006040518083038185875af1925050503d806000811461133b576040519150601f19603f3d011682016040523d82523d6000602084013e611340565b606091505b509150915061135082828661135b565b979650505050505050565b6060831561136a57508161120c565b82511561137a5782518084602001fd5b8160405162461bcd60e51b81526004016103599190611889565b8280548282559060005260206000209081019282156113e9579160200282015b828111156113e957825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906113b4565b506113f59291506113f9565b5090565b5b808211156113f557600081556001016113fa565b80356001600160a01b038116811461142557600080fd5b919050565b60006020828403121561143c57600080fd5b610c6c8261140e565b600081518084526020808501945080840160005b8381101561147e5781516001600160a01b031687529582019590820190600101611459565b509495945050505050565b838152600060206060818401526114a36060840186611445565b838103604085015284518082528286019183019060005b818110156114d6578351835292840192918401916001016114ba565b509098975050505050505050565b6000602082840312156114f657600080fd5b5035919050565b600080600080600060a0868803121561151557600080fd5b61151e8661140e565b945060208601359350604086013560ff8116811461153b57600080fd5b94979396509394606081013594506080013592915050565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561157c57600080fd5b823567ffffffffffffffff8082111561159457600080fd5b818501915085601f8301126115a857600080fd5b8135818111156115ba576115ba611553565b8060051b604051601f19603f830116810181811085821117156115df576115df611553565b6040529182528482019250838101850191888311156115fd57600080fd5b938501935b82851015611622576116138561140e565b84529385019392850192611602565b98975050505050505050565b602081526000610c6c6020830184611445565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156116b6576116b661168c565b5060010190565b600181815b808511156116f85781600019048211156116de576116de61168c565b808516156116eb57918102915b93841c93908002906116c2565b509250929050565b60008261170f57506001610c6f565b8161171c57506000610c6f565b8160018114611732576002811461173c57611758565b6001915050610c6f565b60ff84111561174d5761174d61168c565b50506001821b610c6f565b5060208310610133831016604e8410600b841016171561177b575081810a610c6f565b61178583836116bd565b80600019048211156117995761179961168c565b029392505050565b6000610c6c60ff841683611700565b600082198211156117c3576117c361168c565b500190565b60008160001904831182151516156117e2576117e261168c565b500290565b60008261180457634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fd5b60006020828403121561183157600080fd5b8151801515811461120c57600080fd5b60005b8381101561185c578181015183820152602001611844565b83811115610d515750506000910152565b6000825161187f818460208701611841565b9190910192915050565b60208152600082518060208401526118a8816040850160208701611841565b601f01601f1916919091016040019291505056fea2646970667358221220327277d054406ae6c1e03ce21a2f913a0dcb7520a1a213b066876e5c9fb41c3864736f6c63430008090033

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

000000000000000000000000dec2ced03dba3c7fa13bb1d9b1c4dc60c23fe09a000000000000000000000000cf33208823c3b6e872a006f37d5e6102f6fccc66000000000000000000000000000000000000000000084595161401484a0000000000000000000000000000000000000000000000000000000000000062d664800000000000000000000000000000000000000000000000000000000062e0f080000000000000000000000000000000000000000000000000000000000000c35000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48

-----Decoded View---------------
Arg [0] : walletAddress (address): 0xDec2Ced03dba3c7fa13bb1d9b1c4DC60c23fE09A
Arg [1] : authorizerAddress (address): 0xCF33208823c3B6E872a006F37d5E6102F6Fccc66
Arg [2] : capValue (uint256): 10000000000000000000000000
Arg [3] : openingTimeValue (uint256): 1658217600
Arg [4] : closingTimeValue (uint256): 1658908800
Arg [5] : tokenPriceValue (uint256): 50000
Arg [6] : acceptedPaymentTokensValue (address[]): 0xdAC17F958D2ee523a2206206994597C13D831ec7,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 000000000000000000000000dec2ced03dba3c7fa13bb1d9b1c4dc60c23fe09a
Arg [1] : 000000000000000000000000cf33208823c3b6e872a006f37d5e6102f6fccc66
Arg [2] : 000000000000000000000000000000000000000000084595161401484a000000
Arg [3] : 0000000000000000000000000000000000000000000000000000000062d66480
Arg [4] : 0000000000000000000000000000000000000000000000000000000062e0f080
Arg [5] : 000000000000000000000000000000000000000000000000000000000000c350
Arg [6] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [8] : 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7
Arg [9] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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