ETH Price: $1,585.82 (-2.58%)
Gas: 13 Gwei
 
Transaction Hash
Method
Block
From
To
Value
0xc4d550e1c5cb1916645d968a7cac84651129dedfa4aaacdffcbde93a65438e3eTransfer(pending)2023-08-27 14:05:5325 days 2 hrs ago1693145153IN
Threshold Network: T Token
0 ETH(Pending)(Pending)
Transfer181855032023-09-21 16:40:5910 mins ago1695314459IN
Threshold Network: T Token
0 ETH0.0012029321.27358936
Approve181853592023-09-21 16:11:4740 mins ago1695312707IN
Threshold Network: T Token
0 ETH0.0023278749.9746814
Transfer181847072023-09-21 14:00:112 hrs 51 mins ago1695304811IN
Threshold Network: T Token
0 ETH0.0005401715.55879413
Transfer181846772023-09-21 13:54:112 hrs 57 mins ago1695304451IN
Threshold Network: T Token
0 ETH0.0007750419.61248398
Transfer181845072023-09-21 13:19:593 hrs 31 mins ago1695302399IN
Threshold Network: T Token
0 ETH0.0006660212.85309926
Transfer181843462023-09-21 12:47:474 hrs 4 mins ago1695300467IN
Threshold Network: T Token
0 ETH0.000503412.74252111
Transfer181841202023-09-21 12:02:114 hrs 49 mins ago1695297731IN
Threshold Network: T Token
0 ETH0.000336689.69422978
Transfer181840862023-09-21 11:55:234 hrs 56 mins ago1695297323IN
Threshold Network: T Token
0 ETH0.000459648.8703866
Transfer181839612023-09-21 11:30:115 hrs 21 mins ago1695295811IN
Threshold Network: T Token
0 ETH0.0004774513.7617479
Transfer181838302023-09-21 11:03:355 hrs 48 mins ago1695294215IN
Threshold Network: T Token
0 ETH0.0005396313.65531888
Transfer181836462023-09-21 10:26:116 hrs 25 mins ago1695291971IN
Threshold Network: T Token
0 ETH0.0014664842.25439034
Transfer181836162023-09-21 10:20:116 hrs 31 mins ago1695291611IN
Threshold Network: T Token
0 ETH0.0030681454.20183567
Transfer181834352023-09-21 9:43:597 hrs 7 mins ago1695289439IN
Threshold Network: T Token
0 ETH0.00992529251.23515965
Transfer181833782023-09-21 9:32:237 hrs 19 mins ago1695288743IN
Threshold Network: T Token
0 ETH0.0014565125.73081385
Transfer181833362023-09-21 9:23:477 hrs 28 mins ago1695288227IN
Threshold Network: T Token
0 ETH0.0004997612.65037302
Transfer181832862023-09-21 9:13:477 hrs 38 mins ago1695287627IN
Threshold Network: T Token
0 ETH0.0007362713.009828
Transfer181832232023-09-21 9:00:477 hrs 51 mins ago1695286847IN
Threshold Network: T Token
0 ETH0.0004729513.62735048
Approve181829452023-09-21 8:04:478 hrs 47 mins ago1695283487IN
Threshold Network: T Token
0 ETH0.000398938.56425377
Transfer181829172023-09-21 7:58:598 hrs 52 mins ago1695283139IN
Threshold Network: T Token
0 ETH0.0005747110.15297973
Transfer181828992023-09-21 7:55:238 hrs 56 mins ago1695282923IN
Threshold Network: T Token
0 ETH0.000387859.81758111
Approve181828922023-09-21 7:53:598 hrs 57 mins ago1695282839IN
Threshold Network: T Token
0 ETH0.000411688.88843155
Transfer181828102023-09-21 7:37:359 hrs 14 mins ago1695281855IN
Threshold Network: T Token
0 ETH0.0006319911.16481473
Transfer181827742023-09-21 7:30:119 hrs 21 mins ago1695281411IN
Threshold Network: T Token
0 ETH0.0003828211.02683512
Transfer181827452023-09-21 7:24:239 hrs 27 mins ago1695281063IN
Threshold Network: T Token
0 ETH0.000362489.17539447
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:
T

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion, GNU GPLv3 license
File 1 of 20 : T.sol
// SPDX-License-Identifier: GPL-3.0-or-later

// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ

pragma solidity 0.8.9;

import "../governance/Checkpoints.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol";
import "@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol";

/// @title T token
/// @notice Threshold Network T token
/// @dev By default, token balance does not account for voting power.
///      This makes transfers cheaper. The downside is that it requires users
///      to delegate to themselves to activate checkpoints and have their
///      voting power tracked.
contract T is ERC20WithPermit, MisfundRecovery, Checkpoints {
    /// @notice The EIP-712 typehash for the delegation struct used by
    ///         `delegateBySig`.
    bytes32 public constant DELEGATION_TYPEHASH =
        keccak256(
            "Delegation(address delegatee,uint256 nonce,uint256 deadline)"
        );

    constructor() ERC20WithPermit("Threshold Network Token", "T") {}

    /// @notice Delegates votes from signatory to `delegatee`
    /// @param delegatee The address to delegate votes to
    /// @param deadline The time at which to expire the signature
    /// @param v The recovery byte of the signature
    /// @param r Half of the ECDSA signature pair
    /// @param s Half of the ECDSA signature pair
    function delegateBySig(
        address signatory,
        address delegatee,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external {
        /* solhint-disable-next-line not-rely-on-time */
        require(deadline >= block.timestamp, "Delegation expired");

        // Validate `s` and `v` values for a malleability concern described in EIP2.
        // Only signatures with `s` value in the lower half of the secp256k1
        // curve's order and `v` value of 27 or 28 are considered valid.
        require(
            uint256(s) <=
                0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,
            "Invalid signature 's' value"
        );
        require(v == 27 || v == 28, "Invalid signature 'v' value");

        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                DOMAIN_SEPARATOR(),
                keccak256(
                    abi.encode(
                        DELEGATION_TYPEHASH,
                        delegatee,
                        nonce[signatory]++,
                        deadline
                    )
                )
            )
        );

        address recoveredAddress = ecrecover(digest, v, r, s);
        require(
            recoveredAddress != address(0) && recoveredAddress == signatory,
            "Invalid signature"
        );

        return delegate(signatory, delegatee);
    }

    /// @notice Delegate votes from `msg.sender` to `delegatee`.
    /// @param delegatee The address to delegate votes to
    function delegate(address delegatee) public virtual {
        return delegate(msg.sender, delegatee);
    }

    // slither-disable-next-line dead-code
    function beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal override {
        uint96 safeAmount = SafeCast.toUint96(amount);

        // When minting:
        if (from == address(0)) {
            // Does not allow to mint more than uint96 can fit. Otherwise, the
            // Checkpoint might not fit the balance.
            require(
                totalSupply + amount <= maxSupply(),
                "Maximum total supply exceeded"
            );
            writeCheckpoint(_totalSupplyCheckpoints, add, safeAmount);
        }

        // When burning:
        if (to == address(0)) {
            writeCheckpoint(_totalSupplyCheckpoints, subtract, safeAmount);
        }

        moveVotingPower(delegates(from), delegates(to), safeAmount);
    }

    function delegate(address delegator, address delegatee)
        internal
        virtual
        override
    {
        address currentDelegate = delegates(delegator);
        uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);
        _delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        moveVotingPower(currentDelegate, delegatee, delegatorBalance);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev 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 20 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

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

File 4 of 20 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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 5 of 20 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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 20 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

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

File 7 of 20 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 8 of 20 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 9 of 20 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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);
    }
}

File 10 of 20 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 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 11 of 20 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 12 of 20 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

File 13 of 20 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/math/SafeCast.sol)

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 14 of 20 : ERC20WithPermit.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

import "./IERC20WithPermit.sol";
import "./IReceiveApproval.sol";

