Contract 0x818ceD3D446292061913f1f74B2EAeE6341a76Ec 1

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x8c2b3f3724fe4b442b0b4e6c805fc5f78bdb2f7b92dcb807997eba3567556966Withdraw For Str...33876842021-11-27 21:36:481 hr 19 mins ago0xdb739cfbadd0a3422e31aaa34af6fcea13b1d3a7 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000697033953 ETH
0xe79646f5a4f6f665be5d9eeaaa0b4645a5bf1d175f2a0e0097b7d70591ffe28eWithdraw For Str...33839272021-11-27 17:40:335 hrs 15 mins ago0x4b9d2c6d1d2f6ead98aa8b2249b9a454b357062d IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000699933282 ETH
0xdc82871e7081908865366028fcc2fe17c7aad9e72b83d5e52acb3738168f8e3cWithdraw For Str...33838102021-11-27 17:32:365 hrs 23 mins ago0xa943681cf687774c2d44aab6aeb7d8c701fb7cbb IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000901744153 ETH
0x1833fc6eb8d11f2a08815013b666b813b977db6df132b55a932d10b76ee8db71Withdraw For Str...33815952021-11-27 15:28:177 hrs 27 mins ago0x77ec3b4d6e16a76ad7fd2073267d35e3e78cd1db IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000918011118 ETH
0xdde78f10ad4142c15900a159fff150100e1224c35d00abae64bbb0bf5ff1fac7Withdraw For Str...33796762021-11-27 13:41:589 hrs 13 mins ago0xd771c5856b29710d29193a27e6bdb7dcf7330538 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000731267934 ETH
0xef6bac06a042e42369e225c286e59970fe9364fe3795ed96f6d641c126618213Withdraw For Str...33792202021-11-27 13:15:089 hrs 40 mins ago0xc42d9cc7ba60a82e76e642e9343343f9a92f58bb IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.00094210536 ETH
0xc7ec3aaedfd7e136ef7ac9274f5c72eb55dee980426ca5c4b714e72848ce8b9bWithdraw For Str...33789672021-11-27 13:02:169 hrs 53 mins ago0x727d9d8dc825d3e058533b0e3717a91332276216 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000944070795 ETH
0x61d4280611c1932e882e84c4ec8c0f5619ee964d9154d1c0f5ccdb3225cd3810Withdraw For Str...33763712021-11-27 10:14:5612 hrs 40 mins ago0x4a70836fcbe8eccc604ab3c0b17faecd307a31b0 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.00073949282 ETH
0x9f93b634f86b0d9dda50afb06985cb5d24a84c64c4eb1de0e8b7514497c670b5Withdraw For Str...33733952021-11-27 7:06:4315 hrs 49 mins ago0x3f1e98e330132a09076ead93e758a0d631cb2ef8 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000760684237 ETH
0x87ad93a3890e4e5e4f8d39916e376d0375eebf6f30056193235523ec65512676Withdraw For Str...33726942021-11-27 6:04:4316 hrs 51 mins ago0x51384ba9a2e785a417b84c45c0e5e29313aab534 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.001195840308 ETH
0xde2878ceea99203209dea6b09266b29b01164fa57b2c0dd4e140a4a131ce5632Withdraw For Str...33718862021-11-27 5:04:3817 hrs 51 mins ago0x114794178cd4318888f44cc0924a2da3636ac16a IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.00119938213 ETH
0xec61807e77c3f497fa86b496a31bfa1f0cb1df05fb7af9699cb9e4ea6b43abf7Withdraw For Str...33708302021-11-27 3:35:0719 hrs 20 mins ago0xbe80ef1729fe8dc54e980ff9665550c302d747b0 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.00097227369 ETH
0x67920181c37f89c7a65e7d8dfe6e1cdfd26ad1bf7e588934f74cc5cd983a5b0fWithdraw For Str...33705522021-11-27 3:16:1519 hrs 39 mins ago0xef82a1c88c6ae138d4e98aa5a14f68d03eb1f29b IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000743902623 ETH
0x7d45b6221608a365812856b16265580033ba667b5495c180180cafe8a0fed0f6Withdraw For Str...33702512021-11-27 2:47:2020 hrs 8 mins ago0xf6e710ca64324e1ab6842a12e63e122aeb2adf84 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000963276359 ETH
0x8970c2b64aaa13f6cb8d39c0afee620af52db80d87f71ceaaed8a7eb130a3692Withdraw For Str...33701632021-11-27 2:41:2120 hrs 14 mins ago0x1fd0f6f153150b900eade8b43eecd381e56ca154 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000746889249 ETH
0x469674f7c2f7f5695234f257fed0e6876f3e4a537ed2b0db90f4543dfca3a077Withdraw For Str...33701612021-11-27 2:40:5220 hrs 15 mins ago0x1fd0f6f153150b900eade8b43eecd381e56ca154 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000746882759 ETH
0xe0467e51e24af4c95c703e36c498f2c15a7dff957b70b8eee8cc29990b6ab666Withdraw For Str...33701572021-11-27 2:40:5220 hrs 15 mins ago0x1fd0f6f153150b900eade8b43eecd381e56ca154 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.001176735254 ETH
0xe1cf1f3f115408cafde8be128ad454f5d3be8fe97f91af9f5d62b1a128ef7452Withdraw For Str...33695832021-11-27 1:46:5621 hrs 8 mins ago0xe8adb4db69928af17c4ba6a4156c651f113a3538 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.00096607257 ETH
0xa05b6fbc4d57b827c624d197259111c313e7d7e456b0f578207da08ab84e15e9Withdraw For Str...33693092021-11-27 1:23:4821 hrs 32 mins ago0x4bd7f202e724066fd4a4d59d8758b164234f5f60 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000748734845 ETH
0xd72a8f872093a9173ea59cefb067e307e3e9213fae47196f6e776850e5ef5992Withdraw For Str...33690532021-11-27 1:06:1821 hrs 49 mins ago0x5c18211b8138dc4d9173f8cf91338fce885b8878 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.001190851248 ETH
0x78dc02d80a0563ed0c5ee838dc375ba67c50678c5e53ddc100600a1564860b9dWithdraw For Str...33660452021-11-26 22:06:571 day 48 mins ago0xe76bd289004759db5b33269829b945504e8e5cc8 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000754036339 ETH
0xa336a42c01e7e2b6c4684228631b29b58e8f4584683e0d7d64df8ab6d4e31320Withdraw For Str...33655102021-11-26 21:34:371 day 1 hr ago0x0bd17ea3d63e1890b775f7883293685beda2a144 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000752479243 ETH
0x9c0cd8f5270c552fa05f5bd046dfb6b6f17a136f3e3038d31d13842b25e79177Withdraw For Str...33654952021-11-26 21:33:551 day 1 hr ago0x0bd17ea3d63e1890b775f7883293685beda2a144 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.00075250441 ETH
0x22b41dbff30ddaf7864a1683807f64bb3126aaacab54638753029fe4a41e52b0Withdraw For Str...33654752021-11-26 21:33:291 day 1 hr ago0x0bd17ea3d63e1890b775f7883293685beda2a144 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.001185796358 ETH
0xac4515188d3384a59b2f573a6d64d79a4aab9d015c58ff39905d5b90f3d8519cWithdraw For Str...33647542021-11-26 20:49:031 day 2 hrs ago0x8f022ff0d225a0f8c7343d4050f1163ba2029510 IN  0x818ced3d446292061913f1f74b2eaee6341a76ec0 ETH0.000971628876 ETH
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SSOVDpx

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, Unlicense license
File 1 of 31 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerableUpgradeable {
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
    function __AccessControlEnumerable_init() internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
        __AccessControlEnumerable_init_unchained();
    }

    function __AccessControlEnumerable_init_unchained() internal initializer {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    mapping (bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {grantRole} to track enumerable memberships
     */
    function grantRole(bytes32 role, address account) public virtual override {
        super.grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {revokeRole} to track enumerable memberships
     */
    function revokeRole(bytes32 role, address account) public virtual override {
        super.revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {renounceRole} to track enumerable memberships
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        super.renounceRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {_setupRole} to track enumerable memberships
     */
    function _setupRole(bytes32 role, address account) internal virtual override {
        super._setupRole(role, account);
        _roleMembers[role].add(account);
    }
    uint256[49] private __gap;
}

File 2 of 31 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    function hasRole(bytes32 role, address account) external view returns (bool);
    function getRoleAdmin(bytes32 role) external view returns (bytes32);
    function grantRole(bytes32 role, address account) external;
    function revokeRole(bytes32 role, address account) external;
    function renounceRole(bytes32 role, address account) external;
}

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal initializer {
    }
    struct RoleData {
        mapping (address => bool) members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

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

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

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if(!hasRole(role, account)) {
            revert(string(abi.encodePacked(
                "AccessControl: account ",
                StringsUpgradeable.toHexString(uint160(account), 20),
                " is missing role ",
                StringsUpgradeable.toHexString(uint256(role), 32)
            )));
        }
    }

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

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

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

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

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

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

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 3 of 31 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity ^0.8.0;

/**
 * @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.
 */
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() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 4 of 31 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal initializer {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}

File 5 of 31 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

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 guidelines: functions revert instead
 * of 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 defaut 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 initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _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");
        _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");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is 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");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(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:
     *
     * - `to` 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);
    }

    /**
     * @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");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

        emit Transfer(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 to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * 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 { }
    uint256[45] private __gap;
}

File 6 of 31 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

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 7 of 31 : ERC20BurnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20Upgradeable.sol";
import "../../../utils/ContextUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {
    function __ERC20Burnable_init() internal initializer {
        __Context_init_unchained();
        __ERC20Burnable_init_unchained();
    }

    function __ERC20Burnable_init_unchained() internal initializer {
    }
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        _approve(account, _msgSender(), currentAllowance - amount);
        _burn(account, amount);
    }
    uint256[50] private __gap;
}

File 8 of 31 : ERC20PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20Upgradeable.sol";
import "../../../security/PausableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev ERC20 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 */
abstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {
    function __ERC20Pausable_init() internal initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
        __ERC20Pausable_init_unchained();
    }

    function __ERC20Pausable_init_unchained() internal initializer {
    }
    /**
     * @dev See {ERC20-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
        super._beforeTokenTransfer(from, to, amount);

        require(!paused(), "ERC20Pausable: token transfer while paused");
    }
    uint256[50] private __gap;
}

File 9 of 31 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT

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 10 of 31 : ERC20PresetMinterPauserUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20Upgradeable.sol";
import "../extensions/ERC20BurnableUpgradeable.sol";
import "../extensions/ERC20PausableUpgradeable.sol";
import "../../../access/AccessControlEnumerableUpgradeable.sol";
import "../../../utils/ContextUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev {ERC20} token, including:
 *
 *  - ability for holders to burn (destroy) their tokens
 *  - a minter role that allows for token minting (creation)
 *  - a pauser role that allows to stop all token transfers
 *
 * This contract uses {AccessControl} to lock permissioned functions using the
 * different roles - head to its documentation for details.
 *
 * The account that deploys the contract will be granted the minter and pauser
 * roles, as well as the default admin role, which will let it grant both minter
 * and pauser roles to other accounts.
 */
contract ERC20PresetMinterPauserUpgradeable is Initializable, ContextUpgradeable, AccessControlEnumerableUpgradeable, ERC20BurnableUpgradeable, ERC20PausableUpgradeable {
    function initialize(string memory name, string memory symbol) public virtual initializer {
        __ERC20PresetMinterPauser_init(name, symbol);
    }
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /**
     * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the
     * account that deploys the contract.
     *
     * See {ERC20-constructor}.
     */
    function __ERC20PresetMinterPauser_init(string memory name, string memory symbol) internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
        __AccessControlEnumerable_init_unchained();
        __ERC20_init_unchained(name, symbol);
        __ERC20Burnable_init_unchained();
        __Pausable_init_unchained();
        __ERC20Pausable_init_unchained();
        __ERC20PresetMinterPauser_init_unchained(name, symbol);
    }

    function __ERC20PresetMinterPauser_init_unchained(string memory name, string memory symbol) internal initializer {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

        _setupRole(MINTER_ROLE, _msgSender());
        _setupRole(PAUSER_ROLE, _msgSender());
    }

    /**
     * @dev Creates `amount` new tokens for `to`.
     *
     * See {ERC20-_mint}.
     *
     * Requirements:
     *
     * - the caller must have the `MINTER_ROLE`.
     */
    function mint(address to, uint256 amount) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
        _mint(to, amount);
    }

    /**
     * @dev Pauses all token transfers.
     *
     * See {ERC20Pausable} and {Pausable-_pause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function pause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause");
        _pause();
    }

    /**
     * @dev Unpauses all token transfers.
     *
     * See {ERC20Pausable} and {Pausable-_unpause}.
     *
     * Requirements:
     *
     * - the caller must have the `PAUSER_ROLE`.
     */
    function unpause() public virtual {
        require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause");
        _unpause();
    }

    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20Upgradeable, ERC20PausableUpgradeable) {
        super._beforeTokenTransfer(from, to, amount);
    }
    uint256[50] private __gap;
}

File 11 of 31 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

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 initializer {
        __Context_init_unchained();
    }

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

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
    uint256[50] private __gap;
}

File 12 of 31 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant alphabet = "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] = alphabet[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

}

