Mumbai Testnet

Contract

0x7B006dfca781aee11b4A4E9f42c3239ECd4dcF39

Overview

MATIC Balance

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value

There are no matching entries

Please try again later

Latest 1 internal transaction

Parent Transaction Hash Block From To Value
256462872022-03-24 10:51:38797 days ago1648119098  Contract Creation0 MATIC
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
OpiumPositionToken

Compiler Version
v0.8.5+commit.a4f2e591

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 16 : OpiumPositionToken.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "../interfaces/IDerivativeLogic.sol";
import "../libs/LibDerivative.sol";
import "../libs/LibBokkyPooBahsDateTimeLibrary.sol";

/**
    Error codes:
    - P1 = ERROR_OPIUM_POSITION_TOKEN_NOT_FACTORY
 */

/// @title Opium.OpiumPositionToken is an ERC20PermitUpgradeable child contract created by the Opium.OpiumProxyFactory. It represents a specific position (either LONG or SHORT) for a given `LibDerivative.Derivative` derivative
contract OpiumPositionToken is ERC20PermitUpgradeable {
    using LibDerivative for LibDerivative.Derivative;

    /// It describes the derivative whose position (either LONG or SHORT) is being represented by the OpiumPositionToken
    struct OpiumPositionTokenParams {
        LibDerivative.Derivative derivative;
        LibDerivative.PositionType positionType;
        bytes32 derivativeHash;
    }

    address private factory;
    OpiumPositionTokenParams private opiumPositionTokenParams;

    /// @notice It is applied to all the stateful functions in OpiumPositionToken as they are meant to be consumed only via the OpiumProxyFactory
    modifier onlyFactory() {
        require(msg.sender == factory, "P1");
        _;
    }

    // ****************** EXTERNAL FUNCTIONS ******************

    // ***** SETTERS *****

    /// @notice `it is called only once upon deployment of the contract
    /// @dev it sets the state variables that are meant to be read-only and should be consumed by other contracts to retrieve information about the derivative
    /// @param _derivativeHash bytes32 hash of `LibDerivative.Derivative`
    /// @param _positionType  LibDerivative.PositionType _positionType describes whether the present ERC20 token is LONG or SHORT
    /// @param _derivative LibDerivative.Derivative Derivative definition
    function initialize(
        bytes32 _derivativeHash,
        LibDerivative.PositionType _positionType,
        LibDerivative.Derivative calldata _derivative
    ) external initializer {
        __ERC20_init("", "");
        __EIP712_init_unchained("Opium Position Token", "1");
        __ERC20Permit_init_unchained("");
        factory = msg.sender;
        opiumPositionTokenParams = OpiumPositionTokenParams({
            derivative: _derivative,
            positionType: _positionType,
            derivativeHash: _derivativeHash
        });
    }

    /// @notice it mints a specified amount of tokens to the given address
    /// @dev can only be called by the factory contract set in the `initialize` function
    /// @param _positionOwner address of the recipient of the position tokens
    /// @param _amount amount of position tokens to be minted to the _positionOwner
    function mint(address _positionOwner, uint256 _amount) external onlyFactory {
        _mint(_positionOwner, _amount);
    }

    /// @notice it burns a specified amount of tokens owned by the given address
    /// @dev can only be called by the factory contract set in the `initialize` function
    /// @param _positionOwner address of the owner of the position tokens
    /// @param _amount amount of position tokens to be burnt
    function burn(address _positionOwner, uint256 _amount) external onlyFactory {
        _burn(_positionOwner, _amount);
    }

    // ***** GETTERS *****

    /// @notice It retrieves the address of the factory contract set in the `initialize` function
    /// @return address of the factory contract (OpiumProxyFactory)
    function getFactoryAddress() external view returns (address) {
        return factory;
    }

    /// @notice It retrieves all the stored information about the underlying derivative
    /// @return _opiumPositionTokenParams OpiumPositionTokenParams struct which contains `LibDerivative.Derivative` schema of the derivative, the `LibDerivative.PositionType` of the present ERC20 token and the bytes32 hash `derivativeHash` of the `LibDerivative.Derivative` derivative
    function getPositionTokenData() external view returns (OpiumPositionTokenParams memory _opiumPositionTokenParams) {
        return opiumPositionTokenParams;
    }

    // ****************** PUBLIC FUNCTIONS ******************

    /**
     * @notice It overrides the OpenZeppelin name() getter and returns a custom erc20 name which is derived from the endTime of the erc20 token's associated derivative's maturity, the custom derivative name chosen by the derivative author and the derivative hash
     */
    function name() public view override returns (string memory) {
        string memory derivativeAuthorCustomName = IDerivativeLogic(opiumPositionTokenParams.derivative.syntheticId).getSyntheticIdName();
        string memory derivativeHashSlice = _toDerivativeHashStringIdentifier(opiumPositionTokenParams.derivativeHash);
        bytes memory endTimeDate = _toDerivativeEndTimeIdentifier(opiumPositionTokenParams.derivative.endTime);
        bytes memory baseCustomName = abi.encodePacked(
            "Opium:",
            endTimeDate,
            "-",
            derivativeAuthorCustomName,
            "-",
            derivativeHashSlice
        );
        return
            string(
                abi.encodePacked(
                    baseCustomName,
                    opiumPositionTokenParams.positionType == LibDerivative.PositionType.LONG ? "-LONG" : "-SHORT"
                )
            );
    }

    /**
     * @notice It overrides the OpenZeppelin symbol() getter and returns a custom erc20 symbol which is derived from the endTime of the erc20 token's associated derivative's maturity, the custom derivative name chosen by the derivative author and the derivative hash
     */
    function symbol() public view override returns (string memory) {
        string memory derivativeAuthorCustomName = IDerivativeLogic(opiumPositionTokenParams.derivative.syntheticId).getSyntheticIdName();
        string memory derivativeHashSlice = _toDerivativeHashStringIdentifier(opiumPositionTokenParams.derivativeHash);
        bytes memory endTimeDate = _toDerivativeEndTimeIdentifier(opiumPositionTokenParams.derivative.endTime);
        bytes memory customSymbol = abi.encodePacked(
            "OPIUM",
            "_",
            endTimeDate,
            "_",
            derivativeAuthorCustomName,
            "_",
            derivativeHashSlice
        );
        return
            string(
                abi.encodePacked(
                    customSymbol,
                    opiumPositionTokenParams.positionType == LibDerivative.PositionType.LONG ? "_L" : "_S"
                )
            );
    }

    // ****************** PRIVATE FUNCTIONS ******************

    /// @notice It is used to obtain a slice of derivativeHash and convert it to a string to be used as part of an Opium position token's name
    /// @param _data bytes32 representing a derivativeHash
    /// @return string representing the first 4 characters of a derivativeHash prefixed by "0x"
    function _toDerivativeHashStringIdentifier(bytes32 _data) private pure returns (string memory) {
        bytes4 result;
        assembly {
            result := or(
                and(
                    or(
                        shr(4, and(_data, 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000)),
                        shr(8, and(_data, 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00))
                    ),
                    0xffff000000000000000000000000000000000000000000000000000000000000
                ),
                shr(
                    16,
                    or(
                        shr(4, and(shl(8, _data), 0xF000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000)),
                        shr(8, and(shl(8, _data), 0x0F000F000F000F000F000F000F000F000F000F000F000F000F000F000F000F00))
                    )
                )
            )
        }

        return
            string(
                abi.encodePacked(
                    "0x",
                    bytes4(0x30303030 + uint32(result) + (((uint32(result) + 0x06060606) >> 4) & 0x0F0F0F0F) * 7)
                )
            );
    }

    /// @notice It is used to convert a derivative.endTime to a human-readable date to be used as part of an Opium position token's name
    /// @dev { See the third-party library ./libs/LibBokkyPooBahsDateTimeLibrary.sol }
    /// @param _derivativeEndTime uint256 representing the timestamp of a given derivative's maturity
    /// @return bytes representing the encoding of the derivativeEndTime converted to day-month-year in the format DD/MM/YYYY
    function _toDerivativeEndTimeIdentifier(uint256 _derivativeEndTime) private pure returns (bytes memory) {
        (uint256 year, uint256 month, uint256 day) = BokkyPooBahsDateTimeLibrary.timestampToDate(_derivativeEndTime);

        return
            abi.encodePacked(
                StringsUpgradeable.toString(year),
                month < 10
                    ? abi.encodePacked("0", StringsUpgradeable.toString(month))
                    : bytes(StringsUpgradeable.toString(month)),
                day < 10
                    ? abi.encodePacked("0", StringsUpgradeable.toString(day))
                    : bytes(StringsUpgradeable.toString(day))
            );
    }

    // Reserved storage space to allow for layout changes in the future.
    // The gaps left for the `OpiumPositionToken` are less than the slots allocated for the other upgradeable contracts in the protocol because the OpiumPositionToken is the only contract that is programmatically deployed (frequently), hence we want to minimize the gas cost
    uint256[30] private __gap;
}