/// @title  ERC20WithPermit
/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can
///         authorize a transfer of their token with a signature conforming
///         EIP712 standard instead of an on-chain transaction from their
///         address. Anyone can submit this signature on the user's behalf by
///         calling the permit function, as specified in EIP2612 standard,
///         paying gas fees, and possibly performing other actions in the same
///         transaction.
contract ERC20WithPermit is IERC20WithPermit, Ownable {
    /// @notice The amount of tokens owned by the given account.
    mapping(address => uint256) public override balanceOf;

    /// @notice The remaining number of tokens that spender will be
    ///         allowed to spend on behalf of owner through `transferFrom` and
    ///         `burnFrom`. This is zero by default.
    mapping(address => mapping(address => uint256)) public override allowance;

    /// @notice Returns the current nonce for EIP2612 permission for the
    ///         provided token owner for a replay protection. Used to construct
    ///         EIP2612 signature provided to `permit` function.
    mapping(address => uint256) public override nonce;

    uint256 public immutable cachedChainId;
    bytes32 public immutable cachedDomainSeparator;

    /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612
    ///         signature provided to `permit` function.
    bytes32 public constant override PERMIT_TYPEHASH =
        keccak256(
            "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
        );

    /// @notice The amount of tokens in existence.
    uint256 public override totalSupply;

    /// @notice The name of the token.
    string public override name;

    /// @notice The symbol of the token.
    string public override symbol;

    /// @notice The decimals places of the token.
    uint8 public constant override decimals = 18;

    constructor(string memory _name, string memory _symbol) {
        name = _name;
        symbol = _symbol;

        cachedChainId = block.chainid;
        cachedDomainSeparator = buildDomainSeparator();
    }

    /// @notice Moves `amount` tokens from the caller's account to `recipient`.
    /// @return True if the operation succeeded, reverts otherwise.
    /// @dev Requirements:
    ///       - `recipient` cannot be the zero address,
    ///       - the caller must have a balance of at least `amount`.
    function transfer(address recipient, uint256 amount)
        external
        override
        returns (bool)
    {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    /// @notice Moves `amount` tokens from `spender` to `recipient` using the
    ///         allowance mechanism. `amount` is then deducted from the caller's
    ///         allowance unless the allowance was made for `type(uint256).max`.
    /// @return True if the operation succeeded, reverts otherwise.
    /// @dev Requirements:
    ///      - `spender` and `recipient` cannot be the zero address,
    ///      - `spender` must have a balance of at least `amount`,
    ///      - the caller must have allowance for `spender`'s tokens of at least
    ///        `amount`.
    function transferFrom(
        address spender,
        address recipient,
        uint256 amount
    ) external override returns (bool) {
        uint256 currentAllowance = allowance[spender][msg.sender];
        if (currentAllowance != type(uint256).max) {
            require(
                currentAllowance >= amount,
                "Transfer amount exceeds allowance"
            );
            _approve(spender, msg.sender, currentAllowance - amount);
        }
        _transfer(spender, recipient, amount);
        return true;
    }

    /// @notice EIP2612 approval made with secp256k1 signature.
    ///         Users can authorize a transfer of their tokens with a signature
    ///         conforming EIP712 standard, rather than an on-chain transaction
    ///         from their address. Anyone can submit this signature on the
    ///         user's behalf by calling the permit function, paying gas fees,
    ///         and possibly performing other actions in the same transaction.
    /// @dev    The deadline argument can be set to `type(uint256).max to create
    ///         permits that effectively never expire.  If the `amount` is set
    ///         to `type(uint256).max` then `transferFrom` and `burnFrom` will
    ///         not reduce an allowance.
    function permit(
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external override {
        /* solhint-disable-next-line not-rely-on-time */
        require(deadline >= block.timestamp, "Permission expired");

        // Validate `s` and `v` values for a malleability concern described in EIP2.
        // Only signatures with `s` value in the lower half of the secp256k1
        // curve's order and `v` value of 27 or 28 are considered valid.
        require(
            uint256(s) <=
                0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,
            "Invalid signature 's' value"
        );
        require(v == 27 || v == 28, "Invalid signature 'v' value");

        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                DOMAIN_SEPARATOR(),
                keccak256(
                    abi.encode(
                        PERMIT_TYPEHASH,
                        owner,
                        spender,
                        amount,
                        nonce[owner]++,
                        deadline
                    )
                )
            )
        );
        address recoveredAddress = ecrecover(digest, v, r, s);
        require(
            recoveredAddress != address(0) && recoveredAddress == owner,
            "Invalid signature"
        );
        _approve(owner, spender, amount);
    }

    /// @notice Creates `amount` tokens and assigns them to `account`,
    ///         increasing the total supply.
    /// @dev Requirements:
    ///      - `recipient` cannot be the zero address.
    function mint(address recipient, uint256 amount) external onlyOwner {
        require(recipient != address(0), "Mint to the zero address");

        beforeTokenTransfer(address(0), recipient, amount);

        totalSupply += amount;
        balanceOf[recipient] += amount;
        emit Transfer(address(0), recipient, amount);
    }

    /// @notice Destroys `amount` tokens from the caller.
    /// @dev Requirements:
    ///       - the caller must have a balance of at least `amount`.
    function burn(uint256 amount) external override {
        _burn(msg.sender, amount);
    }

    /// @notice Destroys `amount` of tokens from `account` using the allowance
    ///         mechanism. `amount` is then deducted from the caller's allowance
    ///         unless the allowance was made for `type(uint256).max`.
    /// @dev Requirements:
    ///      - `account` must have a balance of at least `amount`,
    ///      - the caller must have allowance for `account`'s tokens of at least
    ///        `amount`.
    function burnFrom(address account, uint256 amount) external override {
        uint256 currentAllowance = allowance[account][msg.sender];
        if (currentAllowance != type(uint256).max) {
            require(
                currentAllowance >= amount,
                "Burn amount exceeds allowance"
            );
            _approve(account, msg.sender, currentAllowance - amount);
        }
        _burn(account, amount);
    }

    /// @notice Calls `receiveApproval` function on spender previously approving
    ///         the spender to withdraw from the caller multiple times, up to
    ///         the `amount` amount. If this function is called again, it
    ///         overwrites the current allowance with `amount`. Reverts if the
    ///         approval reverted or if `receiveApproval` call on the spender
    ///         reverted.
    /// @return True if both approval and `receiveApproval` calls succeeded.
    /// @dev If the `amount` is set to `type(uint256).max` then
    ///      `transferFrom` and `burnFrom` will not reduce an allowance.
    function approveAndCall(
        address spender,
        uint256 amount,
        bytes memory extraData
    ) external override returns (bool) {
        if (approve(spender, amount)) {
            IReceiveApproval(spender).receiveApproval(
                msg.sender,
                amount,
                address(this),
                extraData
            );
            return true;
        }
        return false;
    }

    /// @notice Sets `amount` as the allowance of `spender` over the caller's
    ///         tokens.
    /// @return True if the operation succeeded.
    /// @dev If the `amount` is set to `type(uint256).max` then
    ///      `transferFrom` and `burnFrom` will not reduce an allowance.
    ///      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
    function approve(address spender, uint256 amount)
        public
        override
        returns (bool)
    {
        _approve(msg.sender, spender, amount);
        return true;
    }

    /// @notice Returns hash of EIP712 Domain struct with the token name as
    ///         a signing domain and token contract as a verifying contract.
    ///         Used to construct EIP2612 signature provided to `permit`
    ///         function.
    /* solhint-disable-next-line func-name-mixedcase */
    function DOMAIN_SEPARATOR() public view override returns (bytes32) {
        // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the
        // chainId and is defined at contract deployment instead of
        // reconstructed for every signature, there is a risk of possible replay
        // attacks between chains in the event of a future chain split.
        // To address this issue, we check the cached chain ID against the
        // current one and in case they are different, we build domain separator
        // from scratch.
        if (block.chainid == cachedChainId) {
            return cachedDomainSeparator;
        } else {
            return buildDomainSeparator();
        }
    }

    /// @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 to 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.
    // slither-disable-next-line dead-code
    function beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    function _burn(address account, uint256 amount) internal {
        uint256 currentBalance = balanceOf[account];
        require(currentBalance >= amount, "Burn amount exceeds balance");

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

        balanceOf[account] = currentBalance - amount;
        totalSupply -= amount;
        emit Transfer(account, address(0), amount);
    }

    function _transfer(
        address spender,
        address recipient,
        uint256 amount
    ) private {
        require(spender != address(0), "Transfer from the zero address");
        require(recipient != address(0), "Transfer to the zero address");
        require(recipient != address(this), "Transfer to the token address");

        beforeTokenTransfer(spender, recipient, amount);

        uint256 spenderBalance = balanceOf[spender];
        require(spenderBalance >= amount, "Transfer amount exceeds balance");
        balanceOf[spender] = spenderBalance - amount;
        balanceOf[recipient] += amount;
        emit Transfer(spender, recipient, amount);
    }

    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) private {
        require(owner != address(0), "Approve from the zero address");
        require(spender != address(0), "Approve to the zero address");
        allowance[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    function buildDomainSeparator() private view returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256(
                        "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
                    ),
                    keccak256(bytes(name)),
                    keccak256(bytes("1")),
                    block.chainid,
                    address(this)
                )
            );
    }
}