File 13 of 31 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal initializer {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal initializer {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 14 of 31 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

File 15 of 31 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

    struct Set {
        // Storage of set values
        bytes32[] _values;

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

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

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

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

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

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

File 16 of 31 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

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

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

File 17 of 31 : Clones.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt, address deployer) internal pure returns (address predicted) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 18 of 31 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 19 of 31 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 20 of 31 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant alphabet = "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] = alphabet[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

}

File 21 of 31 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

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

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

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

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

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

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

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

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

File 22 of 31 : SSOVDpx.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

/**                             .                    .                             
                           .'.                    .'.                           
                         .;:.                      .;:.                         
                       .:o:.                        .;l:.                       
                     .:dd,                            ,od:.                     
                   .:dxo'                              .lxd:.                   
                 .:dkxc.                                .:xkd:.                 
               .:dkkx:.                                  .;dkkd:.               
              .ckkkkxl:,'..                            ..':dkkkkl.              
               'codxxkkkxxdol,                     .,cldxkkkxdoc,               
                  ..',;coxkkkl.                  .;dxkxdol:;'..                 
                       .cxkxl.                   ;dkxl,..                       
                      .:xxxc.                   .cxxd'                          
                      ;dxd:.    ;c,.            .:dxo'                          
                     .lddc.    .cdoc.            'odd:.                         
                     .loo;.     .clol'           .;ool,                         
                     .:loc,.      ..'.            .:loc'                        
                      .,cllc;'.                    .;llc'                       
                        .';cccc:'.                  .;cc:.                      
                           ..,;::;'                  .;::;.                     
                              .';::,.                 .;:;.                     
                                .,;;,.                .;;;.                     
                                  .,,,'..            .,,,'.                     
                                   ..',,,'..      ..'','.                       
                                     ...'''''.....'''...                        
                                         ............                           
                            DOPEX SINGLE STAKING OPTION VAULT
            Mints covered calls while farming yield on single sided DPX staking farm                                                           
*/

// Libraries
import {Strings} from '@openzeppelin/contracts/utils/Strings.sol';
import {Clones} from '@openzeppelin/contracts/proxy/Clones.sol';
import {BokkyPooBahsDateTimeLibrary} from '../external/libraries/BokkyPooBahsDateTimeLibrary.sol';
import {SafeERC20} from '../external/libraries/SafeERC20.sol';

// Contracts
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {ERC20PresetMinterPauserUpgradeable} from '@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable.sol';
import {IVolatilityOracle} from '../interfaces/IVolatilityOracle.sol';

// Interfaces
import {IERC20} from '../external/interfaces/IERC20.sol';
import {IStakingRewards} from '../interfaces/IStakingRewards.sol';
import {IOptionPricing} from '../interfaces/IOptionPricing.sol';
import {IPriceOracleAggregator} from '../interfaces/IPriceOracleAggregator.sol';
import {ISSOV} from '../interfaces/ISSOV.sol';

contract SSOVDpx is Ownable, ISSOV {
    using BokkyPooBahsDateTimeLibrary for uint256;
    using Strings for uint256;
    using SafeERC20 for IERC20;

    /// @dev ERC20PresetMinterPauserUpgradeable implementation address
    address public immutable erc20Implementation;

    /// @dev Boolean of whether the vault is shutdown
    bool public isVaultShutdown;

    /// @dev Current epoch for ssov
    uint256 public currentEpoch;

    /// @dev Exercise Window Size
    uint256 public windowSize = 1 hours;

    /// @dev The list of contract addresses the contract uses
    mapping(bytes32 => address) public addresses;

    /// @dev epoch => the epoch start time
    mapping(uint256 => uint256) public epochStartTimes;

    /// @notice Is epoch expired
    /// @dev epoch => whether the epoch is expired
    mapping(uint256 => bool) public isEpochExpired;

    /// @notice Is vault ready for next epoch
    /// @dev epoch => whether the vault is ready (boostrapped)
    mapping(uint256 => bool) public isVaultReady;

    /// @dev Mapping of strikes for each epoch
    mapping(uint256 => uint256[]) public epochStrikes;

    /// @dev Mapping of (epoch => (strike => tokens))
    mapping(uint256 => mapping(uint256 => address))
        public
        override epochStrikeTokens;

    /// @notice Total epoch deposits for specific strikes
    /// @dev mapping (epoch => (strike => deposits))
    mapping(uint256 => mapping(uint256 => uint256))
        public totalEpochStrikeDeposits;

    /// @notice Total epoch deposits across all strikes
    /// @dev mapping (epoch => deposits)
    mapping(uint256 => uint256) public totalEpochDeposits;

    /// @notice Total epoch deposits for specific strikes
    /// @dev mapping (epoch => (strike => deposits))
    mapping(uint256 => mapping(uint256 => uint256))
        public totalEpochStrikeBalance;

    /// @notice Total epoch deposits across all strikes
    /// @dev mapping (epoch => deposits)
    mapping(uint256 => uint256) public totalEpochBalance;

    /// @notice Epoch deposits by user for each strike
    /// @dev mapping (epoch => (abi.encodePacked(user, strike) => user deposits))
    mapping(uint256 => mapping(bytes32 => uint256)) public userEpochDeposits;

    /// @notice Epoch DPX balance per strike after accounting for rewards
    /// @dev mapping (epoch => (strike => balance))
    mapping(uint256 => mapping(uint256 => uint256))
        public totalEpochStrikeDpxBalance;

    /// @notice Epoch rDPX balance per strike after accounting for rewards
    /// @dev mapping (epoch => (strike => balance))
    mapping(uint256 => mapping(uint256 => uint256))
        public totalEpochStrikeRdpxBalance;

    // Calls purchased for each strike in an epoch
    /// @dev mapping (epoch => (strike => calls purchased))
    mapping(uint256 => mapping(uint256 => uint256))
        public totalEpochCallsPurchased;

    /// @notice Calls purchased by user for each strike
    /// @dev mapping (epoch => (abi.encodePacked(user, strike) => user calls purchased))
    mapping(uint256 => mapping(bytes32 => uint256))
        public userEpochCallsPurchased;

    /// @notice Premium (and fees) collected per strike for an epoch
    /// @dev mapping (epoch => (strike => premium))
    mapping(uint256 => mapping(uint256 => uint256)) public totalEpochPremium;

    /// @notice User premium (and fees) collected per strike for an epoch
    /// @dev mapping (epoch => (abi.encodePacked(user, strike) => user premium))
    mapping(uint256 => mapping(bytes32 => uint256)) public userEpochPremium;

    /// @notice Total dpx tokens that were sent back to the buyer when a options is exercised for a certain strike
    /// @dev mapping (epoch => (strike => amount))
    mapping(uint256 => mapping(uint256 => uint256))
        public totalTokenVaultExercises;

    bytes32 public constant PURCHASE_FEE = keccak256('purchaseFee');
    bytes32 public constant PURCHASE_FEE_CAP = keccak256('purchaseFeeCap');
    bytes32 public constant EXERCISE_FEE = keccak256('exerciseFee');
    bytes32 public constant EXERCISE_FEE_CAP = keccak256('exerciseFeeCap');
    mapping(bytes32 => uint256) public fees;

    /*==== EVENTS ====*/

    event LogAddressSet(bytes32 indexed name, address indexed destination);

    event LogNewStrike(uint256 epoch, uint256 strike);

    event LogBootstrap(uint256 epoch);

    event LogNewDeposit(uint256 epoch, uint256 strike, address user);

    event LogNewPurchase(
        uint256 epoch,
        uint256 strike,
        address user,
        uint256 amount,
        uint256 premium,
        uint256 feesToUser,
        uint256 feeToFeeDistributor
    );

    event LogNewExercise(
        uint256 epoch,
        uint256 strike,
        address user,
        uint256 amount,
        uint256 pnl,
        uint256 feeTouser,
        uint256 feeToFeeDistributor
    );

    event LogCompound(
        uint256 epoch,
        uint256 rewards,
        uint256 oldBalance,
        uint256 newBalance
    );

    event LogNewWithdrawForStrike(
        uint256 epoch,
        uint256 strike,
        address user,
        uint256 amount,
        uint256 rdpxAmount
    );

    event LogFeesUpdate(bytes32 feeKey, uint256 amount);

    event LogWindowSizeUpdate(uint256 windowSizeInHours);

    event LogVaultShutdown(bool isVaultShutdown);

    event LogEmergencySettle(
        uint256 epoch,
        uint256 strike,
        address user,
        uint256 amount, // of options
        uint256 premiumReturned
    );

    /*==== CONSTRUCTOR ====*/

    constructor(
        address _dpx,
        address _rdpx,
        address _stakingRewards,
        address _optionPricing,
        address _priceOracleAggregator,
        address _volatilityOracle,
        address _feeDistributor
    ) {
        require(_dpx != address(0), 'E1');
        require(_rdpx != address(0), 'E2');
        require(_stakingRewards != address(0), 'E3');
        require(_optionPricing != address(0), 'E4');
        require(_priceOracleAggregator != address(0), 'E5');

        addresses['FeeDistributor'] = _feeDistributor;
        addresses['DPX'] = _dpx;
        addresses['RDPX'] = _rdpx;
        addresses['StakingRewards'] = _stakingRewards;
        addresses['OptionPricing'] = _optionPricing;
        addresses['PriceOracleAggregator'] = _priceOracleAggregator;
        addresses['VolatilityOracle'] = _volatilityOracle;

        fees[PURCHASE_FEE] = 2e8 / 100; // 0.02% of the price of the base asset
        fees[PURCHASE_FEE_CAP] = 10e8; // 10% of the option price
        fees[EXERCISE_FEE] = 1e8 / 100; // 0.01% of the price of the base asset
        fees[EXERCISE_FEE_CAP] = 10e8; // 10% of the option price

        erc20Implementation = address(new ERC20PresetMinterPauserUpgradeable());

        // Max approve to stakingRewards
        IERC20(getAddress('DPX')).safeApprove(
            getAddress('StakingRewards'),
            type(uint256).max
        );
    }

    /*==== SETTER METHODS ====*/

    /// @notice Shutdown the vault
    /// @dev Can only be called by owner
    /// @return Whether it was successfully shutdown
    function shutdownVault() external onlyOwner returns (bool) {
        isVaultShutdown = true;

        _updateFinalEpochBalances(false);

        emit LogVaultShutdown(true);

        return true;
    }

    /// @notice Open the vault
    /// @dev Can only be called by owner
    /// @return Whether it was successfully opened
    function openVault() external onlyOwner returns (bool) {
        isVaultShutdown = false;

        emit LogVaultShutdown(false);

        return true;
    }

    /// @notice Update the fee percentage in the vault
    /// @dev Can only be called by owner
    /// @param feeKey The key of the fee to be updated
    /// @param feeAmount The new amount
    /// @return Whether it was successfully updated
    function updateFees(bytes32 feeKey, uint256 feeAmount)
        external
        onlyOwner
        returns (bool)
    {
        fees[feeKey] = feeAmount;

        emit LogFeesUpdate(feeKey, feeAmount);

        return true;
    }

    /// @notice Update the exercise window size of an option
    /// @dev Can only be called by owner
    /// @param _windowSize The window size
    /// @return Whether it was successfully updated
    function updateWindowSize(uint256 _windowSize)
        external
        onlyOwner
        returns (bool)
    {
        windowSize = _windowSize;
        emit LogWindowSizeUpdate(_windowSize);
        return true;
    }

    /// @notice Sets (adds) a list of addresses to the address list
    /// @param names Names of the contracts
    /// @param destinations Addresses of the contract
    /// @return Whether the addresses were set
    function setAddresses(
        bytes32[] calldata names,
        address[] calldata destinations
    ) external onlyOwner returns (bool) {
        require(
            names.length == destinations.length,
            'Input lengths must match'
        );
        for (uint256 i = 0; i < names.length; i++) {
            bytes32 name = names[i];
            address destination = destinations[i];
            addresses[name] = destination;
            emit LogAddressSet(name, destination);
        }
        return true;
    }

    /*==== METHODS ====*/

    /// @notice Sets the current epoch as expired.
    /// @return Whether expire was successful
    function expireEpoch() external onlyOwner returns (bool) {
        // Vault must not be shutdown
        require(!isVaultShutdown, 'E24');

        // Epoch must not be expired
        require(!isEpochExpired[currentEpoch], 'E6');

        (, uint256 epochExpiry) = getEpochTimes(currentEpoch);
        // Current timestamp should be past expiry
        require((block.timestamp > epochExpiry), 'E7');

        isEpochExpired[currentEpoch] = true;

        _updateFinalEpochBalances(true);

        return true;
    }

    /// @dev Updates the final epoch DPX/rDPX balances per strike of the vault
    /// @param accountPremiums Should the fn account for premiums
    function _updateFinalEpochBalances(bool accountPremiums) internal {
        IStakingRewards stakingRewards = IStakingRewards(
            getAddress('StakingRewards')
        );

        IERC20 dpx = IERC20(getAddress('DPX'));
        IERC20 rdpx = IERC20(getAddress('RDPX'));

        if (stakingRewards.balanceOf(address(this)) > 0) {
            // Unstake all tokens from previous epoch
            stakingRewards.withdraw(stakingRewards.balanceOf(address(this)));
        }

        uint256 totalDpxRewardsClaimed = dpx.balanceOf(address(this));
        uint256 totalRdpxRewardsClaimed = rdpx.balanceOf(address(this));

        // Claim DPX and RDPX rewards
        stakingRewards.getReward(2);

        totalDpxRewardsClaimed =
            dpx.balanceOf(address(this)) -
            totalDpxRewardsClaimed;
        totalRdpxRewardsClaimed =
            rdpx.balanceOf(address(this)) -
            totalRdpxRewardsClaimed;

        if (totalEpochBalance[currentEpoch] > 0) {
            uint256[] memory strikes = epochStrikes[currentEpoch];

            for (uint256 i = 0; i < strikes.length; i++) {
                uint256 dpxRewards = (totalDpxRewardsClaimed *
                    totalEpochStrikeBalance[currentEpoch][strikes[i]]) /
                    totalEpochBalance[currentEpoch];

                // Update final dpx and rdpx balances for epoch and strike
                totalEpochStrikeDpxBalance[currentEpoch][strikes[i]] +=
                    totalEpochStrikeDeposits[currentEpoch][strikes[i]] +
                    dpxRewards -
                    totalTokenVaultExercises[currentEpoch][strikes[i]];

                if (accountPremiums) {
                    totalEpochStrikeDpxBalance[currentEpoch][
                        strikes[i]
                    ] += totalEpochPremium[currentEpoch][strikes[i]];
                }

                totalEpochStrikeRdpxBalance[currentEpoch][strikes[i]] =
                    (totalRdpxRewardsClaimed *
                        totalEpochStrikeBalance[currentEpoch][strikes[i]]) /
                    totalEpochBalance[currentEpoch];
            }
        }
    }

    /**
     * @notice Bootstraps a new epoch and mints option tokens equivalent to user deposits for the epoch
     * @return Whether bootstrap was successful
     */
    function bootstrap() external onlyOwner returns (bool) {
        uint256 nextEpoch = currentEpoch + 1;

        // Vault must not be ready
        require(!isVaultReady[nextEpoch], 'E8');

        // Next epoch strike must be set
        require(epochStrikes[nextEpoch].length > 0, 'E9');

        if (currentEpoch > 0) {
            // Previous epoch must be expired
            require(isEpochExpired[currentEpoch], 'E10');
        }

        for (uint256 i = 0; i < epochStrikes[nextEpoch].length; i++) {
            uint256 strike = epochStrikes[nextEpoch][i];
            string memory name = concatenate('DPX-CALL', strike.toString());
            name = concatenate(name, '-EPOCH-');
            name = concatenate(name, (nextEpoch).toString());
            // Create doTokens representing calls for selected strike in epoch
            ERC20PresetMinterPauserUpgradeable _erc20 = ERC20PresetMinterPauserUpgradeable(
                    Clones.clone(erc20Implementation)
                );
            _erc20.initialize(name, name);
            epochStrikeTokens[nextEpoch][strike] = address(_erc20);
            // Mint tokens equivalent to deposits for strike in epoch
            _erc20.mint(
                address(this),
                totalEpochStrikeDeposits[nextEpoch][strike]
            );
        }

        // Mark vault as ready for epoch
        isVaultReady[nextEpoch] = true;
        // Increase the current epoch
        currentEpoch = nextEpoch;

        emit LogBootstrap(nextEpoch);

        return true;
    }

    /**
     * @notice Sets strikes for next epoch
     * @param strikes Strikes to set for next epoch
     * @return Whether strikes were set
     */
    function setStrikes(uint256[] memory strikes)
        external
        onlyOwner
        returns (bool)
    {
        require(!isVaultShutdown, 'E24');
        uint256 nextEpoch = currentEpoch + 1;

        require(totalEpochDeposits[nextEpoch] == 0, 'E11');

        if (currentEpoch > 0) {
            (, uint256 epochExpiry) = getEpochTimes(currentEpoch);
            // Current timestamp should be past expiry
            require((block.timestamp > epochExpiry), 'E12');
        }

        // Set the next epoch strikes
        epochStrikes[nextEpoch] = strikes;
        // Set the next epoch start time
        epochStartTimes[nextEpoch] = block.timestamp;

        for (uint256 i = 0; i < strikes.length; i++)
            emit LogNewStrike(nextEpoch, strikes[i]);
        return true;
    }

    /**
     * @notice Deposits dpx into the ssov to mint options in the next epoch for selected strikes
     * @param strikeIndex Index of strike
     * @param amount Amout of DPX to deposit
     * @return Whether deposit was successful
     */
    function deposit(uint256 strikeIndex, uint256 amount)
        public
        returns (bool)
    {
        require(!isVaultShutdown, 'E24');

        uint256 nextEpoch = currentEpoch + 1;

        if (currentEpoch > 0) {
            require(
                isEpochExpired[currentEpoch] && !isVaultReady[nextEpoch],
                'E26'
            );
        }

        // Must be a valid strikeIndex
        require(strikeIndex < epochStrikes[nextEpoch].length, 'E13');

        // Must +ve amount
        require(amount > 0, 'E14');

        // Must be a valid strike
        uint256 strike = epochStrikes[nextEpoch][strikeIndex];
        require(strike != 0, 'E15');

        bytes32 userStrike = keccak256(abi.encodePacked(msg.sender, strike));

        // Transfer DPX from user to ssov
        IERC20(getAddress('DPX')).safeTransferFrom(
            msg.sender,
            address(this),
            amount
        );

        // Add to user epoch deposits
        userEpochDeposits[nextEpoch][userStrike] += amount;
        // Add to total epoch strike deposits
        totalEpochStrikeDeposits[nextEpoch][strike] += amount;
        // Add to total epoch deposits
        totalEpochDeposits[nextEpoch] += amount;
        // Add to total epoch strike deposits
        totalEpochStrikeBalance[nextEpoch][strike] += amount;
        // Add to total epoch deposits
        totalEpochBalance[nextEpoch] += amount;
        // Deposit into staking rewards
        IStakingRewards(getAddress('StakingRewards')).stake(amount);

        emit LogNewDeposit(nextEpoch, strike, msg.sender);

        return true;
    }

    /**
     * @notice Deposit DPX multiple times
     * @param strikeIndices Indices of strikes to deposit into
     * @param amounts Amount of DPX to deposit into each strike index
     * @return Whether deposits went through successfully
     */
    function depositMultiple(
        uint256[] memory strikeIndices,
        uint256[] memory amounts
    ) public returns (bool) {
        require(strikeIndices.length == amounts.length, 'E16');

        for (uint256 i = 0; i < strikeIndices.length; i++)
            deposit(strikeIndices[i], amounts[i]);
        return true;
    }

    /**
     * @notice Purchases calls for the current epoch
     * @param strikeIndex Strike index for current epoch
     * @param amount Amount of calls to purchase
     * @return Whether purchase was successful
     */
    function purchase(uint256 strikeIndex, uint256 amount)
        external
        override
        returns (uint256, uint256)
    {
        require(!isVaultShutdown, 'E24');
        require(currentEpoch > 0, 'E17');

        // Must be a valid strikeIndex
        require(strikeIndex < epochStrikes[currentEpoch].length, 'E13');

        // Must positive amount
        require(amount > 0, 'E14');

        // Must be a valid strike
        uint256 strike = epochStrikes[currentEpoch][strikeIndex];
        require(strike != 0, 'E15');
        bytes32 userStrike = keccak256(abi.encodePacked(msg.sender, strike));

        address dpx = getAddress('DPX');
        uint256 currentPrice = getUsdPrice(dpx);
        // Get total premium for all calls being purchased
        uint256 premium = (IOptionPricing(getAddress('OptionPricing'))
            .getOptionPrice(
                false,
                getMonthlyExpiryFromTimestamp(block.timestamp),
                strike,
                currentPrice,
                IVolatilityOracle(getAddress('VolatilityOracle')).getVolatility()
            ) * amount) / currentPrice;

        // total fees charged
        uint256 totalFees = calculateFees(premium, currentPrice, true);

        // 30% ( number * 0.3 ) of fees for FeeDistributor
        uint256 feetoFeeDistrubutor = (totalFees * 3) / 10;

        // Add to total epoch calls purchased
        totalEpochCallsPurchased[currentEpoch][strike] += amount;
        // Add to user epoch calls purchased
        userEpochCallsPurchased[currentEpoch][userStrike] += amount;
        // Add to total epoch premium + fees
        totalEpochPremium[currentEpoch][strike] +=
            premium +
            (totalFees - feetoFeeDistrubutor);
        // Add to user epoch premium + fees
        userEpochPremium[currentEpoch][userStrike] +=
            premium +
            (totalFees - feetoFeeDistrubutor);

        // Compound before updating new strike balance
        compound();

        // Add to total epoch strike balance premium + fee to vault
        totalEpochStrikeBalance[currentEpoch][strike] +=
            premium +
            (totalFees - feetoFeeDistrubutor);

        // Add to total epoch balance premium + fee
        totalEpochBalance[currentEpoch] +=
            premium +
            (totalFees - feetoFeeDistrubutor);

        // Transfer usd equivalent to premium from user
        IERC20(dpx).safeTransferFrom(
            msg.sender,
            address(this),
            premium + totalFees
        );

        IERC20(dpx).safeTransfer(
            getAddress('FeeDistributor'),
            feetoFeeDistrubutor
        );

        // Transfer doTokens to user
        IERC20(epochStrikeTokens[currentEpoch][strike]).safeTransfer(
            msg.sender,
            amount
        );

        // Stake premium into farming
        IStakingRewards(getAddress('StakingRewards')).stake(
            premium + (totalFees - feetoFeeDistrubutor)
        );

        emit LogNewPurchase(
            currentEpoch,
            strike,
            msg.sender,
            amount,
            premium,
            totalFees,
            feetoFeeDistrubutor
        );

        return (premium, totalFees);
    }

    /**
     * @notice Exercise calculates the PnL for the user. Withdraw the PnL in DPX from the SSF and transfer it to the user. Will also the burn the doTokens from the user.
     * @param strikeIndex Strike index for current epoch
     * @param amount Amount of calls to exercise
     * @param user Address of the user
     * @return Pnl and Fee
     */
    function exercise(
        uint256 strikeIndex,
        uint256 amount,
        address user
    ) external override returns (uint256, uint256) {
        require(!isVaultShutdown, 'E24');

        uint256 epoch = currentEpoch;

        (, uint256 expiry) = getEpochTimes(epoch);

        // Must be in exercise window
        require(isExerciseWindow(expiry), 'E18');

        // Must be a valid strikeIndex
        require(strikeIndex < epochStrikes[epoch].length, 'E13');

        // Must positive amount
        require(amount > 0, 'E14');

        // Must be a valid strike
        uint256 strike = epochStrikes[epoch][strikeIndex];
        require(strike != 0, 'E15');

        uint256 currentPrice = getUsdPrice(getAddress('DPX'));

        // Revert if strike price is higher than current price
        require(strike < currentPrice, 'E19');

        // Revert if user is zero address
        require(user != address(0), 'E20');

        // Revert if user does not have enough option token balance for the amount specified
        require(
            IERC20(epochStrikeTokens[epoch][strike]).balanceOf(user) >= amount,
            'E21'
        );

        // Calculate PnL (in DPX)
        uint256 PnL = (((currentPrice - strike) * amount) / currentPrice);

        // fee to deduct from users PnL
        uint256 feeToUser = calculateFees(PnL, currentPrice, false);

        // 30% fees to fee distributor
        uint256 feeToFeeDistributor = (feeToUser * 3) / 10;

        // Burn user option tokens
        ERC20PresetMinterPauserUpgradeable(epochStrikeTokens[epoch][strike])
            .burnFrom(user, amount);

        // Update state to account for exercised options (amount of DPX used in exercising)
        totalTokenVaultExercises[epoch][strike] += PnL;

        if (!isVaultShutdown) {
            IStakingRewards(getAddress('StakingRewards')).withdraw(PnL);
        }

        // Transfer PnL to user
        IERC20(getAddress('DPX')).safeTransfer(user, PnL - feeToUser);

        // transfer fees to FeeDistributor
        IERC20(getAddress('DPX')).safeTransfer(
            getAddress('FeeDistributor'),
            feeToFeeDistributor
        );

        emit LogNewExercise(
            epoch,
            strike,
            user,
            amount,
            PnL,
            feeToUser,
            feeToFeeDistributor
        );

        return (PnL, feeToUser);
    }

    /**
     * @notice Allows a user to settle their options due to an emergency shutdown. Returns the premium to the user.
     * @param strikeIndex Strike index for current epoch
     * @param amount Amount of calls to exercise
     * @param user Address of the user
     */
    function emergencySettle(
        uint256 strikeIndex,
        uint256 amount,
        address user
    ) external returns (uint256) {
        // Vault must be shutdown
        require(isVaultShutdown, 'E25');

        uint256 epoch = currentEpoch;

        // Must be a valid strikeIndex
        require(strikeIndex < epochStrikes[epoch].length, 'E13');

        // Must positive amount
        require(amount > 0, 'E14');

        // Must be a valid strike
        uint256 strike = epochStrikes[epoch][strikeIndex];
        require(strike != 0, 'E15');

        // Revert if user is zero address
        require(user != address(0), 'E20');

        // Revert if user does not have enough option token balance for the amount specified
        require(
            IERC20(epochStrikeTokens[epoch][strike]).balanceOf(user) >= amount,
            'E21'
        );

        // Burn user option tokens
        ERC20PresetMinterPauserUpgradeable(epochStrikeTokens[epoch][strike])
            .burnFrom(user, amount);

        bytes32 userStrike = keccak256(abi.encodePacked(msg.sender, strike));

        uint256 userPremium = userEpochPremium[epoch][userStrike];

        userEpochPremium[epoch][userStrike] = 0;

        // Transfer premium to user
        IERC20(getAddress('DPX')).safeTransfer(user, userPremium);

        emit LogEmergencySettle(epoch, strike, user, amount, userPremium);

        return userPremium;
    }

    /**
     * @notice Allows anyone to call compound()
     * @return Whether compound was successful
     */
    function compound() public returns (bool) {
        require(!isVaultShutdown, 'E24');
        require(!isEpochExpired[currentEpoch], 'E6');
        require(isVaultReady[currentEpoch], 'E27');

        if (currentEpoch == 0) {
            return false;
        }

        IStakingRewards stakingRewards = IStakingRewards(
            getAddress('StakingRewards')
        );

        uint256 oldBalance = stakingRewards.balanceOf(address(this));

        (uint256 rewardsDPX, ) = stakingRewards.earned(address(this));

        // Account for DPX rewards per strike deposit
        uint256[] memory strikes = epochStrikes[currentEpoch];
        for (uint256 i = 0; i < strikes.length; i++) {
            uint256 strikeRewards = (rewardsDPX *
                totalEpochStrikeDeposits[currentEpoch][strikes[i]]) /
                totalEpochDeposits[currentEpoch];

            totalEpochStrikeDpxBalance[currentEpoch][
                strikes[i]
            ] += strikeRewards;

            totalEpochStrikeBalance[currentEpoch][strikes[i]] += strikeRewards;
        }

        totalEpochBalance[currentEpoch] += rewardsDPX;
        if (rewardsDPX > 0) {
            // Compound staking rewards
            stakingRewards.compound();
        }

        emit LogCompound(
            currentEpoch,
            rewardsDPX,
            oldBalance,
            stakingRewards.balanceOf(address(this))
        );

        return true;
    }

    /**
     * @notice Withdraws balances for a strike in a completed epoch
     * @param withdrawEpoch Epoch to withdraw from
     * @param strikeIndex Index of strike
     * @return Whether withdraw was successful
     */
    function withdrawForStrike(uint256 withdrawEpoch, uint256 strikeIndex)
        external
        returns (bool)
    {
        // Epoch must be expired
        require(isEpochExpired[withdrawEpoch], 'E22');

        _withdraw(withdrawEpoch, strikeIndex);

        return true;
    }

    /**
     * @notice Emergency withdraws balances for a strike
     * @dev Vault must be shutdown for this
     * @param strikeIndex Index of strike
     * @return Whether withdraw was successful
     */
    function emergencyWithdrawForStrike(uint256 strikeIndex)
        external
        returns (bool)
    {
        require(isVaultShutdown, 'E25');

        _withdraw(currentEpoch, strikeIndex);

        return true;
    }

    /// @dev Internal function to handle a withdraw
    /// @param withdrawEpoch Epoch to withdraw from
    /// @param strikeIndex Index of strike
    function _withdraw(uint256 withdrawEpoch, uint256 strikeIndex) internal {
        // Must be a valid strikeIndex
        require(strikeIndex < epochStrikes[withdrawEpoch].length, 'E13');

        // Must be a valid strike
        uint256 strike = epochStrikes[withdrawEpoch][strikeIndex];
        require(strike != 0, 'E15');

        // Must be a valid user strike deposit amount
        bytes32 userStrike = keccak256(abi.encodePacked(msg.sender, strike));
        uint256 userStrikeDeposits = userEpochDeposits[withdrawEpoch][
            userStrike
        ];

        require(userStrikeDeposits > 0, 'E23');

        address rdpx = getAddress('RDPX');
        // Transfer RDPX tokens to user
        uint256 userRdpxAmount = (totalEpochStrikeRdpxBalance[withdrawEpoch][
            strike
        ] * userStrikeDeposits) /
            totalEpochStrikeDeposits[withdrawEpoch][strike];

        // Transfer DPX tokens to user
        address dpx = getAddress('DPX');
        uint256 userDpxAmount = (totalEpochStrikeDpxBalance[withdrawEpoch][
            strike
        ] * userStrikeDeposits) /
            totalEpochStrikeDeposits[withdrawEpoch][strike];

        userEpochDeposits[withdrawEpoch][userStrike] = 0;

        IERC20(rdpx).safeTransfer(msg.sender, userRdpxAmount);

        IERC20(dpx).safeTransfer(msg.sender, userDpxAmount);

        emit LogNewWithdrawForStrike(
            withdrawEpoch,
            strike,
            msg.sender,
            userStrikeDeposits,
            userRdpxAmount
        );
    }

    /*==== PURE FUNCTIONS ====*/

    /// @notice Calculates the monthly expiry from a solidity date
    /// @param timestamp Timestamp from which the monthly expiry is to be calculated
    /// @return The monthly expiry
    function getMonthlyExpiryFromTimestamp(uint256 timestamp)
        public
        pure
        returns (uint256)
    {
        uint256 lastDay = BokkyPooBahsDateTimeLibrary.timestampFromDate(
            timestamp.getYear(),
            timestamp.getMonth() + 1,
            0
        );

        if (lastDay.getDayOfWeek() < 5) {
            lastDay = BokkyPooBahsDateTimeLibrary.timestampFromDate(
                lastDay.getYear(),
                lastDay.getMonth(),
                lastDay.getDay() - 7
            );
        }

        uint256 lastFridayOfMonth = BokkyPooBahsDateTimeLibrary
            .timestampFromDateTime(
                lastDay.getYear(),
                lastDay.getMonth(),
                lastDay.getDay() + 5 - lastDay.getDayOfWeek(),
                8,
                0,
                0
            );

        if (lastFridayOfMonth <= timestamp) {
            uint256 temp = BokkyPooBahsDateTimeLibrary.timestampFromDate(
                timestamp.getYear(),
                timestamp.getMonth() + 2,
                0
            );

            if (temp.getDayOfWeek() < 5) {
                temp = BokkyPooBahsDateTimeLibrary.timestampFromDate(
                    temp.getYear(),
                    temp.getMonth(),
                    temp.getDay() - 7
                );
            }

            lastFridayOfMonth = BokkyPooBahsDateTimeLibrary
                .timestampFromDateTime(
                    temp.getYear(),
                    temp.getMonth(),
                    temp.getDay() + 5 - temp.getDayOfWeek(),
                    8,
                    0,
                    0
                );
        }
        return lastFridayOfMonth;
    }

    /**
     * @notice Returns a concatenated string of a and b
     * @param a string a
     * @param b string b
     */
    function concatenate(string memory a, string memory b)
        internal
        pure
        returns (string memory)
    {
        return string(abi.encodePacked(a, b));
    }

    /*==== VIEWS ====*/

    /// @notice calculates fees for a given amount
    /// @param amountToCharge amount from which fees is charged from
    /// @param dpxPrice last price of DPX in USDT
    /// @param isPurchase if true, uses purchase fees values, if false, uses exercise fees values
    function calculateFees(
        uint256 amountToCharge,
        uint256 dpxPrice,
        bool isPurchase
    ) public view returns (uint256) {
        uint256 fee = isPurchase ? fees[PURCHASE_FEE] : fees[EXERCISE_FEE];
        uint256 feeCap = isPurchase
            ? fees[PURCHASE_FEE_CAP]
            : fees[EXERCISE_FEE_CAP];

        uint256 baseAssetFees = (dpxPrice * fee) / 1e10;
        uint256 optionPriceFees = (amountToCharge * feeCap * dpxPrice) / 1e28;

        if (baseAssetFees > optionPriceFees) {
            return (optionPriceFees * 1e18) / dpxPrice;
        } else {
            return (baseAssetFees * 1e18) / dpxPrice;
        }
    }

    /**
     * @notice Returns start and end times for an epoch
     * @param epoch Target epoch
     */
    function getEpochTimes(uint256 epoch)
        public
        view
        returns (uint256 start, uint256 end)
    {
        require(epoch > 0, 'E17');

        return (
            epochStartTimes[epoch],
            getMonthlyExpiryFromTimestamp(epochStartTimes[epoch])
        );
    }

    /**
     * @notice Returns epoch strikes array for an epoch
     * @param epoch Target epoch
     */
    function getEpochStrikes(uint256 epoch)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        return epochStrikes[epoch];
    }

    /**
     * Returns epoch strike tokens array for an epoch
     * @param epoch Target epoch
     */
    function getEpochStrikeTokens(uint256 epoch)
        external
        view
        returns (address[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        address[] memory _epochStrikeTokens = new address[](length);

        for (uint256 i = 0; i < length; i++) {
            _epochStrikeTokens[i] = epochStrikeTokens[epoch][
                epochStrikes[epoch][i]
            ];
        }

        return _epochStrikeTokens;
    }

    /**
     * @notice Returns total epoch strike deposits array for an epoch
     * @param epoch Target epoch
     */
    function getTotalEpochStrikeDeposits(uint256 epoch)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        uint256[] memory _totalEpochStrikeDeposits = new uint256[](length);

        for (uint256 i = 0; i < length; i++) {
            _totalEpochStrikeDeposits[i] = totalEpochStrikeDeposits[epoch][
                epochStrikes[epoch][i]
            ];
        }

        return _totalEpochStrikeDeposits;
    }

    /**
     * @notice Returns user epoch deposits array for an epoch
     * @param epoch Target epoch
     * @param user Address of the user
     */
    function getUserEpochDeposits(uint256 epoch, address user)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        uint256[] memory _userEpochDeposits = new uint256[](length);

        for (uint256 i = 0; i < length; i++) {
            uint256 strike = epochStrikes[epoch][i];
            bytes32 userStrike = keccak256(abi.encodePacked(user, strike));

            _userEpochDeposits[i] = userEpochDeposits[epoch][userStrike];
        }

        return _userEpochDeposits;
    }

    /**
     * @notice Returns total epoch calls purchased array for an epoch
     * @param epoch Target epoch
     */
    function getTotalEpochCallsPurchased(uint256 epoch)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        uint256[] memory _totalEpochCallsPurchased = new uint256[](length);

        for (uint256 i = 0; i < length; i++) {
            _totalEpochCallsPurchased[i] = totalEpochCallsPurchased[epoch][
                epochStrikes[epoch][i]
            ];
        }

        return _totalEpochCallsPurchased;
    }

    /**
     * @notice Returns user epoch calls purchased array for an epoch
     * @param epoch Target epoch
     * @param user Address of the user
     */
    function getUserEpochCallsPurchased(uint256 epoch, address user)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        uint256[] memory _userEpochCallsPurchased = new uint256[](length);

        for (uint256 i = 0; i < length; i++) {
            uint256 strike = epochStrikes[epoch][i];
            bytes32 userStrike = keccak256(abi.encodePacked(user, strike));

            _userEpochCallsPurchased[i] = userEpochCallsPurchased[epoch][
                userStrike
            ];
        }

        return _userEpochCallsPurchased;
    }

    /**
     * @notice Returns total epoch premium array for an epoch
     * @param epoch Target epoch
     */
    function getTotalEpochPremium(uint256 epoch)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        uint256[] memory _totalEpochPremium = new uint256[](length);

        for (uint256 i = 0; i < length; i++) {
            _totalEpochPremium[i] = totalEpochPremium[epoch][
                epochStrikes[epoch][i]
            ];
        }

        return _totalEpochPremium;
    }

    /**
     * @notice Returns user epoch premium array for an epoch
     * @param epoch Target epoch
     * @param user Address of the user
     */
    function getUserEpochPremium(uint256 epoch, address user)
        external
        view
        returns (uint256[] memory)
    {
        require(epoch > 0, 'E17');

        uint256 length = epochStrikes[epoch].length;
        uint256[] memory _userEpochPremium = new uint256[](length);

        for (uint256 i = 0; i < length; i++) {
            uint256 strike = epochStrikes[epoch][i];
            bytes32 userStrike = keccak256(abi.encodePacked(user, strike));

            _userEpochPremium[i] = userEpochPremium[epoch][userStrike];
        }

        return _userEpochPremium;
    }

    /**
     * @notice Update & Returns token's price in USD
     * @param _token Address of the token
     */
    function getUsdPrice(address _token) public returns (uint256) {
        return
            IPriceOracleAggregator(getAddress('PriceOracleAggregator'))
                .getPriceInUSD(_token);
    }

    /**
     * @notice Returns token's price in USD
     * @param _token Address of the token
     */
    function viewUsdPrice(address _token) external view returns (uint256) {
        return
            IPriceOracleAggregator(getAddress('PriceOracleAggregator'))
                .viewPriceInUSD(_token);
    }

    /**
     * @notice Returns true if exercise can be called
     * @param expiry The expiry of the option
     */
    function isExerciseWindow(uint256 expiry) public view returns (bool) {
        return ((block.timestamp >= expiry - windowSize) &&
            (block.timestamp < expiry));
    }

    /**
     * @notice Gets the address of a set contract
     * @param name Name of the contract
     * @return The address of the contract
     */
    function getAddress(bytes32 name) public view override returns (address) {
        return addresses[name];
    }
}