File 2 of 16 : draft-ERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol)

pragma solidity ^0.8.0;

import "./draft-IERC20PermitUpgradeable.sol";
import "../ERC20Upgradeable.sol";
import "../../../utils/cryptography/draft-EIP712Upgradeable.sol";
import "../../../utils/cryptography/ECDSAUpgradeable.sol";
import "../../../utils/CountersUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * _Available since v3.4._
 */
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {
    using CountersUpgradeable for CountersUpgradeable.Counter;

    mapping(address => CountersUpgradeable.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private _PERMIT_TYPEHASH;

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

    function __ERC20Permit_init_unchained(string memory name) internal onlyInitializing {
        _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");}

    /**
     * @dev See {IERC20Permit-permit}.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

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

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSAUpgradeable.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @dev See {IERC20Permit-nonces}.
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

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

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        CountersUpgradeable.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
    uint256[49] private __gap;
}

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

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    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 2 of 16 : IDerivativeLogic.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

import "../libs/LibDerivative.sol";

/// @title Opium.Interface.IDerivativeLogic is an interface that every syntheticId should implement
interface IDerivativeLogic {
    // Event with syntheticId metadata JSON string (for DIB.ONE derivative explorer)
    event LogMetadataSet(string metadata);

    /// @notice Validates ticker
    /// @param _derivative Derivative Instance of derivative to validate
    /// @return Returns boolean whether ticker is valid
    function validateInput(LibDerivative.Derivative memory _derivative) external view returns (bool);

    /// @return Returns the custom name of a derivative ticker which will be used as part of the name of its positions
    function getSyntheticIdName() external view returns (string memory);

    /// @notice Calculates margin required for derivative creation
    /// @param _derivative Derivative Instance of derivative
    /// @return buyerMargin uint256 Margin needed from buyer (LONG position)
    /// @return sellerMargin uint256 Margin needed from seller (SHORT position)
    function getMargin(LibDerivative.Derivative memory _derivative)
        external
        view
        returns (uint256 buyerMargin, uint256 sellerMargin);

    /// @notice Calculates payout for derivative execution
    /// @param _derivative Derivative Instance of derivative
    /// @param _result uint256 Data retrieved from oracleId on the maturity
    /// @return buyerPayout uint256 Payout in ratio for buyer (LONG position holder)
    /// @return sellerPayout uint256 Payout in ratio for seller (SHORT position holder)
    function getExecutionPayout(LibDerivative.Derivative memory _derivative, uint256 _result)
        external
        view
        returns (uint256 buyerPayout, uint256 sellerPayout);

    /// @notice Returns syntheticId author address for Opium commissions
    /// @return authorAddress address The address of syntheticId address
    function getAuthorAddress() external view returns (address authorAddress);

    /// @notice Returns syntheticId author commission in base of COMMISSION_BASE
    /// @return commission uint256 Author commission
    function getAuthorCommission() external view returns (uint256 commission);

    /// @notice Returns whether thirdparty could execute on derivative's owner's behalf
    /// @param _derivativeOwner address Derivative owner address
    /// @return Returns boolean whether _derivativeOwner allowed third party execution
    function thirdpartyExecutionAllowed(address _derivativeOwner) external view returns (bool);

    /// @notice Sets whether thirds parties are allowed or not to execute derivative's on msg.sender's behalf
    /// @param _allow bool Flag for execution allowance
    function allowThirdpartyExecution(bool _allow) external;
}

File 2 of 16 : LibDerivative.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.5;

/// @title Opium.Lib.LibDerivative contract should be inherited by contracts that use Derivative structure and calculate derivativeHash
library LibDerivative {
    enum PositionType {
        SHORT,
        LONG
    }

    // Opium derivative structure (ticker) definition
    struct Derivative {
        // Margin parameter for syntheticId
        uint256 margin;
        // Maturity of derivative
        uint256 endTime;
        // Additional parameters for syntheticId
        uint256[] params;
        // oracleId of derivative
        address oracleId;
        // Margin token address of derivative
        address token;
        // syntheticId of derivative
        address syntheticId;
    }

    /// @notice Calculates hash of provided Derivative
    /// @param _derivative Derivative Instance of derivative to hash
    /// @return derivativeHash bytes32 Derivative hash
    function getDerivativeHash(Derivative memory _derivative) internal pure returns (bytes32 derivativeHash) {
        derivativeHash = keccak256(
            abi.encodePacked(
                _derivative.margin,
                _derivative.endTime,
                _derivative.params,
                _derivative.oracleId,
                _derivative.token,
                _derivative.syntheticId
            )
        );
    }
}

File 2 of 16 : LibBokkyPooBahsDateTimeLibrary.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.5;

// ----------------------------------------------------------------------------
// BokkyPooBah's DateTime Library v1.01
//
// A gas-efficient Solidity date and time library
//
// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
//
// Tested date range 1970/01/01 to 2345/12/31
//
// Conventions:
// Unit      | Range         | Notes
// :-------- |:-------------:|:-----
// timestamp | >= 0          | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC
// year      | 1970 ... 2345 |
// month     | 1 ... 12      |
// day       | 1 ... 31      |
// hour      | 0 ... 23      |
// minute    | 0 ... 59      |
// second    | 0 ... 59      |
// dayOfWeek | 1 ... 7       | 1 = Monday, ..., 7 = Sunday
//
//
// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------

// version v1.01
library BokkyPooBahsDateTimeLibrary {
    uint256 constant SECONDS_PER_DAY = 24 * 60 * 60;
    int256 constant OFFSET19700101 = 2440588;

    // ------------------------------------------------------------------------
    // Calculate year/month/day from the number of days since 1970/01/01 using
    // the date conversion algorithm from
    //   http://aa.usno.navy.mil/faq/docs/JD_Formula.php
    // and adding the offset 2440588 so that 1970/01/01 is day 0
    //
    // int L = days + 68569 + offset
    // int N = 4 * L / 146097
    // L = L - (146097 * N + 3) / 4
    // year = 4000 * (L + 1) / 1461001
    // L = L - 1461 * year / 4 + 31
    // month = 80 * L / 2447
    // dd = L - 2447 * month / 80
    // L = month / 11
    // month = month + 2 - 12 * L
    // year = 100 * (N - 49) + year + L
    // ------------------------------------------------------------------------
    function _daysToDate(uint256 _days)
        internal
        pure
        returns (
            uint256 year,
            uint256 month,
            uint256 day
        )
    {
        int256 __days = int256(_days);

        int256 L = __days + 68569 + OFFSET19700101;
        int256 N = (4 * L) / 146097;
        L = L - (146097 * N + 3) / 4;
        int256 _year = (4000 * (L + 1)) / 1461001;
        L = L - (1461 * _year) / 4 + 31;
        int256 _month = (80 * L) / 2447;
        int256 _day = L - (2447 * _month) / 80;
        L = _month / 11;
        _month = _month + 2 - 12 * L;
        _year = 100 * (N - 49) + _year + L;

        year = uint256(_year);
        month = uint256(_month);
        day = uint256(_day);
    }

    function timestampToDate(uint256 timestamp)
        internal
        pure
        returns (
            uint256 year,
            uint256 month,
            uint256 day
        )
    {
        (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

File 2 of 16 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

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

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

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712Upgradeable is Initializable {
    /* solhint-disable var-name-mixedcase */
    bytes32 private _HASHED_NAME;
    bytes32 private _HASHED_VERSION;
    bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

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

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

    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

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

    /**
     * @dev The hash of the name parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712NameHash() internal virtual view returns (bytes32) {
        return _HASHED_NAME;
    }

    /**
     * @dev The hash of the version parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712VersionHash() internal virtual view returns (bytes32) {
        return _HASHED_VERSION;
    }
    uint256[50] private __gap;
}

File 2 of 16 : ECDSAUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../StringsUpgradeable.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 ECDSAUpgradeable {
    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", StringsUpgradeable.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 2 of 16 : CountersUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 2 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 2 of 16 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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 2 of 16 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

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

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

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

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

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

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

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 2 of 16 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    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 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);
            }
        }
    }
}

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

Contract ABI

[{"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":"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":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","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":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_positionOwner","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getFactoryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPositionTokenData","outputs":[{"components":[{"components":[{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256[]","name":"params","type":"uint256[]"},{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"syntheticId","type":"address"}],"internalType":"struct LibDerivative.Derivative","name":"derivative","type":"tuple"},{"internalType":"enum LibDerivative.PositionType","name":"positionType","type":"uint8"},{"internalType":"bytes32","name":"derivativeHash","type":"bytes32"}],"internalType":"struct OpiumPositionToken.OpiumPositionTokenParams","name":"_opiumPositionTokenParams","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_derivativeHash","type":"bytes32"},{"internalType":"enum LibDerivative.PositionType","name":"_positionType","type":"uint8"},{"components":[{"internalType":"uint256","name":"margin","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256[]","name":"params","type":"uint256[]"},{"internalType":"address","name":"oracleId","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"syntheticId","type":"address"}],"internalType":"struct LibDerivative.Derivative","name":"_derivative","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_positionOwner","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":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","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":[],"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":"sender","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"}]

608060405234801561001057600080fd5b506127a8806100206000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c806372d6d1b9116100cd578063a9059cbb11610081578063ce21286d11610066578063ce21286d146102a6578063d505accf146102bb578063dd62ed3e146102ce57600080fd5b8063a9059cbb14610278578063a9c2e36c1461028b57600080fd5b806395d89b41116100b257806395d89b411461024a5780639dc29fac14610252578063a457c2d71461026557600080fd5b806372d6d1b9146102245780637ecebe001461023757600080fd5b8063313ce56711610124578063395093511161010957806339509351146101d357806340c10f19146101e657806370a08231146101fb57600080fd5b8063313ce567146101bc5780633644e515146101cb57600080fd5b806306fdde0314610156578063095ea7b31461017457806318160ddd1461019757806323b872dd146101a9575b600080fd5b61015e610307565b60405161016b9190612265565b60405180910390f35b610187610182366004611f85565b610496565b604051901515815260200161016b565b6035545b60405190815260200161016b565b6101876101b7366004611ed6565b6104ac565b6040516012815260200161016b565b61019b610570565b6101876101e1366004611f85565b61057f565b6101f96101f4366004611f85565b6105bb565b005b61019b610209366004611e81565b6001600160a01b031660009081526033602052604090205490565b6101f9610232366004611faf565b610608565b61019b610245366004611e81565b61087c565b61015e61089c565b6101f9610260366004611f85565b6109dc565b610187610273366004611f85565b610a25565b610187610286366004611f85565b610ad6565b60cc546040516001600160a01b03909116815260200161016b565b6102ae610ae3565b60405161016b9190612298565b6101f96102c9366004611f12565b610c1b565b61019b6102dc366004611ea3565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60d254604080516307ac921760e31b815290516060926000926001600160a01b0390911691633d6490b8916004808201928692909190829003018186803b15801561035157600080fd5b505afa158015610365573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261038d9190810190612013565b9050600061039f60cd60070154610d61565b60ce549091506000906103b190610e6f565b905060008184846040516020016103ca93929190612164565b60408051601f19818403018152919052905080600160d35460ff1660018111156103f6576103f6612730565b14610436576040518060400160405280600681526020017f2d53484f5254000000000000000000000000000000000000000000000000000081525061046d565b6040518060400160405280600581526020017f2d4c4f4e470000000000000000000000000000000000000000000000000000008152505b60405160200161047e9291906120c9565b60405160208183030381529060405294505050505090565b60006104a3338484610f37565b50600192915050565b60006104b984848461105c565b6001600160a01b0384166000908152603460209081526040808320338452909152902054828110156105585760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6105658533858403610f37565b506001949350505050565b600061057a611259565b905090565b3360008181526034602090815260408083206001600160a01b038716845290915281205490916104a39185906105b69086906123f5565b610f37565b60cc546001600160a01b031633146105fa5760405162461bcd60e51b8152602060048201526002602482015261503160f01b604482015260640161054f565b61060482826112d4565b5050565b600054610100900460ff166106235760005460ff1615610627565b303b155b6106995760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161054f565b600054610100900460ff161580156106bb576000805461ffff19166101011790555b6106e360405180602001604052806000815250604051806020016040528060008152506113b3565b61073b6040518060400160405280601481526020017f4f7069756d20506f736974696f6e20546f6b656e000000000000000000000000815250604051806040016040528060018152602001603160f81b815250611430565b610753604051806020016040528060008152506114b5565b60cc805473ffffffffffffffffffffffffffffffffffffffff19163317905560408051606081019091528061078784612577565b815260200184600181111561079e5761079e612730565b815260209081018690528151805160cd9081558183015160ce5560408201518051919384926107d19260cf920190611d92565b50606082015160038201805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03938416179091556080840151600484018054831691841691909117905560a090930151600590920180549093169116179055602082015160068201805460ff19166001838181111561085257610852612730565b0217905550604082015181600701559050508015610876576000805461ff00191690555b50505050565b6001600160a01b0381166000908152609960205260408120545b92915050565b60d254604080516307ac921760e31b815290516060926000926001600160a01b0390911691633d6490b8916004808201928692909190829003018186803b1580156108e657600080fd5b505afa1580156108fa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109229190810190612013565b9050600061093460cd60070154610d61565b60ce5490915060009061094690610e6f565b9050600081848460405160200161095f939291906121e7565b60408051601f19818403018152919052905080600160d35460ff16600181111561098b5761098b612730565b146109b057604051806040016040528060028152602001615f5360f01b81525061046d565b6040518060400160405280600281526020016117d360f21b81525060405160200161047e9291906120c9565b60cc546001600160a01b03163314610a1b5760405162461bcd60e51b8152602060048201526002602482015261503160f01b604482015260640161054f565b6106048282611547565b3360009081526034602090815260408083206001600160a01b038616845290915281205482811015610abf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161054f565b610acc3385858403610f37565b5060019392505050565b60006104a333848461105c565b6040805161012081018252600060608083018281526080840183905260a084019190915260c0830182905260e08301829052610100830182905282526020820181905291810191909152604080516101208101825260cd80546060830190815260ce54608084015260cf80548551602082810282018101909752818152949593948694869360a08701939091830182828015610b9e57602002820191906000526020600020905b815481526020019060010190808311610b8a575b505050918352505060038201546001600160a01b0390811660208084019190915260048401548216604084015260059093015416606090910152908252600683015491019060ff166001811115610bf757610bf7612730565b6001811115610c0857610c08612730565b8152602001600782015481525050905090565b83421115610c6b5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161054f565b6000609a54888888610c7c8c611692565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610cd7826116ba565b90506000610ce782878787611708565b9050896001600160a01b0316816001600160a01b031614610d4a5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161054f565b610d558a8a8a610f37565b50505050505050505050565b6060600f60f81b600483811c91909116600f60f01b600885901c161783821b7f0f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f00167e0f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f85161760101c1790610ddc60e083901c630606060661240d565b63ffffffff16901c630f0f0f0f166007610df691906124f5565b610e0860e083901c633030303061240d565b610e12919061240d565b60e01b604051602001610e58919061060f60f31b81527fffffffff0000000000000000000000000000000000000000000000000000000091909116600282015260060190565b604051602081830303815290604052915050919050565b60606000806000610e7f85611730565b925092509250610e8e83611756565b600a8310610ea457610e9f83611756565b610ecd565b610ead83611756565b604051602001610ebd919061213b565b6040516020818303038152906040525b600a8310610ee357610ede83611756565b610f0c565b610eec83611756565b604051602001610efc919061213b565b6040516020818303038152906040525b604051602001610f1e939291906120f8565b6040516020818303038152906040529350505050919050565b6001600160a01b038316610f995760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161054f565b6001600160a01b038216610ffa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161054f565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166110d85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161054f565b6001600160a01b03821661113a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161054f565b6001600160a01b038316600090815260336020526040902054818110156111c95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161054f565b6001600160a01b038085166000908152603360205260408082208585039055918516815290812080548492906112009084906123f5565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161124c91815260200190565b60405180910390a3610876565b600061057a7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61128860655490565b6066546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b6001600160a01b03821661132a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161054f565b806035600082825461133c91906123f5565b90915550506001600160a01b038216600090815260336020526040812080548392906113699084906123f5565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600054610100900460ff1661141e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b611426611874565b61060482826118e1565b600054610100900460ff1661149b5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b815160209283012081519190920120606591909155606655565b600054610100900460ff166115205760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9609a55565b6001600160a01b0382166115a75760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161054f565b6001600160a01b0382166000908152603360205260409020548181101561161b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161054f565b6001600160a01b038316600090815260336020526040812083830390556035805484929061164a908490612560565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161104f565b505050565b6001600160a01b03811660009081526099602052604090208054600181018255905b50919050565b60006108966116c7611259565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061171987878787611973565b9150915061172681611a60565b5095945050505050565b60008080611749611744620151808661245a565b611c1e565b9196909550909350915050565b60608161177a5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156117a4578061178e816126d5565b915061179d9050600a8361245a565b915061177e565b60008167ffffffffffffffff8111156117bf576117bf61275c565b6040519080825280601f01601f1916602001820160405280156117e9576020820181803683370190505b5090505b841561186c576117fe600183612560565b915061180b600a866126f0565b6118169060306123f5565b60f81b81838151811061182b5761182b612746565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611865600a8661245a565b94506117ed565b949350505050565b600054610100900460ff166118df5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b565b600054610100900460ff1661194c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b815161195f906036906020850190611ddd565b50805161168d906037906020840190611ddd565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156119aa5750600090506003611a57565b8460ff16601b141580156119c257508460ff16601c14155b156119d35750600090506004611a57565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611a27573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611a5057600060019250925050611a57565b9150600090505b94509492505050565b6000816004811115611a7457611a74612730565b1415611a7d5750565b6001816004811115611a9157611a91612730565b1415611adf5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161054f565b6002816004811115611af357611af3612730565b1415611b415760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161054f565b6003816004811115611b5557611b55612730565b1415611bae5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161054f565b6004816004811115611bc257611bc2612730565b1415611c1b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161054f565b50565b60008080838162253d8c611c358362010bd96123b5565b611c3f91906123b5565b9050600062023ab1611c5283600461246e565b611c5c919061242c565b90506004611c6d8262023ab161246e565b611c789060036123b5565b611c82919061242c565b611c8c9083612521565b9150600062164b09611c9f8460016123b5565b611cab90610fa061246e565b611cb5919061242c565b90506004611cc5826105b561246e565b611ccf919061242c565b611cd99084612521565b611ce490601f6123b5565b9250600061098f611cf685605061246e565b611d00919061242c565b905060006050611d128361098f61246e565b611d1c919061242c565b611d269086612521565b9050611d33600b8361242c565b9450611d4085600c61246e565b611d4b8360026123b5565b611d559190612521565b91508483611d64603187612521565b611d6f90606461246e565b611d7991906123b5565b611d8391906123b5565b9a919950975095505050505050565b828054828255906000526020600020908101928215611dcd579160200282015b82811115611dcd578251825591602001919060010190611db2565b50611dd9929150611e50565b5090565b828054611de9906126a0565b90600052602060002090601f016020900481019282611e0b5760008555611dcd565b82601f10611e2457805160ff1916838001178555611dcd565b82800160010185558215611dcd5791820182811115611dcd578251825591602001919060010190611db2565b5b80821115611dd95760008155600101611e51565b80356001600160a01b0381168114611e7c57600080fd5b919050565b600060208284031215611e9357600080fd5b611e9c82611e65565b9392505050565b60008060408385031215611eb657600080fd5b611ebf83611e65565b9150611ecd60208401611e65565b90509250929050565b600080600060608486031215611eeb57600080fd5b611ef484611e65565b9250611f0260208501611e65565b9150604084013590509250925092565b600080600080600080600060e0888a031215611f2d57600080fd5b611f3688611e65565b9650611f4460208901611e65565b95506040880135945060608801359350608088013560ff81168114611f6857600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611f9857600080fd5b611fa183611e65565b946020939093013593505050565b600080600060608486031215611fc457600080fd5b83359250602084013560028110611fda57600080fd5b9150604084013567ffffffffffffffff811115611ff657600080fd5b840160c0818703121561200857600080fd5b809150509250925092565b60006020828403121561202557600080fd5b815167ffffffffffffffff8082111561203d57600080fd5b818401915084601f83011261205157600080fd5b8151818111156120635761206361275c565b612076601f8201601f1916602001612384565b915080825285602082850101111561208d57600080fd5b61209e816020840160208601612674565b50949350505050565b600281106120c557634e487b7160e01b600052602160045260246000fd5b9052565b600083516120db818460208801612674565b8351908301906120ef818360208801612674565b01949350505050565b6000845161210a818460208901612674565b84519083019061211e818360208901612674565b8451910190612131818360208801612674565b0195945050505050565b600360fc1b815260008251612157816001850160208701612674565b9190910160010192915050565b7f4f7069756d3a000000000000000000000000000000000000000000000000000081526000845161219c816006850160208901612674565b8083019050602d60f81b80600683015285516121bf816007850160208a01612674565b600792019182015283516121da816008840160208801612674565b0160080195945050505050565b7f4f5049554d00000000000000000000000000000000000000000000000000000081526000605f60f81b806005840152855161222a816006860160208a01612674565b80840190508160068201528551612248816007840160208a01612674565b0160078101919091528351906121da826008830160208801612674565b6020815260008251806020840152612284816040850160208701612674565b601f01601f19169190910160400192915050565b60208082528251606083830152805160808401528082015160a0840152604081015160c08085015280516101408501819052600093929183019084906101608701905b808310156122fb57835182529285019260019290920191908501906122db565b5060608401516001600160a01b0390811660e089015260808501518082166101008a015260a090950151908116610120890152939250938701519361234360408801866120a7565b60408801516060880152809550505050505092915050565b60405160c0810167ffffffffffffffff8111828210171561237e5761237e61275c565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156123ad576123ad61275c565b604052919050565b6000808212826001600160ff1b03038413811516156123d6576123d6612704565b600160ff1b83900384128116156123ef576123ef612704565b50500190565b6000821982111561240857612408612704565b500190565b600063ffffffff8083168185168083038211156120ef576120ef612704565b60008261243b5761243b61271a565b600160ff1b82146000198414161561245557612455612704565b500590565b6000826124695761246961271a565b500490565b60006001600160ff1b0360008413600084138583048511828216161561249657612496612704565b600160ff1b60008712828116878305891216156124b5576124b5612704565b600087129250878205871284841616156124d1576124d1612704565b878505871281841616156124e7576124e7612704565b505050929093029392505050565b600063ffffffff8083168185168183048111821515161561251857612518612704565b02949350505050565b60008083128015600160ff1b85018412161561253f5761253f612704565b836001600160ff1b0301831381161561255a5761255a612704565b50500390565b60008282101561257257612572612704565b500390565b600060c0823603121561258957600080fd5b61259161235b565b8235815260208084013581830152604084013567ffffffffffffffff808211156125ba57600080fd5b9085019036601f8301126125cd57600080fd5b8135818111156125df576125df61275c565b8060051b91506125f0848301612384565b81815284810190848601368587018801111561260b57600080fd5b600095505b8386101561262e578035835260019590950194918601918601612610565b5080604088015250505050505061264760608401611e65565b606082015261265860808401611e65565b608082015261266960a08401611e65565b60a082015292915050565b60005b8381101561268f578181015183820152602001612677565b838111156108765750506000910152565b600181811c908216806126b457607f821691505b602082108114156116b457634e487b7160e01b600052602260045260246000fd5b60006000198214156126e9576126e9612704565b5060010190565b6000826126ff576126ff61271a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220d013804a35b6569a79e1c51da50e3c7627c6c41797383926a7a7f6e21d13efe864736f6c63430008050033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101515760003560e01c806372d6d1b9116100cd578063a9059cbb11610081578063ce21286d11610066578063ce21286d146102a6578063d505accf146102bb578063dd62ed3e146102ce57600080fd5b8063a9059cbb14610278578063a9c2e36c1461028b57600080fd5b806395d89b41116100b257806395d89b411461024a5780639dc29fac14610252578063a457c2d71461026557600080fd5b806372d6d1b9146102245780637ecebe001461023757600080fd5b8063313ce56711610124578063395093511161010957806339509351146101d357806340c10f19146101e657806370a08231146101fb57600080fd5b8063313ce567146101bc5780633644e515146101cb57600080fd5b806306fdde0314610156578063095ea7b31461017457806318160ddd1461019757806323b872dd146101a9575b600080fd5b61015e610307565b60405161016b9190612265565b60405180910390f35b610187610182366004611f85565b610496565b604051901515815260200161016b565b6035545b60405190815260200161016b565b6101876101b7366004611ed6565b6104ac565b6040516012815260200161016b565b61019b610570565b6101876101e1366004611f85565b61057f565b6101f96101f4366004611f85565b6105bb565b005b61019b610209366004611e81565b6001600160a01b031660009081526033602052604090205490565b6101f9610232366004611faf565b610608565b61019b610245366004611e81565b61087c565b61015e61089c565b6101f9610260366004611f85565b6109dc565b610187610273366004611f85565b610a25565b610187610286366004611f85565b610ad6565b60cc546040516001600160a01b03909116815260200161016b565b6102ae610ae3565b60405161016b9190612298565b6101f96102c9366004611f12565b610c1b565b61019b6102dc366004611ea3565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b60d254604080516307ac921760e31b815290516060926000926001600160a01b0390911691633d6490b8916004808201928692909190829003018186803b15801561035157600080fd5b505afa158015610365573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261038d9190810190612013565b9050600061039f60cd60070154610d61565b60ce549091506000906103b190610e6f565b905060008184846040516020016103ca93929190612164565b60408051601f19818403018152919052905080600160d35460ff1660018111156103f6576103f6612730565b14610436576040518060400160405280600681526020017f2d53484f5254000000000000000000000000000000000000000000000000000081525061046d565b6040518060400160405280600581526020017f2d4c4f4e470000000000000000000000000000000000000000000000000000008152505b60405160200161047e9291906120c9565b60405160208183030381529060405294505050505090565b60006104a3338484610f37565b50600192915050565b60006104b984848461105c565b6001600160a01b0384166000908152603460209081526040808320338452909152902054828110156105585760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6105658533858403610f37565b506001949350505050565b600061057a611259565b905090565b3360008181526034602090815260408083206001600160a01b038716845290915281205490916104a39185906105b69086906123f5565b610f37565b60cc546001600160a01b031633146105fa5760405162461bcd60e51b8152602060048201526002602482015261503160f01b604482015260640161054f565b61060482826112d4565b5050565b600054610100900460ff166106235760005460ff1615610627565b303b155b6106995760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161054f565b600054610100900460ff161580156106bb576000805461ffff19166101011790555b6106e360405180602001604052806000815250604051806020016040528060008152506113b3565b61073b6040518060400160405280601481526020017f4f7069756d20506f736974696f6e20546f6b656e000000000000000000000000815250604051806040016040528060018152602001603160f81b815250611430565b610753604051806020016040528060008152506114b5565b60cc805473ffffffffffffffffffffffffffffffffffffffff19163317905560408051606081019091528061078784612577565b815260200184600181111561079e5761079e612730565b815260209081018690528151805160cd9081558183015160ce5560408201518051919384926107d19260cf920190611d92565b50606082015160038201805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03938416179091556080840151600484018054831691841691909117905560a090930151600590920180549093169116179055602082015160068201805460ff19166001838181111561085257610852612730565b0217905550604082015181600701559050508015610876576000805461ff00191690555b50505050565b6001600160a01b0381166000908152609960205260408120545b92915050565b60d254604080516307ac921760e31b815290516060926000926001600160a01b0390911691633d6490b8916004808201928692909190829003018186803b1580156108e657600080fd5b505afa1580156108fa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109229190810190612013565b9050600061093460cd60070154610d61565b60ce5490915060009061094690610e6f565b9050600081848460405160200161095f939291906121e7565b60408051601f19818403018152919052905080600160d35460ff16600181111561098b5761098b612730565b146109b057604051806040016040528060028152602001615f5360f01b81525061046d565b6040518060400160405280600281526020016117d360f21b81525060405160200161047e9291906120c9565b60cc546001600160a01b03163314610a1b5760405162461bcd60e51b8152602060048201526002602482015261503160f01b604482015260640161054f565b6106048282611547565b3360009081526034602090815260408083206001600160a01b038616845290915281205482811015610abf5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161054f565b610acc3385858403610f37565b5060019392505050565b60006104a333848461105c565b6040805161012081018252600060608083018281526080840183905260a084019190915260c0830182905260e08301829052610100830182905282526020820181905291810191909152604080516101208101825260cd80546060830190815260ce54608084015260cf80548551602082810282018101909752818152949593948694869360a08701939091830182828015610b9e57602002820191906000526020600020905b815481526020019060010190808311610b8a575b505050918352505060038201546001600160a01b0390811660208084019190915260048401548216604084015260059093015416606090910152908252600683015491019060ff166001811115610bf757610bf7612730565b6001811115610c0857610c08612730565b8152602001600782015481525050905090565b83421115610c6b5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640161054f565b6000609a54888888610c7c8c611692565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610cd7826116ba565b90506000610ce782878787611708565b9050896001600160a01b0316816001600160a01b031614610d4a5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640161054f565b610d558a8a8a610f37565b50505050505050505050565b6060600f60f81b600483811c91909116600f60f01b600885901c161783821b7f0f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f00167e0f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f85161760101c1790610ddc60e083901c630606060661240d565b63ffffffff16901c630f0f0f0f166007610df691906124f5565b610e0860e083901c633030303061240d565b610e12919061240d565b60e01b604051602001610e58919061060f60f31b81527fffffffff0000000000000000000000000000000000000000000000000000000091909116600282015260060190565b604051602081830303815290604052915050919050565b60606000806000610e7f85611730565b925092509250610e8e83611756565b600a8310610ea457610e9f83611756565b610ecd565b610ead83611756565b604051602001610ebd919061213b565b6040516020818303038152906040525b600a8310610ee357610ede83611756565b610f0c565b610eec83611756565b604051602001610efc919061213b565b6040516020818303038152906040525b604051602001610f1e939291906120f8565b6040516020818303038152906040529350505050919050565b6001600160a01b038316610f995760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161054f565b6001600160a01b038216610ffa5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161054f565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166110d85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161054f565b6001600160a01b03821661113a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161054f565b6001600160a01b038316600090815260336020526040902054818110156111c95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161054f565b6001600160a01b038085166000908152603360205260408082208585039055918516815290812080548492906112009084906123f5565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161124c91815260200190565b60405180910390a3610876565b600061057a7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61128860655490565b6066546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b6001600160a01b03821661132a5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161054f565b806035600082825461133c91906123f5565b90915550506001600160a01b038216600090815260336020526040812080548392906113699084906123f5565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600054610100900460ff1661141e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b611426611874565b61060482826118e1565b600054610100900460ff1661149b5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b815160209283012081519190920120606591909155606655565b600054610100900460ff166115205760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9609a55565b6001600160a01b0382166115a75760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161054f565b6001600160a01b0382166000908152603360205260409020548181101561161b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161054f565b6001600160a01b038316600090815260336020526040812083830390556035805484929061164a908490612560565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200161104f565b505050565b6001600160a01b03811660009081526099602052604090208054600181018255905b50919050565b60006108966116c7611259565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061171987878787611973565b9150915061172681611a60565b5095945050505050565b60008080611749611744620151808661245a565b611c1e565b9196909550909350915050565b60608161177a5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156117a4578061178e816126d5565b915061179d9050600a8361245a565b915061177e565b60008167ffffffffffffffff8111156117bf576117bf61275c565b6040519080825280601f01601f1916602001820160405280156117e9576020820181803683370190505b5090505b841561186c576117fe600183612560565b915061180b600a866126f0565b6118169060306123f5565b60f81b81838151811061182b5761182b612746565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611865600a8661245a565b94506117ed565b949350505050565b600054610100900460ff166118df5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b565b600054610100900460ff1661194c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161054f565b815161195f906036906020850190611ddd565b50805161168d906037906020840190611ddd565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156119aa5750600090506003611a57565b8460ff16601b141580156119c257508460ff16601c14155b156119d35750600090506004611a57565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611a27573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611a5057600060019250925050611a57565b9150600090505b94509492505050565b6000816004811115611a7457611a74612730565b1415611a7d5750565b6001816004811115611a9157611a91612730565b1415611adf5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161054f565b6002816004811115611af357611af3612730565b1415611b415760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161054f565b6003816004811115611b5557611b55612730565b1415611bae5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161054f565b6004816004811115611bc257611bc2612730565b1415611c1b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161054f565b50565b60008080838162253d8c611c358362010bd96123b5565b611c3f91906123b5565b9050600062023ab1611c5283600461246e565b611c5c919061242c565b90506004611c6d8262023ab161246e565b611c789060036123b5565b611c82919061242c565b611c8c9083612521565b9150600062164b09611c9f8460016123b5565b611cab90610fa061246e565b611cb5919061242c565b90506004611cc5826105b561246e565b611ccf919061242c565b611cd99084612521565b611ce490601f6123b5565b9250600061098f611cf685605061246e565b611d00919061242c565b905060006050611d128361098f61246e565b611d1c919061242c565b611d269086612521565b9050611d33600b8361242c565b9450611d4085600c61246e565b611d4b8360026123b5565b611d559190612521565b91508483611d64603187612521565b611d6f90606461246e565b611d7991906123b5565b611d8391906123b5565b9a919950975095505050505050565b828054828255906000526020600020908101928215611dcd579160200282015b82811115611dcd578251825591602001919060010190611db2565b50611dd9929150611e50565b5090565b828054611de9906126a0565b90600052602060002090601f016020900481019282611e0b5760008555611dcd565b82601f10611e2457805160ff1916838001178555611dcd565b82800160010185558215611dcd5791820182811115611dcd578251825591602001919060010190611db2565b5b80821115611dd95760008155600101611e51565b80356001600160a01b0381168114611e7c57600080fd5b919050565b600060208284031215611e9357600080fd5b611e9c82611e65565b9392505050565b60008060408385031215611eb657600080fd5b611ebf83611e65565b9150611ecd60208401611e65565b90509250929050565b600080600060608486031215611eeb57600080fd5b611ef484611e65565b9250611f0260208501611e65565b9150604084013590509250925092565b600080600080600080600060e0888a031215611f2d57600080fd5b611f3688611e65565b9650611f4460208901611e65565b95506040880135945060608801359350608088013560ff81168114611f6857600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611f9857600080fd5b611fa183611e65565b946020939093013593505050565b600080600060608486031215611fc457600080fd5b83359250602084013560028110611fda57600080fd5b9150604084013567ffffffffffffffff811115611ff657600080fd5b840160c0818703121561200857600080fd5b809150509250925092565b60006020828403121561202557600080fd5b815167ffffffffffffffff8082111561203d57600080fd5b818401915084601f83011261205157600080fd5b8151818111156120635761206361275c565b612076601f8201601f1916602001612384565b915080825285602082850101111561208d57600080fd5b61209e816020840160208601612674565b50949350505050565b600281106120c557634e487b7160e01b600052602160045260246000fd5b9052565b600083516120db818460208801612674565b8351908301906120ef818360208801612674565b01949350505050565b6000845161210a818460208901612674565b84519083019061211e818360208901612674565b8451910190612131818360208801612674565b0195945050505050565b600360fc1b815260008251612157816001850160208701612674565b9190910160010192915050565b7f4f7069756d3a000000000000000000000000000000000000000000000000000081526000845161219c816006850160208901612674565b8083019050602d60f81b80600683015285516121bf816007850160208a01612674565b600792019182015283516121da816008840160208801612674565b0160080195945050505050565b7f4f5049554d00000000000000000000000000000000000000000000000000000081526000605f60f81b806005840152855161222a816006860160208a01612674565b80840190508160068201528551612248816007840160208a01612674565b0160078101919091528351906121da826008830160208801612674565b6020815260008251806020840152612284816040850160208701612674565b601f01601f19169190910160400192915050565b60208082528251606083830152805160808401528082015160a0840152604081015160c08085015280516101408501819052600093929183019084906101608701905b808310156122fb57835182529285019260019290920191908501906122db565b5060608401516001600160a01b0390811660e089015260808501518082166101008a015260a090950151908116610120890152939250938701519361234360408801866120a7565b60408801516060880152809550505050505092915050565b60405160c0810167ffffffffffffffff8111828210171561237e5761237e61275c565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156123ad576123ad61275c565b604052919050565b6000808212826001600160ff1b03038413811516156123d6576123d6612704565b600160ff1b83900384128116156123ef576123ef612704565b50500190565b6000821982111561240857612408612704565b500190565b600063ffffffff8083168185168083038211156120ef576120ef612704565b60008261243b5761243b61271a565b600160ff1b82146000198414161561245557612455612704565b500590565b6000826124695761246961271a565b500490565b60006001600160ff1b0360008413600084138583048511828216161561249657612496612704565b600160ff1b60008712828116878305891216156124b5576124b5612704565b600087129250878205871284841616156124d1576124d1612704565b878505871281841616156124e7576124e7612704565b505050929093029392505050565b600063ffffffff8083168185168183048111821515161561251857612518612704565b02949350505050565b60008083128015600160ff1b85018412161561253f5761253f612704565b836001600160ff1b0301831381161561255a5761255a612704565b50500390565b60008282101561257257612572612704565b500390565b600060c0823603121561258957600080fd5b61259161235b565b8235815260208084013581830152604084013567ffffffffffffffff808211156125ba57600080fd5b9085019036601f8301126125cd57600080fd5b8135818111156125df576125df61275c565b8060051b91506125f0848301612384565b81815284810190848601368587018801111561260b57600080fd5b600095505b8386101561262e578035835260019590950194918601918601612610565b5080604088015250505050505061264760608401611e65565b606082015261265860808401611e65565b608082015261266960a08401611e65565b60a082015292915050565b60005b8381101561268f578181015183820152602001612677565b838111156108765750506000910152565b600181811c908216806126b457607f821691505b602082108114156116b457634e487b7160e01b600052602260045260246000fd5b60006000198214156126e9576126e9612704565b5060010190565b6000826126ff576126ff61271a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220d013804a35b6569a79e1c51da50e3c7627c6c41797383926a7a7f6e21d13efe864736f6c63430008050033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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.