File 15 of 20 : IApproveAndCall.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

/// @notice An interface that should be implemented by tokens supporting
///         `approveAndCall`/`receiveApproval` pattern.
interface IApproveAndCall {
    /// @notice Executes `receiveApproval` function on spender as specified in
    ///         `IReceiveApproval` interface. Approves spender to withdraw from
    ///         the caller multiple times, up to the `amount`. If this
    ///         function is called again, it overwrites the current allowance
    ///         with `amount`. Reverts if the approval reverted or if
    ///         `receiveApproval` call on the spender reverted.
    function approveAndCall(
        address spender,
        uint256 amount,
        bytes memory extraData
    ) external returns (bool);
}

File 16 of 20 : IERC20WithPermit.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

import "./IApproveAndCall.sol";

/// @title  IERC20WithPermit
/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can
///         authorize a transfer of their token with a signature conforming
///         EIP712 standard instead of an on-chain transaction from their
///         address. Anyone can submit this signature on the user's behalf by
///         calling the permit function, as specified in EIP2612 standard,
///         paying gas fees, and possibly performing other actions in the same
///         transaction.
interface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {
    /// @notice EIP2612 approval made with secp256k1 signature.
    ///         Users can authorize a transfer of their tokens with a signature
    ///         conforming EIP712 standard, rather than an on-chain transaction
    ///         from their address. Anyone can submit this signature on the
    ///         user's behalf by calling the permit function, paying gas fees,
    ///         and possibly performing other actions in the same transaction.
    /// @dev    The deadline argument can be set to `type(uint256).max to create
    ///         permits that effectively never expire.
    function permit(
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /// @notice Destroys `amount` tokens from the caller.
    function burn(uint256 amount) external;

    /// @notice Destroys `amount` of tokens from `account`, deducting the amount
    ///         from caller's allowance.
    function burnFrom(address account, uint256 amount) external;

    /// @notice Returns hash of EIP712 Domain struct with the token name as
    ///         a signing domain and token contract as a verifying contract.
    ///         Used to construct EIP2612 signature provided to `permit`
    ///         function.
    /* solhint-disable-next-line func-name-mixedcase */
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice Returns the current nonce for EIP2612 permission for the
    ///         provided token owner for a replay protection. Used to construct
    ///         EIP2612 signature provided to `permit` function.
    function nonce(address owner) external view returns (uint256);

    /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612
    ///         signature provided to `permit` function.
    /* solhint-disable-next-line func-name-mixedcase */
    function PERMIT_TYPEHASH() external pure returns (bytes32);
}

File 17 of 20 : IReceiveApproval.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

/// @notice An interface that should be implemented by contracts supporting
///         `approveAndCall`/`receiveApproval` pattern.
interface IReceiveApproval {
    /// @notice Receives approval to spend tokens. Called as a result of
    ///         `approveAndCall` call on the token.
    function receiveApproval(
        address from,
        uint256 amount,
        address token,
        bytes calldata extraData
    ) external;
}

File 18 of 20 : MisfundRecovery.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/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @title  MisfundRecovery
/// @notice Allows the owner of the token contract extending MisfundRecovery
///         to recover any ERC20 and ERC721 sent mistakenly to the token
///         contract address.
contract MisfundRecovery is Ownable {
    using SafeERC20 for IERC20;

    function recoverERC20(
        IERC20 token,
        address recipient,
        uint256 amount
    ) external onlyOwner {
        token.safeTransfer(recipient, amount);
    }

    function recoverERC721(
        IERC721 token,
        address recipient,
        uint256 tokenId,
        bytes calldata data
    ) external onlyOwner {
        token.safeTransferFrom(address(this), recipient, tokenId, data);
    }
}

File 19 of 20 : Checkpoints.sol
// SPDX-License-Identifier: GPL-3.0-or-later

// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ

pragma solidity 0.8.9;

import "./IVotesHistory.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";

/// @title Checkpoints
/// @dev Abstract contract to support checkpoints for Compound-like voting and
///      delegation. This implementation supports token supply up to 2^96 - 1.
///      This contract keeps a history (checkpoints) of each account's vote
///      power. Vote power can be delegated either by calling the {delegate}
///      function directly, or by providing a signature to be used with
///      {delegateBySig}. Voting power can be publicly queried through
///      {getVotes} and {getPastVotes}.
///      NOTE: Extracted from OpenZeppelin ERCVotes.sol.
abstract contract Checkpoints is IVotesHistory {
    struct Checkpoint {
        uint32 fromBlock;
        uint96 votes;
    }

    // slither-disable-next-line uninitialized-state
    mapping(address => address) internal _delegates;
    mapping(address => uint128[]) internal _checkpoints;
    uint128[] internal _totalSupplyCheckpoints;

    /// @notice Emitted when an account changes their delegate.
    event DelegateChanged(
        address indexed delegator,
        address indexed fromDelegate,
        address indexed toDelegate
    );

    /// @notice Emitted when a balance or delegate change results in changes
    ///         to an account's voting power.
    event DelegateVotesChanged(
        address indexed delegate,
        uint256 previousBalance,
        uint256 newBalance
    );

    function checkpoints(address account, uint32 pos)
        public
        view
        virtual
        returns (Checkpoint memory checkpoint)
    {
        (uint32 fromBlock, uint96 votes) = decodeCheckpoint(
            _checkpoints[account][pos]
        );
        checkpoint = Checkpoint(fromBlock, votes);
    }

    /// @notice Get number of checkpoints for `account`.
    function numCheckpoints(address account)
        public
        view
        virtual
        returns (uint32)
    {
        return SafeCast.toUint32(_checkpoints[account].length);
    }

    /// @notice Get the address `account` is currently delegating to.
    function delegates(address account) public view virtual returns (address) {
        return _delegates[account];
    }

    /// @notice Gets the current votes balance for `account`.
    /// @param account The address to get votes balance
    /// @return The number of current votes for `account`
    function getVotes(address account) public view returns (uint96) {
        uint256 pos = _checkpoints[account].length;
        return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);
    }

    /// @notice Determine the prior number of votes for an account as of
    ///         a block number.
    /// @dev Block number must be a finalized block or else this function will
    ///      revert to prevent misinformation.
    /// @param account The address of the account to check
    /// @param blockNumber The block number to get the vote balance at
    /// @return The number of votes the account had as of the given block
    function getPastVotes(address account, uint256 blockNumber)
        public
        view
        returns (uint96)
    {
        return lookupCheckpoint(_checkpoints[account], blockNumber);
    }