File 23 of 31 : IERC20.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 * NOTE: Modified to include symbols and decimals.
 */
interface IERC20 {
  function totalSupply() external view returns (uint256);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint8);

  function balanceOf(address account) external view returns (uint256);

  function transfer(address recipient, uint256 amount) external returns (bool);

  function allowance(address owner, address spender)
    external
    view
    returns (uint256);

  function approve(address spender, uint256 amount) external returns (bool);

  function transferFrom(
    address sender,
    address recipient,
    uint256 amount
  ) external returns (bool);

  event Transfer(address indexed from, address indexed to, uint256 value);
  event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 24 of 31 : BokkyPooBahsDateTimeLibrary.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

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

library BokkyPooBahsDateTimeLibrary {
  uint256 constant SECONDS_PER_DAY = 24 * 60 * 60;
  uint256 constant SECONDS_PER_HOUR = 60 * 60;
  uint256 constant SECONDS_PER_MINUTE = 60;
  int256 constant OFFSET19700101 = 2440588;

  uint256 constant DOW_MON = 1;
  uint256 constant DOW_TUE = 2;
  uint256 constant DOW_WED = 3;
  uint256 constant DOW_THU = 4;
  uint256 constant DOW_FRI = 5;
  uint256 constant DOW_SAT = 6;
  uint256 constant DOW_SUN = 7;

  // ------------------------------------------------------------------------
  // Calculate the number of days from 1970/01/01 to year/month/day using
  // the date conversion algorithm from
  //   http://aa.usno.navy.mil/faq/docs/JD_Formula.php
  // and subtracting the offset 2440588 so that 1970/01/01 is day 0
  //
  // days = day
  //      - 32075
  //      + 1461 * (year + 4800 + (month - 14) / 12) / 4
  //      + 367 * (month - 2 - (month - 14) / 12 * 12) / 12
  //      - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4
  //      - offset
  // ------------------------------------------------------------------------
  function _daysFromDate(
    uint256 year,
    uint256 month,
    uint256 day
  ) internal pure returns (uint256 _days) {
    require(year >= 1970);
    int256 _year = int256(year);
    int256 _month = int256(month);
    int256 _day = int256(day);

    int256 __days = _day -
      32075 +
      (1461 * (_year + 4800 + (_month - 14) / 12)) /
      4 +
      (367 * (_month - 2 - ((_month - 14) / 12) * 12)) /
      12 -
      (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) /
      4 -
      OFFSET19700101;

    _days = uint256(__days);
  }

  // ------------------------------------------------------------------------
  // 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 timestampFromDate(
    uint256 year,
    uint256 month,
    uint256 day
  ) internal pure returns (uint256 timestamp) {
    timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;
  }

  function timestampFromDateTime(
    uint256 year,
    uint256 month,
    uint256 day,
    uint256 hour,
    uint256 minute,
    uint256 second
  ) internal pure returns (uint256 timestamp) {
    timestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      hour *
      SECONDS_PER_HOUR +
      minute *
      SECONDS_PER_MINUTE +
      second;
  }

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

  function timestampToDateTime(uint256 timestamp)
    internal
    pure
    returns (
      uint256 year,
      uint256 month,
      uint256 day,
      uint256 hour,
      uint256 minute,
      uint256 second
    )
  {
    (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
    uint256 secs = timestamp % SECONDS_PER_DAY;
    hour = secs / SECONDS_PER_HOUR;
    secs = secs % SECONDS_PER_HOUR;
    minute = secs / SECONDS_PER_MINUTE;
    second = secs % SECONDS_PER_MINUTE;
  }

  function isValidDate(
    uint256 year,
    uint256 month,
    uint256 day
  ) internal pure returns (bool valid) {
    if (year >= 1970 && month > 0 && month <= 12) {
      uint256 daysInMonth = _getDaysInMonth(year, month);
      if (day > 0 && day <= daysInMonth) {
        valid = true;
      }
    }
  }

  function isValidDateTime(
    uint256 year,
    uint256 month,
    uint256 day,
    uint256 hour,
    uint256 minute,
    uint256 second
  ) internal pure returns (bool valid) {
    if (isValidDate(year, month, day)) {
      if (hour < 24 && minute < 60 && second < 60) {
        valid = true;
      }
    }
  }

  function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {
    (uint256 year, , ) = _daysToDate(timestamp / SECONDS_PER_DAY);
    leapYear = _isLeapYear(year);
  }

  function _isLeapYear(uint256 year) internal pure returns (bool leapYear) {
    leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
  }

  function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {
    weekDay = getDayOfWeek(timestamp) <= DOW_FRI;
  }

  function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {
    weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;
  }

  function getDaysInMonth(uint256 timestamp)
    internal
    pure
    returns (uint256 daysInMonth)
  {
    (uint256 year, uint256 month, ) = _daysToDate(timestamp / SECONDS_PER_DAY);
    daysInMonth = _getDaysInMonth(year, month);
  }

  function _getDaysInMonth(uint256 year, uint256 month)
    internal
    pure
    returns (uint256 daysInMonth)
  {
    if (
      month == 1 ||
      month == 3 ||
      month == 5 ||
      month == 7 ||
      month == 8 ||
      month == 10 ||
      month == 12
    ) {
      daysInMonth = 31;
    } else if (month != 2) {
      daysInMonth = 30;
    } else {
      daysInMonth = _isLeapYear(year) ? 29 : 28;
    }
  }

  // 1 = Monday, 7 = Sunday
  function getDayOfWeek(uint256 timestamp)
    internal
    pure
    returns (uint256 dayOfWeek)
  {
    uint256 _days = timestamp / SECONDS_PER_DAY;
    dayOfWeek = ((_days + 3) % 7) + 1;
  }

  // 1 = Monday, 7 = Sunday
  function getDayOfWeek(uint256 timestamp, uint256 index)
    internal
    pure
    returns (uint256 dayOfWeek)
  {
    uint256 _days = timestamp / SECONDS_PER_DAY;
    dayOfWeek = ((_days + index) % 7) + 1;
  }

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

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

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

  function getHour(uint256 timestamp) internal pure returns (uint256 hour) {
    uint256 secs = timestamp % SECONDS_PER_DAY;
    hour = secs / SECONDS_PER_HOUR;
  }

  function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {
    uint256 secs = timestamp % SECONDS_PER_HOUR;
    minute = secs / SECONDS_PER_MINUTE;
  }

  function getSecond(uint256 timestamp) internal pure returns (uint256 second) {
    second = timestamp % SECONDS_PER_MINUTE;
  }

  function addYears(uint256 timestamp, uint256 _years)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    (uint256 year, uint256 month, uint256 day) = _daysToDate(
      timestamp / SECONDS_PER_DAY
    );
    year += _years;
    uint256 daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp >= timestamp);
  }

  function addMonths(uint256 timestamp, uint256 _months)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    (uint256 year, uint256 month, uint256 day) = _daysToDate(
      timestamp / SECONDS_PER_DAY
    );
    month += _months;
    year += (month - 1) / 12;
    month = ((month - 1) % 12) + 1;
    uint256 daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp >= timestamp);
  }

  function addDays(uint256 timestamp, uint256 _days)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp + _days * SECONDS_PER_DAY;
    require(newTimestamp >= timestamp);
  }

  function addHours(uint256 timestamp, uint256 _hours)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;
    require(newTimestamp >= timestamp);
  }

  function addMinutes(uint256 timestamp, uint256 _minutes)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;
    require(newTimestamp >= timestamp);
  }

  function addSeconds(uint256 timestamp, uint256 _seconds)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp + _seconds;
    require(newTimestamp >= timestamp);
  }

  function subYears(uint256 timestamp, uint256 _years)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    (uint256 year, uint256 month, uint256 day) = _daysToDate(
      timestamp / SECONDS_PER_DAY
    );
    year -= _years;
    uint256 daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp <= timestamp);
  }

  function subMonths(uint256 timestamp, uint256 _months)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    (uint256 year, uint256 month, uint256 day) = _daysToDate(
      timestamp / SECONDS_PER_DAY
    );
    uint256 yearMonth = year * 12 + (month - 1) - _months;
    year = yearMonth / 12;
    month = (yearMonth % 12) + 1;
    uint256 daysInMonth = _getDaysInMonth(year, month);
    if (day > daysInMonth) {
      day = daysInMonth;
    }
    newTimestamp =
      _daysFromDate(year, month, day) *
      SECONDS_PER_DAY +
      (timestamp % SECONDS_PER_DAY);
    require(newTimestamp <= timestamp);
  }

  function subDays(uint256 timestamp, uint256 _days)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp - _days * SECONDS_PER_DAY;
    require(newTimestamp <= timestamp);
  }

  function subHours(uint256 timestamp, uint256 _hours)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;
    require(newTimestamp <= timestamp);
  }

  function subMinutes(uint256 timestamp, uint256 _minutes)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;
    require(newTimestamp <= timestamp);
  }

  function subSeconds(uint256 timestamp, uint256 _seconds)
    internal
    pure
    returns (uint256 newTimestamp)
  {
    newTimestamp = timestamp - _seconds;
    require(newTimestamp <= timestamp);
  }

  function diffYears(uint256 fromTimestamp, uint256 toTimestamp)
    internal
    pure
    returns (uint256 _years)
  {
    require(fromTimestamp <= toTimestamp);
    (uint256 fromYear, , ) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
    (uint256 toYear, , ) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
    _years = toYear - fromYear;
  }

  function diffMonths(uint256 fromTimestamp, uint256 toTimestamp)
    internal
    pure
    returns (uint256 _months)
  {
    require(fromTimestamp <= toTimestamp);
    (uint256 fromYear, uint256 fromMonth, ) = _daysToDate(
      fromTimestamp / SECONDS_PER_DAY
    );
    (uint256 toYear, uint256 toMonth, ) = _daysToDate(
      toTimestamp / SECONDS_PER_DAY
    );
    _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;
  }

  function diffDays(uint256 fromTimestamp, uint256 toTimestamp)
    internal
    pure
    returns (uint256 _days)
  {
    require(fromTimestamp <= toTimestamp);
    _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;
  }

  function diffHours(uint256 fromTimestamp, uint256 toTimestamp)
    internal
    pure
    returns (uint256 _hours)
  {
    require(fromTimestamp <= toTimestamp);
    _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;
  }

  function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp)
    internal
    pure
    returns (uint256 _minutes)
  {
    require(fromTimestamp <= toTimestamp);
    _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;
  }

  function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp)
    internal
    pure
    returns (uint256 _seconds)
  {
    require(fromTimestamp <= toTimestamp);
    _seconds = toTimestamp - fromTimestamp;
  }
}

File 25 of 31 : SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from '../interfaces/IERC20.sol';
import {SafeMath} from '@openzeppelin/contracts/utils/math/SafeMath.sol';
import {Address} from '@openzeppelin/contracts/utils/Address.sol';

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

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

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

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

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

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(
            value,
            'SafeERC20: decreased allowance below zero'
        );
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(
                token.approve.selector,
                spender,
                newAllowance
            )
        );
    }

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

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

File 26 of 31 : IOptionPricing.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IOptionPricing {
  function getOptionPrice(
    bool isPut,
    uint256 expiry,
    uint256 strike,
    uint256 lastPrice,
    uint256 baseIv
  ) external view returns (uint256);
}

File 27 of 31 : IOracle.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IOracle {
  event PriceUpdated(address asset, uint256 newPrice);

  function getPriceInUSD() external returns (uint256);

  function viewPriceInUSD() external view returns (uint256);
}

File 28 of 31 : IPriceOracleAggregator.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

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

interface IPriceOracleAggregator {
  event UpdateOracle(address token, IOracle oracle);

  function getPriceInUSD(address _token) external returns (uint256);

  function updateOracleForAsset(address _asset, IOracle _oracle) external;

  function viewPriceInUSD(address _token) external view returns (uint256);
}

File 29 of 31 : ISSOV.sol
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface ISSOV {
    function epochStrikeTokens(uint256 epoch, uint256 strike)
        external
        view
        returns (address);

    function purchase(uint256 strikeIndex, uint256 amount)
        external
        returns (uint256, uint256);

    function exercise(
        uint256 strikeIndex,
        uint256 amount,
        address user
    ) external returns (uint256, uint256);

    function getAddress(bytes32 name) external view returns (address);
}