    /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.
    ///         Note, this value is the sum of all balances, but it is NOT the
    ///         sum of all the delegated votes!
    /// @param blockNumber The block number to get the total supply at
    /// @dev `blockNumber` must have been already mined
    function getPastTotalSupply(uint256 blockNumber)
        public
        view
        returns (uint96)
    {
        return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);
    }

    /// @notice Change delegation for `delegator` to `delegatee`.
    // slither-disable-next-line dead-code
    function delegate(address delegator, address delegatee) internal virtual;

    /// @notice Moves voting power from one delegate to another
    /// @param src Address of old delegate
    /// @param dst Address of new delegate
    /// @param amount Voting power amount to transfer between delegates
    function moveVotingPower(
        address src,
        address dst,
        uint256 amount
    ) internal {
        if (src != dst && amount > 0) {
            if (src != address(0)) {
                // https://github.com/crytic/slither/issues/960
                // slither-disable-next-line variable-scope
                (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(
                    _checkpoints[src],
                    subtract,
                    amount
                );
                emit DelegateVotesChanged(src, oldWeight, newWeight);
            }

            if (dst != address(0)) {
                // https://github.com/crytic/slither/issues/959
                // slither-disable-next-line uninitialized-local
                (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(
                    _checkpoints[dst],
                    add,
                    amount
                );
                emit DelegateVotesChanged(dst, oldWeight, newWeight);
            }
        }
    }

    /// @notice Writes a new checkpoint based on operating last stored value
    ///         with a `delta`. Usually, said operation is the `add` or
    ///         `subtract` functions from this contract, but more complex
    ///         functions can be passed as parameters.
    /// @param ckpts The checkpoints array to use
    /// @param op The function to apply over the last value and the `delta`
    /// @param delta Variation with respect to last stored value to be used
    ///              for new checkpoint
    function writeCheckpoint(
        uint128[] storage ckpts,
        function(uint256, uint256) view returns (uint256) op,
        uint256 delta
    ) internal returns (uint256 oldWeight, uint256 newWeight) {
        uint256 pos = ckpts.length;
        oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);
        newWeight = op(oldWeight, delta);

        if (pos > 0) {
            uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);
            // slither-disable-next-line incorrect-equality
            if (fromBlock == block.number) {
                ckpts[pos - 1] = encodeCheckpoint(
                    fromBlock,
                    SafeCast.toUint96(newWeight)
                );
                return (oldWeight, newWeight);
            }
        }

        ckpts.push(
            encodeCheckpoint(
                SafeCast.toUint32(block.number),
                SafeCast.toUint96(newWeight)
            )
        );
    }

    /// @notice Lookup a value in a list of (sorted) checkpoints.
    /// @param ckpts The checkpoints array to use
    /// @param blockNumber Block number when we want to get the checkpoint at
    function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)
        internal
        view
        returns (uint96)
    {
        // We run a binary search to look for the earliest checkpoint taken
        // after `blockNumber`. During the loop, the index of the wanted
        // checkpoint remains in the range [low-1, high). With each iteration,
        // either `low` or `high` is moved towards the middle of the range to
        // maintain the invariant.
        // - If the middle checkpoint is after `blockNumber`,
        //   we look in [low, mid)
        // - If the middle checkpoint is before or equal to `blockNumber`,
        //   we look in [mid+1, high)
        // Once we reach a single value (when low == high), we've found the
        // right checkpoint at the index high-1, if not out of bounds (in that
        // case we're looking too far in the past and the result is 0).
        // Note that if the latest checkpoint available is exactly for
        // `blockNumber`, we end up with an index that is past the end of the
        // array, so we technically don't find a checkpoint after
        // `blockNumber`, but it works out the same.
        require(blockNumber < block.number, "Block not yet determined");

        uint256 high = ckpts.length;
        uint256 low = 0;
        while (low < high) {
            uint256 mid = Math.average(low, high);
            uint32 midBlock = decodeBlockNumber(ckpts[mid]);
            if (midBlock > blockNumber) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        return high == 0 ? 0 : decodeValue(ckpts[high - 1]);
    }

    /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)
    // slither-disable-next-line dead-code
    function maxSupply() internal view virtual returns (uint96) {
        return type(uint96).max;
    }

    /// @notice Encodes a `blockNumber` and `value` into a single `uint128`
    ///         checkpoint.
    /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the
    ///      remaining 96 bits.
    function encodeCheckpoint(uint32 blockNumber, uint96 value)
        internal
        pure
        returns (uint128)
    {
        return (uint128(blockNumber) << 96) | uint128(value);
    }

    /// @notice Decodes a block number from a `uint128` `checkpoint`.
    function decodeBlockNumber(uint128 checkpoint)
        internal
        pure
        returns (uint32)
    {
        return uint32(bytes4(bytes16(checkpoint)));
    }

    /// @notice Decodes a voting value from a `uint128` `checkpoint`.
    function decodeValue(uint128 checkpoint) internal pure returns (uint96) {
        return uint96(checkpoint);
    }

    /// @notice Decodes a block number and voting value from a `uint128`
    ///         `checkpoint`.
    function decodeCheckpoint(uint128 checkpoint)
        internal
        pure
        returns (uint32 blockNumber, uint96 value)
    {
        blockNumber = decodeBlockNumber(checkpoint);
        value = decodeValue(checkpoint);
    }

    // slither-disable-next-line dead-code
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    // slither-disable-next-line dead-code
    function subtract(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }
}

File 20 of 20 : IVotesHistory.sol
// SPDX-License-Identifier: GPL-3.0-or-later

// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ
//               β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ    β–β–ˆβ–ˆβ–ˆβ–ˆβ–Œ

pragma solidity 0.8.9;

interface IVotesHistory {
    function getPastVotes(address account, uint256 blockNumber)
        external
        view
        returns (uint96);