File 30 of 31 : IStakingRewards.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

interface IStakingRewards {
  // Views
  function lastTimeRewardApplicable() external view returns (uint256);

  function rewardPerToken() external view returns (uint256, uint256);

  function earned(address account) external view returns (uint256, uint256);

  function getRewardForDuration() external view returns (uint256, uint256);

  function totalSupply() external view returns (uint256);

  function balanceOf(address account) external view returns (uint256);

  function rewardsDPX(address account) external view returns  (uint256);
  
  function compound() external;

  // Mutative

  function stake(uint256 amount) external payable;

  function withdraw(uint256 amount) external;

  function getReward(uint256 rewardsTokenID) external;

  function exit() external;

}

File 31 of 31 : IVolatilityOracle.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

interface IVolatilityOracle {
    function getVolatility() external returns (uint256);
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_dpx","type":"address"},{"internalType":"address","name":"_rdpx","type":"address"},{"internalType":"address","name":"_stakingRewards","type":"address"},{"internalType":"address","name":"_optionPricing","type":"address"},{"internalType":"address","name":"_priceOracleAggregator","type":"address"},{"internalType":"address","name":"_volatilityOracle","type":"address"},{"internalType":"address","name":"_feeDistributor","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"name","type":"bytes32"},{"indexed":true,"internalType":"address","name":"destination","type":"address"}],"name":"LogAddressSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"LogBootstrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewards","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"LogCompound","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"premiumReturned","type":"uint256"}],"name":"LogEmergencySettle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"feeKey","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LogFeesUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"LogNewDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pnl","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTouser","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeToFeeDistributor","type":"uint256"}],"name":"LogNewExercise","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"premium","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feesToUser","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeToFeeDistributor","type":"uint256"}],"name":"LogNewPurchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"}],"name":"LogNewStrike","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strike","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rdpxAmount","type":"uint256"}],"name":"LogNewWithdrawForStrike","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isVaultShutdown","type":"bool"}],"name":"LogVaultShutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"windowSizeInHours","type":"uint256"}],"name":"LogWindowSizeUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"EXERCISE_FEE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EXERCISE_FEE_CAP","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PURCHASE_FEE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PURCHASE_FEE_CAP","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"addresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bootstrap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountToCharge","type":"uint256"},{"internalType":"uint256","name":"dpxPrice","type":"uint256"},{"internalType":"bool","name":"isPurchase","type":"bool"}],"name":"calculateFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"compound","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strikeIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"strikeIndices","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"depositMultiple","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"strikeIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"emergencySettle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"strikeIndex","type":"uint256"}],"name":"emergencyWithdrawForStrike","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochStartTimes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochStrikeTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochStrikes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc20Implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strikeIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"exercise","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expireEpoch","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"fees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"getAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"getEpochStrikeTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"getEpochStrikes","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"getEpochTimes","outputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"getMonthlyExpiryFromTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"getTotalEpochCallsPurchased","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"getTotalEpochPremium","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"getTotalEpochStrikeDeposits","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getUsdPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserEpochCallsPurchased","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserEpochDeposits","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserEpochPremium","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isEpochExpired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"expiry","type":"uint256"}],"name":"isExerciseWindow","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"isVaultReady","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isVaultShutdown","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"openVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"strikeIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"purchase","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"names","type":"bytes32[]"},{"internalType":"address[]","name":"destinations","type":"address[]"}],"name":"setAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"strikes","type":"uint256[]"}],"name":"setStrikes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shutdownVault","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochCallsPurchased","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochPremium","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochStrikeBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochStrikeDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochStrikeDpxBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalEpochStrikeRdpxBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalTokenVaultExercises","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"feeKey","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"updateFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_windowSize","type":"uint256"}],"name":"updateWindowSize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"userEpochCallsPurchased","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"userEpochDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"userEpochPremium","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"viewUsdPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"windowSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"withdrawEpoch","type":"uint256"},{"internalType":"uint256","name":"strikeIndex","type":"uint256"}],"name":"withdrawForStrike","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]

60a0604052610e106002553480156200001757600080fd5b5060405162007f6138038062007f618339810160408190526200003a9162000850565b600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600160a01b038716620000bc5760405162461bcd60e51b8152602060048201526002602482015261453160f01b60448201526064015b60405180910390fd5b6001600160a01b038616620000f95760405162461bcd60e51b8152602060048201526002602482015261229960f11b6044820152606401620000b3565b6001600160a01b038516620001365760405162461bcd60e51b8152602060048201526002602482015261453360f01b6044820152606401620000b3565b6001600160a01b038416620001735760405162461bcd60e51b8152602060048201526002602482015261114d60f21b6044820152606401620000b3565b6001600160a01b038316620001b05760405162461bcd60e51b8152602060048201526002602482015261453560f01b6044820152606401620000b3565b7fe98e84802325201f1c2aa71df400acf70d292339181f1dfa34ea8c0d5fef8ff280546001600160a01b03199081166001600160a01b038481169190911790925560008051602062007f41833981519152805482168a84161790557f939e137f30f9b4f1facc727260c00ee2482b3b21191b496bae73dd4746306e21805482168984161790557f6222f7ca720cfa6b67945f0b058a94a77ee2e8ab839317d5875400c9c5c00dc1805482168884161790557f325ab4590a041c684fa78c3bf1b67cd4ef612f7acad3e441c4ba92a82df32083805482168784161790557f6c0ce3278d434a585707bbae151044d7d587448b69d9940c1bd8c9fbb4e989b2805482168684161790557fd7c655bed4862415bb75e108b9ab0bb78cf5e3f3492884ac6f9a1d56274baef280549091169184169190911790556015602052621e84807f1b71b761c69aef11537c3bdb752cdebe9ea3ea4f7f57eb41571073ec9bed961555633b9aca007ffbead0292be198213e4924506b442a6fa206487efdbc6afd506d4b85dc1c203b819055620f42407fd66611da29a2846e90b25a72c7cf30d13ce19ee6b0112077aa5f725ab6ad07f8557f23eb6c4efac516e75977cd6ab8fb1be53469dec1800af5e533a4e7811632d21a6000527f72c1cdd7e08da5b291df70686d437faf1fa50bb7218681498f0ee25e5b8bfe0b55604051620003b49062000825565b604051809103906000f080158015620003d1573d6000803e3d6000fd5b5060601b6001600160601b031916608052600360209081527f6222f7ca720cfa6b67945f0b058a94a77ee2e8ab839317d5875400c9c5c00dc15462088a0b60eb1b60005260008051602062007f41833981519152546200044f926001600160a01b03918216929190911690600019906200045c811b62003a2717901c565b50505050505050620009a5565b801580620004ea5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015620004ad57600080fd5b505afa158015620004c2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004e8919062000906565b155b6200055e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401620000b3565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152620005b6918591620005bb16565b505050565b600062000617826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166200069960201b62003b83179092919060201c565b805190915015620005b65780806020019051810190620006389190620008e4565b620005b65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620000b3565b6060620006aa8484600085620006b4565b90505b9392505050565b606082471015620007175760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620000b3565b843b620007675760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620000b3565b600080866001600160a01b031685876040516200078591906200091f565b60006040518083038185875af1925050503d8060008114620007c4576040519150601f19603f3d011682016040523d82523d6000602084013e620007c9565b606091505b509092509050620007dc828286620007e7565b979650505050505050565b60608315620007f8575081620006ad565b825115620008095782518084602001fd5b8160405162461bcd60e51b8152600401620000b391906200093d565b611f8f8062005fb283390190565b80516001600160a01b03811681146200084b57600080fd5b919050565b600080600080600080600060e0888a0312156200086b578283fd5b620008768862000833565b9650620008866020890162000833565b9550620008966040890162000833565b9450620008a66060890162000833565b9350620008b66080890162000833565b9250620008c660a0890162000833565b9150620008d660c0890162000833565b905092959891949750929550565b600060208284031215620008f6578081fd5b81518015158114620006ad578182fd5b60006020828403121562000918578081fd5b5051919050565b600082516200093381846020870162000972565b9190910192915050565b60208152600082518060208401526200095e81604085016020870162000972565b601f01601f19169190910160400192915050565b60005b838110156200098f57818101518382015260200162000975565b838111156200099f576000848401525b50505050565b60805160601c6155e7620009cb6000396000818161076e015261388801526155e76000f3fe608060405234801561001057600080fd5b50600436106103af5760003560e01c80638c2b7870116101f4578063cd653df61161011a578063e5236cc9116100ad578063f306694a1161007c578063f306694a146109e1578063f69e204614610a0c578063fa8e400514610a14578063fb969b0a14610a2757600080fd5b8063e5236cc9146109a0578063ec856816146109a8578063f0977111146109bb578063f2fde38b146109ce57600080fd5b8063d6ad2072116100e9578063d6ad207214610947578063d7e151311461095a578063d990460e1461097a578063e2bbb1581461098d57600080fd5b8063cd653df6146108ee578063cdb5661f14610901578063d3e3e35214610921578063d6379b721461093457600080fd5b8063b0f48cf711610192578063bf434b7a11610161578063bf434b7a1461088a578063c300fd64146108b5578063c3259163146108c8578063cb8d1e47146108db57600080fd5b8063b0f48cf7146107fa578063b12daf6914610825578063b595005a14610850578063b87e0efb1461087757600080fd5b8063901be041116101ce578063901be0411461076957806393c82c7514610790578063a6a1dea4146107b3578063a6fe2b9e146107da57600080fd5b80638c2b7870146107325780638da5cb5b146107455780638e143ccb1461075657600080fd5b806361560c99116102d9578063715018a611610277578063823c151211610246578063823c1512146106d657806386f54712146106f65780638990d045146106fe5780638a14117a1461072957600080fd5b8063715018a614610685578063766718081461068f578063781ed978146106985780637e36701f146106c357600080fd5b80636a778454116102b35780636a7784541461062f5780636db29f6d146106425780636f56f56f1461064a57806370876c981461067257600080fd5b806361560c99146105e05780636274d49d146105f3578063699f200f1461060657600080fd5b80632807b9a8116103515780633f83b8a5116103205780633f83b8a51461054b578063470f42241461056e5780634ab01f5b146105a25780635ba0bee1146105b557600080fd5b80632807b9a8146104ae5780632dc96c8e146104d9578063304dec3a14610504578063344afb5f1461052b57600080fd5b8063175321b81161038d578063175321b8146104355780631874979b146104495780631919e1241461047057806321f8a7211461048357600080fd5b80630258fd79146103b457806310bc629c146103f257806315943b9914610415575b600080fd5b6103df6103c2366004615028565b601460209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b610405610400366004615028565b610a2f565b60405190151581526020016103e9565b610428610423366004615010565b610a8b565b6040516103e99190615201565b60005461040590600160a01b900460ff1681565b6103df7f017840a92fa63ade139eaf1bbf69f6b3949bf8c6f5f3035c2435202bddde8d3481565b6103df61047e3660046150e3565b610b0d565b610496610491366004615010565b610cf0565b6040516001600160a01b0390911681526020016103e9565b6103df6104bc366004615028565b601160209081526000928352604080842090915290825290205481565b6103df6104e7366004615028565b600f60209081526000928352604080842090915290825290205481565b6103df7ff7a5e3d5d9379c574f5c43e29bf5bf1c0ec522d8011ad47c196cc5800d203ba681565b6103df610539366004615010565b600c6020526000908152604090205481565b610405610559366004615010565b60066020526000908152604090205460ff1681565b61049661057c366004615028565b60086020908152600092835260408084209091529082529020546001600160a01b031681565b6104056105b0366004614efa565b610d0b565b6103df6105c3366004615028565b601360209081526000928352604080842090915290825290205481565b6104286105ee366004615061565b610e69565b610428610601366004615061565b610fc5565b610496610614366004615010565b6003602052600090815260409020546001600160a01b031681565b61042861063d366004615010565b611118565b610405611241565b61065d610658366004615010565b61134e565b604080519283526020830191909152016103e9565b61065d610680366004615028565b611392565b61068d61194c565b005b6103df60015481565b6103df6106a6366004615028565b600e60209081526000928352604080842090915290825290205481565b6103df6106d1366004615028565b6119c0565b6106e96106e4366004615010565b6119f1565b6040516103e991906151b4565b610405611b32565b6103df61070c366004615028565b600d60209081526000928352604080842090915290825290205481565b6103df60025481565b610405610740366004615010565b611ba4565b6000546001600160a01b0316610496565b6103df610764366004615010565b611bc8565b6104967f000000000000000000000000000000000000000000000000000000000000000081565b61040561079e366004615010565b60056020526000908152604090205460ff1681565b6103df7f23eb6c4efac516e75977cd6ab8fb1be53469dec1800af5e533a4e7811632d21a81565b6103df6107e8366004615010565b60046020526000908152604090205481565b6103df610808366004615028565b601260209081526000928352604080842090915290825290205481565b6103df610833366004615028565b600960209081526000928352604080842090915290825290205481565b6103df7f27a2995a53386352e8f8aa016d283017e18d6c935e2be6c6f96dd30b6ab652ef81565b610405610885366004615010565b611cfc565b6103df610898366004615028565b601060209081526000928352604080842090915290825290205481565b6104286108c3366004615010565b611d68565b6104056108d6366004615010565b611e89565b6103df6108e9366004614ee0565b611edd565b6104286108fc366004615010565b611f7d565b6103df61090f366004615010565b60156020526000908152604090205481565b61040561092f366004614f62565b61209e565b61065d6109423660046150af565b612258565b610405610955366004614f94565b612700565b6103df610968366004615010565b600a6020526000908152604090205481565b6103df6109883660046150af565b6127b0565b61040561099b366004615028565b612add565b610405612e18565b6104286109b6366004615061565b612e90565b6103df6109c9366004614ee0565b612fe3565b61068d6109dc366004614ee0565b61305d565b6103df6109ef366004615028565b600b60209081526000928352604080842090915290825290205481565b610405613147565b610405610a22366004615028565b61362c565b6104056136ab565b60008281526005602052604081205460ff16610a785760405162461bcd60e51b815260206004820152600360248201526222991960e91b60448201526064015b60405180910390fd5b610a828383613b9a565b50600192915050565b606060008211610aad5760405162461bcd60e51b8152600401610a6f90615271565b60008281526007602090815260409182902080548351818402810184019094528084529091830182828015610b0157602002820191906000526020600020905b815481526020019060010190808311610aed575b50505050509050919050565b60008082610b65577ff7a5e3d5d9379c574f5c43e29bf5bf1c0ec522d8011ad47c196cc5800d203ba660005260156020527fd66611da29a2846e90b25a72c7cf30d13ce19ee6b0112077aa5f725ab6ad07f854610bb1565b7f017840a92fa63ade139eaf1bbf69f6b3949bf8c6f5f3035c2435202bddde8d3460005260156020527f1b71b761c69aef11537c3bdb752cdebe9ea3ea4f7f57eb41571073ec9bed9615545b9050600083610c0a577f23eb6c4efac516e75977cd6ab8fb1be53469dec1800af5e533a4e7811632d21a60005260156020527f72c1cdd7e08da5b291df70686d437faf1fa50bb7218681498f0ee25e5b8bfe0b54610c56565b7f27a2995a53386352e8f8aa016d283017e18d6c935e2be6c6f96dd30b6ab652ef60005260156020527ffbead0292be198213e4924506b442a6fa206487efdbc6afd506d4b85dc1c203b545b905060006402540be400610c6a848861548e565b610c7491906153f7565b905060006b204fce5e3e2502611000000087610c90858b61548e565b610c9a919061548e565b610ca491906153f7565b905080821115610cd65786610cc182670de0b6b3a764000061548e565b610ccb91906153f7565b945050505050610ce9565b86610cc183670de0b6b3a764000061548e565b9392505050565b6000908152600360205260409020546001600160a01b031690565b600080546001600160a01b03163314610d365760405162461bcd60e51b8152600401610a6f906152e5565b838214610d855760405162461bcd60e51b815260206004820152601860248201527f496e707574206c656e67746873206d757374206d6174636800000000000000006044820152606401610a6f565b60005b84811015610e5d576000868683818110610db257634e487b7160e01b600052603260045260246000fd5b9050602002013590506000858584818110610ddd57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610df29190614ee0565b60008381526003602052604080822080546001600160a01b0319166001600160a01b03851690811790915590519293509184917fa06b7cc4941a4dc0c9ee5be0e2194565cbb5a22026bedc4bc363b18140cf2a3391a350508080610e559061552f565b915050610d88565b50600195945050505050565b606060008311610e8b5760405162461bcd60e51b8152600401610a6f90615271565b60008381526007602052604081205490816001600160401b03811115610ec157634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610eea578160200160208202803683370190505b50905060005b82811015610fbc576000868152600760205260408120805483908110610f2657634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905060008682604051602001610f48929190615147565b60408051601f19818403018152918152815160209283012060008b815260138452828120828252909352912054855191925090859085908110610f9b57634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080610fb49061552f565b915050610ef0565b50949350505050565b606060008311610fe75760405162461bcd60e51b8152600401610a6f90615271565b60008381526007602052604081205490816001600160401b0381111561101d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611046578160200160208202803683370190505b50905060005b82811015610fbc57600086815260076020526040812080548390811061108257634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050600086826040516020016110a4929190615147565b60408051601f19818403018152918152815160209283012060008b8152600d84528281208282529093529120548551919250908590859081106110f757634e487b7160e01b600052603260045260246000fd5b602002602001018181525050505080806111109061552f565b91505061104c565b60606000821161113a5760405162461bcd60e51b8152600401610a6f90615271565b60008281526007602052604081205490816001600160401b0381111561117057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611199578160200160208202803683370190505b50905060005b82811015611239576000858152601060209081526040808320600790925282208054919291849081106111e257634e487b7160e01b600052603260045260246000fd5b906000526020600020015481526020019081526020016000205482828151811061121c57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806112318161552f565b91505061119f565b509392505050565b600080546001600160a01b0316331461126c5760405162461bcd60e51b8152600401610a6f906152e5565b600054600160a01b900460ff16156112965760405162461bcd60e51b8152600401610a6f9061528e565b60015460009081526005602052604090205460ff16156112dd5760405162461bcd60e51b8152602060048201526002602482015261229b60f11b6044820152606401610a6f565b60006112ea60015461134e565b9150508042116113215760405162461bcd60e51b8152602060048201526002602482015261453760f01b6044820152606401610a6f565b600180546000908152600560205260409020805460ff19168217905561134690613dea565b600191505090565b600080600083116113715760405162461bcd60e51b8152600401610a6f90615271565b60008381526004602052604090205461138981611bc8565b91509150915091565b600080548190600160a01b900460ff16156113bf5760405162461bcd60e51b8152600401610a6f9061528e565b6000600154116113e15760405162461bcd60e51b8152600401610a6f90615271565b60015460009081526007602052604090205484106114115760405162461bcd60e51b8152600401610a6f906152c8565b600083116114315760405162461bcd60e51b8152600401610a6f906152ab565b600154600090815260076020526040812080548690811061146257634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600014156114905760405162461bcd60e51b8152600401610a6f9061531a565b600033826040516020016114a5929190615147565b60405160208183030381529060405280519060200120905060006114ce62088a0b60eb1b610cf0565b905060006114db82611edd565b9050600081886114fa6c4f7074696f6e50726963696e6760981b610cf0565b6001600160a01b0316635b7b6d88600061151342611bc8565b8a886115316f566f6c6174696c6974794f7261636c6560801b610cf0565b6001600160a01b0316633af2888b6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561156b57600080fd5b505af115801561157f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a39190615049565b6040516001600160e01b031960e088901b1681529415156004860152602485019390935260448401919091526064830152608482015260a40160206040518083038186803b1580156115f457600080fd5b505afa158015611608573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162c9190615049565b611636919061548e565b61164091906153f7565b9050600061165082846001610b0d565b90506000600a61166183600361548e565b61166b91906153f7565b60015460009081526010602090815260408083208b8452909152812080549293508c9290919061169c9084906153b1565b90915550506001546000908152601160209081526040808320898452909152812080548c92906116cd9084906153b1565b909155506116dd905081836154ec565b6116e790846153b1565b60015460009081526012602090815260408083208b8452909152812080549091906117139084906153b1565b90915550611723905081836154ec565b61172d90846153b1565b60015460009081526013602090815260408083208a8452909152812080549091906117599084906153b1565b909155506117679050613147565b5061177281836154ec565b61177c90846153b1565b6001546000908152600b602090815260408083208b8452909152812080549091906117a89084906153b1565b909155506117b8905081836154ec565b6117c290846153b1565b6001546000908152600c6020526040812080549091906117e39084906153b1565b9091555061180a905033306117f885876153b1565b6001600160a01b038916929190614577565b6118386118276d2332b2a234b9ba3934b13aba37b960911b610cf0565b6001600160a01b03871690836145b5565b60015460009081526008602090815260408083208a8452909152902054611869906001600160a01b0316338c6145b5565b6118836d5374616b696e675265776172647360901b610cf0565b6001600160a01b031663a694fc3a61189b83856154ec565b6118a590866153b1565b6040518263ffffffff1660e01b81526004016118c391815260200190565b600060405180830381600087803b1580156118dd57600080fd5b505af11580156118f1573d6000803e3d6000fd5b505050507f97045e6c2fbd28852a4cd5b60059bdeaaf550f4da40c2c7373372fa8ab6c194160015488338d8787876040516119329796959493929190615337565b60405180910390a1509096509450505050505b9250929050565b6000546001600160a01b031633146119765760405162461bcd60e51b8152600401610a6f906152e5565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600760205281600052604060002081815481106119dc57600080fd5b90600052602060002001600091509150505481565b606060008211611a135760405162461bcd60e51b8152600401610a6f90615271565b60008281526007602052604081205490816001600160401b03811115611a4957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611a72578160200160208202803683370190505b50905060005b8281101561123957600085815260086020908152604080832060079092528220805491929184908110611abb57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154815260200190815260200160002060009054906101000a90046001600160a01b0316828281518110611b0857634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280611b2a8161552f565b915050611a78565b600080546001600160a01b03163314611b5d5760405162461bcd60e51b8152600401610a6f906152e5565b6000805460ff60a01b191681556040519081527f3ff7b26c9c1989d572dc980143df229d9bcd7b459794643ef88b6052eceb600f906020015b60405180910390a150600190565b600060025482611bb491906154ec565b4210158015611bc257508142105b92915050565b600080611bf2611bd7846145e5565b611be085614605565b611beb9060016153b1565b6000614617565b90506005611bff82614632565b1015611c3757611c34611c11826145e5565b611c1a83614605565b6007611c2585614666565b611c2f91906154ec565b614617565b90505b6000611c7f611c45836145e5565b611c4e84614605565b611c5785614632565b611c6086614666565b611c6b9060056153b1565b611c7591906154ec565b6008600080614678565b9050838111610ce9576000611caa611c96866145e5565b611c9f87614605565b611beb9060026153b1565b90506005611cb782614632565b1015611ccc57611cc9611c11826145e5565b90505b611cf3611cd8826145e5565b611ce183614605565b611cea84614632565b611c6085614666565b95945050505050565b600080546001600160a01b03163314611d275760405162461bcd60e51b8152600401610a6f906152e5565b60028290556040518281527f0af7f46eea9725a91be28a59af4926adbda62f127c5cb55c9619db11a94dea4a9060200160405180910390a15060015b919050565b606060008211611d8a5760405162461bcd60e51b8152600401610a6f90615271565b60008281526007602052604081205490816001600160401b03811115611dc057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611de9578160200160208202803683370190505b50905060005b8281101561123957600085815260096020908152604080832060079092528220805491929184908110611e3257634e487b7160e01b600052603260045260246000fd5b9060005260206000200154815260200190815260200160002054828281518110611e6c57634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611e818161552f565b915050611def565b60008054600160a01b900460ff16611ec95760405162461bcd60e51b815260206004820152600360248201526245323560e81b6044820152606401610a6f565b611ed560015483613b9a565b506001919050565b6000611f0074283934b1b2a7b930b1b632a0b3b3b932b3b0ba37b960591b610cf0565b604051630226614760e01b81526001600160a01b0384811660048301529190911690630226614790602401602060405180830381600087803b158015611f4557600080fd5b505af1158015611f59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bc29190615049565b606060008211611f9f5760405162461bcd60e51b8152600401610a6f90615271565b60008281526007602052604081205490816001600160401b03811115611fd557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611ffe578160200160208202803683370190505b50905060005b828110156112395760008581526012602090815260408083206007909252822080549192918490811061204757634e487b7160e01b600052603260045260246000fd5b906000526020600020015481526020019081526020016000205482828151811061208157634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806120968161552f565b915050612004565b600080546001600160a01b031633146120c95760405162461bcd60e51b8152600401610a6f906152e5565b600054600160a01b900460ff16156120f35760405162461bcd60e51b8152600401610a6f9061528e565b6000600154600161210491906153b1565b6000818152600a6020526040902054909150156121495760405162461bcd60e51b815260206004820152600360248201526245313160e81b6044820152606401610a6f565b6001541561219857600061215e60015461134e565b9150508042116121965760405162461bcd60e51b815260206004820152600360248201526222989960e91b6044820152606401610a6f565b505b600081815260076020908152604090912084516121b792860190614d8a565b5060008181526004602052604081204290555b835181101561224e577f2815fe71a8123f9bd0e2eaa1e61fc6c244707e2ad75340fa071283de5f08f0328285838151811061221557634e487b7160e01b600052603260045260246000fd5b6020026020010151604051612234929190918252602082015260400190565b60405180910390a1806122468161552f565b9150506121ca565b5060019392505050565b600080548190600160a01b900460ff16156122855760405162461bcd60e51b8152600401610a6f9061528e565b60015460006122938261134e565b91505061229f81611ba4565b6122d15760405162461bcd60e51b815260206004820152600360248201526208a62760eb1b6044820152606401610a6f565b60008281526007602052604090205487106122fe5760405162461bcd60e51b8152600401610a6f906152c8565b6000861161231e5760405162461bcd60e51b8152600401610a6f906152ab565b600082815260076020526040812080548990811061234c57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806000141561237a5760405162461bcd60e51b8152600401610a6f9061531a565b600061238e6108e962088a0b60eb1b610cf0565b90508082106123c55760405162461bcd60e51b815260206004820152600360248201526245313960e81b6044820152606401610a6f565b6001600160a01b0387166124015760405162461bcd60e51b815260206004820152600360248201526204532360ec1b6044820152606401610a6f565b6000848152600860209081526040808320858452909152908190205490516370a0823160e01b81526001600160a01b0389811660048301528a9216906370a082319060240160206040518083038186803b15801561245e57600080fd5b505afa158015612472573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124969190615049565b10156124ca5760405162461bcd60e51b815260206004820152600360248201526245323160e81b6044820152606401610a6f565b600081896124d885836154ec565b6124e2919061548e565b6124ec91906153f7565b905060006124fc82846000610b0d565b90506000600a61250d83600361548e565b61251791906153f7565b60008881526008602090815260408083208984529091529081902054905163079cc67960e41b81526001600160a01b038d81166004830152602482018f90529293509116906379cc679090604401600060405180830381600087803b15801561257f57600080fd5b505af1158015612593573d6000803e3d6000fd5b5050506000888152601460209081526040808320898452909152812080548693509091906125c29084906153b1565b9091555050600054600160a01b900460ff16612652576125f26d5374616b696e675265776172647360901b610cf0565b6001600160a01b0316632e1a7d4d846040518263ffffffff1660e01b815260040161261f91815260200190565b600060405180830381600087803b15801561263957600080fd5b505af115801561264d573d6000803e3d6000fd5b505050505b61267f8a61266084866154ec565b61266f62088a0b60eb1b610cf0565b6001600160a01b031691906145b5565b6126ac61269c6d2332b2a234b9ba3934b13aba37b960911b610cf0565b8261266f62088a0b60eb1b610cf0565b7f6ad50071b7b194cd74cdd9868f94021cfb61298ca23a686ecf5c7e644fdcb4e487868c8e8787876040516126e79796959493929190615337565b60405180910390a150909a909950975050505050505050565b600081518351146127395760405162461bcd60e51b815260206004820152600360248201526222989b60e91b6044820152606401610a6f565b60005b835181101561224e5761279d84828151811061276857634e487b7160e01b600052603260045260246000fd5b602002602001015184838151811061279057634e487b7160e01b600052603260045260246000fd5b6020026020010151612add565b50806127a88161552f565b91505061273c565b60008054600160a01b900460ff166127f05760405162461bcd60e51b815260206004820152600360248201526245323560e81b6044820152606401610a6f565b60015460008181526007602052604090205485106128205760405162461bcd60e51b8152600401610a6f906152c8565b600084116128405760405162461bcd60e51b8152600401610a6f906152ab565b600081815260076020526040812080548790811061286e57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806000141561289c5760405162461bcd60e51b8152600401610a6f9061531a565b6001600160a01b0384166128d85760405162461bcd60e51b815260206004820152600360248201526204532360ec1b6044820152606401610a6f565b6000828152600860209081526040808320848452909152908190205490516370a0823160e01b81526001600160a01b038681166004830152879216906370a082319060240160206040518083038186803b15801561293557600080fd5b505afa158015612949573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061296d9190615049565b10156129a15760405162461bcd60e51b815260206004820152600360248201526245323160e81b6044820152606401610a6f565b60008281526008602090815260408083208484529091529081902054905163079cc67960e41b81526001600160a01b03868116600483015260248201889052909116906379cc679090604401600060405180830381600087803b158015612a0757600080fd5b505af1158015612a1b573d6000803e3d6000fd5b5050505060003382604051602001612a34929190615147565b60408051808303601f19018152918152815160209283012060008681526013845282812082825290935290822080549290559150612a7c868261266f62088a0b60eb1b610cf0565b60408051858152602081018590526001600160a01b03881681830152606081018990526080810183905290517ffe78c1b9e6a078b9b6d0b33c4022a89825db55dea6be97c3c6207ce619eb729c9181900360a00190a1979650505050505050565b60008054600160a01b900460ff1615612b085760405162461bcd60e51b8152600401610a6f9061528e565b60006001546001612b1991906153b1565b60015490915015612b865760015460009081526005602052604090205460ff168015612b54575060008181526006602052604090205460ff16155b612b865760405162461bcd60e51b815260206004820152600360248201526222991b60e91b6044820152606401610a6f565b6000818152600760205260409020548410612bb35760405162461bcd60e51b8152600401610a6f906152c8565b60008311612bd35760405162461bcd60e51b8152600401610a6f906152ab565b6000818152600760205260408120805486908110612c0157634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060001415612c2f5760405162461bcd60e51b8152600401610a6f9061531a565b60003382604051602001612c44929190615147565b604051602081830303815290604052805190602001209050612c82333087612c7162088a0b60eb1b610cf0565b6001600160a01b0316929190614577565b6000838152600d6020908152604080832084845290915281208054879290612cab9084906153b1565b9091555050600083815260096020908152604080832085845290915281208054879290612cd99084906153b1565b90915550506000838152600a602052604081208054879290612cfc9084906153b1565b90915550506000838152600b6020908152604080832085845290915281208054879290612d2a9084906153b1565b90915550506000838152600c602052604081208054879290612d4d9084906153b1565b90915550612d6d90506d5374616b696e675265776172647360901b610cf0565b6001600160a01b031663a694fc3a866040518263ffffffff1660e01b8152600401612d9a91815260200190565b600060405180830381600087803b158015612db457600080fd5b505af1158015612dc8573d6000803e3d6000fd5b50506040805186815260208101869052338183015290517f69a3d39cbba81c2ebd7a5e35a14c851461f3446cf06d57380f89b7a244bb5bf29350908190036060019150a150600195945050505050565b600080546001600160a01b03163314612e435760405162461bcd60e51b8152600401610a6f906152e5565b6000805460ff60a01b1916600160a01b178155612e5f90613dea565b604051600181527f3ff7b26c9c1989d572dc980143df229d9bcd7b459794643ef88b6052eceb600f90602001611b96565b606060008311612eb25760405162461bcd60e51b8152600401610a6f90615271565b60008381526007602052604081205490816001600160401b03811115612ee857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612f11578160200160208202803683370190505b50905060005b82811015610fbc576000868152600760205260408120805483908110612f4d57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905060008682604051602001612f6f929190615147565b60408051601f19818403018152918152815160209283012060008b815260118452828120828252909352912054855191925090859085908110612fc257634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080612fdb9061552f565b915050612f17565b600061300674283934b1b2a7b930b1b632a0b3b3b932b3b0ba37b960591b610cf0565b60405163eb9d14a960e01b81526001600160a01b038481166004830152919091169063eb9d14a99060240160206040518083038186803b15801561304957600080fd5b505afa158015611f59573d6000803e3d6000fd5b6000546001600160a01b031633146130875760405162461bcd60e51b8152600401610a6f906152e5565b6001600160a01b0381166130ec5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a6f565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008054600160a01b900460ff16156131725760405162461bcd60e51b8152600401610a6f9061528e565b60015460009081526005602052604090205460ff16156131b95760405162461bcd60e51b8152602060048201526002602482015261229b60f11b6044820152606401610a6f565b60015460009081526006602052604090205460ff166132005760405162461bcd60e51b815260206004820152600360248201526245323760e81b6044820152606401610a6f565b60015461320d5750600090565b60006132296d5374616b696e675265776172647360901b610cf0565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b15801561326e57600080fd5b505afa158015613282573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132a69190615049565b6040516246613160e11b81523060048201529091506000906001600160a01b03841690628cc26290602401604080518083038186803b1580156132e857600080fd5b505afa1580156132fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613320919061508c565b509050600060076000600154815260200190815260200160002080548060200260200160405190810160405280929190818152602001828054801561338457602002820191906000526020600020905b815481526020019060010190808311613370575b5050505050905060005b81518110156134dc576001546000908152600a602090815260408083205460099092528220845183908690869081106133d757634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002054856133f9919061548e565b61340391906153f7565b905080600e60006001548152602001908152602001600020600085858151811061343d57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600082825461346291906153b1565b90915550506001546000908152600b60205260408120845183929086908690811061349d57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060008282546134c291906153b1565b909155508291506134d490508161552f565b91505061338e565b506001546000908152600c6020526040812080548492906134fe9084906153b1565b9091555050811561355d57836001600160a01b031663f69e20466040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561354457600080fd5b505af1158015613558573d6000803e3d6000fd5b505050505b6001546040516370a0823160e01b81523060048201527ff023808f96f6a68bd22b07b8d9091f94ea9280d1ebbb9631e0dda9d3689fd1e19190849086906001600160a01b038916906370a082319060240160206040518083038186803b1580156135c657600080fd5b505afa1580156135da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135fe9190615049565b60408051948552602085019390935291830152606082015260800160405180910390a1600194505050505090565b600080546001600160a01b031633146136575760405162461bcd60e51b8152600401610a6f906152e5565b60008381526015602090815260409182902084905581518581529081018490527fa0646fc9dac885ce3e0b1e4d169a6208ad836fba961a3974527cdc46d2e536fc910160405180910390a150600192915050565b600080546001600160a01b031633146136d65760405162461bcd60e51b8152600401610a6f906152e5565b600060015460016136e791906153b1565b60008181526006602052604090205490915060ff161561372e5760405162461bcd60e51b815260206004820152600260248201526108a760f31b6044820152606401610a6f565b60008181526007602052604090205461376e5760405162461bcd60e51b8152602060048201526002602482015261453960f01b6044820152606401610a6f565b600154156137bd5760015460009081526005602052604090205460ff166137bd5760405162461bcd60e51b815260206004820152600360248201526204531360ec1b6044820152606401610a6f565b60005b6000828152600760205260409020548110156139c557600082815260076020526040812080548390811061380457634e487b7160e01b600052603260045260246000fd5b906000526020600020015490506000613845604051806040016040528060088152602001671114160b50d0531360c21b815250613840846146d4565b6147ed565b905061387081604051806040016040528060078152602001662d45504f43482d60c81b8152506147ed565b905061387f81613840866146d4565b905060006138ac7f0000000000000000000000000000000000000000000000000000000000000000614819565b60405163266c45bb60e11b81529091506001600160a01b03821690634cd88b76906138dd908590819060040161524c565b600060405180830381600087803b1580156138f757600080fd5b505af115801561390b573d6000803e3d6000fd5b5050506000868152600860209081526040808320878452825280832080546001600160a01b0319166001600160a01b03871690811790915589845260098352818420888552909252918290205491516340c10f1960e01b8152306004820152602481019290925291506340c10f1990604401600060405180830381600087803b15801561399757600080fd5b505af11580156139ab573d6000803e3d6000fd5b5050505050505080806139bd9061552f565b9150506137c0565b5060008181526006602052604090819020805460ff19166001908117909155829055517f648078b14acb0e3f5c3bf89d6216dfc5c1cd4d0fb646963ef9091179ba2808cb90613a179083815260200190565b60405180910390a1600191505090565b801580613ab05750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015613a7657600080fd5b505afa158015613a8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613aae9190615049565b155b613b1b5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610a6f565b6040516001600160a01b038316602482015260448101829052613b7e90849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526148b1565b505050565b6060613b928484600085614983565b949350505050565b6000828152600760205260409020548110613bc75760405162461bcd60e51b8152600401610a6f906152c8565b6000828152600760205260408120805483908110613bf557634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060001415613c235760405162461bcd60e51b8152600401610a6f9061531a565b60003382604051602001613c38929190615147565b60408051601f1981840301815291815281516020928301206000878152600d845282812082825290935291205490915080613c9b5760405162461bcd60e51b815260206004820152600360248201526245323360e81b6044820152606401610a6f565b6000613cad630a488a0b60e31b610cf0565b60008781526009602090815260408083208884528252808320548a8452600f83528184208985529092528220549293509091613cea90859061548e565b613cf491906153f7565b90506000613d0762088a0b60eb1b610cf0565b60008981526009602090815260408083208a84528252808320548c8452600e83528184208b85529092528220549293509091613d4490879061548e565b613d4e91906153f7565b60008a8152600d602090815260408083208a84529091528120559050613d7e6001600160a01b03851633856145b5565b613d926001600160a01b03831633836145b5565b604080518a8152602081018990523381830152606081018790526080810185905290517f69cd43a7a59f690a72044810c7a53102ba8068689b6fb42c9611b7d56201acf39181900360a00190a1505050505050505050565b6000613e066d5374616b696e675265776172647360901b610cf0565b90506000613e1962088a0b60eb1b610cf0565b90506000613e2d630a488a0b60e31b610cf0565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038516906370a082319060240160206040518083038186803b158015613e7257600080fd5b505afa158015613e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eaa9190615049565b1115613f80576040516370a0823160e01b81523060048201526001600160a01b03841690632e1a7d4d9082906370a082319060240160206040518083038186803b158015613ef757600080fd5b505afa158015613f0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f2f9190615049565b6040518263ffffffff1660e01b8152600401613f4d91815260200190565b600060405180830381600087803b158015613f6757600080fd5b505af1158015613f7b573d6000803e3d6000fd5b505050505b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b158015613fc257600080fd5b505afa158015613fd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ffa9190615049565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038416906370a082319060240160206040518083038186803b15801561403f57600080fd5b505afa158015614053573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140779190615049565b604051631c4b774b60e01b8152600260048201529091506001600160a01b03861690631c4b774b90602401600060405180830381600087803b1580156140bc57600080fd5b505af11580156140d0573d6000803e3d6000fd5b50506040516370a0823160e01b81523060048201528492506001600160a01b03871691506370a082319060240160206040518083038186803b15801561411557600080fd5b505afa158015614129573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414d9190615049565b61415791906154ec565b6040516370a0823160e01b815230600482015290925081906001600160a01b038516906370a082319060240160206040518083038186803b15801561419b57600080fd5b505afa1580156141af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141d39190615049565b6141dd91906154ec565b6001546000908152600c60205260409020549091501561456f5760015460009081526007602090815260408083208054825181850281018501909352808352919290919083018282801561425057602002820191906000526020600020905b81548152602001906001019080831161423c575b5050505050905060005b815181101561456c576001546000908152600c6020908152604080832054600b9092528220845183908690869081106142a357634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002054866142c5919061548e565b6142cf91906153f7565b9050601460006001548152602001908152602001600020600084848151811061430857634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205481600960006001548152602001908152602001600020600086868151811061435757634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205461437891906153b1565b61438291906154ec565b600e6000600154815260200190815260200160002060008585815181106143b957634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060008282546143de91906153b1565b9091555050881561449957601260006001548152602001908152602001600020600084848151811061442057634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002054600e60006001548152602001908152602001600020600085858151811061446e57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020600082825461449391906153b1565b90915550505b6001546000908152600c6020908152604080832054600b90925282208551919290918690869081106144db57634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002054856144fd919061548e565b61450791906153f7565b600f60006001548152602001908152602001600020600085858151811061453e57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055505080806145649061552f565b91505061425a565b50505b505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526145af9085906323b872dd60e01b90608401613b47565b50505050565b6040516001600160a01b038316602482015260448101829052613b7e90849063a9059cbb60e01b90606401613b47565b60006145fc6145f762015180846153f7565b614aa0565b50909392505050565b60006112396145f762015180846153f7565b600062015180614628858585614c14565b613b92919061548e565b60008061464262015180846153f7565b905060076146518260036153b1565b61465b919061554a565b610ce99060016153b1565b6000613b926145f762015180846153f7565b600081614686603c8561548e565b614692610e108761548e565b620151806146a18b8b8b614c14565b6146ab919061548e565b6146b591906153b1565b6146bf91906153b1565b6146c991906153b1565b979650505050505050565b6060816146f85750506040805180820190915260018152600360fc1b602082015290565b8160005b8115614722578061470c8161552f565b915061471b9050600a836153f7565b91506146fc565b6000816001600160401b0381111561474a57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614774576020820181803683370190505b5090505b8415613b92576147896001836154ec565b9150614796600a8661554a565b6147a19060306153b1565b60f81b8183815181106147c457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506147e6600a866153f7565b9450614778565b60608282604051602001614802929190615185565b604051602081830303815290604052905092915050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b038116611d635760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610a6f565b6000614906826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613b839092919063ffffffff16565b805190915015613b7e57808060200190518101906149249190614ff4565b613b7e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a6f565b6060824710156149e45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a6f565b843b614a325760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a6f565b600080866001600160a01b03168587604051614a4e9190615169565b60006040518083038185875af1925050503d8060008114614a8b576040519150601f19603f3d011682016040523d82523d6000602084013e614a90565b606091505b50915091506146c9828286614d51565b60008080838162253d8c614ab78362010bd9615370565b614ac19190615370565b9050600062023ab1614ad483600461540b565b614ade91906153c9565b90506004614aef8262023ab161540b565b614afa906003615370565b614b0491906153c9565b614b0e90836154ad565b9150600062164b09614b21846001615370565b614b2d90610fa061540b565b614b3791906153c9565b90506004614b47826105b561540b565b614b5191906153c9565b614b5b90846154ad565b614b6690601f615370565b9250600061098f614b7885605061540b565b614b8291906153c9565b905060006050614b948361098f61540b565b614b9e91906153c9565b614ba890866154ad565b9050614bb5600b836153c9565b9450614bc285600c61540b565b614bcd836002615370565b614bd791906154ad565b91508483614be66031876154ad565b614bf190606461540b565b614bfb9190615370565b614c059190615370565b9a919950975095505050505050565b60006107b2841015614c2557600080fd5b838383600062253d8c60046064600c614c3f600e886154ad565b614c4991906153c9565b614c5588611324615370565b614c5f9190615370565b614c6991906153c9565b614c7490600361540b565b614c7e91906153c9565b600c80614c8c600e886154ad565b614c9691906153c9565b614ca190600c61540b565b614cac6002886154ad565b614cb691906154ad565b614cc29061016f61540b565b614ccc91906153c9565b6004600c614cdb600e896154ad565b614ce591906153c9565b614cf1896112c0615370565b614cfb9190615370565b614d07906105b561540b565b614d1191906153c9565b614d1d617d4b876154ad565b614d279190615370565b614d319190615370565b614d3b91906154ad565b614d4591906154ad565b98975050505050505050565b60608315614d60575081610ce9565b825115614d705782518084602001fd5b8160405162461bcd60e51b8152600401610a6f9190615239565b828054828255906000526020600020908101928215614dc5579160200282015b82811115614dc5578251825591602001919060010190614daa565b50614dd1929150614dd5565b5090565b5b80821115614dd15760008155600101614dd6565b80356001600160a01b0381168114611d6357600080fd5b60008083601f840112614e12578081fd5b5081356001600160401b03811115614e28578182fd5b6020830191508360208260051b850101111561194557600080fd5b600082601f830112614e53578081fd5b813560206001600160401b0380831115614e6f57614e6f61558a565b8260051b604051601f19603f83011681018181108482111715614e9457614e9461558a565b60405284815283810192508684018288018501891015614eb2578687fd5b8692505b85831015614ed4578035845292840192600192909201918401614eb6565b50979650505050505050565b600060208284031215614ef1578081fd5b610ce982614dea565b60008060008060408587031215614f0f578283fd5b84356001600160401b0380821115614f25578485fd5b614f3188838901614e01565b90965094506020870135915080821115614f49578384fd5b50614f5687828801614e01565b95989497509550505050565b600060208284031215614f73578081fd5b81356001600160401b03811115614f88578182fd5b613b9284828501614e43565b60008060408385031215614fa6578182fd5b82356001600160401b0380821115614fbc578384fd5b614fc886838701614e43565b93506020850135915080821115614fdd578283fd5b50614fea85828601614e43565b9150509250929050565b600060208284031215615005578081fd5b8151610ce9816155a0565b600060208284031215615021578081fd5b5035919050565b6000806040838503121561503a578182fd5b50508035926020909101359150565b60006020828403121561505a578081fd5b5051919050565b60008060408385031215615073578182fd5b8235915061508360208401614dea565b90509250929050565b6000806040838503121561509e578182fd5b505080516020909101519092909150565b6000806000606084860312156150c3578283fd5b83359250602084013591506150da60408501614dea565b90509250925092565b6000806000606084860312156150f7578081fd5b83359250602084013591506040840135615110816155a0565b809150509250925092565b60008151808452615133816020860160208601615503565b601f01601f19169290920160200192915050565b60609290921b6bffffffffffffffffffffffff19168252601482015260340190565b6000825161517b818460208701615503565b9190910192915050565b60008351615197818460208801615503565b8351908301906151ab818360208801615503565b01949350505050565b6020808252825182820181905260009190848201906040850190845b818110156151f55783516001600160a01b0316835292840192918401916001016151d0565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156151f55783518352928401929184019160010161521d565b602081526000610ce9602083018461511b565b60408152600061525f604083018561511b565b8281036020840152611cf3818561511b565b60208082526003908201526245313760e81b604082015260600190565b602080825260039082015262114c8d60ea1b604082015260600190565b602080825260039082015262114c4d60ea1b604082015260600190565b60208082526003908201526245313360e81b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526003908201526245313560e81b604082015260600190565b96875260208701959095526001600160a01b039390931660408601526060850191909152608084015260a083015260c082015260e00190565b600080821280156001600160ff1b03849003851316156153925761539261555e565b600160ff1b83900384128116156153ab576153ab61555e565b50500190565b600082198211156153c4576153c461555e565b500190565b6000826153d8576153d8615574565b600160ff1b8214600019841416156153f2576153f261555e565b500590565b60008261540657615406615574565b500490565b60006001600160ff1b03818413828413808216868404861116156154315761543161555e565b600160ff1b8487128281168783058912161561544f5761544f61555e565b85871292508782058712848416161561546a5761546a61555e565b878505871281841616156154805761548061555e565b505050929093029392505050565b60008160001904831182151516156154a8576154a861555e565b500290565b60008083128015600160ff1b8501841216156154cb576154cb61555e565b6001600160ff1b03840183138116156154e6576154e661555e565b50500390565b6000828210156154fe576154fe61555e565b500390565b60005b8381101561551e578181015183820152602001615506565b838111156145af5750506000910152565b60006000198214156155435761554361555e565b5060010190565b60008261555957615559615574565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146155ae57600080fd5b5056fea264697066735822122068aa4ffd01e617d15edba66647281c64af5b84db33445bcb80f3d3d755ef900f64736f6c63430008040033608060405234801561001057600080fd5b50611f6f806100206000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80635c975abb11610104578063a217fddf116100a2578063d539139311610071578063d5391393146103ce578063d547741f146103f5578063dd62ed3e14610408578063e63ab1e91461044157600080fd5b8063a217fddf1461038d578063a457c2d714610395578063a9059cbb146103a8578063ca15c873146103bb57600080fd5b80638456cb59116100de5780638456cb591461033f5780639010d07c1461034757806391d148541461037257806395d89b411461038557600080fd5b80635c975abb146102f757806370a082311461030357806379cc67901461032c57600080fd5b8063313ce567116101715780633f4ba83a1161014b5780633f4ba83a146102b657806340c10f19146102be57806342966c68146102d15780634cd88b76146102e457600080fd5b8063313ce5671461028157806336568abe1461029057806339509351146102a357600080fd5b806318160ddd116101ad57806318160ddd1461022457806323b872dd14610236578063248a9ca3146102495780632f2ff15d1461026c57600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063095ea7b314610211575b600080fd5b6101e76101e2366004611c9e565b610456565b60405190151581526020015b60405180910390f35b610204610481565b6040516101f39190611d9c565b6101e761021f366004611c1a565b610513565b60cb545b6040519081526020016101f3565b6101e7610244366004611bdf565b610529565b610228610257366004611c43565b60009081526065602052604090206001015490565b61027f61027a366004611c5b565b6105df565b005b604051601281526020016101f3565b61027f61029e366004611c5b565b610606565b6101e76102b1366004611c1a565b610628565b61027f61065f565b61027f6102cc366004611c1a565b6106f3565b61027f6102df366004611c43565b610796565b61027f6102f2366004611cc6565b6107a3565b61012d5460ff166101e7565b610228610311366004611b93565b6001600160a01b0316600090815260c9602052604090205490565b61027f61033a366004611c1a565b61081a565b61027f61089d565b61035a610355366004611c7d565b61092f565b6040516001600160a01b0390911681526020016101f3565b6101e7610380366004611c5b565b61094e565b610204610979565b610228600081565b6101e76103a3366004611c1a565b610988565b6101e76103b6366004611c1a565b610a23565b6102286103c9366004611c43565b610a30565b6102287f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b61027f610403366004611c5b565b610a47565b610228610416366004611bad565b6001600160a01b03918216600090815260ca6020908152604080832093909416825291909152205490565b610228600080516020611f1a83398151915281565b60006001600160e01b03198216635a05180f60e01b148061047b575061047b82610a51565b92915050565b606060cc805461049090611eb2565b80601f01602080910402602001604051908101604052809291908181526020018280546104bc90611eb2565b80156105095780601f106104de57610100808354040283529160200191610509565b820191906000526020600020905b8154815290600101906020018083116104ec57829003601f168201915b5050505050905090565b6000610520338484610a86565b50600192915050565b6000610536848484610bab565b6001600160a01b038416600090815260ca60209081526040808320338452909152902054828110156105c05760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6105d485336105cf8685611e54565b610a86565b506001949350505050565b6105e98282610d8e565b60008281526097602052604090206106019082610db4565b505050565b6106108282610dc9565b60008281526097602052604090206106019082610e43565b33600081815260ca602090815260408083206001600160a01b038716845290915281205490916105209185906105cf908690611e1d565b610677600080516020611f1a8339815191523361094e565b6106e95760405162461bcd60e51b815260206004820152603960248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f20756e70617573650000000000000060648201526084016105b7565b6106f1610e58565b565b61071d7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a63361094e565b6107885760405162461bcd60e51b815260206004820152603660248201527f45524332305072657365744d696e7465725061757365723a206d7573742068616044820152751d99481b5a5b9d195c881c9bdb19481d1bc81b5a5b9d60521b60648201526084016105b7565b6107928282610eed565b5050565b6107a03382610fd8565b50565b600054610100900460ff16806107bc575060005460ff16155b6107d85760405162461bcd60e51b81526004016105b790611dcf565b600054610100900460ff161580156107fa576000805461ffff19166101011790555b6108048383611133565b8015610601576000805461ff0019169055505050565b60006108268333610416565b9050818110156108845760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b60648201526084016105b7565b61089383336105cf8585611e54565b6106018383610fd8565b6108b5600080516020611f1a8339815191523361094e565b6109275760405162461bcd60e51b815260206004820152603760248201527f45524332305072657365744d696e7465725061757365723a206d75737420686160448201527f76652070617573657220726f6c6520746f20706175736500000000000000000060648201526084016105b7565b6106f16111d6565b60008281526097602052604081206109479083611253565b9392505050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060cd805461049090611eb2565b33600090815260ca602090815260408083206001600160a01b038616845290915281205482811015610a0a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016105b7565b610a1933856105cf8685611e54565b5060019392505050565b6000610520338484610bab565b600081815260976020526040812061047b9061125f565b6106108282611269565b60006001600160e01b03198216637965db0b60e01b148061047b57506301ffc9a760e01b6001600160e01b031983161461047b565b6001600160a01b038316610ae85760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105b7565b6001600160a01b038216610b495760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105b7565b6001600160a01b03838116600081815260ca602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316610c0f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105b7565b6001600160a01b038216610c715760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105b7565b610c7c83838361128f565b6001600160a01b038316600090815260c9602052604090205481811015610cf45760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016105b7565b610cfe8282611e54565b6001600160a01b03808616600090815260c960205260408082209390935590851681529081208054849290610d34908490611e1d565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610d8091815260200190565b60405180910390a350505050565b600082815260656020526040902060010154610daa813361129a565b61060183836112fe565b6000610947836001600160a01b038416611384565b6001600160a01b0381163314610e395760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016105b7565b61079282826113d3565b6000610947836001600160a01b03841661143a565b61012d5460ff16610ea25760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105b7565b61012d805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b038216610f435760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016105b7565b610f4f6000838361128f565b8060cb6000828254610f619190611e1d565b90915550506001600160a01b038216600090815260c9602052604081208054839290610f8e908490611e1d565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b0382166110385760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016105b7565b6110448260008361128f565b6001600160a01b038216600090815260c96020526040902054818110156110b85760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016105b7565b6110c28282611e54565b6001600160a01b038416600090815260c9602052604081209190915560cb80548492906110f0908490611e54565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610b9e565b600054610100900460ff168061114c575060005460ff16155b6111685760405162461bcd60e51b81526004016105b790611dcf565b600054610100900460ff1615801561118a576000805461ffff19166101011790555b611192611551565b61119a611551565b6111a2611551565b6111aa611551565b6111b483836115bc565b6111bc611551565b6111c4611651565b6111cc611551565b61080483836116c7565b61012d5460ff161561121d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016105b7565b61012d805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610ed03390565b6000610947838361176b565b600061047b825490565b600082815260656020526040902060010154611285813361129a565b61060183836113d3565b6106018383836117ff565b6112a4828261094e565b610792576112bc816001600160a01b03166014611866565b6112c7836020611866565b6040516020016112d8929190611d27565b60408051601f198184030181529082905262461bcd60e51b82526105b791600401611d9c565b611308828261094e565b6107925760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556113403390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008181526001830160205260408120546113cb5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561047b565b50600061047b565b6113dd828261094e565b156107925760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000818152600183016020526040812054801561154757600061145e600183611e54565b855490915060009061147290600190611e54565b9050600086600001828154811061149957634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106114ca57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526001890190915260409020849055865487908061150b57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061047b565b600091505061047b565b600054610100900460ff168061156a575060005460ff16155b6115865760405162461bcd60e51b81526004016105b790611dcf565b600054610100900460ff161580156115a8576000805461ffff19166101011790555b80156107a0576000805461ff001916905550565b600054610100900460ff16806115d5575060005460ff16155b6115f15760405162461bcd60e51b81526004016105b790611dcf565b600054610100900460ff16158015611613576000805461ffff19166101011790555b82516116269060cc906020860190611a57565b50815161163a9060cd906020850190611a57565b508015610601576000805461ff0019169055505050565b600054610100900460ff168061166a575060005460ff16155b6116865760405162461bcd60e51b81526004016105b790611dcf565b600054610100900460ff161580156116a8576000805461ffff19166101011790555b61012d805460ff1916905580156107a0576000805461ff001916905550565b600054610100900460ff16806116e0575060005460ff16155b6116fc5760405162461bcd60e51b81526004016105b790611dcf565b600054610100900460ff1615801561171e576000805461ffff19166101011790555b611729600033611a48565b6117537f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a633611a48565b610804600080516020611f1a83398151915233611a48565b815460009082106117c95760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b60648201526084016105b7565b8260000182815481106117ec57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b61012d5460ff16156106015760405162461bcd60e51b815260206004820152602a60248201527f45524332305061757361626c653a20746f6b656e207472616e736665722077686044820152691a5b19481c185d5cd95960b21b60648201526084016105b7565b60606000611875836002611e35565b611880906002611e1d565b67ffffffffffffffff8111156118a657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156118d0576020820181803683370190505b509050600360fc1b816000815181106118f957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061193657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061195a846002611e35565b611965906001611e1d565b90505b60018111156119f9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106119a757634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106119cb57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936119f281611e9b565b9050611968565b5083156109475760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016105b7565b6105e9828261079282826112fe565b828054611a6390611eb2565b90600052602060002090601f016020900481019282611a855760008555611acb565b82601f10611a9e57805160ff1916838001178555611acb565b82800160010185558215611acb579182015b82811115611acb578251825591602001919060010190611ab0565b50611ad7929150611adb565b5090565b5b80821115611ad75760008155600101611adc565b80356001600160a01b0381168114611b0757600080fd5b919050565b600082601f830112611b1c578081fd5b813567ffffffffffffffff80821115611b3757611b37611f03565b604051601f8301601f19908116603f01168101908282118183101715611b5f57611b5f611f03565b81604052838152866020858801011115611b77578485fd5b8360208701602083013792830160200193909352509392505050565b600060208284031215611ba4578081fd5b61094782611af0565b60008060408385031215611bbf578081fd5b611bc883611af0565b9150611bd660208401611af0565b90509250929050565b600080600060608486031215611bf3578081fd5b611bfc84611af0565b9250611c0a60208501611af0565b9150604084013590509250925092565b60008060408385031215611c2c578182fd5b611c3583611af0565b946020939093013593505050565b600060208284031215611c54578081fd5b5035919050565b60008060408385031215611c6d578182fd5b82359150611bd660208401611af0565b60008060408385031215611c8f578182fd5b50508035926020909101359150565b600060208284031215611caf578081fd5b81356001600160e01b031981168114610947578182fd5b60008060408385031215611cd8578182fd5b823567ffffffffffffffff80821115611cef578384fd5b611cfb86838701611b0c565b93506020850135915080821115611d10578283fd5b50611d1d85828601611b0c565b9150509250929050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611d5f816017850160208801611e6b565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351611d90816028840160208801611e6b565b01602801949350505050565b6020815260008251806020840152611dbb816040850160208701611e6b565b601f01601f19169190910160400192915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60008219821115611e3057611e30611eed565b500190565b6000816000190483118215151615611e4f57611e4f611eed565b500290565b600082821015611e6657611e66611eed565b500390565b60005b83811015611e86578181015183820152602001611e6e565b83811115611e95576000848401525b50505050565b600081611eaa57611eaa611eed565b506000190190565b600181811c90821680611ec657607f821691505b60208210811415611ee757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfe65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aa2646970667358221220d336cd65edd0c4aa5028b35407216fb74d1a0d4b29682c6d07f8491a84222f5964736f6c6343000804003311eeda5ccce3b038d4c97ce3441d2387ea2908f4416997212badd7e59dd2ac640000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee5500000000000000000000000032eb7902d4134bf98a28b963d26de779af92a212000000000000000000000000c6d714170fe766691670f12c2b45c1f34405aab60000000000000000000000002b99e3d67dad973c1b9747da742b7e26c8bdd67b00000000000000000000000074cadbdf7850abd4f9bd355e528a9b23a2d334b4000000000000000000000000b6645813567bb5beea8f62e793d075fe6d3be0b100000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c1

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