    function getPastTotalSupply(uint256 blockNumber)
        external
        view
        returns (uint96);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DELEGATION_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cachedChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cachedDomainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"pos","type":"uint32"}],"name":"checkpoints","outputs":[{"components":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"internalType":"uint96","name":"votes","type":"uint96"}],"internalType":"struct Checkpoints.Checkpoint","name":"checkpoint","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signatory","type":"address"},{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPastTotalSupply","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPastVotes","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getVotes","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"recoverERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040523480156200001157600080fd5b506040518060400160405280601781526020017f5468726573686f6c64204e6574776f726b20546f6b656e000000000000000000815250604051806040016040528060018152602001601560fa1b8152506200007c62000076620000c260201b60201c565b620000c6565b815162000091906005906020850190620001c7565b508051620000a7906006906020840190620001c7565b5046608052620000b662000116565b60a052506200034e9050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60056040516200014a9190620002aa565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b828054620001d5906200026d565b90600052602060002090601f016020900481019282620001f9576000855562000244565b82601f106200021457805160ff191683800117855562000244565b8280016001018555821562000244579182015b828111156200024457825182559160200191906001019062000227565b506200025292915062000256565b5090565b5b8082111562000252576000815560010162000257565b600181811c908216806200028257607f821691505b60208210811415620002a457634e487b7160e01b600052602260045260246000fd5b50919050565b600080835481600182811c915080831680620002c757607f831692505b6020808410821415620002e857634e487b7160e01b86526022600452602486fd5b818015620002ff5760018114620003115762000340565b60ff1986168952848901965062000340565b60008a81526020902060005b86811015620003385781548b8201529085019083016200031d565b505084890196505b509498975050505050505050565b60805160a05161262d620003826000396000818161042301526106f501526000818161038d01526106cc015261262d6000f3fe608060405234801561001057600080fd5b50600436106101bb5760003560e01c8063715018a6116100fa578063b20d7fa91161009d578063b20d7fa91461040b578063b4f94b2e1461041e578063cae9ca5114610445578063d505accf14610458578063dd62ed3e1461046b578063e7a324dc14610496578063f1127ed8146104bd578063f2fde38b146104fa578063fc4e51f61461050d57600080fd5b8063715018a614610380578063771da5c51461038857806379cc6790146103af5780638da5cb5b146103c25780638e539e8c146103ca57806395d89b41146103dd5780639ab24eb0146103e5578063a9059cbb146103f857600080fd5b80633a46b1a8116101625780633a46b1a81461028957806340c10f19146102b457806342966c68146102c7578063587cde1e146102da5780635c19a95c146103055780636fcfff451461031857806370a082311461034057806370ae92d21461036057600080fd5b806306fdde03146101c0578063095ea7b3146101de5780631171bda91461020157806318160ddd1461021657806323b872dd1461022d57806330adf81f14610240578063313ce567146102675780633644e51514610281575b600080fd5b6101c8610520565b6040516101d59190611f0c565b60405180910390f35b6101f16101ec366004611f34565b6105ae565b60405190151581526020016101d5565b61021461020f366004611f60565b6105c4565b005b61021f60045481565b6040519081526020016101d5565b6101f161023b366004611f60565b610615565b61021f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61026f601281565b60405160ff90911681526020016101d5565b61021f6106c8565b61029c610297366004611f34565b610724565b6040516001600160601b0390911681526020016101d5565b6102146102c2366004611f34565b610746565b6102146102d5366004611fa1565b610849565b6102ed6102e8366004611fba565b610856565b6040516001600160a01b0390911681526020016101d5565b610214610313366004611fba565b610874565b61032b610326366004611fba565b61087e565b60405163ffffffff90911681526020016101d5565b61021f61034e366004611fba565b60016020526000908152604090205481565b61021f61036e366004611fba565b60036020526000908152604090205481565b6102146108a6565b61021f7f000000000000000000000000000000000000000000000000000000000000000081565b6102146103bd366004611f34565b6108e1565b6102ed610977565b61029c6103d8366004611fa1565b610986565b6101c8610993565b61029c6103f3366004611fba565b6109a0565b6101f1610406366004611f34565b610a30565b610214610419366004611fed565b610a3d565b61021f7f000000000000000000000000000000000000000000000000000000000000000081565b6101f1610453366004612066565b610c6a565b610214610466366004612133565b610cf2565b61021f6104793660046121a1565b600260209081526000928352604080842090915290825290205481565b61021f7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e281565b6104d06104cb3660046121da565b610f2c565b60408051825163ffffffff1681526020928301516001600160601b031692810192909252016101d5565b610214610508366004611fba565b610fd8565b61021461051b366004612211565b611075565b6005805461052d906122b0565b80601f0160208091040260200160405190810160405280929190818152602001828054610559906122b0565b80156105a65780601f1061057b576101008083540402835291602001916105a6565b820191906000526020600020905b81548152906001019060200180831161058957829003601f168201915b505050505081565b60006105bb338484611106565b50600192915050565b336105cd610977565b6001600160a01b0316146105fc5760405162461bcd60e51b81526004016105f3906122eb565b60405180910390fd5b6106106001600160a01b0384168383611214565b505050565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001981146106b0578281101561069c5760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b60648201526084016105f3565b6106b085336106ab8685612336565b611106565b6106bb858585611266565b60019150505b9392505050565b60007f000000000000000000000000000000000000000000000000000000000000000046141561071757507f000000000000000000000000000000000000000000000000000000000000000090565b61071f611467565b905090565b6001600160a01b03821660009081526008602052604081206106c19083611516565b3361074f610977565b6001600160a01b0316146107755760405162461bcd60e51b81526004016105f3906122eb565b6001600160a01b0382166107c65760405162461bcd60e51b81526020600482015260186024820152774d696e7420746f20746865207a65726f206164647265737360401b60448201526064016105f3565b6107d260008383611611565b80600460008282546107e4919061234d565b90915550506001600160a01b0382166000908152600160205260408120805483929061081190849061234d565b90915550506040518181526001600160a01b038316906000906000805160206125d88339815191529060200160405180910390a35050565b61085333826116fd565b50565b6001600160a01b039081166000908152600760205260409020541690565b61085333826117db565b6001600160a01b0381166000908152600860205260408120546108a09061187d565b92915050565b336108af610977565b6001600160a01b0316146108d55760405162461bcd60e51b81526004016105f3906122eb565b6108df60006118e6565b565b6001600160a01b0382166000908152600260209081526040808320338452909152902054600019811461096d578181101561095e5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e636500000060448201526064016105f3565b61096d83336106ab8585612336565b61061083836116fd565b6000546001600160a01b031690565b60006108a0600983611516565b6006805461052d906122b0565b6001600160a01b0381166000908152600860205260408120548015610a27576001600160a01b0383166000908152600860205260409020610a22906109e6600184612336565b815481106109f6576109f6612365565b90600052602060002090600291828204019190066010029054906101000a90046001600160801b031690565b6106c1565b60009392505050565b60006105bb338484611266565b42841015610a825760405162461bcd60e51b815260206004820152601260248201527111195b1959d85d1a5bdb88195e1c1a5c995960721b60448201526064016105f3565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b03811115610ab85760405162461bcd60e51b81526004016105f39061237b565b8260ff16601b1480610acd57508260ff16601c145b610ae95760405162461bcd60e51b81526004016105f3906123b2565b6000610af36106c8565b6001600160a01b038816600090815260036020526040812080547f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e2928a9290610b3b836123e9565b9190505588604051602001610b7294939291909384526001600160a01b039290921660208401526040830152606082015260800190565b60405160208183030381529060405280519060200120604051602001610b99929190612404565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610c04573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610c3a5750876001600160a01b0316816001600160a01b0316145b610c565760405162461bcd60e51b81526004016105f39061241f565b610c6088886117db565b5050505050505050565b6000610c7684846105ae565b15610ce857604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb190610cad90339087903090889060040161244a565b600060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b50505050600190506106c1565b5060009392505050565b42841015610d375760405162461bcd60e51b815260206004820152601260248201527114195c9b5a5cdcda5bdb88195e1c1a5c995960721b60448201526064016105f3565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b03811115610d6d5760405162461bcd60e51b81526004016105f39061237b565b8260ff16601b1480610d8257508260ff16601c145b610d9e5760405162461bcd60e51b81526004016105f3906123b2565b6000610da86106c8565b6001600160a01b038916600090815260036020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c92909190610df6836123e9565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610e59929190612404565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610ec4573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610efa5750886001600160a01b0316816001600160a01b0316145b610f165760405162461bcd60e51b81526004016105f39061241f565b610f21898989611106565b505050505050505050565b60408051808201909152600080825260208201526001600160a01b038316600090815260086020526040812080548291610fad9163ffffffff8716908110610f7657610f76612365565b90600052602060002090600291828204019190066010029054906101000a90046001600160801b031663ffffffff606082901c1691565b6040805180820190915263ffffffff90921682526001600160601b0316602082015295945050505050565b33610fe1610977565b6001600160a01b0316146110075760405162461bcd60e51b81526004016105f3906122eb565b6001600160a01b03811661106c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105f3565b610853816118e6565b3361107e610977565b6001600160a01b0316146110a45760405162461bcd60e51b81526004016105f3906122eb565b604051635c46a7ef60e11b81526001600160a01b0386169063b88d4fde906110d89030908890889088908890600401612487565b600060405180830381600087803b1580156110f257600080fd5b505af1158015610f21573d6000803e3d6000fd5b6001600160a01b03831661115c5760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f206164647265737300000060448201526064016105f3565b6001600160a01b0382166111b25760405162461bcd60e51b815260206004820152601b60248201527f417070726f766520746f20746865207a65726f2061646472657373000000000060448201526064016105f3565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610610908490611936565b6001600160a01b0383166112bc5760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f2061646472657373000060448201526064016105f3565b6001600160a01b0382166113125760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016105f3565b6001600160a01b03821630141561136b5760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e206164647265737300000060448201526064016105f3565b611376838383611611565b6001600160a01b038316600090815260016020526040902054818110156113df5760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e63650060448201526064016105f3565b6113e98282612336565b6001600160a01b03808616600090815260016020526040808220939093559085168152908120805484929061141f90849061234d565b92505081905550826001600160a01b0316846001600160a01b03166000805160206125d88339815191528460405161145991815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600560405161149991906124db565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60004382106115625760405162461bcd60e51b8152602060048201526018602482015277109b1bd8dac81b9bdd081e595d0819195d195c9b5a5b995960421b60448201526064016105f3565b825460005b818110156115eb57600061157b8284611a08565b905060006115be87838154811061159457611594612365565b6000918252602090912060028204015463ffffffff60019092166010026101000a900460601c1690565b9050858163ffffffff1611156115d6578193506115e4565b6115e182600161234d565b92505b5050611567565b811561160557611600856109e6600185612336565b611608565b60005b95945050505050565b600061161c82611a23565b90506001600160a01b0384166116ab576004546001600160601b039061164390849061234d565b11156116915760405162461bcd60e51b815260206004820152601d60248201527f4d6178696d756d20746f74616c20737570706c7920657863656564656400000060448201526064016105f3565b6116a86009611a8b836001600160601b0316611a97565b50505b6001600160a01b0383166116d3576116d06009611bf3836001600160601b0316611a97565b50505b6116f76116df85610856565b6116e885610856565b836001600160601b0316611bff565b50505050565b6001600160a01b038216600090815260016020526040902054818110156117665760405162461bcd60e51b815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016105f3565b61177283600084611611565b61177c8282612336565b6001600160a01b038416600090815260016020526040812091909155600480548492906117aa908490612336565b90915550506040518281526000906001600160a01b038516906000805160206125d883398151915290602001611207565b60006117e683610856565b6001600160a01b0384166000908152600160205260408120549192509061180c90611a23565b6001600160a01b0385811660008181526007602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46116f78284836001600160601b0316611bff565b600063ffffffff8211156118e25760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b60648201526084016105f3565b5090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061198b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d3c9092919063ffffffff16565b80519091501561061057808060200190518101906119a99190612577565b6106105760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105f3565b6000611a176002848418612599565b6106c19084841661234d565b60006001600160601b038211156118e25760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203960448201526536206269747360d01b60648201526084016105f3565b60006106c1828461234d565b825460009081908015611ab857611ab3866109e6600184612336565b611abb565b60005b6001600160601b03169250611ad483858763ffffffff16565b91508015611b94576000611afd87611aed600185612336565b8154811061159457611594612365565b9050438163ffffffff161415611b9257611b3681611b1a85611a23565b6001600160601b031660609190911b63ffffffff60601b161790565b87611b42600185612336565b81548110611b5257611b52612365565b90600052602060002090600291828204019190066010026101000a8154816001600160801b0302191690836001600160801b031602179055505050611beb565b505b85611baa611ba14361187d565b611b1a85611a23565b81546001818101845560009384526020909320600282040180546001600160801b03938416601093909516929092026101000a938402929093021916179055505b935093915050565b60006106c18284612336565b816001600160a01b0316836001600160a01b031614158015611c215750600081115b15610610576001600160a01b03831615611caf576001600160a01b03831660009081526008602052604081208190611c5c90611bf385611a97565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611ca4929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615610610576001600160a01b03821660009081526008602052604081208190611ce590611a8b85611a97565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611d2d929190918252602082015260400190565b60405180910390a25050505050565b6060611d4b8484600085611d53565b949350505050565b606082471015611db45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105f3565b843b611e025760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105f3565b600080866001600160a01b03168587604051611e1e91906125bb565b60006040518083038185875af1925050503d8060008114611e5b576040519150601f19603f3d011682016040523d82523d6000602084013e611e60565b606091505b5091509150611e70828286611e7b565b979650505050505050565b60608315611e8a5750816106c1565b825115611e9a5782518084602001fd5b8160405162461bcd60e51b81526004016105f39190611f0c565b60005b83811015611ecf578181015183820152602001611eb7565b838111156116f75750506000910152565b60008151808452611ef8816020860160208601611eb4565b601f01601f19169290920160200192915050565b6020815260006106c16020830184611ee0565b6001600160a01b038116811461085357600080fd5b60008060408385031215611f4757600080fd5b8235611f5281611f1f565b946020939093013593505050565b600080600060608486031215611f7557600080fd5b8335611f8081611f1f565b92506020840135611f9081611f1f565b929592945050506040919091013590565b600060208284031215611fb357600080fd5b5035919050565b600060208284031215611fcc57600080fd5b81356106c181611f1f565b803560ff81168114611fe857600080fd5b919050565b60008060008060008060c0878903121561200657600080fd5b863561201181611f1f565b9550602087013561202181611f1f565b94506040870135935061203660608801611fd7565b92506080870135915060a087013590509295509295509295565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561207b57600080fd5b833561208681611f1f565b925060208401359150604084013567ffffffffffffffff808211156120aa57600080fd5b818601915086601f8301126120be57600080fd5b8135818111156120d0576120d0612050565b604051601f8201601f19908116603f011681019083821181831017156120f8576120f8612050565b8160405282815289602084870101111561211157600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a03121561214e57600080fd5b873561215981611f1f565b9650602088013561216981611f1f565b9550604088013594506060880135935061218560808901611fd7565b925060a0880135915060c0880135905092959891949750929550565b600080604083850312156121b457600080fd5b82356121bf81611f1f565b915060208301356121cf81611f1f565b809150509250929050565b600080604083850312156121ed57600080fd5b82356121f881611f1f565b9150602083013563ffffffff811681146121cf57600080fd5b60008060008060006080868803121561222957600080fd5b853561223481611f1f565b9450602086013561224481611f1f565b935060408601359250606086013567ffffffffffffffff8082111561226857600080fd5b818801915088601f83011261227c57600080fd5b81358181111561228b57600080fd5b89602082850101111561229d57600080fd5b9699959850939650602001949392505050565b600181811c908216806122c457607f821691505b602082108114156122e557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561234857612348612320565b500390565b6000821982111561236057612360612320565b500190565b634e487b7160e01b600052603260045260246000fd5b6020808252601b908201527f496e76616c6964207369676e6174757265202773272076616c75650000000000604082015260600190565b6020808252601b908201527f496e76616c6964207369676e6174757265202776272076616c75650000000000604082015260600190565b60006000198214156123fd576123fd612320565b5060010190565b61190160f01b81526002810192909252602282015260420190565b602080825260119082015270496e76616c6964207369676e617475726560781b604082015260600190565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061247d90830184611ee0565b9695505050505050565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080835481600182811c9150808316806124f757607f831692505b602080841082141561251757634e487b7160e01b86526022600452602486fd5b81801561252b576001811461253c57612569565b60ff19861689528489019650612569565b60008a81526020902060005b868110156125615781548b820152908501908301612548565b505084890196505b509498975050505050505050565b60006020828403121561258957600080fd5b815180151581146106c157600080fd5b6000826125b657634e487b7160e01b600052601260045260246000fd5b500490565b600082516125cd818460208701611eb4565b919091019291505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212207eecbfb333a500c574d750bd13d9d3944c632e0e6cfefb9d5262bd9cbb14fb8364736f6c63430008090033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101bb5760003560e01c8063715018a6116100fa578063b20d7fa91161009d578063b20d7fa91461040b578063b4f94b2e1461041e578063cae9ca5114610445578063d505accf14610458578063dd62ed3e1461046b578063e7a324dc14610496578063f1127ed8146104bd578063f2fde38b146104fa578063fc4e51f61461050d57600080fd5b8063715018a614610380578063771da5c51461038857806379cc6790146103af5780638da5cb5b146103c25780638e539e8c146103ca57806395d89b41146103dd5780639ab24eb0146103e5578063a9059cbb146103f857600080fd5b80633a46b1a8116101625780633a46b1a81461028957806340c10f19146102b457806342966c68146102c7578063587cde1e146102da5780635c19a95c146103055780636fcfff451461031857806370a082311461034057806370ae92d21461036057600080fd5b806306fdde03146101c0578063095ea7b3146101de5780631171bda91461020157806318160ddd1461021657806323b872dd1461022d57806330adf81f14610240578063313ce567146102675780633644e51514610281575b600080fd5b6101c8610520565b6040516101d59190611f0c565b60405180910390f35b6101f16101ec366004611f34565b6105ae565b60405190151581526020016101d5565b61021461020f366004611f60565b6105c4565b005b61021f60045481565b6040519081526020016101d5565b6101f161023b366004611f60565b610615565b61021f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61026f601281565b60405160ff90911681526020016101d5565b61021f6106c8565b61029c610297366004611f34565b610724565b6040516001600160601b0390911681526020016101d5565b6102146102c2366004611f34565b610746565b6102146102d5366004611fa1565b610849565b6102ed6102e8366004611fba565b610856565b6040516001600160a01b0390911681526020016101d5565b610214610313366004611fba565b610874565b61032b610326366004611fba565b61087e565b60405163ffffffff90911681526020016101d5565b61021f61034e366004611fba565b60016020526000908152604090205481565b61021f61036e366004611fba565b60036020526000908152604090205481565b6102146108a6565b61021f7f000000000000000000000000000000000000000000000000000000000000000181565b6102146103bd366004611f34565b6108e1565b6102ed610977565b61029c6103d8366004611fa1565b610986565b6101c8610993565b61029c6103f3366004611fba565b6109a0565b6101f1610406366004611f34565b610a30565b610214610419366004611fed565b610a3d565b61021f7f5c4493b0bf56ef8418a7124d28ae7996587fb274a4ae420252de4801753d33e581565b6101f1610453366004612066565b610c6a565b610214610466366004612133565b610cf2565b61021f6104793660046121a1565b600260209081526000928352604080842090915290825290205481565b61021f7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e281565b6104d06104cb3660046121da565b610f2c565b60408051825163ffffffff1681526020928301516001600160601b031692810192909252016101d5565b610214610508366004611fba565b610fd8565b61021461051b366004612211565b611075565b6005805461052d906122b0565b80601f0160208091040260200160405190810160405280929190818152602001828054610559906122b0565b80156105a65780601f1061057b576101008083540402835291602001916105a6565b820191906000526020600020905b81548152906001019060200180831161058957829003601f168201915b505050505081565b60006105bb338484611106565b50600192915050565b336105cd610977565b6001600160a01b0316146105fc5760405162461bcd60e51b81526004016105f3906122eb565b60405180910390fd5b6106106001600160a01b0384168383611214565b505050565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001981146106b0578281101561069c5760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636044820152606560f81b60648201526084016105f3565b6106b085336106ab8685612336565b611106565b6106bb858585611266565b60019150505b9392505050565b60007f000000000000000000000000000000000000000000000000000000000000000146141561071757507f5c4493b0bf56ef8418a7124d28ae7996587fb274a4ae420252de4801753d33e590565b61071f611467565b905090565b6001600160a01b03821660009081526008602052604081206106c19083611516565b3361074f610977565b6001600160a01b0316146107755760405162461bcd60e51b81526004016105f3906122eb565b6001600160a01b0382166107c65760405162461bcd60e51b81526020600482015260186024820152774d696e7420746f20746865207a65726f206164647265737360401b60448201526064016105f3565b6107d260008383611611565b80600460008282546107e4919061234d565b90915550506001600160a01b0382166000908152600160205260408120805483929061081190849061234d565b90915550506040518181526001600160a01b038316906000906000805160206125d88339815191529060200160405180910390a35050565b61085333826116fd565b50565b6001600160a01b039081166000908152600760205260409020541690565b61085333826117db565b6001600160a01b0381166000908152600860205260408120546108a09061187d565b92915050565b336108af610977565b6001600160a01b0316146108d55760405162461bcd60e51b81526004016105f3906122eb565b6108df60006118e6565b565b6001600160a01b0382166000908152600260209081526040808320338452909152902054600019811461096d578181101561095e5760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e636500000060448201526064016105f3565b61096d83336106ab8585612336565b61061083836116fd565b6000546001600160a01b031690565b60006108a0600983611516565b6006805461052d906122b0565b6001600160a01b0381166000908152600860205260408120548015610a27576001600160a01b0383166000908152600860205260409020610a22906109e6600184612336565b815481106109f6576109f6612365565b90600052602060002090600291828204019190066010029054906101000a90046001600160801b031690565b6106c1565b60009392505050565b60006105bb338484611266565b42841015610a825760405162461bcd60e51b815260206004820152601260248201527111195b1959d85d1a5bdb88195e1c1a5c995960721b60448201526064016105f3565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b03811115610ab85760405162461bcd60e51b81526004016105f39061237b565b8260ff16601b1480610acd57508260ff16601c145b610ae95760405162461bcd60e51b81526004016105f3906123b2565b6000610af36106c8565b6001600160a01b038816600090815260036020526040812080547f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e2928a9290610b3b836123e9565b9190505588604051602001610b7294939291909384526001600160a01b039290921660208401526040830152606082015260800190565b60405160208183030381529060405280519060200120604051602001610b99929190612404565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610c04573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610c3a5750876001600160a01b0316816001600160a01b0316145b610c565760405162461bcd60e51b81526004016105f39061241f565b610c6088886117db565b5050505050505050565b6000610c7684846105ae565b15610ce857604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb190610cad90339087903090889060040161244a565b600060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b50505050600190506106c1565b5060009392505050565b42841015610d375760405162461bcd60e51b815260206004820152601260248201527114195c9b5a5cdcda5bdb88195e1c1a5c995960721b60448201526064016105f3565b6fa2a8918ca85bafe22016d0b997e4df60600160ff1b03811115610d6d5760405162461bcd60e51b81526004016105f39061237b565b8260ff16601b1480610d8257508260ff16601c145b610d9e5760405162461bcd60e51b81526004016105f3906123b2565b6000610da86106c8565b6001600160a01b038916600090815260036020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c92909190610df6836123e9565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610e59929190612404565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610ec4573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610efa5750886001600160a01b0316816001600160a01b0316145b610f165760405162461bcd60e51b81526004016105f39061241f565b610f21898989611106565b505050505050505050565b60408051808201909152600080825260208201526001600160a01b038316600090815260086020526040812080548291610fad9163ffffffff8716908110610f7657610f76612365565b90600052602060002090600291828204019190066010029054906101000a90046001600160801b031663ffffffff606082901c1691565b6040805180820190915263ffffffff90921682526001600160601b0316602082015295945050505050565b33610fe1610977565b6001600160a01b0316146110075760405162461bcd60e51b81526004016105f3906122eb565b6001600160a01b03811661106c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105f3565b610853816118e6565b3361107e610977565b6001600160a01b0316146110a45760405162461bcd60e51b81526004016105f3906122eb565b604051635c46a7ef60e11b81526001600160a01b0386169063b88d4fde906110d89030908890889088908890600401612487565b600060405180830381600087803b1580156110f257600080fd5b505af1158015610f21573d6000803e3d6000fd5b6001600160a01b03831661115c5760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f206164647265737300000060448201526064016105f3565b6001600160a01b0382166111b25760405162461bcd60e51b815260206004820152601b60248201527f417070726f766520746f20746865207a65726f2061646472657373000000000060448201526064016105f3565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610610908490611936565b6001600160a01b0383166112bc5760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f2061646472657373000060448201526064016105f3565b6001600160a01b0382166113125760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016105f3565b6001600160a01b03821630141561136b5760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e206164647265737300000060448201526064016105f3565b611376838383611611565b6001600160a01b038316600090815260016020526040902054818110156113df5760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e63650060448201526064016105f3565b6113e98282612336565b6001600160a01b03808616600090815260016020526040808220939093559085168152908120805484929061141f90849061234d565b92505081905550826001600160a01b0316846001600160a01b03166000805160206125d88339815191528460405161145991815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600560405161149991906124db565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60004382106115625760405162461bcd60e51b8152602060048201526018602482015277109b1bd8dac81b9bdd081e595d0819195d195c9b5a5b995960421b60448201526064016105f3565b825460005b818110156115eb57600061157b8284611a08565b905060006115be87838154811061159457611594612365565b6000918252602090912060028204015463ffffffff60019092166010026101000a900460601c1690565b9050858163ffffffff1611156115d6578193506115e4565b6115e182600161234d565b92505b5050611567565b811561160557611600856109e6600185612336565b611608565b60005b95945050505050565b600061161c82611a23565b90506001600160a01b0384166116ab576004546001600160601b039061164390849061234d565b11156116915760405162461bcd60e51b815260206004820152601d60248201527f4d6178696d756d20746f74616c20737570706c7920657863656564656400000060448201526064016105f3565b6116a86009611a8b836001600160601b0316611a97565b50505b6001600160a01b0383166116d3576116d06009611bf3836001600160601b0316611a97565b50505b6116f76116df85610856565b6116e885610856565b836001600160601b0316611bff565b50505050565b6001600160a01b038216600090815260016020526040902054818110156117665760405162461bcd60e51b815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016105f3565b61177283600084611611565b61177c8282612336565b6001600160a01b038416600090815260016020526040812091909155600480548492906117aa908490612336565b90915550506040518281526000906001600160a01b038516906000805160206125d883398151915290602001611207565b60006117e683610856565b6001600160a01b0384166000908152600160205260408120549192509061180c90611a23565b6001600160a01b0385811660008181526007602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46116f78284836001600160601b0316611bff565b600063ffffffff8211156118e25760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203360448201526532206269747360d01b60648201526084016105f3565b5090565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061198b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d3c9092919063ffffffff16565b80519091501561061057808060200190518101906119a99190612577565b6106105760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105f3565b6000611a176002848418612599565b6106c19084841661234d565b60006001600160601b038211156118e25760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203960448201526536206269747360d01b60648201526084016105f3565b60006106c1828461234d565b825460009081908015611ab857611ab3866109e6600184612336565b611abb565b60005b6001600160601b03169250611ad483858763ffffffff16565b91508015611b94576000611afd87611aed600185612336565b8154811061159457611594612365565b9050438163ffffffff161415611b9257611b3681611b1a85611a23565b6001600160601b031660609190911b63ffffffff60601b161790565b87611b42600185612336565b81548110611b5257611b52612365565b90600052602060002090600291828204019190066010026101000a8154816001600160801b0302191690836001600160801b031602179055505050611beb565b505b85611baa611ba14361187d565b611b1a85611a23565b81546001818101845560009384526020909320600282040180546001600160801b03938416601093909516929092026101000a938402929093021916179055505b935093915050565b60006106c18284612336565b816001600160a01b0316836001600160a01b031614158015611c215750600081115b15610610576001600160a01b03831615611caf576001600160a01b03831660009081526008602052604081208190611c5c90611bf385611a97565b91509150846001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611ca4929190918252602082015260400190565b60405180910390a250505b6001600160a01b03821615610610576001600160a01b03821660009081526008602052604081208190611ce590611a8b85611a97565b91509150836001600160a01b03167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051611d2d929190918252602082015260400190565b60405180910390a25050505050565b6060611d4b8484600085611d53565b949350505050565b606082471015611db45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105f3565b843b611e025760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105f3565b600080866001600160a01b03168587604051611e1e91906125bb565b60006040518083038185875af1925050503d8060008114611e5b576040519150601f19603f3d011682016040523d82523d6000602084013e611e60565b606091505b5091509150611e70828286611e7b565b979650505050505050565b60608315611e8a5750816106c1565b825115611e9a5782518084602001fd5b8160405162461bcd60e51b81526004016105f39190611f0c565b60005b83811015611ecf578181015183820152602001611eb7565b838111156116f75750506000910152565b60008151808452611ef8816020860160208601611eb4565b601f01601f19169290920160200192915050565b6020815260006106c16020830184611ee0565b6001600160a01b038116811461085357600080fd5b60008060408385031215611f4757600080fd5b8235611f5281611f1f565b946020939093013593505050565b600080600060608486031215611f7557600080fd5b8335611f8081611f1f565b92506020840135611f9081611f1f565b929592945050506040919091013590565b600060208284031215611fb357600080fd5b5035919050565b600060208284031215611fcc57600080fd5b81356106c181611f1f565b803560ff81168114611fe857600080fd5b919050565b60008060008060008060c0878903121561200657600080fd5b863561201181611f1f565b9550602087013561202181611f1f565b94506040870135935061203660608801611fd7565b92506080870135915060a087013590509295509295509295565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561207b57600080fd5b833561208681611f1f565b925060208401359150604084013567ffffffffffffffff808211156120aa57600080fd5b818601915086601f8301126120be57600080fd5b8135818111156120d0576120d0612050565b604051601f8201601f19908116603f011681019083821181831017156120f8576120f8612050565b8160405282815289602084870101111561211157600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a03121561214e57600080fd5b873561215981611f1f565b9650602088013561216981611f1f565b9550604088013594506060880135935061218560808901611fd7565b925060a0880135915060c0880135905092959891949750929550565b600080604083850312156121b457600080fd5b82356121bf81611f1f565b915060208301356121cf81611f1f565b809150509250929050565b600080604083850312156121ed57600080fd5b82356121f881611f1f565b9150602083013563ffffffff811681146121cf57600080fd5b60008060008060006080868803121561222957600080fd5b853561223481611f1f565b9450602086013561224481611f1f565b935060408601359250606086013567ffffffffffffffff8082111561226857600080fd5b818801915088601f83011261227c57600080fd5b81358181111561228b57600080fd5b89602082850101111561229d57600080fd5b9699959850939650602001949392505050565b600181811c908216806122c457607f821691505b602082108114156122e557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561234857612348612320565b500390565b6000821982111561236057612360612320565b500190565b634e487b7160e01b600052603260045260246000fd5b6020808252601b908201527f496e76616c6964207369676e6174757265202773272076616c75650000000000604082015260600190565b6020808252601b908201527f496e76616c6964207369676e6174757265202776272076616c75650000000000604082015260600190565b60006000198214156123fd576123fd612320565b5060010190565b61190160f01b81526002810192909252602282015260420190565b602080825260119082015270496e76616c6964207369676e617475726560781b604082015260600190565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061247d90830184611ee0565b9695505050505050565b6001600160a01b038681168252851660208201526040810184905260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080835481600182811c9150808316806124f757607f831692505b602080841082141561251757634e487b7160e01b86526022600452602486fd5b81801561252b576001811461253c57612569565b60ff19861689528489019650612569565b60008a81526020902060005b868110156125615781548b820152908501908301612548565b505084890196505b509498975050505050505050565b60006020828403121561258957600080fd5b815180151581146106c157600080fd5b6000826125b657634e487b7160e01b600052601260045260246000fd5b500490565b600082516125cd818460208701611eb4565b919091019291505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212207eecbfb333a500c574d750bd13d9d3944c632e0e6cfefb9d5262bd9cbb14fb8364736f6c63430008090033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

OVERVIEW

Threshold Network is the home of $tBTC v2, proxy re-encryption #PRE, $thUSD, and all threshold cryptography.

Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

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