0000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee5500000000000000000000000032eb7902d4134bf98a28b963d26de779af92a212000000000000000000000000c6d714170fe766691670f12c2b45c1f34405aab60000000000000000000000002b99e3d67dad973c1b9747da742b7e26c8bdd67b00000000000000000000000074cadbdf7850abd4f9bd355e528a9b23a2d334b4000000000000000000000000b6645813567bb5beea8f62e793d075fe6d3be0b100000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c1

-----Decoded View---------------
Arg [0] : _dpx (address): 0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55
Arg [1] : _rdpx (address): 0x32eb7902d4134bf98a28b963d26de779af92a212
Arg [2] : _stakingRewards (address): 0xc6d714170fe766691670f12c2b45c1f34405aab6
Arg [3] : _optionPricing (address): 0x2b99e3d67dad973c1b9747da742b7e26c8bdd67b
Arg [4] : _priceOracleAggregator (address): 0x74cadbdf7850abd4f9bd355e528a9b23a2d334b4
Arg [5] : _volatilityOracle (address): 0xb6645813567bb5beea8f62e793d075fe6d3be0b1
Arg [6] : _feeDistributor (address): 0x55594cce8cc0014ea08c49fd820d731308f204c1

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000006c2c06790b3e3e3c38e12ee22f8183b37a13ee55
Arg [1] : 00000000000000000000000032eb7902d4134bf98a28b963d26de779af92a212
Arg [2] : 000000000000000000000000c6d714170fe766691670f12c2b45c1f34405aab6
Arg [3] : 0000000000000000000000002b99e3d67dad973c1b9747da742b7e26c8bdd67b
Arg [4] : 00000000000000000000000074cadbdf7850abd4f9bd355e528a9b23a2d334b4
Arg [5] : 000000000000000000000000b6645813567bb5beea8f62e793d075fe6d3be0b1
Arg [6] : 00000000000000000000000055594cce8cc0014ea08c49fd820d731308f204c1


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.